Addition of admin destroyitems command.

This commit is contained in:
MobiusDevelopment 2020-02-01 11:19:17 +00:00
parent 43c4afeb25
commit 2958d0af43
3 changed files with 69 additions and 0 deletions

View File

@ -115,6 +115,12 @@
<!-- Section: Delete -->
<admin command="admin_delete" accessLevel="80" />
<!-- Section: Destroy Items -->
<admin command="admin_destroy_items" accessLevel="80" />
<admin command="admin_destroy_all_items" accessLevel="80" />
<admin command="admin_destroyitems" accessLevel="80" />
<admin command="admin_destroyallitems" accessLevel="80" />
<!-- Section: Disconnect -->
<admin command="admin_character_disconnect" accessLevel="90" />

View File

@ -33,6 +33,7 @@ import org.l2jmobius.gameserver.handler.admincommandhandlers.AdminCreateItem;
import org.l2jmobius.gameserver.handler.admincommandhandlers.AdminCursedWeapons;
import org.l2jmobius.gameserver.handler.admincommandhandlers.AdminDMEngine;
import org.l2jmobius.gameserver.handler.admincommandhandlers.AdminDelete;
import org.l2jmobius.gameserver.handler.admincommandhandlers.AdminDestroyItems;
import org.l2jmobius.gameserver.handler.admincommandhandlers.AdminDonator;
import org.l2jmobius.gameserver.handler.admincommandhandlers.AdminDoorControl;
import org.l2jmobius.gameserver.handler.admincommandhandlers.AdminEditChar;
@ -114,6 +115,7 @@ public class AdminCommandHandler
registerAdminCommandHandler(new AdminCTFEngine());
registerAdminCommandHandler(new AdminCursedWeapons());
registerAdminCommandHandler(new AdminDelete());
registerAdminCommandHandler(new AdminDestroyItems());
registerAdminCommandHandler(new AdminDMEngine());
registerAdminCommandHandler(new AdminDonator());
registerAdminCommandHandler(new AdminDoorControl());

View File

@ -0,0 +1,61 @@
/*
* This file is part of the L2J Mobius project.
*
* 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 org.l2jmobius.gameserver.handler.admincommandhandlers;
import org.l2jmobius.gameserver.handler.IAdminCommandHandler;
import org.l2jmobius.gameserver.model.PlayerInventory;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.network.serverpackets.InventoryUpdate;
/**
* @author Mobius
*/
public class AdminDestroyItems implements IAdminCommandHandler
{
private static final String[] ADMIN_COMMANDS =
{
"admin_destroy_items",
"admin_destroy_all_items",
"admin_destroyitems",
"admin_destroyallitems"
};
@Override
public boolean useAdminCommand(String command, PlayerInstance activeChar)
{
final PlayerInventory inventory = activeChar.getInventory();
final InventoryUpdate iu = new InventoryUpdate();
for (ItemInstance item : inventory.getItems())
{
if (item.isEquipped() && !command.contains("all"))
{
continue;
}
iu.addRemovedItem(item);
inventory.destroyItem("Admin Destroy", item, activeChar, null);
}
activeChar.sendPacket(iu);
return true;
}
@Override
public String[] getAdminCommandList()
{
return ADMIN_COMMANDS;
}
}