/*
* This program 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.
*
* This program 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 lineage2.gameserver.handler.admincommands.impl;
import lineage2.gameserver.data.xml.holder.ResidenceHolder;
import lineage2.gameserver.handler.admincommands.IAdminCommandHandler;
import lineage2.gameserver.model.GameObject;
import lineage2.gameserver.model.Player;
import lineage2.gameserver.model.Zone;
import lineage2.gameserver.model.entity.residence.ClanHall;
import lineage2.gameserver.model.pledge.Clan;
import lineage2.gameserver.network.serverpackets.NpcHtmlMessage;
import lineage2.gameserver.network.serverpackets.components.SystemMsg;
import lineage2.gameserver.tables.ClanTable;
/**
* @author Mobius
* @version $Revision: 1.0 $
*/
public class AdminClanHall implements IAdminCommandHandler
{
/**
* @author Mobius
*/
private static enum Commands
{
/**
* Field admin_clanhall.
*/
admin_clanhall,
/**
* Field admin_clanhallset.
*/
admin_clanhallset,
/**
* Field admin_clanhalldel.
*/
admin_clanhalldel,
/**
* Field admin_clanhallteleportself.
*/
admin_clanhallteleportself
}
/**
* Method useAdminCommand.
* @param comm Enum<?>
* @param wordList String[]
* @param fullString String
* @param activeChar Player
* @return boolean * @see lineage2.gameserver.handler.admincommands.IAdminCommandHandler#useAdminCommand(Enum<?>, String[], String, Player)
*/
@Override
public boolean useAdminCommand(Enum<?> comm, String[] wordList, String fullString, Player activeChar)
{
Commands command = (Commands) comm;
if (!activeChar.getPlayerAccess().CanEditNPC)
{
return false;
}
ClanHall clanhall = null;
if (wordList.length > 1)
{
clanhall = ResidenceHolder.getInstance().getResidence(ClanHall.class, Integer.parseInt(wordList[1]));
}
if (clanhall == null)
{
showClanHallSelectPage(activeChar);
return true;
}
switch (command)
{
case admin_clanhall:
showClanHallSelectPage(activeChar);
break;
case admin_clanhallset:
GameObject target = activeChar.getTarget();
Player player = activeChar;
if ((target != null) && target.isPlayer())
{
player = (Player) target;
}
if (player.getClan() == null)
{
activeChar.sendPacket(SystemMsg.THAT_IS_AN_INCORRECT_TARGET);
}
else
{
clanhall.changeOwner(player.getClan());
}
break;
case admin_clanhalldel:
clanhall.changeOwner(null);
break;
case admin_clanhallteleportself:
Zone zone = clanhall.getZone();
if (zone != null)
{
activeChar.teleToLocation(zone.getSpawn());
}
break;
}
showClanHallPage(activeChar, clanhall);
return true;
}
/**
* Method showClanHallSelectPage.
* @param activeChar Player
*/
public void showClanHallSelectPage(Player activeChar)
{
NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
StringBuilder replyMSG = new StringBuilder("<html><body>");
replyMSG.append("<table width=268><tr>");
replyMSG.append("<td width=40><button value=\"Main\" action=\"bypass -h admin_admin\" width=40 height=15 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></td>");
replyMSG.append("<td width=180><center><font color=\"LEVEL\">Clan Halls:</font></center></td>");
replyMSG.append("<td width=40><button value=\"Back\" action=\"bypass -h admin_admin\" width=40 height=15 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></td>");
replyMSG.append("</tr></table><br>");
replyMSG.append("<table width=268>");
replyMSG.append("<tr><td width=130>ClanHall Name</td><td width=58>Town</td><td width=80>Owner</td></tr>");
replyMSG.append("</table>");
replyMSG.append("</body></html>");
adminReply.setHtml(replyMSG.toString());
activeChar.sendPacket(adminReply);
}
/**
* Method showClanHallPage.
* @param activeChar Player
* @param clanhall ClanHall
*/
public void showClanHallPage(Player activeChar, ClanHall clanhall)
{
NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
StringBuilder replyMSG = new StringBuilder("<html><body>");
replyMSG.append("<table width=260><tr>");
replyMSG.append("<td width=40><button value=\"Main\" action=\"bypass -h admin_admin\" width=40 height=15 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></td>");
replyMSG.append("<td width=180><center>ClanHall Name</center></td>");
replyMSG.append("<td width=40><button value=\"Back\" action=\"bypass -h admin_clanhall\" width=40 height=15 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></td>");
replyMSG.append("</tr></table>");
replyMSG.append("<center>");
replyMSG.append("<br><br><br>ClanHall: " + clanhall.getName() + "<br>");
replyMSG.append("Location: &^" + clanhall.getId() + ";<br>");
replyMSG.append("ClanHall Owner: ");
Clan owner = clanhall.getOwnerId() == 0 ? null : ClanTable.getInstance().getClan(clanhall.getOwnerId());
if (owner == null)
{
replyMSG.append("none");
}
else
{
replyMSG.append(owner.getName());
}
replyMSG.append("<br><br><br>");
replyMSG.append("<table>");
replyMSG.append("<tr><td><button value=\"Open Doors\" action=\"bypass -h admin_clanhallopendoors " + clanhall.getId() + "\" width=80 height=15 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></td>");
replyMSG.append("<td><button value=\"Close Doors\" action=\"bypass -h admin_clanhallclosedoors " + clanhall.getId() + "\" width=80 height=15 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></td></tr>");
replyMSG.append("</table>");
replyMSG.append("<br>");
replyMSG.append("<table>");
replyMSG.append("<tr><td><button value=\"Give ClanHall\" action=\"bypass -h admin_clanhallset " + clanhall.getId() + "\" width=80 height=15 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></td>");
replyMSG.append("<td><button value=\"Take ClanHall\" action=\"bypass -h admin_clanhalldel " + clanhall.getId() + "\" width=80 height=15 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></td></tr>");
replyMSG.append("</table>");
replyMSG.append("<br>");
replyMSG.append("<table><tr>");
replyMSG.append("<td><button value=\"Teleport self\" action=\"bypass -h admin_clanhallteleportself " + clanhall.getId() + " \" width=80 height=15 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></td></tr>");
replyMSG.append("</table>");
replyMSG.append("</center>");
replyMSG.append("</body></html>");
adminReply.setHtml(replyMSG.toString());
activeChar.sendPacket(adminReply);
}
/**
* Method getAdminCommandEnum.
* @return Enum[] * @see lineage2.gameserver.handler.admincommands.IAdminCommandHandler#getAdminCommandEnum()
*/
@Override
public Enum<?>[] getAdminCommandEnum()
{
return Commands.values();
}
}