Advertisement
Sarada-L2

Offline Item Click Acis 372

Aug 26th, 2021
531
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.05 KB | None | 0 0
  1. diff --git a/config/CustomMods/OfflineShop.ini b/config/CustomMods/OfflineShop.ini
  2. index 4fd055a..1d329a1 100644
  3. --- a/config/CustomMods/OfflineShop.ini
  4. +++ b/config/CustomMods/OfflineShop.ini
  5. @@ -33,4 +33,7 @@
  6. OfflineDisconnectFinished = True
  7.  
  8. #Offline Effect Sleep
  9. OfflineSetSleepEffect = True
  10.  
  11. +#Coloque o Id do item abaixo, ele podera se usado sem restrição em privatestore.
  12. +UseItemId = 6392
  13. \ No newline at end of file
  14. diff --git a/java/net/sf/l2j/Config.java b/java/net/sf/l2j/Config.java
  15. index 8c4cc43..91fc0f1 100644
  16. --- a/java/net/sf/l2j/Config.java
  17. +++ b/java/net/sf/l2j/Config.java
  18. @@ -471,6 +471,7 @@
  19. public static int OFFLINE_MAX_DAYS;
  20. public static boolean OFFLINE_DISCONNECT_FINISHED;
  21. public static boolean OFFLINE_SET_SLEEP;
  22. + public static int ITEM_PERMITIDO_PARA_USAR_NA_LOJA_ID;
  23.  
  24. /** Brazil Settings */
  25. public static boolean ENABLE_ALTERNATIVE_SKILL_DURATION;
  26. @@ -1253,6 +1254,7 @@
  27. RESTORE_OFFLINERS = offlineshop.getProperty("RestoreOffliners", false);
  28. OFFLINE_MAX_DAYS = offlineshop.getProperty("OfflineMaxDays", 10);
  29. OFFLINE_DISCONNECT_FINISHED = offlineshop.getProperty("OfflineDisconnectFinished", true);
  30. + ITEM_PERMITIDO_PARA_USAR_NA_LOJA_ID = offlineshop.getProperty("UseItemId", 10);
  31.  
  32. }
  33. /**
  34. diff --git a/java/net/sf/l2j/gameserver/handler/ItemHandler.java b/java/net/sf/l2j/gameserver/handler/ItemHandler.java
  35. index 7add89f..07bb3f7 100644
  36. --- a/java/net/sf/l2j/gameserver/handler/ItemHandler.java
  37. +++ b/java/net/sf/l2j/gameserver/handler/ItemHandler.java
  38. @@ -17,6 +17,7 @@
  39. import net.sf.l2j.gameserver.handler.itemhandlers.Keys;
  40. import net.sf.l2j.gameserver.handler.itemhandlers.Maps;
  41. import net.sf.l2j.gameserver.handler.itemhandlers.MercTicket;
  42. +import net.sf.l2j.gameserver.handler.itemhandlers.OfflineClick;
  43. import net.sf.l2j.gameserver.handler.itemhandlers.PaganKeys;
  44. import net.sf.l2j.gameserver.handler.itemhandlers.PetFood;
  45. import net.sf.l2j.gameserver.handler.itemhandlers.Recipes;
  46. @@ -42,6 +43,7 @@
  47.  
  48. protected ItemHandler()
  49. {
  50. + registerItemHandler(new OfflineClick());
  51. registerItemHandler(new BeastSoulShot());
  52. registerItemHandler(new BeastSpice());
  53. registerItemHandler(new BeastSpiritShot());
  54. diff --git a/java/net/sf/l2j/gameserver/handler/itemhandlers/OfflineClick.java b/java/net/sf/l2j/gameserver/handler/itemhandlers/OfflineClick.java
  55. new file mode 100644
  56. index 0000000..baa34ea
  57. --- /dev/null
  58. +++ b/java/net/sf/l2j/gameserver/handler/itemhandlers/OfflineClick.java
  59. @@ -0,0 +1,114 @@
  60. +package net.sf.l2j.gameserver.handler.itemhandlers;
  61. +
  62. +import net.sf.l2j.commons.concurrent.ThreadPool;
  63. +
  64. +import net.sf.l2j.gameserver.handler.IItemHandler;
  65. +import net.sf.l2j.gameserver.model.actor.Playable;
  66. +import net.sf.l2j.gameserver.model.actor.instance.Player;
  67. +import net.sf.l2j.gameserver.model.item.instance.ItemInstance;
  68. +import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
  69. +import net.sf.l2j.gameserver.network.serverpackets.ExShowScreenMessage;
  70. +
  71. +/**
  72. + * @author Sarada
  73. + *
  74. + */
  75. +public class OfflineClick implements IItemHandler
  76. +{
  77. +
  78. + @Override
  79. + public void useItem(Playable playable, ItemInstance item, boolean forceUse)
  80. + {
  81. + if (!(playable instanceof Player))
  82. + return;
  83. +
  84. + final Player activeChar = (Player) playable;
  85. + if ((!activeChar.isInStoreMode() && (!activeChar.isCrafting())) || !activeChar.isSitting())
  86. + {
  87. + activeChar.sendMessage("You are not running a private store or private work shop.");
  88. + activeChar.sendPacket(ActionFailed.STATIC_PACKET);
  89. + return;
  90. + }
  91. + if (activeChar.isInCombat() && !activeChar.isGM())
  92. + {
  93. + activeChar.sendMessage("You cannot Logout while is in Combat mode.");
  94. + activeChar.sendPacket(ActionFailed.STATIC_PACKET);
  95. + return;
  96. + }
  97. + if (activeChar.isFestivalParticipant())
  98. + {
  99. + activeChar.sendMessage("You can't use this item while participating in the Festival!");
  100. + return;
  101. + }
  102. + if (activeChar.isInOlympiadMode())
  103. + {
  104. + activeChar.sendMessage("You can't teleport while you are in olympiad");
  105. + return;
  106. + }
  107. + if (activeChar.isInObserverMode())
  108. + {
  109. + activeChar.sendMessage("You can't teleport while you are in observer mode");
  110. + return;
  111. + }
  112. + activeChar.destroyItem("Consume", item.getObjectId(), 1, null, false);
  113. + this.initCountdown(activeChar, 5);
  114. + ThreadPool.schedule(new Runnable() {
  115. + @Override
  116. + public void run() {
  117. + activeChar.logout();
  118. + }
  119. + }, 5000L);
  120. + }
  121. +
  122. + class Countdown implements Runnable
  123. + {
  124. + private final Player _player;
  125. + private int _time;
  126. +
  127. + public Countdown(final Player player, final int time) {
  128. + this._time = time;
  129. + this._player = player;
  130. + }
  131. +
  132. + /* (non-Javadoc)
  133. + * @see java.lang.Runnable#run()
  134. + */
  135. + @Override
  136. + public void run() {
  137. + if (this._player.isOnline()) {
  138. + switch (this._time) {
  139. + case 5: {
  140. + this._player.sendPacket(new ExShowScreenMessage(this._time + " second(s) to discoonect in!", 950));
  141. + break;
  142. + }
  143. + case 4: {
  144. + this._player.sendPacket(new ExShowScreenMessage(this._time + " second(s) to discoonect in!", 950));
  145. + break;
  146. + }
  147. + case 3: {
  148. + this._player.sendPacket(new ExShowScreenMessage(this._time + " second(s) to discoonect in!", 950));
  149. + break;
  150. + }
  151. + case 2: {
  152. + this._player.sendPacket(new ExShowScreenMessage(this._time + " second(s) to discoonect in!", 950));
  153. + break;
  154. + }
  155. + case 1: {
  156. + this._player.sendPacket(new ExShowScreenMessage(this._time + " second(s) to discoonect in!", 950));
  157. + break;
  158. + }
  159. + }
  160. + if (this._time > 1) {
  161. + ThreadPool.schedule(new Countdown(this._player, this._time - 1), 1000L);
  162. + }
  163. + }
  164. + }
  165. +
  166. +
  167. + }
  168. + public void initCountdown(final Player activeChar, final int duration) {
  169. + if (activeChar != null && activeChar.isOnline()) {
  170. + ThreadPool.schedule(new Countdown(activeChar, duration), 0L);
  171. + }
  172. + }
  173. +}
  174. \ No newline at end of file
  175. diff --git a/java/net/sf/l2j/gameserver/network/clientpackets/UseItem.java b/java/net/sf/l2j/gameserver/network/clientpackets/UseItem.java
  176. index 9faf624..5c482ad 100644
  177. --- a/java/net/sf/l2j/gameserver/network/clientpackets/UseItem.java
  178. +++ b/java/net/sf/l2j/gameserver/network/clientpackets/UseItem.java
  179. @@ -41,11 +41,6 @@
  180. final Player activeChar = getClient().getActiveChar();
  181. if (activeChar == null)
  182. return;
  183. - if (activeChar.isInStoreMode())
  184. - {
  185. - activeChar.sendPacket(SystemMessageId.ITEMS_UNAVAILABLE_FOR_STORE_MANUFACTURE);
  186. - return;
  187. - }
  188. if (activeChar.getActiveTradeList() != null)
  189. {
  190. activeChar.sendPacket(SystemMessageId.CANNOT_PICKUP_OR_USE_ITEM_WHILE_TRADING);
  191. @@ -55,7 +50,11 @@
  192. final ItemInstance item = activeChar.getInventory().getItemByObjectId(_objectId);
  193. if (item == null)
  194. return;
  195. -
  196. + if (activeChar.isInStoreMode() && !(item.getItemId() == Config.ITEM_PERMITIDO_PARA_USAR_NA_LOJA_ID))
  197. + {
  198. + activeChar.sendPacket(SystemMessageId.ITEMS_UNAVAILABLE_FOR_STORE_MANUFACTURE);
  199. + return;
  200. + }
  201. if (item.getItem().getType2() == Item.TYPE2_QUEST)
  202. {
  203. activeChar.sendPacket(SystemMessageId.CANNOT_USE_QUEST_ITEMS);
  204.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement