From f440e4843576408c4feec541269194e9c1000f10 Mon Sep 17 00:00:00 2001 From: Magnus Ulf Date: Tue, 2 Mar 2021 21:53:45 +0100 Subject: [PATCH] Attempt to fix #80 It is very likely I didn't. But when inspecting the code I have absolutely no clue how it could even happen in the first place. Anyhow, if it happens again I'll probably have better debug now. --- .../factions/engine/EngineMain.java | 17 ----------------- .../factions/engine/EnginePermBuild.java | 16 +++++++++------- 2 files changed, 9 insertions(+), 24 deletions(-) delete mode 100644 src/com/massivecraft/factions/engine/EngineMain.java diff --git a/src/com/massivecraft/factions/engine/EngineMain.java b/src/com/massivecraft/factions/engine/EngineMain.java deleted file mode 100644 index 77895c22..00000000 --- a/src/com/massivecraft/factions/engine/EngineMain.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.massivecraft.factions.engine; - -import com.massivecraft.massivecore.ps.PS; - -public class EngineMain -{ - - /** - * @deprecated moved to EnginePermBuild - */ - public static boolean canPlayerBuildAt(Object senderObject, PS ps, boolean verboose) - { - Boolean ret = EnginePermBuild.protect(ProtectCase.BUILD, verboose, senderObject, ps, null, null); - return ret == null || !ret; - } - -} diff --git a/src/com/massivecraft/factions/engine/EnginePermBuild.java b/src/com/massivecraft/factions/engine/EnginePermBuild.java index 84b17c36..de93789b 100644 --- a/src/com/massivecraft/factions/engine/EnginePermBuild.java +++ b/src/com/massivecraft/factions/engine/EnginePermBuild.java @@ -84,9 +84,9 @@ public class EnginePermBuild extends Engine return !perm.has(mplayer, ps, verboose); } - public static Boolean protect(ProtectCase protectCase, boolean verboose, Object senderObject, PS ps, Object object, Cancellable cancellable) + public static Boolean protect(ProtectCase protectCase, boolean verboose, Player player, PS ps, Object object, Cancellable cancellable) { - Boolean ret = isProtected(protectCase, verboose, MPlayer.get(senderObject), ps, object); + Boolean ret = isProtected(protectCase, verboose, MPlayer.get(player), ps, object); if (Boolean.TRUE.equals(ret) && cancellable != null) cancellable.setCancelled(true); return ret; @@ -96,16 +96,17 @@ public class EnginePermBuild extends Engine { if (!(event instanceof Cancellable)) return true; if (MUtil.isntPlayer(entity)) return false; + Player player = (Player) entity; boolean verboose = !isFake(event); - return protect(ProtectCase.BUILD, verboose, entity, PS.valueOf(block), block, (Cancellable) event); + return protect(ProtectCase.BUILD, verboose, player, PS.valueOf(block), block, (Cancellable) event); } - public static Boolean useItem(Entity entity, Block block, Material material, Cancellable cancellable) + public static Boolean useItem(Player player, Block block, Material material, Cancellable cancellable) { - return protect(ProtectCase.USE_ITEM, true, entity, PS.valueOf(block), material, cancellable); + return protect(ProtectCase.USE_ITEM, true, player, PS.valueOf(block), material, cancellable); } - public static Boolean useEntity(Entity player, Entity entity, boolean verboose, Cancellable cancellable) + public static Boolean useEntity(Player player, Entity entity, boolean verboose, Cancellable cancellable) { return protect(ProtectCase.USE_ENTITY, verboose, player, PS.valueOf(entity), entity, cancellable); } @@ -249,6 +250,7 @@ public class EnginePermBuild extends Engine // ... fired by a player ... ProjectileSource projectileSource = entityProjectile.getShooter(); if (MUtil.isntPlayer(projectileSource)) return; + Player player = (Player) projectileSource; // ... and hits an entity which is edited on damage (and thus likely to burn) ... Entity entityTarget = event.getEntity(); @@ -256,7 +258,7 @@ public class EnginePermBuild extends Engine // ... and the player can't build there, cancel the event Block block = entityTarget.getLocation().getBlock(); - protect(ProtectCase.BUILD, false, projectileSource, PS.valueOf(block), block, event); + protect(ProtectCase.BUILD, false, player, PS.valueOf(block), block, event); } // -------------------------------------------- //