/*
* 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 silentium.gameserver.network.clientpackets;
import silentium.gameserver.model.L2Clan;
import silentium.gameserver.model.L2World;
import silentium.gameserver.model.actor.instance.L2PcInstance;
import silentium.gameserver.network.serverpackets.GMViewCharacterInfo;
import silentium.gameserver.network.serverpackets.GMViewHennaInfo;
import silentium.gameserver.network.serverpackets.GMViewItemList;
import silentium.gameserver.network.serverpackets.GMViewPledgeInfo;
import silentium.gameserver.network.serverpackets.GMViewQuestList;
import silentium.gameserver.network.serverpackets.GMViewSkillInfo;
import silentium.gameserver.network.serverpackets.GMViewWarehouseWithdrawList;
import silentium.gameserver.tables.ClanTable;
public final class RequestGMCommand extends L2GameClientPacket
{
private String _targetName;
private int _command;
@Override
protected void readImpl()
{
_targetName = readS();
_command = readD();
}
@Override
protected void runImpl()
{
final L2PcInstance activeChar = getClient().getActiveChar();
if (activeChar == null)
return;
// prevent non gm or low level GMs from viewing player stuff
if (!activeChar.isGM() || !activeChar.getAccessLevel().allowAltG())
return;
final L2PcInstance target = L2World.getInstance().getPlayer(_targetName);
final L2Clan clan = ClanTable.getInstance().getClanByName(_targetName);
if (target == null && (clan == null || _command != 6))
return;
switch (_command)
{
case 1: // target status
sendPacket(new GMViewCharacterInfo(target));
sendPacket(new GMViewHennaInfo(target));
break;
case 2: // target clan
if (target != null && target.getClan() != null)
sendPacket(new GMViewPledgeInfo(target.getClan(), target));
break;
case 3: // target skills
sendPacket(new GMViewSkillInfo(target));
break;
case 4: // target quests
sendPacket(new GMViewQuestList(target));
break;
case 5: // target inventory
sendPacket(new GMViewItemList(target));
sendPacket(new GMViewHennaInfo(target));
break;
case 6: // player or clan warehouse
if (target != null)
sendPacket(new GMViewWarehouseWithdrawList(target));
else
sendPacket(new GMViewWarehouseWithdrawList(clan));
break;
}
}
}