mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 05:06:44 +01:00
Cancel boat placement on interactable blocks, fixes PS-175 (#2934)
* Cancel boat placement on interactable blocks, fixes PS-175 * Keep boat protection for old game versions Co-authored-by: NotMyFault <mc.cache@web.de>
This commit is contained in:
parent
ef95334fe6
commit
585111ca38
@ -85,6 +85,7 @@ import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.Waterlogged;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Boat;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
@ -100,6 +101,7 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.entity.EntityPickupItemEvent;
|
||||
import org.bukkit.event.entity.EntityPlaceEvent;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
|
||||
import org.bukkit.event.hanging.HangingPlaceEvent;
|
||||
@ -1068,6 +1070,34 @@ public class PlayerEventListener extends PlotListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
// Boats can sometimes be placed on interactable blocks such as levers,
|
||||
// see PS-175. Armor stands, minecarts and end crystals (the other entities
|
||||
// supported by this event) don't have this issue.
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onBoatPlace(EntityPlaceEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
Entity placed = event.getEntity();
|
||||
if (!(placed instanceof Boat)) {
|
||||
return;
|
||||
}
|
||||
BukkitPlayer pp = BukkitUtil.getPlayer(player);
|
||||
PlotArea area = pp.getPlotAreaAbs();
|
||||
if (area == null) {
|
||||
return;
|
||||
}
|
||||
PlayerBlockEventType eventType = PlayerBlockEventType.PLACE_VEHICLE;
|
||||
Block block = event.getBlock();
|
||||
BlockType blockType = BukkitAdapter.asBlockType(block.getType());
|
||||
Location location = BukkitUtil.getLocation(block.getLocation());
|
||||
if (!PlotSquared.get().getEventDispatcher()
|
||||
.checkPlayerBlockEvent(pp, eventType, location, blockType, true)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onBucketEmpty(PlayerBucketEmptyEvent event) {
|
||||
BlockFace bf = event.getBlockFace();
|
||||
|
Loading…
Reference in New Issue
Block a user