From 1d327ec3464024563e715ba721f70e6d9cee0725 Mon Sep 17 00:00:00 2001 From: matt <4009945+MattBDev@users.noreply.github.com> Date: Thu, 7 Mar 2019 18:38:21 -0500 Subject: [PATCH] Fixes an issue with boats Signed-off-by: matt <4009945+MattBDev@users.noreply.github.com> --- .../bukkit/listeners/PlayerEvents.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents.java index 5812e4e27..adadc2e55 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents.java @@ -35,6 +35,7 @@ import org.bukkit.event.inventory.InventoryCloseEvent; import org.bukkit.event.player.*; import org.bukkit.event.vehicle.VehicleCreateEvent; import org.bukkit.event.vehicle.VehicleDestroyEvent; +import org.bukkit.event.vehicle.VehicleEntityCollisionEvent; import org.bukkit.event.vehicle.VehicleMoveEvent; import org.bukkit.event.world.StructureGrowEvent; import org.bukkit.help.HelpTopic; @@ -235,6 +236,33 @@ import java.util.regex.Pattern; } } + @EventHandler public void onVehicleEntityCollision(VehicleEntityCollisionEvent e) { + if (e.getVehicle().getType() == EntityType.BOAT) { + Location location = BukkitUtil.getLocation(e.getEntity()); + if (location.getPlotArea() == null) { + //we don't care about events that happen outside of a plot area. + return; + } + if (e.getEntity() instanceof Player) { + PlotPlayer player = BukkitUtil.getPlayer((Player) e.getEntity()); + Plot plot = player.getCurrentPlot(); + if (plot != null) { + if (!plot.isAdded(player.getUUID())) { + //Here the event is only canceled if the player is not the owner + //of the property on which he is located. + e.setCancelled(true); + } + } else { + e.setCancelled(true); + } + } else { + //Here the event is cancelled too, otherwise you can move the + //boat with EchoPets or other mobs running around on the plot. + e.setCancelled(true); + } + } + } + @EventHandler public void onRedstoneEvent(BlockRedstoneEvent event) { Block block = event.getBlock(); /* switch (block.getType()) {