forked from MagicBane/Server
Handler created for ClientAdminCommandMsg
This commit is contained in:
@@ -21,8 +21,8 @@ import engine.net.DispatchMessage;
|
||||
import engine.net.MessageDispatcher;
|
||||
import engine.net.client.ClientConnection;
|
||||
import engine.net.client.Protocol;
|
||||
import engine.net.client.handlers.ClientAdminCommandMsgHandler;
|
||||
import engine.net.client.msg.chat.*;
|
||||
import engine.net.client.msg.commands.ClientAdminCommandMsg;
|
||||
import engine.objects.*;
|
||||
import engine.server.MBServerStatics;
|
||||
import engine.server.world.WorldServer;
|
||||
@@ -190,7 +190,7 @@ public enum ChatManager {
|
||||
}
|
||||
|
||||
if (ChatManager.isDevCommand(text) == true) {
|
||||
ChatManager.processDevCommand(player, text);
|
||||
ClientAdminCommandMsgHandler.processDevCommand(player, text);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1083,94 +1083,4 @@ public enum ChatManager {
|
||||
return text.equalsIgnoreCase("lua_population()");
|
||||
}
|
||||
|
||||
private static boolean processDevCommand(AbstractWorldObject sender, String text) {
|
||||
|
||||
if (sender.getObjectType().equals(GameObjectType.PlayerCharacter)) {
|
||||
|
||||
PlayerCharacter pcSender = (PlayerCharacter) sender;
|
||||
|
||||
// first remove the DEV_CMD_PREFIX
|
||||
String[] words = text.split(MBServerStatics.DEV_CMD_PREFIX, 2);
|
||||
|
||||
if (words[1].length() == 0)
|
||||
return false;
|
||||
|
||||
// next get the command
|
||||
String[] commands = words[1].split(" ", 2);
|
||||
String cmd = commands[0].toLowerCase();
|
||||
String cmdArgument = "";
|
||||
|
||||
if (commands.length > 1)
|
||||
cmdArgument = commands[1].trim();
|
||||
|
||||
AbstractGameObject target = pcSender.getLastTarget();
|
||||
// return DevCmd.processDevCommand(pcSender, cmd, cmdArgument,
|
||||
// target);
|
||||
return DevCmdManager.handleDevCmd(pcSender, cmd,
|
||||
cmdArgument, target);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process an Admin Command, which is a preset command sent from the client
|
||||
*/
|
||||
public static void HandleClientAdminCmd(ClientAdminCommandMsg data,
|
||||
ClientConnection cc) {
|
||||
|
||||
PlayerCharacter pcSender = SessionManager.getPlayerCharacter(cc);
|
||||
|
||||
if (pcSender == null)
|
||||
return;
|
||||
|
||||
Account acct = SessionManager.getAccount(pcSender);
|
||||
|
||||
if (acct == null)
|
||||
return;
|
||||
|
||||
// require minimal access to continue
|
||||
// specific accessLevel checks performed by the DevCmdManager
|
||||
if (acct.status.equals(Enum.AccountStatus.ADMIN) == false) {
|
||||
Logger.warn(pcSender.getFirstName() + " Attempted to use a client admin command");
|
||||
//wtf? ChatManager.chatSystemInfo(pcSender, "CHEATER!!!!!!!!!!!!!");
|
||||
return;
|
||||
}
|
||||
|
||||
// First remove the initial slash
|
||||
String d = data.getMsgCommand();
|
||||
String[] words = d.split("/", 2);
|
||||
|
||||
if (words[1].length() == 0)
|
||||
return;
|
||||
|
||||
// Next get the command
|
||||
String[] commands = words[1].split(" ", 2);
|
||||
String cmd = commands[0].toLowerCase();
|
||||
String cmdArgument = "";
|
||||
|
||||
if (commands.length > 1)
|
||||
cmdArgument = commands[1].trim();
|
||||
|
||||
AbstractGameObject target = data.getTarget();
|
||||
|
||||
// Map to a DevCmd
|
||||
String devCmd = "";
|
||||
|
||||
if (cmd.compareTo("goto") == 0)
|
||||
devCmd = "goto";
|
||||
else if (cmd.compareTo("suspend") == 0)
|
||||
devCmd = "suspend";
|
||||
else if (cmd.compareTo("getinfo") == 0)
|
||||
devCmd = "info";
|
||||
else if (devCmd.isEmpty()) {
|
||||
Logger.info("Unhandled admin command was used: /"
|
||||
+ cmd);
|
||||
return;
|
||||
}
|
||||
|
||||
DevCmdManager.handleDevCmd(pcSender, devCmd, cmdArgument,
|
||||
target);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user