Advertisement
Fabbian

Untitled

Oct 31st, 2014
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.09 KB | None | 0 0
  1. ### Eclipse Workspace Patch 1.0
  2. #P Dream_GameServer
  3. Index: src/com/dream/game/templates/item/L2Item.java
  4. ===================================================================
  5. --- src/com/dream/game/templates/item/L2Item.java (revision 1821)
  6. +++ src/com/dream/game/templates/item/L2Item.java (working copy)
  7. @@ -130,6 +130,7 @@
  8. };
  9.  
  10. private final int _itemId;
  11. + private final String _icon;
  12. private final int _itemDisplayId;
  13. private final String _name;
  14. private final int _type1;
  15. @@ -159,6 +160,7 @@
  16. {
  17. _type = type;
  18. _itemId = set.getInteger("item_id");
  19. + _icon = set.getString("icon", null);
  20. _itemDisplayId = set.getInteger("item_display_id");
  21. _name = set.getString("name");
  22. _type1 = set.getInteger("type1");
  23. @@ -503,6 +505,11 @@
  24. return getName();
  25. }
  26.  
  27. + public String getIcon()
  28. + {
  29. + return _icon;
  30. + }
  31. +
  32. @Override
  33. public final L2Skill getFuncOwnerSkill()
  34. {
  35. Index: src/com/dream/game/handler/admin/AdminInvetory.java
  36. ===================================================================
  37. --- src/com/dream/game/handler/admin/AdminInvetory.java (revision 0)
  38. +++ src/com/dream/game/handler/admin/AdminInvetory.java (working copy)
  39. @@ -0,0 +1,144 @@
  40. +/*
  41. + * Copyright (C) 2004-2014 L2J DataPack
  42. + *
  43. + * This file is part of L2J DataPack.
  44. + *
  45. + * L2J DataPack is free software: you can redistribute it and/or modify
  46. + * it under the terms of the GNU General Public License as published by
  47. + * the Free Software Foundation, either version 3 of the License, or
  48. + * (at your option) any later version.
  49. + *
  50. + * L2J DataPack is distributed in the hope that it will be useful,
  51. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  52. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  53. + * General Public License for more details.
  54. + *
  55. + * You should have received a copy of the GNU General Public License
  56. + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  57. + */
  58. +package com.dream.game.handler.admin;
  59. +
  60. +import com.dream.game.access.gmHandler;
  61. +import com.dream.game.model.actor.instance.L2ItemInstance;
  62. +import com.dream.game.model.actor.instance.L2PcInstance;
  63. +import com.dream.game.network.serverpackets.NpcHtmlMessage;
  64. +import com.dream.game.util.Util;
  65. +
  66. +/**
  67. + * This class handles following admin commands:
  68. + * <ul>
  69. + * <li>show_ivetory</li>
  70. + * <li>delete_item</li>
  71. + * </ul>
  72. + * @author Zealar
  73. + */
  74. +public class AdminInvetory extends gmHandler
  75. +{
  76. + private static final String[] ADMIN_COMMANDS =
  77. + {
  78. + "admin_show_inventory",
  79. + "admin_delete_item"
  80. + };
  81. +
  82. + @Override
  83. + public void runCommand(L2PcInstance admin, String... params)
  84. + {
  85. + if (admin == null)
  86. + {
  87. + return;
  88. + }
  89. + if ((admin.getTarget() == null))
  90. + {
  91. + admin.sendMessage("Select a target");
  92. + return;
  93. + }
  94. +
  95. + final String command = params[0];
  96. +
  97. + L2PcInstance player = admin.getTarget().getActingPlayer();
  98. +
  99. + if (command.startsWith(ADMIN_COMMANDS[0]))
  100. + {
  101. + if (command.length() > ADMIN_COMMANDS[0].length())
  102. + {
  103. + String com = command.substring(ADMIN_COMMANDS[0].length() + 1);
  104. + if (Util.isDigit(com))
  105. + {
  106. + showItemsPage(admin, Integer.parseInt(com));
  107. + }
  108. + }
  109. +
  110. + else
  111. + {
  112. + showItemsPage(admin, 0);
  113. + }
  114. + }
  115. + else if (command.contains(ADMIN_COMMANDS[1]))
  116. + {
  117. + String val = command.substring(ADMIN_COMMANDS[1].length() + 1);
  118. +
  119. + player.destroyItem("GM Destroy", Integer.parseInt(val), player.getInventory().getItemByObjectId(Integer.parseInt(val)).getCount(), null, true);
  120. + showItemsPage(admin, 0);
  121. + }
  122. +
  123. + return;
  124. + }
  125. +
  126. + private void showItemsPage(L2PcInstance activeChar, int page)
  127. + {
  128. + final L2PcInstance target = activeChar.getTarget().getActingPlayer();
  129. +
  130. + final L2ItemInstance[] items = target.getInventory().getItems();
  131. +
  132. + int maxItemsPerPage = 10;
  133. + int maxPages = items.length / maxItemsPerPage;
  134. + if (items.length > (maxItemsPerPage * maxPages))
  135. + {
  136. + maxPages++;
  137. + }
  138. +
  139. + if (page > maxPages)
  140. + {
  141. + page = maxPages;
  142. + }
  143. +
  144. + int itemsStart = maxItemsPerPage * page;
  145. + int itemsEnd = items.length;
  146. + if ((itemsEnd - itemsStart) > maxItemsPerPage)
  147. + {
  148. + itemsEnd = itemsStart + maxItemsPerPage;
  149. + }
  150. +
  151. + final NpcHtmlMessage adminReply = new NpcHtmlMessage(page);
  152. + adminReply.setFile("data/html/admin/inventory.htm");
  153. + adminReply.replace("%PLAYER_NAME%", target.getName());
  154. +
  155. + StringBuilder sbPages = new StringBuilder();
  156. + for (int x = 0; x < maxPages; x++)
  157. + {
  158. + int pagenr = x + 1;
  159. + 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>");
  160. + }
  161. +
  162. + adminReply.replace("%PAGES%", sbPages.toString());
  163. +
  164. + StringBuilder sbItems = new StringBuilder();
  165. +
  166. + for (int i = itemsStart; i < itemsEnd; i++)
  167. + {
  168. + sbItems.append("<tr><td><img src=\"" + items[i].getItem().getIcon() + "\" width=32 height=32></td>");
  169. + sbItems.append("<td width=60>" + items[i].getName() + "</td>");
  170. + 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>");
  171. + }
  172. +
  173. + adminReply.replace("%ITEMS%", sbItems.toString());
  174. +
  175. + activeChar.sendPacket(adminReply);
  176. + }
  177. +
  178. + @Override
  179. + public String[] getCommandList()
  180. + {
  181. + return ADMIN_COMMANDS;
  182. + }
  183. +}
  184. \ No newline at end of file
  185. Index: src/com/dream/game/util/Util.java
  186. ===================================================================
  187. --- src/com/dream/game/util/Util.java (revision 1821)
  188. +++ src/com/dream/game/util/Util.java (working copy)
  189. @@ -555,4 +555,20 @@
  190. return false;
  191. }
  192.  
  193. + public static boolean isDigit(String text)
  194. + {
  195. + if ((text == null) || text.isEmpty())
  196. + {
  197. + return false;
  198. + }
  199. + for (char c : text.toCharArray())
  200. + {
  201. + if (!Character.isDigit(c))
  202. + {
  203. + return false;
  204. + }
  205. + }
  206. + return true;
  207. + }
  208. +
  209. }
  210. \ No newline at end of file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement