Removed handler command enums.
This commit is contained in:
parent
a18389999f
commit
b9611281ae
@ -45,25 +45,11 @@ public class AdminPledge implements IAdminCommandHandler
|
||||
"admin_pledge"
|
||||
};
|
||||
|
||||
private enum CommandEnum
|
||||
{
|
||||
admin_pledge
|
||||
}
|
||||
|
||||
private enum ActionEnum
|
||||
{
|
||||
create,
|
||||
dismiss,
|
||||
info,
|
||||
setlevel,
|
||||
rep
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, PlayerInstance activeChar)
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command);
|
||||
final CommandEnum comm = CommandEnum.valueOf(st.nextToken());
|
||||
final String comm = st.nextToken();
|
||||
if (comm == null)
|
||||
{
|
||||
return false;
|
||||
@ -71,7 +57,7 @@ public class AdminPledge implements IAdminCommandHandler
|
||||
|
||||
switch (comm)
|
||||
{
|
||||
case admin_pledge:
|
||||
case "admin_pledge":
|
||||
{
|
||||
final WorldObject target = activeChar.getTarget();
|
||||
PlayerInstance player = null;
|
||||
@ -85,151 +71,157 @@ public class AdminPledge implements IAdminCommandHandler
|
||||
showMainPage(activeChar);
|
||||
return false;
|
||||
}
|
||||
|
||||
final String name = player.getName();
|
||||
ActionEnum action = null;
|
||||
String action = null;
|
||||
String parameter = null;
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
action = ActionEnum.valueOf(st.nextToken()); // create|info|dismiss|setlevel|rep
|
||||
if (action == null)
|
||||
{
|
||||
BuilderUtil.sendSysMessage(activeChar, "Not allowed Action on Clan");
|
||||
showMainPage(activeChar);
|
||||
return false;
|
||||
}
|
||||
action = st.nextToken(); // create|info|dismiss|setlevel|rep
|
||||
}
|
||||
if ((action != ActionEnum.create) && !player.isClanLeader())
|
||||
|
||||
if (action == null)
|
||||
{
|
||||
BuilderUtil.sendSysMessage(activeChar, "Not allowed Action on Clan");
|
||||
showMainPage(activeChar);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!action.equals("create") && !player.isClanLeader())
|
||||
{
|
||||
activeChar.sendPacket(new SystemMessage(SystemMessageId.S1_IS_NOT_A_CLAN_LEADER).addString(name));
|
||||
showMainPage(activeChar);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
parameter = st.nextToken(); // clanname|nothing|nothing|level|rep_points
|
||||
}
|
||||
if (action != null)
|
||||
|
||||
switch (action)
|
||||
{
|
||||
switch (action)
|
||||
case "create":
|
||||
{
|
||||
case create:
|
||||
if ((parameter == null) || (parameter.length() == 0))
|
||||
{
|
||||
if ((parameter == null) || (parameter.length() == 0))
|
||||
{
|
||||
BuilderUtil.sendSysMessage(activeChar, "Please, enter clan name.");
|
||||
showMainPage(activeChar);
|
||||
return false;
|
||||
}
|
||||
final long cet = player.getClanCreateExpiryTime();
|
||||
player.setClanCreateExpiryTime(0);
|
||||
final Clan clan = ClanTable.getInstance().createClan(player, parameter);
|
||||
if (clan != null)
|
||||
{
|
||||
BuilderUtil.sendSysMessage(activeChar, "Clan " + parameter + " created. Leader: " + player.getName());
|
||||
return true;
|
||||
}
|
||||
player.setClanCreateExpiryTime(cet);
|
||||
BuilderUtil.sendSysMessage(activeChar, "There was a problem while creating the clan.");
|
||||
BuilderUtil.sendSysMessage(activeChar, "Please, enter clan name.");
|
||||
showMainPage(activeChar);
|
||||
return false;
|
||||
}
|
||||
case dismiss:
|
||||
final long cet = player.getClanCreateExpiryTime();
|
||||
player.setClanCreateExpiryTime(0);
|
||||
final Clan clan = ClanTable.getInstance().createClan(player, parameter);
|
||||
if (clan != null)
|
||||
{
|
||||
ClanTable.getInstance().destroyClan(player.getClanId());
|
||||
final Clan clan = player.getClan();
|
||||
if (clan == null)
|
||||
{
|
||||
BuilderUtil.sendSysMessage(activeChar, "Clan disbanded.");
|
||||
return true;
|
||||
}
|
||||
BuilderUtil.sendSysMessage(activeChar, "There was a problem while destroying the clan.");
|
||||
BuilderUtil.sendSysMessage(activeChar, "Clan " + parameter + " created. Leader: " + player.getName());
|
||||
return true;
|
||||
}
|
||||
player.setClanCreateExpiryTime(cet);
|
||||
BuilderUtil.sendSysMessage(activeChar, "There was a problem while creating the clan.");
|
||||
showMainPage(activeChar);
|
||||
return false;
|
||||
}
|
||||
case "dismiss":
|
||||
{
|
||||
ClanTable.getInstance().destroyClan(player.getClanId());
|
||||
final Clan clan = player.getClan();
|
||||
if (clan == null)
|
||||
{
|
||||
BuilderUtil.sendSysMessage(activeChar, "Clan disbanded.");
|
||||
return true;
|
||||
}
|
||||
BuilderUtil.sendSysMessage(activeChar, "There was a problem while destroying the clan.");
|
||||
showMainPage(activeChar);
|
||||
return false;
|
||||
}
|
||||
case "info":
|
||||
{
|
||||
activeChar.sendPacket(new GMViewPledgeInfo(player.getClan(), player));
|
||||
return true;
|
||||
}
|
||||
case "rep":
|
||||
{
|
||||
if (parameter == null)
|
||||
{
|
||||
BuilderUtil.sendSysMessage(activeChar, "Usage: //pledge <setlevel|rep> <number>");
|
||||
showMainPage(activeChar);
|
||||
return false;
|
||||
}
|
||||
case info:
|
||||
int points = player.getClan().getReputationScore();
|
||||
try
|
||||
{
|
||||
activeChar.sendPacket(new GMViewPledgeInfo(player.getClan(), player));
|
||||
return true;
|
||||
points = Integer.parseInt(parameter);
|
||||
}
|
||||
case rep:
|
||||
catch (NumberFormatException nfe)
|
||||
{
|
||||
if (parameter == null)
|
||||
{
|
||||
BuilderUtil.sendSysMessage(activeChar, "Usage: //pledge <setlevel|rep> <number>");
|
||||
showMainPage(activeChar);
|
||||
return false;
|
||||
}
|
||||
int points = player.getClan().getReputationScore();
|
||||
try
|
||||
{
|
||||
points = Integer.parseInt(parameter);
|
||||
}
|
||||
catch (NumberFormatException nfe)
|
||||
{
|
||||
BuilderUtil.sendSysMessage(activeChar, "Points incorrect.");
|
||||
BuilderUtil.sendSysMessage(activeChar, "Usage: //pledge <setlevel|rep> <number>");
|
||||
showMainPage(activeChar);
|
||||
return false;
|
||||
}
|
||||
final Clan clan = player.getClan();
|
||||
if (clan.getLevel() < 5)
|
||||
{
|
||||
BuilderUtil.sendSysMessage(activeChar, "Only clans of level 5 or above may receive reputation points.");
|
||||
showMainPage(activeChar);
|
||||
return false;
|
||||
}
|
||||
clan.setReputationScore(clan.getReputationScore() + points, true);
|
||||
BuilderUtil.sendSysMessage(activeChar, "You " + (points > 0 ? "add " : "remove ") + Math.abs(points) + " points " + (points > 0 ? "to " : "from ") + clan.getName() + "'s reputation. Their current score is " + clan.getReputationScore());
|
||||
return true;
|
||||
BuilderUtil.sendSysMessage(activeChar, "Points incorrect.");
|
||||
BuilderUtil.sendSysMessage(activeChar, "Usage: //pledge <setlevel|rep> <number>");
|
||||
showMainPage(activeChar);
|
||||
return false;
|
||||
}
|
||||
case setlevel:
|
||||
final Clan clan = player.getClan();
|
||||
if (clan.getLevel() < 5)
|
||||
{
|
||||
BuilderUtil.sendSysMessage(activeChar, "Only clans of level 5 or above may receive reputation points.");
|
||||
showMainPage(activeChar);
|
||||
return false;
|
||||
}
|
||||
clan.setReputationScore(clan.getReputationScore() + points, true);
|
||||
BuilderUtil.sendSysMessage(activeChar, "You " + (points > 0 ? "add " : "remove ") + Math.abs(points) + " points " + (points > 0 ? "to " : "from ") + clan.getName() + "'s reputation. Their current score is " + clan.getReputationScore());
|
||||
return true;
|
||||
}
|
||||
case "setlevel":
|
||||
{
|
||||
if (parameter == null)
|
||||
{
|
||||
BuilderUtil.sendSysMessage(activeChar, "Usage: //pledge <setlevel|rep> <number>");
|
||||
showMainPage(activeChar);
|
||||
return false;
|
||||
}
|
||||
int level = player.getClan().getLevel();
|
||||
try
|
||||
{
|
||||
level = Integer.parseInt(parameter);
|
||||
}
|
||||
catch (NumberFormatException nfe)
|
||||
{
|
||||
if (parameter == null)
|
||||
{
|
||||
BuilderUtil.sendSysMessage(activeChar, "Usage: //pledge <setlevel|rep> <number>");
|
||||
showMainPage(activeChar);
|
||||
return false;
|
||||
}
|
||||
int level = player.getClan().getLevel();
|
||||
try
|
||||
{
|
||||
level = Integer.parseInt(parameter);
|
||||
}
|
||||
catch (NumberFormatException nfe)
|
||||
{
|
||||
BuilderUtil.sendSysMessage(activeChar, "Level incorrect.");
|
||||
BuilderUtil.sendSysMessage(activeChar, "Usage: //pledge <setlevel|rep> <number>");
|
||||
showMainPage(activeChar);
|
||||
return false;
|
||||
}
|
||||
if ((level >= 0) && (level < 9))
|
||||
{
|
||||
player.getClan().changeLevel(level);
|
||||
BuilderUtil.sendSysMessage(activeChar, "You set level " + level + " for clan " + player.getClan().getName());
|
||||
return true;
|
||||
}
|
||||
BuilderUtil.sendSysMessage(activeChar, "Level incorrect.");
|
||||
BuilderUtil.sendSysMessage(activeChar, "Usage: //pledge <setlevel|rep> <number>");
|
||||
showMainPage(activeChar);
|
||||
return false;
|
||||
}
|
||||
default:
|
||||
if ((level >= 0) && (level < 9))
|
||||
{
|
||||
BuilderUtil.sendSysMessage(activeChar, "Clan Action not allowed...");
|
||||
showMainPage(activeChar);
|
||||
return false;
|
||||
player.getClan().changeLevel(level);
|
||||
BuilderUtil.sendSysMessage(activeChar, "You set level " + level + " for clan " + player.getClan().getName());
|
||||
return true;
|
||||
}
|
||||
BuilderUtil.sendSysMessage(activeChar, "Level incorrect.");
|
||||
BuilderUtil.sendSysMessage(activeChar, "Usage: //pledge <setlevel|rep> <number>");
|
||||
showMainPage(activeChar);
|
||||
return false;
|
||||
}
|
||||
default:
|
||||
{
|
||||
BuilderUtil.sendSysMessage(activeChar, "Clan Action not allowed...");
|
||||
showMainPage(activeChar);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
default:
|
||||
{
|
||||
BuilderUtil.sendSysMessage(activeChar, "Clan command not allowed");
|
||||
showMainPage(activeChar);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void showMainPage(PlayerInstance activeChar)
|
||||
{
|
||||
AdminHelpPage.showHelpPage(activeChar, "game_menu.htm");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -237,9 +229,4 @@ public class AdminPledge implements IAdminCommandHandler
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
private void showMainPage(PlayerInstance activeChar)
|
||||
{
|
||||
AdminHelpPage.showHelpPage(activeChar, "game_menu.htm");
|
||||
}
|
||||
}
|
||||
|
@ -42,26 +42,19 @@ public class AdminShutdown implements IAdminCommandHandler
|
||||
"admin_server_abort"
|
||||
};
|
||||
|
||||
private enum CommandEnum
|
||||
{
|
||||
admin_server_shutdown,
|
||||
admin_server_restart,
|
||||
admin_server_abort
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, PlayerInstance activeChar)
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command);
|
||||
final CommandEnum comm = CommandEnum.valueOf(st.nextToken());
|
||||
if (comm == null)
|
||||
final String comm = st.nextToken();
|
||||
if (command == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (comm)
|
||||
{
|
||||
case admin_server_shutdown:
|
||||
case "admin_server_shutdown":
|
||||
{
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
@ -86,7 +79,7 @@ public class AdminShutdown implements IAdminCommandHandler
|
||||
sendHtmlForm(activeChar);
|
||||
return false;
|
||||
}
|
||||
case admin_server_restart:
|
||||
case "admin_server_restart":
|
||||
{
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
@ -111,7 +104,7 @@ public class AdminShutdown implements IAdminCommandHandler
|
||||
sendHtmlForm(activeChar);
|
||||
return false;
|
||||
}
|
||||
case admin_server_abort:
|
||||
case "admin_server_abort":
|
||||
{
|
||||
serverAbort(activeChar);
|
||||
return true;
|
||||
@ -120,12 +113,6 @@ public class AdminShutdown implements IAdminCommandHandler
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
private void sendHtmlForm(PlayerInstance activeChar)
|
||||
{
|
||||
final NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
|
||||
@ -156,4 +143,10 @@ public class AdminShutdown implements IAdminCommandHandler
|
||||
{
|
||||
Shutdown.getInstance().abort(activeChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
|
@ -48,6 +48,12 @@ public class Repair implements IVoicedCommandHandler, ICustomByPassHandler
|
||||
"repair",
|
||||
};
|
||||
|
||||
private static final String[] BYPASS_COMMANDS =
|
||||
{
|
||||
"repair",
|
||||
"repair_close_win"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useVoicedCommand(String command, PlayerInstance activeChar, String target)
|
||||
{
|
||||
@ -229,42 +235,17 @@ public class Repair implements IVoicedCommandHandler, ICustomByPassHandler
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getVoicedCommandList()
|
||||
{
|
||||
return VOICED_COMMANDS;
|
||||
}
|
||||
|
||||
private static final String[] _BYPASSCMD =
|
||||
{
|
||||
"repair",
|
||||
"repair_close_win"
|
||||
};
|
||||
|
||||
private enum CommandEnum
|
||||
{
|
||||
repair,
|
||||
repair_close_win
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getByPassCommands()
|
||||
{
|
||||
return _BYPASSCMD;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCommand(String command, PlayerInstance activeChar, String repairChar)
|
||||
{
|
||||
final CommandEnum comm = CommandEnum.valueOf(command);
|
||||
if (comm == null)
|
||||
if (command == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
switch (comm)
|
||||
switch (command)
|
||||
{
|
||||
case repair:
|
||||
case "repair":
|
||||
{
|
||||
if ((repairChar == null) || repairChar.equals(""))
|
||||
{
|
||||
@ -310,11 +291,23 @@ public class Repair implements IVoicedCommandHandler, ICustomByPassHandler
|
||||
activeChar.sendPacket(npcHtmlMessage);
|
||||
return;
|
||||
}
|
||||
case repair_close_win:
|
||||
case "repair_close_win":
|
||||
{
|
||||
// Do nothing.
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getVoicedCommandList()
|
||||
{
|
||||
return VOICED_COMMANDS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getByPassCommands()
|
||||
{
|
||||
return BYPASS_COMMANDS;
|
||||
}
|
||||
}
|
||||
|
@ -29,24 +29,17 @@ public class StatsCmd implements IVoicedCommandHandler
|
||||
"stats"
|
||||
};
|
||||
|
||||
private enum CommandEnum
|
||||
{
|
||||
stat,
|
||||
stats
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useVoicedCommand(String command, PlayerInstance activeChar, String target)
|
||||
{
|
||||
final CommandEnum comm = CommandEnum.valueOf(command);
|
||||
if (comm == null)
|
||||
if (command == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (comm)
|
||||
switch (command)
|
||||
{
|
||||
case stat:
|
||||
case "stat":
|
||||
{
|
||||
if (!Config.ALLOW_DETAILED_STATS_VIEW)
|
||||
{
|
||||
@ -117,7 +110,7 @@ public class StatsCmd implements IVoicedCommandHandler
|
||||
activeChar.sendPacket(adminReply);
|
||||
return true;
|
||||
}
|
||||
case stats:
|
||||
case "stats":
|
||||
{
|
||||
if (!Config.ALLOW_SIMPLE_STATS_VIEW)
|
||||
{
|
||||
@ -138,6 +131,7 @@ public class StatsCmd implements IVoicedCommandHandler
|
||||
activeChar.sendMessage("You can only get the info of a player.");
|
||||
return false;
|
||||
}
|
||||
|
||||
final PlayerInstance targetp = (PlayerInstance) activeChar.getTarget();
|
||||
if (targetp != null)
|
||||
{
|
||||
@ -156,13 +150,12 @@ public class StatsCmd implements IVoicedCommandHandler
|
||||
activeChar.sendPacket(adminReply);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
default:
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user