From cee5b1ee42a7135b1e98fe502f6a2bd4ec928fce Mon Sep 17 00:00:00 2001 From: Myles Date: Sat, 26 Mar 2016 15:55:13 +0000 Subject: [PATCH] Improve the patch to check the pipe and to handle above head placement. --- .../listeners/PaperPatch.java | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/listeners/PaperPatch.java b/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/listeners/PaperPatch.java index fdb160468..49c230ca3 100644 --- a/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/listeners/PaperPatch.java +++ b/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/listeners/PaperPatch.java @@ -1,8 +1,14 @@ package us.myles.ViaVersion.protocols.protocol1_9to1_8.listeners; +import org.bukkit.block.BlockFace; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.block.BlockPlaceEvent; +import us.myles.ViaVersion.ViaVersionPlugin; +import us.myles.ViaVersion.api.ViaVersion; +import us.myles.ViaVersion.api.data.UserConnection; +import us.myles.ViaVersion.protocols.base.ProtocolInfo; +import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9TO1_8; public class PaperPatch implements Listener { @@ -15,8 +21,18 @@ public class PaperPatch implements Listener { @EventHandler(ignoreCancelled = true) public void onPlace(BlockPlaceEvent e) { - if (e.getPlayer().getLocation().getBlock().equals(e.getBlock())) { - e.setCancelled(true); + if (ViaVersion.getInstance().isPorted(e.getPlayer())) { + UserConnection userConnection = ((ViaVersionPlugin) ViaVersion.getInstance()).getConnection(e.getPlayer()); + if (userConnection == null) return; + if (!userConnection.get(ProtocolInfo.class).getPipeline().contains(Protocol1_9TO1_8.class)) return; + + if (e.getPlayer().getLocation().getBlock().equals(e.getBlock())) { + e.setCancelled(true); + } else { + if (e.getPlayer().getLocation().getBlock().getRelative(BlockFace.DOWN).equals(e.getBlock())) { + e.setCancelled(true); + } + } } } }