Advertisement
VANPER

L2jBan Evento Ramdom 1x1

Jul 5th, 2019
760
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 14.06 KB | None | 0 0
  1. ### Eclipse Workspace Patch 1.0
  2. #P aCis_gameserver
  3. Index: java/net/sf/l2j/gameserver/network/clientpackets/Logout.java
  4. ===================================================================
  5. --- java/net/sf/l2j/gameserver/network/clientpackets/Logout.java    (revision 1)
  6. +++ java/net/sf/l2j/gameserver/network/clientpackets/Logout.java    (working copy)
  7. @@ -17,6 +17,7 @@
  8. import net.sf.l2j.gameserver.model.zone.ZoneId;
  9. +import net.sf.l2j.gameserver.model.RandomFight;
  10.  
  11.             return;
  12.         }
  13.  
  14. +              if(RandomFight.players.contains(player))
  15. +                  {
  16. +                      player.sendMessage("Proibido sair do Jogo.");
  17. +                      player.sendPacket(ActionFailed.STATIC_PACKET);
  18. +                      return;
  19. +                  }
  20. Index: config/players.properties
  21. ===================================================================
  22. --- config/players.properties   (revision 1)
  23. +++ config/players.properties   (working copy)
  24.  
  25. +#Random Fight Event
  26. +AllowRandomFight = True
  27. +#Random Fight every how many minutes
  28. +EveryMinutes = 3
  29. +#ID of the reward Item , default:LIFE STONES
  30. +RewardId=8762
  31. +#COUNT of the reward item : default : 5
  32. +RewardCount = 5
  33. Index: java/net/sf/l2j/gameserver/GameServer.java
  34. ===================================================================
  35. --- java/net/sf/l2j/gameserver/GameServer.java  (revision 1)
  36. +++ java/net/sf/l2j/gameserver/GameServer.java  (working copy)
  37. @@ -90,6 +90,7 @@
  38. import net.sf.l2j.Config;
  39. +import net.sf.l2j.gameserver.model.RandomFight;
  40.  
  41. Hero.getInstance();
  42.  
  43. +       StringUtil.printSection("Evento Ramdom 1 vs 1");
  44. +       LOGGER.info("Evento Primiado ao ganhador");
  45. +       if(Config.ALLOW_RANDOM_FIGHT)
  46. +        RandomFight.getInstance();
  47.  
  48. Index: java/net/sf/l2j/gameserver/network/clientpackets/Say2.java
  49. ===================================================================
  50. --- java/net/sf/l2j/gameserver/network/clientpackets/Say2.java  (revision 1)
  51. +++ java/net/sf/l2j/gameserver/network/clientpackets/Say2.java  (working copy)
  52. @@ -21,6 +21,7 @@
  53.  import net.sf.l2j.gameserver.handler.IChatHandler;
  54. +import net.sf.l2j.gameserver.model.RandomFight;
  55.  
  56.             return;
  57.         }
  58.  
  59. +       checkRandomFight(_text,player);
  60. +        if(_text.equalsIgnoreCase("registro") || _text.equalsIgnoreCase("remover"))
  61. +       return;
  62.  
  63.         return false;
  64.     }
  65.  
  66. +     static void checkRandomFight(String text,Player player)
  67. +      {
  68. +          if(text.equalsIgnoreCase("registro"))
  69. +          {
  70. +              if(RandomFight.players.contains(player))
  71. +              {
  72. +                  player.sendMessage("Registro Efetuado.");
  73. +                  return;
  74. +              }
  75. +              if(RandomFight.state == RandomFight.State.INACTIVE)
  76. +                  return;
  77. +              if(RandomFight.state != RandomFight.State.REGISTER)
  78. +              {
  79. +                  player.sendMessage("Evento Quase Iniciando.");
  80. +                  return;
  81. +              }
  82. +              RandomFight.players.add(player);
  83. +              player.sendMessage("Registro Efetuado!!");
  84. +              return;
  85. +          }
  86. +          if(text.equalsIgnoreCase("remover"))
  87. +          {
  88. +              if(!RandomFight.players.contains(player))
  89. +              {
  90. +                  player.sendMessage("Registro Casado.");
  91. +                  return;
  92. +              }
  93. +              if(RandomFight.state == RandomFight.State.INACTIVE)
  94. +              return;
  95. +              if(RandomFight.state != RandomFight.State.REGISTER)
  96. +              {
  97. +                  player.sendMessage("Evento Quase Iniciando.");
  98. +                  return;
  99. +              }
  100. +              RandomFight.players.remove(player);
  101. +              player.sendMessage("Seu Registro foi Removido.");
  102. +          }
  103. +      }
  104.      
  105.    
  106.     @Override
  107.     protected boolean triggersOnActionRequest()
  108.     {
  109.         return false;
  110.     }
  111.  
  112. Index: java/net/sf/l2j/gameserver/model/actor/instance/Player.java
  113. ===================================================================
  114. --- java/net/sf/l2j/gameserver/model/actor/instance/Player.java   (revision 1)
  115. +++ java/net/sf/l2j/gameserver/model/actor/instance/Player.java   (working copy)
  116. @@ -37,6 +37,7 @@
  117.  
  118. +import net.sf.l2j.gameserver.model.RandomFight;
  119.  import net.sf.l2j.gameserver.model.ShotType;
  120.  
  121.         if (killer != null)
  122.         {
  123.             Player pk = killer.getActingPlayer();
  124.  
  125.  
  126. +   if(RandomFight.state == RandomFight.State.FIGHT)
  127. +        {
  128. +       if(RandomFight.players.contains(this) && RandomFight.players.contains(pk))
  129. +               {
  130. +               pk.sendMessage("Voce Ganhou!");
  131. +               Broadcast.announceToOnlinePlayers("[Random Fight Results] " + pk.getName()+" e o Ganhador", true);
  132. +               Broadcast.announceToOnlinePlayers("Event Random Fight Finalizado", true);
  133. +               pk.addItem("",Config.RANDOM_FIGHT_REWARD_ID, Config.RANDOM_FIGHT_REWARD_COUNT, null, true);
  134. +               RandomFight.revert();
  135. +               RandomFight.clean();
  136. +               }
  137. +               }
  138.             // Clear resurrect xp calculation
  139.             setExpBeforeDeath(0);
  140.  
  141. Index: java/net/sf/l2j/Config.java
  142. ===================================================================
  143. --- java/net/sf/l2j/Config.java (revision 1)
  144. +++ java/net/sf/l2j/Config.java (working copy)
  145. @@ -383,6 +383,11 @@
  146.  
  147. + /** Evento 1x1 Juvenil Walker*/
  148. +   public static boolean ALLOW_RANDOM_FIGHT;
  149. +   public static int EVERY_MINUTES;
  150. +   public static int RANDOM_FIGHT_REWARD_ID;
  151. +   public static int RANDOM_FIGHT_REWARD_COUNT;
  152.  
  153.  
  154. DEATH_PENALTY_CHANCE = players.getProperty("DeathPenaltyChance", 20);
  155.  
  156. +           ALLOW_RANDOM_FIGHT = players.getProperty("AllowRandomFight",true);
  157. +           EVERY_MINUTES = players.getProperty("EveryMinutes",3);
  158. +           RANDOM_FIGHT_REWARD_ID = players.getProperty("RewardId" , 8762);
  159. +           RANDOM_FIGHT_REWARD_COUNT = players.getProperty("RewardCount" , 5)
  160. Index: java/net/sf/l2j/gameserver/model/RandomFight.java
  161. ===================================================================
  162. --- java/net/sf/l2j/gameserver/model/RandomFight.java   (revision 0)
  163. +++ java/net/sf/l2j/gameserver/model/RandomFight.java   (revision 0) NAO EXISTE TEM QUE CRIAR A CLASS
  164. @@ -0,0 +1,273 @@
  165. package net.sf.l2j.gameserver.model;
  166.  
  167. import java.util.Iterator;
  168. import java.util.Vector;
  169.  
  170. import net.sf.l2j.Config;
  171. import net.sf.l2j.gameserver.ThreadPoolManager;
  172. import net.sf.l2j.gameserver.model.actor.instance.Player;
  173. import net.sf.l2j.gameserver.model.olympiad.OlympiadManager;
  174. import net.sf.l2j.gameserver.network.serverpackets.ExShowScreenMessage;
  175. import net.sf.l2j.gameserver.util.Broadcast;
  176. import net.sf.l2j.commons.random.Rnd;
  177.  
  178. /**
  179.  * @author lioy
  180.  *
  181.  */
  182. public class RandomFight
  183. {
  184.     public static enum State{INACTIVE,REGISTER,LOADING,FIGHT}
  185.     public static State state = State.INACTIVE;
  186.  
  187.    public static Vector<Player> players = new Vector<>();
  188.  
  189.    protected void openRegistrations()
  190.    {
  191.        state = State.REGISTER;
  192.        Broadcast.announceToOnlinePlayers("Cadastre-se no Evento.");
  193.        Broadcast.announceToOnlinePlayers("1 vs 1 Arena.");
  194.        Broadcast.announceToOnlinePlayers("Digite: registro");
  195.        Broadcast.announceToOnlinePlayers("Digite: remover");
  196.        ThreadPoolManager.getInstance().scheduleGeneral(new checkRegist(), 60000 );
  197.    }
  198.  
  199.    protected void checkRegistrations()
  200.     {
  201.        state=State.LOADING;
  202.      
  203.        if(players.isEmpty() || players.size() < 2)
  204.        {
  205.            clean();
  206.            return;
  207.        }
  208.        Broadcast.announceToOnlinePlayers("Quantidades de Jogadores Registrado: " +players.size());
  209.        Broadcast.announceToOnlinePlayers("2 Jogadores sera Escolhido em 10 segundos!");
  210.        ThreadPoolManager.getInstance().scheduleGeneral(new pickPlayers(), 10000 );
  211.     }
  212.  
  213.  
  214.    protected void pickPlayers()
  215.     {
  216.        if(players.isEmpty() || players.size() < 2)
  217.         {
  218.            clean();
  219.            return;
  220.        }
  221.      
  222.        for(Player p : players)
  223.            if(p.isInOlympiadMode() || OlympiadManager.getInstance().isRegistered(p))
  224.            {
  225.                players.remove(p);
  226.                p.sendMessage("Proibido Registrar em 2 Eventos.");
  227.            }
  228.  
  229.      
  230.        int rnd1=Rnd.get(players.size());
  231.        int rnd2=Rnd.get(players.size());
  232.      
  233.        while(rnd2==rnd1)
  234.            rnd2=Rnd.get(players.size());
  235.      
  236.        for (Iterator<Player> i = players.iterator(); i.hasNext();)
  237.        {
  238.              Player player = i.next();
  239.                  
  240.                if (player != players.get(rnd1) && player != players.get(rnd2))
  241.                    i.remove();
  242.         }
  243.      
  244.        Broadcast.announceToOnlinePlayers("Jogadores: "+players.firstElement().getName()+" || "+players.lastElement().getName());
  245.        Broadcast.announceToOnlinePlayers("Jogadores sera Teleportado em 10 seconds");
  246.        ThreadPoolManager.getInstance().scheduleGeneral(new teleportPlayers(), 10000);
  247.     }
  248.  
  249.  
  250.    public void teleport()
  251.     {
  252.        if(players.isEmpty() || players.size() < 2)
  253.         {
  254.            clean();
  255.            return;
  256.            
  257.        }
  258.        
  259.        Broadcast.announceToOnlinePlayers("Jogadores Teleportados!");
  260.        players.firstElement().teleToLocation(-114498,-249819,-2988,0);
  261.        players.lastElement().teleToLocation(-114500,-248890,-2990,0);
  262.        players.firstElement().setTeam(1);
  263.        players.lastElement().setTeam(2);
  264.        
  265.        players.firstElement().sendPacket(new ExShowScreenMessage("Lute em 30 seconds!", 5000, 2, true));
  266.        players.lastElement().sendPacket(new ExShowScreenMessage("Lute em 30 seconds!", 5000, 2, true));
  267.        players.firstElement().setIsParalyzed(true);
  268.        players.lastElement().setIsParalyzed(true);
  269.        ThreadPoolManager.getInstance().scheduleGeneral(new fight(), 30000);
  270.     }
  271.  
  272.    
  273.    public void startFight()
  274.     {
  275.        if(players.isEmpty() || players.size() < 2)
  276.         {
  277.            Broadcast.announceToOnlinePlayers("Outro Jogadores esta Ausente.");
  278.            clean();
  279.            return;
  280.        }
  281.        state = State.FIGHT;
  282.        Broadcast.announceToOnlinePlayers("LUTA INICIADA!");
  283.        players.firstElement().sendPacket(new ExShowScreenMessage("Mate o Inimigo!", 1000, 2, true));
  284.        players.lastElement().sendPacket(new ExShowScreenMessage("Mate o Inimigo!", 1000, 2, true));
  285.        players.firstElement().setIsParalyzed(false);
  286.        players.lastElement().setIsParalyzed(false);
  287.        ThreadPoolManager.getInstance().scheduleGeneral(new checkLast(), 120000 );
  288.     }
  289.  
  290.     protected void lastCheck()
  291.     {
  292.        if(state == State.FIGHT)
  293.        {
  294.            if(players.isEmpty() || players.size() < 2)
  295.            {
  296.                revert();
  297.                clean();
  298.                return;
  299.            }
  300.          
  301.            int alive=0;
  302.            for(Player player : players)
  303.            {
  304.                if(!player.isDead())
  305.                    alive++;
  306.            }
  307.          
  308.            if(alive==2)
  309.                for(Player p : players)
  310.                {
  311.                    if(p == null)
  312.                        continue;
  313.                    p.setCurrentHp(p.getMaxHp());
  314.                    p.setCurrentCp(p.getMaxCp());
  315.                    p.setCurrentMp(p.getMaxMp());
  316.                    p.broadcastUserInfo();
  317.                    p.teleToLocation(87358,-141982,-1341,10);
  318.                }
  319.            {
  320.                Broadcast.announceToOnlinePlayers("Tivemos Empate!");
  321.                clean();
  322.                revert();
  323.  
  324.            }
  325.        }
  326.     }
  327.  
  328.    public static void revert()
  329.    {
  330.        if(!players.isEmpty())
  331.        for(Player p : players)
  332.        {
  333.            if(p == null)
  334.                continue;
  335.          
  336.            if(p.isDead())
  337.                p.doRevive();
  338.          
  339.            p.setCurrentHp(p.getMaxHp());
  340.            p.setCurrentCp(p.getMaxCp());
  341.            p.setCurrentMp(p.getMaxMp());
  342.            p.broadcastUserInfo();
  343.            p.teleToLocation(87358,-141982,-1341,10);
  344.        }
  345.    }
  346.  
  347.    public static void clean()
  348.    {
  349.      
  350.        if(state == State.FIGHT)
  351.            for(Player p : players)
  352.                p.setTeam(0);
  353.  
  354.      
  355.        players.clear();
  356.        state = State.INACTIVE;
  357.      
  358.    }
  359.  
  360.    protected RandomFight()
  361.    {
  362.        ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new Event(), 60000 * Config.EVERY_MINUTES , 60000 * Config.EVERY_MINUTES);
  363.    }
  364.  
  365.    public static RandomFight getInstance()
  366.    {
  367.        return SingletonHolder._instance;
  368.    }
  369.  
  370.    private static class SingletonHolder
  371.    {
  372.        protected static final RandomFight _instance = new RandomFight();
  373.    }
  374.  
  375.    protected class Event implements Runnable
  376.    {
  377.        @Override
  378.        public void run()
  379.        {
  380.            if(state == State.INACTIVE)
  381.                openRegistrations();
  382.        }
  383.      
  384.    }
  385.  
  386.    protected class checkRegist implements Runnable
  387.    {
  388.  
  389.        @Override
  390.        public void run()
  391.        {
  392.                checkRegistrations();
  393.        }
  394.      
  395.    }
  396.  
  397.    protected class pickPlayers implements Runnable
  398.    {
  399.        @Override
  400.        public void run()
  401.        {
  402.            pickPlayers();
  403.        }
  404.      
  405.    }
  406.  
  407.    protected class teleportPlayers implements Runnable
  408.    {
  409.        @Override
  410.        public void run()
  411.        {
  412.            teleport();
  413.        }
  414.      
  415.    }
  416.  
  417.    protected class fight implements Runnable
  418.    {
  419.  
  420.        @Override
  421.        public void run()
  422.        {
  423.            startFight();
  424.        }
  425.      
  426.    }
  427.  
  428.    protected class checkLast implements Runnable
  429.    {
  430.        @Override
  431.        public void run()
  432.        {
  433.            lastCheck();
  434.        }
  435.      
  436.    }
  437. }
  438. Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestRestart.java
  439. ===================================================================
  440. --- java/net/sf/l2j/gameserver/network/clientpackets/RequestRestart.java    (revision 1)
  441. +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestRestart.java    (working copy)
  442. @@ -17,11 +17,13 @@
  443.  import net.sf.l2j.gameserver.model.L2Party;
  444. +import net.sf.l2j.gameserver.model.RandomFight;
  445.  
  446.  
  447.         if (player.isInsideZone(ZoneId.NO_RESTART))
  448.         {
  449.             player.sendPacket(SystemMessageId.NO_RESTART_HERE);
  450.             sendPacket(RestartResponse.valueOf(false));
  451.             return;
  452.         }
  453.  
  454. +       if(RandomFight.players.contains(player))
  455. +           {
  456. +           player.sendMessage("Restart Bloqueado.");
  457. +           player.sendPacket(ActionFailed.STATIC_PACKET);
  458. +           return;
  459. +           }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement