Skip to content

Commit 629646a

Browse files
fix: cancel structure locate in classic plot worlds (#4653)
1 parent 74a1a1f commit 629646a

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import com.destroystokyo.paper.event.server.AsyncTabCompleteEvent;
3030
import com.google.inject.Inject;
3131
import com.plotsquared.bukkit.util.BukkitUtil;
32+
import com.plotsquared.core.PlotSquared;
3233
import com.plotsquared.core.command.Command;
3334
import com.plotsquared.core.command.MainCommand;
3435
import com.plotsquared.core.configuration.Settings;
@@ -38,6 +39,7 @@
3839
import com.plotsquared.core.player.PlotPlayer;
3940
import com.plotsquared.core.plot.Plot;
4041
import com.plotsquared.core.plot.PlotArea;
42+
import com.plotsquared.core.plot.PlotAreaType;
4143
import com.plotsquared.core.plot.flag.FlagContainer;
4244
import com.plotsquared.core.plot.flag.implementations.BeaconEffectsFlag;
4345
import com.plotsquared.core.plot.flag.implementations.DoneFlag;
@@ -48,6 +50,7 @@
4850
import com.plotsquared.core.plot.world.PlotAreaManager;
4951
import com.plotsquared.core.util.PlotFlagUtil;
5052
import io.papermc.paper.event.entity.EntityMoveEvent;
53+
import io.papermc.paper.event.world.StructuresLocateEvent;
5154
import net.kyori.adventure.text.Component;
5255
import net.kyori.adventure.text.minimessage.tag.Tag;
5356
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
@@ -458,6 +461,21 @@ public void onBeaconEffect(final BeaconEffectEvent event) {
458461
}
459462
}
460463

464+
/**
465+
* Don't let the server die when populating cartographers (villager offering maps) in classic plot worlds
466+
* (as those don't generate POIs)
467+
*/
468+
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
469+
public void onStructuresLocate(StructuresLocateEvent event) {
470+
if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(event.getWorld().getName())) {
471+
return;
472+
}
473+
final PlotArea area = PlotSquared.get().getPlotAreaManager().getPlotAreaByString(event.getWorld().getName());
474+
if (area != null && area.getType() == PlotAreaType.NORMAL) {
475+
event.setCancelled(true);
476+
}
477+
}
478+
461479
private boolean getBooleanFlagValue(
462480
@NonNull FlagContainer container,
463481
@NonNull Class<? extends BooleanFlag<?>> flagClass,

0 commit comments

Comments
 (0)