mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-11-18 08:35:44 +01:00
New config option 'cancel-afk-on-move' - Set to false you don't use afk.
This commit is contained in:
parent
6dc2e96509
commit
d927d04765
@ -72,37 +72,40 @@ public class EssentialsPlayerListener implements Listener
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onPlayerMove(final PlayerMoveEvent event)
|
||||
{
|
||||
if (event.getFrom().getBlockX() == event.getTo().getBlockX()
|
||||
&& event.getFrom().getBlockZ() == event.getTo().getBlockZ()
|
||||
&& event.getFrom().getBlockY() == event.getTo().getBlockY())
|
||||
if ((!ess.getSettings().cancelAfkOnMove() && !ess.getSettings().getFreezeAfkPlayers())
|
||||
|| event.getFrom().getBlockX() == event.getTo().getBlockX()
|
||||
&& event.getFrom().getBlockZ() == event.getTo().getBlockZ()
|
||||
&& event.getFrom().getBlockY() == event.getTo().getBlockY())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
|
||||
if (user.isAfk() && ess.getSettings().getFreezeAfkPlayers())
|
||||
if (user.isAfk())
|
||||
{
|
||||
final Location from = event.getFrom();
|
||||
final Location to = event.getTo().clone();
|
||||
to.setX(from.getX());
|
||||
to.setY(from.getY());
|
||||
to.setZ(from.getZ());
|
||||
try
|
||||
if (ess.getSettings().getFreezeAfkPlayers())
|
||||
{
|
||||
event.setTo(Util.getSafeDestination(to));
|
||||
final Location from = event.getFrom();
|
||||
final Location to = event.getTo().clone();
|
||||
to.setX(from.getX());
|
||||
to.setY(from.getY());
|
||||
to.setZ(from.getZ());
|
||||
try
|
||||
{
|
||||
event.setTo(Util.getSafeDestination(to));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
event.setTo(to);
|
||||
}
|
||||
return;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
event.setTo(to);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
final Location afk = user.getAfkPosition();
|
||||
if (afk == null || !event.getTo().getWorld().equals(afk.getWorld()) || afk.distanceSquared(event.getTo()) > 9)
|
||||
{
|
||||
user.updateActivity(true);
|
||||
final Location afk = user.getAfkPosition();
|
||||
if (afk == null || !event.getTo().getWorld().equals(afk.getWorld()) || afk.distanceSquared(event.getTo()) > 9)
|
||||
{
|
||||
user.updateActivity(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -346,7 +349,7 @@ public class EssentialsPlayerListener implements Listener
|
||||
break;
|
||||
case LEFT_CLICK_AIR:
|
||||
case LEFT_CLICK_BLOCK:
|
||||
if (event.getItem() != null && event.getMaterial() != Material.AIR)
|
||||
if (event.getItem() != null && event.getItem().getTypeId() != Material.AIR.getId())
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (user.hasPowerTools() && user.arePowerToolsEnabled() && usePowertools(user, event.getItem().getTypeId()))
|
||||
|
@ -127,7 +127,7 @@ public interface ISettings extends IConf
|
||||
boolean removeGodOnDisconnect();
|
||||
|
||||
boolean changeDisplayName();
|
||||
|
||||
|
||||
boolean changePlayerListName();
|
||||
|
||||
boolean isPlayerCommand(String string);
|
||||
@ -146,6 +146,8 @@ public interface ISettings extends IConf
|
||||
|
||||
boolean getFreezeAfkPlayers();
|
||||
|
||||
boolean cancelAfkOnMove();
|
||||
|
||||
boolean areDeathMessagesEnabled();
|
||||
|
||||
public void setDebug(boolean debug);
|
||||
@ -165,12 +167,12 @@ public interface ISettings extends IConf
|
||||
EventPriority getRespawnPriority();
|
||||
|
||||
long getTpaAcceptCancellation();
|
||||
|
||||
|
||||
boolean isMetricsEnabled();
|
||||
|
||||
|
||||
void setMetricsEnabled(boolean metricsEnabled);
|
||||
|
||||
long getTeleportInvulnerability();
|
||||
|
||||
|
||||
boolean isTeleportInvulnerability();
|
||||
}
|
||||
|
@ -385,6 +385,8 @@ public class Settings implements ISettings
|
||||
teleportInvulnerability = _isTeleportInvulnerability();
|
||||
disableItemPickupWhileAfk = _getDisableItemPickupWhileAfk();
|
||||
registerBackInListener = _registerBackInListener();
|
||||
cancelAfkOnMove = _cancelAfkOnMove();
|
||||
getFreezeAfkPlayers = _getFreezeAfkPlayers();
|
||||
itemSpawnBl = _getItemSpawnBlacklist();
|
||||
kits = _getKits();
|
||||
chatFormats.clear();
|
||||
@ -654,12 +656,30 @@ public class Settings implements ISettings
|
||||
{
|
||||
return config.getLong("auto-afk-kick", -1);
|
||||
}
|
||||
private boolean getFreezeAfkPlayers;
|
||||
|
||||
@Override
|
||||
public boolean getFreezeAfkPlayers()
|
||||
{
|
||||
return getFreezeAfkPlayers;
|
||||
}
|
||||
|
||||
private boolean _getFreezeAfkPlayers()
|
||||
{
|
||||
return config.getBoolean("freeze-afk-players", false);
|
||||
}
|
||||
private boolean cancelAfkOnMove;
|
||||
|
||||
@Override
|
||||
public boolean cancelAfkOnMove()
|
||||
{
|
||||
return cancelAfkOnMove;
|
||||
}
|
||||
|
||||
private boolean _cancelAfkOnMove()
|
||||
{
|
||||
return config.getBoolean("cancel-afk-on-move", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean areDeathMessagesEnabled()
|
||||
@ -691,20 +711,18 @@ public class Settings implements ISettings
|
||||
{
|
||||
return config.getBoolean("world-teleport-permissions", false);
|
||||
}
|
||||
|
||||
private boolean registerBackInListener;
|
||||
|
||||
|
||||
@Override
|
||||
public boolean registerBackInListener()
|
||||
{
|
||||
return registerBackInListener;
|
||||
}
|
||||
|
||||
|
||||
private boolean _registerBackInListener()
|
||||
{
|
||||
return config.getBoolean("register-back-in-listener", false);
|
||||
}
|
||||
|
||||
private boolean disableItemPickupWhileAfk;
|
||||
|
||||
@Override
|
||||
|
@ -272,6 +272,11 @@ freeze-afk-players: false
|
||||
# Enable this, when you don't want people idling in mob traps.
|
||||
disable-item-pickup-while-afk: true
|
||||
|
||||
# Should we automatically remove afk status when the player moves?
|
||||
# Player will be removed from afk on chat/command reguardless of this setting.
|
||||
# Disable this to reduce server lag.
|
||||
cancel-afk-on-move: true
|
||||
|
||||
# You can disable the death messages of minecraft here
|
||||
death-messages: true
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user