From 2b7a505a7cbdfa5e7d13fd295c99aa97fecfee69 Mon Sep 17 00:00:00 2001 From: ulumulu1510 Date: Fri, 15 Jan 2016 20:30:43 +0100 Subject: [PATCH] Add FakeBlockPlaceEvent handling and adminMode override in PvP. --- .../factions/engine/EngineMain.java | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/com/massivecraft/factions/engine/EngineMain.java b/src/com/massivecraft/factions/engine/EngineMain.java index 867ebf9b..4054d17d 100644 --- a/src/com/massivecraft/factions/engine/EngineMain.java +++ b/src/com/massivecraft/factions/engine/EngineMain.java @@ -904,6 +904,10 @@ public class EngineMain extends EngineAbstract // ... gather defender PS and faction information ... PS defenderPs = PS.valueOf(defender.getLocation()); Faction defenderPsFaction = BoardColl.get().getFactionAt(defenderPs); + + // ... fast evaluate if the attacker is overriding ... + MPlayer mplayer = MPlayer.get(eattacker); + if (mplayer != null && mplayer.isUsingAdminMode()) return true; // ... PVP flag may cause a damage block ... if (defenderPsFaction.getFlag(MFlag.getFlagPvp()) == false) @@ -1421,7 +1425,9 @@ public class EngineMain extends EngineAbstract { if (!event.canBuild()) return; - if (canPlayerBuildAt(event.getPlayer(), PS.valueOf(event.getBlock()), true)) return; + boolean verboose = ! MUtil.isFakeEvent(event); + + if (canPlayerBuildAt(event.getPlayer(), PS.valueOf(event.getBlock()), verboose)) return; event.setBuild(false); event.setCancelled(true); @@ -1430,7 +1436,9 @@ public class EngineMain extends EngineAbstract @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void blockBuild(BlockBreakEvent event) { - if (canPlayerBuildAt(event.getPlayer(), PS.valueOf(event.getBlock()), true)) return; + boolean verboose = ! MUtil.isFakeEvent(event); + + if (canPlayerBuildAt(event.getPlayer(), PS.valueOf(event.getBlock()), verboose)) return; event.setCancelled(true); } @@ -1440,7 +1448,9 @@ public class EngineMain extends EngineAbstract { if (!event.getInstaBreak()) return; - if (canPlayerBuildAt(event.getPlayer(), PS.valueOf(event.getBlock()), true)) return; + boolean verboose = ! MUtil.isFakeEvent(event); + + if (canPlayerBuildAt(event.getPlayer(), PS.valueOf(event.getBlock()), verboose)) return; event.setCancelled(true); } @@ -1507,7 +1517,9 @@ public class EngineMain extends EngineAbstract @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void blockBuild(HangingPlaceEvent event) { - if (canPlayerBuildAt(event.getPlayer(), PS.valueOf(event.getEntity().getLocation()), true)) return; + boolean verboose = ! MUtil.isFakeEvent(event); + + if (canPlayerBuildAt(event.getPlayer(), PS.valueOf(event.getEntity().getLocation()), verboose)) return; event.setCancelled(true); } @@ -1521,7 +1533,9 @@ public class EngineMain extends EngineAbstract Entity breaker = entityEvent.getRemover(); if (MUtil.isntPlayer(breaker)) return; - if ( ! canPlayerBuildAt(breaker, PS.valueOf(event.getEntity().getLocation()), true)) + boolean verboose = ! MUtil.isFakeEvent(event); + + if ( ! canPlayerBuildAt(breaker, PS.valueOf(event.getEntity().getLocation()), verboose)) { event.setCancelled(true); }