From cb0043600d68d64a1558213c8928e7508a0556fd Mon Sep 17 00:00:00 2001 From: Nick Porillo Date: Tue, 12 May 2015 12:08:42 -0400 Subject: [PATCH] Adds LiquidFlow exploit handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit “hand” merged from HCF. Adds option in conf.json that defaults to false which if enabled will prevent liquid from flowing between into other factions if it shouldn’t. --- .../java/com/massivecraft/factions/Conf.java | 1 + .../listeners/FactionsBlockListener.java | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/main/java/com/massivecraft/factions/Conf.java b/src/main/java/com/massivecraft/factions/Conf.java index a3d76791..be72beaf 100644 --- a/src/main/java/com/massivecraft/factions/Conf.java +++ b/src/main/java/com/massivecraft/factions/Conf.java @@ -102,6 +102,7 @@ public class Conf { public static boolean handleExploitEnderPearlClipping = true; public static boolean handleExploitInteractionSpam = true; public static boolean handleExploitTNTWaterlog = false; + public static boolean handleExploitLiquidFlow = false; public static boolean homesEnabled = true; public static boolean homesMustBeInClaimedTerritory = true; diff --git a/src/main/java/com/massivecraft/factions/listeners/FactionsBlockListener.java b/src/main/java/com/massivecraft/factions/listeners/FactionsBlockListener.java index da5d9dc1..a59605a7 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsBlockListener.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsBlockListener.java @@ -38,6 +38,30 @@ public class FactionsBlockListener implements Listener { } } + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onBlockFromTo(BlockFromToEvent event) { + if (!Conf.handleExploitLiquidFlow) { + return; + } + if (event.getBlock().isLiquid()) { + if (event.getToBlock().isEmpty()) { + Faction from = Board.getInstance().getFactionAt(new FLocation(event.getBlock())); + Faction to = Board.getInstance().getFactionAt(new FLocation(event.getToBlock())); + if (from == to) { + // not concerned with inter-faction events + return; + } + // from faction != to faction + if (to.isNormal()) { + if (from.isNormal() && from.getRelationTo(to).isAlly()) { + return; + } + event.setCancelled(true); + } + } + } + } + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onBlockBreak(BlockBreakEvent event) { if (!playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "destroy", false)) {