Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### Eclipse Workspace Patch 1.0
- #P Dream_GameServer
- Index: src/com/dream/game/templates/item/L2Item.java
- ===================================================================
- --- src/com/dream/game/templates/item/L2Item.java (revision 1821)
- +++ src/com/dream/game/templates/item/L2Item.java (working copy)
- @@ -130,6 +130,7 @@
- };
- private final int _itemId;
- + private final String _icon;
- private final int _itemDisplayId;
- private final String _name;
- private final int _type1;
- @@ -159,6 +160,7 @@
- {
- _type = type;
- _itemId = set.getInteger("item_id");
- + _icon = set.getString("icon", null);
- _itemDisplayId = set.getInteger("item_display_id");
- _name = set.getString("name");
- _type1 = set.getInteger("type1");
- @@ -503,6 +505,11 @@
- return getName();
- }
- + public String getIcon()
- + {
- + return _icon;
- + }
- +
- @Override
- public final L2Skill getFuncOwnerSkill()
- {
- Index: src/com/dream/game/handler/admin/AdminInvetory.java
- ===================================================================
- --- src/com/dream/game/handler/admin/AdminInvetory.java (revision 0)
- +++ src/com/dream/game/handler/admin/AdminInvetory.java (working copy)
- @@ -0,0 +1,144 @@
- +/*
- + * Copyright (C) 2004-2014 L2J DataPack
- + *
- + * This file is part of L2J DataPack.
- + *
- + * L2J DataPack 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.
- + *
- + * L2J DataPack 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 com.dream.game.handler.admin;
- +
- +import com.dream.game.access.gmHandler;
- +import com.dream.game.model.actor.instance.L2ItemInstance;
- +import com.dream.game.model.actor.instance.L2PcInstance;
- +import com.dream.game.network.serverpackets.NpcHtmlMessage;
- +import com.dream.game.util.Util;
- +
- +/**
- + * This class handles following admin commands:
- + * <ul>
- + * <li>show_ivetory</li>
- + * <li>delete_item</li>
- + * </ul>
- + * @author Zealar
- + */
- +public class AdminInvetory extends gmHandler
- +{
- + private static final String[] ADMIN_COMMANDS =
- + {
- + "admin_show_inventory",
- + "admin_delete_item"
- + };
- +
- + @Override
- + public void runCommand(L2PcInstance admin, String... params)
- + {
- + if (admin == null)
- + {
- + return;
- + }
- + if ((admin.getTarget() == null))
- + {
- + admin.sendMessage("Select a target");
- + return;
- + }
- +
- + final String command = params[0];
- +
- + L2PcInstance player = admin.getTarget().getActingPlayer();
- +
- + if (command.startsWith(ADMIN_COMMANDS[0]))
- + {
- + if (command.length() > ADMIN_COMMANDS[0].length())
- + {
- + String com = command.substring(ADMIN_COMMANDS[0].length() + 1);
- + if (Util.isDigit(com))
- + {
- + showItemsPage(admin, Integer.parseInt(com));
- + }
- + }
- +
- + else
- + {
- + showItemsPage(admin, 0);
- + }
- + }
- + else if (command.contains(ADMIN_COMMANDS[1]))
- + {
- + String val = command.substring(ADMIN_COMMANDS[1].length() + 1);
- +
- + player.destroyItem("GM Destroy", Integer.parseInt(val), player.getInventory().getItemByObjectId(Integer.parseInt(val)).getCount(), null, true);
- + showItemsPage(admin, 0);
- + }
- +
- + return;
- + }
- +
- + private void showItemsPage(L2PcInstance activeChar, int page)
- + {
- + final L2PcInstance target = activeChar.getTarget().getActingPlayer();
- +
- + final L2ItemInstance[] items = target.getInventory().getItems();
- +
- + int maxItemsPerPage = 10;
- + int maxPages = items.length / maxItemsPerPage;
- + if (items.length > (maxItemsPerPage * maxPages))
- + {
- + maxPages++;
- + }
- +
- + if (page > maxPages)
- + {
- + page = maxPages;
- + }
- +
- + int itemsStart = maxItemsPerPage * page;
- + int itemsEnd = items.length;
- + if ((itemsEnd - itemsStart) > maxItemsPerPage)
- + {
- + itemsEnd = itemsStart + maxItemsPerPage;
- + }
- +
- + final NpcHtmlMessage adminReply = new NpcHtmlMessage(page);
- + adminReply.setFile("data/html/admin/inventory.htm");
- + adminReply.replace("%PLAYER_NAME%", target.getName());
- +
- + StringBuilder sbPages = new StringBuilder();
- + for (int x = 0; x < maxPages; x++)
- + {
- + int pagenr = x + 1;
- + sbPages.append("<td><button value=\"" + String.valueOf(pagenr) + "\" action=\"bypass -h admin_show_inventory " + String.valueOf(x) + "\" width=20 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>");
- + }
- +
- + adminReply.replace("%PAGES%", sbPages.toString());
- +
- + StringBuilder sbItems = new StringBuilder();
- +
- + for (int i = itemsStart; i < itemsEnd; i++)
- + {
- + sbItems.append("<tr><td><img src=\"" + items[i].getItem().getIcon() + "\" width=32 height=32></td>");
- + sbItems.append("<td width=60>" + items[i].getName() + "</td>");
- + sbItems.append("<td><button action=\"bypass -h admin_delete_item " + String.valueOf(items[i].getObjectId()) + "\" width=16 height=16 back=\"L2UI_ct1.Button_DF_Delete\" fore=\"L2UI_ct1.Button_DF_Delete\">" + "</td></tr>");
- + }
- +
- + adminReply.replace("%ITEMS%", sbItems.toString());
- +
- + activeChar.sendPacket(adminReply);
- + }
- +
- + @Override
- + public String[] getCommandList()
- + {
- + return ADMIN_COMMANDS;
- + }
- +}
- \ No newline at end of file
- Index: src/com/dream/game/util/Util.java
- ===================================================================
- --- src/com/dream/game/util/Util.java (revision 1821)
- +++ src/com/dream/game/util/Util.java (working copy)
- @@ -555,4 +555,20 @@
- return false;
- }
- + public static boolean isDigit(String text)
- + {
- + if ((text == null) || text.isEmpty())
- + {
- + return false;
- + }
- + for (char c : text.toCharArray())
- + {
- + if (!Character.isDigit(c))
- + {
- + return false;
- + }
- + }
- + return true;
- + }
- +
- }
- \ No newline at end of file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement