Guest User

resme

a guest
Jun 30th, 2016
559
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.17 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/taskmanager/Res.java
  24. ===================================================================
  25. --- java/net/sf/l2j/gameserver/taskmanager/Res.java (revision 0)
  26. +++ java/net/sf/l2j/gameserver/taskmanager/Res.java (working copy)
  27. @@ -0,0 +1,22 @@
  28. +package net.sf.l2j.gameserver.taskmanager;
  29. +
  30. +import java.util.Map.Entry;
  31. +
  32. +import net.sf.l2j.gameserver.handler.usercommandhandlers.Resurrection;
  33. +
  34. +public class Res extends Resurrection implements Runnable
  35. +{
  36. + @Override
  37. + public void run()
  38. + {
  39. + long systemTime = System.currentTimeMillis();
  40. +
  41. + for (Entry<Integer, Long> key : _res.entrySet())
  42. + {
  43. + if (key.getValue() < systemTime)
  44. + _res.remove(key.getKey(), key.getValue());
  45. + }
  46. +
  47. + _check = true;
  48. + }
  49. +}
  50. \ No newline at end of file
  51. Index: java/net/sf/l2j/gameserver/handler/usercommandhandlers/Resurrection.java
  52. ===================================================================
  53. --- java/net/sf/l2j/gameserver/handler/usercommandhandlers/Resurrection.java (revision 0)
  54. +++ java/net/sf/l2j/gameserver/handler/usercommandhandlers/Resurrection.java (working copy)
  55. @@ -0,0 +1,65 @@
  56. +package net.sf.l2j.gameserver.handler.usercommandhandlers;
  57. +
  58. +import java.util.Map;
  59. +import java.util.concurrent.ConcurrentHashMap;
  60. +
  61. +import net.sf.l2j.commons.concurrent.ThreadPool;
  62. +
  63. +import net.sf.l2j.gameserver.handler.IUserCommandHandler;
  64. +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  65. +import net.sf.l2j.gameserver.network.SystemMessageId;
  66. +import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
  67. +import net.sf.l2j.gameserver.taskmanager.Res;
  68. +
  69. +public class Resurrection implements IUserCommandHandler
  70. +{
  71. + private static final int[] COMMAND_IDS =
  72. + {
  73. + 114
  74. + };
  75. +
  76. + public Map<Integer, Long> _res = new ConcurrentHashMap<>();
  77. + public boolean _check = true;
  78. +
  79. + @Override
  80. + public boolean useUserCommand(int id, final L2PcInstance activeChar)
  81. + {
  82. + if (!activeChar.isDead())
  83. + {
  84. + activeChar.sendMessage("Your current state doesn't allow you to use the /resme command.");
  85. + }
  86. + else if (_res.get(activeChar.getObjectId()) != null && _res.get(activeChar.getObjectId()).longValue() > System.currentTimeMillis())
  87. + {
  88. + activeChar.sendMessage("You can use it again in " + (_res.get(activeChar.getObjectId()).longValue() - System.currentTimeMillis()) / 1000 + " sec(s).");
  89. + }
  90. + else if (!activeChar.destroyItemByItemId("Res", 57, 1, null, true))
  91. + {
  92. + activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NOT_ENOUGH_ITEMS));
  93. + }
  94. + else
  95. + {
  96. + _res.put(activeChar.getObjectId(), System.currentTimeMillis() + 60 * 1000);
  97. +
  98. + activeChar.doRevive();
  99. + activeChar.setCurrentHp(activeChar.getMaxHp());
  100. + activeChar.setCurrentMp(activeChar.getMaxMp());
  101. + activeChar.setCurrentCp(activeChar.getMaxCp());
  102. +
  103. + if (_res.size() > 50 && _check)
  104. + {
  105. + _check = false;
  106. + ThreadPool.schedule(new Res(), 10 * 60 * 1000);
  107. + }
  108. +
  109. + return true;
  110. + }
  111. +
  112. + return false;
  113. + }
  114. +
  115. + @Override
  116. + public int[] getUserCommandList()
  117. + {
  118. + return COMMAND_IDS;
  119. + }
  120. +}
  121. \ No newline at end of file
Advertisement
Add Comment
Please, Sign In to add comment