/* * 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 handlers.admincommandhandlers;import com.l2jserver.gameserver.handler.IAdminCommandHandler;import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;import com.l2jserver.gameserver.datatables.ItemTable;import com.l2jserver.gameserver.model.L2ItemInstance;import java.util.StringTokenizer;import com.l2jserver.gameserver.network.serverpackets.InventoryUpdate;import com.l2jserver.gameserver.model.L2World;import com.l2jserver.gameserver.templates.item.L2Item;public class AdminWipe implements IAdminCommandHandler{ private static final String[] ADMIN_COMMANDS = { "admin_wipe" }; /** * * @see com.l2jserver.gameserver.handler.IAdminCommandHandler#useAdminCommand(java.lang.String, com.l2jserver.gameserver.model.actor.instance.L2PcInstance) */ public boolean useAdminCommand(String command, L2PcInstance activeChar) { StringTokenizer st = new StringTokenizer(command, " "); String[] cmds = command.split(" "); String cmd = st.nextToken(); if (cmd.equals("admin_wipe")) { // @author Szponiasty(Angakaran) if (cmds.length < 3 || cmds.length > 4) { activeChar.sendMessage("Usage:"); activeChar.sendMessage("//wipe <itemid> <count> <nickname>"); return true; } int itemId = -1; int itemCount = -1; L2PcInstance _toErase = (cmds.length < 4 ? (activeChar.getTarget() != null ? activeChar.getTarget().getActingPlayer() : activeChar) : L2World.getInstance().getPlayer(cmds[3])); try { itemId = Integer.valueOf(cmds[1]); itemCount = Integer.valueOf(cmds[2]); } catch (Exception e) { e.printStackTrace(); return false; } L2ItemInstance item = _toErase.getInventory().destroyItemByItemId("Inveraser", itemId, itemCount, _toErase, null); InventoryUpdate iu = new InventoryUpdate(); L2Item template = ItemTable.getInstance().getTemplate(itemId); if (_toErase instanceof L2PcInstance && _toErase.getName() == activeChar.getName()) { iu.addRemovedItem(item); _toErase.sendPacket(iu); _toErase.getInventory().updateDatabase(); _toErase.sendMessage("N00Bz0r you wiped from your inventory :)))"); } else if (_toErase instanceof L2PcInstance && _toErase.getName() != activeChar.getName() && _toErase.isOnline() > 0) { iu.addRemovedItem(item); _toErase.sendPacket(iu); _toErase.getInventory().updateDatabase(); _toErase.sendMessage(activeChar.getName()+" wiped "+itemCount+" "+template.getName()+" from your inventory."); } else { activeChar.sendMessage("Invalid target."); return false; } return true; } return true; } /** * * @see com.l2jserver.gameserver.handler.IAdminCommandHandler#getAdminCommandList() */ public String[] getAdminCommandList() { return ADMIN_COMMANDS; }}