diff options
author | KHobbits <rob@khobbits.co.uk> | 2013-07-02 07:16:42 +0100 |
---|---|---|
committer | KHobbits <rob@khobbits.co.uk> | 2013-07-02 07:16:42 +0100 |
commit | 73373f288ac0d322afeabcc69d489bb4bcf44417 (patch) | |
tree | f4063ec7e1fafde4e613c97e97c13d09ef8130d4 | |
parent | a3ed9cd507904eaeaf7428baded487fc77e849a8 (diff) | |
download | Essentials-73373f288ac0d322afeabcc69d489bb4bcf44417.tar Essentials-73373f288ac0d322afeabcc69d489bb4bcf44417.tar.gz Essentials-73373f288ac0d322afeabcc69d489bb4bcf44417.tar.lz Essentials-73373f288ac0d322afeabcc69d489bb4bcf44417.tar.xz Essentials-73373f288ac0d322afeabcc69d489bb4bcf44417.zip |
Add command logging for CommandBlocks and other console types.
-rw-r--r-- | Essentials/src/com/earth2me/essentials/Essentials.java | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/Essentials/src/com/earth2me/essentials/Essentials.java b/Essentials/src/com/earth2me/essentials/Essentials.java index d9bb6fc2c..3d60046cb 100644 --- a/Essentials/src/com/earth2me/essentials/Essentials.java +++ b/Essentials/src/com/earth2me/essentials/Essentials.java @@ -20,6 +20,7 @@ package com.earth2me.essentials; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.api.Economy; import com.earth2me.essentials.api.IJails; +import com.earth2me.essentials.commands.EssentialsCommand; import com.earth2me.essentials.commands.IEssentialsCommand; import com.earth2me.essentials.commands.NoChargeException; import com.earth2me.essentials.commands.NotEnoughArgumentsException; @@ -48,6 +49,8 @@ import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Server; import org.bukkit.World; +import org.bukkit.block.Block; +import org.bukkit.command.BlockCommandSender; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.command.PluginCommand; @@ -243,12 +246,13 @@ public class Essentials extends JavaPlugin implements IEssentials LOGGER.log(Level.INFO, "Essentials load " + timeroutput); } } - + @Override - public void saveConfig() { + public void saveConfig() + { // We don't use any of the bukkit config writing, as this breaks our config file formatting. } - + private void registerListeners(PluginManager pm) { HandlerList.unregisterAll(this); @@ -356,10 +360,32 @@ public class Essentials extends JavaPlugin implements IEssentials try { User user = null; + Block bSenderBlock = null; if (sender instanceof Player) { user = getUser(sender); } + else if (sender instanceof BlockCommandSender) + { + BlockCommandSender bsender = (BlockCommandSender)sender; + bSenderBlock = bsender.getBlock(); + } + + if (bSenderBlock != null) + { + Bukkit.getLogger().log(Level.INFO, "CommandBlock at {0},{1},{2} issued server command: /{3} {4}", new Object[] + { + bSenderBlock.getX(), bSenderBlock.getY(), bSenderBlock.getZ(), commandLabel, EssentialsCommand.getFinalArg(args, 0) + }); + } + else if (user == null) + { + Bukkit.getLogger().log(Level.INFO, "{0} issued server command: /{1} {2}", new Object[] + { + sender.getName(), commandLabel, EssentialsCommand.getFinalArg(args, 0) + }); + } + // New mail notification if (user != null && !getSettings().isCommandDisabled("mail") && !command.getName().equals("mail") && user.isAuthorized("essentials.mail")) |