package l2r.gameserver.scripts.handlers.admincommandhandlers;
import l2r.gameserver.handler.IAdminCommandHandler;
import l2r.gameserver.model.L2Object;
import l2r.gameserver.model.actor.instance.L2PcInstance;
/**
* @author Ventic
*/
public class AdminSit implements IAdminCommandHandler
{
private static final String[] ADMIN_COMMANDS =
{
"sit",
"stand",
"rangesit",
"rangestand"
};
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if (command.startsWith("sit"))
{
L2Object target = activeChar.getTarget();
L2PcInstance player = null;
if (target instanceof L2PcInstance)
{
player = (L2PcInstance) target;
}
else
{
activeChar.sendMessage("No target found");
return false;
}
if (!activeChar.isSitting())
{
player.sitDown();
}
}
else if (command.startsWith("stand"))
{
L2Object target = activeChar.getTarget();
L2PcInstance player = null;
if (target instanceof L2PcInstance)
{
player = (L2PcInstance) target;
}
else
{
activeChar.sendMessage("No target found");
return false;
}
if (activeChar.isSitting())
{
player.standUp();
}
}
else if (command.startsWith("rangesit"))
{
for (L2PcInstance p : activeChar.getKnownList().getKnownPlayersInRadius(240))
{
if ((p != null) && !p.isSitting())
{
p.sitDown();
}
}
}
else if (command.startsWith("rangestand"))
{
for (L2PcInstance pPc : activeChar.getKnownList().getKnownPlayersInRadius(240))
{
if ((pPc != null) && pPc.isSitting())
{
pPc.standUp();
}
}
}
return true;
}
@Override
public String[] getAdminCommandList()
{
return ADMIN_COMMANDS;
}
}
Better so many casts for nothing..