New config option disable-item-pickup-while-afk, defaults to true.

This commit is contained in:
snowleo 2011-12-07 12:10:41 +01:00
parent 324cd74826
commit d60de76d87
5 changed files with 33 additions and 6 deletions

View File

@ -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);

View File

@ -235,7 +235,7 @@ public class EssentialsPlayerListener extends PlayerListener
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();
}
@ -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);
}
}
}

View File

@ -146,4 +146,6 @@ public interface ISettings extends IConf
boolean getIsWorldTeleportPermissions();
boolean registerBackInListener();
public boolean getDisableItemPickupWhileAfk();
}

View File

@ -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);
}
}

View File

@ -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