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/model/actor/appearance/PcAppearance.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/actor/appearance/PcAppearance.java (revision 4)
- +++ java/net/sf/l2j/gameserver/model/actor/appearance/PcAppearance.java (working copy)
- @@ -1,9 +1,11 @@
- package net.sf.l2j.gameserver.model.actor.appearance;
- +import net.sf.l2j.gameserver.model.actor.instance.Player;
- import net.sf.l2j.gameserver.model.base.Sex;
- public final class PcAppearance
- {
- + private Player _owner;
- private byte _face;
- private byte _hairColor;
- private byte _hairStyle;
- @@ -11,6 +13,7 @@
- private boolean _invisible = false;
- private int _nameColor = 0xFFFFFF;
- private int _titleColor = 0xFFFF77;
- + private String _visibleTitle;
- public PcAppearance(byte face, byte hColor, byte hStyle, Sex sex)
- {
- @@ -104,4 +107,27 @@
- {
- _titleColor = (red & 0xFF) + ((green & 0xFF) << 8) + ((blue & 0xFF) << 16);
- }
- +
- + public final void setVisibleTitle(String visibleTitle)
- + {
- + _visibleTitle = visibleTitle;
- + }
- +
- + public final String getVisibleTitle()
- + {
- + if (_visibleTitle == null)
- + _visibleTitle = getOwner().getTitle();
- +
- + return _visibleTitle;
- + }
- +
- + public void setOwner(Player owner)
- + {
- + _owner = owner;
- + }
- +
- + public Player getOwner()
- + {
- + return _owner;
- + }
- }
- \ No newline at end of file
- Index: java/net/sf/l2j/gameserver/network/serverpackets/Die.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/network/serverpackets/Die.java (revision 4)
- +++ java/net/sf/l2j/gameserver/network/serverpackets/Die.java (working copy)
- @@ -1,6 +1,7 @@
- package net.sf.l2j.gameserver.network.serverpackets;
- import net.sf.l2j.gameserver.data.manager.CastleManager;
- +import net.sf.l2j.gameserver.engine.impl.EventCommons;
- import net.sf.l2j.gameserver.model.actor.Attackable;
- import net.sf.l2j.gameserver.model.actor.Creature;
- import net.sf.l2j.gameserver.model.actor.instance.Player;
- @@ -43,7 +44,10 @@
- writeC(0x06);
- writeD(_charObjId);
- - writeD(0x01); // to nearest village
- + if (_activeChar instanceof Player && EventCommons.getInstance().showDiePacket((Player)_activeChar))
- + writeD(0x01); // to nearest village
- + else
- + writeD(0x00);
- if (_clan != null)
- {
- Index: java/net/sf/l2j/gameserver/model/olympiad/OlympiadManager.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/olympiad/OlympiadManager.java (revision 4)
- +++ java/net/sf/l2j/gameserver/model/olympiad/OlympiadManager.java (working copy)
- @@ -242,7 +242,13 @@
- player.sendPacket(SystemMessageId.ONLY_NOBLESS_CAN_PARTICIPATE_IN_THE_OLYMPIAD);
- return false;
- }
- -
- +
- + if (player.isInFunEvent())
- + {
- + player.sendMessage("You cannot register in olympiad while registered at TvT.");
- + return false;
- + }
- +
- if (player.isSubClassActive())
- {
- player.sendPacket(SystemMessageId.YOU_CANT_JOIN_THE_OLYMPIAD_WITH_A_SUB_JOB_CHARACTER);
- Index: java/net/sf/l2j/gameserver/handler/skillhandlers/Resurrect.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/skillhandlers/Resurrect.java (revision 4)
- +++ java/net/sf/l2j/gameserver/handler/skillhandlers/Resurrect.java (working copy)
- @@ -25,9 +25,11 @@
- {
- final Creature target = (Creature) cha;
- if (activeChar instanceof Player)
- - {
- + {
- if (cha instanceof Player)
- ((Player) cha).reviveRequest((Player) activeChar, skill, false);
- + else if (cha instanceof Player)
- + ((Player) cha).isInFunEvent();
- else if (cha instanceof Pet)
- {
- if (((Pet) cha).getOwner() == activeChar)
- Index: java/net/sf/l2j/gameserver/network/clientpackets/TradeRequest.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/network/clientpackets/TradeRequest.java (revision 4)
- +++ java/net/sf/l2j/gameserver/network/clientpackets/TradeRequest.java (working copy)
- @@ -46,7 +46,13 @@
- player.sendMessage("You or your target cannot trade during Olympiad.");
- return;
- }
- -
- +
- + if (player.isInFunEvent() || target.isInFunEvent())
- + {
- + player.sendMessage("You or your target cannot trade during event.");
- + return;
- + }
- +
- // Alt game - Karma punishment
- if (!Config.KARMA_PLAYER_CAN_TRADE && (player.getKarma() > 0 || target.getKarma() > 0))
- {
- Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestBypassToServer.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/network/clientpackets/RequestBypassToServer.java (revision 4)
- +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestBypassToServer.java (working copy)
- @@ -170,6 +170,12 @@
- player.sendPacket(SystemMessageId.WHILE_YOU_ARE_ON_THE_WAITING_LIST_YOU_ARE_NOT_ALLOWED_TO_WATCH_THE_GAME);
- return;
- }
- +
- + if (player.isInFunEvent())
- + {
- + player.sendMessage("You can not observe games while registered for event.");
- + return;
- + }
- final int arenaId = Integer.parseInt(_command.substring(12).trim());
- player.enterOlympiadObserverMode(arenaId);
- Index: java/net/sf/l2j/gameserver/handler/UserCommandHandler.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/UserCommandHandler.java (revision 4)
- +++ java/net/sf/l2j/gameserver/handler/UserCommandHandler.java (working copy)
- @@ -10,6 +10,7 @@
- import net.sf.l2j.gameserver.handler.usercommandhandlers.ClanWarsList;
- import net.sf.l2j.gameserver.handler.usercommandhandlers.DisMount;
- import net.sf.l2j.gameserver.handler.usercommandhandlers.Escape;
- +import net.sf.l2j.gameserver.handler.usercommandhandlers.EventCommands;
- import net.sf.l2j.gameserver.handler.usercommandhandlers.Loc;
- import net.sf.l2j.gameserver.handler.usercommandhandlers.Mount;
- import net.sf.l2j.gameserver.handler.usercommandhandlers.OlympiadStat;
- @@ -30,6 +31,7 @@
- registerHandler(new ClanWarsList());
- registerHandler(new DisMount());
- registerHandler(new Escape());
- + registerHandler(new EventCommands());
- registerHandler(new Loc());
- registerHandler(new Mount());
- registerHandler(new OlympiadStat());
- Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestGiveNickName.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/network/clientpackets/RequestGiveNickName.java (revision 4)
- +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestGiveNickName.java (working copy)
- @@ -25,8 +25,14 @@
- if (activeChar == null)
- return;
- + // check participants can not change their title
- + if (activeChar.isInFunEvent())
- + {
- + activeChar.sendMessage("You cannot change title while participating in an event.");
- + return;
- + }
- // Noblesse can bestow a title to themselves
- - if (activeChar.isNoble() && _target.matches(activeChar.getName()))
- + else if (activeChar.isNoble() && _target.matches(activeChar.getName()))
- {
- activeChar.setTitle(_title);
- activeChar.sendPacket(SystemMessageId.TITLE_CHANGED);
- Index: java/net/sf/l2j/gameserver/engine/impl/EventCommons.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/engine/impl/EventCommons.java (revision 0)
- +++ java/net/sf/l2j/gameserver/engine/impl/EventCommons.java (working copy)
- @@ -0,0 +1,240 @@
- +package net.sf.l2j.gameserver.engine.impl;
- +
- +import java.util.ArrayList;
- +import java.util.HashMap;
- +import net.sf.l2j.commons.concurrent.ThreadPool;
- +
- +import net.sf.l2j.Config;
- +import net.sf.l2j.gameserver.engine.TvTEvent;
- +import net.sf.l2j.gameserver.model.actor.Creature;
- +import net.sf.l2j.gameserver.model.actor.instance.Player;
- +import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
- +import net.sf.l2j.gameserver.network.serverpackets.PlaySound;
- +import net.sf.l2j.gameserver.network.serverpackets.SocialAction;
- +
- +/**
- + * @author Anarchy
- + *
- + */
- +public class EventCommons
- +{
- + private HashMap<Player, IEvent> _players;
- + private HashMap<Player, Class<?>> _registeredPlayers;
- +
- + public static EventCommons getInstance()
- + {
- + return SingletonHolder._instance;
- + }
- +
- + protected EventCommons()
- + {
- + _players = new HashMap<>();
- + _registeredPlayers = new HashMap<>();
- + }
- +
- + public void registerPlayer(Player player, Class<?> c)
- + {
- + if (_registeredPlayers.containsKey(player))
- + {
- + player.sendMessage("You have already registered for the event.");
- + return;
- + }
- + _registeredPlayers.put(player, c);
- + }
- +
- + public void unregisterPlayer(Player player, Class<?> c)
- + {
- + if (!_registeredPlayers.containsKey(player))
- + {
- + player.sendMessage("You have not registered for the event.");
- + return;
- + }
- +
- + _registeredPlayers.remove(player);
- + }
- +
- + public boolean showDiePacket(Player player)
- + {
- + if (_players.containsKey(player))
- + {
- + if (_players.get(player) instanceof TvTEvent)
- + return false;
- + }
- +
- + return true;
- + }
- +
- + public void doDie(Creature killer, Player victim)
- + {
- + if (_players.containsKey(victim))
- + {
- + if (killer != null && killer instanceof Player)
- + {
- + Player kl = (Player)killer;
- +
- + if (_players.containsKey(kl))
- + {
- + if (_players.get(victim) == _players.get(kl))
- + {
- + // TvT event kills.
- + if (_players.get(victim) instanceof TvTEvent)
- + {
- + if (kl.getEventTeam() != victim.getEventTeam())
- + {
- + final PlaySound ps = new PlaySound(0, "ItemSound.quest_itemget");
- + sysMsgToAllParticipants(killer.getName() + " I have killed " + victim.getName()+ " !");
- + kl.getEventTeam().addPoints(1);
- + kl.increaseScore();
- + kl.setTitle("Kills: " + kl.getScore());
- + kl.getAppearance().setVisibleTitle("Kills: " + kl.getScore());
- + kl.broadcastTitleInfo();
- + kl.sendPacket(ps);
- + }
- + victim.sendMessage("You will be revived in " + Config.TVT_RES_SECONDS + " second(s)");
- + ThreadPool.schedule(new ResTask(victim.getEventTeam().getRespawnX(), victim.getEventTeam().getRespawnY(), victim.getEventTeam().getRespawnZ(), victim, true),Config.TVT_RES_SECONDS * 1000);
- + }
- + }
- + }
- + }
- + }
- + }
- +
- + public void sysMsgToAllParticipants(String message)
- + {
- + for (Player player : _registeredPlayers.keySet())
- + {
- + if (player != null)
- + player.sendMessage(message);
- + }
- + }
- +
- + public boolean canTarget(Player player, Player target)
- + {
- + if ((!_players.containsKey(player) && _players.containsKey(target)) || (_players.containsKey(player) && !_players.containsKey(target)))
- + {
- + player.setTarget(null);
- + player.sendPacket(ActionFailed.STATIC_PACKET);
- + return false;
- + }
- +
- + if (_players.get(player) != _players.get(target))
- + {
- + player.setTarget(null);
- + player.sendPacket(ActionFailed.STATIC_PACKET);
- + return false;
- + }
- +
- + if ((target.getEventTeam() != null && player.getEventTeam() == null))
- + {
- + player.setTarget(null);
- + player.sendPacket(ActionFailed.STATIC_PACKET);
- + return false;
- + }
- +
- + if (target.getEventTeam() == null && player.getEventTeam() != null)
- + {
- + player.setTarget(null);
- + player.sendPacket(ActionFailed.STATIC_PACKET);
- + return false;
- + }
- +
- + return true;
- + }
- +
- + public void addPlayer(Player player, IEvent event)
- + {
- + if (!_players.containsKey(player))
- + _players.put(player, event);
- + }
- +
- + public void removePlayer(Player player)
- + {
- + if (_players.containsKey(player))
- + _players.remove(player);
- +
- + player.setTitle(player.getOriginalTitle());
- + player.getAppearance().setVisibleTitle(player.getOriginalTitle());
- + player.broadcastTitleInfo();
- + player.clearPoints();
- + player.broadcastPacket(new SocialAction(player, 7));
- + }
- +
- + public int getRegisteredPlayersSize(Class<?> c)
- + {
- + int i = 0;
- + for (Player p : _registeredPlayers.keySet())
- + {
- + if (_registeredPlayers.get(p) == c)
- + i++;
- + }
- +
- + return i;
- + }
- +
- + public void removeRegisteredPlayers(Class<?> c)
- + {
- + ArrayList<Player> temp = new ArrayList<>();
- +
- + for (Player p : _registeredPlayers.keySet())
- + {
- + if (_registeredPlayers.get(p) == c)
- + temp.add(p);
- + }
- +
- + for (Player p : temp)
- + {
- + _registeredPlayers.remove(p);
- + }
- + }
- +
- + public HashMap<Player, Class<?>> getRegisteredPlayers()
- + {
- + return _registeredPlayers;
- + }
- +
- + public ArrayList<Player> getRegisteredPlayers(Class<?> c)
- + {
- + ArrayList<Player> temp = new ArrayList<>();
- +
- + for (Player p : _registeredPlayers.keySet())
- + {
- + if (_registeredPlayers.get(p) == c)
- + temp.add(p);
- + }
- +
- + return temp;
- + }
- +
- + public class ResTask implements Runnable
- + {
- + private final int _x, _y, _z;
- + private final Player _player;
- + private final boolean _heal;
- +
- + public ResTask(int x, int y, int z, Player player, boolean heal)
- + {
- + _x = x;
- + _y = y;
- + _z = z;
- + _player = player;
- + _heal = heal;
- + }
- +
- + @Override
- + public void run()
- + {
- + _player.doRevive();
- + _player.teleToLocation(_x, _y, _z, 0);
- + if (_heal)
- + {
- + _player.setCurrentHpMp(_player.getMaxHp(), _player.getMaxMp());
- + _player.setCurrentCp(_player.getMaxCp());
- + }
- + }
- + }
- +
- + private static class SingletonHolder
- + {
- + protected static final EventCommons _instance = new EventCommons();
- + }
- +}
- \ No newline at end of file
- Index: java/net/sf/l2j/gameserver/handler/usercommandhandlers/Escape.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/usercommandhandlers/Escape.java (revision 4)
- +++ java/net/sf/l2j/gameserver/handler/usercommandhandlers/Escape.java (working copy)
- @@ -17,7 +17,7 @@
- @Override
- public boolean useUserCommand(int id, Player activeChar)
- {
- - if (activeChar.isCastingNow() || activeChar.isSitting() || activeChar.isMovementDisabled() || activeChar.isOutOfControl() || activeChar.isInOlympiadMode() || activeChar.isInObserverMode() || activeChar.isFestivalParticipant() || activeChar.isInJail() || activeChar.isInsideZone(ZoneId.BOSS))
- + if (activeChar.isCastingNow() || activeChar.isSitting() || activeChar.isMovementDisabled() || activeChar.isOutOfControl() || activeChar.isInOlympiadMode() || activeChar.isInObserverMode() || activeChar.isFestivalParticipant() || activeChar.isInJail() || activeChar.isInsideZone(ZoneId.BOSS) || activeChar.isInFunEvent())
- {
- activeChar.sendPacket(SystemMessageId.NO_UNSTUCK_PLEASE_SEND_PETITION);
- return false;
- Index: java/net/sf/l2j/gameserver/handler/itemhandlers/ItemSkills.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/itemhandlers/ItemSkills.java (revision 4)
- +++ java/net/sf/l2j/gameserver/handler/itemhandlers/ItemSkills.java (working copy)
- @@ -35,6 +35,13 @@
- return;
- }
- + // players can not use in events
- + if (activeChar.isInFunEvent())
- + {
- + activeChar.sendMessage("You can't use in event.");
- + return;
- + }
- +
- final IntIntHolder[] skills = item.getEtcItem().getSkills();
- if (skills == null)
- {
- Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestJoinParty.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/network/clientpackets/RequestJoinParty.java (revision 4)
- +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestJoinParty.java (working copy)
- @@ -40,7 +40,12 @@
- requestor.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.S1_HAS_ADDED_YOU_TO_IGNORE_LIST).addCharName(target));
- return;
- }
- -
- +
- + if (target.isInFunEvent() || requestor.isInFunEvent())
- + {
- + requestor.sendMessage("The player you tried to invite is currently in an event.");
- + return;
- + }
- if (target.equals(requestor) || target.isCursedWeaponEquipped() || requestor.isCursedWeaponEquipped() || target.getAppearance().getInvisible())
- {
- requestor.sendPacket(SystemMessageId.YOU_HAVE_INVITED_THE_WRONG_TARGET);
- Index: java/net/sf/l2j/gameserver/engine/TvTEvent.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/engine/TvTEvent.java (revision 0)
- +++ java/net/sf/l2j/gameserver/engine/TvTEvent.java (working copy)
- @@ -0,0 +1,251 @@
- +package net.sf.l2j.gameserver.engine;
- +
- +import java.util.ArrayList;
- +import java.util.LinkedList;
- +
- +import net.sf.l2j.commons.concurrent.ThreadPool;
- +
- +import net.sf.l2j.Config;
- +import net.sf.l2j.gameserver.data.ItemTable;
- +import net.sf.l2j.gameserver.data.xml.DoorData;
- +import net.sf.l2j.gameserver.engine.impl.EventCommons;
- +import net.sf.l2j.gameserver.engine.impl.EventState;
- +import net.sf.l2j.gameserver.engine.impl.EventTeam;
- +import net.sf.l2j.gameserver.engine.impl.IEvent;
- +import net.sf.l2j.gameserver.engine.impl.manager.EventManager;
- +import net.sf.l2j.gameserver.model.actor.instance.Door;
- +import net.sf.l2j.gameserver.model.actor.instance.Player;
- +import net.sf.l2j.gameserver.util.Broadcast;
- +
- +/**
- + * @author Anarchy
- + *
- + */
- +public class TvTEvent implements IEvent
- +{
- + public ArrayList<Player> _players;
- + private EventState _state = EventState.INACTIVE;
- + private final ArrayList<EventTeam> _teams;
- + private final ArrayList<Door> _doors;
- +
- + public TvTEvent()
- + {
- + _players = new ArrayList<>();
- + _teams = new ArrayList<>();
- + _doors = new ArrayList<>();
- + }
- +
- + @Override
- + public void runEvent()
- + {
- + if (EventManager.getInstance().getCurrentEvent() != null)
- + return;
- +
- + EventManager.getInstance().setCurrentEvent(this);
- +
- + if (Config.ALLOW_TVT_EVENT)
- + Broadcast.announceToOnlinePlayers("TeamVsTeam: Registration opened for " + Config.TVT_EVENT_PARTICIPATION_TIME + " minute(s). Type /join or /leave", true);
- + else
- + Broadcast.announceToOnlinePlayers("TVT: Registration opened for " + Config.TVT_EVENT_PARTICIPATION_TIME + " minute(s).", true);
- + for (int reward : Config.TVT_EVENT_REWARDS.keySet())
- + Broadcast.announceToOnlinePlayers("TeamVsTeam: Reward: " + reward + " " + ItemTable.getInstance().getTemplate(reward).getName(), true);
- +
- + _state = EventState.REGISTERING;
- +
- + sleep(120);
- +
- + // sleep(Config.TVT_EVENT_PARTICIPATION_TIME * 60 * 1000); // in config given as minutes
- +
- + if (!check())
- + {
- + EventManager.getInstance().setCurrentEvent(null);
- + return;
- + }
- +
- + Broadcast.announceToOnlinePlayers("TeamVsTeam: Registrations for the TvT Event are closed.", true);
- + EventCommons.getInstance().sysMsgToAllParticipants(" Teleporting participants to an arena in " + 10 + " second(s).");
- +
- + _state = EventState.RUNNING;
- +
- + sleep(10);
- +
- + split();
- +
- + for (EventTeam et : _teams)
- + {
- + et.teleportTeam(Config.TVT_TEAMS_DATA.get(et.getName())[0], Config.TVT_TEAMS_DATA.get(et.getName())[1], Config.TVT_TEAMS_DATA.get(et.getName())[2], true);
- +
- + et.paralize(true);
- + }
- + closeDoors();
- +
- + sleep(5);
- +
- + for (EventTeam et : _teams)
- + {
- + et.paralize(false);
- + }
- +
- + Broadcast.announceToOnlinePlayers("TeamVsTeam: The event will last for " + Config.TVT_EVENT_RUNNING_TIME + " minute(s).", true);
- + sleep(300); // tvt time in min
- +
- + ThreadPool.schedule(new Runnable()
- + {
- + @Override
- + public void run()
- + {
- + rewardAndClear();
- + }
- + }, 1000 * 13);
- +
- +
- + openDoors();
- + _state = EventState.INACTIVE;
- +
- + EventManager.getInstance().setCurrentEvent(null);
- + System.out.append("TeamVsTeam: Initialized, started in " + Config.TVT_EVENT_PARTICIPATION_TIME + " minute(s) and ends in " + Config.TVT_EVENT_RUNNING_TIME +" minute(s).");
- + }
- +
- + private void openDoors()
- + {
- + if (_doors.isEmpty())
- + {
- + for (int i : Config.TVT_DOORS)
- + {
- + Door door = DoorData.getInstance().getDoor(i);
- + door.openMe();
- + }
- + }
- + else
- + {
- + for (Door door : _doors)
- + {
- + door.deleteMe();
- + }
- + }
- + }
- +
- + private static void closeDoors()
- + {
- + for (int i : Config.TVT_DOORS)
- + {
- + Door door = DoorData.getInstance().getDoor(i);
- + door.closeMe();
- + }
- + }
- +
- + public void rewardAndClear()
- + {
- + int i = 0;
- + EventTeam winner = null;
- +
- + for (EventTeam et : _teams)
- + {
- + et.teleportTeam(82698, 148638, -3473, true);
- +
- + for (Player player : et.getPlayers())
- + {
- + EventCommons.getInstance().removePlayer(player);
- + }
- +
- + if (et.getPoints() > i)
- + {
- + i = et.getPoints();
- + winner = et;
- + }
- + }
- +
- + if (winner != null)
- + {
- + for (int ii : Config.TVT_EVENT_REWARDS.keySet())
- + {
- + winner.rewardTeam(ii, Config.TVT_EVENT_REWARDS.get(ii));
- + }
- +
- + Broadcast.announceToOnlinePlayers("TeamVsTeam: "+ winner.getName() + " team has won the event with " + winner.getPoints() + ".", true);
- + System.out.append("TeamVsTeam: "+ winner.getName() + " team has won the event with " + winner.getPoints() + ".");
- + }
- + else
- + Broadcast.announceToOnlinePlayers("TeamVsTeam: Ended with no winner.", true);
- + System.out.append("TeamVsTeam: Ended with no winner.");
- + return;
- + }
- +
- + public boolean check()
- + {
- + if (EventCommons.getInstance().getRegisteredPlayersSize(TvTEvent.class) < Config.TVT_TEAMS_DATA.size() * 1)
- + {
- + Broadcast.announceToOnlinePlayers("TeamVsTeam: Has been canceled due to lack of participants.", true);
- + EventCommons.getInstance().removeRegisteredPlayers(TvTEvent.class);
- + _state = EventState.INACTIVE;
- + System.out.append("TeamVsTeam: Has been canceled due to lack of participants.");
- + return false;
- + }
- +
- + return true;
- + }
- +
- + public void split()
- + {
- + int i = Config.TVT_TEAMS_DATA.size() - 1;
- + LinkedList<LinkedList<Player>> temp = new LinkedList<>();
- +
- + for (int ii = Config.TVT_TEAMS_DATA.size(); ii > 0; ii--)
- + {
- + LinkedList<Player> t = new LinkedList<>();
- + temp.add(t);
- + }
- +
- + for (Player p : EventCommons.getInstance().getRegisteredPlayers(TvTEvent.class))
- + {
- + temp.get(i).add(p);
- + i--;
- +
- + if (i == -1)
- + i = Config.TVT_TEAMS_DATA.size();
- +
- + EventCommons.getInstance().addPlayer(p, this);
- + }
- +
- + for (String s : Config.TVT_TEAMS_DATA.keySet())
- + {
- + EventTeam et = new EventTeam(temp.getLast(), s, 0, new int[]
- + {
- + Config.TVT_TEAMS_DATA.get(s)[0], Config.TVT_TEAMS_DATA.get(s)[1], Config.TVT_TEAMS_DATA.get(s)[2]
- + });
- + temp.remove(temp.getLast());
- +
- + _teams.add(et);
- + }
- + }
- +
- + private static void sleep(int seconds)
- + {
- + try
- + {
- + Thread.sleep(seconds * 1000);
- + }
- + catch (InterruptedException e)
- + {
- + e.printStackTrace();
- + }
- + }
- +
- + @Override
- + public EventState getState()
- + {
- + return _state;
- + }
- +
- + @Override
- + public String getTimes()
- + {
- + return Config.TVT_EVENT_TIMES;
- + }
- +
- + @Override
- + public int getId()
- + {
- + return 1;
- + }
- +}
- \ No newline at end of file
- Index: java/net/sf/l2j/gameserver/handler/itemhandlers/SummonItems.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/itemhandlers/SummonItems.java (revision 4)
- +++ java/net/sf/l2j/gameserver/handler/itemhandlers/SummonItems.java (working copy)
- @@ -41,6 +41,9 @@
- activeChar.sendPacket(SystemMessageId.CANT_MOVE_SITTING);
- return;
- }
- +
- + if (activeChar.isInFunEvent())
- + return;
- if (activeChar.isInObserverMode())
- return;
- Index: java/net/sf/l2j/gameserver/model/actor/instance/WeddingManagerNpc.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/actor/instance/WeddingManagerNpc.java (revision 4)
- +++ java/net/sf/l2j/gameserver/model/actor/instance/WeddingManagerNpc.java (working copy)
- @@ -122,7 +122,7 @@
- }
- // Simple checks to avoid exploits
- - if (partner.isInJail() || partner.isInOlympiadMode() || partner.isInDuel() || partner.isFestivalParticipant() || (partner.isInParty() && partner.getParty().isInDimensionalRift()) || partner.isInObserverMode())
- + if (partner.isInFunEvent() || partner.isInJail() || partner.isInOlympiadMode() || partner.isInDuel() || partner.isFestivalParticipant() || (partner.isInParty() && partner.getParty().isInDimensionalRift()) || partner.isInObserverMode())
- {
- player.sendMessage("Due to the current partner's status, the teleportation failed.");
- return;
- Index: java/net/sf/l2j/gameserver/model/actor/Creature.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/actor/Creature.java (revision 4)
- +++ java/net/sf/l2j/gameserver/model/actor/Creature.java (working copy)
- @@ -131,6 +131,7 @@
- private CreatureTemplate _template; // The link on the L2CharTemplate object containing generic and static properties
- protected String _title;
- + protected String _originalTitle;
- private double _hpUpdateIncCheck = .0;
- private double _hpUpdateDecCheck = .0;
- private double _hpUpdateInterval = .0;
- @@ -1888,8 +1889,16 @@
- {
- return _title;
- }
- -
- +
- /**
- + * @return the Title of the Creature.
- + */
- + public final String getOriginalTitle()
- + {
- + return _originalTitle;
- + }
- +
- + /**
- * Set the Title of the Creature. Concatens it if length > 16.
- * @param value The String to test.
- */
- Index: java/net/sf/l2j/gameserver/engine/impl/IEvent.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/engine/impl/IEvent.java (revision 0)
- +++ java/net/sf/l2j/gameserver/engine/impl/IEvent.java (working copy)
- @@ -0,0 +1,13 @@
- +package net.sf.l2j.gameserver.engine.impl;
- +
- +/**
- + * @author Anarchy
- + *
- + */
- +public interface IEvent
- +{
- + public void runEvent();
- + public EventState getState();
- + public String getTimes();
- + public int getId();
- +}
- Index: java/net/sf/l2j/gameserver/engine/impl/EventState.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/engine/impl/EventState.java (revision 0)
- +++ java/net/sf/l2j/gameserver/engine/impl/EventState.java (working copy)
- @@ -0,0 +1,12 @@
- +package net.sf.l2j.gameserver.engine.impl;
- +
- +/**
- + * @author Anarchy
- + *
- + */
- +public enum EventState
- +{
- + INACTIVE,
- + REGISTERING,
- + RUNNING
- +}
- Index: java/net/sf/l2j/gameserver/engine/impl/EventTeam.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/engine/impl/EventTeam.java (revision 0)
- +++ java/net/sf/l2j/gameserver/engine/impl/EventTeam.java (working copy)
- @@ -0,0 +1,207 @@
- +package net.sf.l2j.gameserver.engine.impl;
- +
- +import java.util.List;
- +
- +import net.sf.l2j.Config;
- +import net.sf.l2j.gameserver.data.SkillTable;
- +import net.sf.l2j.gameserver.model.actor.Summon;
- +import net.sf.l2j.gameserver.model.actor.instance.Pet;
- +import net.sf.l2j.gameserver.model.actor.instance.Player;
- +import net.sf.l2j.gameserver.model.group.Party;
- +import net.sf.l2j.gameserver.model.group.Party.MessageType;
- +import net.sf.l2j.gameserver.network.serverpackets.ExShowScreenMessage;
- +import net.sf.l2j.gameserver.network.serverpackets.MagicSkillUse;
- +import net.sf.l2j.gameserver.network.serverpackets.Ride;
- +import net.sf.l2j.gameserver.network.serverpackets.SocialAction;
- +import net.sf.l2j.gameserver.skills.AbnormalEffect;
- +
- +/**
- + * @author williams
- + *
- + */
- +public class EventTeam
- +{
- + private final List<Player> _players;
- + private final String _name;
- + private int _points;
- + private final int[] _respawnLoc;
- +
- + public EventTeam(List<Player> players, String name, int points, int[] respawnLoc)
- + {
- + _players = players;
- + _name = name;
- + _points = points;
- + _respawnLoc = respawnLoc;
- +
- + for (Player p : _players)
- + {
- + p.setEventTeam(this);
- + }
- + }
- +
- + /**
- + * The method to teleport the player<br>
- + * 1. Unsummon pet if there is one
- + * 2. Remove all effects
- + * 3. Revive and full heal the player
- + * 4. Teleport the player
- + * 5. Broadcast status and user info
- + * 6. Remove party
- + * 7. Remove players mounted
- + * @param x
- + * @param y
- + * @param z
- + * @param teleport
- + */
- + public void teleportTeam(int x, int y, int z, boolean teleport)
- + {
- + for (Player player : _players)
- + {
- + if (player == null)
- + return;
- +
- + // Count Kills at the title
- + player.setTitle("Kills: " + player.getScore());
- + player.getAppearance().setVisibleTitle("Kills: " + player.getScore());
- + player.broadcastTitleInfo();
- +
- + // Aura duel for team
- + if (teleport)
- + player.setTeam(1 + 1);
- + else
- + player.setTeam(0);
- +
- + // Remove players Mounted
- + if (player.isMounted())
- + {
- + if (player.dismount())
- + {
- + if (player.isFlying())
- + player.removeSkill(SkillTable.FrequentSkill.WYVERN_BREATH.getSkill().getId(), false);
- +
- + final Ride dismount = new Ride(player.getObjectId(), Ride.ACTION_DISMOUNT, 0);
- + player.broadcastPacket(dismount);
- + player.setMountObjectId(0);
- + }
- + }
- +
- + // Remove Buffs
- + if (Config.TvT_EVENT_REMOVE_BUFFS)
- + player.stopAllEffectsExceptThoseThatLastThroughDeath();
- +
- + // Heal/Revive Player fully
- + player.setCurrentCp(player.getMaxCp());
- + player.setCurrentHp(player.getMaxHp());
- + player.setCurrentMp(player.getMaxMp());
- + player.doRevive();
- +
- + // Remove Summon's Buffs
- + final Summon summon = player.getPet();
- + if (Config.TvT_EVENT_REMOVE_BUFFS && summon != null)
- + {
- + summon.stopAllEffectsExceptThoseThatLastThroughDeath();
- + summon.abortAttack();
- + summon.abortCast();
- +
- + if (summon instanceof Pet)
- + summon.unSummon(player);
- + }
- +
- + player.broadcastStatusUpdate();
- + player.broadcastUserInfo();
- +
- + // stop any cubic that has been given by other player.
- + player.stopCubicsByOthers();
- +
- + // Remove player from his party
- + if (teleport)
- + {
- + final Party party = player.getParty();
- + if (party != null)
- + party.removePartyMember(player, MessageType.EXPELLED);
- + }
- +
- + player.teleToLocation(x, y, z, 0);
- + if (teleport)
- + player.sendMessage("You have been teleported.");
- + }
- + }
- +
- + public void paralize(boolean val)
- + {
- + if (val)
- + {
- + for (Player player : _players)
- + {
- + player.sendPacket(new ExShowScreenMessage("Fight starts in seconds!", 5000, 0x02, true));
- + player.startAbnormalEffect(AbnormalEffect.ROOT);
- + player.setIsParalyzed(true);
- + }
- + }
- + else
- + {
- + for (Player player : _players)
- + {
- + player.broadcastPacket(new SocialAction(player, 4));
- + player.sendPacket(new ExShowScreenMessage("Fight started!", 5000, 0x02, true));
- + player.stopAbnormalEffect(AbnormalEffect.ROOT);
- + player.setIsParalyzed(false);
- + }
- + }
- + }
- +
- + public void rewardTeam(int itemId, int count)
- + {
- + for (Player player : _players)
- + {
- + // Fireworks for rewarded player
- + player.broadcastPacket(new MagicSkillUse(player, player, 2025, 1, 1, 1));
- + player.addItem("Event Reward", itemId, count, null, true);
- + }
- + }
- +
- + public void addPoints(int val)
- + {
- + _points += val;
- + }
- +
- + public void removePoints(int val)
- + {
- + _points -= val;
- + }
- +
- + public int getPoints()
- + {
- + return _points;
- + }
- +
- + public int getRespawnX()
- + {
- + return _respawnLoc[0];
- + }
- +
- + public int getRespawnY()
- + {
- + return _respawnLoc[1];
- + }
- +
- + public int getRespawnZ()
- + {
- + return _respawnLoc[2];
- + }
- +
- + public String getName()
- + {
- + return _name;
- + }
- +
- + public List<Player> getPlayers()
- + {
- + return _players;
- + }
- +
- + public boolean containsPlayer(Player p)
- + {
- + return _players.contains(p);
- + }
- +}
- \ No newline at end of file
- Index: java/net/sf/l2j/gameserver/model/actor/instance/Player.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/actor/instance/Player.java (revision 4)
- +++ java/net/sf/l2j/gameserver/model/actor/instance/Player.java (working copy)
- @@ -48,6 +48,9 @@
- import net.sf.l2j.gameserver.data.xml.NpcData;
- import net.sf.l2j.gameserver.data.xml.PlayerData;
- import net.sf.l2j.gameserver.data.xml.RecipeData;
- +import net.sf.l2j.gameserver.engine.TvTEvent;
- +import net.sf.l2j.gameserver.engine.impl.EventCommons;
- +import net.sf.l2j.gameserver.engine.impl.EventTeam;
- import net.sf.l2j.gameserver.geoengine.GeoEngine;
- import net.sf.l2j.gameserver.handler.IItemHandler;
- import net.sf.l2j.gameserver.handler.ItemHandler;
- @@ -578,6 +581,10 @@
- private Door _requestedGate;
- + private EventTeam _eventTeam = null;
- +
- + private short _points = 0;
- +
- /**
- * Constructor of Player (use Creature constructor).
- * <ul>
- @@ -2897,6 +2904,9 @@
- @Override
- public void onAction(Player player)
- {
- + if (!EventCommons.getInstance().canTarget(player, this))
- + return;
- +
- // Set the target of the player
- if (player.getTarget() != this)
- player.setTarget(this);
- @@ -2942,6 +2952,9 @@
- if (player.isGM())
- AdminEditChar.showCharacterInfo(player, this);
- + if (!EventCommons.getInstance().canTarget(player, this))
- + return;
- +
- super.onActionShift(player);
- }
- @@ -3654,6 +3667,8 @@
- if (isFakeDeath())
- stopFakeDeath(true);
- }
- +
- + EventCommons.getInstance().doDie(killer, this);
- if (killer != null)
- {
- @@ -3870,6 +3885,9 @@
- // PK Points are increased only if you kill a player.
- if (target instanceof Player)
- setPkKills(getPkKills() + 1);
- +
- + if (isInFunEvent() == false)
- + return;
- // Calculate new karma.
- setKarma(getKarma() + Formulas.calculateKarmaGain(getPkKills(), target instanceof Summon));
- @@ -3895,6 +3913,9 @@
- final Player player = target.getActingPlayer();
- if (player == null)
- return;
- +
- + if (isInFunEvent() == false)
- + return;
- if (isInDuel() && player.getDuelId() == getDuelId())
- return;
- @@ -9278,6 +9299,9 @@
- if (OlympiadManager.getInstance().isRegisteredInComp(this))
- OlympiadManager.getInstance().removeDisconnectedCompetitor(this);
- +
- + // Handle removal from TeamVsTeam
- + EventCommons.getInstance().removeRegisteredPlayers(TvTEvent.class);
- // Open a Html message to inform the player
- final NpcHtmlMessage html = new NpcHtmlMessage(0);
- @@ -9425,7 +9449,7 @@
- if (_deathPenaltyBuffLevel >= 15) // maximum level reached
- return;
- - if ((getKarma() > 0 || Rnd.get(1, 100) <= Config.DEATH_PENALTY_CHANCE) && !(killer instanceof Player) && !isGM() && !(getCharmOfLuck() && (killer == null || killer.isRaid())) && !isPhoenixBlessed() && !(isInsideZone(ZoneId.PVP) || isInsideZone(ZoneId.SIEGE)))
- + if ((getKarma() > 0 || Rnd.get(1, 100) <= Config.DEATH_PENALTY_CHANCE) && !(killer instanceof Player) && !isGM() && !(getCharmOfLuck() && (killer == null || killer.isRaid())) && !isPhoenixBlessed() && !(isInsideZone(ZoneId.PVP) || isInsideZone(ZoneId.SIEGE)) && isInFunEvent())
- {
- if (_deathPenaltyBuffLevel != 0)
- removeSkill(5076, false);
- @@ -9808,7 +9832,7 @@
- if (summonerChar == null)
- return false;
- - if (summonerChar.isInOlympiadMode() || summonerChar.isInObserverMode() || summonerChar.isInsideZone(ZoneId.NO_SUMMON_FRIEND) || summonerChar.isMounted())
- + if (summonerChar.isInFunEvent() || summonerChar.isInOlympiadMode() || summonerChar.isInObserverMode() || summonerChar.isInsideZone(ZoneId.NO_SUMMON_FRIEND) || summonerChar.isMounted())
- return false;
- return true;
- @@ -9851,7 +9875,7 @@
- return false;
- }
- - if (targetChar.isInObserverMode() || targetChar.isInsideZone(ZoneId.NO_SUMMON_FRIEND))
- + if (targetChar.isInObserverMode() || targetChar.isInsideZone(ZoneId.NO_SUMMON_FRIEND) || targetChar.isInFunEvent())
- {
- summonerChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.S1_IN_SUMMON_BLOCKING_AREA).addCharName(targetChar));
- return false;
- @@ -10174,6 +10198,36 @@
- {
- _requestedGate = door;
- }
- +
- + public boolean isInFunEvent()
- + {
- + return ((EventCommons.getInstance().getRegisteredPlayers().containsKey(this)));
- + }
- +
- + public EventTeam getEventTeam()
- + {
- + return _eventTeam;
- + }
- +
- + public void setEventTeam(EventTeam val)
- + {
- + _eventTeam = val;
- + }
- +
- + public short getScore()
- + {
- + return _points;
- + }
- +
- + public void clearPoints()
- + {
- + _points = 0;
- + }
- +
- + public void increaseScore()
- + {
- + _points++;
- + }
- @Override
- public boolean polymorph(PolyType type, int npcId)
- Index: config/events.properties
- ===================================================================
- --- config/events.properties (revision 4)
- +++ config/events.properties (working copy)
- @@ -235,4 +235,29 @@
- AltFishChampionshipReward2 = 500000
- AltFishChampionshipReward3 = 300000
- AltFishChampionshipReward4 = 200000
- -AltFishChampionshipReward5 = 100000
- \ No newline at end of file
- +AltFishChampionshipReward5 = 100000
- +
- +#=============================================================
- +# TvT Event
- +#=============================================================
- +# Enable or disable the TvT Event.
- +AllowTvtEvent = True
- +# Times of day that the event will take place.
- +TvtEventTimes = 12:00,14:00,16:00
- +# Registration timer from start of event (in minutes).
- +TvTEventParticipationTime = 5
- +# Event running time (in minutes).
- +TvTEventRunningTime = 5
- +# Rewards.
- +TvtEventRewards = 57,1000;
- +# Team data. Should be like this: teamname_x,y,z;teamname_x,y,z.
- +# Note: You can add as many teams as you like.
- +TvtTeamsData = Angels_148404,46718,-3414;Demons_150545,46718,-3414
- +# Time to res after death.
- +TvtResSeconds = 5
- +# Doors to close when event starts.
- +# Default doors: Coliseum
- +TvtDoors = 24190001,24190002,24190003,24190004
- +# Participant's effects
- +# 1. Unsummon pet if there is one , 2. Remove all effects , 3. Remove party, 4. Remove players mounted
- +TvTEventRemoveBuffs True
- \ No newline at end of file
- Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestRestart.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/network/clientpackets/RequestRestart.java (revision 4)
- +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestRestart.java (working copy)
- @@ -36,7 +36,14 @@
- sendPacket(RestartResponse.valueOf(false));
- return;
- }
- -
- +
- + if (player.isInFunEvent())
- + {
- + player.sendMessage("You can not restart the event.");
- + sendPacket(RestartResponse.valueOf(false));
- + return;
- + }
- +
- if (AttackStanceTaskManager.getInstance().isInAttackStance(player))
- {
- player.sendPacket(SystemMessageId.CANT_RESTART_WHILE_FIGHTING);
- Index: java/net/sf/l2j/gameserver/skills/l2skills/L2SkillTeleport.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/skills/l2skills/L2SkillTeleport.java (revision 4)
- +++ java/net/sf/l2j/gameserver/skills/l2skills/L2SkillTeleport.java (working copy)
- @@ -38,7 +38,7 @@
- if (activeChar instanceof Player)
- {
- // Check invalid states.
- - if (activeChar.isAfraid() || ((Player) activeChar).isInOlympiadMode() || activeChar.isInsideZone(ZoneId.BOSS))
- + if (((Player) activeChar).isInFunEvent() || activeChar.isAfraid() || ((Player) activeChar).isInOlympiadMode() || activeChar.isInsideZone(ZoneId.BOSS))
- return;
- }
- Index: java/net/sf/l2j/gameserver/handler/usercommandhandlers/EventCommands.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/usercommandhandlers/EventCommands.java (revision 0)
- +++ java/net/sf/l2j/gameserver/handler/usercommandhandlers/EventCommands.java (working copy)
- @@ -0,0 +1,52 @@
- +package net.sf.l2j.gameserver.handler.usercommandhandlers;
- +
- +import net.sf.l2j.gameserver.engine.TvTEvent;
- +import net.sf.l2j.gameserver.engine.impl.EventCommons;
- +import net.sf.l2j.gameserver.engine.impl.EventState;
- +import net.sf.l2j.gameserver.engine.impl.manager.EventManager;
- +import net.sf.l2j.gameserver.handler.IUserCommandHandler;
- +import net.sf.l2j.gameserver.model.actor.instance.Player;
- +
- +/**
- + * @author williams
- + *
- + */
- +public class EventCommands implements IUserCommandHandler
- +{
- + private static final int[] COMMAND_IDS =
- + {
- + 114, 115
- + };
- +
- + @Override
- + public boolean useUserCommand(int id, Player activeChar)
- + {
- + if (activeChar.isInOlympiadMode())
- + return false;
- +
- + if (id == 114)
- + {
- + if (EventManager.getInstance().getCurrentEvent() == null || EventManager.getInstance().getCurrentEvent().getState() != EventState.REGISTERING)
- + return false;
- +
- + EventCommons.getInstance().registerPlayer(activeChar, TvTEvent.class);
- + activeChar.sendMessage("You have registered successfully.");
- +
- + }
- + else if (id == 115)
- + {
- + if (EventCommons.getInstance().getRegisteredPlayers().containsKey(activeChar))
- + EventCommons.getInstance().unregisterPlayer(activeChar,EventCommons.getInstance().getRegisteredPlayers().get(activeChar));
- +
- + activeChar.sendMessage("You have canceled your registration.");
- + }
- +
- + return true;
- + }
- +
- + @Override
- + public int[] getUserCommandList()
- + {
- + return COMMAND_IDS;
- + }
- +}
- Index: java/net/sf/l2j/gameserver/GameServer.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/GameServer.java (revision 4)
- +++ java/net/sf/l2j/gameserver/GameServer.java (working copy)
- @@ -59,6 +59,7 @@
- import net.sf.l2j.gameserver.data.xml.SummonItemData;
- import net.sf.l2j.gameserver.data.xml.TeleportLocationData;
- import net.sf.l2j.gameserver.data.xml.WalkerRouteData;
- +import net.sf.l2j.gameserver.engine.impl.manager.EventManager;
- import net.sf.l2j.gameserver.geoengine.GeoEngine;
- import net.sf.l2j.gameserver.handler.AdminCommandHandler;
- import net.sf.l2j.gameserver.handler.ChatHandler;
- @@ -278,6 +279,9 @@
- LOGGER.info("Loaded {} skill handlers.", SkillHandler.getInstance().size());
- LOGGER.info("Loaded {} user command handlers.", UserCommandHandler.getInstance().size());
- + StringUtil.printSection("Event Manager");
- + EventManager.getInstance();
- +
- StringUtil.printSection("System");
- Runtime.getRuntime().addShutdownHook(Shutdown.getInstance());
- ForumsBBSManager.getInstance();
- Index: java/net/sf/l2j/gameserver/handler/itemhandlers/ScrollOfResurrection.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/itemhandlers/ScrollOfResurrection.java (revision 4)
- +++ java/net/sf/l2j/gameserver/handler/itemhandlers/ScrollOfResurrection.java (working copy)
- @@ -38,6 +38,12 @@
- activeChar.sendPacket(SystemMessageId.INCORRECT_TARGET);
- return;
- }
- +
- + if (activeChar.isInFunEvent())
- + {
- + activeChar.sendMessage("You can't use resurrection in event.");
- + return;
- + }
- // Pet scrolls to ress a player.
- if (item.getItemId() == 6387 && target instanceof Player)
- Index: java/net/sf/l2j/Config.java
- ===================================================================
- --- java/net/sf/l2j/Config.java (revision 4)
- +++ java/net/sf/l2j/Config.java (working copy)
- @@ -168,7 +168,7 @@
- public static int FS_TIME_WARMUP;
- public static int FS_PARTY_MEMBER_COUNT;
- - /** dimensional rift */
- + /** Dimensional rift */
- public static int RIFT_MIN_PARTY_SIZE;
- public static int RIFT_SPAWN_DELAY;
- public static int RIFT_MAX_JUMPS;
- @@ -205,6 +205,17 @@
- public static int ALT_FISH_CHAMPIONSHIP_REWARD_4;
- public static int ALT_FISH_CHAMPIONSHIP_REWARD_5;
- + /** TvT Event */
- + public static boolean ALLOW_TVT_EVENT;
- + public static boolean TvT_EVENT_REMOVE_BUFFS;
- + public static int TVT_EVENT_PARTICIPATION_TIME;
- + public static int TVT_EVENT_RUNNING_TIME;
- + public static int TVT_RES_SECONDS;
- + public static String TVT_EVENT_TIMES;
- + public static HashMap<Integer, Integer> TVT_EVENT_REWARDS = new HashMap<>();
- + public static HashMap<String, int[]> TVT_TEAMS_DATA = new HashMap<>();
- + public static ArrayList<Integer> TVT_DOORS = new ArrayList<>();
- +
- // --------------------------------------------------
- // GeoEngine
- // --------------------------------------------------
- @@ -871,6 +882,41 @@
- ALT_FISH_CHAMPIONSHIP_REWARD_3 = events.getProperty("AltFishChampionshipReward3", 300000);
- ALT_FISH_CHAMPIONSHIP_REWARD_4 = events.getProperty("AltFishChampionshipReward4", 200000);
- ALT_FISH_CHAMPIONSHIP_REWARD_5 = events.getProperty("AltFishChampionshipReward5", 100000);
- +
- + ALLOW_TVT_EVENT = events.getProperty("AllowTvtEvent", false);
- + TvT_EVENT_REMOVE_BUFFS = events.getProperty("TvTEventRemoveBuffs", false);
- + TVT_EVENT_TIMES = events.getProperty("TvtEventTimes", "12:00,14:00,16:00");
- + TVT_EVENT_PARTICIPATION_TIME = events.getProperty("TvTEventParticipationTime", 3600);
- + TVT_EVENT_RUNNING_TIME = events.getProperty("TvTEventRunningTime", 1800);
- + String TVT_EVENT_REWARDS_VALUE = events.getProperty("TvtEventRewards", "57,1;");
- + String[] tvt_event_rewards_splitted_1 = TVT_EVENT_REWARDS_VALUE.split(";");
- + for (String i : tvt_event_rewards_splitted_1)
- + {
- + String[] tvt_event_rewards_splitted_2 = i.split(",");
- + TVT_EVENT_REWARDS.put(Integer.parseInt(tvt_event_rewards_splitted_2[0]),
- + Integer.parseInt(tvt_event_rewards_splitted_2[1]));
- + }
- + String tvt_teams_data = events.getProperty("TvtTeamsData", "Good_0,0,0;Evil_0,0,0");
- + String[] ttd_splitted = tvt_teams_data.split(";");
- + for (String s : ttd_splitted)
- + {
- + String[] ss = s.split("_");
- + String name = ss[0];
- + String[] sss = ss[1].split(",");
- + int x = Integer.parseInt(sss[0]);
- + int y = Integer.parseInt(sss[1]);
- + int z = Integer.parseInt(sss[2]);
- +
- + TVT_TEAMS_DATA.put(name, new int[] { x, y, z });
- + }
- + TVT_RES_SECONDS = events.getProperty("TvtResSeconds", 10);
- + String tvt_doors = events.getProperty("TvtDoors", "24190001,24190002,24190003,24190004");
- + String[] tvt_doors_split = tvt_doors.split(",");
- + for (String s : tvt_doors_split)
- + {
- + int i = Integer.parseInt(s);
- + TVT_DOORS.add(i);
- + }
- }
- /**
- Index: java/net/sf/l2j/gameserver/engine/impl/manager/EventManager.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/engine/impl/manager/EventManager.java (revision 0)
- +++ java/net/sf/l2j/gameserver/engine/impl/manager/EventManager.java (working copy)
- @@ -0,0 +1,132 @@
- +package net.sf.l2j.gameserver.engine.impl.manager;
- +
- +import java.util.Calendar;
- +import java.util.HashMap;
- +import java.util.logging.Logger;
- +
- +import net.sf.l2j.commons.concurrent.ThreadPool;
- +
- +import net.sf.l2j.Config;
- +import net.sf.l2j.gameserver.engine.TvTEvent;
- +import net.sf.l2j.gameserver.engine.impl.IEvent;
- +
- +/**
- + * @author Anarchy
- + *
- + */
- +public final class EventManager
- +{
- + private static final Logger _log = Logger.getLogger(EventManager.class.getName());
- +
- + public static int TVT = 1;
- +
- + private int _events = 0;
- + public HashMap<IEvent, Integer> _eventsTasks;
- + private IEvent _currentEvent = null;
- +
- + public static EventManager getInstance()
- + {
- + return SingletonHolder._instance;
- + }
- +
- + protected EventManager()
- + {
- + _eventsTasks = new HashMap<>();
- +
- + if (Config.ALLOW_TVT_EVENT)
- + registerEvent(Config.TVT_EVENT_TIMES, TvTEvent.class);
- +
- + _log.info("Loaded " + _events + " events.");
- + }
- +
- + public void registerEvent(final String times, final Class<?> type)
- + {
- + _events++;
- +
- + int i = 0;
- +
- + for (String time : times.split(","))
- + {
- + final IEvent event;
- +
- + try
- + {
- + event = (IEvent)type.newInstance();
- + }
- + catch (InstantiationException | IllegalAccessException ea)
- + {
- + ea.printStackTrace();
- + return;
- + }
- +
- + String[] timeArray = time.split(":");
- + int hours = Integer.parseInt(timeArray[0]);
- + int minutes = Integer.parseInt(timeArray[1]);
- +
- + Calendar cld = Calendar.getInstance();
- +
- + cld.set(Calendar.HOUR_OF_DAY, hours);
- + cld.set(Calendar.MINUTE, minutes);
- + cld.set(Calendar.SECOND, 0);
- +
- + if (cld.getTimeInMillis() - System.currentTimeMillis() < 0)
- + {
- + cld.set(Calendar.DAY_OF_MONTH, cld.get(Calendar.DAY_OF_MONTH) + 1);
- + cld.set(Calendar.HOUR_OF_DAY, hours);
- + cld.set(Calendar.MINUTE, minutes);
- + cld.set(Calendar.SECOND, 0);
- + }
- +
- + if (cld.getTimeInMillis() - System.currentTimeMillis() > 0)
- + {
- + i++;
- +
- + if (_eventsTasks.containsKey(event))
- + {
- + _eventsTasks.remove(event);
- + _eventsTasks.put(event, i);
- + }
- + else
- + {
- + _eventsTasks.put(event, i);
- + }
- +
- + ThreadPool.schedule(new Runnable()
- + {
- + @Override
- + public void run()
- + {
- + if (_eventsTasks.get(event) == 1)
- + {
- + _eventsTasks.remove(event);
- + registerEvent(times, type);
- + }
- + else
- + {
- + int t = _eventsTasks.get(event);
- + _eventsTasks.remove(event);
- + _eventsTasks.put(event, t--);
- + }
- +
- + event.runEvent();
- + }
- + }, cld.getTimeInMillis() - System.currentTimeMillis());
- + }
- + }
- + }
- +
- + public IEvent getCurrentEvent()
- + {
- + return _currentEvent;
- + }
- +
- + public void setCurrentEvent(IEvent event)
- + {
- + _currentEvent = event;
- + }
- +
- + private static class SingletonHolder
- + {
- + protected static final EventManager _instance = new EventManager();
- + }
- +}
- \ No newline at end of file
- Index: java/net/sf/l2j/gameserver/handler/skillhandlers/GetPlayer.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/skillhandlers/GetPlayer.java (revision 4)
- +++ java/net/sf/l2j/gameserver/handler/skillhandlers/GetPlayer.java (working copy)
- @@ -28,6 +28,9 @@
- final Player victim = target.getActingPlayer();
- if (victim == null || victim.isAlikeDead())
- continue;
- +
- + if (!victim.isInFunEvent())
- + continue;
- victim.teleToLocation(activeChar.getX(), activeChar.getY(), activeChar.getZ(), 0);
- }
- Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestRestartPoint.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/network/clientpackets/RequestRestartPoint.java (revision 4)
- +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestRestartPoint.java (working copy)
- @@ -39,6 +39,9 @@
- player.stopFakeDeath(true);
- return;
- }
- +
- + if (player.isInFunEvent())
- + return;
- if (!player.isDead())
- return;
- Index: java/net/sf/l2j/gameserver/network/clientpackets/Logout.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/network/clientpackets/Logout.java (revision 4)
- +++ java/net/sf/l2j/gameserver/network/clientpackets/Logout.java (working copy)
- @@ -26,6 +26,13 @@
- player.sendPacket(ActionFailed.STATIC_PACKET);
- return;
- }
- +
- + if (player.isInFunEvent())
- + {
- + player.sendMessage("You can not exit the event.");
- + player.sendPacket(ActionFailed.STATIC_PACKET);
- + return;
- + }
- if (player.isInsideZone(ZoneId.NO_RESTART))
- {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement