diff options
author | snowleo <schneeleo@gmail.com> | 2011-12-07 12:10:41 +0100 |
---|---|---|
committer | snowleo <schneeleo@gmail.com> | 2011-12-07 12:10:41 +0100 |
commit | d60de76d87ce00a3b3d3a77a470852e455e58d7f (patch) | |
tree | 9ef10a7d1668d5eedf56205de2249b96746a98bb | |
parent | 324cd748261cc53ce7a709674842c72530ea1d2b (diff) | |
download | Essentials-d60de76d87ce00a3b3d3a77a470852e455e58d7f.tar Essentials-d60de76d87ce00a3b3d3a77a470852e455e58d7f.tar.gz Essentials-d60de76d87ce00a3b3d3a77a470852e455e58d7f.tar.lz Essentials-d60de76d87ce00a3b3d3a77a470852e455e58d7f.tar.xz Essentials-d60de76d87ce00a3b3d3a77a470852e455e58d7f.zip |
New config option disable-item-pickup-while-afk, defaults to true.
5 files changed, 33 insertions, 6 deletions
diff --git a/Essentials/src/com/earth2me/essentials/Essentials.java b/Essentials/src/com/earth2me/essentials/Essentials.java index 8e5a2f588..f0c22e557 100644 --- a/Essentials/src/com/earth2me/essentials/Essentials.java +++ b/Essentials/src/com/earth2me/essentials/Essentials.java @@ -215,6 +215,7 @@ public class Essentials extends JavaPlugin implements IEssentials pm.registerEvent(Type.PLAYER_ANIMATION, playerListener, Priority.High, this); pm.registerEvent(Type.PLAYER_CHANGED_WORLD, playerListener, Priority.Normal, this); pm.registerEvent(Type.PLAYER_INTERACT, playerListener, Priority.Monitor, this); + pm.registerEvent(Type.PLAYER_PICKUP_ITEM, playerListener, Priority.Low, this); pm.registerEvent(Type.PLAYER_TELEPORT, new ItemDupeFix(), Priority.Monitor, this); final EssentialsBlockListener blockListener = new EssentialsBlockListener(this); @@ -298,7 +299,7 @@ public class Essentials extends JavaPlugin implements IEssentials final PluginCommand pc = alternativeCommandsHandler.getAlternative(commandLabel); if (pc != null) { - alternativeCommandsHandler.executed(commandLabel, pc.getLabel()); + alternativeCommandsHandler.executed(commandLabel, pc.getLabel()); return pc.execute(sender, commandLabel, args); } } diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java index 0991a16e4..a90e98013 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java @@ -227,19 +227,19 @@ public class EssentialsPlayerListener extends PlayerListener @Override public void onPlayerTeleport(PlayerTeleportEvent event) - { + { if (event.isCancelled()) { return; } - - final User user = ess.getUser(event.getPlayer()); + + final User user = ess.getUser(event.getPlayer()); //There is TeleportCause.COMMMAND but plugins have to actively pass the cause in on their teleports. - if((event.getCause() == TeleportCause.PLUGIN || event.getCause() == TeleportCause.COMMAND)&& ess.getSettings().registerBackInListener()) + if ((event.getCause() == TeleportCause.PLUGIN || event.getCause() == TeleportCause.COMMAND) && ess.getSettings().registerBackInListener()) { user.setLastLocation(); } - + if (ess.getSettings().changeDisplayName()) { user.setDisplayNick(); @@ -382,4 +382,18 @@ public class EssentialsPlayerListener extends PlayerListener SetBed.setBed(event.getPlayer(), event.getClickedBlock()); } } + + @Override + public void onPlayerPickupItem(PlayerPickupItemEvent event) + { + if (event.isCancelled() || !ess.getSettings().getDisableItemPickupWhileAfk()) + { + return; + } + final User user = ess.getUser(event.getPlayer()); + if (user.isAfk()) + { + event.setCancelled(true); + } + } } diff --git a/Essentials/src/com/earth2me/essentials/ISettings.java b/Essentials/src/com/earth2me/essentials/ISettings.java index 97b0fad93..66d53299b 100644 --- a/Essentials/src/com/earth2me/essentials/ISettings.java +++ b/Essentials/src/com/earth2me/essentials/ISettings.java @@ -146,4 +146,6 @@ public interface ISettings extends IConf boolean getIsWorldTeleportPermissions(); boolean registerBackInListener(); + + public boolean getDisableItemPickupWhileAfk(); } diff --git a/Essentials/src/com/earth2me/essentials/Settings.java b/Essentials/src/com/earth2me/essentials/Settings.java index efda428ef..25b32d544 100644 --- a/Essentials/src/com/earth2me/essentials/Settings.java +++ b/Essentials/src/com/earth2me/essentials/Settings.java @@ -572,4 +572,10 @@ public class Settings implements ISettings { return config.getBoolean("register-back-in-listener", false); } + + @Override + public boolean getDisableItemPickupWhileAfk() + { + return config.getBoolean("disable-item-pickup-while-afk", true); + } } diff --git a/Essentials/src/config.yml b/Essentials/src/config.yml index 3b7637fea..f7851714e 100644 --- a/Essentials/src/config.yml +++ b/Essentials/src/config.yml @@ -213,6 +213,10 @@ auto-afk-kick: -1 # The player has to use the command /afk to leave the afk mode. freeze-afk-players: false +# When the player is afk, should he be able to pickup items? +# Enable this, when you don't want people idling in mob traps. +disable-item-pickup-while-afk: true + # You can disable the death messages of minecraft here death-messages: true |