Advertisement
Sarada-L2

Auto GB MegaPack

Mar 3rd, 2023
1,137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.02 KB | None | 0 0
  1. ### Eclipse Workspace Patch 1.0
  2. #P Source Mega 11.12.2022
  3. diff --git java/com/l2jmega/gameserver/handler/voicedcommandhandlers/VoicedMenu.java
  4. index 7e28c4e..b931271 100644
  5. --- java/com/l2jmega/gameserver/handler/voicedcommandhandlers/VoicedMenu.java
  6. +++ java/com/l2jmega/gameserver/handler/voicedcommandhandlers/VoicedMenu.java
  7. @@ -13,65 +13,68 @@
  8. import com.l2jmega.gameserver.MissionReset;
  9. import com.l2jmega.gameserver.NewZoneVote;
  10. import com.l2jmega.gameserver.PartyFarmEvent;
  11. import com.l2jmega.gameserver.Restart;
  12. import com.l2jmega.gameserver.data.SkillTable;
  13. import com.l2jmega.gameserver.data.xml.DressMeData;
  14. import com.l2jmega.gameserver.handler.IVoicedCommandHandler;
  15. import com.l2jmega.gameserver.model.DressMe;
  16. import com.l2jmega.gameserver.model.actor.instance.Player;
  17. import com.l2jmega.gameserver.model.olympiad.Olympiad;
  18. import com.l2jmega.gameserver.model.zone.ZoneId;
  19. import com.l2jmega.gameserver.network.serverpackets.NpcHtmlMessage;
  20. import com.l2jmega.gameserver.network.serverpackets.OpenUrl;
  21.  
  22. import java.sql.Date;
  23. import java.text.SimpleDateFormat;
  24. import java.util.StringTokenizer;
  25.  
  26. import com.l2jmega.commons.concurrent.ThreadPool;
  27.  
  28. +import net.sf.l2j.gameserver.taskmanager.AutoGoldBar;
  29.  
  30. public class VoicedMenu implements IVoicedCommandHandler
  31. {
  32.  
  33. private static final String[] VOICED_COMMANDS =
  34. {
  35. "menu",
  36. "MENU",
  37. "partyon",
  38. "tradeon",
  39. "buffon",
  40. "messageon",
  41. "partyoff",
  42. "tradeoff",
  43. "buffoff",
  44. "messageoff",
  45. "setPartyRefuse",
  46. "setTradeRefuse",
  47. "setMessageRefuse",
  48. "setBuffProtection",
  49. "optimizeFPS",
  50. "info",
  51. "event",
  52. "bp_changedressmestatus",
  53. "mission",
  54. "info_url",
  55. + "setAutoGb",
  56. "skins",
  57. "trySkin",
  58. "hair",
  59. "pin",
  60. "bp_changedressmestatus",
  61. "disable_Helm",
  62. "disable_skin"
  63.  
  64.  
  65. };
  66.  
  67. @Override
  68. public boolean useVoicedCommand(String command, Player activeChar, String target)
  69. {
  70.  
  71. if (command.equals("menu") || command.equals("MENU"))
  72. showMenuHtml(activeChar);
  73. else if (command.equals("partyon"))
  74. {
  75. if (activeChar.isPartyInvProt())
  76. @@ -236,40 +239,54 @@
  77. }
  78. else if (command.equals("mission"))
  79. {
  80. showMissionHtml(activeChar);
  81. }
  82. else if (command.startsWith("info_url")) {
  83. activeChar.sendPacket(new OpenUrl("" + Config.INFO_URL + ""));
  84. }
  85. else if (command.startsWith("hair")) {
  86.  
  87. if(activeChar.getDress() == null){
  88. activeChar.sendMessage("You are not wearing a skin.");
  89. return false;
  90. }
  91.  
  92. if (activeChar.getDress() != null){
  93. activeChar.getDress().setHairId(0);
  94. activeChar.broadcastUserInfo();
  95. }
  96. }
  97. + else if (command.equalsIgnoreCase("setAutoGb"))
  98. + {
  99. + if (activeChar.isAutoGb())
  100. + {
  101. + activeChar.setAutoGb(false);
  102. + AutoGoldBar.getInstance().remove(activeChar);
  103. + }
  104. + else
  105. + {
  106. + activeChar.setAutoGb(true);
  107. + AutoGoldBar.getInstance().add(activeChar);
  108. + }
  109. + VoicedMenu.showMenuHtml(activeChar);
  110. + }
  111. else if (command.startsWith("trySkin"))
  112. if(activeChar.isVip()){
  113.  
  114. StringTokenizer st = new StringTokenizer(command);
  115. st.nextToken();
  116. int skinId = Integer.parseInt(st.nextToken());
  117.  
  118. final DressMe dress = DressMeData.getInstance().getItemId(skinId);
  119.  
  120. if (dress != null) {
  121. activeChar.setDress(dress);
  122. DressMeData.getInstance().reloadPL();
  123. activeChar.broadcastUserInfo();
  124. }
  125. else {
  126. activeChar.sendMessage("Invalid skin.");
  127. return false;
  128. }
  129. }
  130. else{
  131. @@ -301,40 +318,41 @@
  132. else {
  133. activeChar.sendMessage("Invalid skin.");
  134. return false;
  135. }
  136. }
  137. return true;
  138. }
  139.  
  140. static SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
  141.  
  142. static void showMenuHtml(Player activeChar)
  143. {
  144.  
  145. NpcHtmlMessage html = new NpcHtmlMessage(0);
  146. html.setFile("data/html/mods/menu/Menu.htm");
  147. html.replace("%dat%", (new SimpleDateFormat("dd/MM/yyyy")).format(new Date(System.currentTimeMillis())) );
  148. html.replace("%time%", (new SimpleDateFormat("HH:mm:ss")).format(new Date(System.currentTimeMillis())) );
  149. html.replace("%partyRefusal%", activeChar.isPartyInvProt() ? "checked" : "unable");
  150. html.replace("%tradeRefusal%", activeChar.getTradeRefusal() ? "checked" : "unable");
  151. html.replace("%messageRefusal%", activeChar.getMessageRefusal() ? "checked" : "unable");
  152. + html.replace("%setAutoGb%", activeChar.isAutoGb() ? "checked" : "unable");
  153. html.replace("%dressme%", activeChar.isDressMeEnabled() ? "ON" : "OFF");
  154. html.replace("%buff%", activeChar.isBuffProtected() ? "checked" : "unable");
  155. html.replace("%optimize%", activeChar.isOptimizeFPS() ? "checked" : "unable");
  156. html.replace("%name%", activeChar.getName());
  157.  
  158. if(Config.PVP_EVENT_ENABLED){
  159. if(PvPEvent.getInstance().isActive())
  160. html.replace("%pvp%", "In Progress");
  161. else
  162. html.replace("%pvp%", PvPEventNext.getInstance().getNextTime().toString() );
  163. }
  164. if(Config.TVT_EVENT_ENABLED){
  165. if(TvT.is_inProgress())
  166. html.replace("%tvt%", "In Progress");
  167. else
  168. html.replace("%tvt%", TvTEventManager.getInstance().getNextTime().toString() );
  169. }
  170. if(Config.CTF_EVENT_ENABLED){
  171. if(CTF.is_inProgress())
  172. html.replace("%ctf%", "In Progress");
  173. diff --git java/com/l2jmega/gameserver/model/actor/instance/Player.java
  174. index 584b1b2..05af79d 100644
  175. --- java/com/l2jmega/gameserver/model/actor/instance/Player.java
  176. +++ java/com/l2jmega/gameserver/model/actor/instance/Player.java
  177. @@ -14464,21 +14464,32 @@
  178. private boolean _dressedHelm;
  179. public boolean isDressMeHelmEnabled() {
  180. return _dressedHelm;
  181. }
  182.  
  183. public void setDressMeHelmEnabled(boolean val) {
  184. _dressedHelm = val;
  185. }
  186.  
  187. private DressMe _dressMe;
  188.  
  189. public DressMe getDress()
  190. {
  191. return _dressMe;
  192. }
  193.  
  194. public void setDress(DressMe val)
  195. {
  196. _dressMe = val;
  197. }
  198. + private boolean _gbforadena = false;
  199. + public boolean isAutoGb()
  200. + {
  201. + return _gbforadena;
  202. + }
  203. + public void setAutoGb(boolean gbforadena)
  204. + {
  205. + _gbforadena = gbforadena;
  206. + }
  207. }
  208. \ No newline at end of file
  209. diff --git java/net/sf/l2j/gameserver/taskmanager/AutoGoldBar.java
  210. new file mode 100644
  211. index 0000000..3d5b86b
  212. --- /dev/null
  213. +++ java/net/sf/l2j/gameserver/taskmanager/AutoGoldBar.java
  214. @@ -0,0 +1,62 @@
  215. +package net.sf.l2j.gameserver.taskmanager;
  216. +
  217. +import com.l2jmega.Config;
  218. +import com.l2jmega.gameserver.model.actor.Creature;
  219. +import com.l2jmega.gameserver.model.actor.instance.Player;
  220. +import com.l2jmega.gameserver.network.serverpackets.ItemList;
  221. +
  222. +import java.util.Map;
  223. +import java.util.concurrent.ConcurrentHashMap;
  224. +
  225. +import com.l2jmega.commons.concurrent.ThreadPool;
  226. +
  227. +public class AutoGoldBar implements Runnable
  228. +{
  229. + @Override
  230. + public final void run()
  231. + {
  232. + if (_players.isEmpty())
  233. + return;
  234. +
  235. + for (Map.Entry<Player, Long> entry : _players.entrySet())
  236. + {
  237. + final Player player = entry.getKey();
  238. +
  239. + if (player.getInventory().getInventoryItemCount(57, 0) >= Config.BANKING_SYSTEM_ADENA)
  240. + {
  241. + player.getInventory().reduceAdena("Goldbar", Config.BANKING_SYSTEM_ADENA, player, null);
  242. + player.getInventory().addItem("Goldbar", Config.BANKING_SYSTEM_GOLDBAR_ID, Config.BANKING_SYSTEM_GOLDBARS, player, null);
  243. + player.getInventory().updateDatabase();
  244. + player.sendPacket(new ItemList(player, false));
  245. + }
  246. + }
  247. + }
  248. +
  249. + private final Map<Player, Long> _players = new ConcurrentHashMap<>();
  250. +
  251. + protected AutoGoldBar()
  252. + {
  253. + // Run task each 10 second.
  254. + ThreadPool.scheduleAtFixedRate(this, 1000, 1000);
  255. + }
  256. +
  257. + public final void add(Player player)
  258. + {
  259. + _players.put(player, System.currentTimeMillis());
  260. + }
  261. +
  262. + public final void remove(Creature player)
  263. + {
  264. + _players.remove(player);
  265. + }
  266. +
  267. + public static final AutoGoldBar getInstance()
  268. + {
  269. + return SingletonHolder._instance;
  270. + }
  271. +
  272. + private static class SingletonHolder
  273. + {
  274. + protected static final AutoGoldBar _instance = new AutoGoldBar();
  275. + }
  276. +}
  277. \ No newline at end of file
  278.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement