Advertisement
ChristianMacedo

Bloquear Items Olympiadas L2jLisvus

Jun 20th, 2022 (edited)
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.09 KB | None | 0 0
  1. ### Eclipse Workspace Patch 1.0
  2. #P core
  3. diff --git java/config/Olympiad.properties
  4. index 5c25403..2263ab6 100644
  5. --- java/config/Olympiad.properties
  6. +++ java/config/Olympiad.properties
  7. @@ -80,9 +80,12 @@
  8. AltOlyLosePointsOnTie = True
  9.  
  10. # Hero tables show last month's winners or current status.
  11. # Default: True
  12. AltOlyShowMonthlyWinners = True
  13.  
  14. # Enchant limit for items during Olympiad games. Disabled = -1.
  15. # Default: -1
  16. AltOlyEnchantLimit = -1
  17. +
  18. +# Restrict specified items in Olympiad. ItemID's need to be separated with a comma (ex. 1,200,350)
  19. +AltOlyRestrictedItems = 7575,6379,858
  20. diff --git java/net/sf/l2j/Config.java
  21. index 88ec0a3..ac06dfa 100644
  22. --- java/net/sf/l2j/Config.java
  23. +++ java/net/sf/l2j/Config.java
  24. @@ -99,16 +99,18 @@
  25. public static boolean DEVELOPER;
  26. public static boolean ACCEPT_GEOEDITOR_CONN;
  27.  
  28. /** Set if this server is a test server used for development */
  29. public static boolean TEST_SERVER;
  30.  
  31. /** Enable upnp service */
  32. public static boolean ENABLE_UPNP;
  33. + public static String ALT_OLY_RESTRICTED_ITEMS;
  34. + public static List<Integer> LIST_OLY_RESTRICTED_ITEMS = new ArrayList<>();
  35.  
  36. /** Game Server ports */
  37. public static int PORT_GAME;
  38. /** Login Server port */
  39. public static int PORT_LOGIN;
  40. /** Login Server bind ip */
  41. public static String LOGIN_BIND_ADDRESS;
  42. /** Number of tries of login before ban */
  43. @@ -1920,17 +1922,22 @@
  44. {
  45. olympiadSettings.load(is);
  46. }
  47. catch (Exception e)
  48. {
  49. e.printStackTrace();
  50. throw new Error("Failed to Load " + OLYMPIAD_FILE + " File.");
  51. }
  52. + ALT_OLY_RESTRICTED_ITEMS = olympiadSettings.getProperty("AltOlyRestrictedItems", "0");
  53. + LIST_OLY_RESTRICTED_ITEMS = new ArrayList<>();
  54. + for (final String id : ALT_OLY_RESTRICTED_ITEMS.split(","))
  55. + {
  56. + LIST_OLY_RESTRICTED_ITEMS.add(Integer.parseInt(id));
  57. + }
  58. ALT_OLY_START_TIME = Integer.parseInt(olympiadSettings.getProperty("AltOlyStartTime", "20"));
  59. ALT_OLY_MIN = Integer.parseInt(olympiadSettings.getProperty("AltOlyMin", "00"));
  60. ALT_OLY_CPERIOD = Long.parseLong(olympiadSettings.getProperty("AltOlyCPeriod", "14400000"));
  61. ALT_OLY_BATTLE = Long.parseLong(olympiadSettings.getProperty("AltOlyBattle", "180000"));
  62. ALT_OLY_BWAIT = Long.parseLong(olympiadSettings.getProperty("AltOlyBWait", "600000"));
  63. ALT_OLY_IWAIT = Long.parseLong(olympiadSettings.getProperty("AltOlyIWait", "300000"));
  64. ALT_OLY_WPERIOD = Long.parseLong(olympiadSettings.getProperty("AltOlyWPeriod", "604800000"));
  65. ALT_OLY_VPERIOD = Long.parseLong(olympiadSettings.getProperty("AltOlyVPeriod", "86400000"));
  66. diff --git java/net/sf/l2j/gameserver/model/L2ItemInstance.java
  67. index 7d9342f..d21a224 100644
  68. --- java/net/sf/l2j/gameserver/model/L2ItemInstance.java
  69. +++ java/net/sf/l2j/gameserver/model/L2ItemInstance.java
  70. @@ -597,16 +597,29 @@
  71. * Returns if item is tradeable
  72. * @return boolean
  73. */
  74. public boolean isTradeable()
  75. {
  76. return _item.isTradeable();
  77. }
  78. + public boolean isOlyRestrictedItem()
  79. + {
  80. + return (Config.LIST_OLY_RESTRICTED_ITEMS.contains(_itemId));
  81. + }
  82. +
  83. + public boolean checkOlympCondition()
  84. + {
  85. + if (isOlyRestrictedItem())
  86. + return false;
  87. + return true;
  88. + }
  89. +
  90. /**
  91. * Returns if item is a hero item
  92. * @return boolean
  93. */
  94. public boolean isHeroItem()
  95. {
  96. return _item.isHeroItem();
  97. }
  98. diff --git java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
  99. index c09140b..9436f23 100644
  100. --- java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
  101. +++ java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
  102. @@ -12401,16 +12401,48 @@
  103. }
  104. }
  105. catch (Exception e)
  106. {
  107. _log.warning("Error found in " + getName() + "'s FriendList: " + e.getMessage() + e);
  108. }
  109. }
  110.  
  111. + public void checkItemOlympiad()
  112. + {
  113. + for (int i = 0; i < Inventory.PAPERDOLL_TOTALSLOTS; i++)
  114. + {
  115. + final L2ItemInstance equippedItem = getInventory().getPaperdollItem(i);
  116. + if (equippedItem != null && !equippedItem.checkOlympCondition())
  117. + {
  118. + final L2ItemInstance[] items = getInventory().unEquipItemInSlotAndRecord(i);
  119. + if (equippedItem.isWear())
  120. + continue;
  121. + SystemMessage sm = null;
  122. + if (equippedItem.getEnchantLevel() > 0)
  123. + {
  124. + sm = new SystemMessage(SystemMessage.EQUIPMENT_S1_S2_REMOVED);
  125. + sm.addNumber(equippedItem.getEnchantLevel());
  126. + sm.addItemName(equippedItem.getItemId());
  127. + }
  128. + else
  129. + {
  130. + sm = new SystemMessage(SystemMessage.S1_DISARMED);
  131. + sm.addItemName(equippedItem.getItemId());
  132. + }
  133. + sendPacket(sm);
  134. + final InventoryUpdate iu = new InventoryUpdate();
  135. + iu.addItems(Arrays.asList(items));
  136. + sendPacket(iu);
  137. + broadcastUserInfo();
  138. + }
  139. + }
  140. + }
  141. +
  142. +
  143. /**
  144. * Notifies this user's friends upon log in.
  145. */
  146. private void notifyFriends()
  147. {
  148. for (int id : _friendList)
  149. {
  150. L2PcInstance friend = L2World.getInstance().getPlayer(id);
  151. diff --git java/net/sf/l2j/gameserver/model/olympiad/OlympiadGame.java
  152. index a90442a..e676bdf 100644
  153. --- java/net/sf/l2j/gameserver/model/olympiad/OlympiadGame.java
  154. +++ java/net/sf/l2j/gameserver/model/olympiad/OlympiadGame.java
  155. @@ -196,16 +196,18 @@
  156. if (party != null)
  157. {
  158. party.removePartyMember(player, true);
  159. }
  160.  
  161. // Remove forbidden items
  162. player.checkItemRestriction();
  163.  
  164. + // Remove itens olympiadas custom
  165. + player.checkItemOlympiad();
  166.  
  167. // Remove shot automation
  168. player.disableAutoShotsAll();
  169.  
  170. // Discharge any active shots
  171. player.setChargedSoulShot(L2ItemInstance.CHARGED_NONE);
  172. player.setChargedSpiritShot(L2ItemInstance.CHARGED_NONE);
  173.  
  174. // Cubic cleanup
  175. diff --git java/net/sf/l2j/gameserver/network/clientpackets/UseItem.java
  176. index 302ea92..a47d89e 100644
  177. --- java/net/sf/l2j/gameserver/network/clientpackets/UseItem.java
  178. +++ java/net/sf/l2j/gameserver/network/clientpackets/UseItem.java
  179. @@ -198,16 +198,21 @@
  180. int bodyPart = item.getItem().getBodyPart();
  181.  
  182. // Prevent player to equip weapon/shield while mounted
  183. if (activeChar.isMounted() && ((bodyPart == L2Item.SLOT_LR_HAND) || (bodyPart == L2Item.SLOT_L_HAND) || (bodyPart == L2Item.SLOT_R_HAND)))
  184. {
  185. return;
  186. }
  187.  
  188. + if (activeChar.isInOlympiadMode() && ((bodyPart == L2Item.SLOT_LR_HAND || bodyPart == L2Item.SLOT_L_HAND || bodyPart == L2Item.SLOT_R_HAND) && (item.getItemId() >= 6611 && item.getItemId() <= 6621 || item.getItemId() == 6842) || Config.LIST_OLY_RESTRICTED_ITEMS.contains(item.getItemId())))
  189. + {
  190. + return;
  191. + }
  192. +
  193. // Don't allow weapon/shield equipment if wearing formal wear
  194. if (activeChar.isWearingFormalWear() && ((bodyPart == L2Item.SLOT_LR_HAND) || (bodyPart == L2Item.SLOT_L_HAND) || (bodyPart == L2Item.SLOT_R_HAND)))
  195. {
  196. activeChar.sendPacket(new SystemMessage(SystemMessage.CANNOT_USE_ITEMS_SKILLS_WITH_FORMALWEAR));
  197. return;
  198. }
  199.  
  200. SystemMessage sm = null;
  201.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement