summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKHobbits <rob@khobbits.co.uk>2013-07-02 07:16:42 +0100
committerKHobbits <rob@khobbits.co.uk>2013-07-02 07:16:42 +0100
commit522c3e85b2a15bc0689df87fdb8eeea63aefdfee (patch)
treec0c7aacbb803f99beb5aaebd00109b670eb7fe8a
parent188a214de9a6e15b469ec8eb3b810123ea1a8cdb (diff)
downloadEssentials-522c3e85b2a15bc0689df87fdb8eeea63aefdfee.tar
Essentials-522c3e85b2a15bc0689df87fdb8eeea63aefdfee.tar.gz
Essentials-522c3e85b2a15bc0689df87fdb8eeea63aefdfee.tar.lz
Essentials-522c3e85b2a15bc0689df87fdb8eeea63aefdfee.tar.xz
Essentials-522c3e85b2a15bc0689df87fdb8eeea63aefdfee.zip
Add command logging for CommandBlocks and other console types.
-rw-r--r--Essentials/src/com/earth2me/essentials/Essentials.java32
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"))