Advertisement
Sarada-L2

Vip Coin pra Acis

Jan 29th, 2021
524
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.28 KB | None | 0 0
  1. +package net.sf.l2j.gameserver.handler.itemhandlers;
  2. +
  3. +import java.util.Calendar;
  4. +
  5. +import net.sf.l2j.Config;
  6. +import net.sf.l2j.gameserver.handler.IItemHandler;
  7. +import net.sf.l2j.gameserver.model.actor.Playable;
  8. +import net.sf.l2j.gameserver.model.actor.instance.Player;
  9. +import net.sf.l2j.gameserver.model.item.instance.ItemInstance;
  10. +import net.sf.l2j.gameserver.network.serverpackets.EtcStatusUpdate;
  11. +
  12. +public class VipCoin implements IItemHandler
  13. +{
  14. + //Hero Coin Level - 1
  15. + private final int VIP_ID1 = Config.VIP_COIN_ID1;
  16. + private final int VIP_DAYS1 = Config.VIP_DAYS_ID1;
  17. +
  18. + //Hero Coin Level - 2
  19. + private final int VIP_ID2 = Config.VIP_COIN_ID2;
  20. + private final int VIP_DAYS2 = Config.VIP_DAYS_ID2;
  21. +
  22. + //Hero Coin Level - 3
  23. + private final int VIP_ID3 = Config.VIP_COIN_ID3;
  24. + private final int VIP_DAYS3 = Config.VIP_DAYS_ID3;
  25. +
  26. + @Override
  27. + public void useItem(Playable playable, ItemInstance item, boolean forceUse)
  28. + {
  29. + if (!(playable instanceof Player))
  30. + return;
  31. +
  32. + Player activeChar = (Player)playable;
  33. +
  34. + int itemId = item.getItemId();
  35. +
  36. + if (itemId == VIP_ID1)
  37. + {
  38. + if (activeChar.isInOlympiadMode())
  39. + {
  40. + activeChar.sendMessage("This item cannot be used on Olympiad Games.");
  41. + return;
  42. + }
  43. + if (activeChar.destroyItem("Consume", item.getObjectId(), 1, null, false))
  44. + {
  45. + if (activeChar.isVip())
  46. + {
  47. + long daysleft = (activeChar.getVipEndTime() - Calendar.getInstance().getTimeInMillis()) / 86400000L;
  48. + activeChar.setEndTime("vip", (int)(daysleft + VIP_DAYS1));
  49. + activeChar.sendMessage("Congratulations, You just received another " + VIP_DAYS1 + " day of VIP.");
  50. + }
  51. + else
  52. + {
  53. + activeChar.setVip(true);
  54. + activeChar.setEndTime("vip", VIP_DAYS1);
  55. + activeChar.sendMessage("Congrats, you just became VIP per " + VIP_DAYS1 + " day.");
  56. + }
  57. +
  58. + if (Config.ALLOW_VIP_NCOLOR && activeChar.isVip())
  59. + activeChar.getAppearance().setNameColor(Config.VIP_NCOLOR);
  60. +
  61. + if (Config.ALLOW_VIP_TCOLOR && activeChar.isVip())
  62. + activeChar.getAppearance().setTitleColor(Config.VIP_TCOLOR);
  63. +
  64. + activeChar.broadcastUserInfo();
  65. + activeChar.sendPacket(new EtcStatusUpdate(activeChar));
  66. + }
  67. + }
  68. +
  69. + if (itemId == VIP_ID2)
  70. + {
  71. + if (activeChar.isInOlympiadMode())
  72. + {
  73. + activeChar.sendMessage("This item cannot be used on Olympiad Games.");
  74. + return;
  75. + }
  76. + if (activeChar.destroyItem("Consume", item.getObjectId(), 1, null, false))
  77. + {
  78. + if (activeChar.isVip())
  79. + {
  80. + long daysleft = (activeChar.getVipEndTime() - Calendar.getInstance().getTimeInMillis()) / 86400000L;
  81. + activeChar.setEndTime("vip", (int)(daysleft + VIP_DAYS2));
  82. + activeChar.sendMessage("Congratulations, You just received another " + VIP_DAYS2 + " day of VIP.");
  83. + }
  84. + else
  85. + {
  86. + activeChar.setVip(true);
  87. + activeChar.setEndTime("vip", VIP_DAYS2);
  88. + activeChar.sendMessage("Congrats, you just became VIP per " + VIP_DAYS2 + " day.");
  89. + }
  90. +
  91. + if (Config.ALLOW_VIP_NCOLOR && activeChar.isVip())
  92. + activeChar.getAppearance().setNameColor(Config.VIP_NCOLOR);
  93. +
  94. + if (Config.ALLOW_VIP_TCOLOR && activeChar.isVip())
  95. + activeChar.getAppearance().setTitleColor(Config.VIP_TCOLOR);
  96. +
  97. + activeChar.broadcastUserInfo();
  98. + activeChar.sendPacket(new EtcStatusUpdate(activeChar));
  99. + }
  100. + }
  101. +
  102. + if (itemId == VIP_ID3)
  103. + {
  104. + if (activeChar.isInOlympiadMode())
  105. + {
  106. + activeChar.sendMessage("This item cannot be used on Olympiad Games.");
  107. + return;
  108. + }
  109. + if (activeChar.destroyItem("Consume", item.getObjectId(), 1, null, false))
  110. + {
  111. + if (activeChar.isVip())
  112. + {
  113. + long daysleft = (activeChar.getVipEndTime() - Calendar.getInstance().getTimeInMillis()) / 86400000L;
  114. + activeChar.setEndTime("vip", (int)(daysleft + VIP_DAYS3));
  115. + activeChar.sendMessage("Congratulations, You just received another " + VIP_DAYS3 + " day of VIP.");
  116. + }
  117. + else
  118. + {
  119. + activeChar.setVip(true);
  120. + activeChar.setEndTime("vip", VIP_DAYS3);
  121. + activeChar.sendMessage("Congrats, you just became VIP per " + VIP_DAYS3 + " day.");
  122. + }
  123. +
  124. + if (Config.ALLOW_VIP_NCOLOR && activeChar.isVip())
  125. + activeChar.getAppearance().setNameColor(Config.VIP_NCOLOR);
  126. +
  127. + if (Config.ALLOW_VIP_TCOLOR && activeChar.isVip())
  128. + activeChar.getAppearance().setTitleColor(Config.VIP_TCOLOR);
  129. +
  130. + activeChar.broadcastUserInfo();
  131. + activeChar.sendPacket(new EtcStatusUpdate(activeChar));
  132. + }
  133. + }
  134. + }
  135. +}
  136.  
  137.  
  138.  
  139.  
  140. ItemHandler.java
  141.  
  142. import net.sf.l2j.gameserver.handler.itemhandlers.BeastSoulShot;
  143. +import net.sf.l2j.gameserver.handler.itemhandlers.VipCoin;
  144.  
  145. registerItemHandler(new BeastSoulShot());
  146. + registerItemHandler(new VipCoin());
  147.  
  148.  
  149.  
  150.  
  151.  
  152. Config.java
  153.  
  154. + public static int VIP_COIN_ID1;
  155. + public static int VIP_DAYS_ID1;
  156. + public static int VIP_COIN_ID2;
  157. + public static int VIP_DAYS_ID2;
  158. + public static int VIP_COIN_ID3;
  159. + public static int VIP_DAYS_ID3;
  160. +
  161. + VIP_COIN_ID1 = Integer.parseInt(vip.getProperty("VipCoin", "6392"));
  162. + VIP_DAYS_ID1 = Integer.parseInt(vip.getProperty("VipCoinDays", "1"));
  163. + VIP_COIN_ID2 = Integer.parseInt(vip.getProperty("VipCoin2", "6393"));
  164. + VIP_DAYS_ID2 = Integer.parseInt(vip.getProperty("VipCoinDays2", "2"));
  165. + VIP_COIN_ID3 = Integer.parseInt(vip.getProperty("VipCoin3", "5557"));
  166. + VIP_DAYS_ID3 = Integer.parseInt(vip.getProperty("VipCoinDays3", "3"));
  167.  
  168.  
  169.  
  170. datapack
  171.  
  172. +#=============================================================
  173. +# VIP Item 1
  174. +#=============================================================
  175. +#registrar esse nome no item no xml abaixo
  176. +#<set name="handler" val="VipCoin" />
  177. +VipCoin = 6392
  178. +VipCoinDays = 1
  179. +
  180. +#=============================================================
  181. +# VIP Item 2
  182. +#=============================================================
  183. +#registrar esse nome no item no xml abaixo
  184. +#<set name="handler" val="VipCoin" />
  185. +VipCoin2 = 6393
  186. +VipCoinDays2 = 2
  187. +
  188. +#=============================================================
  189. +# VIP Item 3
  190. +#=============================================================
  191. +#registrar esse nome no item no xml abaixo
  192. +#<set name="handler" val="VipCoin" />
  193. +VipCoin3 = 5557
  194. +VipCoinDays3 = 3
  195.  
  196.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement