Add a way to log commands

This commit is contained in:
Sarah 2017-04-19 01:40:23 +02:00 committed by cnr
parent fdee6b1163
commit 8a33eabe3d
2 changed files with 9 additions and 1 deletions

View File

@ -89,12 +89,13 @@ public class CommandCenter implements Listener, IPacketHandler
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
{ {
String commandName = event.getMessage().substring(1); String commandName = event.getMessage().substring(1);
String argString = event.getMessage().substring(event.getMessage().indexOf(' ') + 1);
String[] args = new String[]{}; String[] args = new String[]{};
if (commandName.contains(" ")) if (commandName.contains(" "))
{ {
commandName = commandName.split(" ")[0]; commandName = commandName.split(" ")[0];
args = event.getMessage().substring(event.getMessage().indexOf(' ') + 1).split(" "); args = argString.split(" ");
} }
ICommand command = Commands.get(commandName.toLowerCase()); ICommand command = Commands.get(commandName.toLowerCase());
@ -113,6 +114,12 @@ public class CommandCenter implements Listener, IPacketHandler
} }
command.SetAliasUsed(commandName.toLowerCase()); command.SetAliasUsed(commandName.toLowerCase());
if (command instanceof LoggedCommand)
{
((LoggedCommand) command).execute(System.currentTimeMillis(), event.getPlayer().getName(), commandName, argString);
}
command.Execute(event.getPlayer(), args); command.Execute(event.getPlayer(), args);
} }
return; return;

View File

@ -3,6 +3,7 @@ package mineplex.core.personalServer;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase; import mineplex.core.command.CommandBase;
import mineplex.core.command.LoggedCommand;
import mineplex.core.common.Rank; import mineplex.core.common.Rank;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;