Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/L2jOne_C6_Interlude/data/xml/events/DeathMatch.xml b/L2jOne_C6_Interlude/data/xml/events/DeathMatch.xml
- new file mode 100644
- index 0000000..1403ec3
- --- /dev/null
- +++ b/L2jOne_C6_Interlude/data/xml/events/DeathMatch.xml
- @@ -0,0 +1,79 @@
- +<?xml version="1.0" encoding="UTF-8"?>
- +<!-- Death Match Event -->
- +<dm>
- + <!-- Times Death Match will occur (24h format) -->
- + <EventTimeInterval val="17:21" />
- +
- + <!-- Event duration time (in minutes) -->
- + <Duration val="10" />
- +
- + <!-- The minimum and maximum number of players to start the event -->
- + <Participants min="2" max="50" />
- +
- + <!-- The minimum and maximum level allowed to participate at the event -->
- + <Level min="76" max="85" />
- +
- + <!-- Time for registration (in minutes) -->
- + <TimeToRegistration val="10" />
- +
- + <!-- Time for registration (in seconds) -->
- + <TimeToTeleport val="10" />
- +
- + <!-- Require item to register in the event? -->
- + <AllowTakeItems val="false" />
- + <!-- Item ID and Count required to register -->
- + <TakeItems id="57" count="100000" />
- +
- + <!-- Allow give reward for kill? -->
- + <AllowKillBonus val="false" />
- + <!-- Reward ID and Count for each kill -->
- + <KillReward id="57" count="100000" />
- +
- + <!-- Coordinates where the players will spawn -->
- + <PlayerEventCoordinates x="-213471" y="244903" z="2021" h="32768" />
- +
- + <!-- Stop all effects at the start of the event? -->
- + <StopAllEffects val="true" />
- +
- + <!-- Hide the player names and titles at the event? -->
- + <HidePlayersIdentity val="true" />
- +
- + <!-- Enable / Disable the participation with multiple boxes -->
- + <AllowMultipleBoxes val="false" />
- +
- + <!-- Reward ID and Count for the winner. For multiple rewards separate with (,) -->
- + <Rewards1stPlace id="3470,9627,6673" count="25,3,1" />
- +
- + <!-- Reward ID and Count for the second place. For multiple rewards separate with (,) -->
- + <Rewards2ndPlace id="3470,9627,6673" count="15,2,1" />
- +
- + <!-- Reward ID and Count for the third place. For multiple rewards separate with (,) -->
- + <Rewards3rdPlace id="3470,9627,6673" count="5,1,1" />
- +
- + <!-- Reward in case of tie? -->
- + <RewardTie val="true" />
- +
- + <!-- List of buffs given to the players, separate with (,) -->
- + <ListMageSupport val="1078,1085,1303,1517,1518,1519,1535,1536,1537,1538" />
- + <ListFighterSupport val="1499,1500,1501,1502,1503,1504,1517" />
- +
- + <!-- List of the restricted items on the event, separate with (,) -->
- + <!--<RestrictItems val="" />-->
- +
- + <!-- List of the restricted skills on the event, separate with (,) -->
- + <!--<RestrictSkills val="" />-->
- +
- + <!-- Allow player to use potions during the event? -->
- + <AllowPotions val="false" />
- +
- + <!-- Allow player to use scrolls during the event? -->
- + <AllowScrolls val="false" />
- +
- + <!-- Allow player to use summons by items during the event? -->
- + <AllowSummonByItem val="false" />
- +
- + <!-- Require a minimal amount of kills to receive the reward? -->
- + <RequireMinFragsToReward val="false" />
- + <!-- Minimal amount of kills to receive the reward -->
- + <MinFragsRequired val="1" />
- +</dm>
- \ No newline at end of file
- diff --git a/L2jOne_C6_Interlude/data/xml/events/TvT.xml b/L2jOne_C6_Interlude/data/xml/events/TvT.xml
- new file mode 100644
- index 0000000..530e237
- --- /dev/null
- +++ b/L2jOne_C6_Interlude/data/xml/events/TvT.xml
- @@ -0,0 +1,84 @@
- +<?xml version='1.0' encoding='utf-8'?>
- +<!-- TvT Event -->
- +<tvt>
- + <!-- Times TvT will occur (24h format) -->
- + <EventTimeInterval val="18:11" />
- +
- + <!-- Event duration time (in minutes) -->
- + <Duration val="1" />
- +
- + <!-- The minimum and maximum number of players to start the event -->
- + <Participants min="5" max="250" />
- +
- + <!-- The minimum and maximum level allowed to participate at the event -->
- + <Level min="76" max="85" />
- +
- + <!-- Time for registration (in minutes) -->
- + <TimeToRegistration val="10" />
- +
- + <!-- Time for registration (in seconds) -->
- + <TimeToTeleport val="10" />
- +
- + <!-- Require item to register in the event? -->
- + <AllowTakeItems val="true" />
- + <!-- Item ID and Count required to register -->
- + <TakeItems id="57" count="100000" />
- +
- + <!-- Allow give reward for kill? -->
- + <AllowKillBonus val="false" />
- + <!-- Reward ID and Count for each kill -->
- + <KillReward id="57" count="100000" />
- +
- + <!-- Stop all effects at the start of the event? -->
- + <StopAllEffects val="true" />
- +
- + <!-- Hide the player names and titles at the event? -->
- + <HidePlayersIdentity val="true" />
- +
- + <!-- Team ids, colors, names and coordinates. Min. 2 teams -->
- + <Team id="1" name="Green" color="009933" coordinates="-84640,-45360,-10683,-9380" />
- + <Team id="2" name="Blue" color="CC6600" coordinates="-79120,-45440,-10683,-23248" />
- + <Team id="3" name="Red" color="000099" coordinates="-77408,-50656,-10683,29664" />
- + <Team id="4" name="Orange" color="0099FF" coordinates="-81904,-53904,-10683,17044" />
- + <Team id="5" name="Yellow" color="00CCFF" coordinates="-86359,-50593,-10649,3704" />
- +
- + <!-- Reward ID and Count for the players of the winner team. For multiple rewards separate with (,) -->
- + <Rewards id="3470,9627,6673" count="10,1,1" />
- +
- + <!-- Reward all winner teams in case of tie? -->
- + <RewardTeamTie val="true" />
- +
- + <!-- List of buffs given to the players, separate with (,) -->
- + <ListMageSupport val="1078,1085,1303,1517,1518,1519,1535,1536,1537,1538" />
- + <ListFighterSupport val="1499,1500,1501,1502,1503,1504,1517" />
- +
- + <!-- List of the restricted items on the event, separate with (,) -->
- + <!--<RestrictItems val="" />-->
- +
- + <!-- List of the restricted skills on the event, separate with (,) -->
- + <!--<RestrictSkills val="" />-->
- +
- + <!-- Allow player to use potions during the event? -->
- + <AllowPotions val="false" />
- +
- + <!-- Allow player to use scrolls during the event? -->
- + <AllowScrolls val="false" />
- +
- + <!-- Allow player to use summons by items during the event? -->
- + <AllowSummonByItem val="false" />
- +
- + <!-- Allow player to target team members during the event? -->
- + <AllowTargetTeamMembers val="false" />
- +
- + <!-- Require a minimal amount of kills to receive the reward? -->
- + <RequireMinFragsToReward val="true" />
- + <!-- Minimal amount of kills to receive the reward -->
- + <MinFragsRequired val="1" />
- +
- + <!-- In total there are 2 types of TvT: (1) The winning team is determined
- + by number of dead characters rivals. (2) The winning team is determined by number
- + of rounds won. In this case, you must use the <NumberOfRounds val="5"/> number
- + of rounds. Also the "Duration" in this case stands for each round! Do not
- + use together! -->
- + <NumberOfRounds val="1" />
- +</tvt>
- \ No newline at end of file
- diff --git a/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/actor/Player.java b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/actor/Player.java
- index c0e585c..e2069af 100644
- --- a/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/actor/Player.java
- +++ b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/actor/Player.java
- @@ -133,6 +133,7 @@
- import net.sf.l2j.gameserver.model.craft.ManufactureList;
- import net.sf.l2j.gameserver.model.entity.Castle;
- import net.sf.l2j.gameserver.model.entity.Duel.DuelState;
- +import net.sf.l2j.gameserver.model.gameevent.GameEvent;
- import net.sf.l2j.gameserver.model.group.CommandChannel;
- import net.sf.l2j.gameserver.model.group.Party;
- import net.sf.l2j.gameserver.model.group.PartyMatchRoom;
- @@ -463,6 +464,7 @@
- private final int[] _loto = new int[5];
- private final int[] _race = new int[2];
- + private GameEvent _event;
- private TeamType _team = TeamType.NONE;
- private int _alliedVarkaKetra; // lvl of alliance with ketra orcs or varka silenos, used in quests and aggro checks [-5,-1] varka, 0 neutral, [1,5] ketra
- @@ -2747,6 +2749,9 @@
- stopFakeDeath(true);
- }
- + if (getEvent() != null)
- + getEvent().onKill(killer, this);
- +
- if (killer != null)
- {
- final Player pk = killer.getActingPlayer();
- @@ -6085,6 +6090,22 @@
- return _lvlJoinedAcademy > 0;
- }
- + public void setEvent(GameEvent event)
- + {
- + _event = event;
- + }
- +
- + public GameEvent getEvent()
- + {
- + return _event;
- + }
- +
- + public boolean isInEvent()
- + {
- + final GameEvent event = getEvent();
- + return (event != null) && (event.isRunning() && event.isParticipant(getObjectId()));
- + }
- +
- public void setTeam(TeamType team)
- {
- _team = team;
- diff --git a/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/GameEvent.java b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/GameEvent.java
- new file mode 100644
- index 0000000..74b7153
- --- /dev/null
- +++ b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/GameEvent.java
- @@ -0,0 +1,499 @@
- +package net.sf.l2j.gameserver.model.gameevent;
- +
- +import java.util.Collection;
- +
- +import net.sf.l2j.commons.logging.CLogger;
- +import net.sf.l2j.commons.random.Rnd;
- +
- +import net.sf.l2j.gameserver.data.SkillTable;
- +import net.sf.l2j.gameserver.data.xml.DoorData;
- +import net.sf.l2j.gameserver.data.xml.ItemData;
- +import net.sf.l2j.gameserver.model.actor.Creature;
- +import net.sf.l2j.gameserver.model.actor.Npc;
- +import net.sf.l2j.gameserver.model.actor.Player;
- +import net.sf.l2j.gameserver.model.actor.instance.Door;
- +import net.sf.l2j.gameserver.model.gameevent.config.GameEventConfig;
- +import net.sf.l2j.gameserver.model.item.instance.ItemInstance;
- +import net.sf.l2j.gameserver.model.olympiad.OlympiadManager;
- +import net.sf.l2j.gameserver.network.SystemMessageId;
- +import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
- +import net.sf.l2j.gameserver.skills.L2Skill;
- +
- +public abstract class GameEvent
- +{
- + protected static final CLogger LOGGER = new CLogger(GameEvent.class.getName());
- +
- + public enum EventState
- + {
- + INACTIVE,
- + REGISTER,
- + STARTED,
- + REWARDING
- + }
- +
- + private EventState _state = EventState.INACTIVE;
- + protected String _eventName = "";
- +
- + public abstract GameEventConfig getConfigs();
- + public abstract void init();
- + protected abstract String calculateRewards();
- + protected abstract void teleportPlayersToArena();
- + protected abstract void teleportPlayersBack();
- + protected abstract void clear();
- + public abstract boolean isParticipant(int objectId);
- + public abstract int getCountPlayers();
- + public abstract boolean addParticipant(GameEventPlayer eventPlayer);
- + public abstract boolean removeParticipant(Player player);
- +
- + public abstract void sysMsgToAllParticipants(String message);
- +
- + public abstract void onKill(Creature killerCharacter, Player killedplayer);
- +
- + public abstract boolean onSkillUse(Player caster, L2Skill skill);
- +
- + public abstract void onLogin(Player player);
- +
- + public abstract boolean onAction(Player player, int targetObjectId);
- +
- + /**
- + * Gets the Game Event state
- + * @return EventState: _state
- + */
- + public EventState getState()
- + {
- + synchronized (_state)
- + {
- + return _state;
- + }
- + }
- +
- + /**
- + * Sets the Game Event state
- + * @param state as EventState
- + */
- + protected void setState(EventState state)
- + {
- + synchronized (_state)
- + {
- + _state = state;
- + }
- + }
- +
- + public String getName()
- + {
- + return _eventName;
- + }
- +
- + public boolean isInactive()
- + {
- + return getState() == EventState.INACTIVE;
- + }
- +
- + public boolean isRunning()
- + {
- + return getState() == EventState.STARTED;
- + }
- +
- + public boolean isRegistrating()
- + {
- + return getState() == EventState.REGISTER;
- + }
- +
- + /**
- + * Method called to check if a player can register at the event
- + * @param player as Player
- + * @param first as Integer
- + * @return boolean: true if the player can register, otherwise false
- + */
- + protected boolean canRegister(Player player, boolean first)
- + {
- + if (first && getConfigs().ALLOW_TAKE_ITEM)
- + {
- + if (player.getInventory().getItemCount(getConfigs().TAKE_ITEM_ID, -1) < getConfigs().TAKE_COUNT)
- + {
- + player.sendMessage("You don't have enough " + ItemData.getInstance().getTemplate(getConfigs().TAKE_ITEM_ID).getName() + " to participate.");
- + return false;
- + }
- + }
- +
- + if (first && !isRegistrating())
- + {
- + player.sendMessage("The registration process is not active.");
- + return false;
- + }
- +
- + if (first && isParticipant(player.getObjectId()))
- + {
- + player.sendMessage("You are already registred.");
- + return false;
- + }
- +
- + if (player.isTeleporting())
- + {
- + player.sendMessage("You are in a teleporting process.");
- + return false;
- + }
- +
- + if (!player.isOnline())
- + {
- + player.sendMessage("You have to be online to register.");
- + return false;
- + }
- +
- + if (player.isMounted())
- + {
- + player.sendMessage("Revoke your pet before register.");
- + return false;
- + }
- +
- + if (player.isInDuel())
- + {
- + player.sendMessage("You must complete the duel before register.");
- + return false;
- + }
- +
- + if (first && (player.getEvent() != null))
- + {
- + player.sendMessage("You are already registered in another event.");
- + return false;
- + }
- +
- + if (player.isInOlympiadMode() || OlympiadManager.getInstance().isRegistered(player))
- + {
- + player.sendMessage("You are already registered in the Olympics.");
- + return false;
- + }
- +
- + if (player.isInParty() && player.getParty().isInDimensionalRift())
- + {
- + player.sendMessage("You are already registered in another event.");
- + return false;
- + }
- +
- + if (player.isCursedWeaponEquipped())
- + {
- + player.sendMessage("You can't register to the event with a cursed weapon.");
- + return false;
- + }
- +
- + if (player.isDead())
- + {
- + player.sendMessage("You can't register while you are dead.");
- + return false;
- + }
- +
- + if (player.getKarma() > 0)
- + {
- + player.sendMessage("PK's can't participate in the opening event.");
- + return false;
- + }
- +
- + if ((player.getStatus().getLevel() < getConfigs().MIN_LEVEL) || (player.getStatus().getLevel() > getConfigs().MAX_LEVEL))
- + {
- + player.sendMessage("You are not eligible to participate in the opening event with this level.");
- + return false;
- + }
- +
- + if (first && (getCountPlayers() >= getConfigs().MAX_PARTICIPANTS))
- + {
- + player.sendMessage("The opening event has reached the maximum number of participants.");
- + return false;
- + }
- +
- + return true;
- + }
- +
- + /**
- + * Method called to start the event registration process
- + */
- + public void startRegistration()
- + {
- + setState(EventState.REGISTER);
- + }
- +
- + /**
- + * Method called to register a player in the event
- + * @param player as Player
- + * @return boolean: true if success, otherwise false
- + */
- + public boolean register(Player player)
- + {
- + if (player == null)
- + return false;
- +
- + if (!canRegister(player, true))
- + return false;
- +
- + final GameEventPlayer eventPlayer = new GameEventPlayer(player, getConfigs().PLAYER_CREDITS);
- +
- + if (getConfigs().ALLOW_TAKE_ITEM)
- + {
- + if (player.destroyItemByItemId("Event Participation Fee", getConfigs().TAKE_ITEM_ID, getConfigs().TAKE_COUNT, null, true))
- + {
- + if (addParticipant(eventPlayer))
- + return true;
- + }
- + }
- +
- + if (addParticipant(eventPlayer))
- + return true;
- +
- + return false;
- + }
- +
- + /**
- + * Method called to remove the player registration in the event
- + * @param player as Player
- + * @return boolean: true if success, otherwise false
- + */
- + public boolean unRegister(Player player)
- + {
- + if (player == null)
- + return false;
- +
- + if ((getState() == EventState.STARTED) || !isParticipant(player.getObjectId()))
- + {
- + player.sendMessage("You can't cancel your registration to the event at this moment!");
- + return false;
- + }
- +
- + if (removeParticipant(player))
- + {
- + player.sendMessage("Your registration at the " + _eventName + " Event was cancelled!");
- + return true;
- + }
- +
- + return false;
- + }
- +
- + /**
- + * Method called to start the event
- + * @return boolean: true if success, otherwise false
- + */
- + public boolean start()
- + {
- + if (getCountPlayers() >= getConfigs().MIN_PARTICIPANTS)
- + {
- + setState(EventState.STARTED);
- + closeDoors();
- + teleportPlayersToArena();
- + return true;
- + }
- + clear();
- + setState(EventState.INACTIVE);
- + return false;
- + }
- +
- + /**
- + * Method called to stop the running event
- + */
- + public void stop()
- + {
- + openDoors();
- + teleportPlayersBack();
- + clear();
- + setState(EventState.INACTIVE);
- + }
- +
- + /**
- + * Method used to close the instance door(s)
- + */
- + protected void closeDoors()
- + {
- + Collection<Door> doorsToClose = DoorData.getInstance().getDoors();
- +
- + for (Door door : doorsToClose)
- + {
- + if (door != null)
- + door.closeMe();
- + }
- + }
- +
- + /**
- + * Method used to open the instance door(s)
- + */
- + protected void openDoors()
- + {
- + Collection<Door> doorsToOpen = DoorData.getInstance().getDoors();
- +
- + for (Door door : doorsToOpen)
- + {
- + if (door != null)
- + door.openMe();
- + }
- + }
- +
- + /**
- + * Method called to put the kill rewards into the players inventory
- + * @param player as Player
- + */
- + protected void giveKillBonus(Player player)
- + {
- + SystemMessage systemMessage = null;
- +
- + player.addItem(_eventName, getConfigs().TAKE_ITEM_ID, getConfigs().TAKE_COUNT, player, true);
- +
- + if (getConfigs().TAKE_COUNT > 1)
- + {
- + systemMessage = SystemMessage.getSystemMessage(SystemMessageId.EARNED_S2_S1_S);
- + systemMessage.addItemName(getConfigs().TAKE_ITEM_ID);
- + systemMessage.addItemNumber(getConfigs().TAKE_COUNT);
- + }
- + else
- + {
- + systemMessage = SystemMessage.getSystemMessage(SystemMessageId.EARNED_ITEM_S1);
- + systemMessage.addItemName(getConfigs().TAKE_ITEM_ID);
- + }
- +
- + player.sendPacket(systemMessage);
- + }
- +
- + /**
- + * Method called to put the rewards into the players inventory
- + * @param player as Player
- + * @param rewards as Integer
- + */
- + protected void deliverRewards(Player player, int[][] rewards)
- + {
- + SystemMessage systemMessage = null;
- +
- + for (int[] reward : rewards)
- + {
- + player.getInventory().addItem(_eventName, reward[0], reward[1], player, player);
- +
- + if (reward[1] > 1)
- + {
- + systemMessage = SystemMessage.getSystemMessage(SystemMessageId.EARNED_S2_S1_S);
- + systemMessage.addItemName(reward[0]);
- + systemMessage.addItemNumber(reward[1]);
- + }
- + else
- + {
- + systemMessage = SystemMessage.getSystemMessage(SystemMessageId.EARNED_ITEM_S1);
- + systemMessage.addItemName(reward[0]);
- + }
- +
- + player.sendPacket(systemMessage);
- + }
- + }
- +
- + /**
- + * Method called on Appearing packet received (player finished teleporting)<br>
- + * Buff player's with event buffs
- + * @param player
- + */
- + public void onTeleported(Player player)
- + {
- + if (!isRunning() || (player == null) || !isParticipant(player.getObjectId()))
- + return;
- +
- + if ((getConfigs().LIST_MAGE_SUPPORT != null) && (getConfigs().LIST_MAGE_SUPPORT.length != 0) || (getConfigs().LIST_FIGHTER_SUPPORT != null) && (getConfigs().LIST_FIGHTER_SUPPORT.length != 0))
- + {
- + for (Integer skillId : player.isMageClass() ? getConfigs().LIST_MAGE_SUPPORT : getConfigs().LIST_FIGHTER_SUPPORT)
- + {
- + final L2Skill skill = SkillTable.getInstance().getInfo(skillId, SkillTable.getInstance().getMaxLevel(skillId));
- + if (skill != null)
- + skill.getEffects(player, player);
- + }
- + }
- + }
- +
- + /**
- + * Called when a player logs out
- + * @param player as Player
- + */
- + public void onLogout(Player player)
- + {
- + if ((player != null) && (isRunning() || isRegistrating()))
- + {
- + if (removeParticipant(player))
- + player.setXYZInvisible((83447 + Rnd.get(101)) - 50, (148638 + Rnd.get(101)) - 50, -3400); // Giran
- + }
- + }
- +
- + /**
- + * Method called on every summon item use
- + * @param objectId as Integer
- + * @return boolean: true if player is allowed to summon by item, otherwise false
- + */
- + public boolean onItemSummon(int objectId)
- + {
- + if (isRunning() && isParticipant(objectId) && !getConfigs().ALLOW_SUMMON_BY_ITEM)
- + return false;
- +
- + return true;
- + }
- +
- + /**
- + * Method called on every Scroll use
- + * @param objectId as Integer
- + * @return boolean: true if player is allowed to use scroll, otherwise false
- + */
- + public boolean onScrollUse(int objectId)
- + {
- + if (isRunning() && isParticipant(objectId) && !getConfigs().ALLOW_SCROLLS)
- + return false;
- +
- + return true;
- + }
- +
- + /**
- + * Method called on every Potion use
- + * @param objectId as Integer
- + * @return boolean: true if player is allowed to use potion, otherwise false
- + */
- + public boolean onPotionUse(int objectId)
- + {
- + if (isRunning() && isParticipant(objectId) && !getConfigs().ALLOW_POTIONS)
- + return false;
- +
- + return true;
- + }
- +
- + /**
- + * Method called on every Escape use
- + * @param objectId as Integer
- + * @return boolean: true if player is allowed to use escape, otherwise false
- + */
- + public boolean onEscapeUse(int objectId)
- + {
- + if (isRunning() && isParticipant(objectId))
- + return false;
- +
- + return true;
- + }
- +
- + /**
- + * Method called on every Item use
- + * @param actor as Player
- + * @param item as ItemInstance
- + * @return boolean: true if the player is allowed to use the item, otherwise false
- + */
- + public boolean onItemUse(Player actor, ItemInstance item)
- + {
- + if (!isRunning() || !isParticipant(actor.getObjectId()))
- + return true;
- +
- + if ((getConfigs().RESTRICT_ITEMS != null) && (getConfigs().RESTRICT_ITEMS.length != 0))
- + {
- + for (int itemId : getConfigs().RESTRICT_ITEMS)
- + {
- + if (item.getItemId() == itemId)
- + return false;
- + }
- + }
- +
- + return true;
- + }
- +
- + /**
- + * Method called when a player interact with an event npc
- + * @param player as Player
- + * @param npc as Npc
- + * @return boolean: true if implemented by the event, otherwise false
- + */
- + public boolean onInteract(Player player, Npc npc)
- + {
- + return false;
- + }
- +}
- \ No newline at end of file
- diff --git a/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/GameEventManager.java b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/GameEventManager.java
- new file mode 100644
- index 0000000..51f7689
- --- /dev/null
- +++ b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/GameEventManager.java
- @@ -0,0 +1,246 @@
- +package net.sf.l2j.gameserver.model.gameevent;
- +
- +import java.util.Calendar;
- +import java.util.HashMap;
- +import java.util.Map;
- +import java.util.concurrent.ScheduledFuture;
- +
- +import net.sf.l2j.commons.logging.CLogger;
- +import net.sf.l2j.commons.pool.ThreadPool;
- +
- +import net.sf.l2j.gameserver.model.World;
- +
- +public class GameEventManager
- +{
- + protected static final CLogger LOGGER = new CLogger(GameEventManager.class.getName());
- +
- + private final Map<String, GameEvent> _events;
- + private GameEvent _event;
- + private GameEventStartTask task;
- + private String _currentEventName = "-";
- + private String _nextEventInfo = "-";
- +
- + public GameEventManager()
- + {
- + _events = new HashMap<>();
- + _event = null;
- + }
- +
- + public void registerEvent(GameEvent gameEvent)
- + {
- + _events.put(gameEvent.getName(), gameEvent);
- + LOGGER.info("Game Event Engine - Event registered: " + gameEvent.getName());
- + }
- +
- + public GameEvent getEvent()
- + {
- + return _event;
- + }
- +
- + public void startRegistration()
- + {
- + _currentEventName = getEvent().getName();
- + _nextEventInfo = "-";
- + getEvent().startRegistration();
- + World.announceToOnlinePlayers(getEvent().getName() + " Event: Registration opened for " + getEvent().getConfigs().REGISTRATION_TIME + " minute(s). Type .join to register!", true);
- + task.setStartTime(System.currentTimeMillis() + (60000L * getEvent().getConfigs().REGISTRATION_TIME));
- + ThreadPool.execute(task);
- + }
- +
- + public void startEvent()
- + {
- + if (!getEvent().start())
- + {
- + World.announceToOnlinePlayers(getEvent().getName() + " Event: Event cancelled due to lack of Participation.", true);
- + scheduleNextEvent();
- + _currentEventName = "-";
- + }
- + else
- + {
- + getEvent().sysMsgToAllParticipants(getEvent().getName() + " Event: Teleporting participants to an arena in " + getEvent().getConfigs().TELEPORT_TIME + " second(s).");
- + task.setStartTime(System.currentTimeMillis() + (60000L * getEvent().getConfigs().EVENT_DURATION_TIME));
- + ThreadPool.execute(task);
- + }
- + }
- +
- + public void endEvent()
- + {
- + World.announceToOnlinePlayers(getEvent().getName() + " Event: " + getEvent().calculateRewards(), true);
- + getEvent().sysMsgToAllParticipants(getEvent().getName() + " Event: Teleporting back in " + getEvent().getConfigs().TELEPORT_TIME + " second(s).");
- + getEvent().stop();
- + scheduleNextEvent();
- + _currentEventName = "-";
- + }
- +
- + public Calendar nextEventStartTime(GameEvent gameEvent)
- + {
- + Calendar currentTime = Calendar.getInstance();
- + Calendar nextStartTime = null;
- +
- + if (gameEvent.getConfigs().EVENT_INTERVAL != null)
- + {
- + for (String timeOfDay : gameEvent.getConfigs().EVENT_INTERVAL)
- + {
- + Calendar testStartTime = Calendar.getInstance();
- + testStartTime.setLenient(true);
- +
- + String[] splitTimeOfDay = timeOfDay.split(":");
- + testStartTime.set(Calendar.HOUR_OF_DAY, Integer.parseInt(splitTimeOfDay[0]));
- + testStartTime.set(Calendar.MINUTE, Integer.parseInt(splitTimeOfDay[1]));
- +
- + if (testStartTime.getTimeInMillis() < currentTime.getTimeInMillis())
- + testStartTime.add(Calendar.DAY_OF_MONTH, 1);
- +
- + if ((nextStartTime == null) || (testStartTime.getTimeInMillis() < nextStartTime.getTimeInMillis()))
- + nextStartTime = testStartTime;
- + }
- + }
- + return nextStartTime;
- + }
- +
- + public void scheduleNextEvent()
- + {
- + if ((_events != null) && !_events.isEmpty())
- + {
- + Calendar nextStartTime = null;
- +
- + for (GameEvent gameEvent : _events.values())
- + {
- + final Calendar tempNextStartTime = nextEventStartTime(gameEvent);
- + if (tempNextStartTime == null)
- + continue;
- +
- + if (nextStartTime == null)
- + {
- + nextStartTime = tempNextStartTime;
- + _event = gameEvent;
- + }
- + else
- + {
- + if (tempNextStartTime.getTimeInMillis() < nextStartTime.getTimeInMillis())
- + {
- + nextStartTime = tempNextStartTime;
- + _event = gameEvent;
- + }
- + }
- + }
- +
- + if (nextStartTime != null)
- + {
- + _nextEventInfo = _event.getName() + " in " + ((nextStartTime.getTimeInMillis() - System.currentTimeMillis()) / 60000L) + " minutes!";
- + task = new GameEventStartTask(nextStartTime.getTimeInMillis());
- + ThreadPool.execute(task);
- + LOGGER.info("Game Event Engine - Next Event: " + _event.getName() + " in " + ((nextStartTime.getTimeInMillis() - System.currentTimeMillis()) / 60000L) + " minutes!");
- + }
- + }
- + }
- +
- + public void skipDelay()
- + {
- + if (task.nextRun.cancel(false))
- + {
- + task.setStartTime(System.currentTimeMillis());
- + ThreadPool.execute(task);
- + }
- + }
- +
- + public String getCurrentEventName()
- + {
- + return _currentEventName;
- + }
- +
- + public String getNextEventInfo()
- + {
- + return _nextEventInfo;
- + }
- +
- + public class GameEventStartTask implements Runnable
- + {
- + private long _startTime;
- + public ScheduledFuture<?> nextRun;
- +
- + public GameEventStartTask(long startTime)
- + {
- + _startTime = startTime;
- + }
- +
- + public void setStartTime(long startTime)
- + {
- + _startTime = startTime;
- + }
- +
- + @Override
- + public void run()
- + {
- + int delay = (int) Math.round((_startTime - System.currentTimeMillis()) / 1000.0);
- +
- + if (delay > 0)
- + announce(delay);
- +
- + int nextMsg = 0;
- + if (delay > 3600)
- + nextMsg = delay - 3600;
- + else if (delay > 1800)
- + nextMsg = delay - 1800;
- + else if (delay > 900)
- + nextMsg = delay - 900;
- + else if (delay > 600)
- + nextMsg = delay - 600;
- + else if (delay > 300)
- + nextMsg = delay - 300;
- + else if (delay > 60)
- + nextMsg = delay - 60;
- + else if (delay > 5)
- + nextMsg = delay - 5;
- + else if (delay > 0)
- + nextMsg = delay;
- + else
- + {
- + if (getEvent().isInactive())
- + startRegistration();
- + else if (getEvent().isRegistrating())
- + startEvent();
- + else
- + endEvent();
- + }
- +
- + if (delay > 0)
- + nextRun = ThreadPool.schedule(this, nextMsg * 1000);
- + }
- +
- + private void announce(long time)
- + {
- + if ((time >= 3600) && ((time % 3600) == 0))
- + {
- + if (getEvent().isRegistrating())
- + World.announceToOnlinePlayers(getEvent().getName() + " Event: " + (time / 60 / 60) + " hour(s) until registration is closed! Type .join to register!", true);
- + else if (getEvent().isRunning())
- + getEvent().sysMsgToAllParticipants(getEvent().getName() + " Event: " + (time / 60 / 60) + " hour(s) until event is finished!");
- + }
- + else if (time >= 60)
- + {
- + if (getEvent().isRegistrating())
- + World.announceToOnlinePlayers(getEvent().getName() + " Event: " + (time / 60) + " minute(s) until registration is closed! Type .join to register!", true);
- + else if (getEvent().isRunning())
- + getEvent().sysMsgToAllParticipants(getEvent().getName() + " Event: " + (time / 60) + " minute(s) until the event is finished!");
- + }
- + else
- + {
- + if (getEvent().isRegistrating())
- + World.announceToOnlinePlayers(getEvent().getName() + " Event: " + time + " second(s) until registration is closed! Type .join to register!", true);
- + else if (getEvent().isRunning())
- + getEvent().sysMsgToAllParticipants(getEvent().getName() + " Event: " + time + " second(s) until the event is finished!");
- + }
- + }
- + }
- +
- + public static GameEventManager getInstance()
- + {
- + return SingletonHolder.INSTANCE;
- + }
- +
- + private static class SingletonHolder
- + {
- + protected static final GameEventManager INSTANCE = new GameEventManager();
- + }
- +}
- \ No newline at end of file
- diff --git a/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/GameEventPlayer.java b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/GameEventPlayer.java
- new file mode 100644
- index 0000000..c20a952
- --- /dev/null
- +++ b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/GameEventPlayer.java
- @@ -0,0 +1,109 @@
- +package net.sf.l2j.gameserver.model.gameevent;
- +
- +import net.sf.l2j.gameserver.model.actor.Player;
- +
- +public class GameEventPlayer implements Comparable<GameEventPlayer>
- +{
- + private Player _player;
- + private int _kills;
- + private int _deaths;
- + private int _credits;
- + private int _originalNameColor;
- + private int _originalTitleColor;
- + private int[] _originalCoordinates;
- +
- + public GameEventPlayer(Player player, int playerCredits)
- + {
- + _player = player;
- + _kills = 0;
- + _deaths = 0;
- + _credits = playerCredits;
- + }
- +
- + public Player getPlayer()
- + {
- + return _player;
- + }
- +
- + public void setPlayer(Player player)
- + {
- + _player = player;
- + }
- +
- + public int getKills()
- + {
- + return _kills;
- + }
- +
- + public void increaseKills()
- + {
- + ++_kills;
- + }
- +
- + public int getDeaths()
- + {
- + return _deaths;
- + }
- +
- + public int getCredits()
- + {
- + return _credits;
- + }
- +
- + public void increaseDeaths()
- + {
- + ++_deaths;
- + }
- +
- + public void decreaseCredits()
- + {
- + --_credits;
- + }
- +
- + public int getOriginalNameColor()
- + {
- + return _originalNameColor;
- + }
- +
- + public int getOriginalTitleColor()
- + {
- + return _originalTitleColor;
- + }
- +
- + public void setOriginalNameColor(int originalNameColor)
- + {
- + _originalNameColor = originalNameColor;
- + }
- +
- + public void setOriginalTitleColor(int originalTitleColor)
- + {
- + _originalTitleColor = originalTitleColor;
- + }
- +
- + public int[] getOriginalCoordinates()
- + {
- + return _originalCoordinates;
- + }
- +
- + public void setOriginalCoordinates(int[] originalCoordinates)
- + {
- + _originalCoordinates = originalCoordinates;
- + }
- +
- + @Override
- + public int compareTo(GameEventPlayer anotherEventPlayer)
- + {
- + Integer c1 = Integer.valueOf(anotherEventPlayer.getKills() - getKills());
- + Integer c2 = Integer.valueOf(getDeaths() - anotherEventPlayer.getDeaths());
- + Integer c3 = getPlayer().getName().compareTo(anotherEventPlayer.getPlayer().getName());
- +
- + if (c1 == 0)
- + {
- + if (c2 == 0)
- + return c3;
- +
- + return c2;
- + }
- + return c1;
- + }
- +}
- \ No newline at end of file
- diff --git a/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/GameEventTeam.java b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/GameEventTeam.java
- new file mode 100644
- index 0000000..8eec94f
- --- /dev/null
- +++ b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/GameEventTeam.java
- @@ -0,0 +1,95 @@
- +package net.sf.l2j.gameserver.model.gameevent;
- +
- +import java.util.Map;
- +import java.util.concurrent.ConcurrentHashMap;
- +
- +public class GameEventTeam
- +{
- + private final int _id;
- + private final String _name;
- + private final int _color;
- + private final int[] _coordinates;
- + private int _points;
- + private final Map<Integer, GameEventPlayer> _participatedPlayers;
- +
- + public GameEventTeam(int id, String name, int color, int[] coordinates)
- + {
- + _id = id;
- + _name = name;
- + _color = color;
- + _coordinates = coordinates;
- + _points = 0;
- + _participatedPlayers = new ConcurrentHashMap<>();
- + }
- +
- + public boolean addPlayer(GameEventPlayer eventPlayer)
- + {
- + if (eventPlayer == null)
- + return false;
- +
- + _participatedPlayers.put(eventPlayer.getPlayer().getObjectId(), eventPlayer);
- +
- + return true;
- + }
- +
- + public void removePlayer(int objectId)
- + {
- + _participatedPlayers.remove(objectId);
- + }
- +
- + public void increasePoints()
- + {
- + ++_points;
- + }
- +
- + public void cleanMe()
- + {
- + _participatedPlayers.clear();
- + _points = 0;
- + }
- +
- + public boolean containsPlayer(int objectId)
- + {
- + return _participatedPlayers.containsKey(objectId);
- + }
- +
- + public int getId()
- + {
- + return _id;
- + }
- +
- + public String getName()
- + {
- + return _name;
- + }
- +
- + public int getColor()
- + {
- + return _color;
- + }
- +
- + public int[] getCoordinates()
- + {
- + return _coordinates;
- + }
- +
- + public int getPoints()
- + {
- + return _points;
- + }
- +
- + public Map<Integer, GameEventPlayer> getParticipatedPlayers()
- + {
- + return _participatedPlayers;
- + }
- +
- + public int getParticipatedPlayerCount()
- + {
- + return _participatedPlayers.size();
- + }
- +
- + public GameEventPlayer getEventPlayer(int objectId)
- + {
- + return _participatedPlayers.get(objectId);
- + }
- +}
- \ No newline at end of file
- diff --git a/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/GameEventTeleporter.java b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/GameEventTeleporter.java
- new file mode 100644
- index 0000000..4c66e71
- --- /dev/null
- +++ b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/GameEventTeleporter.java
- @@ -0,0 +1,107 @@
- +package net.sf.l2j.gameserver.model.gameevent;
- +
- +import net.sf.l2j.commons.pool.ThreadPool;
- +import net.sf.l2j.commons.random.Rnd;
- +
- +import net.sf.l2j.gameserver.enums.MessageType;
- +import net.sf.l2j.gameserver.enums.TeamType;
- +import net.sf.l2j.gameserver.model.actor.Player;
- +import net.sf.l2j.gameserver.model.actor.Summon;
- +import net.sf.l2j.gameserver.model.entity.Duel.DuelState;
- +import net.sf.l2j.gameserver.model.group.Party;
- +
- +public class GameEventTeleporter implements Runnable
- +{
- + private GameEventPlayer _eventPlayer = null;
- + private GameEvent _event = null;
- + private int[] _coordinates = new int[3];
- +
- + public GameEventTeleporter(GameEventPlayer eventPlayer, int[] coordinates, boolean fastSchedule)
- + {
- + _eventPlayer = eventPlayer;
- + _event = eventPlayer.getPlayer().getEvent();
- + _coordinates = coordinates;
- + ThreadPool.schedule(this, fastSchedule ? 0 : _event.getConfigs().TELEPORT_TIME * 1000);
- + }
- +
- + @Override
- + public void run()
- + {
- + if ((_eventPlayer == null) || (_event == null))
- + return;
- +
- + final Player player = _eventPlayer.getPlayer();
- + if (player == null)
- + return;
- +
- + final Summon summon = player.getSummon();
- + if (summon != null)
- + summon.unSummon(player);
- +
- + if (_event.getConfigs().STOP_ALL_EFFECTS == true)
- + player.stopAllEffectsExceptThoseThatLastThroughDeath();
- +
- + if (player.isInParty())
- + {
- + final Party party = player.getParty();
- + party.removePartyMember(player, MessageType.EXPELLED);
- + }
- +
- + if (player.isInDuel())
- + player.setDuelState(DuelState.INTERRUPTED);
- +
- + player.doRevive();
- +
- + player.teleportTo((_coordinates[0] + Rnd.get(101)) - 50, (_coordinates[1] + Rnd.get(101)) - 50, _coordinates[2], 0);
- +
- + if (_event.isRunning())
- + {
- + _eventPlayer.setOriginalNameColor(player.getAppearance().getNameColor());
- + _eventPlayer.setOriginalTitleColor(player.getAppearance().getTitleColor());
- +
- + if (_event instanceof TeamGameEvent)
- + {
- + TeamGameEvent teamGameEvent = (TeamGameEvent) _event;
- +
- + final GameEventTeam team = teamGameEvent.getParticipantTeam(player.getObjectId());
- + if (team != null)
- + {
- + if (teamGameEvent.getConfigs().TEAMS.size() <= 2)
- + player.setTeam(team.getId() == 1 ? TeamType.BLUE : TeamType.RED);
- + else
- + player.getAppearance().setNameColor(team.getColor());
- + }
- + }
- + else if (_event instanceof IndividualGameEvent)
- + player.setTeam(TeamType.BLUE);
- +
- + if (_event.getConfigs().HIDE_PLAYERS_IDENTITY)
- + player.getAppearance().setTitleColor(Integer.decode("0x" + "333333"));
- +
- + player.doRevive();
- + }
- + else
- + {
- + if (_event instanceof TeamGameEvent)
- + {
- + TeamGameEvent teamGameEvent = (TeamGameEvent) _event;
- +
- + if (teamGameEvent.getConfigs().TEAMS.size() <= 2)
- + player.setTeam(TeamType.NONE);
- + else
- + player.getAppearance().setNameColor(_eventPlayer.getOriginalNameColor());
- + }
- + else if (_event instanceof IndividualGameEvent)
- + player.setTeam(TeamType.NONE);
- +
- + if (_event.getConfigs().HIDE_PLAYERS_IDENTITY)
- + player.getAppearance().setTitleColor(_eventPlayer.getOriginalTitleColor());
- +
- + player.doRevive();
- + player.setEvent(null);
- + }
- +
- + player.getStatus().setMaxCpHpMp();
- + player.broadcastUserInfo();
- + }
- +}
- \ No newline at end of file
- diff --git a/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/IndividualGameEvent.java b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/IndividualGameEvent.java
- new file mode 100644
- index 0000000..521dbd5
- --- /dev/null
- +++ b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/IndividualGameEvent.java
- @@ -0,0 +1,245 @@
- +package net.sf.l2j.gameserver.model.gameevent;
- +
- +import java.util.Map;
- +import java.util.TreeSet;
- +
- +import net.sf.l2j.gameserver.enums.SayType;
- +import net.sf.l2j.gameserver.model.actor.Player;
- +import net.sf.l2j.gameserver.model.gameevent.config.IndividualGameEventConfig;
- +import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;
- +import net.sf.l2j.gameserver.skills.L2Skill;
- +
- +public abstract class IndividualGameEvent extends GameEvent
- +{
- + protected Map<Integer, GameEventPlayer> _participants;
- +
- + @Override
- + public abstract IndividualGameEventConfig getConfigs();
- +
- + /**
- + * Method called to verify if a player is participant at the event
- + * @param eventPlayerObjectId as Integer
- + * @return boolean: true if the player is participant, otherwise false
- + */
- + @Override
- + public boolean isParticipant(int eventPlayerObjectId)
- + {
- + return _participants.containsKey(eventPlayerObjectId);
- + }
- +
- + /**
- + * Method that returns the total of the event players
- + * @return Integer playersCount
- + */
- + @Override
- + public int getCountPlayers()
- + {
- + return _participants.size();
- + }
- +
- + /**
- + * Add a GameEvent player to a team
- + * @param eventPlayer as GameEventPlayer
- + * @return boolean: true if success, otherwise false
- + */
- + @Override
- + public boolean addParticipant(GameEventPlayer eventPlayer)
- + {
- + if (_participants.containsKey(eventPlayer.getPlayer().getObjectId()))
- + return false;
- +
- + _participants.put(eventPlayer.getPlayer().getObjectId(), eventPlayer);
- + eventPlayer.getPlayer().setEvent(this);
- +
- + return true;
- + }
- +
- + /**
- + * Removes a GameEvent player from it's team
- + * @param player as Player
- + * @return boolean: true if success, otherwise false
- + */
- + @Override
- + public boolean removeParticipant(Player player)
- + {
- + if (!_participants.containsKey(player.getObjectId()))
- + return false;
- +
- + _participants.remove(player.getObjectId());
- + player.setEvent(null);
- +
- + return true;
- + }
- +
- + /**
- + * Method called to teleport players to the arena
- + */
- + @Override
- + public void teleportPlayersToArena()
- + {
- + for (GameEventPlayer eventPlayer : _participants.values())
- + {
- + if ((eventPlayer != null) && (eventPlayer.getPlayer() != null))
- + {
- + int[] playerCoordinates = new int[]
- + {
- + eventPlayer.getPlayer().getX(),
- + eventPlayer.getPlayer().getY(),
- + eventPlayer.getPlayer().getZ(),
- + };
- + eventPlayer.setOriginalCoordinates(playerCoordinates);
- + new GameEventTeleporter(eventPlayer, getConfigs().EVENT_COORDINATES, false);
- + }
- + }
- + }
- +
- + /**
- + * Method called to teleport players back
- + */
- + @Override
- + public void teleportPlayersBack()
- + {
- + for (GameEventPlayer eventPlayer : _participants.values())
- + {
- + if ((eventPlayer != null) && (eventPlayer.getPlayer() != null))
- + new GameEventTeleporter(eventPlayer, eventPlayer.getOriginalCoordinates(), false);
- + }
- + }
- +
- + /**
- + * Method used to send messages to all the event participants
- + * @param message as String
- + */
- + @Override
- + public void sysMsgToAllParticipants(String message)
- + {
- + for (GameEventPlayer eventPlayer : _participants.values())
- + {
- + if ((eventPlayer != null) && (eventPlayer.getPlayer() != null))
- + eventPlayer.getPlayer().sendPacket(new CreatureSay(SayType.CRITICAL_ANNOUNCE, _eventName, message));
- + }
- + }
- +
- + /**
- + * Method called to get the informations about the 1st position player
- + * @param countPos as Integer
- + * @return String: player informations
- + */
- + public String[] getFirstPosition(int countPos)
- + {
- + TreeSet<GameEventPlayer> players = new TreeSet<>();
- + players.addAll(_participants.values());
- +
- + String text = "";
- +
- + for (int i = 0; i < countPos; i++)
- + {
- + if (players.isEmpty())
- + break;
- +
- + GameEventPlayer player = players.first();
- + if (player.getKills() == 0)
- + break;
- +
- + text = player.getPlayer().getName() + "," + String.valueOf(player.getKills()) + ";";
- + players.remove(player);
- +
- + int playerPointPrev = player.getKills();
- +
- + if (!getConfigs().REWARD_EVENT_TIE)
- + continue;
- +
- + while (!players.isEmpty())
- + {
- + player = players.first();
- + if (player.getKills() != playerPointPrev)
- + break;
- +
- + text = player.getPlayer().getName() + "," + String.valueOf(player.getKills()) + ";";
- + players.remove(player);
- + }
- + }
- +
- + if (text != "")
- + return text.split("\\;");
- +
- + return null;
- + }
- +
- + /**
- + * Method called on every Skill use
- + * @param caster as Player
- + * @param skill as L2Skill
- + * @return boolean: true if the player is allowed to use the skill, otherwise false
- + */
- + @Override
- + public boolean onSkillUse(Player caster, L2Skill skill)
- + {
- + if (!isRunning() || !isParticipant(caster.getObjectId()))
- + return true;
- +
- + if ((getConfigs().RESTRICT_SKILLS != null) && (getConfigs().RESTRICT_SKILLS.length != 0))
- + {
- + for (int skillId : getConfigs().RESTRICT_SKILLS)
- + {
- + if (skillId == skill.getId())
- + return false;
- + }
- + }
- +
- + return true;
- + }
- +
- + /**
- + * Method called on every onAction in L2PcIstance
- + * @param player as Player
- + * @param targetedPlayerObjectId as Integer
- + * @return boolean: true if player is allowed to target, otherwise false
- + */
- + @Override
- + public boolean onAction(Player player, int targetedPlayerObjectId)
- + {
- + if ((player == null) || !isRunning())
- + return true;
- +
- + if (player.isGM())
- + return true;
- +
- + if (!isParticipant(player.getObjectId()) && isParticipant(targetedPlayerObjectId))
- + return false;
- +
- + if (isParticipant(player.getObjectId()) && !isParticipant(targetedPlayerObjectId))
- + return false;
- +
- + return true;
- + }
- +
- + /**
- + * Method called when a player logs in
- + * @param player as Player
- + */
- + @Override
- + public void onLogin(Player player)
- + {
- + if ((player == null) || (!isRunning()))
- + return;
- +
- + if (isParticipant(player.getObjectId()))
- + {
- + final GameEventPlayer eventPlayer = _participants.get(player.getObjectId());
- + if (eventPlayer == null)
- + return;
- +
- + new GameEventTeleporter(eventPlayer, getConfigs().EVENT_COORDINATES, true);
- + }
- + }
- +
- + /**
- + * Method called to clear event attributes
- + */
- + @Override
- + protected void clear()
- + {
- + _participants.clear();
- + }
- +}
- \ No newline at end of file
- diff --git a/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/TeamGameEvent.java b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/TeamGameEvent.java
- new file mode 100644
- index 0000000..87e7cab
- --- /dev/null
- +++ b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/TeamGameEvent.java
- @@ -0,0 +1,360 @@
- +package net.sf.l2j.gameserver.model.gameevent;
- +
- +import java.util.ArrayList;
- +import java.util.List;
- +
- +import net.sf.l2j.gameserver.enums.SayType;
- +import net.sf.l2j.gameserver.model.actor.Player;
- +import net.sf.l2j.gameserver.model.gameevent.config.TeamGameEventConfig;
- +import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;
- +import net.sf.l2j.gameserver.skills.L2Skill;
- +
- +public abstract class TeamGameEvent extends GameEvent
- +{
- + protected GameEventTeam[] _teams;
- + protected int _rounds = 1;
- +
- + @Override
- + public abstract TeamGameEventConfig getConfigs();
- +
- + /**
- + * Method called to verify if a player is participant at the event
- + * @param objectId as Integer
- + * @return boolean: true if the player is participant, otherwise false
- + */
- + @Override
- + public boolean isParticipant(int objectId)
- + {
- + boolean isParticipant = false;
- + for (GameEventTeam team : _teams)
- + {
- + if (team.containsPlayer(objectId))
- + isParticipant = true;
- + }
- + return isParticipant;
- + }
- +
- + /**
- + * Method that returns the total of the event players
- + * @return Integer playersCount
- + */
- + @Override
- + public int getCountPlayers()
- + {
- + int playersCount = 0;
- +
- + for (GameEventTeam team : _teams)
- + playersCount = team.getParticipatedPlayerCount();
- +
- + return playersCount;
- + }
- +
- + /**
- + * Method that returns a list of the event teams
- + * @return GameEventTeam[]: _teams
- + */
- + public GameEventTeam[] getTeams()
- + {
- + return _teams;
- + }
- +
- + /**
- + * Method that returns the team id with less players
- + * @return GameEventTeam team
- + */
- + private GameEventTeam getTeamWithMinPlayers()
- + {
- + GameEventTeam teamWithMinPlayers = null;
- + int playersCount = getConfigs().MAX_PARTICIPANTS;
- +
- + for (GameEventTeam team : _teams)
- + {
- + if (playersCount > team.getParticipatedPlayerCount())
- + {
- + playersCount = team.getParticipatedPlayerCount();
- + teamWithMinPlayers = team;
- + }
- + }
- + return teamWithMinPlayers;
- + }
- +
- + /**
- + * Method used to retrieve the Team of the event player
- + * @param objectId as Integer
- + * @return GameEventTeam participantTeam
- + */
- + public GameEventTeam getParticipantTeam(int objectId)
- + {
- + GameEventTeam participantTeam = null;
- + for (GameEventTeam team : _teams)
- + {
- + if (team.containsPlayer(objectId))
- + participantTeam = team;
- + }
- +
- + return participantTeam;
- + }
- +
- + /**
- + * Add a GameEvent player to a team
- + * @param eventPlayer as GameEventPlayer
- + * @return boolean: true if success, otherwise false
- + */
- + @Override
- + public boolean addParticipant(GameEventPlayer eventPlayer)
- + {
- + if (getTeamWithMinPlayers().addPlayer(eventPlayer))
- + {
- + eventPlayer.getPlayer().setEvent(this);
- + return true;
- + }
- + return false;
- + }
- +
- + /**
- + * Removes a GameEvent player from it's team
- + * @param player as Player
- + * @return boolean: true if success, otherwise false
- + */
- + @Override
- + public boolean removeParticipant(Player player)
- + {
- + final GameEventTeam playerTeam = getParticipantTeam(player.getObjectId());
- + if (playerTeam != null)
- + {
- + playerTeam.removePlayer(player.getObjectId());
- + player.setEvent(null);
- +
- + return true;
- + }
- +
- + return false;
- + }
- +
- + /**
- + * Method called to teleport players to the arena
- + */
- + @Override
- + public void teleportPlayersToArena()
- + {
- + for (GameEventTeam team : _teams)
- + {
- + for (GameEventPlayer eventPlayer : team.getParticipatedPlayers().values())
- + {
- + if ((eventPlayer != null) && (eventPlayer.getPlayer() != null))
- + {
- + int[] playerCoordinates = new int[]
- + {
- + eventPlayer.getPlayer().getX(),
- + eventPlayer.getPlayer().getY(),
- + eventPlayer.getPlayer().getZ(),
- + };
- + eventPlayer.setOriginalCoordinates(playerCoordinates);
- + eventPlayer.getPlayer().doRevive();
- + new GameEventTeleporter(eventPlayer, team.getCoordinates(), false);
- + }
- + }
- + }
- + }
- +
- + /**
- + * Method called to teleport players back
- + */
- + @Override
- + public void teleportPlayersBack()
- + {
- + for (GameEventTeam team : _teams)
- + {
- + for (GameEventPlayer eventPlayer : team.getParticipatedPlayers().values())
- + {
- + if ((eventPlayer != null) && (eventPlayer.getPlayer() != null))
- + new GameEventTeleporter(eventPlayer, eventPlayer.getOriginalCoordinates(), false);
- + }
- + }
- + }
- +
- + /**
- + * Method called to set the winner teams
- + * @return String: msg
- + */
- + @Override
- + public String calculateRewards()
- + {
- + List<GameEventTeam> winners = new ArrayList<>(getConfigs().TEAMS.size());
- + GameEventTeam winnerTeam = null;
- + int maxPoints = 0;
- + String msg = "";
- +
- + for (GameEventTeam team : _teams)
- + {
- + if ((maxPoints == 0) && (team.getPoints() > 0))
- + {
- + maxPoints = team.getPoints();
- + winnerTeam = team;
- + }
- + else if ((team.getPoints() == maxPoints) && (team.getPoints() > 0))
- + {
- + maxPoints = team.getPoints();
- + winners.add(team);
- + winners.add(winnerTeam);
- + winnerTeam = null;
- + }
- + else if ((team.getPoints() > maxPoints))
- + {
- + maxPoints = team.getPoints();
- + winnerTeam = team;
- + winners.clear();
- + }
- + }
- +
- + setState(EventState.REWARDING);
- +
- + if (winnerTeam != null)
- + {
- + reward(winnerTeam);
- + msg = _eventName + ": Event finish. Team " + winnerTeam.getName() + " won with " + winnerTeam.getPoints() + " kills.";
- + }
- + else if (winners.size() >= 2)
- + {
- + if (getConfigs().REWARD_EVENT_TIE)
- + {
- + for (GameEventTeam team : winners)
- + reward(team);
- + }
- + msg = _eventName + ": Event has ended with both teams tying!";
- + }
- + else if (winners.isEmpty())
- + msg = _eventName + ": Event has ended with both teams tying without any points!";
- +
- + winners.clear();
- +
- + return msg;
- + }
- +
- + /**
- + * Method used to reward the winner team(s)
- + * @param team as GameEventTeam
- + */
- + public void reward(GameEventTeam team)
- + {
- + for (GameEventPlayer eventPlayer : team.getParticipatedPlayers().values())
- + {
- + if (eventPlayer == null)
- + continue;
- +
- + final Player player = eventPlayer.getPlayer();
- + if (player == null)
- + continue;
- +
- + if (getConfigs().REQUIRE_MIN_FRAGS_TO_REWARD && (eventPlayer.getKills() < getConfigs().MIN_FRAGS_TO_REWARD))
- + {
- + player.sendMessage("You did not killed enough players at the event to receive the reward!");
- + continue;
- + }
- +
- + if (getConfigs().REWARDS != null)
- + deliverRewards(player, getConfigs().REWARDS);
- + }
- + }
- +
- + /**
- + * Method used to send messages to all the event participants
- + * @param message as String
- + */
- + @Override
- + public void sysMsgToAllParticipants(String message)
- + {
- + for (GameEventTeam team : _teams)
- + {
- + for (GameEventPlayer eventPlayer : team.getParticipatedPlayers().values())
- + {
- + if ((eventPlayer != null) && (eventPlayer.getPlayer() != null))
- + {
- + final CreatureSay cs = new CreatureSay(SayType.CRITICAL_ANNOUNCE, _eventName, message);
- + eventPlayer.getPlayer().sendPacket(cs);
- + }
- + }
- + }
- + }
- +
- + /**
- + * Method called on every Skill use
- + * @param caster as Player
- + * @param skill as L2Skill
- + * @return boolean: true if the player is allowed to use the skill, otherwise false
- + */
- + @Override
- + public boolean onSkillUse(Player caster, L2Skill skill)
- + {
- + if (!isRunning() || !isParticipant(caster.getObjectId()))
- + return true;
- +
- + if ((getConfigs().RESTRICT_SKILLS != null) && (getConfigs().RESTRICT_SKILLS.length != 0))
- + {
- + for (int skillId : getConfigs().RESTRICT_SKILLS)
- + {
- + if (skillId == skill.getId())
- + return false;
- + }
- + }
- + return true;
- + }
- +
- + /**
- + * Method called on every onAction in L2PcIstance
- + * @param player as Player
- + * @param targetedPlayerObjectId as Integer
- + * @return boolean: true if player is allowed to target, otherwise false
- + */
- + @Override
- + public boolean onAction(Player player, int targetedPlayerObjectId)
- + {
- + if ((player == null) || !isRunning())
- + return true;
- +
- + if (player.isGM())
- + return true;
- +
- + GameEventTeam playerTeam = getParticipantTeam(player.getObjectId());
- + GameEventTeam targetedPlayerTeam = getParticipantTeam(targetedPlayerObjectId);
- +
- + if (((playerTeam != null) && (targetedPlayerTeam == null)) || ((playerTeam == null) && (targetedPlayerTeam != null)))
- + return false;
- +
- + if ((playerTeam != null) && (targetedPlayerTeam != null) && (playerTeam == targetedPlayerTeam) && (player.getObjectId() != targetedPlayerObjectId) && !getConfigs().ALLOW_TARGET_TEAM_MEMBERS)
- + return false;
- +
- + return true;
- + }
- +
- + /**
- + * Method called when a player logs in
- + * @param player as Player
- + */
- + @Override
- + public void onLogin(Player player)
- + {
- + if ((player == null) || (!isRunning()))
- + return;
- +
- + final GameEventTeam team = getParticipantTeam(player.getObjectId());
- + if (team == null)
- + return;
- +
- + final GameEventPlayer eventPlayer = team.getEventPlayer(player.getObjectId());
- + if (eventPlayer == null)
- + return;
- +
- + new GameEventTeleporter(eventPlayer, team.getCoordinates(), true);
- + }
- +
- + /**
- + * Method called to clear event attributes
- + */
- + @Override
- + protected void clear()
- + {
- + for (GameEventTeam team : _teams)
- + team.cleanMe();
- + }
- +}
- \ No newline at end of file
- diff --git a/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/config/GameEventConfig.java b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/config/GameEventConfig.java
- new file mode 100644
- index 0000000..3e7eea3
- --- /dev/null
- +++ b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/config/GameEventConfig.java
- @@ -0,0 +1,33 @@
- +package net.sf.l2j.gameserver.model.gameevent.config;
- +
- +public abstract class GameEventConfig
- +{
- + public String[] EVENT_INTERVAL;
- + public byte EVENT_DURATION_TIME = 10;
- + public byte TELEPORT_TIME = 15;
- + public byte REGISTRATION_TIME = 10;
- + public short MIN_PARTICIPANTS = 2;
- + public short MAX_PARTICIPANTS = 10;
- + public byte MIN_LEVEL = 1;
- + public byte MAX_LEVEL = 85;
- + public boolean ALLOW_TAKE_ITEM = false;
- + public short TAKE_ITEM_ID = 0;
- + public int TAKE_COUNT = 0;
- + public boolean ALLOW_KILL_BONUS = false;
- + public short KILL_BONUS_ID = 0;
- + public int KILL_BONUS_COUNT = 0;
- + public boolean STOP_ALL_EFFECTS = true;
- + public int[] LIST_MAGE_SUPPORT;
- + public int[] LIST_FIGHTER_SUPPORT;
- + public int[] RESTRICT_ITEMS;
- + public int[] RESTRICT_SKILLS;
- + public boolean HIDE_PLAYERS_IDENTITY = false;
- + public boolean REWARD_EVENT_TIE = false;
- + public int[][] REWARDS;
- + public boolean ALLOW_POTIONS = false;
- + public boolean ALLOW_SCROLLS = false;
- + public boolean ALLOW_SUMMON_BY_ITEM = false;
- + public boolean REQUIRE_MIN_FRAGS_TO_REWARD = false;
- + public byte MIN_FRAGS_TO_REWARD = 0;
- + public byte PLAYER_CREDITS = 0;
- +}
- \ No newline at end of file
- diff --git a/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/config/IGameEventConfig.java b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/config/IGameEventConfig.java
- new file mode 100644
- index 0000000..ec08693
- --- /dev/null
- +++ b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/config/IGameEventConfig.java
- @@ -0,0 +1,6 @@
- +package net.sf.l2j.gameserver.model.gameevent.config;
- +
- +public interface IGameEventConfig
- +{
- + public void load();
- +}
- \ No newline at end of file
- diff --git a/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/config/IndividualGameEventConfig.java b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/config/IndividualGameEventConfig.java
- new file mode 100644
- index 0000000..3bd4ede
- --- /dev/null
- +++ b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/config/IndividualGameEventConfig.java
- @@ -0,0 +1,6 @@
- +package net.sf.l2j.gameserver.model.gameevent.config;
- +
- +public class IndividualGameEventConfig extends GameEventConfig
- +{
- + public int[] EVENT_COORDINATES;
- +}
- \ No newline at end of file
- diff --git a/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/config/TeamGameEventConfig.java b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/config/TeamGameEventConfig.java
- new file mode 100644
- index 0000000..6bf05e6
- --- /dev/null
- +++ b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/config/TeamGameEventConfig.java
- @@ -0,0 +1,46 @@
- +package net.sf.l2j.gameserver.model.gameevent.config;
- +
- +import java.util.ArrayList;
- +import java.util.List;
- +
- +public abstract class TeamGameEventConfig extends GameEventConfig
- +{
- + public List<GameEventTeamConfig> TEAMS = new ArrayList<>();
- + public boolean ALLOW_TARGET_TEAM_MEMBERS = false;
- +
- + public class GameEventTeamConfig
- + {
- + private final int _id;
- + private final String _name;
- + private final int _color;
- + private final int[] _coordinates;
- +
- + public GameEventTeamConfig(int id, String name, int color, int[] coordinates)
- + {
- + _id = id;
- + _name = name;
- + _color = color;
- + _coordinates = coordinates;
- + }
- +
- + public int getId()
- + {
- + return _id;
- + }
- +
- + public String getName()
- + {
- + return _name;
- + }
- +
- + public int getColor()
- + {
- + return _color;
- + }
- +
- + public int[] getCoordinates()
- + {
- + return _coordinates;
- + }
- + }
- +}
- \ No newline at end of file
- diff --git a/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/dm/DMConfig.java b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/dm/DMConfig.java
- new file mode 100644
- index 0000000..0a411d2
- --- /dev/null
- +++ b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/dm/DMConfig.java
- @@ -0,0 +1,264 @@
- +package net.sf.l2j.gameserver.model.gameevent.dm;
- +
- +import java.io.File;
- +
- +import javax.xml.parsers.DocumentBuilderFactory;
- +
- +import net.sf.l2j.commons.logging.CLogger;
- +
- +import net.sf.l2j.gameserver.model.gameevent.config.IGameEventConfig;
- +import net.sf.l2j.gameserver.model.gameevent.config.IndividualGameEventConfig;
- +
- +import org.w3c.dom.Document;
- +import org.w3c.dom.NamedNodeMap;
- +import org.w3c.dom.Node;
- +
- +public class DMConfig extends IndividualGameEventConfig implements IGameEventConfig
- +{
- + private static final CLogger LOGGER = new CLogger(DMConfig.class.getName());
- +
- + public int[][] REWARDS_1ST_PLACE;
- + public int[][] REWARDS_2ND_PLACE;
- + public int[][] REWARDS_3RD_PLACE;
- +
- + private DMConfig()
- + {
- + load();
- + }
- +
- + @Override
- + public void load()
- + {
- + try
- + {
- + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- + factory.setValidating(false);
- + factory.setIgnoringComments(true);
- +
- + File file = new File("./data/xml/events/DeathMatch.xml");
- +
- + Document doc = factory.newDocumentBuilder().parse(file);
- +
- + for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling())
- + {
- + if (!"dm".equalsIgnoreCase(n.getNodeName()))
- + continue;
- +
- + NamedNodeMap attrs = n.getAttributes();
- +
- + for (Node cd = n.getFirstChild(); cd != null; cd = cd.getNextSibling())
- + {
- + if ("EventTimeInterval".equalsIgnoreCase(cd.getNodeName()))
- + {
- + attrs = cd.getAttributes();
- + EVENT_INTERVAL = attrs.getNamedItem("val").getNodeValue().split(",");
- + }
- + else if ("Duration".equalsIgnoreCase(cd.getNodeName()))
- + {
- + attrs = cd.getAttributes();
- + EVENT_DURATION_TIME = Byte.parseByte(attrs.getNamedItem("val").getNodeValue());
- + }
- + else if ("Participants".equalsIgnoreCase(cd.getNodeName()))
- + {
- + attrs = cd.getAttributes();
- + MIN_PARTICIPANTS = Short.parseShort(attrs.getNamedItem("min").getNodeValue());
- + MAX_PARTICIPANTS = Short.parseShort(attrs.getNamedItem("max").getNodeValue());
- + }
- + else if ("Level".equalsIgnoreCase(cd.getNodeName()))
- + {
- + attrs = cd.getAttributes();
- + MIN_LEVEL = Byte.parseByte(attrs.getNamedItem("min").getNodeValue());
- + MAX_LEVEL = Byte.parseByte(attrs.getNamedItem("max").getNodeValue());
- + }
- + else if ("TimeToRegistration".equalsIgnoreCase(cd.getNodeName()))
- + {
- + attrs = cd.getAttributes();
- + REGISTRATION_TIME = Byte.parseByte(attrs.getNamedItem("val").getNodeValue());
- + }
- + else if ("TimeToTeleport".equalsIgnoreCase(cd.getNodeName()))
- + {
- + attrs = cd.getAttributes();
- + TELEPORT_TIME = Byte.parseByte(attrs.getNamedItem("val").getNodeValue());
- + }
- + else if ("AllowTakeItem".equalsIgnoreCase(cd.getNodeName()))
- + {
- + attrs = cd.getAttributes();
- + ALLOW_TAKE_ITEM = Boolean.parseBoolean(attrs.getNamedItem("val").getNodeValue());
- + }
- + else if ("TakeItem".equalsIgnoreCase(cd.getNodeName()))
- + {
- + attrs = cd.getAttributes();
- + TAKE_ITEM_ID = Short.parseShort(attrs.getNamedItem("id").getNodeValue());
- + TAKE_COUNT = Integer.parseInt(attrs.getNamedItem("count").getNodeValue());
- + }
- + else if ("AllowKillBonus".equalsIgnoreCase(cd.getNodeName()))
- + {
- + attrs = cd.getAttributes();
- + ALLOW_KILL_BONUS = Boolean.parseBoolean(attrs.getNamedItem("val").getNodeValue());
- + }
- + else if ("KillReward".equalsIgnoreCase(cd.getNodeName()))
- + {
- + attrs = cd.getAttributes();
- + KILL_BONUS_ID = Short.parseShort(attrs.getNamedItem("id").getNodeValue());
- + KILL_BONUS_COUNT = Integer.parseInt(attrs.getNamedItem("count").getNodeValue());
- + }
- + else if ("PlayerEventCoordinates".equalsIgnoreCase(cd.getNodeName()))
- + {
- + attrs = cd.getAttributes();
- + int x = Integer.parseInt(attrs.getNamedItem("x").getNodeValue());
- + int y = Integer.parseInt(attrs.getNamedItem("y").getNodeValue());
- + int z = Integer.parseInt(attrs.getNamedItem("z").getNodeValue());
- + int h = Integer.parseInt(attrs.getNamedItem("h").getNodeValue());
- + EVENT_COORDINATES = new int[]
- + {
- + x,
- + y,
- + z,
- + h
- + };
- + }
- + else if ("StopAllEffects".equalsIgnoreCase(cd.getNodeName()))
- + {
- + attrs = cd.getAttributes();
- + STOP_ALL_EFFECTS = Boolean.parseBoolean(attrs.getNamedItem("val").getNodeValue());
- + }
- + else if ("HidePlayersIdentity".equalsIgnoreCase(cd.getNodeName()))
- + {
- + attrs = cd.getAttributes();
- + HIDE_PLAYERS_IDENTITY = Boolean.parseBoolean(attrs.getNamedItem("val").getNodeValue());
- + }
- + else if ("Rewards1stPlace".equalsIgnoreCase(cd.getNodeName()))
- + {
- + attrs = cd.getAttributes();
- + String[] itemIds = attrs.getNamedItem("id").getNodeValue().split(",");
- + String[] counts = attrs.getNamedItem("count").getNodeValue().split(",");
- + REWARDS_1ST_PLACE = new int[itemIds.length][];
- + for (int i = 0; i < itemIds.length; i++)
- + {
- + REWARDS_1ST_PLACE[i] = new int[]
- + {
- + Integer.parseInt(itemIds[i]),
- + Integer.parseInt(counts[i])
- + };
- + }
- + }
- + else if ("Rewards2ndPlace".equalsIgnoreCase(cd.getNodeName()))
- + {
- + attrs = cd.getAttributes();
- + String[] itemIds = attrs.getNamedItem("id").getNodeValue().split(",");
- + String[] counts = attrs.getNamedItem("count").getNodeValue().split(",");
- + REWARDS_2ND_PLACE = new int[itemIds.length][];
- + for (int i = 0; i < itemIds.length; i++)
- + {
- + REWARDS_2ND_PLACE[i] = new int[]
- + {
- + Integer.parseInt(itemIds[i]),
- + Integer.parseInt(counts[i])
- + };
- + }
- + }
- + else if ("Rewards3rdPlace".equalsIgnoreCase(cd.getNodeName()))
- + {
- + attrs = cd.getAttributes();
- + String[] itemIds = attrs.getNamedItem("id").getNodeValue().split(",");
- + String[] counts = attrs.getNamedItem("count").getNodeValue().split(",");
- + REWARDS_3RD_PLACE = new int[itemIds.length][];
- + for (int i = 0; i < itemIds.length; i++)
- + {
- + REWARDS_3RD_PLACE[i] = new int[]
- + {
- + Integer.parseInt(itemIds[i]),
- + Integer.parseInt(counts[i])
- + };
- + }
- + }
- + else if ("RewardTie".equalsIgnoreCase(cd.getNodeName()))
- + {
- + attrs = cd.getAttributes();
- + REWARD_EVENT_TIE = Boolean.parseBoolean(attrs.getNamedItem("val").getNodeValue());
- + }
- + else if ("ListMageSupport".equalsIgnoreCase(cd.getNodeName()))
- + {
- + attrs = cd.getAttributes();
- + String[] skills = attrs.getNamedItem("val").getNodeValue().split(",");
- + LIST_MAGE_SUPPORT = new int[skills.length];
- + for (int i = 0; i < skills.length; i++)
- + {
- + LIST_MAGE_SUPPORT[i] = Integer.parseInt(skills[i]);
- + }
- + }
- + else if ("ListFighterSupport".equalsIgnoreCase(cd.getNodeName()))
- + {
- + attrs = cd.getAttributes();
- + String[] skills = attrs.getNamedItem("val").getNodeValue().split(",");
- + LIST_FIGHTER_SUPPORT = new int[skills.length];
- + for (int i = 0; i < skills.length; i++)
- + {
- + LIST_FIGHTER_SUPPORT[i] = Integer.parseInt(skills[i]);
- + }
- + }
- + else if ("RestrictItems".equalsIgnoreCase(cd.getNodeName()))
- + {
- + attrs = cd.getAttributes();
- + String[] items = attrs.getNamedItem("val").getNodeValue().split(",");
- + RESTRICT_ITEMS = new int[items.length];
- + for (int i = 0; i < items.length; i++)
- + {
- + RESTRICT_ITEMS[i] = Integer.parseInt(items[i]);
- + }
- +
- + }
- + else if ("RestrictSkills".equalsIgnoreCase(cd.getNodeName()))
- + {
- + attrs = cd.getAttributes();
- + String[] skills = attrs.getNamedItem("val").getNodeValue().split(",");
- + RESTRICT_SKILLS = new int[skills.length];
- + for (int i = 0; i < skills.length; i++)
- + {
- + RESTRICT_SKILLS[i] = Integer.parseInt(skills[i]);
- + }
- + }
- + else if ("AllowPotions".equalsIgnoreCase(cd.getNodeName()))
- + {
- + attrs = cd.getAttributes();
- + ALLOW_POTIONS = Boolean.parseBoolean(attrs.getNamedItem("val").getNodeValue());
- + }
- + else if ("AllowScrolls".equalsIgnoreCase(cd.getNodeName()))
- + {
- + attrs = cd.getAttributes();
- + ALLOW_SCROLLS = Boolean.parseBoolean(attrs.getNamedItem("val").getNodeValue());
- + }
- + else if ("AllowSummonByItem".equalsIgnoreCase(cd.getNodeName()))
- + {
- + attrs = cd.getAttributes();
- + ALLOW_SUMMON_BY_ITEM = Boolean.parseBoolean(attrs.getNamedItem("val").getNodeValue());
- + }
- + else if ("RequireMinFragsToReward".equalsIgnoreCase(cd.getNodeName()))
- + {
- + attrs = cd.getAttributes();
- + REQUIRE_MIN_FRAGS_TO_REWARD = Boolean.parseBoolean(attrs.getNamedItem("val").getNodeValue());
- + }
- + else if ("MinFragsRequired".equalsIgnoreCase(cd.getNodeName()))
- + {
- + attrs = cd.getAttributes();
- + MIN_FRAGS_TO_REWARD = Byte.parseByte(attrs.getNamedItem("val").getNodeValue());
- + }
- + }
- + }
- + }
- + catch (Exception e)
- + {
- + LOGGER.warn("Error parsing DeathMatch.xml, by error: " + e.getMessage());
- + }
- + }
- +
- + public static DMConfig getInstance()
- + {
- + return SingletonHolder.INSTANCE;
- + }
- +
- + private static class SingletonHolder
- + {
- + protected static final DMConfig INSTANCE = new DMConfig();
- + }
- +}
- \ No newline at end of file
- diff --git a/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/dm/DMEvent.java b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/dm/DMEvent.java
- new file mode 100644
- index 0000000..5b7d6a6
- --- /dev/null
- +++ b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/dm/DMEvent.java
- @@ -0,0 +1,174 @@
- +package net.sf.l2j.gameserver.model.gameevent.dm;
- +
- +import java.util.HashMap;
- +import java.util.TreeSet;
- +
- +import net.sf.l2j.gameserver.model.gameevent.GameEventTeleporter;
- +import net.sf.l2j.gameserver.model.gameevent.IndividualGameEvent;
- +import net.sf.l2j.gameserver.enums.SayType;
- +import net.sf.l2j.gameserver.model.World;
- +import net.sf.l2j.gameserver.model.actor.Creature;
- +import net.sf.l2j.gameserver.model.actor.Player;
- +import net.sf.l2j.gameserver.model.actor.Summon;
- +import net.sf.l2j.gameserver.model.gameevent.GameEventManager;
- +import net.sf.l2j.gameserver.model.gameevent.GameEventPlayer;
- +import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;
- +
- +public final class DMEvent extends IndividualGameEvent
- +{
- + @Override
- + public void init()
- + {
- + _eventName = "Death Match";
- + _participants = new HashMap<>();
- +
- + setState(EventState.INACTIVE);
- +
- + GameEventManager.getInstance().registerEvent(this);
- + }
- +
- + @Override
- + public DMConfig getConfigs()
- + {
- + return DMConfig.getInstance();
- + }
- +
- + /**
- + * Method called to set the winners
- + * @return String: msg
- + */
- + @Override
- + public String calculateRewards()
- + {
- + TreeSet<GameEventPlayer> players = new TreeSet<>();
- + players.addAll(_participants.values());
- +
- + for (int i = 0; i < 3; i++)
- + {
- + if (players.isEmpty())
- + break;
- +
- + GameEventPlayer player = players.first();
- +
- + if (player.getKills() == 0)
- + break;
- +
- + reward(player, i + 1);
- + players.remove(player);
- +
- + int playerPointPrev = player.getKills();
- +
- + if (getConfigs().REWARD_EVENT_TIE)
- + continue;
- +
- + while (!players.isEmpty())
- + {
- + player = players.first();
- +
- + if (player.getKills() != playerPointPrev)
- + break;
- +
- + reward(player, i + 1);
- + players.remove(player);
- + }
- + }
- +
- + setState(EventState.REWARDING);
- +
- + String[] topPositions;
- + topPositions = getFirstPosition(3);
- +
- + if (topPositions != null)
- + {
- + World.announceToOnlinePlayers(_eventName + " Event: Winners", true);
- + for (String topPosition : topPositions)
- + {
- + String[] row = topPosition.split("\\,");
- + World.announceToOnlinePlayers(_eventName + " Event: " + row[0] + " with " + row[1] + " kills.", true);
- + }
- + }
- + else
- + World.announceToOnlinePlayers(_eventName + " Event: No players win the match (nobody was killed).", true);
- +
- + return "Ended, thanks to everyone who participated!";
- + }
- +
- + private void reward(GameEventPlayer eventPlayer, int pos)
- + {
- + if (eventPlayer == null)
- + return;
- +
- + final Player player = eventPlayer.getPlayer();
- + if (player == null)
- + return;
- +
- + int[][] rewards = null;
- + if (pos == 1)
- + rewards = getConfigs().REWARDS_1ST_PLACE;
- + else if (pos == 2)
- + rewards = getConfigs().REWARDS_2ND_PLACE;
- + else if (pos == 3)
- + rewards = getConfigs().REWARDS_3RD_PLACE;
- +
- + if (rewards != null)
- + deliverRewards(player, rewards);
- + }
- +
- + /**
- + * Method called when a player is killed
- + * @param killer as Creature
- + * @param killed as Player
- + */
- + @Override
- + public void onKill(Creature killer, Player killed)
- + {
- + if ((killed == null) || (killer == null) || !isRunning() || !isParticipant(killed.getObjectId()))
- + return;
- +
- + final GameEventPlayer killedEventPlayer = _participants.get(killed.getObjectId());
- + if (killedEventPlayer == null)
- + return;
- +
- + new GameEventTeleporter(killedEventPlayer, getConfigs().EVENT_COORDINATES, false);
- +
- + Player killerPlayer = null;
- +
- + if (killer.getSummon() != null)
- + {
- + killerPlayer = ((Summon) killer).getOwner();
- +
- + if (killerPlayer == null)
- + return;
- + }
- + else
- + killerPlayer = (Player) killer;
- +
- + if (isParticipant(killerPlayer.getObjectId()))
- + {
- + GameEventPlayer killerEventPlayer = _participants.get(killerPlayer.getObjectId());
- +
- + killerEventPlayer.increaseKills();
- + killerPlayer.sendPacket(new CreatureSay(killerPlayer.getObjectId(), SayType.PARTYROOM_ALL, killerPlayer.getName(), "I have killed " + killed.getName() + "!"));
- + killerPlayer.sendMessage("Your kills: " + killerEventPlayer.getKills());
- + killerPlayer.sendMessage("Your deaths: " + killerEventPlayer.getDeaths());
- +
- + killedEventPlayer.increaseDeaths();
- + killed.sendPacket(new CreatureSay(killerPlayer.getObjectId(), SayType.PARTYROOM_ALL, killerPlayer.getName(), "I killed you!"));
- + killed.sendMessage("Your kills: " + killerEventPlayer.getKills());
- + killed.sendMessage("Your deaths: " + killedEventPlayer.getDeaths());
- + }
- +
- + if (getConfigs().ALLOW_KILL_BONUS)
- + giveKillBonus(killerPlayer);
- + }
- +
- + public static DMEvent getInstance()
- + {
- + return SingletonHolder.INSTANCE;
- + }
- +
- + private static class SingletonHolder
- + {
- + protected static final DMEvent INSTANCE = new DMEvent();
- + }
- +}
- \ No newline at end of file
- diff --git a/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/tvt/TvTConfig.java b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/tvt/TvTConfig.java
- new file mode 100644
- index 0000000..81ef484
- --- /dev/null
- +++ b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/tvt/TvTConfig.java
- @@ -0,0 +1,236 @@
- +package net.sf.l2j.gameserver.model.gameevent.tvt;
- +
- +import java.io.File;
- +
- +import javax.xml.parsers.DocumentBuilderFactory;
- +
- +import org.w3c.dom.Document;
- +import org.w3c.dom.NamedNodeMap;
- +import org.w3c.dom.Node;
- +
- +import net.sf.l2j.commons.logging.CLogger;
- +
- +import net.sf.l2j.gameserver.model.gameevent.config.IGameEventConfig;
- +import net.sf.l2j.gameserver.model.gameevent.config.TeamGameEventConfig;
- +
- +public class TvTConfig extends TeamGameEventConfig implements IGameEventConfig
- +{
- + protected static final CLogger LOGGER = new CLogger(TvTConfig.class.getName());
- +
- + /* TODO: IMPLEMENT */
- + public byte NUMBER_OF_ROUNDS = 0;
- + /* ------------------------------ */
- +
- + private TvTConfig()
- + {
- + load();
- + }
- +
- + @Override
- + public void load()
- + {
- + try
- + {
- + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- + factory.setValidating(false);
- + factory.setIgnoringComments(true);
- +
- + File file = new File("./data/xml/events/TvT.xml");
- +
- + Document doc = factory.newDocumentBuilder().parse(file);
- +
- + for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling())
- + {
- + if (!"tvt".equalsIgnoreCase(n.getNodeName()))
- + continue;
- +
- + for (Node cd = n.getFirstChild(); cd != null; cd = cd.getNextSibling())
- + {
- + NamedNodeMap attrs = n.getAttributes();
- +
- + if ("EventTimeInterval".equalsIgnoreCase(cd.getNodeName()))
- + {
- + attrs = cd.getAttributes();
- + EVENT_INTERVAL = attrs.getNamedItem("val").getNodeValue().split(",");
- + }
- + else if ("Duration".equalsIgnoreCase(cd.getNodeName()))
- + {
- + attrs = cd.getAttributes();
- + EVENT_DURATION_TIME = Byte.parseByte(attrs.getNamedItem("val").getNodeValue());
- + }
- + else if ("Participants".equalsIgnoreCase(cd.getNodeName()))
- + {
- + attrs = cd.getAttributes();
- + MIN_PARTICIPANTS = Short.parseShort(attrs.getNamedItem("min").getNodeValue());
- + MAX_PARTICIPANTS = Short.parseShort(attrs.getNamedItem("max").getNodeValue());
- + }
- + else if ("Level".equalsIgnoreCase(cd.getNodeName()))
- + {
- + attrs = cd.getAttributes();
- + MIN_LEVEL = Byte.parseByte(attrs.getNamedItem("min").getNodeValue());
- + MAX_LEVEL = Byte.parseByte(attrs.getNamedItem("max").getNodeValue());
- + }
- + else if ("TimeToRegistration".equalsIgnoreCase(cd.getNodeName()))
- + {
- + attrs = cd.getAttributes();
- + REGISTRATION_TIME = Byte.parseByte(attrs.getNamedItem("val").getNodeValue());
- + }
- + else if ("TimeToTeleport".equalsIgnoreCase(cd.getNodeName()))
- + {
- + attrs = cd.getAttributes();
- + TELEPORT_TIME = Byte.parseByte(attrs.getNamedItem("val").getNodeValue());
- + }
- + else if ("AllowTakeItem".equalsIgnoreCase(cd.getNodeName()))
- + {
- + attrs = cd.getAttributes();
- + ALLOW_TAKE_ITEM = Boolean.parseBoolean(attrs.getNamedItem("val").getNodeValue());
- + }
- + else if ("TakeItem".equalsIgnoreCase(cd.getNodeName()))
- + {
- + attrs = cd.getAttributes();
- + TAKE_ITEM_ID = Short.parseShort(attrs.getNamedItem("id").getNodeValue());
- + TAKE_COUNT = Integer.parseInt(attrs.getNamedItem("count").getNodeValue());
- + }
- + else if ("AllowKillBonus".equalsIgnoreCase(cd.getNodeName()))
- + {
- + attrs = cd.getAttributes();
- + ALLOW_KILL_BONUS = Boolean.parseBoolean(attrs.getNamedItem("val").getNodeValue());
- + }
- + else if ("KillReward".equalsIgnoreCase(cd.getNodeName()))
- + {
- + attrs = cd.getAttributes();
- + KILL_BONUS_ID = Short.parseShort(attrs.getNamedItem("id").getNodeValue());
- + KILL_BONUS_COUNT = Integer.parseInt(attrs.getNamedItem("count").getNodeValue());
- + }
- + else if ("StopAllEffects".equalsIgnoreCase(cd.getNodeName()))
- + {
- + attrs = cd.getAttributes();
- + STOP_ALL_EFFECTS = Boolean.parseBoolean(attrs.getNamedItem("val").getNodeValue());
- + }
- + else if ("HidePlayersIdentity".equalsIgnoreCase(cd.getNodeName()))
- + {
- + attrs = cd.getAttributes();
- + HIDE_PLAYERS_IDENTITY = Boolean.parseBoolean(attrs.getNamedItem("val").getNodeValue());
- + }
- + else if ("Team".equalsIgnoreCase(cd.getNodeName()))
- + {
- + attrs = cd.getAttributes();
- + byte teamId = Byte.parseByte(attrs.getNamedItem("id").getNodeValue());
- + String name = attrs.getNamedItem("name").getNodeValue();
- + int color = Integer.decode("0x" + attrs.getNamedItem("color").getNodeValue());
- + String[] coord = attrs.getNamedItem("coordinates").getNodeValue().split(",");
- + int[] coordinates = new int[4];
- +
- + for (int i = 0; i < coord.length; i++)
- + coordinates[i] = Integer.parseInt(coord[i]);
- +
- + TEAMS.add(new GameEventTeamConfig(teamId, name, color, coordinates));
- + }
- + else if ("Rewards".equalsIgnoreCase(cd.getNodeName()))
- + {
- + attrs = cd.getAttributes();
- + String[] itemIds = attrs.getNamedItem("id").getNodeValue().split(",");
- + String[] counts = attrs.getNamedItem("count").getNodeValue().split(",");
- + REWARDS = new int[itemIds.length][];
- + for (int i = 0; i < itemIds.length; i++)
- + {
- + REWARDS[i] = new int[]
- + {
- + Integer.parseInt(itemIds[i]),
- + Integer.parseInt(counts[i])
- + };
- + }
- + }
- + else if ("RewardTeamTie".equalsIgnoreCase(cd.getNodeName()))
- + {
- + attrs = cd.getAttributes();
- + REWARD_EVENT_TIE = Boolean.parseBoolean(attrs.getNamedItem("val").getNodeValue());
- + }
- + else if ("ListMageSupport".equalsIgnoreCase(cd.getNodeName()))
- + {
- + attrs = cd.getAttributes();
- + String[] skills = attrs.getNamedItem("val").getNodeValue().split(",");
- + LIST_MAGE_SUPPORT = new int[skills.length];
- +
- + for (int i = 0; i < skills.length; i++)
- + LIST_MAGE_SUPPORT[i] = Integer.parseInt(skills[i]);
- + }
- + else if ("ListFighterSupport".equalsIgnoreCase(cd.getNodeName()))
- + {
- + attrs = cd.getAttributes();
- + String[] skills = attrs.getNamedItem("val").getNodeValue().split(",");
- + LIST_FIGHTER_SUPPORT = new int[skills.length];
- +
- + for (int i = 0; i < skills.length; i++)
- + LIST_FIGHTER_SUPPORT[i] = Integer.parseInt(skills[i]);
- + }
- + else if ("RestrictItems".equalsIgnoreCase(cd.getNodeName()))
- + {
- + attrs = cd.getAttributes();
- + String[] items = attrs.getNamedItem("val").getNodeValue().split(",");
- + RESTRICT_ITEMS = new int[items.length];
- + for (int i = 0; i < items.length; i++)
- + RESTRICT_ITEMS[i] = Integer.parseInt(items[i]);
- + }
- + else if ("RestrictSkills".equalsIgnoreCase(cd.getNodeName()))
- + {
- + attrs = cd.getAttributes();
- + String[] skills = attrs.getNamedItem("val").getNodeValue().split(",");
- + RESTRICT_SKILLS = new int[skills.length];
- + for (int i = 0; i < skills.length; i++)
- + RESTRICT_SKILLS[i] = Integer.parseInt(skills[i]);
- + }
- + else if ("AllowPotions".equalsIgnoreCase(cd.getNodeName()))
- + {
- + attrs = cd.getAttributes();
- + ALLOW_POTIONS = Boolean.parseBoolean(attrs.getNamedItem("val").getNodeValue());
- + }
- + else if ("AllowScrolls".equalsIgnoreCase(cd.getNodeName()))
- + {
- + attrs = cd.getAttributes();
- + ALLOW_SCROLLS = Boolean.parseBoolean(attrs.getNamedItem("val").getNodeValue());
- + }
- + else if ("AllowSummonByItem".equalsIgnoreCase(cd.getNodeName()))
- + {
- + attrs = cd.getAttributes();
- + ALLOW_SUMMON_BY_ITEM = Boolean.parseBoolean(attrs.getNamedItem("val").getNodeValue());
- + }
- + else if ("AllowTargetTeamMembers".equalsIgnoreCase(cd.getNodeName()))
- + {
- + attrs = cd.getAttributes();
- + ALLOW_TARGET_TEAM_MEMBERS = Boolean.parseBoolean(attrs.getNamedItem("val").getNodeValue());
- + }
- + else if ("RequireMinFragsToReward".equalsIgnoreCase(cd.getNodeName()))
- + {
- + attrs = cd.getAttributes();
- + REQUIRE_MIN_FRAGS_TO_REWARD = Boolean.parseBoolean(attrs.getNamedItem("val").getNodeValue());
- + }
- + else if ("MinFragsRequired".equalsIgnoreCase(cd.getNodeName()))
- + {
- + attrs = cd.getAttributes();
- + MIN_FRAGS_TO_REWARD = Byte.parseByte(attrs.getNamedItem("val").getNodeValue());
- + }
- + else if ("NumberOfRounds".equalsIgnoreCase(cd.getNodeName()))
- + {
- + attrs = cd.getAttributes();
- + NUMBER_OF_ROUNDS = Byte.parseByte(attrs.getNamedItem("val").getNodeValue());
- + }
- + }
- + }
- + }
- + catch (Exception e)
- + {
- + LOGGER.warn("Error parsing TvT.xml, by error: " + e.getMessage());
- + }
- + }
- +
- + public static TvTConfig getInstance()
- + {
- + return SingletonHolder.INSTANCE;
- + }
- +
- + private static class SingletonHolder
- + {
- + protected static final TvTConfig INSTANCE = new TvTConfig();
- + }
- +}
- \ No newline at end of file
- diff --git a/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/tvt/TvTEvent.java b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/tvt/TvTEvent.java
- new file mode 100644
- index 0000000..bc8787a
- --- /dev/null
- +++ b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/tvt/TvTEvent.java
- @@ -0,0 +1,109 @@
- +package net.sf.l2j.gameserver.model.gameevent.tvt;
- +
- +import java.util.List;
- +
- +import net.sf.l2j.gameserver.enums.SayType;
- +import net.sf.l2j.gameserver.model.actor.Creature;
- +import net.sf.l2j.gameserver.model.actor.Player;
- +import net.sf.l2j.gameserver.model.actor.Summon;
- +import net.sf.l2j.gameserver.model.gameevent.GameEventManager;
- +import net.sf.l2j.gameserver.model.gameevent.GameEventPlayer;
- +import net.sf.l2j.gameserver.model.gameevent.GameEventTeam;
- +import net.sf.l2j.gameserver.model.gameevent.GameEventTeleporter;
- +import net.sf.l2j.gameserver.model.gameevent.TeamGameEvent;
- +import net.sf.l2j.gameserver.model.gameevent.config.TeamGameEventConfig.GameEventTeamConfig;
- +import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;
- +
- +public final class TvTEvent extends TeamGameEvent
- +{
- + @Override
- + public void init()
- + {
- + _eventName = "Team vs Team";
- +
- + List<GameEventTeamConfig> teamsConfig = getConfigs().TEAMS;
- + _teams = new GameEventTeam[teamsConfig.size()];
- + for (int i = 0; i < teamsConfig.size(); i++)
- + _teams[i] = new GameEventTeam(teamsConfig.get(i).getId(), teamsConfig.get(i).getName(), teamsConfig.get(i).getColor(), teamsConfig.get(i).getCoordinates());
- +
- + setState(EventState.INACTIVE);
- +
- + GameEventManager.getInstance().registerEvent(this);
- + }
- +
- + @Override
- + public TvTConfig getConfigs()
- + {
- + return TvTConfig.getInstance();
- + }
- +
- + /**
- + * Method called when a player is killed
- + * @param killer as Creature
- + * @param killed as Player
- + */
- + @Override
- + public void onKill(Creature killer, Player killed)
- + {
- + if ((killed == null) || (killer == null) || !isRunning())
- + return;
- +
- + final GameEventTeam killedTeam = getParticipantTeam(killed.getObjectId());
- + if (killedTeam == null)
- + return;
- +
- + final GameEventPlayer killedEventPlayer = killedTeam.getEventPlayer(killed.getObjectId());
- + if (killedEventPlayer == null)
- + return;
- +
- + new GameEventTeleporter(killedEventPlayer, killedTeam.getCoordinates(), false);
- +
- + Player killerPlayer = null;
- +
- + if (killer.getSummon() != null)
- + {
- + killerPlayer = ((Summon) killer).getOwner();
- +
- + if (killerPlayer == null)
- + return;
- + }
- + else
- + killerPlayer = (Player) killer;
- +
- + final GameEventTeam killerTeam = getParticipantTeam(killerPlayer.getObjectId());
- + if (killerTeam == null)
- + return;
- +
- + final GameEventPlayer killerEventPlayer = killerTeam.getEventPlayer(killerPlayer.getObjectId());
- + if (killerEventPlayer == null)
- + return;
- +
- + if (killerTeam.getId() != killedTeam.getId())
- + {
- + killedEventPlayer.increaseDeaths();
- + killedEventPlayer.increaseKills();
- + killerTeam.increasePoints();
- +
- + CreatureSay cs = new CreatureSay(killerPlayer.getObjectId(), SayType.PARTYROOM_ALL, killerPlayer.getName(), "I have killed " + killed.getName() + "!");
- +
- + for (GameEventPlayer eventPlayer : killerTeam.getParticipatedPlayers().values())
- + {
- + if ((eventPlayer != null) && (eventPlayer.getPlayer() != null))
- + eventPlayer.getPlayer().sendPacket(cs);
- + }
- + }
- +
- + if (getConfigs().ALLOW_KILL_BONUS)
- + giveKillBonus(killerPlayer);
- + }
- +
- + public static TvTEvent getInstance()
- + {
- + return SingletonHolder.INSTANCE;
- + }
- +
- + private static class SingletonHolder
- + {
- + protected static final TvTEvent INSTANCE = new TvTEvent();
- + }
- +}
- \ No newline at end of file
Add Comment
Please, Sign In to add comment