l2j_mobius/trunk/dist/game/data/scripts/handlers/admincommandhandlers/AdminHellbound.java
2015-01-01 20:02:50 +00:00

96 lines
2.8 KiB
Java

/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.admincommandhandlers;
import java.util.StringTokenizer;
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
import hellbound.HellboundEngine;
/**
* Hellbound admin command.
* @author DS, Gladicek
*/
public class AdminHellbound implements IAdminCommandHandler
{
private static final String[] ADMIN_COMMANDS =
{
"admin_hellbound_setlevel",
"admin_hellbound"
};
@Override
public String[] getAdminCommandList()
{
return ADMIN_COMMANDS;
}
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if (activeChar == null)
{
return false;
}
if (command.startsWith(ADMIN_COMMANDS[0]))
{
try
{
StringTokenizer st = new StringTokenizer(command, " ");
st.nextToken();
final int level = Integer.parseInt(st.nextToken());
if ((level < 0) || (level > 11))
{
throw new NumberFormatException();
}
HellboundEngine.getInstance().setLevel(level);
activeChar.sendMessage("Hellbound level set to " + level);
return true;
}
catch (Exception e)
{
activeChar.sendMessage("Usage: //hellbound_setlevel 0-11");
return false;
}
}
else if (command.startsWith(ADMIN_COMMANDS[1]))
{
showMenu(activeChar);
return true;
}
return false;
}
private void showMenu(L2PcInstance activeChar)
{
final NpcHtmlMessage html = new NpcHtmlMessage();
html.setFile(activeChar.getHtmlPrefix(), "data/html/admin/hellbound.htm");
html.replace("%hbstage%", String.valueOf(HellboundEngine.getInstance().getLevel()));
html.replace("%trust%", String.valueOf(HellboundEngine.getInstance().getTrust()));
html.replace("%maxtrust%", String.valueOf(HellboundEngine.getInstance().getMaxTrust()));
html.replace("%mintrust%", String.valueOf(HellboundEngine.getInstance().getMinTrust()));
activeChar.sendPacket(html);
}
}