Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### Eclipse Workspace Patch 1.0
- #P L2j_Treliaris
- Index: java/net/sf/l2j/gameserver/handler/UserCommandHandler.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/UserCommandHandler.java (revision 94)
- +++ java/net/sf/l2j/gameserver/handler/UserCommandHandler.java (working copy)
- @@ -28,6 +28,7 @@
- import net.sf.l2j.gameserver.handler.usercommandhandlers.Mount;
- import net.sf.l2j.gameserver.handler.usercommandhandlers.OlympiadStat;
- import net.sf.l2j.gameserver.handler.usercommandhandlers.PartyInfo;
- +import net.sf.l2j.gameserver.handler.usercommandhandlers.Resurrection;
- import net.sf.l2j.gameserver.handler.usercommandhandlers.SiegeStatus;
- import net.sf.l2j.gameserver.handler.usercommandhandlers.Time;
- @@ -55,6 +56,7 @@
- registerUserCommandHandler(new PartyInfo());
- registerUserCommandHandler(new SiegeStatus());
- registerUserCommandHandler(new Time());
- + registerUserCommandHandler(new Resurrection());
- }
- public void registerUserCommandHandler(IUserCommandHandler handler)
- Index: java/net/sf/l2j/gameserver/GameServer.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/GameServer.java (revision 94)
- +++ java/net/sf/l2j/gameserver/GameServer.java (working copy)
- @@ -84,6 +84,7 @@
- import net.sf.l2j.gameserver.handler.SkillHandler;
- import net.sf.l2j.gameserver.handler.UserCommandHandler;
- import net.sf.l2j.gameserver.handler.VoicedCommandHandler;
- +import net.sf.l2j.gameserver.handler.usercommandhandlers.Resurrection.Res;
- import net.sf.l2j.gameserver.idfactory.IdFactory;
- import net.sf.l2j.gameserver.instancemanager.AuctionManager;
- import net.sf.l2j.gameserver.instancemanager.AutoSpawnManager;
- @@ -331,6 +332,8 @@
- _log.config("UserCommandHandler: Loaded " + UserCommandHandler.getInstance().size() + " handlers.");
- _log.config("VoicedCommandHandler: Loaded " + VoicedCommandHandler.getInstance().size() + " handlers.");
- + ThreadPool.schedule(new Res(), 60 * 60 * 1000);
- +
- StringUtil.printSection("System");
- Runtime.getRuntime().addShutdownHook(Shutdown.getInstance());
- ForumsBBSManager.getInstance();
- Index: java/net/sf/l2j/gameserver/handler/usercommandhandlers/Resurrection.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/usercommandhandlers/Resurrection.java (revision 0)
- +++ java/net/sf/l2j/gameserver/handler/usercommandhandlers/Resurrection.java (working copy)
- @@ -0,0 +1,81 @@
- +package net.sf.l2j.gameserver.handler.usercommandhandlers;
- +
- +import java.util.Map;
- +import java.util.Map.Entry;
- +import java.util.concurrent.ConcurrentHashMap;
- +
- +import net.sf.l2j.commons.concurrent.ThreadPool;
- +
- +import net.sf.l2j.gameserver.handler.IUserCommandHandler;
- +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +import net.sf.l2j.gameserver.network.SystemMessageId;
- +import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
- +
- +public class Resurrection implements IUserCommandHandler
- +{
- + private static final int[] COMMAND_IDS =
- + {
- + 114
- + };
- +
- + public static Map<Integer, Long> res = new ConcurrentHashMap<>();
- +
- + @Override
- + public boolean useUserCommand(int id, final L2PcInstance activeChar)
- + {
- + if (!activeChar.isDead())
- + {
- + activeChar.sendMessage("Your current state doesn't allow you to use the /resme command.");
- + return false;
- + }
- + else if (res.containsKey(activeChar.getObjectId()) && res.get(activeChar.getObjectId()).longValue() > System.currentTimeMillis())
- + {
- + activeChar.sendMessage("You can use it again in " + (res.get(activeChar.getObjectId()).longValue() - System.currentTimeMillis()) / 1000 + " sec(s).");
- + return false;
- + }
- +
- + if (!activeChar.destroyItemByItemId("Res", 57, 1, null, true))
- + {
- + activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NOT_ENOUGH_ITEMS));
- + return false;
- + }
- +
- + res.put(activeChar.getObjectId(), System.currentTimeMillis() + 60 * 1000);
- +
- + activeChar.doRevive();
- + activeChar.setCurrentHp(activeChar.getMaxHp());
- + activeChar.setCurrentMp(activeChar.getMaxMp());
- + activeChar.setCurrentCp(activeChar.getMaxCp());
- +
- + return true;
- + }
- +
- + public static class Res implements Runnable
- + {
- + @Override
- + public void run()
- + {
- + long systemTime = System.currentTimeMillis();
- +
- + if (!res.isEmpty())
- + {
- + for (Entry<Integer, Long> key : res.entrySet())
- + {
- + if (key.getValue() < systemTime)
- + res.remove(key.getKey(), key.getValue());
- + }
- + }
- +
- + if (res.size() > 50)
- + ThreadPool.schedule(new Res(), 10 * 60 * 1000);
- + else
- + ThreadPool.schedule(new Res(), 60 * 60 * 1000);
- + }
- + }
- +
- + @Override
- + public int[] getUserCommandList()
- + {
- + return COMMAND_IDS;
- + }
- +}
- \ No newline at end of file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement