From 9492b01d9739c9904fb3980539cc53a5e5e34a19 Mon Sep 17 00:00:00 2001 From: Psithief Date: Mon, 25 Jun 2012 21:43:56 +0800 Subject: [PATCH 1/2] Attempt to fix fake-players being invincible through superperms. A Player entity that's not an actual player will always return false for permissions, making it invincible. isOnline() seems to be an adequate check to determine the difference between a real player and a fake. --- .../java/ru/tehkode/modifyworld/handlers/EntityListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/ru/tehkode/modifyworld/handlers/EntityListener.java b/src/main/java/ru/tehkode/modifyworld/handlers/EntityListener.java index 0f667ca..1440113 100644 --- a/src/main/java/ru/tehkode/modifyworld/handlers/EntityListener.java +++ b/src/main/java/ru/tehkode/modifyworld/handlers/EntityListener.java @@ -52,7 +52,7 @@ public class EntityListener extends ModifyworldListener { if (edbe.getEntity() instanceof Player) { player = (Player) edbe.getEntity(); - if (edbe.getDamager() != null) { // Prevent from taking damage by entity + if (edbe.getDamager() != null && player.isOnline()) { // Prevent from taking damage by entity if (_permissionDenied(player, "modifyworld.damage.take", edbe.getDamager())) { cancelDamageEvent(player, event); } From dbe566315d3ae422e1d57abe3731b9b3ad7423c5 Mon Sep 17 00:00:00 2001 From: Psithief Date: Tue, 21 Aug 2012 21:40:16 +0800 Subject: [PATCH 2/2] Fixes players being able to throw items if right-clicking blocks. --- .../ru/tehkode/modifyworld/handlers/PlayerListener.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/ru/tehkode/modifyworld/handlers/PlayerListener.java b/src/main/java/ru/tehkode/modifyworld/handlers/PlayerListener.java index 1835a0d..845de24 100644 --- a/src/main/java/ru/tehkode/modifyworld/handlers/PlayerListener.java +++ b/src/main/java/ru/tehkode/modifyworld/handlers/PlayerListener.java @@ -251,7 +251,7 @@ public class PlayerListener extends ModifyworldListener { Player player = event.getPlayer(); - if (action == Action.RIGHT_CLICK_AIR) { //RIGHT_CLICK_AIR is cancelled by default. + if (action == Action.RIGHT_CLICK_AIR || action == Action.RIGHT_CLICK_BLOCK) { //RIGHT_CLICK_AIR is cancelled by default. switch (player.getItemInHand().getType()) { case POTION: //Only check splash potions. if ((player.getItemInHand().getDurability() & 0x4000) != 0x4000) { @@ -267,7 +267,9 @@ public class PlayerListener extends ModifyworldListener { event.getPlayer().updateInventory(); } } - return; + if (action == Action.RIGHT_CLICK_AIR) { + return; + } } }