Fixes an issue with boats

Signed-off-by: matt <4009945+MattBDev@users.noreply.github.com>
This commit is contained in:
matt 2019-03-07 18:38:21 -05:00
parent 56c24a6a56
commit 1d327ec346

View File

@ -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()) {