|
29 | 29 | import com.destroystokyo.paper.event.server.AsyncTabCompleteEvent; |
30 | 30 | import com.google.inject.Inject; |
31 | 31 | import com.plotsquared.bukkit.util.BukkitUtil; |
| 32 | +import com.plotsquared.core.PlotSquared; |
32 | 33 | import com.plotsquared.core.command.Command; |
33 | 34 | import com.plotsquared.core.command.MainCommand; |
34 | 35 | import com.plotsquared.core.configuration.Settings; |
|
38 | 39 | import com.plotsquared.core.player.PlotPlayer; |
39 | 40 | import com.plotsquared.core.plot.Plot; |
40 | 41 | import com.plotsquared.core.plot.PlotArea; |
| 42 | +import com.plotsquared.core.plot.PlotAreaType; |
41 | 43 | import com.plotsquared.core.plot.flag.FlagContainer; |
42 | 44 | import com.plotsquared.core.plot.flag.implementations.BeaconEffectsFlag; |
43 | 45 | import com.plotsquared.core.plot.flag.implementations.DoneFlag; |
|
48 | 50 | import com.plotsquared.core.plot.world.PlotAreaManager; |
49 | 51 | import com.plotsquared.core.util.PlotFlagUtil; |
50 | 52 | import io.papermc.paper.event.entity.EntityMoveEvent; |
| 53 | +import io.papermc.paper.event.world.StructuresLocateEvent; |
51 | 54 | import net.kyori.adventure.text.Component; |
52 | 55 | import net.kyori.adventure.text.minimessage.tag.Tag; |
53 | 56 | import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver; |
@@ -458,6 +461,21 @@ public void onBeaconEffect(final BeaconEffectEvent event) { |
458 | 461 | } |
459 | 462 | } |
460 | 463 |
|
| 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 | + |
461 | 479 | private boolean getBooleanFlagValue( |
462 | 480 | @NonNull FlagContainer container, |
463 | 481 | @NonNull Class<? extends BooleanFlag<?>> flagClass, |
|
0 commit comments