/**
*
* @author Visor123
* L2Emu Enterprise Server
*/
public class L2ManagementEventGroupEngine extends L2EventGroupEngine
{
public L2ManagementEventGroupEngine(String name, String command)
{
super(name, command);
}
@Override
public boolean useAdminCommand(L2PcInstance player, String command)
{
if (Config.ENT_TESTEVENTS)
_log.info("L2ManagementEventGroupEngine "+getName()+" useAdminCommand player="+player.getName()+" command="+command);
if (command.equalsIgnoreCase(getCommand()))
{
showMainPage(player);
}
else if (command.startsWith(getCommand()+"_show")
|| command.startsWith(getCommand()+"_status")
|| command.startsWith(getCommand()+"_edit")
|| command.startsWith(getCommand()+"_save")
|| command.startsWith(getCommand()+"_load")
|| command.startsWith(getCommand()+"_schedule")
|| command.startsWith(getCommand()+"_totaliser")
|| command.startsWith(getCommand()+"_join")
|| command.startsWith(getCommand()+"_start")
|| command.startsWith(getCommand()+"_teleport")
|| command.startsWith(getCommand()+"_abort")
|| command.startsWith(getCommand()+"_finish")
|| command.startsWith(getCommand()+"_auto")
|| command.startsWith(getCommand()+"_sit")
|| command.startsWith(getCommand()+"_stand")
|| command.startsWith(getCommand()+"_kick")
)
{
String eventName = command.substring(getCommand().length()+6);
if (command.startsWith(getCommand()+"_schedule")
|| command.startsWith(getCommand()+"_teleport"))
eventName = command.substring(getCommand().length()+10);
else if (command.startsWith(getCommand()+"_finish") || command.startsWith(getCommand()+"_status"))
eventName = command.substring(getCommand().length()+8);
else if (command.startsWith(getCommand()+"_start")
|| command.startsWith(getCommand()+"_abort")
|| command.startsWith(getCommand()+"_stand"))
eventName = command.substring(getCommand().length()+7);
else if (command.startsWith(getCommand()+"_sit"))
eventName = command.substring(getCommand().length()+5);
else if (command.startsWith(getCommand()+"_totaliser"))
eventName = command.substring(getCommand().length()+11);
try
{
String[] params = eventName.split(" ");
if (Config.ENT_TESTEVENTS)
_log.info("L2ManagementEventEngine "+getName()+" show/edit... eventName="+params[0]+" params.length="+params.length);
if (_eventInstances.containsKey(params[0]))
_eventInstances.get(params[0]).useAdminCommand(player, command, params);
else
{
player.sendMessage("Event instance with name="+params[0]+" not found");
showMainPage(player);
}
return true;
}
catch (Exception e) {
_log.warn(e.getMessage());
}
}
else if (command.startsWith(getCommand()+"_del"))
{
try
{
String eventName = command.substring(getCommand().length()+5);
String[] params = eventName.split(" ");
if (Config.ENT_TESTEVENTS)
_log.info(getName()+" eventName="+params[0]+" params.length="+params.length);
if (_eventInstances.containsKey(params[0]) && params.length > 1 && params[1].equalsIgnoreCase("y"))
{
L2EventGroupEngineInstance event = _eventInstances.remove(params[0]);
event.deleteData();
saveData();
player.sendMessage(getName()+" data saved to DB");
}
else if (params.length 0 && !eventName.contains(" ") && eventName.length() 16)
player.sendMessage("Name event need have 1-16 characters");
showMainPage(player);
}
catch (Exception e) {
_log.warn(e.getMessage());
}
}
return super.useAdminCommand(player, command);
}
protected void showMainPage(L2PcInstance player)
{
NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
TextBuilder replyMSG = new TextBuilder(""+getName()+"");
replyMSG.append("[ "+getName()+" ]"
+""
+"");
replyMSG.append("
Engine instances");
replyMSG.append("");
for (L2EventGroupEngineInstance event : _eventInstances.values())
{
replyMSG.append(""+event.getName()+""
+""
+""
+""
);
}
replyMSG.append("");
replyMSG.append("");
replyMSG.append("");
replyMSG.append("");
replyMSG.append("");
adminReply.setHtml(replyMSG.toString());
player.sendPacket(adminReply);
// Send a Server->Client ActionFailed to the L2PcInstance in order to avoid that the client wait another packet
player.sendPacket(ActionFailed.STATIC_PACKET);
}
}
С точки зрения ява-машины - ничего страшного, но нужно было оставить вторую проверку - выполнение кода не пошло бы хоть так, хоть эдак, никаких потерь по времени
Но с точки зрения написания - ***ец
Чет герычем попахивает, мдам.......
command.substring(getCommand().length()+5); еще меня особенно умиляет)