Advertisement
Guest User

resme

a guest
Jun 29th, 2016
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.83 KB | None | 0 0
  1. ### Eclipse Workspace Patch 1.0
  2. #P L2j_Treliaris
  3. Index: java/net/sf/l2j/gameserver/handler/UserCommandHandler.java
  4. ===================================================================
  5. --- java/net/sf/l2j/gameserver/handler/UserCommandHandler.java (revision 94)
  6. +++ java/net/sf/l2j/gameserver/handler/UserCommandHandler.java (working copy)
  7. @@ -28,6 +28,7 @@
  8. import net.sf.l2j.gameserver.handler.usercommandhandlers.Mount;
  9. import net.sf.l2j.gameserver.handler.usercommandhandlers.OlympiadStat;
  10. import net.sf.l2j.gameserver.handler.usercommandhandlers.PartyInfo;
  11. +import net.sf.l2j.gameserver.handler.usercommandhandlers.Resurrection;
  12. import net.sf.l2j.gameserver.handler.usercommandhandlers.SiegeStatus;
  13. import net.sf.l2j.gameserver.handler.usercommandhandlers.Time;
  14.  
  15. @@ -55,6 +56,7 @@
  16. registerUserCommandHandler(new PartyInfo());
  17. registerUserCommandHandler(new SiegeStatus());
  18. registerUserCommandHandler(new Time());
  19. + registerUserCommandHandler(new Resurrection());
  20. }
  21.  
  22. public void registerUserCommandHandler(IUserCommandHandler handler)
  23. Index: java/net/sf/l2j/gameserver/GameServer.java
  24. ===================================================================
  25. --- java/net/sf/l2j/gameserver/GameServer.java (revision 94)
  26. +++ java/net/sf/l2j/gameserver/GameServer.java (working copy)
  27. @@ -84,6 +84,7 @@
  28. import net.sf.l2j.gameserver.handler.SkillHandler;
  29. import net.sf.l2j.gameserver.handler.UserCommandHandler;
  30. import net.sf.l2j.gameserver.handler.VoicedCommandHandler;
  31. +import net.sf.l2j.gameserver.handler.usercommandhandlers.Resurrection.Res;
  32. import net.sf.l2j.gameserver.idfactory.IdFactory;
  33. import net.sf.l2j.gameserver.instancemanager.AuctionManager;
  34. import net.sf.l2j.gameserver.instancemanager.AutoSpawnManager;
  35. @@ -331,6 +332,8 @@
  36. _log.config("UserCommandHandler: Loaded " + UserCommandHandler.getInstance().size() + " handlers.");
  37. _log.config("VoicedCommandHandler: Loaded " + VoicedCommandHandler.getInstance().size() + " handlers.");
  38.  
  39. + ThreadPool.schedule(new Res(), 60 * 60 * 1000);
  40. +
  41. StringUtil.printSection("System");
  42. Runtime.getRuntime().addShutdownHook(Shutdown.getInstance());
  43. ForumsBBSManager.getInstance();
  44. Index: java/net/sf/l2j/gameserver/handler/usercommandhandlers/Resurrection.java
  45. ===================================================================
  46. --- java/net/sf/l2j/gameserver/handler/usercommandhandlers/Resurrection.java (revision 0)
  47. +++ java/net/sf/l2j/gameserver/handler/usercommandhandlers/Resurrection.java (working copy)
  48. @@ -0,0 +1,81 @@
  49. +package net.sf.l2j.gameserver.handler.usercommandhandlers;
  50. +
  51. +import java.util.Map;
  52. +import java.util.Map.Entry;
  53. +import java.util.concurrent.ConcurrentHashMap;
  54. +
  55. +import net.sf.l2j.commons.concurrent.ThreadPool;
  56. +
  57. +import net.sf.l2j.gameserver.handler.IUserCommandHandler;
  58. +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  59. +import net.sf.l2j.gameserver.network.SystemMessageId;
  60. +import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
  61. +
  62. +public class Resurrection implements IUserCommandHandler
  63. +{
  64. + private static final int[] COMMAND_IDS =
  65. + {
  66. + 114
  67. + };
  68. +
  69. + public static Map<Integer, Long> res = new ConcurrentHashMap<>();
  70. +
  71. + @Override
  72. + public boolean useUserCommand(int id, final L2PcInstance activeChar)
  73. + {
  74. + if (!activeChar.isDead())
  75. + {
  76. + activeChar.sendMessage("Your current state doesn't allow you to use the /resme command.");
  77. + return false;
  78. + }
  79. + else if (res.containsKey(activeChar.getObjectId()) && res.get(activeChar.getObjectId()).longValue() > System.currentTimeMillis())
  80. + {
  81. + activeChar.sendMessage("You can use it again in " + (res.get(activeChar.getObjectId()).longValue() - System.currentTimeMillis()) / 1000 + " sec(s).");
  82. + return false;
  83. + }
  84. +
  85. + if (!activeChar.destroyItemByItemId("Res", 57, 1, null, true))
  86. + {
  87. + activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NOT_ENOUGH_ITEMS));
  88. + return false;
  89. + }
  90. +
  91. + res.put(activeChar.getObjectId(), System.currentTimeMillis() + 60 * 1000);
  92. +
  93. + activeChar.doRevive();
  94. + activeChar.setCurrentHp(activeChar.getMaxHp());
  95. + activeChar.setCurrentMp(activeChar.getMaxMp());
  96. + activeChar.setCurrentCp(activeChar.getMaxCp());
  97. +
  98. + return true;
  99. + }
  100. +
  101. + public static class Res implements Runnable
  102. + {
  103. + @Override
  104. + public void run()
  105. + {
  106. + long systemTime = System.currentTimeMillis();
  107. +
  108. + if (!res.isEmpty())
  109. + {
  110. + for (Entry<Integer, Long> key : res.entrySet())
  111. + {
  112. + if (key.getValue() < systemTime)
  113. + res.remove(key.getKey(), key.getValue());
  114. + }
  115. + }
  116. +
  117. + if (res.size() > 50)
  118. + ThreadPool.schedule(new Res(), 10 * 60 * 1000);
  119. + else
  120. + ThreadPool.schedule(new Res(), 60 * 60 * 1000);
  121. + }
  122. + }
  123. +
  124. + @Override
  125. + public int[] getUserCommandList()
  126. + {
  127. + return COMMAND_IDS;
  128. + }
  129. +}
  130. \ No newline at end of file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement