Convert 9 anonymous scheduled tasks to named classes for better logging.

This commit is contained in:
KHobbits 2014-05-18 21:32:07 +01:00
parent 8159530906
commit c929ebb89a
7 changed files with 44 additions and 33 deletions

View file

@ -146,7 +146,7 @@ public class Backup implements Runnable
} }
finally finally
{ {
ess.scheduleSyncDelayedTask(new Runnable() class BackupEnableSaveTask implements Runnable
{ {
@Override @Override
public void run() public void run()
@ -159,7 +159,8 @@ public class Backup implements Runnable
active = false; active = false;
LOGGER.log(Level.INFO, tl("backupFinished")); LOGGER.log(Level.INFO, tl("backupFinished"));
} }
}); }
ess.scheduleSyncDelayedTask(new BackupEnableSaveTask());
} }
} }
}); });

View file

@ -56,8 +56,7 @@ public class EssentialsBlockListener implements Listener
final User user = ess.getUser(event.getPlayer()); final User user = ess.getUser(event.getPlayer());
if (user.hasUnlimited(is) && user.getBase().getGameMode() == GameMode.SURVIVAL) if (user.hasUnlimited(is) && user.getBase().getGameMode() == GameMode.SURVIVAL)
{ {
ess.scheduleSyncDelayedTask( class UnlimitedItemSpawnTask implements Runnable
new Runnable()
{ {
@Override @Override
public void run() public void run()
@ -65,7 +64,8 @@ public class EssentialsBlockListener implements Listener
user.getBase().getInventory().addItem(is); user.getBase().getInventory().addItem(is);
user.getBase().updateInventory(); user.getBase().updateInventory();
} }
}); }
ess.scheduleSyncDelayedTask(new UnlimitedItemSpawnTask());
} }
} }
} }

View file

@ -55,7 +55,7 @@ public class EssentialsEntityListener implements Listener
attacker.updateActivity(true); attacker.updateActivity(true);
} }
else if (eAttack instanceof Projectile && eDefend instanceof Player) else if (eAttack instanceof Projectile && eDefend instanceof Player)
{ {
final Projectile projectile = (Projectile)event.getDamager(); final Projectile projectile = (Projectile)event.getDamager();
//This should return a ProjectileSource on 1.7.3 beta + //This should return a ProjectileSource on 1.7.3 beta +
final Object shooter = projectile.getShooter(); final Object shooter = projectile.getShooter();
@ -105,8 +105,8 @@ public class EssentialsEntityListener implements Listener
final String command = powertoolPlayer.matcher(tempCommand).replaceAll(defender.getName()); final String command = powertoolPlayer.matcher(tempCommand).replaceAll(defender.getName());
if (command != null && !command.isEmpty() && !command.equals(tempCommand)) if (command != null && !command.isEmpty() && !command.equals(tempCommand))
{ {
ess.scheduleSyncDelayedTask(
new Runnable() class PowerToolInteractTask implements Runnable
{ {
@Override @Override
public void run() public void run()
@ -114,7 +114,8 @@ public class EssentialsEntityListener implements Listener
attacker.getServer().dispatchCommand(attacker.getBase(), command); attacker.getServer().dispatchCommand(attacker.getBase(), command);
LOGGER.log(Level.INFO, String.format("[PT] %s issued server command: /%s", attacker.getName(), command)); LOGGER.log(Level.INFO, String.format("[PT] %s issued server command: /%s", attacker.getName(), command));
} }
}); }
ess.scheduleSyncDelayedTask(new PowerToolInteractTask());
event.setCancelled(true); event.setCancelled(true);
return; return;

View file

@ -220,7 +220,7 @@ public class EssentialsPlayerListener implements Listener
dUser.checkMuteTimeout(currentTime); dUser.checkMuteTimeout(currentTime);
dUser.updateActivity(false); dUser.updateActivity(false);
ess.scheduleSyncDelayedTask(new Runnable() class DelayJoinTask implements Runnable
{ {
@Override @Override
public void run() public void run()
@ -319,7 +319,9 @@ public class EssentialsPlayerListener implements Listener
user.getBase().setWalkSpeed(0.2f); user.getBase().setWalkSpeed(0.2f);
} }
}); }
ess.scheduleSyncDelayedTask(new DelayJoinTask());
} }
// Makes the compass item ingame always point to the first essentials home. #EasterEgg // Makes the compass item ingame always point to the first essentials home. #EasterEgg
@ -573,8 +575,7 @@ public class EssentialsPlayerListener implements Listener
{ {
final Location otarget = LocationUtil.getTarget(user.getBase()); final Location otarget = LocationUtil.getTarget(user.getBase());
ess.scheduleSyncDelayedTask( class DelayedClickJumpTask implements Runnable
new Runnable()
{ {
@Override @Override
public void run() public void run()
@ -588,7 +589,8 @@ public class EssentialsPlayerListener implements Listener
} }
user.getBase().teleport(loc, TeleportCause.PLUGIN); user.getBase().teleport(loc, TeleportCause.PLUGIN);
} }
}); }
ess.scheduleSyncDelayedTask(new DelayedClickJumpTask());
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -622,8 +624,8 @@ public class EssentialsPlayerListener implements Listener
else else
{ {
used = true; used = true;
ess.scheduleSyncDelayedTask(
new Runnable() class PowerToolUseTask implements Runnable
{ {
@Override @Override
public void run() public void run()
@ -631,7 +633,9 @@ public class EssentialsPlayerListener implements Listener
user.getServer().dispatchCommand(user.getBase(), command); user.getServer().dispatchCommand(user.getBase(), command);
LOGGER.log(Level.INFO, String.format("[PT] %s issued server command: /%s", user.getName(), command)); LOGGER.log(Level.INFO, String.format("[PT] %s issued server command: /%s", user.getName(), command));
} }
}); }
ess.scheduleSyncDelayedTask(new PowerToolUseTask());
} }
} }
return used; return used;

View file

@ -89,7 +89,7 @@ public class TimedTeleport implements Runnable
return; return;
} }
ess.scheduleSyncDelayedTask(new Runnable() class DelayedTeleportTask implements Runnable
{ {
@Override @Override
public void run() public void run()
@ -146,7 +146,8 @@ public class TimedTeleport implements Runnable
} }
} }
} }
}); }
ess.scheduleSyncDelayedTask(new DelayedTeleportTask());
} }
//If we need to cancelTimer a pending teleportPlayer call this method //If we need to cancelTimer a pending teleportPlayer call this method

View file

@ -31,7 +31,8 @@ public class Commandkittycannon extends EssentialsCommand
ocelot.setTamed(true); ocelot.setTamed(true);
ocelot.setBaby(); ocelot.setBaby();
ocelot.setVelocity(user.getBase().getEyeLocation().getDirection().multiply(2)); ocelot.setVelocity(user.getBase().getEyeLocation().getDirection().multiply(2));
ess.scheduleSyncDelayedTask(new Runnable()
class KittyCannonExplodeTask implements Runnable
{ {
@Override @Override
public void run() public void run()
@ -40,6 +41,8 @@ public class Commandkittycannon extends EssentialsCommand
ocelot.remove(); ocelot.remove();
loc.getWorld().createExplosion(loc, 0F); loc.getWorld().createExplosion(loc, 0F);
} }
}, 20); }
ess.scheduleSyncDelayedTask(new KittyCannonExplodeTask(), 20);
} }
} }

View file

@ -27,7 +27,7 @@ public class Commandsudo extends EssentialsCommand
} }
final User user = getPlayer(server, sender, args, 0); final User user = getPlayer(server, sender, args, 0);
if(args[1].toLowerCase(Locale.ENGLISH).startsWith("c:")) if (args[1].toLowerCase(Locale.ENGLISH).startsWith("c:"))
{ {
if (user.isAuthorized("essentials.sudo.exempt") && sender.isPlayer()) if (user.isAuthorized("essentials.sudo.exempt") && sender.isPlayer())
{ {
@ -53,18 +53,19 @@ public class Commandsudo extends EssentialsCommand
final PluginCommand execCommand = ess.getServer().getPluginCommand(command); final PluginCommand execCommand = ess.getServer().getPluginCommand(command);
if (execCommand != null) if (execCommand != null)
{ {
ess.scheduleSyncDelayedTask( class SudoCommandTask implements Runnable
new Runnable() {
{ @Override
@Override public void run()
public void run() {
{ LOGGER.log(Level.INFO, String.format("[Sudo] %s issued server command: /%s %s", user.getName(), command, getFinalArg(arguments, 0)));
LOGGER.log(Level.INFO, String.format("[Sudo] %s issued server command: /%s %s", user.getName(), command, getFinalArg(arguments, 0))); execCommand.execute(user.getBase(), command, arguments);
execCommand.execute(user.getBase(), command, arguments); }
} }
}); ess.scheduleSyncDelayedTask(new SudoCommandTask());
} }
else { else
{
sender.sendMessage(tl("errorCallingCommand", command)); sender.sendMessage(tl("errorCallingCommand", command));
} }
} }