Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### Eclipse Workspace Patch 1.0
- #P aCis_gameserver
- Index: java/net/sf/l2j/gameserver/network/clientpackets/Logout.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/network/clientpackets/Logout.java (revision 1)
- +++ java/net/sf/l2j/gameserver/network/clientpackets/Logout.java (working copy)
- @@ -17,6 +17,7 @@
- import net.sf.l2j.gameserver.model.zone.ZoneId;
- +import net.sf.l2j.gameserver.model.RandomFight;
- return;
- }
- + if(RandomFight.players.contains(player))
- + {
- + player.sendMessage("Proibido sair do Jogo.");
- + player.sendPacket(ActionFailed.STATIC_PACKET);
- + return;
- + }
- Index: config/players.properties
- ===================================================================
- --- config/players.properties (revision 1)
- +++ config/players.properties (working copy)
- +#Random Fight Event
- +AllowRandomFight = True
- +#Random Fight every how many minutes
- +EveryMinutes = 3
- +#ID of the reward Item , default:LIFE STONES
- +RewardId=8762
- +#COUNT of the reward item : default : 5
- +RewardCount = 5
- Index: java/net/sf/l2j/gameserver/GameServer.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/GameServer.java (revision 1)
- +++ java/net/sf/l2j/gameserver/GameServer.java (working copy)
- @@ -90,6 +90,7 @@
- import net.sf.l2j.Config;
- +import net.sf.l2j.gameserver.model.RandomFight;
- Hero.getInstance();
- + StringUtil.printSection("Evento Ramdom 1 vs 1");
- + LOGGER.info("Evento Primiado ao ganhador");
- + if(Config.ALLOW_RANDOM_FIGHT)
- + RandomFight.getInstance();
- Index: java/net/sf/l2j/gameserver/network/clientpackets/Say2.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/network/clientpackets/Say2.java (revision 1)
- +++ java/net/sf/l2j/gameserver/network/clientpackets/Say2.java (working copy)
- @@ -21,6 +21,7 @@
- import net.sf.l2j.gameserver.handler.IChatHandler;
- +import net.sf.l2j.gameserver.model.RandomFight;
- return;
- }
- + checkRandomFight(_text,player);
- + if(_text.equalsIgnoreCase("registro") || _text.equalsIgnoreCase("remover"))
- + return;
- return false;
- }
- + static void checkRandomFight(String text,Player player)
- + {
- + if(text.equalsIgnoreCase("registro"))
- + {
- + if(RandomFight.players.contains(player))
- + {
- + player.sendMessage("Registro Efetuado.");
- + return;
- + }
- + if(RandomFight.state == RandomFight.State.INACTIVE)
- + return;
- + if(RandomFight.state != RandomFight.State.REGISTER)
- + {
- + player.sendMessage("Evento Quase Iniciando.");
- + return;
- + }
- + RandomFight.players.add(player);
- + player.sendMessage("Registro Efetuado!!");
- + return;
- + }
- + if(text.equalsIgnoreCase("remover"))
- + {
- + if(!RandomFight.players.contains(player))
- + {
- + player.sendMessage("Registro Casado.");
- + return;
- + }
- + if(RandomFight.state == RandomFight.State.INACTIVE)
- + return;
- + if(RandomFight.state != RandomFight.State.REGISTER)
- + {
- + player.sendMessage("Evento Quase Iniciando.");
- + return;
- + }
- + RandomFight.players.remove(player);
- + player.sendMessage("Seu Registro foi Removido.");
- + }
- + }
- @Override
- protected boolean triggersOnActionRequest()
- {
- return false;
- }
- Index: java/net/sf/l2j/gameserver/model/actor/instance/Player.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/actor/instance/Player.java (revision 1)
- +++ java/net/sf/l2j/gameserver/model/actor/instance/Player.java (working copy)
- @@ -37,6 +37,7 @@
- +import net.sf.l2j.gameserver.model.RandomFight;
- import net.sf.l2j.gameserver.model.ShotType;
- if (killer != null)
- {
- Player pk = killer.getActingPlayer();
- + if(RandomFight.state == RandomFight.State.FIGHT)
- + {
- + if(RandomFight.players.contains(this) && RandomFight.players.contains(pk))
- + {
- + pk.sendMessage("Voce Ganhou!");
- + Broadcast.announceToOnlinePlayers("[Random Fight Results] " + pk.getName()+" e o Ganhador", true);
- + Broadcast.announceToOnlinePlayers("Event Random Fight Finalizado", true);
- + pk.addItem("",Config.RANDOM_FIGHT_REWARD_ID, Config.RANDOM_FIGHT_REWARD_COUNT, null, true);
- + RandomFight.revert();
- + RandomFight.clean();
- + }
- + }
- // Clear resurrect xp calculation
- setExpBeforeDeath(0);
- Index: java/net/sf/l2j/Config.java
- ===================================================================
- --- java/net/sf/l2j/Config.java (revision 1)
- +++ java/net/sf/l2j/Config.java (working copy)
- @@ -383,6 +383,11 @@
- + /** Evento 1x1 Juvenil Walker*/
- + public static boolean ALLOW_RANDOM_FIGHT;
- + public static int EVERY_MINUTES;
- + public static int RANDOM_FIGHT_REWARD_ID;
- + public static int RANDOM_FIGHT_REWARD_COUNT;
- DEATH_PENALTY_CHANCE = players.getProperty("DeathPenaltyChance", 20);
- + ALLOW_RANDOM_FIGHT = players.getProperty("AllowRandomFight",true);
- + EVERY_MINUTES = players.getProperty("EveryMinutes",3);
- + RANDOM_FIGHT_REWARD_ID = players.getProperty("RewardId" , 8762);
- + RANDOM_FIGHT_REWARD_COUNT = players.getProperty("RewardCount" , 5)
- Index: java/net/sf/l2j/gameserver/model/RandomFight.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/RandomFight.java (revision 0)
- +++ java/net/sf/l2j/gameserver/model/RandomFight.java (revision 0) NAO EXISTE TEM QUE CRIAR A CLASS
- @@ -0,0 +1,273 @@
- package net.sf.l2j.gameserver.model;
- import java.util.Iterator;
- import java.util.Vector;
- import net.sf.l2j.Config;
- import net.sf.l2j.gameserver.ThreadPoolManager;
- import net.sf.l2j.gameserver.model.actor.instance.Player;
- import net.sf.l2j.gameserver.model.olympiad.OlympiadManager;
- import net.sf.l2j.gameserver.network.serverpackets.ExShowScreenMessage;
- import net.sf.l2j.gameserver.util.Broadcast;
- import net.sf.l2j.commons.random.Rnd;
- /**
- * @author lioy
- *
- */
- public class RandomFight
- {
- public static enum State{INACTIVE,REGISTER,LOADING,FIGHT}
- public static State state = State.INACTIVE;
- public static Vector<Player> players = new Vector<>();
- protected void openRegistrations()
- {
- state = State.REGISTER;
- Broadcast.announceToOnlinePlayers("Cadastre-se no Evento.");
- Broadcast.announceToOnlinePlayers("1 vs 1 Arena.");
- Broadcast.announceToOnlinePlayers("Digite: registro");
- Broadcast.announceToOnlinePlayers("Digite: remover");
- ThreadPoolManager.getInstance().scheduleGeneral(new checkRegist(), 60000 );
- }
- protected void checkRegistrations()
- {
- state=State.LOADING;
- if(players.isEmpty() || players.size() < 2)
- {
- clean();
- return;
- }
- Broadcast.announceToOnlinePlayers("Quantidades de Jogadores Registrado: " +players.size());
- Broadcast.announceToOnlinePlayers("2 Jogadores sera Escolhido em 10 segundos!");
- ThreadPoolManager.getInstance().scheduleGeneral(new pickPlayers(), 10000 );
- }
- protected void pickPlayers()
- {
- if(players.isEmpty() || players.size() < 2)
- {
- clean();
- return;
- }
- for(Player p : players)
- if(p.isInOlympiadMode() || OlympiadManager.getInstance().isRegistered(p))
- {
- players.remove(p);
- p.sendMessage("Proibido Registrar em 2 Eventos.");
- }
- int rnd1=Rnd.get(players.size());
- int rnd2=Rnd.get(players.size());
- while(rnd2==rnd1)
- rnd2=Rnd.get(players.size());
- for (Iterator<Player> i = players.iterator(); i.hasNext();)
- {
- Player player = i.next();
- if (player != players.get(rnd1) && player != players.get(rnd2))
- i.remove();
- }
- Broadcast.announceToOnlinePlayers("Jogadores: "+players.firstElement().getName()+" || "+players.lastElement().getName());
- Broadcast.announceToOnlinePlayers("Jogadores sera Teleportado em 10 seconds");
- ThreadPoolManager.getInstance().scheduleGeneral(new teleportPlayers(), 10000);
- }
- public void teleport()
- {
- if(players.isEmpty() || players.size() < 2)
- {
- clean();
- return;
- }
- Broadcast.announceToOnlinePlayers("Jogadores Teleportados!");
- players.firstElement().teleToLocation(-114498,-249819,-2988,0);
- players.lastElement().teleToLocation(-114500,-248890,-2990,0);
- players.firstElement().setTeam(1);
- players.lastElement().setTeam(2);
- players.firstElement().sendPacket(new ExShowScreenMessage("Lute em 30 seconds!", 5000, 2, true));
- players.lastElement().sendPacket(new ExShowScreenMessage("Lute em 30 seconds!", 5000, 2, true));
- players.firstElement().setIsParalyzed(true);
- players.lastElement().setIsParalyzed(true);
- ThreadPoolManager.getInstance().scheduleGeneral(new fight(), 30000);
- }
- public void startFight()
- {
- if(players.isEmpty() || players.size() < 2)
- {
- Broadcast.announceToOnlinePlayers("Outro Jogadores esta Ausente.");
- clean();
- return;
- }
- state = State.FIGHT;
- Broadcast.announceToOnlinePlayers("LUTA INICIADA!");
- players.firstElement().sendPacket(new ExShowScreenMessage("Mate o Inimigo!", 1000, 2, true));
- players.lastElement().sendPacket(new ExShowScreenMessage("Mate o Inimigo!", 1000, 2, true));
- players.firstElement().setIsParalyzed(false);
- players.lastElement().setIsParalyzed(false);
- ThreadPoolManager.getInstance().scheduleGeneral(new checkLast(), 120000 );
- }
- protected void lastCheck()
- {
- if(state == State.FIGHT)
- {
- if(players.isEmpty() || players.size() < 2)
- {
- revert();
- clean();
- return;
- }
- int alive=0;
- for(Player player : players)
- {
- if(!player.isDead())
- alive++;
- }
- if(alive==2)
- for(Player p : players)
- {
- if(p == null)
- continue;
- p.setCurrentHp(p.getMaxHp());
- p.setCurrentCp(p.getMaxCp());
- p.setCurrentMp(p.getMaxMp());
- p.broadcastUserInfo();
- p.teleToLocation(87358,-141982,-1341,10);
- }
- {
- Broadcast.announceToOnlinePlayers("Tivemos Empate!");
- clean();
- revert();
- }
- }
- }
- public static void revert()
- {
- if(!players.isEmpty())
- for(Player p : players)
- {
- if(p == null)
- continue;
- if(p.isDead())
- p.doRevive();
- p.setCurrentHp(p.getMaxHp());
- p.setCurrentCp(p.getMaxCp());
- p.setCurrentMp(p.getMaxMp());
- p.broadcastUserInfo();
- p.teleToLocation(87358,-141982,-1341,10);
- }
- }
- public static void clean()
- {
- if(state == State.FIGHT)
- for(Player p : players)
- p.setTeam(0);
- players.clear();
- state = State.INACTIVE;
- }
- protected RandomFight()
- {
- ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new Event(), 60000 * Config.EVERY_MINUTES , 60000 * Config.EVERY_MINUTES);
- }
- public static RandomFight getInstance()
- {
- return SingletonHolder._instance;
- }
- private static class SingletonHolder
- {
- protected static final RandomFight _instance = new RandomFight();
- }
- protected class Event implements Runnable
- {
- @Override
- public void run()
- {
- if(state == State.INACTIVE)
- openRegistrations();
- }
- }
- protected class checkRegist implements Runnable
- {
- @Override
- public void run()
- {
- checkRegistrations();
- }
- }
- protected class pickPlayers implements Runnable
- {
- @Override
- public void run()
- {
- pickPlayers();
- }
- }
- protected class teleportPlayers implements Runnable
- {
- @Override
- public void run()
- {
- teleport();
- }
- }
- protected class fight implements Runnable
- {
- @Override
- public void run()
- {
- startFight();
- }
- }
- protected class checkLast implements Runnable
- {
- @Override
- public void run()
- {
- lastCheck();
- }
- }
- }
- Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestRestart.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/network/clientpackets/RequestRestart.java (revision 1)
- +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestRestart.java (working copy)
- @@ -17,11 +17,13 @@
- import net.sf.l2j.gameserver.model.L2Party;
- +import net.sf.l2j.gameserver.model.RandomFight;
- if (player.isInsideZone(ZoneId.NO_RESTART))
- {
- player.sendPacket(SystemMessageId.NO_RESTART_HERE);
- sendPacket(RestartResponse.valueOf(false));
- return;
- }
- + if(RandomFight.players.contains(player))
- + {
- + player.sendMessage("Restart Bloqueado.");
- + player.sendPacket(ActionFailed.STATIC_PACKET);
- + return;
- + }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement