Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: java/com/l2jserver/gameserver/model/entity/CTFManager.java
- ===================================================================
- --- java/com/l2jserver/gameserver/model/entity/CTFManager.java (revision 0)
- +++ java/com/l2jserver/gameserver/model/entity/CTFManager.java (working copy)
- @@ -0,0 +1,298 @@
- +/*
- + * This program is free software: you can redistribute it and/or modify it under
- + * the terms of the GNU General Public License as published by the Free Software
- + * Foundation, either version 3 of the License, or (at your option) any later
- + * version.
- + *
- + * This program is distributed in the hope that it will be useful, but WITHOUT
- + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- + * details.
- + *
- + * You should have received a copy of the GNU General Public License along with
- + * this program. If not, see <http://www.gnu.org/licenses/>.
- + */
- +
- +package com.l2jserver.gameserver.model.entity;
- +
- +import java.util.Calendar;
- +import java.util.concurrent.ScheduledFuture;
- +import java.util.logging.Logger;
- +
- +import com.l2jserver.Config;
- +import com.l2jserver.gameserver.Announcements;
- +import com.l2jserver.gameserver.ThreadPoolManager;
- +
- +/**
- + * @author FBIagent, edited U3Games
- + */
- +
- +public class CTFManager
- +{
- + protected static final Logger _log = Logger.getLogger(CTFManager.class.getName());
- +
- + /** Task for event cycles<br> */
- + private CTFStartTask _task;
- +
- + /**
- + * New instance only by getInstance()<br>
- + */
- + private CTFManager()
- + {
- + if (Config.CTF_EVENT_ENABLED)
- + {
- + CTFEvent.init();
- +
- + this.scheduleEventStart();
- + _log.info("CTFEventEngine[CTFManager.CTFManager()]: Started.");
- + }
- + else
- + {
- + _log.info("CTFEventEngine[CTFManager.CTFManager()]: Engine is disabled.");
- + }
- + }
- +
- + /**
- + * Initialize new/Returns the one and only instance<br><br>
- + *
- + * @return CTFManager<br>
- + */
- + public static CTFManager getInstance()
- + {
- + return SingletonHolder._instance;
- + }
- +
- + /**
- + * Starts CTFStartTask
- + */
- + public void scheduleEventStart()
- + {
- + try
- + {
- + Calendar currentTime = Calendar.getInstance();
- + Calendar nextStartTime = null;
- + Calendar testStartTime = null;
- + for (String timeOfDay : Config.CTF_EVENT_INTERVAL)
- + {
- + // Creating a Calendar object from the specified interval value
- + 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 the date is in the past, make it the next day (Example: Checking for "1:00", when the time is 23:57.)
- + if (testStartTime.getTimeInMillis() < currentTime.getTimeInMillis())
- + {
- + testStartTime.add(Calendar.DAY_OF_MONTH, 1);
- + }
- + // Check for the test date to be the minimum (smallest in the specified list)
- + if (nextStartTime == null || testStartTime.getTimeInMillis() < nextStartTime.getTimeInMillis())
- + {
- + nextStartTime = testStartTime;
- + }
- + }
- + _task = new CTFStartTask(nextStartTime.getTimeInMillis());
- + ThreadPoolManager.getInstance().executeTask(_task);
- + }
- + catch (Exception e)
- + {
- + _log.warning("CTFEventEngine[CTFManager.scheduleEventStart()]: Error figuring out a start time. Check CTFEventInterval in config file.");
- + }
- + }
- +
- + /**
- + * Method to start participation
- + */
- + public void startReg()
- + {
- + if (!CTFEvent.startParticipation())
- + {
- + Announcements.getInstance().announceToAll("CTF Event: Event was cancelled.");
- + _log.warning("CTFEventEngine[CTFManager.run()]: Error spawning event npc for participation.");
- +
- + this.scheduleEventStart();
- + }
- + else
- + {
- + Announcements.getInstance().announceToAll("CTF Event: Registration opened for " + Config.CTF_EVENT_PARTICIPATION_TIME
- + + " minute(s).");
- +
- + // schedule registration end
- + _task.setStartTime(System.currentTimeMillis() + 60000L * Config.CTF_EVENT_PARTICIPATION_TIME);
- + ThreadPoolManager.getInstance().executeTask(_task);
- + }
- + }
- +
- + /**
- + * Method to start the fight
- + */
- + public void startEvent()
- + {
- + if (!CTFEvent.startFight())
- + {
- + Announcements.getInstance().announceToAll("CTF Event: Event cancelled due to lack of Participation.");
- + _log.info("CTFEventEngine[CTFManager.run()]: Lack of registration, abort event.");
- +
- + this.scheduleEventStart();
- + }
- + else
- + {
- + CTFEvent.sysMsgToAllParticipants("CTF Event: Teleporting participants to an arena in "
- + + Config.CTF_EVENT_START_LEAVE_TELEPORT_DELAY + " second(s).");
- + _task.setStartTime(System.currentTimeMillis() + 60000L * Config.CTF_EVENT_RUNNING_TIME);
- + ThreadPoolManager.getInstance().executeTask(_task);
- + }
- + }
- +
- + /**
- + * Method to end the event and reward
- + */
- + public void endEvent()
- + {
- + Announcements.getInstance().announceToAll(CTFEvent.calculateRewards());
- + CTFEvent.sysMsgToAllParticipants("CTF Event: Teleporting back to the registration npc in "
- + + Config.CTF_EVENT_START_LEAVE_TELEPORT_DELAY + " second(s).");
- + CTFEvent.stopFight();
- +
- + this.scheduleEventStart();
- + }
- +
- + public void skipDelay()
- + {
- + if (_task.nextRun.cancel(false))
- + {
- + _task.setStartTime(System.currentTimeMillis());
- + ThreadPoolManager.getInstance().executeTask(_task);
- + }
- + }
- +
- + /**
- + * Class for CTF cycles
- + */
- + class CTFStartTask implements Runnable
- + {
- + private long _startTime;
- + public ScheduledFuture<?> nextRun;
- +
- + public CTFStartTask(long startTime)
- + {
- + _startTime = startTime;
- + }
- +
- + public void setStartTime(long startTime)
- + {
- + _startTime = startTime;
- + }
- +
- + /**
- + * @see java.lang.Runnable#run()
- + */
- + public void run()
- + {
- + int delay = (int) Math.round((_startTime - System.currentTimeMillis()) / 1000.0);
- +
- + if (delay > 0)
- + {
- + this.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
- + {
- + // start
- + if (CTFEvent.isInactive())
- + {
- + CTFManager.this.startReg();
- + }
- + else if (CTFEvent.isParticipating())
- + {
- + CTFManager.this.startEvent();
- + }
- + else
- + {
- + CTFManager.this.endEvent();
- + }
- + }
- +
- + if (delay > 0)
- + {
- + nextRun = ThreadPoolManager.getInstance().scheduleGeneral(this, nextMsg * 1000);
- + }
- + }
- +
- + private void announce(long time)
- + {
- + if (time >= 3600 && time % 3600 == 0)
- + {
- + if (CTFEvent.isParticipating())
- + {
- + Announcements.getInstance().announceToAll("CTF Event: " + (time / 60 / 60) + " hour(s) until registration is closed!");
- + }
- + else if (CTFEvent.isStarted())
- + {
- + CTFEvent.sysMsgToAllParticipants("CTF Event: " + (time / 60 / 60) + " hour(s) until event is finished!");
- + }
- + }
- + else if (time >= 60)
- + {
- + if (CTFEvent.isParticipating())
- + {
- + Announcements.getInstance().announceToAll("CTF Event: " + (time / 60) + " minute(s) until registration is closed!");
- + }
- + else if (CTFEvent.isStarted())
- + {
- + CTFEvent.sysMsgToAllParticipants("CTF Event: " + (time / 60) + " minute(s) until the event is finished!");
- + }
- + }
- + else
- + {
- + if (CTFEvent.isParticipating())
- + {
- + Announcements.getInstance().announceToAll("CTF Event: " + time + " second(s) until registration is closed!");
- + }
- + else if (CTFEvent.isStarted())
- + {
- + CTFEvent.sysMsgToAllParticipants("CTF Event: " + time + " second(s) until the event is finished!");
- + }
- + }
- + }
- + }
- +
- + @SuppressWarnings("synthetic-access")
- + private static class SingletonHolder
- + {
- + protected static final CTFManager _instance = new CTFManager();
- + }
- +}
- Index: java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java
- ===================================================================
- --- java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java (revision 65)
- +++ java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java (working copy)
- @@ -162,7 +162,9 @@
- import com.l2jserver.gameserver.model.effects.EffectTemplate;
- import com.l2jserver.gameserver.model.effects.L2Effect;
- import com.l2jserver.gameserver.model.effects.L2EffectType;
- +import com.l2jserver.gameserver.model.entity.CTFEvent;
- import com.l2jserver.gameserver.model.entity.Castle;
- +import com.l2jserver.gameserver.model.entity.DMEvent;
- import com.l2jserver.gameserver.model.entity.Duel;
- import com.l2jserver.gameserver.model.entity.Fort;
- import com.l2jserver.gameserver.model.entity.Hero;
- @@ -5981,6 +5983,8 @@
- {
- L2PcInstance pk = killer.getActingPlayer();
- + CTFEvent.onKill(killer, this);
- + DMEvent.onKill(killer, this);
- TvTEvent.onKill(killer, this);
- TvTRoundEvent.onKill(killer, this);
- @@ -9439,6 +9443,18 @@
- }
- }
- + // Check if the attacker is in CTF and CTF is started
- + if (CTFEvent.isStarted() && CTFEvent.isPlayerParticipant(getObjectId()))
- + {
- + return true;
- + }
- +
- + // Check if the attacker is in DM and DM is started
- + if (DMEvent.isStarted() && DMEvent.isPlayerParticipant(getObjectId()))
- + {
- + return true;
- + }
- +
- // Check if the attacker is in TvT and TvT is started
- if (TvTEvent.isStarted() && TvTEvent.isPlayerParticipant(getObjectId()))
- {
- @@ -12243,6 +12259,8 @@
- pet.updateAndBroadcastStatus(0);
- }
- + CTFEvent.onTeleported(this);
- + DMEvent.onTeleported(this);
- TvTEvent.onTeleported(this);
- TvTRoundEvent.onTeleported(this);
- }
- @@ -13008,6 +13026,26 @@
- _log.log(Level.SEVERE, "deleteMe()", e);
- }
- + // CTF Event removal
- + try
- + {
- + CTFEvent.onLogout(this);
- + }
- + catch (Exception e)
- + {
- + _log.log(Level.SEVERE, "deleteMe()", e);
- + }
- +
- + // DM Event removal
- + try
- + {
- + DMEvent.onLogout(this);
- + }
- + catch (Exception e)
- + {
- + _log.log(Level.SEVERE, "deleteMe()", e);
- + }
- +
- // TvT Event removal
- try
- {
- @@ -13880,6 +13918,14 @@
- sendMessage("You are in jail for " + delayInMinutes + " minutes.");
- }
- + if (!CTFEvent.isInactive() && CTFEvent.isPlayerParticipant(getObjectId()))
- + {
- + CTFEvent.removeParticipant(getObjectId());
- + }
- + if (!DMEvent.isInactive() && DMEvent.isPlayerParticipant(getObjectId()))
- + {
- + DMEvent.removeParticipant(getObjectId());
- + }
- if (!TvTEvent.isInactive() && TvTEvent.isPlayerParticipant(getObjectId()))
- {
- TvTEvent.removeParticipant(getObjectId());
- @@ -14315,7 +14361,7 @@
- public void calculateDeathPenaltyBuffLevel(L2Character killer)
- {
- - if (((getKarma() > 0) || (Rnd.get(1, 100) <= Config.DEATH_PENALTY_CHANCE)) && !(killer instanceof L2PcInstance) && !(canOverrideCond(PcCondOverride.DEATH_PENALTY)) && !(getCharmOfLuck() && killer.isRaid()) && !isPhoenixBlessed() && !isLucky() && !(TvTEvent.isStarted() && TvTEvent.isPlayerParticipant(getObjectId())) && !(TvTRoundEvent.isStarted() && TvTRoundEvent.isPlayerParticipant(getObjectId())) && !(isInsideZone(ZoneId.PVP) || isInsideZone(ZoneId.SIEGE)))
- + if (((getKarma() > 0) || (Rnd.get(1, 100) <= Config.DEATH_PENALTY_CHANCE)) && !(killer instanceof L2PcInstance) && !(canOverrideCond(PcCondOverride.DEATH_PENALTY)) && !(getCharmOfLuck() && killer.isRaid()) && !isPhoenixBlessed() && !isLucky() && !(CTFEvent.isStarted() && CTFEvent.isPlayerParticipant(getObjectId())) && !(DMEvent.isStarted() && DMEvent.isPlayerParticipant(getObjectId())) && !(TvTEvent.isStarted() && TvTEvent.isPlayerParticipant(getObjectId())) && !(TvTRoundEvent.isStarted() && TvTRoundEvent.isPlayerParticipant(getObjectId())) && !(isInsideZone(ZoneId.PVP) || isInsideZone(ZoneId.SIEGE)))
- {
- increaseDeathPenaltyBuffLevel();
- }
- @@ -14834,6 +14880,18 @@
- return false;
- }
- + if (!CTFEvent.onEscapeUse(summonerChar.getObjectId()))
- + {
- + summonerChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOUR_TARGET_IS_IN_AN_AREA_WHICH_BLOCKS_SUMMONING));
- + return false;
- + }
- +
- + if (!DMEvent.onEscapeUse(summonerChar.getObjectId()))
- + {
- + summonerChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOUR_TARGET_IS_IN_AN_AREA_WHICH_BLOCKS_SUMMONING));
- + return false;
- + }
- +
- if (!TvTEvent.onEscapeUse(summonerChar.getObjectId()))
- {
- summonerChar.sendPacket(SystemMessageId.YOUR_TARGET_IS_IN_AN_AREA_WHICH_BLOCKS_SUMMONING);
- @@ -14913,6 +14971,18 @@
- return false;
- }
- + if (!CTFEvent.onEscapeUse(targetChar.getObjectId()))
- + {
- + summonerChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOUR_TARGET_IS_IN_AN_AREA_WHICH_BLOCKS_SUMMONING));
- + return false;
- + }
- +
- + if (!DMEvent.onEscapeUse(targetChar.getObjectId()))
- + {
- + summonerChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOUR_TARGET_IS_IN_AN_AREA_WHICH_BLOCKS_SUMMONING));
- + return false;
- + }
- +
- if (!TvTEvent.onEscapeUse(targetChar.getObjectId()))
- {
- summonerChar.sendPacket(SystemMessageId.YOUR_TARGET_IS_IN_AN_AREA_WHICH_BLOCKS_SUMMONING);
- Index: java/com/l2jserver/gameserver/engines/DocumentBase.java
- ===================================================================
- --- java/com/l2jserver/gameserver/engines/DocumentBase.java (revision 65)
- +++ java/com/l2jserver/gameserver/engines/DocumentBase.java (working copy)
- @@ -740,6 +740,16 @@
- boolean val = Boolean.parseBoolean(a.getNodeValue());
- cond = joinAnd(cond, new ConditionPlayerIsClanLeader(val));
- }
- + else if ("onCTFEvent".equalsIgnoreCase(a.getNodeName()))
- + {
- + boolean val = Boolean.valueOf(a.getNodeValue());
- + cond = joinAnd(cond, new ConditionPlayerTvTEvent(val));
- + }
- + else if ("onDMEvent".equalsIgnoreCase(a.getNodeName()))
- + {
- + boolean val = Boolean.valueOf(a.getNodeValue());
- + cond = joinAnd(cond, new ConditionPlayerTvTEvent(val));
- + }
- else if ("onTvTEvent".equalsIgnoreCase(a.getNodeName()))
- {
- boolean val = Boolean.parseBoolean(a.getNodeValue());
- Index: java/com/l2jserver/gameserver/instancemanager/AntiFeedManager.java
- ===================================================================
- --- java/com/l2jserver/gameserver/instancemanager/AntiFeedManager.java (revision 65)
- +++ java/com/l2jserver/gameserver/instancemanager/AntiFeedManager.java (working copy)
- @@ -33,6 +33,8 @@
- public static final int TVT_ID = 2;
- public static final int L2EVENT_ID = 3;
- public static final int TVT_ROUND_ID = 4;
- + public static final int CTF_ID = 5;
- + public static final int DM_ID = 6;
- private final Map<Integer, Long> _lastDeathTimes = new L2FastMap<>(true);
- private final L2HashMap<Integer, Map<Integer, Connections>> _eventIPs = new L2HashMap<>();
- Index: java/com/l2jserver/gameserver/model/skills/l2skills/L2SkillMount.java
- ===================================================================
- --- java/com/l2jserver/gameserver/model/skills/l2skills/L2SkillMount.java (revision 65)
- +++ java/com/l2jserver/gameserver/model/skills/l2skills/L2SkillMount.java (working copy)
- @@ -18,6 +18,8 @@
- import com.l2jserver.gameserver.model.StatsSet;
- import com.l2jserver.gameserver.model.actor.L2Character;
- import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
- +import com.l2jserver.gameserver.model.entity.CTFEvent;
- +import com.l2jserver.gameserver.model.entity.DMEvent;
- import com.l2jserver.gameserver.model.entity.TvTEvent;
- import com.l2jserver.gameserver.model.entity.TvTRoundEvent;
- import com.l2jserver.gameserver.model.skills.L2Skill;
- @@ -43,11 +45,21 @@
- return;
- }
- + if (!CTFEvent.onItemSummon(caster.getObjectId()))
- + {
- + return;
- + }
- +
- + if (!DMEvent.onItemSummon(caster.getObjectId()))
- + {
- + return;
- + }
- +
- if (!TvTEvent.onItemSummon(caster.getObjectId()))
- {
- return;
- }
- -
- +
- if (!TvTRoundEvent.onItemSummon(caster.getObjectId()))
- {
- return;
- Index: java/com/l2jserver/gameserver/model/entity/DMEventPlayer.java
- ===================================================================
- --- java/com/l2jserver/gameserver/model/entity/DMEventPlayer.java (revision 0)
- +++ java/com/l2jserver/gameserver/model/entity/DMEventPlayer.java (working copy)
- @@ -0,0 +1,207 @@
- +/*
- + * This program is free software: you can redistribute it and/or modify it under
- + * the terms of the GNU General Public License as published by the Free Software
- + * Foundation, either version 3 of the License, or (at your option) any later
- + * version.
- + *
- + * This program is distributed in the hope that it will be useful, but WITHOUT
- + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- + * details.
- + *
- + * You should have received a copy of the GNU General Public License along with
- + * this program. If not, see <http://www.gnu.org/licenses/>.
- + */
- +
- +package com.l2jserver.gameserver.model.entity;
- +
- +import java.util.Map;
- +
- +import javolution.util.FastMap;
- +
- +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
- +
- +/**
- + * @author FBIagent, edited U3Games
- + */
- +
- +public class DMEventPlayer
- +{
- + /** The player of the player<br> */
- + private L2PcInstance _player;
- + /** The points of the player<br> */
- + private short _points;
- + /** The death of the player<br> */
- + private short _death;
- + private String _hexCode;
- + /** player and instance of all participated players in FastMap<br> */
- + private Map<Integer, L2PcInstance> _participatedPlayers = new FastMap<Integer, L2PcInstance>();
- +
- + /**
- + * C'tor initialize the team<br><br>
- + *
- + * @param player as String<br>
- + * @param coordinates as int[]<br>
- + */
- + public DMEventPlayer(L2PcInstance player, int[] coordinates, String hexCode)
- + {
- + _player = player;
- + _coordinates = coordinates;
- + _points = 0;
- + _death = 0;
- + _hexCode = hexCode;
- + }
- +
- + /**
- + * Adds a player to the team<br><br>
- + *
- + * @param playerInstance as L2PcInstance<br>
- + * @return boolean: true if success, otherwise false<br>
- + */
- + public boolean addPlayer(L2PcInstance playerInstance)
- + {
- + if (playerInstance == null)
- + {
- + return false;
- + }
- +
- + synchronized (_participatedPlayers)
- + {
- + _participatedPlayers.put(playerInstance.getObjectId(), playerInstance);
- + }
- +
- + return true;
- + }
- +
- + /**
- + * Removes a player from the team
- + * @param playerObjectId
- + */
- + public void removePlayer(int playerObjectId)
- + {
- + synchronized (_participatedPlayers)
- + {
- + _participatedPlayers.remove(playerObjectId);
- + }
- + }
- +
- + /**
- + * Increases the points of the team<br>
- + */
- + public short getPoints()
- + {
- + return _points;
- + }
- +
- + /**
- + * Cleanup the team and make it ready for adding players again<br>
- + */
- + public void cleanMe()
- + {
- + _participatedPlayers.clear();
- + _participatedPlayers = new FastMap<Integer, L2PcInstance>();
- + _points = 0;
- + }
- +
- + /**
- + * Returns the player of the team<br><br>
- + *
- + * @return String: player of the team<br>
- + */
- + public L2PcInstance getPlayer()
- + {
- + return _player;
- + }
- +
- + /**
- + * Returns the coordinates of the team spot<br><br>
- + *
- + * @return int[]: team coordinates<br>
- + */
- + public int[] getCoordinates()
- + {
- + return _coordinates;
- + }
- +
- + /**
- + * @param points the _points to set
- + */
- + public void setPoints(short points)
- + {
- + _points = points;
- + }
- +
- + /**
- + * Increases the points of the player<br>
- + */
- + public void increasePoints()
- + {
- + ++_points;
- + }
- +
- + /**
- + * @return the _death
- + */
- + public short getDeath()
- + {
- + return _death;
- + }
- +
- + /**
- + * @param death the _death to set
- + */
- + public void setDeath(short death)
- + {
- + _death = death;
- + }
- +
- + /**
- + * Increases the death of the player<br>
- + */
- + public void increaseDeath()
- + {
- + ++_death;
- + }
- +
- + /**
- + * @return the _hexCode
- + */
- + public String getHexCode()
- + {
- + return _hexCode;
- + }
- +
- + /**
- + * Returns player and instance of all participated players in FastMap<br><br>
- + *
- + * @return Map<String, L2PcInstance>: map of players in this team<br>
- + */
- + public Map<Integer, L2PcInstance> getParticipatedPlayers()
- + {
- + Map<Integer, L2PcInstance> participatedPlayers = null;
- +
- + synchronized (_participatedPlayers)
- + {
- + participatedPlayers = _participatedPlayers;
- + }
- +
- + return participatedPlayers;
- + }
- +
- + /**
- + * Returns player count of this team<br><br>
- + *
- + * @return int: number of players in team<br>
- + */
- + public int getParticipatedPlayerCount()
- + {
- + int participatedPlayerCount;
- +
- + synchronized (_participatedPlayers)
- + {
- + participatedPlayerCount = _participatedPlayers.size();
- + }
- +
- + return participatedPlayerCount;
- + }
- +}
- Index: java/com/l2jserver/gameserver/network/clientpackets/EnterWorld.java
- ===================================================================
- --- java/com/l2jserver/gameserver/network/clientpackets/EnterWorld.java (revision 65)
- +++ java/com/l2jserver/gameserver/network/clientpackets/EnterWorld.java (working copy)
- @@ -51,8 +51,10 @@
- import com.l2jserver.gameserver.model.PcCondOverride;
- import com.l2jserver.gameserver.model.actor.instance.L2ClassMasterInstance;
- import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
- +import com.l2jserver.gameserver.model.entity.CTFEvent;
- import com.l2jserver.gameserver.model.entity.Castle;
- import com.l2jserver.gameserver.model.entity.Couple;
- +import com.l2jserver.gameserver.model.entity.DMEvent;
- import com.l2jserver.gameserver.model.entity.Fort;
- import com.l2jserver.gameserver.model.entity.FortSiege;
- import com.l2jserver.gameserver.model.entity.Hitman;
- @@ -146,9 +148,9 @@
- {
- L2PcInstance activeChar = getClient().getActiveChar();
- - PvPColorSystem pvpcolor = new PvPColorSystem();
- - pvpcolor.updateNameColor(activeChar);
- - pvpcolor.updateTitleColor(activeChar);
- + PvPColorSystem pvpcolor = new PvPColorSystem();
- + pvpcolor.updateNameColor(activeChar);
- + pvpcolor.updateTitleColor(activeChar);
- if (activeChar == null)
- {
- @@ -188,14 +190,14 @@
- _log.warning("User already exists in Object ID map! User " + activeChar.getName() + " is a character clone.");
- }
- }
- -
- - if (activeChar.getPremiumService()==1)
- +
- + if (activeChar.getPremiumService() == 1)
- {
- activeChar.sendPacket(new ExBrPremiumState(activeChar.getObjectId(), 1));
- }
- else
- {
- - activeChar.sendPacket(new ExBrPremiumState(activeChar.getObjectId(),0));
- + activeChar.sendPacket(new ExBrPremiumState(activeChar.getObjectId(), 0));
- }
- // Apply special GM properties to the GM when entering
- @@ -452,14 +454,18 @@
- }
- activeChar.updateEffectIcons();
- -
- +
- if (Config.PC_BANG_ENABLED)
- + {
- + if (activeChar.getPcBangPoints() > 0)
- {
- - if (activeChar.getPcBangPoints() > 0)
- - activeChar.sendPacket(new ExPCCafePointInfo(activeChar.getPcBangPoints(), 0, 1));
- - else
- - activeChar.sendPacket(new ExPCCafePointInfo());
- + activeChar.sendPacket(new ExPCCafePointInfo(activeChar.getPcBangPoints(), 0, 1));
- }
- + else
- + {
- + activeChar.sendPacket(new ExPCCafePointInfo());
- + }
- + }
- activeChar.sendPacket(new EtcStatusUpdate(activeChar));
- @@ -484,8 +490,8 @@
- Announcements.getInstance().showAnnouncements(activeChar);
- activeChar.sendMessage("==================================");
- activeChar.sendMessage("Developer: Flash ");
- - activeChar.sendMessage("Welcome Back "+activeChar.getName()+" to our Server!");
- - activeChar.sendMessage("players online "+L2World.getInstance().getAllPlayers().size());
- + activeChar.sendMessage("Welcome Back " + activeChar.getName() + " to our Server!");
- + activeChar.sendMessage("players online " + L2World.getInstance().getAllPlayers().size());
- activeChar.sendMessage("==================================");
- if (showClanNotice)
- @@ -505,19 +511,23 @@
- sendPacket(new NpcHtmlMessage(1, serverNews));
- }
- }
- -
- +
- // Bot manager punishment
- - if(Config.ENABLE_BOTREPORT)
- - BotManager.getInstance().onEnter(activeChar);
- + if (Config.ENABLE_BOTREPORT)
- + {
- + BotManager.getInstance().onEnter(activeChar);
- + }
- // Clan Leader Color Name
- - if (!activeChar.isGM() && (activeChar.getClan() != null && activeChar.isClanLeader() && Config.CLAN_LEADER_COLOR_ENABLED && activeChar.getClan().getLevel() >= Config.CLAN_LEADER_COLOR_CLAN_LEVEL))
- - activeChar.getAppearance().setNameColor(Config.CLAN_LEADER_COLOR);
- + if (!activeChar.isGM() && ((activeChar.getClan() != null) && activeChar.isClanLeader() && Config.CLAN_LEADER_COLOR_ENABLED && (activeChar.getClan().getLevel() >= Config.CLAN_LEADER_COLOR_CLAN_LEVEL)))
- + {
- + activeChar.getAppearance().setNameColor(Config.CLAN_LEADER_COLOR);
- + }
- if (Config.ANNOUNCE_CASTLE_LORDS)
- {
- notifyCastleOwner(activeChar);
- - }
- + }
- if (Config.PETITIONING_ALLOWED)
- {
- @@ -538,7 +548,7 @@
- sendPacket(new ExNevitAdventTimeChange(activeChar.getAdventTime(), false));
- sendPacket(new ExShowContactList(activeChar));
- - boolean reloadRune = false;
- + boolean reloadRune = false;
- for (L2ItemInstance i : activeChar.getInventory().getItems())
- {
- if (i.isTimeLimitedItem())
- @@ -548,12 +558,16 @@
- if (i.isShadowItem() && i.isEquipped())
- {
- i.decreaseMana(false);
- - if(i.isRune())
- - reloadRune = true;
- + if (i.isRune())
- + {
- + reloadRune = true;
- + }
- }
- }
- - if (reloadRune)
- + if (reloadRune)
- + {
- activeChar.reloadRune();
- + }
- for (L2ItemInstance i : activeChar.getWarehouse().getItems())
- {
- if (i.isTimeLimitedItem())
- @@ -561,16 +575,16 @@
- i.scheduleLifeTimeTask();
- }
- }
- - for (L2ItemInstance items : activeChar.getInventory().getItems())
- - {
- - if (!activeChar.isGM() && items.isEquipable() && items.getEnchantLevel() > Config.MAX_ENCHANT_LEVEL)
- - {
- - activeChar.getInventory().destroyItem(null, items, activeChar, null);
- - Util.handleIllegalPlayerAction(activeChar, "Player " + activeChar.getName() + " has Overenchanted item! Kicked! ", Config.DEFAULT_PUNISH);
- - _log.info(items+" item has been removed from "+activeChar);
- - }
- - }
- -
- + for (L2ItemInstance items : activeChar.getInventory().getItems())
- + {
- + if (!activeChar.isGM() && items.isEquipable() && (items.getEnchantLevel() > Config.MAX_ENCHANT_LEVEL))
- + {
- + activeChar.getInventory().destroyItem(null, items, activeChar, null);
- + Util.handleIllegalPlayerAction(activeChar, "Player " + activeChar.getName() + " has Overenchanted item! Kicked! ", Config.DEFAULT_PUNISH);
- + _log.info(items + " item has been removed from " + activeChar);
- + }
- + }
- +
- if (DimensionalRiftManager.getInstance().checkIfInRiftZone(activeChar.getX(), activeChar.getY(), activeChar.getZ(), false))
- {
- DimensionalRiftManager.getInstance().teleportToWaitingRoom(activeChar);
- @@ -616,6 +630,8 @@
- RegionBBSManager.getInstance().changeCommunityBoard();
- CommunityServerThread.getInstance().sendPacket(new WorldInfo(activeChar, null, WorldInfo.TYPE_UPDATE_PLAYER_STATUS));
- + CTFEvent.onLogin(activeChar);
- + DMEvent.onLogin(activeChar);
- TvTEvent.onLogin(activeChar);
- TvTRoundEvent.onLogin(activeChar);
- @@ -625,9 +641,11 @@
- }
- L2ClassMasterInstance.showQuestionMark(activeChar);
- - if(Config.ALLOW_HITMAN_GDE)
- - Hitman.getInstance().onEnterWorld(activeChar);
- -
- + if (Config.ALLOW_HITMAN_GDE)
- + {
- + Hitman.getInstance().onEnterWorld(activeChar);
- + }
- +
- int birthday = activeChar.checkBirthDay();
- if (birthday == 0)
- {
- @@ -783,19 +801,19 @@
- {
- qs.getQuest().notifyEvent("UC", null, player);
- }
- -
- +
- }
- +
- // Premium Service Icon
- private void PremiumServiceIcon(L2PcInstance activeChar)
- {
- - if(activeChar.getPremiumService()==1)
- + if (activeChar.getPremiumService() == 1)
- {
- activeChar.sendPacket(new PremiumState(activeChar.getObjectId(), 1));
- activeChar.sendMessage("Premium account: now active");
- }
- }
- -
- @Override
- public String getType()
- {
- @@ -829,6 +847,7 @@
- {
- listeners.remove(listener);
- }
- +
- private void notifyCastleOwner(L2PcInstance activeChar)
- {
- L2Clan clan = activeChar.getClan();
- @@ -839,7 +858,9 @@
- {
- Castle castle = CastleManager.getInstance().getCastleById(clan.getCastleId());
- if ((castle != null) && (activeChar.getObjectId() == clan.getLeaderId()))
- + {
- Announcements.getInstance().announceToAll("Lord " + activeChar.getName() + " Ruler Of " + castle.getName() + " Castle is Now Online!");
- + }
- }
- }
- }
- Index: java/com/l2jserver/gameserver/model/actor/instance/L2CTFEventNpcInstance.java
- ===================================================================
- --- java/com/l2jserver/gameserver/model/actor/instance/L2CTFEventNpcInstance.java (revision 0)
- +++ java/com/l2jserver/gameserver/model/actor/instance/L2CTFEventNpcInstance.java (working copy)
- @@ -0,0 +1,108 @@
- +/*
- + * This program is free software: you can redistribute it and/or modify it under
- + * the terms of the GNU General Public License as published by the Free Software
- + * Foundation, either version 3 of the License, or (at your option) any later
- + * version.
- + *
- + * This program is distributed in the hope that it will be useful, but WITHOUT
- + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- + * details.
- + *
- + * You should have received a copy of the GNU General Public License along with
- + * this program. If not, see <http://www.gnu.org/licenses/>.
- + */
- +
- +package com.l2jserver.gameserver.model.actor.instance;
- +
- +import com.l2jserver.Config;
- +import com.l2jserver.gameserver.cache.HtmCache;
- +import com.l2jserver.gameserver.model.actor.L2Npc;
- +import com.l2jserver.gameserver.model.actor.templates.L2NpcTemplate;
- +import com.l2jserver.gameserver.model.entity.CTFEvent;
- +import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
- +import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
- +
- +public class L2CTFEventNpcInstance extends L2Npc
- +{
- + private static final String htmlPath = "data/html/mods/CTFEvent/";
- +
- + public L2CTFEventNpcInstance(int objectId, L2NpcTemplate template)
- + {
- + super(objectId, template);
- + setInstanceType(InstanceType.L2CTFEventNpcInstance);
- + }
- +
- + @Override
- + public void onBypassFeedback(L2PcInstance playerInstance, String command)
- + {
- + CTFEvent.onBypass(command, playerInstance);
- + }
- +
- + @Override
- + public void showChatWindow(L2PcInstance playerInstance, int val)
- + {
- + if (playerInstance == null)
- + {
- + return;
- + }
- +
- + if (CTFEvent.isParticipating())
- + {
- + final boolean isParticipant = CTFEvent.isPlayerParticipant(playerInstance.getObjectId());
- + final String htmContent;
- +
- + if (!isParticipant)
- + {
- + htmContent = HtmCache.getInstance().getHtm(playerInstance.getHtmlPrefix(), htmlPath + "Participation.htm");
- + }
- + else
- + {
- + htmContent = HtmCache.getInstance().getHtm(playerInstance.getHtmlPrefix(), htmlPath + "RemoveParticipation.htm");
- + }
- +
- + if (htmContent != null)
- + {
- + int[] teamsPlayerCounts = CTFEvent.getTeamsPlayerCounts();
- + NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(getObjectId());
- +
- + npcHtmlMessage.setHtml(htmContent);
- + npcHtmlMessage.replace("%objectId%", String.valueOf(getObjectId()));
- + npcHtmlMessage.replace("%team1name%", Config.CTF_EVENT_TEAM_1_NAME);
- + npcHtmlMessage.replace("%team1playercount%", String.valueOf(teamsPlayerCounts[0]));
- + npcHtmlMessage.replace("%team2name%", Config.CTF_EVENT_TEAM_2_NAME);
- + npcHtmlMessage.replace("%team2playercount%", String.valueOf(teamsPlayerCounts[1]));
- + npcHtmlMessage.replace("%playercount%", String.valueOf(teamsPlayerCounts[0] + teamsPlayerCounts[1]));
- + if (!isParticipant)
- + {
- + npcHtmlMessage.replace("%fee%", CTFEvent.getParticipationFee());
- + }
- +
- + playerInstance.sendPacket(npcHtmlMessage);
- + }
- + }
- + else if (CTFEvent.isStarting() || CTFEvent.isStarted())
- + {
- + final String htmContent = HtmCache.getInstance().getHtm(playerInstance.getHtmlPrefix(), htmlPath + "Status.htm");
- +
- + if (htmContent != null)
- + {
- + int[] teamsPlayerCounts = CTFEvent.getTeamsPlayerCounts();
- + int[] teamsPointsCounts = CTFEvent.getTeamsPoints();
- + NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(getObjectId());
- +
- + npcHtmlMessage.setHtml(htmContent);
- + // npcHtmlMessage.replace("%objectId%", String.valueOf(getObjectId()));
- + npcHtmlMessage.replace("%team1name%", Config.CTF_EVENT_TEAM_1_NAME);
- + npcHtmlMessage.replace("%team1playercount%", String.valueOf(teamsPlayerCounts[0]));
- + npcHtmlMessage.replace("%team1points%", String.valueOf(teamsPointsCounts[0]));
- + npcHtmlMessage.replace("%team2name%", Config.CTF_EVENT_TEAM_2_NAME);
- + npcHtmlMessage.replace("%team2playercount%", String.valueOf(teamsPlayerCounts[1]));
- + npcHtmlMessage.replace("%team2points%", String.valueOf(teamsPointsCounts[1])); // <---- array index from 0 to 1 thx DaRkRaGe
- + playerInstance.sendPacket(npcHtmlMessage);
- + }
- + }
- +
- + playerInstance.sendPacket(ActionFailed.STATIC_PACKET);
- + }
- +}
- Index: java/com/l2jserver/gameserver/model/olympiad/AbstractOlympiadGame.java
- ===================================================================
- --- java/com/l2jserver/gameserver/model/olympiad/AbstractOlympiadGame.java (revision 65)
- +++ java/com/l2jserver/gameserver/model/olympiad/AbstractOlympiadGame.java (working copy)
- @@ -32,6 +32,8 @@
- import com.l2jserver.gameserver.model.actor.L2Summon;
- import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
- import com.l2jserver.gameserver.model.actor.instance.L2PetInstance;
- +import com.l2jserver.gameserver.model.entity.CTFEvent;
- +import com.l2jserver.gameserver.model.entity.DMEvent;
- import com.l2jserver.gameserver.model.entity.TvTEvent;
- import com.l2jserver.gameserver.model.entity.TvTRoundEvent;
- import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
- @@ -140,7 +142,7 @@
- }
- // safety precautions
- - if (player.inObserverMode() || TvTEvent.isPlayerParticipant(player.getObjectId()) || TvTRoundEvent.isPlayerParticipant(player.getObjectId()))
- + if (player.inObserverMode() || TvTEvent.isPlayerParticipant(player.getObjectId()) || CTFEvent.isPlayerParticipant(player.getObjectId()) || DMEvent.isPlayerParticipant(player.getObjectId()) || TvTRoundEvent.isPlayerParticipant(player.getObjectId()))
- {
- return SystemMessage.getSystemMessage(SystemMessageId.THE_GAME_HAS_BEEN_CANCELLED_BECAUSE_THE_OTHER_PARTY_DOES_NOT_MEET_THE_REQUIREMENTS_FOR_JOINING_THE_GAME);
- }
- Index: java/com/l2jserver/gameserver/model/entity/DMEvent.java
- ===================================================================
- --- java/com/l2jserver/gameserver/model/entity/DMEvent.java (revision 0)
- +++ java/com/l2jserver/gameserver/model/entity/DMEvent.java (working copy)
- @@ -0,0 +1,1215 @@
- +/*
- + * This program is free software: you can redistribute it and/or modify it under
- + * the terms of the GNU General Public License as published by the Free Software
- + * Foundation, either version 3 of the License, or (at your option) any later
- + * version.
- + *
- + * This program is distributed in the hope that it will be useful, but WITHOUT
- + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- + * details.
- + *
- + * You should have received a copy of the GNU General Public License along with
- + * this program. If not, see <http://www.gnu.org/licenses/>.
- + */
- +
- +package com.l2jserver.gameserver.model.entity;
- +
- +import java.math.BigInteger;
- +import java.util.Collection;
- +import java.util.Comparator;
- +import java.util.List;
- +import java.util.Map;
- +import java.util.TreeSet;
- +import java.util.logging.Level;
- +import java.util.logging.Logger;
- +
- +import javolution.util.FastMap;
- +
- +import com.l2jserver.Config;
- +import com.l2jserver.gameserver.cache.HtmCache;
- +import com.l2jserver.gameserver.datatables.DoorTable;
- +import com.l2jserver.gameserver.datatables.ItemTable;
- +import com.l2jserver.gameserver.datatables.NpcTable;
- +import com.l2jserver.gameserver.datatables.SkillTable;
- +import com.l2jserver.gameserver.datatables.SpawnTable;
- +import com.l2jserver.gameserver.instancemanager.AntiFeedManager;
- +import com.l2jserver.gameserver.instancemanager.InstanceManager;
- +import com.l2jserver.gameserver.model.L2Party;
- +import com.l2jserver.gameserver.model.L2Spawn;
- +import com.l2jserver.gameserver.model.L2World;
- +import com.l2jserver.gameserver.model.actor.L2Character;
- +import com.l2jserver.gameserver.model.actor.L2Npc;
- +import com.l2jserver.gameserver.model.actor.L2Summon;
- +import com.l2jserver.gameserver.model.actor.instance.L2DoorInstance;
- +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
- +import com.l2jserver.gameserver.model.actor.instance.L2PetInstance;
- +import com.l2jserver.gameserver.model.actor.instance.L2ServitorInstance;
- +import com.l2jserver.gameserver.model.actor.templates.L2NpcTemplate;
- +import com.l2jserver.gameserver.model.itemcontainer.PcInventory;
- +import com.l2jserver.gameserver.model.skills.L2Skill;
- +import com.l2jserver.gameserver.network.SystemMessageId;
- +import com.l2jserver.gameserver.network.clientpackets.Say2;
- +import com.l2jserver.gameserver.network.serverpackets.CreatureSay;
- +import com.l2jserver.gameserver.network.serverpackets.MagicSkillUse;
- +import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
- +import com.l2jserver.gameserver.network.serverpackets.StatusUpdate;
- +import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
- +import com.l2jserver.util.Rnd;
- +import com.l2jserver.util.StringUtil;
- +
- +/**
- + * @author FBIagent, edited U3Games and DreamStage
- + */
- +
- +public class DMEvent
- +{
- + enum EventState
- + {
- + INACTIVE,
- + INACTIVATING,
- + PARTICIPATING,
- + STARTING,
- + STARTED,
- + REWARDING
- + }
- +
- + protected static final Logger _log = Logger.getLogger(DMEvent.class.getName());
- + /** html path **/
- + private static final String htmlPath = "data/html/mods/DMEvent/";
- + /** The state of the DMEvent<br> */
- + private static EventState _state = EventState.INACTIVE;
- + /** The spawn of the participation npc<br> */
- + private static L2Spawn _npcSpawn = null;
- + /** The teams of the TvTEvent<br> */
- + public static TvTEventTeam[] _teams = new TvTEventTeam[1];
- + /** the npc instance of the participation npc<br> */
- + private static L2Npc _lastNpcSpawn = null;
- + /** Instance id<br> */
- + private static int _DMEventInstance = 0;
- +
- + // private static List<DMEventPlayer> _DMEventPlayer = new ArrayList<DMEventPlayer>();
- +
- + private static Map<Integer, DMEventPlayer> _DMEventPlayer = new FastMap<Integer, DMEventPlayer>();
- +
- + public DMEvent()
- + {
- + }
- +
- + /**
- + * DM initializing<br>
- + */
- + public static void init()
- + {
- + }
- +
- + /**
- + * Sets the DMEvent state<br>
- + * <br>
- + * @param state as EventState<br>
- + */
- + private static void setState(EventState state)
- + {
- + synchronized (_state)
- + {
- + _state = state;
- + }
- + }
- +
- + /**
- + * Is DMEvent inactive?<br>
- + * <br>
- + * @return boolean: true if event is inactive(waiting for next event cycle), otherwise false<br>
- + */
- + public static boolean isInactive()
- + {
- + boolean isInactive;
- +
- + synchronized (_state)
- + {
- + isInactive = _state == EventState.INACTIVE;
- + }
- +
- + return isInactive;
- + }
- +
- + /**
- + * Is DMEvent in inactivating?<br>
- + * <br>
- + * @return boolean: true if event is in inactivating progress, otherwise false<br>
- + */
- + public static boolean isInactivating()
- + {
- + boolean isInactivating;
- +
- + synchronized (_state)
- + {
- + isInactivating = _state == EventState.INACTIVATING;
- + }
- +
- + return isInactivating;
- + }
- +
- + /**
- + * Is DMEvent in participation?<br>
- + * <br>
- + * @return boolean: true if event is in participation progress, otherwise false<br>
- + */
- + public static boolean isParticipating()
- + {
- + boolean isParticipating;
- +
- + synchronized (_state)
- + {
- + isParticipating = _state == EventState.PARTICIPATING;
- + }
- +
- + return isParticipating;
- + }
- +
- + /**
- + * Is DMEvent starting?<br>
- + * <br>
- + * @return boolean: true if event is starting up(setting up fighting spot, teleport players etc.), otherwise false<br>
- + */
- + public static boolean isStarting()
- + {
- + boolean isStarting;
- +
- + synchronized (_state)
- + {
- + isStarting = _state == EventState.STARTING;
- + }
- +
- + return isStarting;
- + }
- +
- + /**
- + * Is DMEvent started?<br>
- + * <br>
- + * @return boolean: true if event is started, otherwise false<br>
- + */
- + public static boolean isStarted()
- + {
- + boolean isStarted;
- +
- + synchronized (_state)
- + {
- + isStarted = _state == EventState.STARTED;
- + }
- +
- + return isStarted;
- + }
- +
- + /**
- + * Is DMEvent rewadrding?<br>
- + * <br>
- + * @return boolean: true if event is currently rewarding, otherwise false<br>
- + */
- + public static boolean isRewarding()
- + {
- + boolean isRewarding;
- +
- + synchronized (_state)
- + {
- + isRewarding = _state == EventState.REWARDING;
- + }
- +
- + return isRewarding;
- + }
- +
- + /**
- + * Close doors specified in configs
- + */
- + private static void closeDoors(List<Integer> doors)
- + {
- + for (int doorId : doors)
- + {
- + L2DoorInstance doorInstance = DoorTable.getInstance().getDoor(doorId);
- +
- + if (doorInstance != null)
- + {
- + doorInstance.closeMe();
- + }
- + }
- + }
- +
- + /**
- + * Open doors specified in configs
- + */
- + private static void openDoors(List<Integer> doors)
- + {
- + for (int doorId : doors)
- + {
- + L2DoorInstance doorInstance = DoorTable.getInstance().getDoor(doorId);
- +
- + if (doorInstance != null)
- + {
- + doorInstance.openMe();
- + }
- + }
- + }
- +
- + /**
- + * UnSpawns the DMEvent npc
- + */
- + private static void unSpawnNpc()
- + {
- + // Delete the npc
- + _lastNpcSpawn.deleteMe();
- + SpawnTable.getInstance().deleteSpawn(_lastNpcSpawn.getSpawn(), false);
- + // Stop respawning of the npc
- + _npcSpawn.stopRespawn();
- + _npcSpawn = null;
- + _lastNpcSpawn = null;
- + }
- +
- + /**
- + * Starts the participation of the DMEvent<br>
- + * 1. Get L2NpcTemplate by Config.DM_EVENT_PARTICIPATION_NPC_ID<br>
- + * 2. Try to spawn a new npc of it<br>
- + * <br>
- + * @return boolean: true if success, otherwise false<br>
- + */
- + public static boolean startParticipation()
- + {
- + L2NpcTemplate tmpl = NpcTable.getInstance().getTemplate(Config.DM_EVENT_PARTICIPATION_NPC_ID);
- +
- + if (tmpl == null)
- + {
- + _log.warning("DMEventEngine[DMEvent.startParticipation()]: L2NpcTemplate is a NullPointer -> Invalid npc id in configs?");
- + return false;
- + }
- +
- + try
- + {
- + _npcSpawn = new L2Spawn(tmpl);
- +
- + _npcSpawn.setLocx(Config.DM_EVENT_PARTICIPATION_NPC_COORDINATES[0]);
- + _npcSpawn.setLocy(Config.DM_EVENT_PARTICIPATION_NPC_COORDINATES[1]);
- + _npcSpawn.setLocz(Config.DM_EVENT_PARTICIPATION_NPC_COORDINATES[2]);
- + _npcSpawn.setAmount(1);
- + _npcSpawn.setHeading(Config.DM_EVENT_PARTICIPATION_NPC_COORDINATES[3]);
- + _npcSpawn.setRespawnDelay(1);
- + // later no need to delete spawn from db, we don't store it (false)
- + SpawnTable.getInstance().addNewSpawn(_npcSpawn, false);
- + _npcSpawn.init();
- + _lastNpcSpawn = _npcSpawn.getLastSpawn();
- + _lastNpcSpawn.setCurrentHp(_lastNpcSpawn.getMaxHp());
- + _lastNpcSpawn.setTitle("DM Event Participation");
- + _lastNpcSpawn.isAggressive();
- + _lastNpcSpawn.decayMe();
- + _lastNpcSpawn.spawnMe(_npcSpawn.getLastSpawn().getX(), _npcSpawn.getLastSpawn().getY(), _npcSpawn.getLastSpawn().getZ());
- + _lastNpcSpawn.broadcastPacket(new MagicSkillUse(_lastNpcSpawn, _lastNpcSpawn, 1034, 1, 1, 1));
- + }
- + catch (Exception e)
- + {
- + _log.log(Level.WARNING, "DMEventEngine[DMEvent.startParticipation()]: exception: " + e.getMessage(), e);
- + return false;
- + }
- +
- + setState(EventState.PARTICIPATING);
- + return true;
- + }
- +
- + /**
- + * Starts the DMEvent fight<br>
- + * 1. Set state EventState.STARTING<br>
- + * 2. Close doors specified in configs<br>
- + * 3. Abort if not enought participants(return false)<br>
- + * 4. Set state EventState.STARTED<br>
- + * 5. Teleport all participants to team spot<br>
- + * <br>
- + * @return boolean: true if success, otherwise false<br>
- + */
- + public static boolean startFight()
- + {
- + // Set state to STARTING
- + setState(EventState.STARTING);
- +
- + // Check the number of participants
- + if (_DMEventPlayer.size() < Config.DM_EVENT_MIN_PLAYERS)
- + {
- + // Set state INACTIVE
- + setState(EventState.INACTIVE);
- +
- + // Cleanup of participants
- + _DMEventPlayer.clear();
- +
- + // Unspawn the event NPC
- + unSpawnNpc();
- + return false;
- + }
- +
- + if (Config.DM_EVENT_IN_INSTANCE)
- + {
- + try
- + {
- + _DMEventInstance = InstanceManager.getInstance().createDynamicInstance(Config.DM_EVENT_INSTANCE_FILE);
- + InstanceManager.getInstance().getInstance(_DMEventInstance).setAllowSummon(false);
- + InstanceManager.getInstance().getInstance(_DMEventInstance).setPvPInstance(true);
- + InstanceManager.getInstance().getInstance(_DMEventInstance).setEmptyDestroyTime((Config.DM_EVENT_START_LEAVE_TELEPORT_DELAY * 1000) + 60000L);
- + }
- + catch (Exception e)
- + {
- + _DMEventInstance = 0;
- + _log.log(Level.WARNING, "DMEventEngine[DMEvent.createDynamicInstance]: exception: " + e.getMessage(), e);
- + }
- + }
- +
- + // Opens all doors specified in configs for dm
- + openDoors(Config.DM_DOORS_IDS_TO_OPEN);
- + // Closes all doors specified in configs for dm
- + closeDoors(Config.DM_DOORS_IDS_TO_CLOSE);
- + // Set state STARTED
- + setState(EventState.STARTED);
- +
- + for (DMEventPlayer player : _DMEventPlayer.values())
- + {
- + if (player != null)
- + {
- + // Teleporter implements Runnable and starts itself
- + new DMEventTeleporter(player.getPlayer(), Config.DM_EVENT_PARTICIPATION_NPC_COORDINATES, false, false);
- + }
- +
- + }
- +
- + return true;
- + }
- +
- + public static TreeSet<DMEventPlayer> orderPosition(Collection<DMEventPlayer> listPlayer)
- + {
- + TreeSet<DMEventPlayer> players = new TreeSet<DMEventPlayer>(new Comparator<DMEventPlayer>()
- + {
- + @Override
- + public int compare(DMEventPlayer p1, DMEventPlayer p2)
- + {
- + Integer c1 = Integer.valueOf(p2.getPoints() - p1.getPoints());
- + Integer c2 = Integer.valueOf(p1.getDeath() - p2.getDeath());
- + Integer c3 = p1.getHexCode().compareTo(p2.getHexCode());
- +
- + if (c1 == 0)
- + {
- + if (c2 == 0)
- + {
- + return c3;
- + }
- + return c2;
- + }
- + return c1;
- + }
- + });
- + players.addAll(listPlayer);
- + return players;
- + }
- +
- + /**
- + * Calculates the DMEvent reward<br>
- + * 1. If both teams are at a tie(points equals), send it as system message to all participants, if one of the teams have 0 participants left online abort rewarding<br>
- + * 2. Wait till teams are not at a tie anymore<br>
- + * 3. Set state EvcentState.REWARDING<br>
- + * 4. Reward team with more points<br>
- + * 5. Show win html to wining team participants<br>
- + * <br>
- + * @return String: winning team name<br>
- + */
- + public static String calculateRewards()
- + {
- + TreeSet<DMEventPlayer> players = orderPosition(_DMEventPlayer.values());
- +
- + for (int j = 0; j < Config.DM_REWARD_FIRST_PLAYERS; j++)
- + {
- + if (players.isEmpty())
- + {
- + break;
- + }
- +
- + DMEventPlayer player = players.first();
- +
- + if (player.getPoints() == 0)
- + {
- + break;
- + }
- + rewardPlayer(player, j + 1);
- + players.remove(player);
- + int playerPointPrev = player.getPoints();
- +
- + if (!Config.DM_REWARD_TEAM_TIE)
- + {
- + continue;
- + }
- +
- + while (!players.isEmpty())
- + {
- + player = players.first();
- + if (player.getPoints() != playerPointPrev)
- + {
- + break;
- + }
- + rewardPlayer(player, j + 1);
- + players.remove(player);
- + }
- + }
- +
- + // Set state REWARDING so nobody can point anymore
- + setState(EventState.REWARDING);
- +
- + return "DM Event ended, thanks to everyone who participated!";
- + }
- +
- + private static void rewardPlayer(DMEventPlayer p, int pos)
- + {
- + L2PcInstance activeChar = p.getPlayer();
- +
- + // Check for nullpointer
- + if (activeChar == null)
- + {
- + return;
- + }
- +
- + SystemMessage systemMessage = null;
- +
- + List<int[]> rewards = Config.DM_EVENT_REWARDS;
- +
- + for (int[] reward : rewards)
- + {
- + PcInventory inv = activeChar.getInventory();
- +
- + // Check for stackable item, non stackabe items need to be added one by one
- + if (ItemTable.getInstance().createDummyItem(reward[0]).isStackable())
- + {
- + inv.addItem("DM Event", reward[0], reward[1], activeChar, activeChar);
- +
- + 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]);
- + }
- +
- + activeChar.sendPacket(systemMessage);
- + }
- + else
- + {
- + for (int i = 0; i < reward[1]; ++i)
- + {
- + inv.addItem("DM Event", reward[0], 1, activeChar, activeChar);
- + systemMessage = SystemMessage.getSystemMessage(SystemMessageId.EARNED_ITEM_S1);
- + systemMessage.addItemName(reward[0]);
- + activeChar.sendPacket(systemMessage);
- + }
- + }
- + }
- +
- + StatusUpdate statusUpdate = new StatusUpdate(activeChar);
- + NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(0);
- +
- + statusUpdate.addAttribute(StatusUpdate.CUR_LOAD, activeChar.getCurrentLoad());
- + npcHtmlMessage.setHtml(HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), htmlPath + "Reward.htm"));
- + activeChar.sendPacket(statusUpdate);
- + activeChar.sendPacket(npcHtmlMessage);
- + }
- +
- + /**
- + * Stops the DMEvent fight<br>
- + * 1. Set state EventState.INACTIVATING<br>
- + * 2. Remove DM npc from world<br>
- + * 3. Open doors specified in configs<br>
- + * 4. Send Top Rank<br>
- + * 5. Teleport all participants back to participation npc location<br>
- + * 6. List players cleaning<br>
- + * 7. Set state EventState.INACTIVE<br>
- + */
- + public static void stopFight()
- + {
- + // Set state INACTIVATING
- + setState(EventState.INACTIVATING);
- + // Unspawn event npc
- + unSpawnNpc();
- + // Opens all doors specified in configs for DM
- + openDoors(Config.DM_DOORS_IDS_TO_CLOSE);
- + // Closes all doors specified in Configs for DM
- + closeDoors(Config.DM_DOORS_IDS_TO_OPEN);
- +
- + String[] topPositions;
- + String htmltext = "";
- + if (Config.DM_EVENT_SHOW_TOP_RANK)
- + {
- + topPositions = getFirstPosition(Config.DM_EVENT_TOP_RANK);
- + Boolean c = true;
- + String c1 = "D9CC46";
- + String c2 = "FFFFFF";
- + if (topPositions != null)
- + {
- + for (int i = 0; i < topPositions.length; i++)
- + {
- + String color = (c ? c1 : c2);
- + String[] row = topPositions[i].split("\\,");
- + htmltext += "<tr>";
- + htmltext += "<td width=\"35\" align=\"center\"><font color=\"" + color + "\">" + String.valueOf(i + 1) + "</font></td>";
- + htmltext += "<td width=\"100\" align=\"left\"><font color=\"" + color + "\">" + row[0] + "</font></td>";
- + htmltext += "<td width=\"125\" align=\"right\"><font color=\"" + color + "\">" + row[1] + "</font></td>";
- + htmltext += "</tr>";
- + c = !c;
- + }
- + }
- + }
- +
- + for (DMEventPlayer player : _DMEventPlayer.values())
- + {
- + if (player != null)
- + {
- + // Top Rank
- + if (Config.DM_EVENT_SHOW_TOP_RANK)
- + {
- + NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(0);
- + npcHtmlMessage.setHtml(HtmCache.getInstance().getHtm(player.getPlayer().getHtmlPrefix(), htmlPath + "TopRank.htm"));
- + npcHtmlMessage.replace("%toprank%", htmltext);
- + player.getPlayer().sendPacket(npcHtmlMessage);
- + }
- + new DMEventTeleporter(player.getPlayer(), Config.DM_EVENT_PARTICIPATION_NPC_COORDINATES, false, false);
- + }
- + }
- +
- + // Cleanup list
- + _DMEventPlayer = new FastMap<Integer, DMEventPlayer>();
- + // Set state INACTIVE
- + setState(EventState.INACTIVE);
- + }
- +
- + /**
- + * Adds a player to a DMEvent<br>
- + * @param activeChar as L2PcInstance<br>
- + * @return boolean: true if success, otherwise false<br>
- + */
- + public static synchronized boolean addParticipant(L2PcInstance activeChar)
- + {
- + // Check for nullpoitner
- + if (activeChar == null)
- + {
- + return false;
- + }
- +
- + if (isPlayerParticipant(activeChar))
- + {
- + return false;
- + }
- +
- + String hexCode = hexToString(generateHex(16));
- + _DMEventPlayer.put(activeChar.getObjectId(), new DMEventPlayer(activeChar, hexCode));
- + return true;
- + }
- +
- + public static boolean isPlayerParticipant(L2PcInstance activeChar)
- + {
- + if (activeChar == null)
- + {
- + return false;
- + }
- + try
- + {
- + if (_DMEventPlayer.containsKey(activeChar.getObjectId()))
- + {
- + return true;
- + }
- + }
- + catch (Exception e)
- + {
- + return false;
- + }
- + return false;
- + }
- +
- + public static boolean isPlayerParticipant(int objectId)
- + {
- + L2PcInstance activeChar = L2World.getInstance().getPlayer(objectId);
- + if (activeChar == null)
- + {
- + return false;
- + }
- + return isPlayerParticipant(activeChar);
- + }
- +
- + /**
- + * Removes a DMEvent player<br>
- + * @param activeChar as L2PcInstance<br>
- + * @return boolean: true if success, otherwise false<br>
- + */
- + public static boolean removeParticipant(L2PcInstance activeChar)
- + {
- + if (activeChar == null)
- + {
- + return false;
- + }
- +
- + if (!isPlayerParticipant(activeChar))
- + {
- + return false;
- + }
- +
- + try
- + {
- + _DMEventPlayer.remove(activeChar.getObjectId());
- + }
- + catch (Exception e)
- + {
- + return false;
- + }
- +
- + return true;
- + }
- +
- + public static boolean payParticipationFee(L2PcInstance activeChar)
- + {
- + int itemId = Config.DM_EVENT_PARTICIPATION_FEE[0];
- + int itemNum = Config.DM_EVENT_PARTICIPATION_FEE[1];
- + if ((itemId == 0) || (itemNum == 0))
- + {
- + return true;
- + }
- +
- + if (activeChar.getInventory().getInventoryItemCount(itemId, -1) < itemNum)
- + {
- + return false;
- + }
- +
- + return activeChar.destroyItemByItemId("DM Participation Fee", itemId, itemNum, _lastNpcSpawn, true);
- + }
- +
- + public static String getParticipationFee()
- + {
- + int itemId = Config.DM_EVENT_PARTICIPATION_FEE[0];
- + int itemNum = Config.DM_EVENT_PARTICIPATION_FEE[1];
- +
- + if ((itemId == 0) || (itemNum == 0))
- + {
- + return "-";
- + }
- +
- + return StringUtil.concat(String.valueOf(itemNum), " ", ItemTable.getInstance().getTemplate(itemId).getName());
- + }
- +
- + /**
- + * Send a SystemMessage to all participated players<br>
- + * @param message as String<br>
- + */
- + public static void sysMsgToAllParticipants(String message)
- + {
- + for (DMEventPlayer player : _DMEventPlayer.values())
- + {
- + if (player != null)
- + {
- + player.getPlayer().sendMessage(message);
- + }
- + }
- + }
- +
- + /**
- + * Called when a player logs in<br>
- + * <br>
- + * @param activeChar as L2PcInstance<br>
- + */
- + public static void onLogin(L2PcInstance activeChar)
- + {
- + if ((activeChar == null) || (!isStarting() && !isStarted()))
- + {
- + return;
- + }
- +
- + if (!isPlayerParticipant(activeChar))
- + {
- + return;
- + }
- +
- + new DMEventTeleporter(activeChar.getActingPlayer(), Config.DM_EVENT_PARTICIPATION_NPC_COORDINATES, false, false);
- + }
- +
- + /**
- + * Called when a player logs out<br>
- + * <br>
- + * @param activeChar as L2PcInstance<br>
- + */
- + public static void onLogout(L2PcInstance activeChar)
- + {
- + if ((activeChar != null) && (isStarting() || isStarted() || isParticipating()))
- + {
- + if (removeParticipant(activeChar))
- + {
- + activeChar.setXYZInvisible((Config.DM_EVENT_PARTICIPATION_NPC_COORDINATES[0] + Rnd.get(101)) - 50, (Config.DM_EVENT_PARTICIPATION_NPC_COORDINATES[1] + Rnd.get(101)) - 50, Config.DM_EVENT_PARTICIPATION_NPC_COORDINATES[2]);
- + }
- + }
- + }
- +
- + /**
- + * Called on every bypass by npc of type L2DMEventNpc<br>
- + * Needs synchronization cause of the max player check<br>
- + * <br>
- + * @param command as String<br>
- + * @param activeChar as L2PcInstance<br>
- + */
- + public static synchronized void onBypass(String command, L2PcInstance activeChar)
- + {
- + if ((activeChar == null) || !isParticipating())
- + {
- + return;
- + }
- +
- + final String htmContent;
- +
- + if (command.equals("dm_event_participation"))
- + {
- + NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(0);
- + int playerLevel = activeChar.getLevel();
- +
- + if (activeChar.isCursedWeaponEquipped())
- + {
- + htmContent = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), htmlPath + "CursedWeaponEquipped.htm");
- + if (htmContent != null)
- + {
- + npcHtmlMessage.setHtml(htmContent);
- + }
- + }
- + else if (activeChar.isInOlympiadMode())
- + {
- + htmContent = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), htmlPath + "Olympiad.htm");
- + if (htmContent != null)
- + {
- + npcHtmlMessage.setHtml(htmContent);
- + }
- + }
- + else if (activeChar.getKarma() > 0)
- + {
- + htmContent = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), htmlPath + "Karma.htm");
- + if (htmContent != null)
- + {
- + npcHtmlMessage.setHtml(htmContent);
- + }
- + }
- + else if ((playerLevel < Config.DM_EVENT_MIN_LVL) || (playerLevel > Config.DM_EVENT_MAX_LVL))
- + {
- + htmContent = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), htmlPath + "Level.htm");
- + if (htmContent != null)
- + {
- + npcHtmlMessage.setHtml(htmContent);
- + npcHtmlMessage.replace("%min%", String.valueOf(Config.DM_EVENT_MIN_LVL));
- + npcHtmlMessage.replace("%max%", String.valueOf(Config.DM_EVENT_MAX_LVL));
- + }
- + }
- + else if (_DMEventPlayer.size() == Config.DM_EVENT_MAX_PLAYERS)
- + {
- + htmContent = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), htmlPath + "Full.htm");
- + if (htmContent != null)
- + {
- + npcHtmlMessage.setHtml(htmContent);
- + npcHtmlMessage.replace("%max%", String.valueOf(Config.DM_EVENT_MAX_PLAYERS));
- + }
- + }
- + else if ((Config.DM_EVENT_MAX_PARTICIPANTS_PER_IP > 0) && !AntiFeedManager.getInstance().tryAddPlayer(AntiFeedManager.DM_ID, activeChar, Config.DM_EVENT_MAX_PARTICIPANTS_PER_IP))
- + {
- + htmContent = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), htmlPath + "IPRestriction.htm");
- + if (htmContent != null)
- + {
- + npcHtmlMessage.setHtml(htmContent);
- + npcHtmlMessage.replace("%max%", String.valueOf(AntiFeedManager.getInstance().getLimit(activeChar, Config.DM_EVENT_MAX_PARTICIPANTS_PER_IP)));
- + }
- + }
- + else if (!payParticipationFee(activeChar))
- + {
- + htmContent = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), htmlPath + "ParticipationFee.htm");
- + if (htmContent != null)
- + {
- + npcHtmlMessage.setHtml(htmContent);
- + npcHtmlMessage.replace("%fee%", getParticipationFee());
- + }
- + }
- + else if (isPlayerParticipant(activeChar))
- + {
- + npcHtmlMessage.setHtml(HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), htmlPath + "Registered.htm"));
- + }
- + else if (addParticipant(activeChar))
- + {
- + npcHtmlMessage.setHtml(HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), htmlPath + "Registered.htm"));
- + }
- + else
- + {
- + return;
- + }
- +
- + activeChar.sendPacket(npcHtmlMessage);
- + }
- + else if (command.equals("dm_event_remove_participation"))
- + {
- + removeParticipant(activeChar);
- + if (Config.TVT_EVENT_MAX_PARTICIPANTS_PER_IP > 0)
- + {
- + AntiFeedManager.getInstance().removePlayer(AntiFeedManager.DM_ID, activeChar);
- + }
- +
- + NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(0);
- +
- + npcHtmlMessage.setHtml(HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), htmlPath + "Unregistered.htm"));
- + activeChar.sendPacket(npcHtmlMessage);
- + }
- + }
- +
- + /**
- + * Called on every onAction in L2PcIstance<br>
- + * <br>
- + * @param activeChar as L2PcInstance<br>
- + * @param targetPlayerName as Integer<br>
- + * @return boolean: true if player is allowed to target, otherwise false<br>
- + */
- + public static boolean onAction(L2PcInstance activeChar, int targetedPlayerObjectId)
- + {
- + if ((activeChar == null) || !isStarted())
- + {
- + return true;
- + }
- + if (activeChar.isGM())
- + {
- + return true;
- + }
- + if (!isPlayerParticipant(activeChar) && isPlayerParticipant(targetedPlayerObjectId))
- + {
- + return false;
- + }
- + if (isPlayerParticipant(activeChar) && !isPlayerParticipant(targetedPlayerObjectId))
- + {
- + return false;
- + }
- +
- + return true;
- + }
- +
- + /**
- + * Called on every scroll use<br>
- + * <br>
- + * @param objectId as Integer<br>
- + * @return boolean: true if player is allowed to use scroll, otherwise false<br>
- + */
- + public static boolean onScrollUse(int objectId)
- + {
- + if (!isStarted())
- + {
- + return true;
- + }
- +
- + if (isPlayerParticipant(objectId) && !Config.DM_EVENT_SCROLL_ALLOWED)
- + {
- + return false;
- + }
- +
- + return true;
- + }
- +
- + /**
- + * Called on every potion use<br>
- + * <br>
- + * @param objectId as Integer<br>
- + * @return boolean: true if player is allowed to use potions, otherwise false<br>
- + */
- + public static boolean onPotionUse(int objectId)
- + {
- + if (!isStarted())
- + {
- + return true;
- + }
- +
- + if (isPlayerParticipant(objectId) && !Config.DM_EVENT_POTIONS_ALLOWED)
- + {
- + return false;
- + }
- +
- + return true;
- + }
- +
- + /**
- + * Called on every escape use<br>
- + * <br>
- + * @param objectId as Integer<br>
- + * @return boolean: true if player is not in DM Event, otherwise false<br>
- + */
- + public static boolean onEscapeUse(int objectId)
- + {
- + if (!isStarted())
- + {
- + return true;
- + }
- +
- + if (isPlayerParticipant(objectId))
- + {
- + return false;
- + }
- +
- + return true;
- + }
- +
- + /**
- + * Called on every summon item use<br>
- + * <br>
- + * @param objectId as Integer<br>
- + * @return boolean: true if player is allowed to summon by item, otherwise false<br>
- + */
- + public static boolean onItemSummon(int objectId)
- + {
- + if (!isStarted())
- + {
- + return true;
- + }
- +
- + if (isPlayerParticipant(objectId) && !Config.DM_EVENT_SUMMON_BY_ITEM_ALLOWED)
- + {
- + return false;
- + }
- +
- + return true;
- + }
- +
- + /**
- + * Is called when a player is killed<br>
- + * <br>
- + * @param killerCharacter as L2Character<br>
- + * @param killedPlayerInstance as L2PcInstance<br>
- + */
- + public static void onKill(L2Character killerCharacter, L2PcInstance killedPlayerInstance)
- + {
- + if ((killedPlayerInstance == null) || !isStarted())
- + {
- + return;
- + }
- +
- + if (!isPlayerParticipant(killedPlayerInstance.getObjectId()))
- + {
- + return;
- + }
- +
- + new DMEventTeleporter(killedPlayerInstance, Config.DM_EVENT_PARTICIPATION_NPC_COORDINATES, false, false);
- +
- + if (killerCharacter == null)
- + {
- + return;
- + }
- +
- + L2PcInstance killerPlayerInstance = null;
- +
- + if ((killerCharacter instanceof L2PetInstance) || (killerCharacter instanceof L2ServitorInstance))
- + {
- + killerPlayerInstance = ((L2Summon) killerCharacter).getOwner();
- + if (killerPlayerInstance == null)
- + {
- + return;
- + }
- + }
- + else if (killerCharacter instanceof L2PcInstance)
- + {
- + killerPlayerInstance = (L2PcInstance) killerCharacter;
- + }
- + else
- + {
- + return;
- + }
- +
- + if (isPlayerParticipant(killerPlayerInstance))
- + {
- + _DMEventPlayer.get(killerPlayerInstance.getObjectId()).increasePoints();
- + killerPlayerInstance.sendPacket(new CreatureSay(killerPlayerInstance.getObjectId(), Say2.TELL, killerPlayerInstance.getName(), "I have killed " + killedPlayerInstance.getName() + "!"));
- +
- + _DMEventPlayer.get(killedPlayerInstance.getObjectId()).increaseDeath();
- + killedPlayerInstance.sendPacket(new CreatureSay(killerPlayerInstance.getObjectId(), Say2.TELL, killerPlayerInstance.getName(), "I killed you!"));
- + }
- + }
- +
- + /**
- + * Called on Appearing packet received (player finished teleporting)<br>
- + * <br>
- + * @param L2PcInstance activeChar
- + */
- + public static void onTeleported(L2PcInstance activeChar)
- + {
- + if (!isStarted() || (activeChar == null) || !isPlayerParticipant(activeChar.getObjectId()))
- + {
- + return;
- + }
- +
- + if (activeChar.isMageClass())
- + {
- + if ((Config.DM_EVENT_MAGE_BUFFS != null) && !Config.DM_EVENT_MAGE_BUFFS.isEmpty())
- + {
- + for (int i : Config.DM_EVENT_MAGE_BUFFS.keys())
- + {
- + L2Skill skill = SkillTable.getInstance().getInfo(i, Config.DM_EVENT_MAGE_BUFFS.get(i));
- + if (skill != null)
- + {
- + skill.getEffects(activeChar, activeChar);
- + }
- + }
- + }
- + }
- + else
- + {
- + if ((Config.DM_EVENT_FIGHTER_BUFFS != null) && !Config.DM_EVENT_FIGHTER_BUFFS.isEmpty())
- + {
- + for (int i : Config.DM_EVENT_FIGHTER_BUFFS.keys())
- + {
- + L2Skill skill = SkillTable.getInstance().getInfo(i, Config.DM_EVENT_FIGHTER_BUFFS.get(i));
- + if (skill != null)
- + {
- + skill.getEffects(activeChar, activeChar);
- + }
- + }
- + }
- + }
- +
- + removeParty(activeChar);
- + }
- +
- + /*
- + * Return true if player valid for skill
- + */
- + public static final boolean checkForDMSkill(L2PcInstance source, L2PcInstance target, L2Skill skill)
- + {
- + if (!isStarted())
- + {
- + return true;
- + }
- +
- + // DM is started
- + final boolean isSourceParticipant = isPlayerParticipant(source);
- + final boolean isTargetParticipant = isPlayerParticipant(target);
- +
- + // both players not participating
- + if (!isSourceParticipant && !isTargetParticipant)
- + {
- + return true;
- + }
- + // one player not participating
- + if (!(isSourceParticipant && isTargetParticipant))
- + {
- + return false;
- + }
- +
- + return true;
- + }
- +
- + public static int getPlayerCounts()
- + {
- + return _DMEventPlayer.size();
- + }
- +
- + public static String[] getFirstPosition(int countPos)
- + {
- + TreeSet<DMEventPlayer> players = orderPosition(_DMEventPlayer.values());
- + String text = "";
- + for (int j = 0; j < countPos; j++)
- + {
- + if (players.isEmpty())
- + {
- + break;
- + }
- +
- + DMEventPlayer player = players.first();
- +
- + if (player.getPoints() == 0)
- + {
- + break;
- + }
- +
- + text += player.getPlayer().getName() + "," + String.valueOf(player.getPoints()) + ";";
- + players.remove(player);
- +
- + int playerPointPrev = player.getPoints();
- +
- + if (!Config.DM_REWARD_TEAM_TIE)
- + {
- + continue;
- + }
- +
- + while (!players.isEmpty())
- + {
- + player = players.first();
- + if (player.getPoints() != playerPointPrev)
- + {
- + break;
- + }
- + text += player.getPlayer().getName() + "," + String.valueOf(player.getPoints()) + ";";
- + players.remove(player);
- + }
- + }
- +
- + if (text != "")
- + {
- + return text.split("\\;");
- + }
- +
- + return null;
- + }
- +
- + /**
- + * Returns the team id of a player, if player is not participant it returns -1<br>
- + * <br>
- + * @param playerName as String<br>
- + * @return byte: team name of the given playerName, if not in event -1<br>
- + */
- + public static byte getParticipantTeamId(int playerObjectId)
- + {
- + return (byte) (_teams[0].containsPlayer(playerObjectId) ? 0 : -1);
- + }
- +
- + public static void removeParty(L2PcInstance activeChar)
- + {
- + if (activeChar.getParty() != null)
- + {
- + L2Party party = activeChar.getParty();
- + party.removePartyMember(activeChar);
- + }
- + }
- +
- + public static byte[] generateHex(int size)
- + {
- + byte[] array = new byte[size];
- + Rnd.nextBytes(array);
- + return array;
- + }
- +
- + public static String hexToString(byte[] hex)
- + {
- + return new BigInteger(hex).toString(16);
- + }
- +
- + public static int getDMEventInstance()
- + {
- + return _DMEventInstance;
- + }
- +
- + /**
- + * @return
- + */
- + public static int[] getTeamsPlayerCounts()
- + {
- + // TODO Auto-generated method stub
- + return null;
- + }
- +
- + /**
- + * @return
- + */
- + public static int[] getTeamsPoints()
- + {
- + // TODO Auto-generated method stub
- + return null;
- + }
- +
- + /**
- + * @param objectId
- + */
- + public static void removeParticipant(int objectId)
- + {
- + // TODO Auto-generated method stub
- +
- + }
- +}
- Index: java/com/l2jserver/gameserver/network/clientpackets/RequestRestartPoint.java
- ===================================================================
- --- java/com/l2jserver/gameserver/network/clientpackets/RequestRestartPoint.java (revision 65)
- +++ java/com/l2jserver/gameserver/network/clientpackets/RequestRestartPoint.java (working copy)
- @@ -25,8 +25,10 @@
- import com.l2jserver.gameserver.model.Location;
- import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
- import com.l2jserver.gameserver.model.actor.instance.L2SiegeFlagInstance;
- +import com.l2jserver.gameserver.model.entity.CTFEvent;
- import com.l2jserver.gameserver.model.entity.Castle;
- import com.l2jserver.gameserver.model.entity.ClanHall;
- +import com.l2jserver.gameserver.model.entity.DMEvent;
- import com.l2jserver.gameserver.model.entity.Fort;
- import com.l2jserver.gameserver.model.entity.TvTEvent;
- import com.l2jserver.gameserver.model.entity.TvTRoundEvent;
- @@ -75,6 +77,16 @@
- return;
- }
- + if (CTFEvent.isStarted() && CTFEvent.isPlayerParticipant(activeChar.getObjectId()))
- + {
- + return;
- + }
- +
- + if (DMEvent.isStarted() && DMEvent.isPlayerParticipant(activeChar.getObjectId()))
- + {
- + return;
- + }
- +
- if (TvTEvent.isStarted() && TvTEvent.isPlayerParticipant(activeChar.getObjectId()))
- {
- return;
- @@ -82,7 +94,7 @@
- if (TvTRoundEvent.isStarted() && TvTRoundEvent.isPlayerParticipant(activeChar.getObjectId()))
- {
- - return;
- + return;
- }
- if (activeChar.isFakeDeath())
- @@ -142,9 +154,13 @@
- return;
- }
- if (activeChar.isInTownWarEvent())
- - loc = MapRegionManager.getInstance().getTeleToLocation(activeChar, MapRegionManager.TeleportWhereType.Town);
- + {
- + loc = MapRegionManager.getInstance().getTeleToLocation(activeChar, MapRegionManager.TeleportWhereType.Town);
- + }
- else
- - loc = MapRegionManager.getInstance().getTeleToLocation(activeChar, MapRegionManager.TeleportWhereType.ClanHall);
- + {
- + loc = MapRegionManager.getInstance().getTeleToLocation(activeChar, MapRegionManager.TeleportWhereType.ClanHall);
- + }
- if ((ClanHallManager.getInstance().getClanHallByOwner(activeChar.getClan()) != null) && (ClanHallManager.getInstance().getClanHallByOwner(activeChar.getClan()).getFunction(ClanHall.FUNC_RESTORE_EXP) != null))
- {
- Index: java/com/l2jserver/gameserver/GameServer.java
- ===================================================================
- --- java/com/l2jserver/gameserver/GameServer.java (revision 65)
- +++ java/com/l2jserver/gameserver/GameServer.java (working copy)
- @@ -124,6 +124,8 @@
- import com.l2jserver.gameserver.model.L2World;
- import com.l2jserver.gameserver.model.PartyMatchRoomList;
- import com.l2jserver.gameserver.model.PartyMatchWaitingList;
- +import com.l2jserver.gameserver.model.entity.CTFManager;
- +import com.l2jserver.gameserver.model.entity.DMManager;
- import com.l2jserver.gameserver.model.entity.Hero;
- import com.l2jserver.gameserver.model.entity.Hitman;
- import com.l2jserver.gameserver.model.entity.TownWarManager;
- @@ -143,7 +145,6 @@
- import com.l2jserver.util.DeadLockDetector;
- import com.l2jserver.util.IPv4Filter;
- -
- public class GameServer
- {
- private static final Logger _log = Logger.getLogger(GameServer.class.getName());
- @@ -254,7 +255,7 @@
- PetDataTable.getInstance();
- CharSummonTable.getInstance().init();
- - printSection("Clans");
- + printSection("Clans");
- ClanTable.getInstance();
- CHSiegeManager.getInstance();
- ClanHallManager.getInstance();
- @@ -282,9 +283,11 @@
- SpawnTable.getInstance();
- ColosseumFencesTable.getInstance();
- HellboundManager.getInstance();
- -
- +
- if (Config.ENABLE_BONUS_MANAGER)
- + {
- BonusExpManager.getInstance();
- + }
- RaidBossSpawnManager.getInstance();
- DayNightSpawnManager.getInstance().trim().notifyChangeMode();
- @@ -347,7 +350,7 @@
- if (Config.SAVE_DROPPED_ITEM)
- {
- ItemsOnGroundManager.getInstance();
- -
- +
- }
- if ((Config.AUTODESTROY_ITEM_AFTER > 0) || (Config.HERB_AUTO_DESTROY_TIME > 0))
- @@ -372,21 +375,29 @@
- {
- CoupleManager.getInstance();
- }
- -
- +
- if (Config.RANK_ARENA_ENABLED)
- + {
- ArenaLeaderboard.getInstance();
- + }
- if (Config.RANK_FISHERMAN_ENABLED)
- + {
- FishermanLeaderboard.getInstance();
- + }
- if (Config.RANK_CRAFT_ENABLED)
- + {
- CraftLeaderboard.getInstance();
- + }
- if (Config.RANK_TVT_ENABLED)
- + {
- TvTLeaderboard.getInstance();
- + }
- TaskManager.getInstance();
- -
- +
- AntiFeedManager.getInstance().registerEvent(AntiFeedManager.GAME_ID);
- MerchantPriceConfigTable.getInstance().updateReferences();
- CastleManager.getInstance().activateInstances();
- @@ -406,6 +417,8 @@
- _log.info("IdFactory: Free ObjectID's remaining: " + IdFactory.getInstance().size());
- + CTFManager.getInstance();
- + DMManager.getInstance();
- TvTManager.getInstance();
- TvTRoundManager.getInstance();
- TownWarManager.getInstance();
- Index: java/com/l2jserver/gameserver/model/entity/CTFEventTeam.java
- ===================================================================
- --- java/com/l2jserver/gameserver/model/entity/CTFEventTeam.java (revision 0)
- +++ java/com/l2jserver/gameserver/model/entity/CTFEventTeam.java (working copy)
- @@ -0,0 +1,183 @@
- +/*
- + * This program is free software: you can redistribute it and/or modify it under
- + * the terms of the GNU General Public License as published by the Free Software
- + * Foundation, either version 3 of the License, or (at your option) any later
- + * version.
- + *
- + * This program is distributed in the hope that it will be useful, but WITHOUT
- + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- + * details.
- + *
- + * You should have received a copy of the GNU General Public License along with
- + * this program. If not, see <http://www.gnu.org/licenses/>.
- + */
- +
- +package com.l2jserver.gameserver.model.entity;
- +
- +import java.util.Map;
- +
- +import javolution.util.FastMap;
- +
- +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
- +
- +/**
- + * @author FBIagent, edited U3Games
- + */
- +
- +public class CTFEventTeam
- +{
- + /** The name of the team<br> */
- + private String _name;
- + /** The team spot coordinated<br> */
- + private int[] _coordinates = new int[3];
- + /** The points of the team<br> */
- + private short _points;
- + /** Name and instance of all participated players in FastMap<br> */
- + private Map<Integer, L2PcInstance> _participatedPlayers = new FastMap<Integer, L2PcInstance>();
- +
- + /**
- + * C'tor initialize the team<br><br>
- + *
- + * @param name as String<br>
- + * @param coordinates as int[]<br>
- + */
- + public CTFEventTeam(String name, int[] coordinates)
- + {
- + _name = name;
- + _coordinates = coordinates;
- + _points = 0;
- + }
- +
- + /**
- + * Adds a player to the team<br><br>
- + *
- + * @param playerInstance as L2PcInstance<br>
- + * @return boolean: true if success, otherwise false<br>
- + */
- + public boolean addPlayer(L2PcInstance playerInstance)
- + {
- + if (playerInstance == null)
- + {
- + return false;
- + }
- +
- + synchronized (_participatedPlayers)
- + {
- + _participatedPlayers.put(playerInstance.getObjectId(), playerInstance);
- + }
- +
- + return true;
- + }
- +
- + /**
- + * Removes a player from the team
- + * @param playerObjectId
- + */
- + public void removePlayer(int playerObjectId)
- + {
- + synchronized (_participatedPlayers)
- + {
- + _participatedPlayers.remove(playerObjectId);
- + }
- + }
- +
- + /**
- + * Increases the points of the team<br>
- + */
- + public void increasePoints()
- + {
- + ++_points;
- + }
- +
- + /**
- + * Cleanup the team and make it ready for adding players again<br>
- + */
- + public void cleanMe()
- + {
- + _participatedPlayers.clear();
- + _participatedPlayers = new FastMap<Integer, L2PcInstance>();
- + _points = 0;
- + }
- +
- + /**
- + * Is given player in this team?
- + * @param playerObjectId
- + * @return boolean: true if player is in this team, otherwise false
- + */
- + public boolean containsPlayer(int playerObjectId)
- + {
- + boolean containsPlayer;
- +
- + synchronized (_participatedPlayers)
- + {
- + containsPlayer = _participatedPlayers.containsKey(playerObjectId);
- + }
- +
- + return containsPlayer;
- + }
- +
- + /**
- + * Returns the name of the team<br><br>
- + *
- + * @return String: name of the team<br>
- + */
- + public String getName()
- + {
- + return _name;
- + }
- +
- + /**
- + * Returns the coordinates of the team spot<br><br>
- + *
- + * @return int[]: team coordinates<br>
- + */
- + public int[] getCoordinates()
- + {
- + return _coordinates;
- + }
- +
- + /**
- + * Returns the points of the team<br><br>
- + *
- + * @return short: team points<br>
- + */
- + public short getPoints()
- + {
- + return _points;
- + }
- +
- + /**
- + * Returns name and instance of all participated players in FastMap<br><br>
- + *
- + * @return Map<String, L2PcInstance>: map of players in this team<br>
- + */
- + public Map<Integer, L2PcInstance> getParticipatedPlayers()
- + {
- + Map<Integer, L2PcInstance> participatedPlayers = null;
- +
- + synchronized (_participatedPlayers)
- + {
- + participatedPlayers = _participatedPlayers;
- + }
- +
- + return participatedPlayers;
- + }
- +
- + /**
- + * Returns player count of this team<br><br>
- + *
- + * @return int: number of players in team<br>
- + */
- + public int getParticipatedPlayerCount()
- + {
- + int participatedPlayerCount;
- +
- + synchronized (_participatedPlayers)
- + {
- + participatedPlayerCount = _participatedPlayers.size();
- + }
- +
- + return participatedPlayerCount;
- + }
- +}
- Index: java/com/l2jserver/gameserver/model/actor/instance/L2CastleMagicianInstance.java
- ===================================================================
- --- java/com/l2jserver/gameserver/model/actor/instance/L2CastleMagicianInstance.java (revision 65)
- +++ java/com/l2jserver/gameserver/model/actor/instance/L2CastleMagicianInstance.java (working copy)
- @@ -27,6 +27,8 @@
- import com.l2jserver.gameserver.model.actor.templates.L2NpcTemplate;
- import com.l2jserver.gameserver.model.base.AcquireSkillType;
- import com.l2jserver.gameserver.model.effects.L2EffectType;
- +import com.l2jserver.gameserver.model.entity.CTFEvent;
- +import com.l2jserver.gameserver.model.entity.DMEvent;
- import com.l2jserver.gameserver.model.entity.TvTEvent;
- import com.l2jserver.gameserver.model.entity.TvTRoundEvent;
- import com.l2jserver.gameserver.model.zone.ZoneId;
- @@ -500,6 +502,31 @@
- }
- }
- + if (!CTFEvent.onEscapeUse(player.getObjectId()))
- + {
- + player.sendMessage("You on CTF Event, teleporting disabled.");
- + return false;
- + }
- +
- + if (!CTFEvent.onEscapeUse(clanLeader.getObjectId()))
- + {
- + // Need retail message if there's one.
- + player.sendMessage("Couldn't teleport to clan leader. The requirements was not meet.");
- + return false;
- + }
- +
- + if (!DMEvent.onEscapeUse(player.getObjectId()))
- + {
- + player.sendMessage("You on DM Event, teleporting disabled.");
- + return false;
- + }
- +
- + if (!DMEvent.onEscapeUse(clanLeader.getObjectId()))
- + {
- + // Need retail message if there's one.
- + player.sendMessage("Couldn't teleport to clan leader. The requirements was not meet.");
- + return false;
- + }
- if (!TvTEvent.onEscapeUse(player.getObjectId()))
- {
- player.sendMessage("You on TvT Event, teleporting disabled.");
- @@ -512,7 +539,7 @@
- player.sendMessage("Couldn't teleport to clan leader. The requirements was not meet.");
- return false;
- }
- -
- +
- if (!TvTRoundEvent.onEscapeUse(player.getObjectId()))
- {
- player.sendMessage("You on TvT Round Event, teleporting disabled.");
- Index: java/com/l2jserver/gameserver/network/L2GameClient.java
- ===================================================================
- --- java/com/l2jserver/gameserver/network/L2GameClient.java (revision 65)
- +++ java/com/l2jserver/gameserver/network/L2GameClient.java (working copy)
- @@ -45,8 +45,9 @@
- import com.l2jserver.gameserver.model.L2Clan;
- import com.l2jserver.gameserver.model.L2World;
- import com.l2jserver.gameserver.model.PcCondOverride;
- -import com.l2jserver.gameserver.model.actor.L2Character;
- import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
- +import com.l2jserver.gameserver.model.entity.CTFEvent;
- +import com.l2jserver.gameserver.model.entity.DMEvent;
- import com.l2jserver.gameserver.model.entity.L2Event;
- import com.l2jserver.gameserver.model.entity.TvTEvent;
- import com.l2jserver.gameserver.model.entity.TvTRoundEvent;
- @@ -798,7 +799,7 @@
- protected boolean offlineMode(L2PcInstance player)
- {
- boolean canSetShop = false;
- - if (player.isInOlympiadMode() || player.isFestivalParticipant() || TvTEvent.isPlayerParticipant(player.getObjectId()) || TvTRoundEvent.isPlayerParticipant(player.getObjectId()) || player.isInJail() || (player.getVehicle() != null))
- + if (player.isInOlympiadMode() || player.isFestivalParticipant() || TvTEvent.isPlayerParticipant(player.getObjectId()) || CTFEvent.isPlayerParticipant(player.getObjectId()) || DMEvent.isPlayerParticipant(player.getObjectId()) || TvTRoundEvent.isPlayerParticipant(player.getObjectId()) || player.isInJail() || (player.getVehicle() != null))
- {
- return false;
- }
- Index: java/com/l2jserver/gameserver/model/skills/l2skills/L2SkillTeleport.java
- ===================================================================
- --- java/com/l2jserver/gameserver/model/skills/l2skills/L2SkillTeleport.java (revision 65)
- +++ java/com/l2jserver/gameserver/model/skills/l2skills/L2SkillTeleport.java (working copy)
- @@ -25,6 +25,8 @@
- import com.l2jserver.gameserver.model.StatsSet;
- import com.l2jserver.gameserver.model.actor.L2Character;
- import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
- +import com.l2jserver.gameserver.model.entity.CTFEvent;
- +import com.l2jserver.gameserver.model.entity.DMEvent;
- import com.l2jserver.gameserver.model.entity.TvTEvent;
- import com.l2jserver.gameserver.model.entity.TvTRoundEvent;
- import com.l2jserver.gameserver.model.skills.L2Skill;
- @@ -56,7 +58,7 @@
- @Override
- public void useSkill(L2Character activeChar, L2Object[] targets)
- - {
- + {
- boolean bss = isMagic() && activeChar.isChargedShot(ShotType.BLESSED_SPIRITSHOTS);
- if (activeChar.isPlayer())
- @@ -67,7 +69,19 @@
- activeChar.sendPacket(ActionFailed.STATIC_PACKET);
- return;
- }
- -
- +
- + if (!CTFEvent.onEscapeUse(activeChar.getActingPlayer().getObjectId()))
- + {
- + activeChar.sendPacket(ActionFailed.STATIC_PACKET);
- + return;
- + }
- +
- + if (!DMEvent.onEscapeUse(activeChar.getActingPlayer().getObjectId()))
- + {
- + activeChar.sendPacket(ActionFailed.STATIC_PACKET);
- + return;
- + }
- +
- if (!TvTRoundEvent.onEscapeUse(((L2PcInstance) activeChar).getObjectId()))
- {
- activeChar.sendPacket(ActionFailed.STATIC_PACKET);
- @@ -134,12 +148,22 @@
- {
- continue;
- }
- -
- - if (!TvTRoundEvent.onEscapeUse(targetChar.getObjectId()))
- +
- + if (!CTFEvent.onEscapeUse(targetChar.getObjectId()))
- {
- continue;
- }
- -
- +
- + if (!DMEvent.onEscapeUse(targetChar.getObjectId()))
- + {
- + continue;
- + }
- +
- + if (!TvTRoundEvent.onEscapeUse(targetChar.getObjectId()))
- + {
- + continue;
- + }
- +
- if (targetChar.isInOlympiadMode())
- {
- continue;
- Index: java/com/l2jserver/Config.java
- ===================================================================
- --- java/com/l2jserver/Config.java (revision 65)
- +++ java/com/l2jserver/Config.java (working copy)
- @@ -15,7 +15,6 @@
- package com.l2jserver;
- import info.tak11.subnet.Subnet;
- -import gnu.trove.map.hash.TIntFloatHashMap;
- import java.io.BufferedReader;
- import java.io.File;
- @@ -58,6 +57,9 @@
- import com.l2jserver.util.L2Properties;
- import com.l2jserver.util.StringUtil;
- +import gnu.trove.map.hash.TIntFloatHashMap;
- +import gnu.trove.map.hash.TIntIntHashMap;
- +
- /**
- * This class loads all the game server related configurations from files.<br>
- * The files are usually located in config folder in server root folder.<br>
- @@ -117,8 +119,8 @@
- public static String PKS_COLORS;
- public static FastMap<Integer, Integer> PKS_COLORS_LIST;
- public static boolean ANNOUNCE_CASTLE_LORDS;
- - //balance
- - public static float DAGGER_VS_HEAVY;
- + // balance
- + public static float DAGGER_VS_HEAVY;
- public static float DAGGER_VS_LIGHT;
- public static float DAGGER_VS_ROBE;
- public static float ARCHER_VS_HEAVY;
- @@ -139,9 +141,9 @@
- public static float POLE_VS_HEAVY;
- public static float POLE_VS_LIGHT;
- public static float POLE_VS_ROBE;
- - //--------------------------------------------------
- + // --------------------------------------------------
- // PC bang points
- - //--------------------------------------------------
- + // --------------------------------------------------
- public static boolean PC_BANG_ENABLED;
- public static int MAX_PC_BANG_POINTS;
- public static boolean ENABLE_DOUBLE_PC_BANG_POINTS;
- @@ -150,30 +152,30 @@
- public static boolean RANDOM_PC_BANG_POINT;
- public static boolean ENABLE_BONUS_MANAGER;
- public static boolean Boost_EXP_COMMAND;
- - //--------------------------------------------------
- + // --------------------------------------------------
- // Premium Settings
- - //--------------------------------------------------
- - public static boolean USE_PREMIUMSERVICE;
- - public static boolean PREMIUM_INFO;
- - public static float PREMIUM_RATE_XP;
- - public static float PREMIUM_RATE_SP;
- - public static float PREMIUM_RATE_DROP_ITEMS;
- - public static float PREMIUM_RATE_DROP_ITEMS_BY_RAID;
- - public static float PREMIUM_RATE_DROP_SPOIL;
- - public static TIntFloatHashMap PREMIUM_RATE_DROP_ITEMS_ID;
- + // --------------------------------------------------
- + public static boolean USE_PREMIUMSERVICE;
- + public static boolean PREMIUM_INFO;
- + public static float PREMIUM_RATE_XP;
- + public static float PREMIUM_RATE_SP;
- + public static float PREMIUM_RATE_DROP_ITEMS;
- + public static float PREMIUM_RATE_DROP_ITEMS_BY_RAID;
- + public static float PREMIUM_RATE_DROP_SPOIL;
- + public static TIntFloatHashMap PREMIUM_RATE_DROP_ITEMS_ID;
- public static boolean ENABLE_BOTREPORT;
- - public static boolean ALT_ALLOW_REFINE_PVP_ITEM;
- + public static boolean ALT_ALLOW_REFINE_PVP_ITEM;
- public static boolean HB_NEEDS_QUEST;
- public static boolean PVP_MANAPOTION;
- public static boolean ENABLE_UNSTUCK_PVP;
- public static boolean USE_CR_ITEM;
- - public static int CR_ITEM_MIN_CLAN_LVL;
- - public static int CR_ITEM_REPS_TO_BE_AWARDED;
- - public static int CR_ITEM_REPS_ITEM_ID;
- - public static boolean NOBLE_CUSTOM_ITEMS;
- - public static int NOOBLE_CUSTOM_ITEM_ID;
- + public static int CR_ITEM_MIN_CLAN_LVL;
- + public static int CR_ITEM_REPS_TO_BE_AWARDED;
- + public static int CR_ITEM_REPS_ITEM_ID;
- + public static boolean NOBLE_CUSTOM_ITEMS;
- + public static int NOOBLE_CUSTOM_ITEM_ID;
- public static int GAME_POINT_ITEM_ID;
- - //Npc Buffer
- + // Npc Buffer
- public static boolean NpcBuffer_Reload;
- public static boolean NpcBuffer_SmartWindow;
- public static boolean NpcBuffer_VIP;
- @@ -213,10 +215,10 @@
- public static int TOPID;
- public static boolean TOPDEBUG;
- public static boolean CHAR_TITLE;
- - public static String ADD_CHAR_TITLE;
- + public static String ADD_CHAR_TITLE;
- // ---------------------------------------------------
- // Event Custom Config
- - //----------------------------------------------------
- + // ----------------------------------------------------
- public static int TW_TOWN_ID;
- public static String TW_TOWN_NAME;
- public static boolean TW_ALL_TOWNS;
- @@ -232,7 +234,7 @@
- public static boolean TW_RESS_ON_DEATH;
- public static boolean TW_RANDOM_SPAWN;
- public static boolean TW_LOSE_BUFFS_ON_DEATH;
- - //Tvt Round
- + // Tvt Round
- public static boolean TVT_ROUND_EVENT_ENABLED;
- public static boolean TVT_ROUND_EVENT_IN_INSTANCE;
- public static String TVT_ROUND_EVENT_INSTANCE_FILE;
- @@ -276,17 +278,17 @@
- public static boolean TVT_ROUND_ALLOW_VOICED_COMMAND;
- public static boolean ALLOW_HITMAN_GDE;
- public static boolean HITMAN_GDE_TAKE_KARMA;
- - //Hide and Seek
- - public static boolean ALT_HAS_ENABLE;
- - public static int ALT_HAS_TIME_REG;
- - public static int ALT_HAS_TIME_EVENT;
- - public static int ALT_HAS_NPC;
- - public static boolean ALT_HAS_PKJOIN;
- - public static boolean ALT_HAS_SECUENTIAL;
- - public static int ALT_HAS_MINLEVEL;
- - public static int ALT_HAS_MAXLEVEL;
- - public static int ALT_HAS_MINPLAYERS;
- - public static int ALT_HAS_MAXPLAYERS;
- + // Hide and Seek
- + public static boolean ALT_HAS_ENABLE;
- + public static int ALT_HAS_TIME_REG;
- + public static int ALT_HAS_TIME_EVENT;
- + public static int ALT_HAS_NPC;
- + public static boolean ALT_HAS_PKJOIN;
- + public static boolean ALT_HAS_SECUENTIAL;
- + public static int ALT_HAS_MINLEVEL;
- + public static int ALT_HAS_MAXLEVEL;
- + public static int ALT_HAS_MINPLAYERS;
- + public static int ALT_HAS_MAXPLAYERS;
- public static boolean RANK_ARENA_ACCEPT_SAME_IP;
- public static boolean RANK_ARENA_ENABLED;
- public static int RANK_ARENA_INTERVAL;
- @@ -304,6 +306,67 @@
- public static int RANK_TVT_INTERVAL;
- public static int RANK_TVT_REWARD_ID;
- public static int RANK_TVT_REWARD_COUNT;
- + public static boolean CTF_EVENT_ENABLED;
- + public static boolean CTF_EVENT_IN_INSTANCE;
- + public static String CTF_EVENT_INSTANCE_FILE;
- + public static String[] CTF_EVENT_INTERVAL;
- + public static int CTF_EVENT_PARTICIPATION_TIME;
- + public static int CTF_EVENT_RUNNING_TIME;
- + public static int CTF_EVENT_PARTICIPATION_NPC_ID;
- + public static int[] CTF_EVENT_PARTICIPATION_NPC_COORDINATES = new int[4];
- + public static int[] CTF_EVENT_PARTICIPATION_FEE = new int[2];
- + public static int CTF_EVENT_MIN_PLAYERS_IN_TEAMS;
- + public static int CTF_EVENT_MAX_PLAYERS_IN_TEAMS;
- + public static int CTF_EVENT_RESPAWN_TELEPORT_DELAY;
- + public static int CTF_EVENT_START_LEAVE_TELEPORT_DELAY;
- + public static String CTF_EVENT_TEAM_1_NAME;
- + public static int[] CTF_EVENT_TEAM_1_COORDINATES = new int[3];
- + public static String CTF_EVENT_TEAM_2_NAME;
- + public static int[] CTF_EVENT_TEAM_2_COORDINATES = new int[3];
- + public static List<int[]> CTF_EVENT_REWARDS;
- + public static boolean CTF_EVENT_TARGET_TEAM_MEMBERS_ALLOWED;
- + public static boolean CTF_EVENT_SCROLL_ALLOWED;
- + public static boolean CTF_EVENT_POTIONS_ALLOWED;
- + public static boolean CTF_EVENT_SUMMON_BY_ITEM_ALLOWED;
- + public static List<Integer> CTF_DOORS_IDS_TO_OPEN;
- + public static List<Integer> CTF_DOORS_IDS_TO_CLOSE;
- + public static boolean CTF_REWARD_TEAM_TIE;
- + public static byte CTF_EVENT_MIN_LVL;
- + public static byte CTF_EVENT_MAX_LVL;
- + public static int CTF_EVENT_EFFECTS_REMOVAL;
- + public static TIntIntHashMap CTF_EVENT_FIGHTER_BUFFS;
- + public static TIntIntHashMap CTF_EVENT_MAGE_BUFFS;
- + public static int CTF_EVENT_MAX_PARTICIPANTS_PER_IP;
- + public static boolean CTF_ALLOW_VOICED_COMMAND;
- + public static boolean DM_EVENT_ENABLED;
- + public static boolean DM_EVENT_IN_INSTANCE;
- + public static String DM_EVENT_INSTANCE_FILE;
- + public static String[] DM_EVENT_INTERVAL;
- + public static int DM_EVENT_PARTICIPATION_TIME;
- + public static int DM_EVENT_RUNNING_TIME;
- + public static int DM_EVENT_PARTICIPATION_NPC_ID;
- + public static boolean DM_EVENT_SHOW_TOP_RANK;
- + public static int DM_EVENT_TOP_RANK;
- + public static int[] DM_EVENT_PARTICIPATION_NPC_COORDINATES = new int[4];
- + public static int[] DM_EVENT_PARTICIPATION_FEE = new int[2];
- + public static int DM_EVENT_MIN_PLAYERS;
- + public static int DM_EVENT_MAX_PLAYERS;
- + public static int DM_EVENT_RESPAWN_TELEPORT_DELAY;
- + public static int DM_EVENT_START_LEAVE_TELEPORT_DELAY;
- + public static List<int[]> DM_EVENT_REWARDS;
- + public static boolean DM_EVENT_SCROLL_ALLOWED;
- + public static boolean DM_EVENT_POTIONS_ALLOWED;
- + public static boolean DM_EVENT_SUMMON_BY_ITEM_ALLOWED;
- + public static List<Integer> DM_DOORS_IDS_TO_OPEN;
- + public static List<Integer> DM_DOORS_IDS_TO_CLOSE;
- + public static boolean DM_REWARD_TEAM_TIE;
- + public static byte DM_EVENT_MIN_LVL;
- + public static byte DM_EVENT_MAX_LVL;
- + public static int DM_EVENT_EFFECTS_REMOVAL;
- + public static TIntIntHashMap DM_EVENT_FIGHTER_BUFFS;
- + public static TIntIntHashMap DM_EVENT_MAGE_BUFFS;
- + public static int DM_EVENT_MAX_PARTICIPANTS_PER_IP;
- + public static boolean DM_ALLOW_VOICED_COMMAND;
- // --------------------------------------------------
- // L2J Variable Definitions
- // --------------------------------------------------
- @@ -884,8 +947,8 @@
- public static int L2JMOD_CHAMP_MAX_LVL;
- public static int L2JMOD_CHAMPION_HP;
- public static int L2JMOD_CHAMPION_REWARDS;
- - public static int L2JMOD_CHAMPION_REWARDS_XP;
- - public static int L2JMOD_CHAMPION_REWARDS_SP;
- + public static int L2JMOD_CHAMPION_REWARDS_XP;
- + public static int L2JMOD_CHAMPION_REWARDS_SP;
- public static float L2JMOD_CHAMPION_ADENAS_REWARDS;
- public static float L2JMOD_CHAMPION_HP_REGEN;
- public static float L2JMOD_CHAMPION_ATK;
- @@ -1272,11 +1335,11 @@
- public static int ZAKEN_MAXMEMBERS_NIGHTTIME;
- public static int FRINTEZZA_MAXPLAYERS;
- public static int MIN_FREYA_PLAYERS;
- - public static int MAX_FREYA_PLAYERS;
- - public static int MIN_LEVEL_PLAYERS;
- - public static int MIN_FREYA_HC_PLAYERS;
- - public static int MAX_FREYA_HC_PLAYERS;
- - public static int MIN_LEVEL_HC_PLAYERS;
- + public static int MAX_FREYA_PLAYERS;
- + public static int MIN_LEVEL_PLAYERS;
- + public static int MIN_FREYA_HC_PLAYERS;
- + public static int MAX_FREYA_HC_PLAYERS;
- + public static int MIN_LEVEL_HC_PLAYERS;
- // Gracia Seeds Settings
- @@ -1652,428 +1715,681 @@
- try (InputStream is = new FileInputStream(Avenger))
- {
- Avengers.load(is);
- -
- -
- - BODY_ZA_MINUTU = Integer.parseInt(Avengers.getProperty("BodyZaMinutu", "20"));
- - GUARD_ID = Integer.parseInt(Avengers.getProperty("GuardId", "36602"));
- - CLAN_LEADER_COLOR_ENABLED = Boolean.parseBoolean(Avengers.getProperty("ClanLeaderNameColorEnabled", "False"));
- - CLAN_LEADER_COLOR = Integer.decode((new StringBuilder()).append("0x").append(Avengers.getProperty("ClanLeaderColor", "00FFFF")).toString()).intValue();
- - CLAN_LEADER_COLOR_CLAN_LEVEL = Integer.parseInt(Avengers.getProperty("ClanLeaderColorAtClanLevel", "1"));
- - ANNOUNCE_CASTLE_LORDS = Boolean.parseBoolean(Avengers.getProperty("AnnounceCastleLords", "false"));
- - DAGGER_VS_HEAVY = Float.parseFloat(Avengers.getProperty("DaggerVsHeavy", "1.00"));
- - DAGGER_VS_LIGHT = Float.parseFloat(Avengers.getProperty("DaggerVsLight", "1.00"));
- - DAGGER_VS_ROBE = Float.parseFloat(Avengers.getProperty("DaggerVsRobe", "1.00"));
- - ARCHER_VS_HEAVY = Float.parseFloat(Avengers.getProperty("ArcherVsHeavy", "1.00"));
- - ARCHER_VS_LIGHT = Float.parseFloat(Avengers.getProperty("ArcherVsLight", "1.00"));
- - ARCHER_VS_ROBE = Float.parseFloat(Avengers.getProperty("ArcherVsRobe", "1.00"));
- - BLUNT_VS_HEAVY = Float.parseFloat(Avengers.getProperty("BluntVsHeavy", "1.00"));
- - BLUNT_VS_LIGHT = Float.parseFloat(Avengers.getProperty("BluntVsLight", "1.00"));
- - BLUNT_VS_ROBE = Float.parseFloat(Avengers.getProperty("BluntVsRobe", "1.00"));
- - FIST_VS_HEAVY = Float.parseFloat(Avengers.getProperty("FistVsHeavy", "1.00"));
- - FIST_VS_LIGHT = Float.parseFloat(Avengers.getProperty("FistVsLight", "1.00"));
- - FIST_VS_ROBE = Float.parseFloat(Avengers.getProperty("FistVsRobe", "1.00"));
- - DUAL_VS_HEAVY = Float.parseFloat(Avengers.getProperty("DualVsHeavy", "1.00"));
- - DUAL_VS_LIGHT = Float.parseFloat(Avengers.getProperty("DualVsLight", "1.00"));
- - DUAL_VS_ROBE = Float.parseFloat(Avengers.getProperty("DualVsRobe", "1.00"));
- - SWORD_VS_HEAVY = Float.parseFloat(Avengers.getProperty("SwordVsHeavy", "1.00"));
- - SWORD_VS_LIGHT = Float.parseFloat(Avengers.getProperty("SwordVsLight", "1.00"));
- - SWORD_VS_ROBE = Float.parseFloat(Avengers.getProperty("SwordVsRobe", "1.00"));
- - POLE_VS_HEAVY = Float.parseFloat(Avengers.getProperty("PoleVsHeavy", "1.00"));
- - POLE_VS_LIGHT = Float.parseFloat(Avengers.getProperty("PoleVsLight", "1.00"));
- - POLE_VS_ROBE = Float.parseFloat(Avengers.getProperty("PoleVsRobe", "1.00"));
- - PC_BANG_ENABLED = Boolean.parseBoolean(Avengers.getProperty("Enabled", "false"));
- - ENABLE_BOTREPORT = Boolean.valueOf(Avengers.getProperty("EnableBotReport", "false"));
- - ALT_ALLOW_REFINE_PVP_ITEM = Boolean.parseBoolean(Avengers.getProperty("AltAllowRefinePVPItem", "False"));
- - HB_NEEDS_QUEST = Boolean.parseBoolean(Avengers.getProperty("HBNeedsQuest", "True"));
- - PVP_MANAPOTION = Boolean.parseBoolean(Avengers.getProperty("PvPManaPotion", "True"));
- - ENABLE_UNSTUCK_PVP = Boolean.parseBoolean(Avengers.getProperty("EnableUnstuckPvP", "True"));
- - USE_CR_ITEM = Boolean.parseBoolean(Avengers.getProperty("EnableTheClanRepPointsItem", "False"));
- - CR_ITEM_MIN_CLAN_LVL = Integer.parseInt(Avengers.getProperty("MinClanLevelNeededForCR", "7"));
- - CR_ITEM_REPS_TO_BE_AWARDED = Integer.parseInt(Avengers.getProperty("HowManyClanRepsToGive", "500"));
- - CR_ITEM_REPS_ITEM_ID = Integer.parseInt(Avengers.getProperty("CRItemID", "6673"));
- - NOBLE_CUSTOM_ITEMS = Boolean.parseBoolean(Avengers.getProperty("EnableNobleCustomItem", "true"));
- - NOOBLE_CUSTOM_ITEM_ID = Integer.parseInt(Avengers.getProperty("NoobleCustomItemId", "6673"));
- - GAME_POINT_ITEM_ID = Integer.parseInt(Avengers.getProperty("GamePointItemId", "-300"));
- - NpcBuffer_Reload = Boolean.parseBoolean(Avengers.getProperty("EnableReloadScript", "False"));
- - NpcBuffer_SmartWindow = Boolean.parseBoolean(Avengers.getProperty("EnableSmartWindow", "True"));
- - NpcBuffer_VIP = Boolean.parseBoolean(Avengers.getProperty("EnableVIP", "False"));
- - NpcBuffer_VIP_ALV= Integer.parseInt(Avengers.getProperty("VipAccesLevel", "1"));
- - NpcBuffer_EnableBuff = Boolean.parseBoolean(Avengers.getProperty("EnableBuffSection", "True"));
- - NpcBuffer_EnableScheme = Boolean.parseBoolean(Avengers.getProperty("EnableScheme", "True"));
- - NpcBuffer_EnableHeal = Boolean.parseBoolean(Avengers.getProperty("EnableHeal", "True"));
- - NpcBuffer_EnableBuffs = Boolean.parseBoolean(Avengers.getProperty("EnableBuffs", "True"));
- - NpcBuffer_EnableResist = Boolean.parseBoolean(Avengers.getProperty("EnableResist", "True"));
- - NpcBuffer_EnableSong = Boolean.parseBoolean(Avengers.getProperty("EnableSongs", "True"));
- - NpcBuffer_EnableDance = Boolean.parseBoolean(Avengers.getProperty("EnableDances", "True"));
- - NpcBuffer_EnableChant = Boolean.parseBoolean(Avengers.getProperty("EnableChants", "True"));
- - NpcBuffer_EnableOther = Boolean.parseBoolean(Avengers.getProperty("EnableOther", "True"));
- - NpcBuffer_EnableSpecial = Boolean.parseBoolean(Avengers.getProperty("EnableSpecial", "True"));
- - NpcBuffer_EnableCubic = Boolean.parseBoolean(Avengers.getProperty("EnableCubic", "True"));
- - NpcBuffer_EnableCancel = Boolean.parseBoolean(Avengers.getProperty("EnableRemoveBuffs", "True"));
- - NpcBuffer_EnableBuffSet = Boolean.parseBoolean(Avengers.getProperty("EnableBuffSet", "True"));
- - NpcBuffer_EnableBuffPK = Boolean.parseBoolean(Avengers.getProperty("EnableBuffForPK", "False"));
- - NpcBuffer_EnableFreeBuffs = Boolean.parseBoolean(Avengers.getProperty("EnableFreeBuffs", "True"));
- - NpcBuffer_EnableTimeOut = Boolean.parseBoolean(Avengers.getProperty("EnableTimeOut", "True"));
- - NpcBuffer_TimeOutTime = Integer.parseInt(Avengers.getProperty("TimeoutTime", "10"));
- - NpcBuffer_MinLevel = Integer.parseInt(Avengers.getProperty("MinimumLevel", "20"));
- - NpcBuffer_PriceCancel = Integer.parseInt(Avengers.getProperty("RemoveBuffsPrice", "100000"));
- - NpcBuffer_PriceHeal = Integer.parseInt(Avengers.getProperty("HealPrice", "100000"));
- - NpcBuffer_PriceBuffs = Integer.parseInt(Avengers.getProperty("BuffsPrice", "100000"));
- - NpcBuffer_PriceResist = Integer.parseInt(Avengers.getProperty("ResistPrice", "100000"));
- - NpcBuffer_PriceSong = Integer.parseInt(Avengers.getProperty("SongPrice", "100000"));
- - NpcBuffer_PriceDance = Integer.parseInt(Avengers.getProperty("DancePrice", "100000"));
- - NpcBuffer_PriceChant = Integer.parseInt(Avengers.getProperty("ChantsPrice", "100000"));
- - NpcBuffer_PriceOther = Integer.parseInt(Avengers.getProperty("OtherPrice", "100000"));
- - NpcBuffer_PriceSpecial = Integer.parseInt(Avengers.getProperty("SpecialPrice", "100000"));
- - NpcBuffer_PriceCubic = Integer.parseInt(Avengers.getProperty("CubicPrice", "100000"));
- - NpcBuffer_PriceSet = Integer.parseInt(Avengers.getProperty("SetPrice", "10000000"));
- - NpcBuffer_PriceScheme = Integer.parseInt(Avengers.getProperty("SchemePrice", "10000000"));
- - NpcBuffer_MaxScheme = Integer.parseInt(Avengers.getProperty("MaxScheme", "4"));
- - NpcBuffer_consumableID = Integer.parseInt(Avengers.getProperty("ConsumableID", "57"));
- - TOPDEBUG = Boolean.parseBoolean(Avengers.getProperty("TopNpcDebug", "false"));
- - CHAR_TITLE = Boolean.parseBoolean(Avengers.getProperty("CharTitle", "true"));
- - ADD_CHAR_TITLE = Avengers.getProperty("CharAddTitle", "Flash");
- - TOPID = Integer.parseInt(Avengers.getProperty("TopNpcID", "36602"));
- - MAX_PC_BANG_POINTS = Integer.parseInt(Avengers.getProperty("MaxPcBangPoints", "200000"));
- - if(MAX_PC_BANG_POINTS<0)
- - MAX_PC_BANG_POINTS=0;
- - ENABLE_DOUBLE_PC_BANG_POINTS = Boolean.parseBoolean(Avengers.getProperty("DoublingAcquisitionPoints", "false"));
- - DOUBLE_PC_BANG_POINTS_CHANCE = Integer.parseInt(Avengers.getProperty("DoublingAcquisitionPointsChance", "1"));
- - if(DOUBLE_PC_BANG_POINTS_CHANCE<0 || DOUBLE_PC_BANG_POINTS_CHANCE>100)
- - DOUBLE_PC_BANG_POINTS_CHANCE=1;
- - PC_BANG_POINT_RATE = Double.parseDouble(Avengers.getProperty("AcquisitionPointsRate", "1.0"));
- - if(PC_BANG_POINT_RATE<0)
- - PC_BANG_POINT_RATE=1;
- - RANDOM_PC_BANG_POINT = Boolean.parseBoolean(Avengers.getProperty("AcquisitionPointsRandom", "false"));
- - Boost_EXP_COMMAND = Boolean.parseBoolean(Avengers.getProperty("SpExpCommand", "False"));
- - ENABLE_BONUS_MANAGER = Boolean.parseBoolean(Avengers.getProperty("EnableBonusManager", "False"));
- - USE_PREMIUMSERVICE = Boolean.parseBoolean(Avengers.getProperty("EnablePremium", "false"));
- - PREMIUM_INFO = Boolean.parseBoolean(Avengers.getProperty("PremiumInfo", "False"));
- - PREMIUM_RATE_XP = Float.parseFloat(Avengers.getProperty("PremiumRateXp", "2."));
- - PREMIUM_RATE_SP = Float.parseFloat(Avengers.getProperty("PremiumRateSp", "2."));
- - PREMIUM_RATE_DROP_ITEMS = Float.parseFloat(Avengers.getProperty("PremiumRateDropItems", "2."));
- - PREMIUM_RATE_DROP_ITEMS_BY_RAID = Float.parseFloat(Avengers.getProperty("PremiumRateRaidDropItems", "2."));
- - PREMIUM_RATE_DROP_SPOIL = Float.parseFloat(Avengers.getProperty("PremiumRateDropSpoil", "2."));
- -
- - PVPS_COLORS = Avengers.getProperty("PvpsColors", "");
- - PVPS_COLORS_LIST = new FastMap<Integer, Integer>();
- -
- - String[] splitted_pvps_colors = PVPS_COLORS.split(";");
- -
- - for(String iii:splitted_pvps_colors)
- - {
- - String[] pvps_colors = iii.split(",");
- - if(pvps_colors.length != 2)
- - {
- - System.out.println("Invalid properties.");
- - }
- - else
- - {
- - PVPS_COLORS_LIST.put(Integer.parseInt(pvps_colors[0]), Integer.decode("0x" + pvps_colors[1]));
- - }
- - }
- - PKS_COLORS = Avengers.getProperty("PksColors", "");
- - PKS_COLORS_LIST = new FastMap<Integer, Integer>();
- - String[] splitted_pks_colors = PKS_COLORS.split(";");
- -
- - for(String iii:splitted_pks_colors)
- - {
- - String[] pks_colors = iii.split(",");
- - if(pks_colors.length != 2)
- - {
- - System.out.println("Invalid properties.");
- - }
- - else
- - {
- - PKS_COLORS_LIST.put(Integer.parseInt(pks_colors[0]), Integer.decode("0x" + pks_colors[1]));
- - }
- - }
- - String[] propertySplit = Avengers.getProperty("PremiumRateDropItemsById", "").split(";");
- - PREMIUM_RATE_DROP_ITEMS_ID = new TIntFloatHashMap(propertySplit.length);
- - if (!propertySplit[0].isEmpty())
- - {
- - for (String item : propertySplit)
- - {
- - String[] itemSplit = item.split(",");
- - if (itemSplit.length != 2)
- - _log.warning(StringUtil.concat("Config.load(): invalid config property -> PremiumRateDropItemsById \"", item, "\""));
- - else
- - {
- - try
- - {
- - PREMIUM_RATE_DROP_ITEMS_ID.put(Integer.parseInt(itemSplit[0]), Float.parseFloat(itemSplit[1]));
- - }
- - catch (NumberFormatException nfe)
- - {
- - if (!item.isEmpty())
- - _log.warning(StringUtil.concat("Config.load(): invalid config property -> PremiumRateDropItemsById \"", item, "\""));
- - }
- - }
- - }
- - }
- - if (PREMIUM_RATE_DROP_ITEMS_ID.get(PcInventory.ADENA_ID) == 0f)
- - {
- - PREMIUM_RATE_DROP_ITEMS_ID.put(PcInventory.ADENA_ID, PREMIUM_RATE_DROP_ITEMS); //for Adena rate if not defined
- - }
- - }
- -
- - catch (Exception e)
- - {
- - _log.log(Level.SEVERE, "Error while loading Avengers settings!", e);
- - }
- + BODY_ZA_MINUTU = Integer.parseInt(Avengers.getProperty("BodyZaMinutu", "20"));
- + GUARD_ID = Integer.parseInt(Avengers.getProperty("GuardId", "36602"));
- + CLAN_LEADER_COLOR_ENABLED = Boolean.parseBoolean(Avengers.getProperty("ClanLeaderNameColorEnabled", "False"));
- + CLAN_LEADER_COLOR = Integer.decode((new StringBuilder()).append("0x").append(Avengers.getProperty("ClanLeaderColor", "00FFFF")).toString()).intValue();
- + CLAN_LEADER_COLOR_CLAN_LEVEL = Integer.parseInt(Avengers.getProperty("ClanLeaderColorAtClanLevel", "1"));
- + ANNOUNCE_CASTLE_LORDS = Boolean.parseBoolean(Avengers.getProperty("AnnounceCastleLords", "false"));
- + DAGGER_VS_HEAVY = Float.parseFloat(Avengers.getProperty("DaggerVsHeavy", "1.00"));
- + DAGGER_VS_LIGHT = Float.parseFloat(Avengers.getProperty("DaggerVsLight", "1.00"));
- + DAGGER_VS_ROBE = Float.parseFloat(Avengers.getProperty("DaggerVsRobe", "1.00"));
- + ARCHER_VS_HEAVY = Float.parseFloat(Avengers.getProperty("ArcherVsHeavy", "1.00"));
- + ARCHER_VS_LIGHT = Float.parseFloat(Avengers.getProperty("ArcherVsLight", "1.00"));
- + ARCHER_VS_ROBE = Float.parseFloat(Avengers.getProperty("ArcherVsRobe", "1.00"));
- + BLUNT_VS_HEAVY = Float.parseFloat(Avengers.getProperty("BluntVsHeavy", "1.00"));
- + BLUNT_VS_LIGHT = Float.parseFloat(Avengers.getProperty("BluntVsLight", "1.00"));
- + BLUNT_VS_ROBE = Float.parseFloat(Avengers.getProperty("BluntVsRobe", "1.00"));
- + FIST_VS_HEAVY = Float.parseFloat(Avengers.getProperty("FistVsHeavy", "1.00"));
- + FIST_VS_LIGHT = Float.parseFloat(Avengers.getProperty("FistVsLight", "1.00"));
- + FIST_VS_ROBE = Float.parseFloat(Avengers.getProperty("FistVsRobe", "1.00"));
- + DUAL_VS_HEAVY = Float.parseFloat(Avengers.getProperty("DualVsHeavy", "1.00"));
- + DUAL_VS_LIGHT = Float.parseFloat(Avengers.getProperty("DualVsLight", "1.00"));
- + DUAL_VS_ROBE = Float.parseFloat(Avengers.getProperty("DualVsRobe", "1.00"));
- + SWORD_VS_HEAVY = Float.parseFloat(Avengers.getProperty("SwordVsHeavy", "1.00"));
- + SWORD_VS_LIGHT = Float.parseFloat(Avengers.getProperty("SwordVsLight", "1.00"));
- + SWORD_VS_ROBE = Float.parseFloat(Avengers.getProperty("SwordVsRobe", "1.00"));
- + POLE_VS_HEAVY = Float.parseFloat(Avengers.getProperty("PoleVsHeavy", "1.00"));
- + POLE_VS_LIGHT = Float.parseFloat(Avengers.getProperty("PoleVsLight", "1.00"));
- + POLE_VS_ROBE = Float.parseFloat(Avengers.getProperty("PoleVsRobe", "1.00"));
- + PC_BANG_ENABLED = Boolean.parseBoolean(Avengers.getProperty("Enabled", "false"));
- + ENABLE_BOTREPORT = Boolean.valueOf(Avengers.getProperty("EnableBotReport", "false"));
- + ALT_ALLOW_REFINE_PVP_ITEM = Boolean.parseBoolean(Avengers.getProperty("AltAllowRefinePVPItem", "False"));
- + HB_NEEDS_QUEST = Boolean.parseBoolean(Avengers.getProperty("HBNeedsQuest", "True"));
- + PVP_MANAPOTION = Boolean.parseBoolean(Avengers.getProperty("PvPManaPotion", "True"));
- + ENABLE_UNSTUCK_PVP = Boolean.parseBoolean(Avengers.getProperty("EnableUnstuckPvP", "True"));
- + USE_CR_ITEM = Boolean.parseBoolean(Avengers.getProperty("EnableTheClanRepPointsItem", "False"));
- + CR_ITEM_MIN_CLAN_LVL = Integer.parseInt(Avengers.getProperty("MinClanLevelNeededForCR", "7"));
- + CR_ITEM_REPS_TO_BE_AWARDED = Integer.parseInt(Avengers.getProperty("HowManyClanRepsToGive", "500"));
- + CR_ITEM_REPS_ITEM_ID = Integer.parseInt(Avengers.getProperty("CRItemID", "6673"));
- + NOBLE_CUSTOM_ITEMS = Boolean.parseBoolean(Avengers.getProperty("EnableNobleCustomItem", "true"));
- + NOOBLE_CUSTOM_ITEM_ID = Integer.parseInt(Avengers.getProperty("NoobleCustomItemId", "6673"));
- + GAME_POINT_ITEM_ID = Integer.parseInt(Avengers.getProperty("GamePointItemId", "-300"));
- + NpcBuffer_Reload = Boolean.parseBoolean(Avengers.getProperty("EnableReloadScript", "False"));
- + NpcBuffer_SmartWindow = Boolean.parseBoolean(Avengers.getProperty("EnableSmartWindow", "True"));
- + NpcBuffer_VIP = Boolean.parseBoolean(Avengers.getProperty("EnableVIP", "False"));
- + NpcBuffer_VIP_ALV = Integer.parseInt(Avengers.getProperty("VipAccesLevel", "1"));
- + NpcBuffer_EnableBuff = Boolean.parseBoolean(Avengers.getProperty("EnableBuffSection", "True"));
- + NpcBuffer_EnableScheme = Boolean.parseBoolean(Avengers.getProperty("EnableScheme", "True"));
- + NpcBuffer_EnableHeal = Boolean.parseBoolean(Avengers.getProperty("EnableHeal", "True"));
- + NpcBuffer_EnableBuffs = Boolean.parseBoolean(Avengers.getProperty("EnableBuffs", "True"));
- + NpcBuffer_EnableResist = Boolean.parseBoolean(Avengers.getProperty("EnableResist", "True"));
- + NpcBuffer_EnableSong = Boolean.parseBoolean(Avengers.getProperty("EnableSongs", "True"));
- + NpcBuffer_EnableDance = Boolean.parseBoolean(Avengers.getProperty("EnableDances", "True"));
- + NpcBuffer_EnableChant = Boolean.parseBoolean(Avengers.getProperty("EnableChants", "True"));
- + NpcBuffer_EnableOther = Boolean.parseBoolean(Avengers.getProperty("EnableOther", "True"));
- + NpcBuffer_EnableSpecial = Boolean.parseBoolean(Avengers.getProperty("EnableSpecial", "True"));
- + NpcBuffer_EnableCubic = Boolean.parseBoolean(Avengers.getProperty("EnableCubic", "True"));
- + NpcBuffer_EnableCancel = Boolean.parseBoolean(Avengers.getProperty("EnableRemoveBuffs", "True"));
- + NpcBuffer_EnableBuffSet = Boolean.parseBoolean(Avengers.getProperty("EnableBuffSet", "True"));
- + NpcBuffer_EnableBuffPK = Boolean.parseBoolean(Avengers.getProperty("EnableBuffForPK", "False"));
- + NpcBuffer_EnableFreeBuffs = Boolean.parseBoolean(Avengers.getProperty("EnableFreeBuffs", "True"));
- + NpcBuffer_EnableTimeOut = Boolean.parseBoolean(Avengers.getProperty("EnableTimeOut", "True"));
- + NpcBuffer_TimeOutTime = Integer.parseInt(Avengers.getProperty("TimeoutTime", "10"));
- + NpcBuffer_MinLevel = Integer.parseInt(Avengers.getProperty("MinimumLevel", "20"));
- + NpcBuffer_PriceCancel = Integer.parseInt(Avengers.getProperty("RemoveBuffsPrice", "100000"));
- + NpcBuffer_PriceHeal = Integer.parseInt(Avengers.getProperty("HealPrice", "100000"));
- + NpcBuffer_PriceBuffs = Integer.parseInt(Avengers.getProperty("BuffsPrice", "100000"));
- + NpcBuffer_PriceResist = Integer.parseInt(Avengers.getProperty("ResistPrice", "100000"));
- + NpcBuffer_PriceSong = Integer.parseInt(Avengers.getProperty("SongPrice", "100000"));
- + NpcBuffer_PriceDance = Integer.parseInt(Avengers.getProperty("DancePrice", "100000"));
- + NpcBuffer_PriceChant = Integer.parseInt(Avengers.getProperty("ChantsPrice", "100000"));
- + NpcBuffer_PriceOther = Integer.parseInt(Avengers.getProperty("OtherPrice", "100000"));
- + NpcBuffer_PriceSpecial = Integer.parseInt(Avengers.getProperty("SpecialPrice", "100000"));
- + NpcBuffer_PriceCubic = Integer.parseInt(Avengers.getProperty("CubicPrice", "100000"));
- + NpcBuffer_PriceSet = Integer.parseInt(Avengers.getProperty("SetPrice", "10000000"));
- + NpcBuffer_PriceScheme = Integer.parseInt(Avengers.getProperty("SchemePrice", "10000000"));
- + NpcBuffer_MaxScheme = Integer.parseInt(Avengers.getProperty("MaxScheme", "4"));
- + NpcBuffer_consumableID = Integer.parseInt(Avengers.getProperty("ConsumableID", "57"));
- + TOPDEBUG = Boolean.parseBoolean(Avengers.getProperty("TopNpcDebug", "false"));
- + CHAR_TITLE = Boolean.parseBoolean(Avengers.getProperty("CharTitle", "true"));
- + ADD_CHAR_TITLE = Avengers.getProperty("CharAddTitle", "Flash");
- + TOPID = Integer.parseInt(Avengers.getProperty("TopNpcID", "36602"));
- + MAX_PC_BANG_POINTS = Integer.parseInt(Avengers.getProperty("MaxPcBangPoints", "200000"));
- + if (MAX_PC_BANG_POINTS < 0)
- + {
- + MAX_PC_BANG_POINTS = 0;
- + }
- + ENABLE_DOUBLE_PC_BANG_POINTS = Boolean.parseBoolean(Avengers.getProperty("DoublingAcquisitionPoints", "false"));
- + DOUBLE_PC_BANG_POINTS_CHANCE = Integer.parseInt(Avengers.getProperty("DoublingAcquisitionPointsChance", "1"));
- + if ((DOUBLE_PC_BANG_POINTS_CHANCE < 0) || (DOUBLE_PC_BANG_POINTS_CHANCE > 100))
- + {
- + DOUBLE_PC_BANG_POINTS_CHANCE = 1;
- + }
- + PC_BANG_POINT_RATE = Double.parseDouble(Avengers.getProperty("AcquisitionPointsRate", "1.0"));
- + if (PC_BANG_POINT_RATE < 0)
- + {
- + PC_BANG_POINT_RATE = 1;
- + }
- + RANDOM_PC_BANG_POINT = Boolean.parseBoolean(Avengers.getProperty("AcquisitionPointsRandom", "false"));
- + Boost_EXP_COMMAND = Boolean.parseBoolean(Avengers.getProperty("SpExpCommand", "False"));
- + ENABLE_BONUS_MANAGER = Boolean.parseBoolean(Avengers.getProperty("EnableBonusManager", "False"));
- + USE_PREMIUMSERVICE = Boolean.parseBoolean(Avengers.getProperty("EnablePremium", "false"));
- + PREMIUM_INFO = Boolean.parseBoolean(Avengers.getProperty("PremiumInfo", "False"));
- + PREMIUM_RATE_XP = Float.parseFloat(Avengers.getProperty("PremiumRateXp", "2."));
- + PREMIUM_RATE_SP = Float.parseFloat(Avengers.getProperty("PremiumRateSp", "2."));
- + PREMIUM_RATE_DROP_ITEMS = Float.parseFloat(Avengers.getProperty("PremiumRateDropItems", "2."));
- + PREMIUM_RATE_DROP_ITEMS_BY_RAID = Float.parseFloat(Avengers.getProperty("PremiumRateRaidDropItems", "2."));
- + PREMIUM_RATE_DROP_SPOIL = Float.parseFloat(Avengers.getProperty("PremiumRateDropSpoil", "2."));
- + PVPS_COLORS = Avengers.getProperty("PvpsColors", "");
- + PVPS_COLORS_LIST = new FastMap<Integer, Integer>();
- + String[] splitted_pvps_colors = PVPS_COLORS.split(";");
- +
- + for (String iii : splitted_pvps_colors)
- + {
- + String[] pvps_colors = iii.split(",");
- + if (pvps_colors.length != 2)
- + {
- + System.out.println("Invalid properties.");
- + }
- + else
- + {
- + PVPS_COLORS_LIST.put(Integer.parseInt(pvps_colors[0]), Integer.decode("0x" + pvps_colors[1]));
- + }
- + }
- + PKS_COLORS = Avengers.getProperty("PksColors", "");
- + PKS_COLORS_LIST = new FastMap<Integer, Integer>();
- + String[] splitted_pks_colors = PKS_COLORS.split(";");
- +
- + for (String iii : splitted_pks_colors)
- + {
- + String[] pks_colors = iii.split(",");
- + if (pks_colors.length != 2)
- + {
- + System.out.println("Invalid properties.");
- + }
- + else
- + {
- + PKS_COLORS_LIST.put(Integer.parseInt(pks_colors[0]), Integer.decode("0x" + pks_colors[1]));
- + }
- + }
- +
- + String[] propertySplit = Avengers.getProperty("PremiumRateDropItemsById", "").split(";");
- + PREMIUM_RATE_DROP_ITEMS_ID = new TIntFloatHashMap(propertySplit.length);
- + if (!propertySplit[0].isEmpty())
- + {
- + for (String item : propertySplit)
- + {
- + String[] itemSplit = item.split(",");
- + if (itemSplit.length != 2)
- + {
- + _log.warning(StringUtil.concat("Config.load(): invalid config property -> PremiumRateDropItemsById \"", item, "\""));
- + }
- + else
- + {
- + try
- + {
- + PREMIUM_RATE_DROP_ITEMS_ID.put(Integer.parseInt(itemSplit[0]), Float.parseFloat(itemSplit[1]));
- + }
- + catch (NumberFormatException nfe)
- + {
- + if (!item.isEmpty())
- + {
- + _log.warning(StringUtil.concat("Config.load(): invalid config property -> PremiumRateDropItemsById \"", item, "\""));
- + }
- + }
- + }
- + }
- + }
- + if (PREMIUM_RATE_DROP_ITEMS_ID.get(PcInventory.ADENA_ID) == 0f)
- + {
- + PREMIUM_RATE_DROP_ITEMS_ID.put(PcInventory.ADENA_ID, PREMIUM_RATE_DROP_ITEMS); // for Adena rate if not defined
- + }
- + }
- +
- + catch (Exception e)
- + {
- + _log.log(Level.SEVERE, "Error while loading Avengers settings!", e);
- + }
- +
- // Event Custom Config
- L2Properties Event = new L2Properties();
- final File Events = new File(EVENT_FILE);
- try (InputStream is = new FileInputStream(Events))
- {
- Event.load(is);
- -
- - TW_TOWN_ID = Integer.parseInt(Event.getProperty("TownWarTownId", "9"));
- - TW_TOWN_NAME = Event.getProperty("TownWarTownName", "Giran Town");
- - TW_ALL_TOWNS = Boolean.parseBoolean(Event.getProperty("TownWarAllTowns", "False"));
- - TW_AUTO_EVENT = Boolean.parseBoolean(Event.getProperty("TownWarAutoEvent", "False"));
- - TW_INTERVAL = Event.getProperty("TownWarInterval", "20:00").split(",");
- - TW_TIME_BEFORE_START = Integer.parseInt(Event.getProperty("TownWarTimeBeforeStart", "5"));
- - TW_RUNNING_TIME = Integer.parseInt(Event.getProperty("TownWarRunningTime", "10"));
- - TW_ITEM_ID = Integer.parseInt(Event.getProperty("TownWarItemId", "57"));
- - TW_ITEM_AMOUNT = Integer.parseInt(Event.getProperty("TownWarItemAmount", "5000"));
- - TW_GIVE_PVP_AND_PK_POINTS = Boolean.parseBoolean(Event.getProperty("TownWarGivePvPAndPkPoints", "False"));
- - TW_ALLOW_KARMA = Boolean.parseBoolean(Event.getProperty("TownWarAllowKarma", "False"));
- - TW_DISABLE_GK = Boolean.parseBoolean(Event.getProperty("TownWarDisableGK", "False"));
- - TW_RESS_ON_DEATH = Boolean.parseBoolean(Event.getProperty("TownWarRessOnDeath", "True"));
- - TW_RANDOM_SPAWN = Boolean.parseBoolean(Event.getProperty("TownWarRandomSpawn", "True"));
- - TW_LOSE_BUFFS_ON_DEATH = Boolean.parseBoolean(Event.getProperty("TownWarLoseBuffsOnDeath", "False"));
- - ALLOW_HITMAN_GDE = Boolean.valueOf(Event.getProperty("AllowHitmanGDE", "true"));
- - HITMAN_GDE_TAKE_KARMA = Boolean.valueOf(Event.getProperty("HitmansTakekarma", "false"));
- - ALT_HAS_ENABLE = Boolean.parseBoolean(Event.getProperty("HaSEventEnabled", "false"));
- - ALT_HAS_TIME_REG = Integer.parseInt(Event.getProperty("HaSEventParticipationTime", "5"));
- - ALT_HAS_TIME_EVENT = Integer.parseInt(Event.getProperty("HaSEventRunningTime", "10"));
- - ALT_HAS_NPC = Integer.parseInt(Event.getProperty("HaSEventParticipationNpcId", "90000"));
- - ALT_HAS_PKJOIN = Boolean.parseBoolean(Event.getProperty("HaSEventCanPkJoin", "false"));
- - ALT_HAS_SECUENTIAL = Boolean.parseBoolean(Event.getProperty("HaSEventSecuential", "false"));
- - ALT_HAS_MINLEVEL = Integer.parseInt(Event.getProperty("HaSEventMinimumLevel", "1"));
- - ALT_HAS_MAXLEVEL = Integer.parseInt(Event.getProperty("HaSEventMaximumLevel", "85"));
- - ALT_HAS_MINPLAYERS = Integer.parseInt(Event.getProperty("HaSEventMinimumPlayers", "2"));
- - ALT_HAS_MAXPLAYERS = Integer.parseInt(Event.getProperty("HaSEventMaximumPlayers", "20"));
- - RANK_ARENA_ACCEPT_SAME_IP = Boolean.parseBoolean(Event.getProperty("ArenaAcceptSameIP", "true"));
- - RANK_ARENA_ENABLED = Boolean.parseBoolean(Event.getProperty("RankArenaEnabled", "false"));
- - RANK_ARENA_INTERVAL = Integer.parseInt(Event.getProperty("RankArenaInterval", "120"));
- - RANK_ARENA_REWARD_ID = Integer.parseInt(Event.getProperty("RankArenaRewardId", "57"));
- - RANK_ARENA_REWARD_COUNT = Integer.parseInt(Event.getProperty("RankArenaRewardCount", "1000"));
- - RANK_FISHERMAN_ENABLED = Boolean.parseBoolean(Event.getProperty("RankFishermanEnabled", "false"));
- - RANK_FISHERMAN_INTERVAL = Integer.parseInt(Event.getProperty("RankFishermanInterval", "120"));
- - RANK_FISHERMAN_REWARD_ID = Integer.parseInt(Event.getProperty("RankFishermanRewardId", "57"));
- - RANK_FISHERMAN_REWARD_COUNT = Integer.parseInt(Event.getProperty("RankFishermanRewardCount", "1000"));
- - RANK_CRAFT_ENABLED = Boolean.parseBoolean(Event.getProperty("RankCraftEnabled", "false"));
- - RANK_CRAFT_INTERVAL = Integer.parseInt(Event.getProperty("RankCraftInterval", "120"));
- - RANK_CRAFT_REWARD_ID = Integer.parseInt(Event.getProperty("RankCraftRewardId", "57"));
- - RANK_CRAFT_REWARD_COUNT = Integer.parseInt(Event.getProperty("RankCraftRewardCount", "1000"));
- - RANK_TVT_ENABLED = Boolean.parseBoolean(Event.getProperty("RankTvTEnabled", "false"));
- - RANK_TVT_INTERVAL = Integer.parseInt(Event.getProperty("RankTvTInterval", "120"));
- - RANK_TVT_REWARD_ID = Integer.parseInt(Event.getProperty("RankTvTRewardId", "57"));
- - RANK_TVT_REWARD_COUNT = Integer.parseInt(Event.getProperty("RankTvTRewardCount", "1000"));
- - TVT_ROUND_EVENT_ENABLED = Boolean.parseBoolean(Event.getProperty("TvTRoundEventEnabled", "false"));
- - TVT_ROUND_EVENT_IN_INSTANCE = Boolean.parseBoolean(Event.getProperty("TvTRoundEventInInstance", "false"));
- - TVT_ROUND_EVENT_INSTANCE_FILE = Event.getProperty("TvTRoundEventInstanceFile", "coliseum.xml");
- - TVT_ROUND_EVENT_INTERVAL = Event.getProperty("TvTRoundEventInterval", "20:00").split(",");
- - TVT_ROUND_EVENT_PARTICIPATION_TIME = Integer.parseInt(Event.getProperty("TvTRoundEventParticipationTime", "3600"));
- - TVT_ROUND_EVENT_FIRST_FIGHT_RUNNING_TIME = Integer.parseInt(Event.getProperty("TvTRoundEventFirstFightRunningTime", "1800"));
- - TVT_ROUND_EVENT_SECOND_FIGHT_RUNNING_TIME = Integer.parseInt(Event.getProperty("TvTRoundEventSecondFightRunningTime", "1800"));
- - TVT_ROUND_EVENT_THIRD_FIGHT_RUNNING_TIME = Integer.parseInt(Event.getProperty("TvTRoundEventThirdFightRunningTime", "1800"));
- - TVT_ROUND_EVENT_PARTICIPATION_NPC_ID = Integer.parseInt(Event.getProperty("TvTRoundEventParticipationNpcId", "0"));
- - TVT_ROUND_EVENT_ON_DIE = Boolean.parseBoolean(Event.getProperty("TvTRoundEventOnDie", "true"));
- -
- +
- + TW_TOWN_ID = Integer.parseInt(Event.getProperty("TownWarTownId", "9"));
- + TW_TOWN_NAME = Event.getProperty("TownWarTownName", "Giran Town");
- + TW_ALL_TOWNS = Boolean.parseBoolean(Event.getProperty("TownWarAllTowns", "False"));
- + TW_AUTO_EVENT = Boolean.parseBoolean(Event.getProperty("TownWarAutoEvent", "False"));
- + TW_INTERVAL = Event.getProperty("TownWarInterval", "20:00").split(",");
- + TW_TIME_BEFORE_START = Integer.parseInt(Event.getProperty("TownWarTimeBeforeStart", "5"));
- + TW_RUNNING_TIME = Integer.parseInt(Event.getProperty("TownWarRunningTime", "10"));
- + TW_ITEM_ID = Integer.parseInt(Event.getProperty("TownWarItemId", "57"));
- + TW_ITEM_AMOUNT = Integer.parseInt(Event.getProperty("TownWarItemAmount", "5000"));
- + TW_GIVE_PVP_AND_PK_POINTS = Boolean.parseBoolean(Event.getProperty("TownWarGivePvPAndPkPoints", "False"));
- + TW_ALLOW_KARMA = Boolean.parseBoolean(Event.getProperty("TownWarAllowKarma", "False"));
- + TW_DISABLE_GK = Boolean.parseBoolean(Event.getProperty("TownWarDisableGK", "False"));
- + TW_RESS_ON_DEATH = Boolean.parseBoolean(Event.getProperty("TownWarRessOnDeath", "True"));
- + TW_RANDOM_SPAWN = Boolean.parseBoolean(Event.getProperty("TownWarRandomSpawn", "True"));
- + TW_LOSE_BUFFS_ON_DEATH = Boolean.parseBoolean(Event.getProperty("TownWarLoseBuffsOnDeath", "False"));
- + ALLOW_HITMAN_GDE = Boolean.valueOf(Event.getProperty("AllowHitmanGDE", "true"));
- + HITMAN_GDE_TAKE_KARMA = Boolean.valueOf(Event.getProperty("HitmansTakekarma", "false"));
- + ALT_HAS_ENABLE = Boolean.parseBoolean(Event.getProperty("HaSEventEnabled", "false"));
- + ALT_HAS_TIME_REG = Integer.parseInt(Event.getProperty("HaSEventParticipationTime", "5"));
- + ALT_HAS_TIME_EVENT = Integer.parseInt(Event.getProperty("HaSEventRunningTime", "10"));
- + ALT_HAS_NPC = Integer.parseInt(Event.getProperty("HaSEventParticipationNpcId", "90000"));
- + ALT_HAS_PKJOIN = Boolean.parseBoolean(Event.getProperty("HaSEventCanPkJoin", "false"));
- + ALT_HAS_SECUENTIAL = Boolean.parseBoolean(Event.getProperty("HaSEventSecuential", "false"));
- + ALT_HAS_MINLEVEL = Integer.parseInt(Event.getProperty("HaSEventMinimumLevel", "1"));
- + ALT_HAS_MAXLEVEL = Integer.parseInt(Event.getProperty("HaSEventMaximumLevel", "85"));
- + ALT_HAS_MINPLAYERS = Integer.parseInt(Event.getProperty("HaSEventMinimumPlayers", "2"));
- + ALT_HAS_MAXPLAYERS = Integer.parseInt(Event.getProperty("HaSEventMaximumPlayers", "20"));
- + RANK_ARENA_ACCEPT_SAME_IP = Boolean.parseBoolean(Event.getProperty("ArenaAcceptSameIP", "true"));
- + RANK_ARENA_ENABLED = Boolean.parseBoolean(Event.getProperty("RankArenaEnabled", "false"));
- + RANK_ARENA_INTERVAL = Integer.parseInt(Event.getProperty("RankArenaInterval", "120"));
- + RANK_ARENA_REWARD_ID = Integer.parseInt(Event.getProperty("RankArenaRewardId", "57"));
- + RANK_ARENA_REWARD_COUNT = Integer.parseInt(Event.getProperty("RankArenaRewardCount", "1000"));
- + RANK_FISHERMAN_ENABLED = Boolean.parseBoolean(Event.getProperty("RankFishermanEnabled", "false"));
- + RANK_FISHERMAN_INTERVAL = Integer.parseInt(Event.getProperty("RankFishermanInterval", "120"));
- + RANK_FISHERMAN_REWARD_ID = Integer.parseInt(Event.getProperty("RankFishermanRewardId", "57"));
- + RANK_FISHERMAN_REWARD_COUNT = Integer.parseInt(Event.getProperty("RankFishermanRewardCount", "1000"));
- + RANK_CRAFT_ENABLED = Boolean.parseBoolean(Event.getProperty("RankCraftEnabled", "false"));
- + RANK_CRAFT_INTERVAL = Integer.parseInt(Event.getProperty("RankCraftInterval", "120"));
- + RANK_CRAFT_REWARD_ID = Integer.parseInt(Event.getProperty("RankCraftRewardId", "57"));
- + RANK_CRAFT_REWARD_COUNT = Integer.parseInt(Event.getProperty("RankCraftRewardCount", "1000"));
- + RANK_TVT_ENABLED = Boolean.parseBoolean(Event.getProperty("RankTvTEnabled", "false"));
- + RANK_TVT_INTERVAL = Integer.parseInt(Event.getProperty("RankTvTInterval", "120"));
- + RANK_TVT_REWARD_ID = Integer.parseInt(Event.getProperty("RankTvTRewardId", "57"));
- + RANK_TVT_REWARD_COUNT = Integer.parseInt(Event.getProperty("RankTvTRewardCount", "1000"));
- + CTF_EVENT_ENABLED = Boolean.parseBoolean(Event.getProperty("CTFEventEnabled", "false"));
- + CTF_EVENT_IN_INSTANCE = Boolean.parseBoolean(Event.getProperty("CTFEventInInstance", "false"));
- + CTF_EVENT_INSTANCE_FILE = Event.getProperty("CTFEventInstanceFile", "coliseum.xml");
- + CTF_EVENT_INTERVAL = Event.getProperty("CTFEventInterval", "22:00").split(",");
- + CTF_EVENT_PARTICIPATION_TIME = Integer.parseInt(Event.getProperty("CTFEventParticipationTime", "3600"));
- + CTF_EVENT_RUNNING_TIME = Integer.parseInt(Event.getProperty("CTFEventRunningTime", "1800"));
- + CTF_EVENT_PARTICIPATION_NPC_ID = Integer.parseInt(Event.getProperty("CTFEventParticipationNpcId", "0"));
- +
- + DM_EVENT_ENABLED = Boolean.parseBoolean(Event.getProperty("DMEventEnabled", "false"));
- + DM_EVENT_IN_INSTANCE = Boolean.parseBoolean(Event.getProperty("DMEventInInstance", "false"));
- + DM_EVENT_INSTANCE_FILE = Event.getProperty("DMEventInstanceFile", "coliseum.xml");
- + DM_EVENT_INTERVAL = Event.getProperty("DMEventInterval", "21:00").split(",");
- + DM_EVENT_PARTICIPATION_TIME = Integer.parseInt(Event.getProperty("DMEventParticipationTime", "3600"));
- + DM_EVENT_RUNNING_TIME = Integer.parseInt(Event.getProperty("DMEventRunningTime", "1800"));
- + DM_EVENT_PARTICIPATION_NPC_ID = Integer.parseInt(Event.getProperty("DMEventParticipationNpcId", "0"));
- + DM_EVENT_SHOW_TOP_RANK = Boolean.parseBoolean(Event.getProperty("DMEventShowTopRank", "False"));
- + DM_EVENT_TOP_RANK = Integer.parseInt(Event.getProperty("DMEventTopRank", "10"));
- +
- + TVT_ROUND_EVENT_ENABLED = Boolean.parseBoolean(Event.getProperty("TvTRoundEventEnabled", "false"));
- + TVT_ROUND_EVENT_IN_INSTANCE = Boolean.parseBoolean(Event.getProperty("TvTRoundEventInInstance", "false"));
- + TVT_ROUND_EVENT_INSTANCE_FILE = Event.getProperty("TvTRoundEventInstanceFile", "coliseum.xml");
- + TVT_ROUND_EVENT_INTERVAL = Event.getProperty("TvTRoundEventInterval", "20:00").split(",");
- + TVT_ROUND_EVENT_PARTICIPATION_TIME = Integer.parseInt(Event.getProperty("TvTRoundEventParticipationTime", "3600"));
- + TVT_ROUND_EVENT_FIRST_FIGHT_RUNNING_TIME = Integer.parseInt(Event.getProperty("TvTRoundEventFirstFightRunningTime", "1800"));
- + TVT_ROUND_EVENT_SECOND_FIGHT_RUNNING_TIME = Integer.parseInt(Event.getProperty("TvTRoundEventSecondFightRunningTime", "1800"));
- + TVT_ROUND_EVENT_THIRD_FIGHT_RUNNING_TIME = Integer.parseInt(Event.getProperty("TvTRoundEventThirdFightRunningTime", "1800"));
- + TVT_ROUND_EVENT_PARTICIPATION_NPC_ID = Integer.parseInt(Event.getProperty("TvTRoundEventParticipationNpcId", "0"));
- + TVT_ROUND_EVENT_ON_DIE = Boolean.parseBoolean(Event.getProperty("TvTRoundEventOnDie", "true"));
- +
- if (TVT_ROUND_EVENT_PARTICIPATION_NPC_ID == 0)
- + {
- + TVT_ROUND_EVENT_ENABLED = false;
- + _log.warning("TvTRoundEventEngine[Config.load()]: invalid config property -> TvTRoundEventParticipationNpcId");
- + }
- + else
- + {
- + String[] propertySplit = Event.getProperty("TvTRoundEventParticipationNpcCoordinates", "0,0,0").split(",");
- + if (propertySplit.length < 3)
- {
- TVT_ROUND_EVENT_ENABLED = false;
- - _log.warning("TvTRoundEventEngine[Config.load()]: invalid config property -> TvTRoundEventParticipationNpcId");
- + _log.warning("TvTRoundEventEngine[Config.load()]: invalid config property -> TvTRoundEventParticipationNpcCoordinates");
- }
- else
- {
- - String[] propertySplit = Event.getProperty("TvTRoundEventParticipationNpcCoordinates", "0,0,0").split(",");
- + TVT_ROUND_EVENT_REWARDS = new ArrayList<int[]>();
- + TVT_ROUND_DOORS_IDS_TO_OPEN = new ArrayList<Integer>();
- + TVT_ROUND_DOORS_IDS_TO_CLOSE = new ArrayList<Integer>();
- + TVT_ROUND_ANTEROOM_DOORS_IDS_TO_OPEN_CLOSE = new ArrayList<Integer>();
- + TVT_ROUND_EVENT_WAIT_OPEN_ANTEROOM_DOORS = Integer.parseInt(Event.getProperty("TvTRoundEventWaitOpenAnteroomDoors", "30"));
- + TVT_ROUND_EVENT_WAIT_CLOSE_ANTEROOM_DOORS = Integer.parseInt(Event.getProperty("TvTRoundEventWaitCloseAnteroomDoors", "15"));
- + TVT_ROUND_EVENT_STOP_ON_TIE = Boolean.parseBoolean(Event.getProperty("TvTRoundEventStopOnTie", "false"));
- + TVT_ROUND_EVENT_MINIMUM_TIE = Integer.parseInt(Event.getProperty("TvTRoundEventMinimumTie", "1"));
- + if ((TVT_ROUND_EVENT_MINIMUM_TIE != 1) && (TVT_ROUND_EVENT_MINIMUM_TIE != 2) && (TVT_ROUND_EVENT_MINIMUM_TIE != 3))
- + {
- + TVT_ROUND_EVENT_MINIMUM_TIE = 1;
- + }
- + TVT_ROUND_EVENT_PARTICIPATION_NPC_COORDINATES = new int[4];
- + TVT_ROUND_EVENT_TEAM_1_COORDINATES = new int[3];
- + TVT_ROUND_EVENT_TEAM_2_COORDINATES = new int[3];
- + TVT_ROUND_EVENT_PARTICIPATION_NPC_COORDINATES[0] = Integer.parseInt(propertySplit[0]);
- + TVT_ROUND_EVENT_PARTICIPATION_NPC_COORDINATES[1] = Integer.parseInt(propertySplit[1]);
- + TVT_ROUND_EVENT_PARTICIPATION_NPC_COORDINATES[2] = Integer.parseInt(propertySplit[2]);
- + if (propertySplit.length == 4)
- + {
- + TVT_ROUND_EVENT_PARTICIPATION_NPC_COORDINATES[3] = Integer.parseInt(propertySplit[3]);
- + }
- + TVT_ROUND_EVENT_MIN_PLAYERS_IN_TEAMS = Integer.parseInt(Event.getProperty("TvTRoundEventMinPlayersInTeams", "1"));
- + TVT_ROUND_EVENT_MAX_PLAYERS_IN_TEAMS = Integer.parseInt(Event.getProperty("TvTRoundEventMaxPlayersInTeams", "20"));
- + TVT_ROUND_EVENT_MIN_LVL = (byte) Integer.parseInt(Event.getProperty("TvTRoundEventMinPlayerLevel", "1"));
- + TVT_ROUND_EVENT_MAX_LVL = (byte) Integer.parseInt(Event.getProperty("TvTRoundEventMaxPlayerLevel", "80"));
- + TVT_ROUND_EVENT_START_RESPAWN_LEAVE_TELEPORT_DELAY = Integer.parseInt(Event.getProperty("TvTRoundEventStartRespawnLeaveTeleportDelay", "10"));
- + TVT_ROUND_EVENT_EFFECTS_REMOVAL = Integer.parseInt(Event.getProperty("TvTRoundEventEffectsRemoval", "0"));
- + TVT_ROUND_EVENT_MAX_PARTICIPANTS_PER_IP = Integer.parseInt(Event.getProperty("TvTRoundEventMaxParticipantsPerIP", "0"));
- + TVT_ROUND_ALLOW_VOICED_COMMAND = Boolean.parseBoolean(Event.getProperty("TvTRoundAllowVoicedInfoCommand", "false"));
- + TVT_ROUND_EVENT_TEAM_1_NAME = Event.getProperty("TvTRoundEventTeam1Name", "Team1");
- + propertySplit = Event.getProperty("TvTRoundEventTeam1Coordinates", "0,0,0").split(",");
- if (propertySplit.length < 3)
- {
- TVT_ROUND_EVENT_ENABLED = false;
- - _log.warning("TvTRoundEventEngine[Config.load()]: invalid config property -> TvTRoundEventParticipationNpcCoordinates");
- + _log.warning("TvTRoundEventEngine[Config.load()]: invalid config property -> TvTRoundEventTeam1Coordinates");
- }
- else
- {
- - TVT_ROUND_EVENT_REWARDS = new ArrayList<int[]>();
- - TVT_ROUND_DOORS_IDS_TO_OPEN = new ArrayList<Integer>();
- - TVT_ROUND_DOORS_IDS_TO_CLOSE = new ArrayList<Integer>();
- - TVT_ROUND_ANTEROOM_DOORS_IDS_TO_OPEN_CLOSE = new ArrayList<Integer>();
- - TVT_ROUND_EVENT_WAIT_OPEN_ANTEROOM_DOORS = Integer.parseInt(Event.getProperty("TvTRoundEventWaitOpenAnteroomDoors", "30"));
- - TVT_ROUND_EVENT_WAIT_CLOSE_ANTEROOM_DOORS = Integer.parseInt(Event.getProperty("TvTRoundEventWaitCloseAnteroomDoors", "15"));
- - TVT_ROUND_EVENT_STOP_ON_TIE = Boolean.parseBoolean(Event.getProperty("TvTRoundEventStopOnTie", "false"));
- - TVT_ROUND_EVENT_MINIMUM_TIE = Integer.parseInt(Event.getProperty("TvTRoundEventMinimumTie", "1"));
- - if (TVT_ROUND_EVENT_MINIMUM_TIE != 1 && TVT_ROUND_EVENT_MINIMUM_TIE != 2 && TVT_ROUND_EVENT_MINIMUM_TIE != 3) TVT_ROUND_EVENT_MINIMUM_TIE = 1;
- - TVT_ROUND_EVENT_PARTICIPATION_NPC_COORDINATES = new int[4];
- - TVT_ROUND_EVENT_TEAM_1_COORDINATES = new int[3];
- - TVT_ROUND_EVENT_TEAM_2_COORDINATES = new int[3];
- - TVT_ROUND_EVENT_PARTICIPATION_NPC_COORDINATES[0] = Integer.parseInt(propertySplit[0]);
- - TVT_ROUND_EVENT_PARTICIPATION_NPC_COORDINATES[1] = Integer.parseInt(propertySplit[1]);
- - TVT_ROUND_EVENT_PARTICIPATION_NPC_COORDINATES[2] = Integer.parseInt(propertySplit[2]);
- - if (propertySplit.length == 4)
- - TVT_ROUND_EVENT_PARTICIPATION_NPC_COORDINATES[3] = Integer.parseInt(propertySplit[3]);
- - TVT_ROUND_EVENT_MIN_PLAYERS_IN_TEAMS = Integer.parseInt(Event.getProperty("TvTRoundEventMinPlayersInTeams", "1"));
- - TVT_ROUND_EVENT_MAX_PLAYERS_IN_TEAMS = Integer.parseInt(Event.getProperty("TvTRoundEventMaxPlayersInTeams", "20"));
- - TVT_ROUND_EVENT_MIN_LVL = (byte)Integer.parseInt(Event.getProperty("TvTRoundEventMinPlayerLevel", "1"));
- - TVT_ROUND_EVENT_MAX_LVL = (byte)Integer.parseInt(Event.getProperty("TvTRoundEventMaxPlayerLevel", "80"));
- - TVT_ROUND_EVENT_START_RESPAWN_LEAVE_TELEPORT_DELAY = Integer.parseInt(Event.getProperty("TvTRoundEventStartRespawnLeaveTeleportDelay", "10"));
- - TVT_ROUND_EVENT_EFFECTS_REMOVAL = Integer.parseInt(Event.getProperty("TvTRoundEventEffectsRemoval", "0"));
- - TVT_ROUND_EVENT_MAX_PARTICIPANTS_PER_IP = Integer.parseInt(Event.getProperty("TvTRoundEventMaxParticipantsPerIP", "0"));
- - TVT_ROUND_ALLOW_VOICED_COMMAND = Boolean.parseBoolean(Event.getProperty("TvTRoundAllowVoicedInfoCommand", "false"));
- - TVT_ROUND_EVENT_TEAM_1_NAME = Event.getProperty("TvTRoundEventTeam1Name", "Team1");
- - propertySplit = Event.getProperty("TvTRoundEventTeam1Coordinates", "0,0,0").split(",");
- + TVT_ROUND_EVENT_TEAM_1_COORDINATES[0] = Integer.parseInt(propertySplit[0]);
- + TVT_ROUND_EVENT_TEAM_1_COORDINATES[1] = Integer.parseInt(propertySplit[1]);
- + TVT_ROUND_EVENT_TEAM_1_COORDINATES[2] = Integer.parseInt(propertySplit[2]);
- + TVT_ROUND_EVENT_TEAM_2_NAME = Event.getProperty("TvTRoundEventTeam2Name", "Team2");
- + propertySplit = Event.getProperty("TvTRoundEventTeam2Coordinates", "0,0,0").split(",");
- if (propertySplit.length < 3)
- {
- TVT_ROUND_EVENT_ENABLED = false;
- - _log.warning("TvTRoundEventEngine[Config.load()]: invalid config property -> TvTRoundEventTeam1Coordinates");
- + _log.warning("TvTRoundEventEngine[Config.load()]: invalid config property -> TvTRoundEventTeam2Coordinates");
- }
- else
- {
- - TVT_ROUND_EVENT_TEAM_1_COORDINATES[0] = Integer.parseInt(propertySplit[0]);
- - TVT_ROUND_EVENT_TEAM_1_COORDINATES[1] = Integer.parseInt(propertySplit[1]);
- - TVT_ROUND_EVENT_TEAM_1_COORDINATES[2] = Integer.parseInt(propertySplit[2]);
- - TVT_ROUND_EVENT_TEAM_2_NAME = Event.getProperty("TvTRoundEventTeam2Name", "Team2");
- - propertySplit = Event.getProperty("TvTRoundEventTeam2Coordinates", "0,0,0").split(",");
- - if (propertySplit.length < 3)
- + TVT_ROUND_EVENT_TEAM_2_COORDINATES[0] = Integer.parseInt(propertySplit[0]);
- + TVT_ROUND_EVENT_TEAM_2_COORDINATES[1] = Integer.parseInt(propertySplit[1]);
- + TVT_ROUND_EVENT_TEAM_2_COORDINATES[2] = Integer.parseInt(propertySplit[2]);
- + propertySplit = Event.getProperty("TvTRoundEventParticipationFee", "0,0").split(",");
- + try
- {
- - TVT_ROUND_EVENT_ENABLED= false;
- - _log.warning("TvTRoundEventEngine[Config.load()]: invalid config property -> TvTRoundEventTeam2Coordinates");
- + TVT_ROUND_EVENT_PARTICIPATION_FEE[0] = Integer.parseInt(propertySplit[0]);
- + TVT_ROUND_EVENT_PARTICIPATION_FEE[1] = Integer.parseInt(propertySplit[1]);
- }
- - else
- + catch (NumberFormatException nfe)
- {
- - TVT_ROUND_EVENT_TEAM_2_COORDINATES[0] = Integer.parseInt(propertySplit[0]);
- - TVT_ROUND_EVENT_TEAM_2_COORDINATES[1] = Integer.parseInt(propertySplit[1]);
- - TVT_ROUND_EVENT_TEAM_2_COORDINATES[2] = Integer.parseInt(propertySplit[2]);
- - propertySplit = Event.getProperty("TvTRoundEventParticipationFee", "0,0").split(",");
- + if (propertySplit.length > 0)
- + {
- + _log.warning("TvTRoundEventEngine[Config.load()]: invalid config property -> TvTRoundEventParticipationFee");
- + }
- + }
- + propertySplit = Event.getProperty("TvTRoundEventReward", "57,100000").split(";");
- + for (String reward : propertySplit)
- + {
- + String[] rewardSplit = reward.split(",");
- + if (rewardSplit.length != 2)
- + {
- + _log.warning(StringUtil.concat("TvTRoundEventEngine[Config.load()]: invalid config property -> TvTRoundEventReward \"", reward, "\""));
- + }
- + else
- + {
- + try
- + {
- + TVT_ROUND_EVENT_REWARDS.add(new int[]
- + {
- + Integer.parseInt(rewardSplit[0]),
- + Integer.parseInt(rewardSplit[1])
- + });
- + }
- + catch (NumberFormatException nfe)
- + {
- + if (!reward.isEmpty())
- + {
- + _log.warning(StringUtil.concat("TvTRoundEventEngine[Config.load()]: invalid config property -> TvTRoundEventReward \"", reward, "\""));
- + }
- + }
- + }
- + }
- +
- + TVT_ROUND_EVENT_TARGET_TEAM_MEMBERS_ALLOWED = Boolean.parseBoolean(Event.getProperty("TvTRoundEventTargetTeamMembersAllowed", "true"));
- + TVT_ROUND_EVENT_SCROLL_ALLOWED = Boolean.parseBoolean(Event.getProperty("TvTRoundEventScrollsAllowed", "false"));
- + TVT_ROUND_EVENT_POTIONS_ALLOWED = Boolean.parseBoolean(Event.getProperty("TvTRoundEventPotionsAllowed", "false"));
- + TVT_ROUND_EVENT_SUMMON_BY_ITEM_ALLOWED = Boolean.parseBoolean(Event.getProperty("TvTRoundEventSummonByItemAllowed", "false"));
- + TVT_ROUND_GIVE_POINT_TEAM_TIE = Boolean.parseBoolean(Event.getProperty("TvTRoundGivePointTeamTie", "false"));
- + TVT_ROUND_REWARD_TEAM_TIE = Boolean.parseBoolean(Event.getProperty("TvTRoundRewardTeamTie", "false"));
- + TVT_ROUND_EVENT_REWARD_ON_SECOND_FIGHT_END = Boolean.parseBoolean(Event.getProperty("TvTRoundEventRewardOnSecondFightEnd", "false"));
- + propertySplit = Event.getProperty("TvTRoundDoorsToOpen", "").split(";");
- + for (String door : propertySplit)
- + {
- try
- {
- - TVT_ROUND_EVENT_PARTICIPATION_FEE[0] = Integer.parseInt(propertySplit[0]);
- - TVT_ROUND_EVENT_PARTICIPATION_FEE[1] = Integer.parseInt(propertySplit[1]);
- + TVT_ROUND_DOORS_IDS_TO_OPEN.add(Integer.parseInt(door));
- }
- catch (NumberFormatException nfe)
- {
- - if (propertySplit.length > 0)
- - _log.warning("TvTRoundEventEngine[Config.load()]: invalid config property -> TvTRoundEventParticipationFee");
- + if (!door.isEmpty())
- + {
- + _log.warning(StringUtil.concat("TvTRoundEventEngine[Config.load()]: invalid config property -> TvTRoundDoorsToOpen \"", door, "\""));
- + }
- }
- - propertySplit = Event.getProperty("TvTRoundEventReward", "57,100000").split(";");
- - for (String reward : propertySplit)
- + }
- +
- + propertySplit = Event.getProperty("TvTRoundDoorsToClose", "").split(";");
- + for (String door : propertySplit)
- + {
- + try
- {
- - String[] rewardSplit = reward.split(",");
- - if (rewardSplit.length != 2)
- - _log.warning(StringUtil.concat("TvTRoundEventEngine[Config.load()]: invalid config property -> TvTRoundEventReward \"", reward, "\""));
- + TVT_ROUND_DOORS_IDS_TO_CLOSE.add(Integer.parseInt(door));
- + }
- + catch (NumberFormatException nfe)
- + {
- + if (!door.isEmpty())
- + {
- + _log.warning(StringUtil.concat("TvTRoundEventEngine[Config.load()]: invalid config property -> TvTRoundDoorsToClose \"", door, "\""));
- + }
- + }
- + }
- +
- + propertySplit = Event.getProperty("TvTRoundAnteroomDoorsToOpenClose", "").split(";");
- + for (String door : propertySplit)
- + {
- + try
- + {
- + TVT_ROUND_ANTEROOM_DOORS_IDS_TO_OPEN_CLOSE.add(Integer.parseInt(door));
- + }
- + catch (NumberFormatException nfe)
- + {
- + if (!door.isEmpty())
- + {
- + _log.warning(StringUtil.concat("TvTRoundEventEngine[Config.load()]: invalid config property -> TvTRoundAnteroomDoorsToOpenClose \"", door, "\""));
- + }
- + }
- + }
- +
- + propertySplit = Event.getProperty("TvTRoundEventFighterBuffs", "").split(";");
- + if (!propertySplit[0].isEmpty())
- + {
- + TVT_ROUND_EVENT_FIGHTER_BUFFS = new HashMap<>(propertySplit.length);
- + for (String skill : propertySplit)
- + {
- + String[] skillSplit = skill.split(",");
- + if (skillSplit.length != 2)
- + {
- + _log.warning(StringUtil.concat("TvTRoundEventEngine[Config.load()]: invalid config property -> TvTRoundEventFighterBuffs \"", skill, "\""));
- + }
- else
- {
- try
- {
- - TVT_ROUND_EVENT_REWARDS.add(new int[]{Integer.parseInt(rewardSplit[0]), Integer.parseInt(rewardSplit[1])});
- + TVT_ROUND_EVENT_FIGHTER_BUFFS.put(Integer.parseInt(skillSplit[0]), Integer.parseInt(skillSplit[1]));
- }
- catch (NumberFormatException nfe)
- {
- - if (!reward.isEmpty())
- - _log.warning(StringUtil.concat("TvTRoundEventEngine[Config.load()]: invalid config property -> TvTRoundEventReward \"", reward, "\""));
- + if (!skill.isEmpty())
- + {
- + _log.warning(StringUtil.concat("TvTRoundEventEngine[Config.load()]: invalid config property -> TvTRoundEventFighterBuffs \"", skill, "\""));
- + }
- }
- }
- }
- -
- - TVT_ROUND_EVENT_TARGET_TEAM_MEMBERS_ALLOWED = Boolean.parseBoolean(Event.getProperty("TvTRoundEventTargetTeamMembersAllowed", "true"));
- - TVT_ROUND_EVENT_SCROLL_ALLOWED = Boolean.parseBoolean(Event.getProperty("TvTRoundEventScrollsAllowed", "false"));
- - TVT_ROUND_EVENT_POTIONS_ALLOWED = Boolean.parseBoolean(Event.getProperty("TvTRoundEventPotionsAllowed", "false"));
- - TVT_ROUND_EVENT_SUMMON_BY_ITEM_ALLOWED = Boolean.parseBoolean(Event.getProperty("TvTRoundEventSummonByItemAllowed", "false"));
- - TVT_ROUND_GIVE_POINT_TEAM_TIE = Boolean.parseBoolean(Event.getProperty("TvTRoundGivePointTeamTie", "false"));
- - TVT_ROUND_REWARD_TEAM_TIE = Boolean.parseBoolean(Event.getProperty("TvTRoundRewardTeamTie", "false"));
- - TVT_ROUND_EVENT_REWARD_ON_SECOND_FIGHT_END = Boolean.parseBoolean(Event.getProperty("TvTRoundEventRewardOnSecondFightEnd", "false"));
- - propertySplit = Event.getProperty("TvTRoundDoorsToOpen", "").split(";");
- - for (String door : propertySplit)
- + }
- +
- + propertySplit = Event.getProperty("TvTRoundEventMageBuffs", "").split(";");
- + if (!propertySplit[0].isEmpty())
- + {
- + TVT_ROUND_EVENT_MAGE_BUFFS = new HashMap<>(propertySplit.length);
- + for (String skill : propertySplit)
- {
- - try
- + String[] skillSplit = skill.split(",");
- + if (skillSplit.length != 2)
- {
- - TVT_ROUND_DOORS_IDS_TO_OPEN.add(Integer.parseInt(door));
- + _log.warning(StringUtil.concat("TvTRoundEventEngine[Config.load()]: invalid config property -> TvTRoundEventMageBuffs \"", skill, "\""));
- }
- - catch (NumberFormatException nfe)
- + else
- {
- - if (!door.isEmpty())
- - _log.warning(StringUtil.concat("TvTRoundEventEngine[Config.load()]: invalid config property -> TvTRoundDoorsToOpen \"", door, "\""));
- + try
- + {
- + TVT_ROUND_EVENT_MAGE_BUFFS.put(Integer.parseInt(skillSplit[0]), Integer.parseInt(skillSplit[1]));
- + }
- + catch (NumberFormatException nfe)
- + {
- + if (!skill.isEmpty())
- + {
- + _log.warning(StringUtil.concat("TvTRoundEventEngine[Config.load()]: invalid config property -> TvTRoundEventMageBuffs \"", skill, "\""));
- + }
- + }
- }
- }
- -
- - propertySplit = Event.getProperty("TvTRoundDoorsToClose", "").split(";");
- - for (String door : propertySplit)
- + }
- + }
- + }
- + }
- + }
- +
- + if (CTF_EVENT_PARTICIPATION_NPC_ID == 0)
- + {
- + CTF_EVENT_ENABLED = false;
- + _log.warning("CTFEventEngine[Config.load()]: invalid config property -> CTFEventParticipationNpcId");
- + }
- + else
- + {
- + String[] propertySplit = Event.getProperty("CTFEventParticipationNpcCoordinates", "0,0,0").split(",");
- + if (propertySplit.length < 3)
- + {
- + CTF_EVENT_ENABLED = false;
- + _log.warning("CTFEventEngine[Config.load()]: invalid config property -> CTFEventParticipationNpcCoordinates");
- + }
- + else
- + {
- + CTF_EVENT_REWARDS = new ArrayList<int[]>();
- + CTF_DOORS_IDS_TO_OPEN = new ArrayList<Integer>();
- + CTF_DOORS_IDS_TO_CLOSE = new ArrayList<Integer>();
- + CTF_EVENT_PARTICIPATION_NPC_COORDINATES = new int[4];
- + CTF_EVENT_TEAM_1_COORDINATES = new int[3];
- + CTF_EVENT_TEAM_2_COORDINATES = new int[3];
- + CTF_EVENT_PARTICIPATION_NPC_COORDINATES[0] = Integer.parseInt(propertySplit[0]);
- + CTF_EVENT_PARTICIPATION_NPC_COORDINATES[1] = Integer.parseInt(propertySplit[1]);
- + CTF_EVENT_PARTICIPATION_NPC_COORDINATES[2] = Integer.parseInt(propertySplit[2]);
- + if (propertySplit.length == 4)
- + {
- + CTF_EVENT_PARTICIPATION_NPC_COORDINATES[3] = Integer.parseInt(propertySplit[3]);
- + }
- + CTF_EVENT_MIN_PLAYERS_IN_TEAMS = Integer.parseInt(Event.getProperty("CTFEventMinPlayersInTeams", "1"));
- + CTF_EVENT_MAX_PLAYERS_IN_TEAMS = Integer.parseInt(Event.getProperty("CTFEventMaxPlayersInTeams", "20"));
- + CTF_EVENT_MIN_LVL = (byte) Integer.parseInt(Event.getProperty("CTFEventMinPlayerLevel", "1"));
- + CTF_EVENT_MAX_LVL = (byte) Integer.parseInt(Event.getProperty("CTFEventMaxPlayerLevel", "80"));
- + CTF_EVENT_RESPAWN_TELEPORT_DELAY = Integer.parseInt(Event.getProperty("CTFEventRespawnTeleportDelay", "20"));
- + CTF_EVENT_START_LEAVE_TELEPORT_DELAY = Integer.parseInt(Event.getProperty("CTFEventStartLeaveTeleportDelay", "20"));
- + CTF_EVENT_EFFECTS_REMOVAL = Integer.parseInt(Event.getProperty("CTFEventEffectsRemoval", "0"));
- + CTF_EVENT_MAX_PARTICIPANTS_PER_IP = Integer.parseInt(Event.getProperty("CTFEventMaxParticipantsPerIP", "0"));
- + CTF_ALLOW_VOICED_COMMAND = Boolean.parseBoolean(Event.getProperty("CTFAllowVoicedInfoCommand", "false"));
- + CTF_EVENT_TEAM_1_NAME = Event.getProperty("CTFEventTeam1Name", "Team1");
- + propertySplit = Event.getProperty("CTFEventTeam1Coordinates", "0,0,0").split(",");
- + if (propertySplit.length < 3)
- + {
- + CTF_EVENT_ENABLED = false;
- + _log.warning("CTFEventEngine[Config.load()]: invalid config property -> CTFEventTeam1Coordinates");
- + }
- + else
- + {
- + CTF_EVENT_TEAM_1_COORDINATES[0] = Integer.parseInt(propertySplit[0]);
- + CTF_EVENT_TEAM_1_COORDINATES[1] = Integer.parseInt(propertySplit[1]);
- + CTF_EVENT_TEAM_1_COORDINATES[2] = Integer.parseInt(propertySplit[2]);
- + CTF_EVENT_TEAM_2_NAME = Event.getProperty("CTFEventTeam2Name", "Team2");
- + propertySplit = Event.getProperty("CTFEventTeam2Coordinates", "0,0,0").split(",");
- + if (propertySplit.length < 3)
- + {
- + CTF_EVENT_ENABLED = false;
- + _log.warning("CTFEventEngine[Config.load()]: invalid config property -> CTFEventTeam2Coordinates");
- + }
- + else
- + {
- + CTF_EVENT_TEAM_2_COORDINATES[0] = Integer.parseInt(propertySplit[0]);
- + CTF_EVENT_TEAM_2_COORDINATES[1] = Integer.parseInt(propertySplit[1]);
- + CTF_EVENT_TEAM_2_COORDINATES[2] = Integer.parseInt(propertySplit[2]);
- + propertySplit = Event.getProperty("CTFEventParticipationFee", "0,0").split(",");
- + try
- + {
- + CTF_EVENT_PARTICIPATION_FEE[0] = Integer.parseInt(propertySplit[0]);
- + CTF_EVENT_PARTICIPATION_FEE[1] = Integer.parseInt(propertySplit[1]);
- + }
- + catch (NumberFormatException nfe)
- + {
- + if (propertySplit.length > 0)
- {
- + _log.warning("CTFEventEngine[Config.load()]: invalid config property -> CTFEventParticipationFee");
- + }
- + }
- + propertySplit = Event.getProperty("CTFEventReward", "57,100000").split(";");
- + for (String reward : propertySplit)
- + {
- + String[] rewardSplit = reward.split(",");
- + if (rewardSplit.length != 2)
- + {
- + _log.warning(StringUtil.concat("CTFEventEngine[Config.load()]: invalid config property -> CTFEventReward \"", reward, "\""));
- + }
- + else
- + {
- try
- {
- - TVT_ROUND_DOORS_IDS_TO_CLOSE.add(Integer.parseInt(door));
- + CTF_EVENT_REWARDS.add(new int[]
- + {
- + Integer.parseInt(rewardSplit[0]),
- + Integer.parseInt(rewardSplit[1])
- + });
- }
- catch (NumberFormatException nfe)
- {
- - if (!door.isEmpty())
- - _log.warning(StringUtil.concat("TvTRoundEventEngine[Config.load()]: invalid config property -> TvTRoundDoorsToClose \"", door, "\""));
- + if (!reward.isEmpty())
- + {
- + _log.warning(StringUtil.concat("CTFEventEngine[Config.load()]: invalid config property -> CTFEventReward \"", reward, "\""));
- + }
- }
- }
- -
- - propertySplit = Event.getProperty("TvTRoundAnteroomDoorsToOpenClose", "").split(";");
- - for (String door : propertySplit)
- + }
- +
- + CTF_EVENT_TARGET_TEAM_MEMBERS_ALLOWED = Boolean.parseBoolean(Event.getProperty("CTFEventTargetTeamMembersAllowed", "true"));
- + CTF_EVENT_SCROLL_ALLOWED = Boolean.parseBoolean(Event.getProperty("CTFEventScrollsAllowed", "false"));
- + CTF_EVENT_POTIONS_ALLOWED = Boolean.parseBoolean(Event.getProperty("CTFEventPotionsAllowed", "false"));
- + CTF_EVENT_SUMMON_BY_ITEM_ALLOWED = Boolean.parseBoolean(Event.getProperty("CTFEventSummonByItemAllowed", "false"));
- + CTF_REWARD_TEAM_TIE = Boolean.parseBoolean(Event.getProperty("CTFRewardTeamTie", "false"));
- + propertySplit = Event.getProperty("CTFDoorsToOpen", "").split(";");
- + for (String door : propertySplit)
- + {
- + try
- {
- - try
- + CTF_DOORS_IDS_TO_OPEN.add(Integer.parseInt(door));
- + }
- + catch (NumberFormatException nfe)
- + {
- + if (!door.isEmpty())
- {
- - TVT_ROUND_ANTEROOM_DOORS_IDS_TO_OPEN_CLOSE.add(Integer.parseInt(door));
- + _log.warning(StringUtil.concat("CTFEventEngine[Config.load()]: invalid config property -> CTFDoorsToOpen \"", door, "\""));
- }
- - catch (NumberFormatException nfe)
- + }
- + }
- +
- + propertySplit = Event.getProperty("CTFDoorsToClose", "").split(";");
- + for (String door : propertySplit)
- + {
- + try
- + {
- + CTF_DOORS_IDS_TO_CLOSE.add(Integer.parseInt(door));
- + }
- + catch (NumberFormatException nfe)
- + {
- + if (!door.isEmpty())
- {
- - if (!door.isEmpty())
- - _log.warning(StringUtil.concat("TvTRoundEventEngine[Config.load()]: invalid config property -> TvTRoundAnteroomDoorsToOpenClose \"", door, "\""));
- + _log.warning(StringUtil.concat("CTFEventEngine[Config.load()]: invalid config property -> CTFDoorsToClose \"", door, "\""));
- }
- }
- -
- - propertySplit = Event.getProperty("TvTRoundEventFighterBuffs", "").split(";");
- - if (!propertySplit[0].isEmpty())
- + }
- +
- + propertySplit = Event.getProperty("CTFEventFighterBuffs", "").split(";");
- + if (!propertySplit[0].isEmpty())
- + {
- + CTF_EVENT_FIGHTER_BUFFS = new TIntIntHashMap(propertySplit.length);
- + for (String skill : propertySplit)
- {
- - TVT_ROUND_EVENT_FIGHTER_BUFFS = new HashMap<>(propertySplit.length);
- - for (String skill : propertySplit)
- + String[] skillSplit = skill.split(",");
- + if (skillSplit.length != 2)
- {
- - String[] skillSplit = skill.split(",");
- - if (skillSplit.length != 2)
- - _log.warning(StringUtil.concat("TvTRoundEventEngine[Config.load()]: invalid config property -> TvTRoundEventFighterBuffs \"", skill, "\""));
- - else
- + _log.warning(StringUtil.concat("CTFEventEngine[Config.load()]: invalid config property -> CTFEventFighterBuffs \"", skill, "\""));
- + }
- + else
- + {
- + try
- {
- - try
- + CTF_EVENT_FIGHTER_BUFFS.put(Integer.parseInt(skillSplit[0]), Integer.parseInt(skillSplit[1]));
- + }
- + catch (NumberFormatException nfe)
- + {
- + if (!skill.isEmpty())
- {
- - TVT_ROUND_EVENT_FIGHTER_BUFFS.put(Integer.parseInt(skillSplit[0]), Integer.parseInt(skillSplit[1]));
- + _log.warning(StringUtil.concat("CTFEventEngine[Config.load()]: invalid config property -> CTFEventFighterBuffs \"", skill, "\""));
- }
- - catch (NumberFormatException nfe)
- - {
- - if (!skill.isEmpty())
- - _log.warning(StringUtil.concat("TvTRoundEventEngine[Config.load()]: invalid config property -> TvTRoundEventFighterBuffs \"", skill, "\""));
- - }
- }
- }
- }
- -
- - propertySplit = Event.getProperty("TvTRoundEventMageBuffs", "").split(";");
- - if (!propertySplit[0].isEmpty())
- + }
- +
- + propertySplit = Event.getProperty("CTFEventMageBuffs", "").split(";");
- + if (!propertySplit[0].isEmpty())
- + {
- + CTF_EVENT_MAGE_BUFFS = new TIntIntHashMap(propertySplit.length);
- + for (String skill : propertySplit)
- {
- - TVT_ROUND_EVENT_MAGE_BUFFS = new HashMap<>(propertySplit.length);
- - for (String skill : propertySplit)
- + String[] skillSplit = skill.split(",");
- + if (skillSplit.length != 2)
- {
- - String[] skillSplit = skill.split(",");
- - if (skillSplit.length != 2)
- - _log.warning(StringUtil.concat("TvTRoundEventEngine[Config.load()]: invalid config property -> TvTRoundEventMageBuffs \"", skill, "\""));
- - else
- + _log.warning(StringUtil.concat("CTFEventEngine[Config.load()]: invalid config property -> CTFEventMageBuffs \"", skill, "\""));
- + }
- + else
- + {
- + try
- {
- - try
- + CTF_EVENT_MAGE_BUFFS.put(Integer.parseInt(skillSplit[0]), Integer.parseInt(skillSplit[1]));
- + }
- + catch (NumberFormatException nfe)
- + {
- + if (!skill.isEmpty())
- {
- - TVT_ROUND_EVENT_MAGE_BUFFS.put(Integer.parseInt(skillSplit[0]), Integer.parseInt(skillSplit[1]));
- + _log.warning(StringUtil.concat("CTFEventEngine[Config.load()]: invalid config property -> CTFEventMageBuffs \"", skill, "\""));
- }
- - catch (NumberFormatException nfe)
- - {
- - if (!skill.isEmpty())
- - _log.warning(StringUtil.concat("TvTRoundEventEngine[Config.load()]: invalid config property -> TvTRoundEventMageBuffs \"", skill, "\""));
- - }
- }
- }
- }
- @@ -2081,12 +2397,193 @@
- }
- }
- }
- -
- - }
- - catch (Exception e)
- - {
- - _log.log(Level.SEVERE, "Error while loading Event settings!", e);
- - }
- + }
- +
- + if (DM_EVENT_PARTICIPATION_NPC_ID == 0)
- + {
- + DM_EVENT_ENABLED = false;
- + _log.warning("DMEventEngine[Config.load()]: invalid config property -> DMEventParticipationNpcId");
- + }
- + else
- + {
- + String[] propertySplit = Event.getProperty("DMEventParticipationNpcCoordinates", "0,0,0").split(",");
- + if (propertySplit.length < 3)
- + {
- + DM_EVENT_ENABLED = false;
- + _log.warning("DMEventEngine[Config.load()]: invalid config property -> DMEventParticipationNpcCoordinates");
- + }
- + else
- + {
- + DM_EVENT_REWARDS = new ArrayList<int[]>();
- + DM_DOORS_IDS_TO_OPEN = new ArrayList<Integer>();
- + DM_DOORS_IDS_TO_CLOSE = new ArrayList<Integer>();
- + DM_EVENT_PARTICIPATION_NPC_COORDINATES = new int[4];
- + DM_EVENT_TEAM_1_COORDINATES = new int[3];
- + DM_EVENT_TEAM_2_COORDINATES = new int[3];
- + DM_EVENT_PARTICIPATION_NPC_COORDINATES[0] = Integer.parseInt(propertySplit[0]);
- + DM_EVENT_PARTICIPATION_NPC_COORDINATES[1] = Integer.parseInt(propertySplit[1]);
- + DM_EVENT_PARTICIPATION_NPC_COORDINATES[2] = Integer.parseInt(propertySplit[2]);
- + if (propertySplit.length == 4)
- + {
- + DM_EVENT_PARTICIPATION_NPC_COORDINATES[3] = Integer.parseInt(propertySplit[3]);
- + }
- + DM_EVENT_MIN_PLAYERS = Integer.parseInt(Event.getProperty("DMEventMinPlayers", "1"));
- + DM_EVENT_MAX_PLAYERS = Integer.parseInt(Event.getProperty("DMEventMaxPlayers", "20"));
- + DM_EVENT_MIN_LVL = (byte) Integer.parseInt(Event.getProperty("DMEventMinPlayerLevel", "1"));
- + DM_EVENT_MAX_LVL = (byte) Integer.parseInt(Event.getProperty("DMEventMaxPlayerLevel", "80"));
- + DM_EVENT_RESPAWN_TELEPORT_DELAY = Integer.parseInt(Event.getProperty("DMEventRespawnTeleportDelay", "20"));
- + DM_EVENT_START_LEAVE_TELEPORT_DELAY = Integer.parseInt(Event.getProperty("DMEventStartLeaveTeleportDelay", "20"));
- + DM_EVENT_EFFECTS_REMOVAL = Integer.parseInt(Event.getProperty("DMEventEffectsRemoval", "0"));
- + DM_EVENT_MAX_PARTICIPANTS_PER_IP = Integer.parseInt(Event.getProperty("DMEventMaxParticipantsPerIP", "0"));
- + DM_ALLOW_VOICED_COMMAND = Boolean.parseBoolean(Event.getProperty("DMAllowVoicedInfoCommand", "false"));
- + if (propertySplit.length < 3)
- + {
- + DM_EVENT_ENABLED = false;
- + _log.warning("DMEventEngine[Config.load()]: invalid config property -> DMEventCoordinates");
- + }
- + else
- + {
- + propertySplit = Event.getProperty("DMEventParticipationFee", "0,0").split(",");
- + try
- + {
- + DM_EVENT_PARTICIPATION_FEE[0] = Integer.parseInt(propertySplit[0]);
- + DM_EVENT_PARTICIPATION_FEE[1] = Integer.parseInt(propertySplit[1]);
- + }
- + catch (NumberFormatException nfe)
- + {
- + if (propertySplit.length > 0)
- + {
- + _log.warning("DMEventEngine[Config.load()]: invalid config property -> DMEventParticipationFee");
- + }
- + }
- + propertySplit = Event.getProperty("DMEventReward", "57,100000").split(";");
- + for (String reward : propertySplit)
- + {
- + String[] rewardSplit = reward.split(",");
- + if (rewardSplit.length != 2)
- + {
- + _log.warning(StringUtil.concat("DMEventEngine[Config.load()]: invalid config property -> DMEventReward \"", reward, "\""));
- + }
- + else
- + {
- + try
- + {
- + DM_EVENT_REWARDS.add(new int[]
- + {
- + Integer.parseInt(rewardSplit[0]),
- + Integer.parseInt(rewardSplit[1])
- + });
- + }
- + catch (NumberFormatException nfe)
- + {
- + if (!reward.isEmpty())
- + {
- + _log.warning(StringUtil.concat("DMEventEngine[Config.load()]: invalid config property -> DMEventReward \"", reward, "\""));
- + }
- + }
- + }
- + }
- +
- + DM_EVENT_TARGET_TEAM_MEMBERS_ALLOWED = Boolean.parseBoolean(Event.getProperty("DMEventTargetTeamMembersAllowed", "true"));
- + DM_EVENT_SCROLL_ALLOWED = Boolean.parseBoolean(Event.getProperty("DMEventScrollsAllowed", "false"));
- + DM_EVENT_POTIONS_ALLOWED = Boolean.parseBoolean(Event.getProperty("DMEventPotionsAllowed", "false"));
- + DM_EVENT_SUMMON_BY_ITEM_ALLOWED = Boolean.parseBoolean(Event.getProperty("DMEventSummonByItemAllowed", "false"));
- + DM_REWARD_TEAM_TIE = Boolean.parseBoolean(Event.getProperty("DMRewardTeamTie", "false"));
- + propertySplit = Event.getProperty("DMDoorsToOpen", "").split(";");
- + for (String door : propertySplit)
- + {
- + try
- + {
- + DM_DOORS_IDS_TO_OPEN.add(Integer.parseInt(door));
- + }
- + catch (NumberFormatException nfe)
- + {
- + if (!door.isEmpty())
- + {
- + _log.warning(StringUtil.concat("DMEventEngine[Config.load()]: invalid config property -> DMDoorsToOpen \"", door, "\""));
- + }
- + }
- + }
- +
- + propertySplit = Event.getProperty("DMDoorsToClose", "").split(";");
- + for (String door : propertySplit)
- + {
- + try
- + {
- + DM_DOORS_IDS_TO_CLOSE.add(Integer.parseInt(door));
- + }
- + catch (NumberFormatException nfe)
- + {
- + if (!door.isEmpty())
- + {
- + _log.warning(StringUtil.concat("DMEventEngine[Config.load()]: invalid config property -> DMDoorsToClose \"", door, "\""));
- + }
- + }
- + }
- +
- + propertySplit = Event.getProperty("DMEventFighterBuffs", "").split(";");
- + if (!propertySplit[0].isEmpty())
- + {
- + DM_EVENT_FIGHTER_BUFFS = new TIntIntHashMap(propertySplit.length);
- + for (String skill : propertySplit)
- + {
- + String[] skillSplit = skill.split(",");
- + if (skillSplit.length != 2)
- + {
- + _log.warning(StringUtil.concat("DMEventEngine[Config.load()]: invalid config property -> DMEventFighterBuffs \"", skill, "\""));
- + }
- + else
- + {
- + try
- + {
- + DM_EVENT_FIGHTER_BUFFS.put(Integer.parseInt(skillSplit[0]), Integer.parseInt(skillSplit[1]));
- + }
- + catch (NumberFormatException nfe)
- + {
- + if (!skill.isEmpty())
- + {
- + _log.warning(StringUtil.concat("DMEventEngine[Config.load()]: invalid config property -> DMEventFighterBuffs \"", skill, "\""));
- + }
- + }
- + }
- + }
- + }
- +
- + propertySplit = Event.getProperty("DMEventMageBuffs", "").split(";");
- + if (!propertySplit[0].isEmpty())
- + {
- + DM_EVENT_MAGE_BUFFS = new TIntIntHashMap(propertySplit.length);
- + for (String skill : propertySplit)
- + {
- + String[] skillSplit = skill.split(",");
- + if (skillSplit.length != 2)
- + {
- + _log.warning(StringUtil.concat("DMEventEngine[Config.load()]: invalid config property -> DMEventMageBuffs \"", skill, "\""));
- + }
- + else
- + {
- + try
- + {
- + DM_EVENT_MAGE_BUFFS.put(Integer.parseInt(skillSplit[0]), Integer.parseInt(skillSplit[1]));
- + }
- + catch (NumberFormatException nfe)
- + {
- + if (!skill.isEmpty())
- + {
- + _log.warning(StringUtil.concat("DMEventEngine[Config.load()]: invalid config property -> DMEventMageBuffs \"", skill, "\""));
- + }
- + }
- + }
- + }
- + }
- + }
- + }
- + }
- + }
- + catch (Exception e)
- + {
- + _log.log(Level.SEVERE, "Error while loading Event settings!", e);
- + }
- // Load Character L2Properties file (if exists)
- L2Properties Character = new L2Properties();
- final File chars = new File(CHARACTER_CONFIG_FILE);
- @@ -3002,8 +3499,8 @@
- L2JMOD_CHAMPION_HP = Integer.parseInt(L2JModSettings.getProperty("ChampionHp", "7"));
- L2JMOD_CHAMPION_HP_REGEN = Float.parseFloat(L2JModSettings.getProperty("ChampionHpRegen", "1."));
- L2JMOD_CHAMPION_REWARDS = Integer.parseInt(L2JModSettings.getProperty("ChampionRewards", "8"));
- - L2JMOD_CHAMPION_REWARDS_XP = Integer.parseInt(L2JModSettings.getProperty("ChampionXPRewards", "8"));
- - L2JMOD_CHAMPION_REWARDS_SP = Integer.parseInt(L2JModSettings.getProperty("ChampionSPRewards", "8"));
- + L2JMOD_CHAMPION_REWARDS_XP = Integer.parseInt(L2JModSettings.getProperty("ChampionXPRewards", "8"));
- + L2JMOD_CHAMPION_REWARDS_SP = Integer.parseInt(L2JModSettings.getProperty("ChampionSPRewards", "8"));
- L2JMOD_CHAMPION_ADENAS_REWARDS = Float.parseFloat(L2JModSettings.getProperty("ChampionAdenasRewards", "1"));
- L2JMOD_CHAMPION_ATK = Float.parseFloat(L2JModSettings.getProperty("ChampionAtk", "1."));
- L2JMOD_CHAMPION_SPD_ATK = Float.parseFloat(L2JModSettings.getProperty("ChampionSpdAtk", "1."));
- @@ -3072,7 +3569,7 @@
- TVT_EVENT_EFFECTS_REMOVAL = Integer.parseInt(L2JModSettings.getProperty("TvTEventEffectsRemoval", "0"));
- TVT_EVENT_MAX_PARTICIPANTS_PER_IP = Integer.parseInt(L2JModSettings.getProperty("TvTEventMaxParticipantsPerIP", "0"));
- TVT_ALLOW_VOICED_COMMAND = Boolean.parseBoolean(L2JModSettings.getProperty("TvTAllowVoicedInfoCommand", "false"));
- - TVT_ALLOW_REGISTER_VOICED_COMMAND = Boolean.parseBoolean(L2JModSettings.getProperty("TvTAllowRegisterVoicedCommand", "false"));
- + TVT_ALLOW_REGISTER_VOICED_COMMAND = Boolean.parseBoolean(L2JModSettings.getProperty("TvTAllowRegisterVoicedCommand", "false"));
- TVT_EVENT_TEAM_1_NAME = L2JModSettings.getProperty("TvTEventTeam1Name", "Team1");
- tvtNpcCoords = L2JModSettings.getProperty("TvTEventTeam1Coordinates", "0,0,0").split(",");
- if (tvtNpcCoords.length < 3)
- @@ -3594,35 +4091,38 @@
- BELETH_MIN_PLAYERS = Integer.parseInt(GrandBossSettings.getProperty("BelethMinPlayers", "36"));
- - Interval_Of_Sailren_Spawn = Integer.parseInt(GrandBossSettings.getProperty("IntervalOfSailrenSpawn", "12"));
- - if (Interval_Of_Sailren_Spawn < 1 || Interval_Of_Sailren_Spawn > 192)
- - Interval_Of_Sailren_Spawn = 12;
- - Interval_Of_Sailren_Spawn = Interval_Of_Sailren_Spawn * 3600000;
- -
- - Random_Of_Sailren_Spawn = Integer.parseInt(GrandBossSettings.getProperty("RandomOfSailrenSpawn", "24"));
- - if (Random_Of_Sailren_Spawn < 1 || Random_Of_Sailren_Spawn > 192)
- - Random_Of_Sailren_Spawn = 24;
- - Random_Of_Sailren_Spawn = Random_Of_Sailren_Spawn * 3600000;
- -
- - ZAKEN_MINLEVEL_DAYTIME = Integer.parseInt(GrandBossSettings.getProperty("ZakenMinLevelDaytime", "55"));
- - ZAKEN_MINLEVEL_DAYTIME83 = Integer.parseInt(GrandBossSettings.getProperty("ZakenMinLevelDaytime83", "78"));
- - FRINTEZZA_MINLEVEL = Integer.parseInt(GrandBossSettings.getProperty("FrintezzaMinLevel", "80"));
- -
- - FRINTEZZA_MINPLAYERS = Integer.parseInt(GrandBossSettings.getProperty("FrintezzaMinPlayers", "36"));
- - ZAKEN_MINMEMBERS_DAYTIME = Integer.parseInt(GrandBossSettings.getProperty("ZakenMinMembersDaytime", "9"));
- - ZAKEN_MINMEMBERS_NIGHTTIME = Integer.parseInt(GrandBossSettings.getProperty("ZakenMinMembersNighttime", "72"));
- -
- - ZAKEN_MAXMEMBERS_DAYTIME = Integer.parseInt(GrandBossSettings.getProperty("ZakenMaxMembersDaytime", "27"));
- - ZAKEN_MAXMEMBERS_NIGHTTIME = Integer.parseInt(GrandBossSettings.getProperty("ZakenMaxMembersNighttime", "450"));
- - FRINTEZZA_MAXPLAYERS = Integer.parseInt(GrandBossSettings.getProperty("FrintezzaMaxPlayers", "45"));
- - MIN_FREYA_PLAYERS = Integer.parseInt(GrandBossSettings.getProperty("MinFreyaPlayers", "18"));
- - MAX_FREYA_PLAYERS = Integer.parseInt(GrandBossSettings.getProperty("MaxFreyaPlayers", "27"));
- - MIN_LEVEL_PLAYERS = Integer.parseInt(GrandBossSettings.getProperty("MinLevelPlayers", "82"));
- - MIN_FREYA_HC_PLAYERS = Integer.parseInt(GrandBossSettings.getProperty("MinFreyaHcPlayers", "36"));
- - MAX_FREYA_HC_PLAYERS = Integer.parseInt(GrandBossSettings.getProperty("MaxFreyaHcPlayers", "45"));
- - MIN_LEVEL_HC_PLAYERS = Integer.parseInt(GrandBossSettings.getProperty("MinLevelHcPlayers", "82"));
- -
- -
- + Interval_Of_Sailren_Spawn = Integer.parseInt(GrandBossSettings.getProperty("IntervalOfSailrenSpawn", "12"));
- + if ((Interval_Of_Sailren_Spawn < 1) || (Interval_Of_Sailren_Spawn > 192))
- + {
- + Interval_Of_Sailren_Spawn = 12;
- + }
- + Interval_Of_Sailren_Spawn = Interval_Of_Sailren_Spawn * 3600000;
- +
- + Random_Of_Sailren_Spawn = Integer.parseInt(GrandBossSettings.getProperty("RandomOfSailrenSpawn", "24"));
- + if ((Random_Of_Sailren_Spawn < 1) || (Random_Of_Sailren_Spawn > 192))
- + {
- + Random_Of_Sailren_Spawn = 24;
- + }
- + Random_Of_Sailren_Spawn = Random_Of_Sailren_Spawn * 3600000;
- +
- + ZAKEN_MINLEVEL_DAYTIME = Integer.parseInt(GrandBossSettings.getProperty("ZakenMinLevelDaytime", "55"));
- + ZAKEN_MINLEVEL_DAYTIME83 = Integer.parseInt(GrandBossSettings.getProperty("ZakenMinLevelDaytime83", "78"));
- + FRINTEZZA_MINLEVEL = Integer.parseInt(GrandBossSettings.getProperty("FrintezzaMinLevel", "80"));
- +
- + FRINTEZZA_MINPLAYERS = Integer.parseInt(GrandBossSettings.getProperty("FrintezzaMinPlayers", "36"));
- + ZAKEN_MINMEMBERS_DAYTIME = Integer.parseInt(GrandBossSettings.getProperty("ZakenMinMembersDaytime", "9"));
- + ZAKEN_MINMEMBERS_NIGHTTIME = Integer.parseInt(GrandBossSettings.getProperty("ZakenMinMembersNighttime", "72"));
- +
- + ZAKEN_MAXMEMBERS_DAYTIME = Integer.parseInt(GrandBossSettings.getProperty("ZakenMaxMembersDaytime", "27"));
- + ZAKEN_MAXMEMBERS_NIGHTTIME = Integer.parseInt(GrandBossSettings.getProperty("ZakenMaxMembersNighttime", "450"));
- + FRINTEZZA_MAXPLAYERS = Integer.parseInt(GrandBossSettings.getProperty("FrintezzaMaxPlayers", "45"));
- + MIN_FREYA_PLAYERS = Integer.parseInt(GrandBossSettings.getProperty("MinFreyaPlayers", "18"));
- + MAX_FREYA_PLAYERS = Integer.parseInt(GrandBossSettings.getProperty("MaxFreyaPlayers", "27"));
- + MIN_LEVEL_PLAYERS = Integer.parseInt(GrandBossSettings.getProperty("MinLevelPlayers", "82"));
- + MIN_FREYA_HC_PLAYERS = Integer.parseInt(GrandBossSettings.getProperty("MinFreyaHcPlayers", "36"));
- + MAX_FREYA_HC_PLAYERS = Integer.parseInt(GrandBossSettings.getProperty("MaxFreyaHcPlayers", "45"));
- + MIN_LEVEL_HC_PLAYERS = Integer.parseInt(GrandBossSettings.getProperty("MinLevelHcPlayers", "82"));
- +
- // Gracia Seeds
- L2Properties GraciaSeedsSettings = new L2Properties();
- final File graciaseeds = new File(GRACIASEEDS_CONFIG_FILE);
- @@ -3832,31 +4332,61 @@
- {
- switch (pName.trim().toLowerCase())
- {
- - case "EnableBotReport":
- - ENABLE_BOTREPORT = Boolean.parseBoolean(pValue);
- - break;
- - case"PremiumRateXp":
- - PREMIUM_RATE_XP = Float.parseFloat(pValue);
- - break;
- - case"PremiumRateSp":
- - PREMIUM_RATE_SP = Float.parseFloat(pValue);
- - break;
- - case"PremiumRateDropItems":
- - PREMIUM_RATE_DROP_ITEMS = Float.parseFloat(pValue);
- - break;
- - case"PremiumRateRaidDropItems":
- - PREMIUM_RATE_DROP_ITEMS_BY_RAID = Float.parseFloat(pValue);
- - break;
- - case"PremiumRateDropSpoil":
- - PREMIUM_RATE_DROP_SPOIL = Float.parseFloat(pValue);
- - break;
- - case"PremiumRateDropAdena":
- - PREMIUM_RATE_DROP_ITEMS_ID.put(PcInventory.ADENA_ID, Float.parseFloat(pValue));
- - break;
- + case "CTFEventEnabled":
- + TVT_EVENT_ENABLED = Boolean.parseBoolean(pValue);
- + break;
- + case "CTFEventInterval":
- + TVT_EVENT_INTERVAL = pValue.split(",");
- + break;
- + case "CTFEventParticipationTime":
- + TVT_EVENT_PARTICIPATION_TIME = Integer.parseInt(pValue);
- + break;
- + case "CTFEventRunningTime":
- + TVT_EVENT_RUNNING_TIME = Integer.parseInt(pValue);
- + break;
- + case "CTFEventParticipationNpcId":
- + TVT_EVENT_PARTICIPATION_NPC_ID = Integer.parseInt(pValue);
- + break;
- + case "DMEventEnabled":
- + TVT_EVENT_ENABLED = Boolean.parseBoolean(pValue);
- + break;
- + case "DMEventInterval":
- + TVT_EVENT_INTERVAL = pValue.split(",");
- + break;
- + case "DMEventParticipationTime":
- + TVT_EVENT_PARTICIPATION_TIME = Integer.parseInt(pValue);
- + break;
- + case "DMEventRunningTime":
- + TVT_EVENT_RUNNING_TIME = Integer.parseInt(pValue);
- + break;
- + case "DMEventParticipationNpcId":
- + TVT_EVENT_PARTICIPATION_NPC_ID = Integer.parseInt(pValue);
- + case "EnableBotReport":
- + break;
- + ENABLE_BOTREPORT = Boolean.parseBoolean(pValue);
- + break;
- + case "PremiumRateXp":
- + PREMIUM_RATE_XP = Float.parseFloat(pValue);
- + break;
- + case "PremiumRateSp":
- + PREMIUM_RATE_SP = Float.parseFloat(pValue);
- + break;
- + case "PremiumRateDropItems":
- + PREMIUM_RATE_DROP_ITEMS = Float.parseFloat(pValue);
- + break;
- + case "PremiumRateRaidDropItems":
- + PREMIUM_RATE_DROP_ITEMS_BY_RAID = Float.parseFloat(pValue);
- + break;
- + case "PremiumRateDropSpoil":
- + PREMIUM_RATE_DROP_SPOIL = Float.parseFloat(pValue);
- + break;
- + case "PremiumRateDropAdena":
- + PREMIUM_RATE_DROP_ITEMS_ID.put(PcInventory.ADENA_ID, Float.parseFloat(pValue));
- + break;
- case "RateXp":
- RATE_XP = Float.parseFloat(pValue);
- break;
- - // rates.properties
- + // rates.properties
- case "ratexp":
- RATE_XP = Float.parseFloat(pValue);
- break;
- @@ -4544,12 +5074,12 @@
- case "championrewards":
- L2JMOD_CHAMPION_REWARDS = Integer.parseInt(pValue);
- break;
- - case "ChampionXPRewards":
- - L2JMOD_CHAMPION_REWARDS_XP = Integer.parseInt(pValue);
- - break;
- - case "ChampionSPRewards":
- - L2JMOD_CHAMPION_REWARDS_SP = Integer.parseInt(pValue);
- - break;
- + case "ChampionXPRewards":
- + L2JMOD_CHAMPION_REWARDS_XP = Integer.parseInt(pValue);
- + break;
- + case "ChampionSPRewards":
- + L2JMOD_CHAMPION_REWARDS_SP = Integer.parseInt(pValue);
- + break;
- case "championadenasrewards":
- L2JMOD_CHAMPION_ADENAS_REWARDS = Float.parseFloat(pValue);
- break;
- Index: java/com/l2jserver/gameserver/network/serverpackets/Die.java
- ===================================================================
- --- java/com/l2jserver/gameserver/network/serverpackets/Die.java (revision 65)
- +++ java/com/l2jserver/gameserver/network/serverpackets/Die.java (working copy)
- @@ -25,7 +25,9 @@
- import com.l2jserver.gameserver.model.actor.L2Attackable;
- import com.l2jserver.gameserver.model.actor.L2Character;
- import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
- +import com.l2jserver.gameserver.model.entity.CTFEvent;
- import com.l2jserver.gameserver.model.entity.Castle;
- +import com.l2jserver.gameserver.model.entity.DMEvent;
- import com.l2jserver.gameserver.model.entity.Fort;
- import com.l2jserver.gameserver.model.entity.TvTEvent;
- import com.l2jserver.gameserver.model.entity.TvTRoundEvent;
- @@ -56,7 +58,7 @@
- }
- _charObjId = cha.getObjectId();
- - _canTeleport = !((cha.isPlayer() && ((TvTEvent.isStarted() && TvTEvent.isPlayerParticipant(_charObjId)) || (TvTRoundEvent.isStarted() && TvTRoundEvent.isPlayerParticipant(_charObjId)))) ||cha.isPendingRevive());
- + _canTeleport = !(((cha.isPlayer() && ((TvTEvent.isStarted() && TvTEvent.isPlayerParticipant(_charObjId)) || ((CTFEvent.isStarted() && CTFEvent.isPlayerParticipant(_charObjId)) || (DMEvent.isStarted() && DMEvent.isPlayerParticipant(_charObjId)) || (TvTRoundEvent.isStarted() && TvTRoundEvent.isPlayerParticipant(_charObjId))))) || cha.isPendingRevive()));
- if (cha.isL2Attackable())
- {
- _sweepable = ((L2Attackable) cha).isSweepActive();
- Index: java/com/l2jserver/gameserver/model/actor/instance/L2CubicInstance.java
- ===================================================================
- --- java/com/l2jserver/gameserver/model/actor/instance/L2CubicInstance.java (revision 65)
- +++ java/com/l2jserver/gameserver/model/actor/instance/L2CubicInstance.java (working copy)
- @@ -34,6 +34,9 @@
- import com.l2jserver.gameserver.model.actor.L2Character;
- import com.l2jserver.gameserver.model.actor.L2Playable;
- import com.l2jserver.gameserver.model.effects.L2Effect;
- +import com.l2jserver.gameserver.model.entity.CTFEvent;
- +import com.l2jserver.gameserver.model.entity.CTFEventTeam;
- +import com.l2jserver.gameserver.model.entity.DMEvent;
- import com.l2jserver.gameserver.model.entity.TvTEvent;
- import com.l2jserver.gameserver.model.entity.TvTEventTeam;
- import com.l2jserver.gameserver.model.entity.TvTRoundEvent;
- @@ -306,6 +309,36 @@
- {
- return;
- }
- + // CTF event targeting
- + if (CTFEvent.isStarted() && CTFEvent.isPlayerParticipant(_owner.getObjectId()))
- + {
- + CTFEventTeam enemyTeam = CTFEvent.getParticipantEnemyTeam(_owner.getObjectId());
- +
- + if (ownerTarget.getActingPlayer() != null)
- + {
- + L2PcInstance target = ownerTarget.getActingPlayer();
- + if (enemyTeam.containsPlayer(target.getObjectId()) && !(target.isDead()))
- + {
- + _target = (L2Character) ownerTarget;
- + }
- + }
- + return;
- + }
- + // DM event targeting
- + if (DMEvent.isStarted() && DMEvent.isPlayerParticipant(_owner.getObjectId()))
- + {
- + DMEventTeam enemyTeam = DMEvent.getParticipantEnemyTeam(_owner.getObjectId());
- +
- + if (ownerTarget.getActingPlayer() != null)
- + {
- + L2PcInstance target = ownerTarget.getActingPlayer();
- + if (enemyTeam.containsPlayer(target.getObjectId()) && !(target.isDead()))
- + {
- + _target = (L2Character) ownerTarget;
- + }
- + }
- + return;
- + }
- // TvT event targeting
- if (TvTEvent.isStarted() && TvTEvent.isPlayerParticipant(_owner.getObjectId()))
- {
- @@ -321,7 +354,7 @@
- }
- return;
- }
- -
- +
- // TvT Round event targeting
- if (TvTRoundEvent.isStarted() && TvTRoundEvent.isPlayerParticipant(_owner.getObjectId()))
- {
- Index: java/com/l2jserver/gameserver/model/entity/CTFEvent.java
- ===================================================================
- --- java/com/l2jserver/gameserver/model/entity/CTFEvent.java (revision 0)
- +++ java/com/l2jserver/gameserver/model/entity/CTFEvent.java (working copy)
- @@ -0,0 +1,3243 @@
- +/*
- + * This program is free software: you can redistribute it and/or modify it under
- + * the terms of the GNU General Public License as published by the Free Software
- + * Foundation, either version 3 of the License, or (at your option) any later
- + * version.
- + *
- + * This program is distributed in the hope that it will be useful, but WITHOUT
- + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- + * details.
- + *
- + * You should have received a copy of the GNU General Public License along with
- + * this program. If not, see <http://www.gnu.org/licenses/>.
- + */
- +package com.l2jserver.gameserver.model.entity;
- +
- +import java.sql.Connection;
- +import java.sql.PreparedStatement;
- +import java.sql.ResultSet;
- +import java.sql.SQLException;
- +import java.util.Calendar;
- +import java.util.Map;
- +import java.util.Vector;
- +import java.util.concurrent.ScheduledFuture;
- +import java.util.logging.Logger;
- +
- +import javolution.text.TextBuilder;
- +import javolution.util.FastMap;
- +
- +import com.l2jserver.Config;
- +import com.l2jserver.L2DatabaseFactory;
- +import com.l2jserver.gameserver.Announcements;
- +import com.l2jserver.gameserver.ThreadPoolManager;
- +import com.l2jserver.gameserver.datatables.ItemTable;
- +import com.l2jserver.gameserver.datatables.NpcTable;
- +import com.l2jserver.gameserver.datatables.SpawnTable;
- +import com.l2jserver.gameserver.model.L2Party;
- +import com.l2jserver.gameserver.model.L2Radar;
- +import com.l2jserver.gameserver.model.L2Spawn;
- +import com.l2jserver.gameserver.model.actor.L2Character;
- +import com.l2jserver.gameserver.model.actor.L2Summon;
- +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
- +import com.l2jserver.gameserver.model.actor.instance.L2PetInstance;
- +import com.l2jserver.gameserver.model.actor.templates.L2NpcTemplate;
- +import com.l2jserver.gameserver.model.effects.L2Effect;
- +import com.l2jserver.gameserver.model.effects.L2EffectType;
- +import com.l2jserver.gameserver.model.itemcontainer.Inventory;
- +import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
- +import com.l2jserver.gameserver.model.skills.L2Skill;
- +import com.l2jserver.gameserver.network.SystemMessageId;
- +import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
- +import com.l2jserver.gameserver.network.serverpackets.CreatureSay;
- +import com.l2jserver.gameserver.network.serverpackets.InventoryUpdate;
- +import com.l2jserver.gameserver.network.serverpackets.ItemList;
- +import com.l2jserver.gameserver.network.serverpackets.MagicSkillUse;
- +import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
- +import com.l2jserver.gameserver.network.serverpackets.PlaySound;
- +import com.l2jserver.gameserver.network.serverpackets.RadarControl;
- +import com.l2jserver.gameserver.network.serverpackets.SocialAction;
- +import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
- +import com.l2jserver.util.Rnd;
- +
- +public class CTFEvent
- +{
- + /** Task for event cycles<br> */
- + private CTFStartTask _task1;
- +
- + private CTFEvent()
- + {
- + if (Config.CTF_EVENT_ENABLED)
- + {
- + loadData();
- + this.scheduleCTFEventStart();
- + _log.warning("CTFEventEngine[CTF.CTF()]: Started.");
- + }
- + else
- + {
- + _log.warning("CTFEventEngine[CTF.CTF()]: Engine is disabled.");
- + }
- + }
- +
- + /**
- + * Initialize new/Returns the one and only instance<br>
- + * <br>
- + * @return CTF<br>
- + */
- + public static CTFEvent getInstance()
- + {
- + return SingletonHolder._instance;
- + }
- +
- + /**
- + * Starts CTFStartTask
- + */
- + public void scheduleCTFEventStart()
- + {
- + try
- + {
- + Calendar currentTime = Calendar.getInstance();
- + Calendar nextStartTime = null;
- + Calendar testStartTime = null;
- + for (String timeOfDay : Config.CTF_EVENT_INTERVAL)
- + {
- + // Creating a Calendar object from the specified interval value
- + 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 the date is in the past, make it the next day (Example: Checking for "1:00", when the time is 23:57.)
- + if (testStartTime.getTimeInMillis() < currentTime.getTimeInMillis())
- + {
- + testStartTime.add(Calendar.DAY_OF_MONTH, 1);
- + }
- + // Check for the test date to be the minimum (smallest in the specified list)
- + if ((nextStartTime == null) || (testStartTime.getTimeInMillis() < nextStartTime.getTimeInMillis()))
- + {
- + nextStartTime = testStartTime;
- + }
- + }
- + _task1 = new CTFStartTask(nextStartTime.getTimeInMillis());
- + ThreadPoolManager.getInstance().executeTask(_task1);
- + }
- + catch (Exception e)
- + {
- + _log.warning("CTFEventEngine: Error figuring out a start time. Check CTFEventInterval in config file.");
- + }
- + }
- +
- + public void skipDelay()
- + {
- + if (_task1.nextRun.cancel(false))
- + {
- + _task1.setStartTime(System.currentTimeMillis());
- + ThreadPoolManager.getInstance().executeTask(_task1);
- + }
- + }
- +
- + /**
- + * Class forCTFT cycles
- + */
- + class CTFStartTask implements Runnable
- + {
- + private long _startTime;
- + public ScheduledFuture<?> nextRun;
- +
- + public CTFStartTask(long startTime)
- + {
- + _startTime = startTime;
- + }
- +
- + public void setStartTime(long startTime)
- + {
- + _startTime = startTime;
- + }
- +
- + /**
- + * @see java.lang.Runnable#run()
- + */
- + @Override
- + public void run()
- + {
- + int delay = (int) Math.round((_startTime - System.currentTimeMillis()) / 1000.0);
- +
- + 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
- + {
- + // start
- +
- + autoEvent();
- + _task1.setStartTime(System.currentTimeMillis() + (60000L * 225));
- + ThreadPoolManager.getInstance().executeTask(_task1);
- + }
- +
- + if (delay > 0)
- + {
- + nextRun = ThreadPoolManager.getInstance().scheduleGeneral(this, nextMsg * 1000);
- + }
- + }
- + }
- +
- + private final static Logger _log = Logger.getLogger(CTFEvent.class.getName());
- + private static int _FlagNPC = 35062, _FLAG_IN_HAND_ITEM_ID = 6718;
- + public static String _eventName = new String(), _eventDesc = new String(), _topTeam = new String(), _joiningLocationName = new String();
- + public static Vector<String> _teams = new Vector<String>(), _savePlayers = new Vector<String>(), _savePlayerTeams = new Vector<String>();
- + public static Vector<L2PcInstance> _players = new Vector<L2PcInstance>(), _playersShuffle = new Vector<L2PcInstance>();
- + public static Vector<Integer> _teamPlayersCount = new Vector<Integer>(), _teamColors = new Vector<Integer>(), _teamsX = new Vector<Integer>(), _teamsY = new Vector<Integer>(), _teamsZ = new Vector<Integer>(), _teamsBaseX = new Vector<Integer>(), _teamsBaseY = new Vector<Integer>(),
- + _teamsBaseZ = new Vector<Integer>();
- + public static boolean _joining = false, _teleport = false, _started = false, _sitForced = false;
- + public static L2Spawn _npcSpawn;
- + public static int _npcId = 0, _npcX = 0, _npcY = 0, _npcZ = 0, _npcHeading = 0, _rewardId = 0, _rewardAmount = 0, _minlvl = 0, _maxlvl = 0, _joinTime = 0, _eventTime = 0, _minPlayers = 0, _maxPlayers = 0;
- + public static long _flagHoldTime = 0;
- + public static Vector<Integer> _teamPointsCount = new Vector<Integer>();
- + public static Vector<Integer> _flagIds = new Vector<Integer>(), _flagsX = new Vector<Integer>(), _flagsY = new Vector<Integer>(), _flagsZ = new Vector<Integer>();
- + public static Vector<L2Spawn> _flagSpawns = new Vector<L2Spawn>(), _throneSpawns = new Vector<L2Spawn>();
- + public static Vector<Boolean> _flagsTaken = new Vector<Boolean>(), _flagsNotRemoved = new Vector<Boolean>();
- + public static int _topScore = 0, eventCenterX = 0, eventCenterY = 0, eventCenterZ = 0, eventOffset = 0;
- + public static Map<String, Integer> _playerScores = new FastMap<String, Integer>();
- +
- + public static void showFlagHtml(L2PcInstance eventPlayer, String objectId, String teamName)
- + {
- + if (eventPlayer == null)
- + {
- + return;
- + }
- +
- + try
- + {
- + NpcHtmlMessage adminReply = new NpcHtmlMessage(0);
- +
- + TextBuilder replyMSG = new TextBuilder();
- +
- + replyMSG.append("<html><body><center>");
- + replyMSG.append("CTF Flag<br><br>");
- + replyMSG.append("<font color=\"00FF00\">" + teamName + "'s Flag</font><br>");
- + if ((eventPlayer._teamNameCTF != null) && eventPlayer._teamNameCTF.equals(teamName))
- + {
- + replyMSG.append("<font color=\"LEVEL\">This is your Flag</font><br>");
- + }
- + else
- + {
- + replyMSG.append("<font color=\"LEVEL\">Enemy Flag!</font><br>");
- + }
- + if (_started)
- + {
- + processInFlagRange(eventPlayer);
- + }
- + else
- + {
- + replyMSG.append("CTF match is not in progress yet.<br>Wait for a GM to start the event<br>");
- + }
- + replyMSG.append("</center></body></html>");
- + adminReply.setHtml(replyMSG.toString());
- + eventPlayer.sendPacket(adminReply);
- + }
- + catch (Exception e)
- + {
- + _log.warning("" + "CTF Engine[showEventHtlm(" + eventPlayer.getName() + ", " + objectId + ")]: exception: " + e.getStackTrace());
- + }
- + }
- +
- + public static void CheckRestoreFlags()
- + {
- + Vector<Integer> teamsTakenFlag = new Vector<Integer>();
- + try
- + {
- + for (L2PcInstance player : _players)
- + { // if there's a player with a flag
- + // add the index of the team who's FLAG WAS TAKEN to the list
- + if (player != null)
- + {
- + if (!player.isOnline() && player._haveFlagCTF)// logged off with a flag in his hands
- + {
- + AnnounceToPlayers(false, "CTF Event: " + player.getName() + " logged off with a CTF flag!");
- + player._haveFlagCTF = false;
- + if (_teams.indexOf(player._teamNameHaveFlagCTF) >= 0)
- + {
- + if (_flagsTaken.get(_teams.indexOf(player._teamNameHaveFlagCTF)))
- + {
- + _flagsTaken.set(_teams.indexOf(player._teamNameHaveFlagCTF), false);
- + spawnFlag(player._teamNameHaveFlagCTF);
- + AnnounceToPlayers(false, "CTF Event: " + player._teamNameHaveFlagCTF + " flag now returned to place.");
- + }
- + }
- + removeFlagFromPlayer(player);
- + player._teamNameHaveFlagCTF = null;
- + return;
- + }
- + else if (player._haveFlagCTF)
- + {
- + teamsTakenFlag.add(_teams.indexOf(player._teamNameHaveFlagCTF));
- + }
- + }
- + }
- + // Go over the list of ALL teams
- + for (String team : _teams)
- + {
- + if (team == null)
- + {
- + continue;
- + }
- + int index = _teams.indexOf(team);
- + if (!teamsTakenFlag.contains(index))
- + {
- + if (_flagsTaken.get(index))
- + {
- + _flagsTaken.set(index, false);
- + spawnFlag(team);
- + AnnounceToPlayers(false, "CTF Event: " + team + " flag returned due to player error.");
- + }
- + }
- + }
- + // Check if a player ran away from the event holding a flag:
- + for (L2PcInstance player : _players)
- + {
- + if ((player != null) && player._haveFlagCTF)
- + {
- + if (isOutsideCTFArea(player))
- + {
- + AnnounceToPlayers(false, "CTF Event: " + player.getName() + " escaped from the event holding a flag!");
- + player._haveFlagCTF = false;
- + if (_teams.indexOf(player._teamNameHaveFlagCTF) >= 0)
- + {
- + if (_flagsTaken.get(_teams.indexOf(player._teamNameHaveFlagCTF)))
- + {
- + _flagsTaken.set(_teams.indexOf(player._teamNameHaveFlagCTF), false);
- + spawnFlag(player._teamNameHaveFlagCTF);
- + AnnounceToPlayers(false, "CTF Event: " + player._teamNameHaveFlagCTF + " flag now returned to place.");
- + }
- + }
- + removeFlagFromPlayer(player);
- + player._teamNameHaveFlagCTF = null;
- + if (Config.CTF_BASE_TELEPORT_FIRST)
- + {
- + player.teleToLocation(_teamsBaseX.get(_teams.indexOf(player._teamNameCTF)), _teamsBaseY.get(_teams.indexOf(player._teamNameCTF)), _teamsBaseZ.get(_teams.indexOf(player._teamNameCTF)));
- +
- + ThreadPoolManager.getInstance().scheduleGeneral(new BaseTeleportTask(player, false), 10000);
- +
- + player.sendMessage("You have been returned to your base. You will be sent into battle in 10 seconds.");
- + }
- + else
- + {
- + player.teleToLocation(_teamsX.get(_teams.indexOf(player._teamNameCTF)), _teamsY.get(_teams.indexOf(player._teamNameCTF)), _teamsZ.get(_teams.indexOf(player._teamNameCTF)));
- + player.sendMessage("You have been returned to your team spawn.");
- + }
- + return;
- + }
- + }
- + }
- + }
- + catch (Exception e)
- + {
- + _log.warning("CTF.restoreFlags() Error:" + e.toString());
- + }
- + }
- +
- + public static void kickPlayerFromCTf(L2PcInstance playerToKick)
- + {
- + if (playerToKick == null)
- + {
- + return;
- + }
- +
- + if (_joining)
- + {
- + _playersShuffle.remove(playerToKick);
- + _players.remove(playerToKick);
- + playerToKick._inEventCTF = false;
- + playerToKick._teamNameCTF = new String();
- + }
- + if (_started || _teleport)
- + {
- + _playersShuffle.remove(playerToKick);
- + playerToKick._inEventCTF = false;
- + removePlayer(playerToKick);
- + if (playerToKick.isOnline())
- + {
- + playerToKick.getAppearance().setNameColor(playerToKick._originalNameColorCTF);
- + playerToKick.setKarma(playerToKick._originalKarmaCTF);
- + playerToKick.setTitle(playerToKick._originalTitleCTF);
- + playerToKick.broadcastUserInfo();
- + playerToKick.sendMessage("You have been kicked from the CTF.");
- + playerToKick.teleToLocation(_npcX, _npcY, _npcZ, false);
- + }
- + }
- + }
- +
- + public static void AnnounceToPlayers(Boolean toall, String announce)
- + {
- + if (toall)
- + {
- + Announcements.getInstance().announceToAll(announce);
- + }
- + else
- + {
- + CreatureSay cs = new CreatureSay(0, 2, "", "Announcements : " + announce);
- + if ((_players != null) && !_players.isEmpty())
- + {
- + for (L2PcInstance player : _players)
- + {
- + if ((player != null) && player.isOnline())
- + {
- + player.sendPacket(cs);
- + }
- + }
- + }
- + }
- + }
- +
- + public static void Started(L2PcInstance player)
- + {
- + player._teamNameHaveFlagCTF = null;
- + player._haveFlagCTF = false;
- + }
- +
- + public static void StartEvent()
- + {
- + for (L2PcInstance player : _players)
- + {
- + if (player != null)
- + {
- + player._teamNameHaveFlagCTF = null;
- + player._haveFlagCTF = false;
- + }
- + }
- + }
- +
- + public static void addFlagToPlayer(L2PcInstance _player)
- + {
- + // remove items from the player hands (right, left, both)
- + // This is NOT a BUG, I don't want them to see the icon they have 8D
- + L2ItemInstance wpn = _player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND);
- + if (wpn == null)
- + {
- + wpn = _player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND);
- + if (wpn != null)
- + {
- + _player.getInventory().unEquipItemInBodySlotAndRecord(Inventory.PAPERDOLL_RHAND);
- + }
- + }
- + else
- + {
- + _player.getInventory().unEquipItemInBodySlotAndRecord(Inventory.PAPERDOLL_RHAND);
- + wpn = _player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_LHAND);
- + if (wpn != null)
- + {
- + _player.getInventory().unEquipItemInBodySlotAndRecord(Inventory.PAPERDOLL_LHAND);
- + }
- + }
- + // add the flag in his hands
- + _player.getInventory().equipItem(ItemTable.getInstance().createItem("", CTF._FLAG_IN_HAND_ITEM_ID, 1, _player, null));
- + _player.broadcastPacket(new SocialAction(_player, 16)); // amazing glow
- + _player._haveFlagCTF = true;
- + _player.broadcastUserInfo();
- + CreatureSay cs = new CreatureSay(_player.getObjectId(), 15, ":", "You got it! Run back! ::"); // 8D
- + _player.sendPacket(cs);
- +
- + // Start the flag holding timer
- + _flagsNotRemoved.set(_teams.indexOf(_player._teamNameCTF), true);
- + flagHoldTimer(_player, _flagHoldTime);
- +
- + // If player is invisible, make them visible
- + if (_player.getAppearance().getInvisible())
- + {
- + @SuppressWarnings("unused")
- + L2Effect eInvisible = _player.getFirstEffect(L2EffectType.HIDE);
- + }
- + }
- +
- + public static void removeFlagFromPlayer(L2PcInstance player)
- + {
- + L2ItemInstance wpn = player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND);
- + player._haveFlagCTF = false;
- +
- + // Reset boolean of whether the holder's flag has not been removed yet to false and kill the flagHoldTimer thread
- + _flagsNotRemoved.set(_teams.indexOf(player._teamNameCTF), false);
- +
- + if (wpn != null)
- + {
- + L2ItemInstance[] unequiped = player.getInventory().unEquipItemInBodySlotAndRecord(wpn.getItem().getBodyPart());
- + player.getInventory().destroyItemByItemId("", CTF._FLAG_IN_HAND_ITEM_ID, 1, player, null);
- + InventoryUpdate iu = new InventoryUpdate();
- + for (L2ItemInstance element : unequiped)
- + {
- + iu.addModifiedItem(element);
- + }
- + player.sendPacket(iu);
- + player.sendPacket(new ItemList(player, true)); // get your weapon back now ...
- + player.abortAttack();
- + player.broadcastUserInfo();
- + }
- + else
- + {
- + player.getInventory().destroyItemByItemId("", CTF._FLAG_IN_HAND_ITEM_ID, 1, player, null);
- + player.sendPacket(new ItemList(player, true)); // get your weapon back now ...
- + player.abortAttack();
- + player.broadcastUserInfo();
- + }
- + }
- +
- + public static void setTeamFlag(String teamName, L2PcInstance activeChar)
- + {
- + int index = _teams.indexOf(teamName);
- +
- + if (index == -1)
- + {
- + return;
- + }
- + addOrSet(_teams.indexOf(teamName), null, false, _FlagNPC, activeChar.getX(), activeChar.getY(), activeChar.getZ());
- + }
- +
- + public static void setTeamFlag(String teamName, int x, int y, int z)
- + {
- + int index = _teams.indexOf(teamName);
- +
- + if (index == -1)
- + {
- + return;
- + }
- + addOrSet(_teams.indexOf(teamName), null, false, _FlagNPC, x, y, z);
- + }
- +
- + public static void spawnAllFlags()
- + {
- + while (_flagSpawns.size() < _teams.size())
- + {
- + _flagSpawns.add(null);
- + }
- + while (_throneSpawns.size() < _teams.size())
- + {
- + _throneSpawns.add(null);
- + }
- + for (String team : _teams)
- + {
- + int index = _teams.indexOf(team);
- + L2NpcTemplate tmpl = NpcTable.getInstance().getTemplate(_flagIds.get(index));
- + L2NpcTemplate throne = NpcTable.getInstance().getTemplate(32027);
- + try
- + {
- + // spawn throne
- + _throneSpawns.set(index, new L2Spawn(throne));
- + _throneSpawns.get(index).setLocx(_flagsX.get(index));
- + _throneSpawns.get(index).setLocy(_flagsY.get(index));
- + _throneSpawns.get(index).setLocz(_flagsZ.get(index) - 10);
- + _throneSpawns.get(index).setAmount(1);
- + _throneSpawns.get(index).setHeading(0);
- + _throneSpawns.get(index).setRespawnDelay(1);
- + SpawnTable.getInstance().addNewSpawn(_throneSpawns.get(index), false);
- + _throneSpawns.get(index).init();
- + _throneSpawns.get(index).getLastSpawn().getStatus().setCurrentHp(999999999);
- + _throneSpawns.get(index).getLastSpawn().decayMe();
- + _throneSpawns.get(index).getLastSpawn().spawnMe(_throneSpawns.get(index).getLastSpawn().getX(), _throneSpawns.get(index).getLastSpawn().getY(), _throneSpawns.get(index).getLastSpawn().getZ());
- + _throneSpawns.get(index).getLastSpawn().setTitle(team + " Throne");
- + _throneSpawns.get(index).getLastSpawn().broadcastPacket(new MagicSkillUse(_throneSpawns.get(index).getLastSpawn(), _throneSpawns.get(index).getLastSpawn(), 1036, 1, 5500, 1));
- + _throneSpawns.get(index).getLastSpawn()._isCTF_throneSpawn = true;
- +
- + // spawn flag
- + _flagSpawns.set(index, new L2Spawn(tmpl));
- + _flagSpawns.get(index).setLocx(_flagsX.get(index));
- + _flagSpawns.get(index).setLocy(_flagsY.get(index));
- + _flagSpawns.get(index).setLocz(_flagsZ.get(index));
- + _flagSpawns.get(index).setAmount(1);
- + _flagSpawns.get(index).setHeading(0);
- + _flagSpawns.get(index).setRespawnDelay(1);
- + SpawnTable.getInstance().addNewSpawn(_flagSpawns.get(index), false);
- + _flagSpawns.get(index).init();
- + _flagSpawns.get(index).getLastSpawn().getStatus().setCurrentHp(999999999);
- + _flagSpawns.get(index).getLastSpawn().setTitle(team + "'s Flag");
- + _flagSpawns.get(index).getLastSpawn()._CTF_FlagTeamName = team;
- + _flagSpawns.get(index).getLastSpawn().decayMe();
- + _flagSpawns.get(index).getLastSpawn().spawnMe(_flagSpawns.get(index).getLastSpawn().getX(), _flagSpawns.get(index).getLastSpawn().getY(), _flagSpawns.get(index).getLastSpawn().getZ());
- + _flagSpawns.get(index).getLastSpawn()._isCTF_Flag = true;
- + if (index == (_teams.size() - 1))
- + {
- + calculateOutSideOfCTF(); // sets event boundaries so players don't run with the flag.
- + }
- + }
- + catch (Exception e)
- + {
- + _log.warning("CTF Engine[spawnAllFlags()]: exception: " + e.getStackTrace());
- + }
- + }
- + }
- +
- + public static void processTopTeam()
- + {
- +
- + _topTeam = null;
- + for (String team : _teams)
- + {
- + if ((teamPointsCount(team) == _topScore) && (_topScore > 0))
- + {
- + _topTeam = null;
- + }
- + if (teamPointsCount(team) > _topScore)
- + {
- + _topTeam = team;
- + _topScore = teamPointsCount(team);
- + }
- + }
- + if (_topScore <= 0)
- + {
- + AnnounceToPlayers(true, "CTF Event: No flags taken.");
- + }
- + else
- + {
- + if (_topTeam == null)
- + {
- + AnnounceToPlayers(true, "CTF Event: Maximum flags taken : " + _topScore + " flags! No one won.");
- + }
- + else
- + {
- + AnnounceToPlayers(true, "CTF Event: Team " + _topTeam + " wins the match, with " + _topScore + " flags taken!");
- + rewardTeam(_topTeam);
- + }
- + }
- + }
- +
- + public static void unspawnAllFlags()
- + {
- + try
- + {
- + if ((_throneSpawns == null) || (_flagSpawns == null) || (_teams == null))
- + {
- + return;
- + }
- + for (String team : _teams)
- + {
- + int index = _teams.indexOf(team);
- + if (_throneSpawns.get(index) != null)
- + {
- + _throneSpawns.get(index).getLastSpawn().deleteMe();
- + _throneSpawns.get(index).stopRespawn();
- + SpawnTable.getInstance().deleteSpawn(_throneSpawns.get(index), true);
- + }
- + if (_flagSpawns.get(index) != null)
- + {
- + _flagSpawns.get(index).getLastSpawn().deleteMe();
- + _flagSpawns.get(index).stopRespawn();
- + SpawnTable.getInstance().deleteSpawn(_flagSpawns.get(index), true);
- + }
- + }
- + _throneSpawns.removeAllElements();
- + }
- + catch (Throwable t)
- + {
- + _log.warning("CTF Engine[unspawnAllFlags()]: exception: " + t.getStackTrace());
- + }
- + }
- +
- + private static void unspawnFlag(String teamName)
- + {
- + int index = _teams.indexOf(teamName);
- +
- + _flagSpawns.get(index).getLastSpawn().deleteMe();
- + _flagSpawns.get(index).stopRespawn();
- + SpawnTable.getInstance().deleteSpawn(_flagSpawns.get(index), true);
- + }
- +
- + public static void spawnFlag(String teamName)
- + {
- + int index = _teams.indexOf(teamName);
- + L2NpcTemplate tmpl = NpcTable.getInstance().getTemplate(_flagIds.get(index));
- +
- + try
- + {
- + _flagSpawns.set(index, new L2Spawn(tmpl));
- +
- + _flagSpawns.get(index).setLocx(_flagsX.get(index));
- + _flagSpawns.get(index).setLocy(_flagsY.get(index));
- + _flagSpawns.get(index).setLocz(_flagsZ.get(index));
- + _flagSpawns.get(index).setAmount(1);
- + _flagSpawns.get(index).setHeading(0);
- + _flagSpawns.get(index).setRespawnDelay(1);
- +
- + SpawnTable.getInstance().addNewSpawn(_flagSpawns.get(index), false);
- +
- + _flagSpawns.get(index).init();
- + _flagSpawns.get(index).getLastSpawn().getStatus().setCurrentHp(999999999);
- + _flagSpawns.get(index).getLastSpawn().setTitle(teamName + "'s Flag");
- + _flagSpawns.get(index).getLastSpawn()._CTF_FlagTeamName = teamName;
- + _flagSpawns.get(index).getLastSpawn()._isCTF_Flag = true;
- + _flagSpawns.get(index).getLastSpawn().decayMe();
- + _flagSpawns.get(index).getLastSpawn().spawnMe(_flagSpawns.get(index).getLastSpawn().getX(), _flagSpawns.get(index).getLastSpawn().getY(), _flagSpawns.get(index).getLastSpawn().getZ());
- + }
- + catch (Exception e)
- + {
- + _log.warning("CTF Engine[spawnFlag(" + teamName + ")]: exception: " + e.getStackTrace());
- + }
- + }
- +
- + public static boolean InRangeOfFlag(L2PcInstance _player, int flagIndex, int offset)
- + {
- + if ((_player.getX() > (CTF._flagsX.get(flagIndex) - offset)) && (_player.getX() < (CTF._flagsX.get(flagIndex) + offset)) && (_player.getY() > (CTF._flagsY.get(flagIndex) - offset)) && (_player.getY() < (CTF._flagsY.get(flagIndex) + offset)) && (_player.getZ() > (CTF._flagsZ.get(flagIndex) - offset)) && (_player.getZ() < (CTF._flagsZ.get(flagIndex) + offset)))
- + {
- + return true;
- + }
- + return false;
- + }
- +
- + public static void processInFlagRange(L2PcInstance _player)
- + {
- + try
- + {
- + CheckRestoreFlags();
- + for (String team : _teams)
- + {
- + if (team.equals(_player._teamNameCTF))
- + {
- + int indexOwn = _teams.indexOf(_player._teamNameCTF);
- +
- + // if player is near his team flag holding the enemy flag
- + if (InRangeOfFlag(_player, indexOwn, 100) && !_flagsTaken.get(indexOwn) && _player._haveFlagCTF)
- + {
- + int indexEnemy = _teams.indexOf(_player._teamNameHaveFlagCTF);
- + // return enemy flag to place
- + _flagsTaken.set(indexEnemy, false);
- + spawnFlag(_player._teamNameHaveFlagCTF);
- + // remove the flag from this player
- + _player.broadcastPacket(new SocialAction(_player, 16)); // amazing glow
- + _player.broadcastUserInfo();
- + _player.broadcastPacket(new SocialAction(_player, 3)); // Victory
- + _player.broadcastUserInfo();
- + removeFlagFromPlayer(_player);
- + _teamPointsCount.set(indexOwn, teamPointsCount(team) + 1);
- + _player.broadcastPacket(new PlaySound(0, "ItemSound.quest_finish", 1, _player.getObjectId(), _player.getX(), _player.getY(), _player.getZ()));
- + _player.broadcastUserInfo();
- + _playerScores.put(_player.getName(), playerScoresCount(_player.getName()) + 1);
- + AnnounceToPlayers(false, "CTF Event: " + _player.getName() + " scores for " + _player._teamNameCTF + " team.");
- + AnnounceToPlayers(false, "CTF Event: Scores - " + _teams.get(0) + ": " + teamPointsCount(_teams.get(0)) + " " + _teams.get(1) + ": " + teamPointsCount(_teams.get(1)));
- + }
- + }
- + else
- + {
- + int indexEnemy = _teams.indexOf(team);
- + // if the player is near a enemy flag
- + if (InRangeOfFlag(_player, indexEnemy, 100) && !_flagsTaken.get(indexEnemy) && !_player._haveFlagCTF && !_player.isDead())
- + {
- + if (_player.isRidingStrider() || _player.isFlying())
- + {
- + _player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_CANNOT_BOARD_AN_AIRSHIP_WHILE_A_PET_OR_A_SERVITOR_IS_SUMMONED));
- + break;
- + }
- +
- + _flagsTaken.set(indexEnemy, true);
- + unspawnFlag(team);
- + _player._teamNameHaveFlagCTF = team;
- + addFlagToPlayer(_player);
- + _player.broadcastUserInfo();
- + _player._haveFlagCTF = true;
- + AnnounceToPlayers(false, "CTF Event: " + team + " flag taken by " + _player.getName() + "...");
- + pointTeamTo(_player, team);
- + break;
- + }
- + }
- + }
- + }
- + catch (Exception e)
- + {
- + e.printStackTrace();
- + }
- + }
- +
- + public static void pointTeamTo(L2PcInstance hasFlag, String ourFlag)
- + {
- + try
- + {
- + for (L2PcInstance player : _players)
- + {
- + if ((player != null) && player.isOnline())
- + {
- + if (player._teamNameCTF.equals(ourFlag))
- + {
- + player.sendMessage(hasFlag.getName() + " took your flag!");
- + if (player._haveFlagCTF)
- + {
- + player.sendMessage("You can not return the flag to headquarters, until your flag is returned to it's place.");
- + player.sendPacket(new RadarControl(1, 1, player.getX(), player.getY(), player.getZ()));
- + }
- + else
- + {
- + player.sendPacket(new RadarControl(0, 1, hasFlag.getX(), hasFlag.getY(), hasFlag.getZ()));
- + L2Radar rdr = new L2Radar(player);
- + L2Radar.RadarOnPlayer radar = rdr.new RadarOnPlayer(hasFlag, player);
- + ThreadPoolManager.getInstance().scheduleGeneral(radar, 10000 + Rnd.get(30000));
- + }
- + }
- + }
- + }
- + }
- + catch (Throwable t)
- + {
- + }
- + }
- +
- + private static int playerScoresCount(String player)
- + {
- + if (_playerScores.containsKey(player))
- + {
- + return _playerScores.get(player);
- + }
- + else if (player != null)
- + {
- + _playerScores.put(player, 0);
- + return _playerScores.get(player);
- + }
- + else
- + {
- + return 0;
- + }
- + }
- +
- + public static int teamPointsCount(String teamName)
- + {
- + int index = _teams.indexOf(teamName);
- +
- + if (index == -1)
- + {
- + return -1;
- + }
- +
- + return _teamPointsCount.get(index);
- + }
- +
- + public static void setTeamPointsCount(String teamName, int teamPointCount)
- + {
- + int index = _teams.indexOf(teamName);
- +
- + if (index == -1)
- + {
- + return;
- + }
- +
- + _teamPointsCount.set(index, teamPointCount);
- + }
- +
- + public static int teamPlayersCount(String teamName)
- + {
- + int index = _teams.indexOf(teamName);
- +
- + if (index == -1)
- + {
- + return -1;
- + }
- +
- + return _teamPlayersCount.get(index);
- + }
- +
- + public static void setTeamPlayersCount(String teamName, int teamPlayersCount)
- + {
- + int index = _teams.indexOf(teamName);
- +
- + if (index == -1)
- + {
- + return;
- + }
- +
- + _teamPlayersCount.set(index, teamPlayersCount);
- + }
- +
- + public static void setNpcPos(L2PcInstance activeChar)
- + {
- + _npcX = activeChar.getX();
- + _npcY = activeChar.getY();
- + _npcZ = activeChar.getZ();
- + _npcHeading = activeChar.getHeading();
- + }
- +
- + public static void setNpcPos(int x, int y, int z)
- + {
- + _npcX = x;
- + _npcY = y;
- + _npcZ = z;
- + }
- +
- + public static void addTeam(String teamName)
- + {
- + if (!checkTeamOk())
- + {
- + if (Config.DEBUG)
- + {
- + _log.fine("CTF Engine[addTeam(" + teamName + ")]: checkTeamOk() = false");
- + }
- + return;
- + }
- +
- + if (teamName.equals(" "))
- + {
- + return;
- + }
- +
- + _teams.add(teamName);
- + _teamPlayersCount.add(0);
- + _teamColors.add(0);
- + _teamsX.add(0);
- + _teamsY.add(0);
- + _teamsZ.add(0);
- + _teamsBaseX.add(0);
- + _teamsBaseY.add(0);
- + _teamsBaseZ.add(0);
- + _teamPointsCount.add(0);
- + addOrSet(_teams.indexOf(teamName), null, false, _FlagNPC, 0, 0, 0);
- + }
- +
- + private static void addOrSet(int listSize, L2Spawn flagSpawn, boolean flagsTaken, int flagId, int flagX, int flagY, int flagZ)
- + {
- + while (_flagsX.size() <= listSize)
- + {
- + _flagSpawns.add(null);
- + _flagsTaken.add(false);
- + _flagIds.add(_FlagNPC);
- + _flagsX.add(0);
- + _flagsY.add(0);
- + _flagsZ.add(0);
- + }
- + _flagSpawns.set(listSize, flagSpawn);
- + _flagsTaken.set(listSize, flagsTaken);
- + _flagIds.set(listSize, flagId);
- + _flagsX.set(listSize, flagX);
- + _flagsY.set(listSize, flagY);
- + _flagsZ.set(listSize, flagZ);
- + }
- +
- + public static boolean checkMaxLevel(int maxlvl)
- + {
- + if (_minlvl >= maxlvl)
- + {
- + return false;
- + }
- +
- + return true;
- + }
- +
- + public static boolean checkMinLevel(int minlvl)
- + {
- + if (_maxlvl <= minlvl)
- + {
- + return false;
- + }
- +
- + return true;
- + }
- +
- + /** returns true if participated players is higher or equal then minimum needed players */
- + public static boolean checkMinPlayers(int players)
- + {
- + if (_minPlayers <= players)
- + {
- + return true;
- + }
- +
- + return false;
- + }
- +
- + /** returns true if max players is higher or equal then participated players */
- + public static boolean checkMaxPlayers(int players)
- + {
- + if (_maxPlayers > players)
- + {
- + return true;
- + }
- +
- + return false;
- + }
- +
- + public static void removeTeam(String teamName)
- + {
- + if (!checkTeamOk() || _teams.isEmpty())
- + {
- + if (Config.DEBUG)
- + {
- + _log.fine("CTF Engine[removeTeam(" + teamName + ")]: checkTeamOk() = false");
- + }
- + return;
- + }
- +
- + if (teamPlayersCount(teamName) > 0)
- + {
- + if (Config.DEBUG)
- + {
- + _log.fine("CTF Engine[removeTeam(" + teamName + ")]: teamPlayersCount(teamName) > 0");
- + }
- + return;
- + }
- +
- + int index = _teams.indexOf(teamName);
- +
- + if (index == -1)
- + {
- + return;
- + }
- +
- + _teamsZ.remove(index);
- + _teamsY.remove(index);
- + _teamsX.remove(index);
- + _teamsBaseZ.remove(index);
- + _teamsBaseY.remove(index);
- + _teamsBaseX.remove(index);
- + _teamColors.remove(index);
- + _teamPointsCount.remove(index);
- + _teamPlayersCount.remove(index);
- + _teams.remove(index);
- + _flagSpawns.remove(index);
- + _flagsTaken.remove(index);
- + _flagIds.remove(index);
- + _flagsX.remove(index);
- + _flagsY.remove(index);
- + _flagsZ.remove(index);
- + }
- +
- + public static void setTeamPos(String teamName, L2PcInstance activeChar)
- + {
- + int index = _teams.indexOf(teamName);
- +
- + if (index == -1)
- + {
- + return;
- + }
- +
- + _teamsX.set(index, activeChar.getX());
- + _teamsY.set(index, activeChar.getY());
- + _teamsZ.set(index, activeChar.getZ());
- + }
- +
- + public static void setTeamPos(String teamName, int x, int y, int z)
- + {
- + int index = _teams.indexOf(teamName);
- +
- + if (index == -1)
- + {
- + return;
- + }
- +
- + _teamsX.set(index, x);
- + _teamsY.set(index, y);
- + _teamsZ.set(index, z);
- + }
- +
- + public static void setTeamBasePos(String teamName, L2PcInstance activeChar)
- + {
- + int index = _teams.indexOf(teamName);
- +
- + if (index == -1)
- + {
- + return;
- + }
- +
- + _teamsBaseX.set(index, activeChar.getX());
- + _teamsBaseY.set(index, activeChar.getY());
- + _teamsBaseZ.set(index, activeChar.getZ());
- + }
- +
- + public static void setTeamBasePos(String teamName, int x, int y, int z)
- + {
- + int index = _teams.indexOf(teamName);
- +
- + if (index == -1)
- + {
- + return;
- + }
- +
- + _teamsBaseX.set(index, x);
- + _teamsBaseY.set(index, y);
- + _teamsBaseZ.set(index, z);
- + }
- +
- + public static void setTeamColor(String teamName, int color)
- + {
- + if (!checkTeamOk())
- + {
- + return;
- + }
- +
- + int index = _teams.indexOf(teamName);
- +
- + if (index == -1)
- + {
- + return;
- + }
- +
- + _teamColors.set(index, color);
- + }
- +
- + public static boolean checkTeamOk()
- + {
- + if (_started || _teleport || _joining)
- + {
- + return false;
- + }
- +
- + return true;
- + }
- +
- + public static void startJoin(L2PcInstance activeChar)
- + {
- + if (!startJoinOk())
- + {
- + activeChar.sendMessage("Event not setted propertly.");
- + if (Config.DEBUG)
- + {
- + _log.fine("CTF Engine[startJoin(" + activeChar.getName() + ")]: startJoinOk() = false");
- + }
- + return;
- + }
- +
- + _joining = true;
- + spawnEventNpc(activeChar);
- + AnnounceToPlayers(true, "CTF Event: Registration opened for 15 minute(s)! Use .joinctf command to register.");
- + }
- +
- + public static void startJoin()
- + {
- + if (!startJoinOk())
- + {
- + _log.warning("Event not setted propertly.");
- + if (Config.DEBUG)
- + {
- + _log.fine("CTF Engine[startJoin(startJoinOk() = false");
- + }
- + return;
- + }
- +
- + _joining = true;
- + spawnEventNpc();
- + }
- +
- + public static boolean startAutoJoin()
- + {
- + if (!startJoinOk())
- + {
- + if (Config.DEBUG)
- + {
- + _log.fine("CTF Engine[startJoin]: startJoinOk() = false");
- + }
- + return false;
- + }
- +
- + _joining = true;
- + spawnEventNpc();
- + AnnounceToPlayers(true, "CTF Event: Registration opened for 15 minute(s)! Use .joinctf command to register.");
- + return true;
- + }
- +
- + public static boolean startJoinOk()
- + {
- + if (Config.CTF_BASE_TELEPORT_FIRST && (_teamsBaseX.contains(0) || _teamsBaseY.contains(0) || _teamsBaseZ.contains(0)))
- + {
- + return false;
- + }
- + else if (_started || _teleport || _joining || (_teams.size() < 2) || _eventName.equals("") || _joiningLocationName.equals("") || _eventDesc.equals("") || (_npcId == 0) || (_npcX == 0) || (_npcY == 0) || (_npcZ == 0) || (_rewardId == 0) || (_rewardAmount == 0) || _teamsX.contains(0) || _teamsY.contains(0) || _teamsZ.contains(0) || (_flagHoldTime == 0))
- + {
- + return false;
- + }
- + try
- + {
- + if (_flagsX.contains(0) || _flagsY.contains(0) || _flagsZ.contains(0) || _flagIds.contains(0))
- + {
- + return false;
- + }
- + if ((_flagsX.size() < _teams.size()) || (_flagsY.size() < _teams.size()) || (_flagsZ.size() < _teams.size()) || (_flagIds.size() < _teams.size()))
- + {
- + return false;
- + }
- + }
- + catch (ArrayIndexOutOfBoundsException e)
- + {
- + return false;
- + }
- + return true;
- + }
- +
- + private static void spawnEventNpc(L2PcInstance activeChar)
- + {
- + L2NpcTemplate tmpl = NpcTable.getInstance().getTemplate(_npcId);
- +
- + try
- + {
- + _npcSpawn = new L2Spawn(tmpl);
- +
- + _npcSpawn.setLocx(_npcX);
- + _npcSpawn.setLocy(_npcY);
- + _npcSpawn.setLocz(_npcZ);
- + _npcSpawn.setAmount(1);
- + _npcSpawn.setHeading(_npcHeading);
- + _npcSpawn.setRespawnDelay(1);
- +
- + SpawnTable.getInstance().addNewSpawn(_npcSpawn, false);
- +
- + _npcSpawn.init();
- + _npcSpawn.getLastSpawn().getStatus().setCurrentHp(999999999);
- + _npcSpawn.getLastSpawn().setTitle(_eventName);
- + _npcSpawn.getLastSpawn()._isEventMobCTF = true;
- + _npcSpawn.getLastSpawn().isAggressive();
- + _npcSpawn.getLastSpawn().decayMe();
- + _npcSpawn.getLastSpawn().spawnMe(_npcSpawn.getLastSpawn().getX(), _npcSpawn.getLastSpawn().getY(), _npcSpawn.getLastSpawn().getZ());
- +
- + _npcSpawn.getLastSpawn().broadcastPacket(new MagicSkillUse(_npcSpawn.getLastSpawn(), _npcSpawn.getLastSpawn(), 1034, 1, 1, 1));
- + }
- + catch (Exception e)
- + {
- + _log.warning("CTF Engine[spawnEventNpc(" + activeChar.getName() + ")]: exception: " + e.getMessage());
- + }
- + }
- +
- + public static class BaseTeleportTask implements Runnable
- + {
- + L2PcInstance player;
- + boolean onBegin;
- +
- + public BaseTeleportTask(L2PcInstance _player, boolean _onBegin)
- + {
- + player = _player;
- + onBegin = _onBegin;
- + }
- +
- + public BaseTeleportTask(boolean _onBegin)
- + {
- + onBegin = _onBegin;
- + }
- +
- + @Override
- + public void run()
- + {
- + if (CTF._teleport || CTF._started)
- + {
- + if (onBegin)
- + {
- + spawnAllFlags();
- +
- + for (L2PcInstance players : _players)
- + {
- + new BaseTeleportTask(players, false).run();
- + }
- + }
- + else
- + {
- + if (player != null)
- + {
- + player.teleToLocation(CTF._teamsX.get(CTF._teams.indexOf(player._teamNameCTF)), CTF._teamsY.get(CTF._teams.indexOf(player._teamNameCTF)), CTF._teamsZ.get(CTF._teams.indexOf(player._teamNameCTF)), false);
- + }
- + }
- + }
- + }
- + }
- +
- + private static void spawnEventNpc()
- + {
- + L2NpcTemplate tmpl = NpcTable.getInstance().getTemplate(_npcId);
- +
- + try
- + {
- + _npcSpawn = new L2Spawn(tmpl);
- +
- + _npcSpawn.setLocx(_npcX);
- + _npcSpawn.setLocy(_npcY);
- + _npcSpawn.setLocz(_npcZ);
- + _npcSpawn.setAmount(1);
- + _npcSpawn.setHeading(_npcHeading);
- + _npcSpawn.setRespawnDelay(1);
- +
- + SpawnTable.getInstance().addNewSpawn(_npcSpawn, false);
- +
- + _npcSpawn.init();
- + _npcSpawn.getLastSpawn().getStatus().setCurrentHp(999999999);
- + _npcSpawn.getLastSpawn().setTitle(_eventName);
- + _npcSpawn.getLastSpawn()._isEventMobCTF = true;
- + _npcSpawn.getLastSpawn().isAggressive();
- + _npcSpawn.getLastSpawn().decayMe();
- + _npcSpawn.getLastSpawn().spawnMe(_npcSpawn.getLastSpawn().getX(), _npcSpawn.getLastSpawn().getY(), _npcSpawn.getLastSpawn().getZ());
- +
- + _npcSpawn.getLastSpawn().broadcastPacket(new MagicSkillUse(_npcSpawn.getLastSpawn(), _npcSpawn.getLastSpawn(), 1034, 1, 1, 1));
- + }
- + catch (Exception e)
- + {
- + _log.warning("CTF Engine[spawnEventNpc(exception: " + e.getMessage());
- + }
- + }
- +
- + public static void teleportStart()
- + {
- + if (!_joining || _started || _teleport)
- + {
- + return;
- + }
- +
- + if (Config.CTF_EVEN_TEAMS.equals("SHUFFLE") && checkMinPlayers(_playersShuffle.size()))
- + {
- + removeOfflinePlayers();
- + shuffleTeams();
- + }
- + else if (Config.CTF_EVEN_TEAMS.equals("SHUFFLE") && !checkMinPlayers(_playersShuffle.size()))
- + {
- + return;
- + }
- +
- + _joining = false;
- + setUserData();
- +
- + if (Config.CTF_BASE_TELEPORT_FIRST)
- + {
- + AnnounceToPlayers(true, "CTF Event: Teleporting to team base. The fight will being in 20 seconds!");
- +
- + for (L2PcInstance player : _players)
- + {
- + if (player != null)
- + {
- + if (Config.CTF_ON_START_UNSUMMON_PET)
- + {
- + // Remove Summon's buffs
- + if (player.getPet() != null)
- + {
- + L2Summon summon = player.getPet();
- + for (L2Effect e : summon.getAllEffects())
- + {
- + if (e != null)
- + {
- + e.exit();
- + }
- + }
- +
- + if (summon instanceof L2PetInstance)
- + {
- + summon.unSummon(player);
- + }
- + }
- + }
- +
- + if (Config.CTF_ON_START_REMOVE_ALL_EFFECTS)
- + {
- + for (L2Effect e : player.getAllEffects())
- + {
- + if (e != null)
- + {
- + e.exit();
- + }
- + }
- + }
- +
- + // Remove player from his party
- + if (player.getParty() != null)
- + {
- + L2Party party = player.getParty();
- + party.removePartyMember(player);
- + }
- +
- + player.teleToLocation(_teamsBaseX.get(_teams.indexOf(player._teamNameCTF)), _teamsBaseY.get(_teams.indexOf(player._teamNameCTF)), _teamsBaseZ.get(_teams.indexOf(player._teamNameCTF)));
- + }
- + }
- + ThreadPoolManager.getInstance().scheduleGeneral(new BaseTeleportTask(true), 20000);
- + }
- + else
- + {
- + AnnounceToPlayers(true, "CTF Event: Teleporting to team spot in 15 seconds!");
- +
- + ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
- + {
- + @Override
- + public void run()
- + {
- + spawnAllFlags();
- +
- + for (L2PcInstance player : _players)
- + {
- + if (player != null)
- + {
- + if (Config.CTF_ON_START_UNSUMMON_PET)
- + {
- + // Remove Summon's buffs
- + if (player.getPet() != null)
- + {
- + L2Summon summon = player.getPet();
- + for (L2Effect e : summon.getAllEffects())
- + {
- + if (e != null)
- + {
- + e.exit();
- + }
- + }
- +
- + if (summon instanceof L2PetInstance)
- + {
- + summon.unSummon(player);
- + }
- + }
- + }
- +
- + if (Config.CTF_ON_START_REMOVE_ALL_EFFECTS)
- + {
- + for (L2Effect e : player.getAllEffects())
- + {
- + if (e != null)
- + {
- + e.exit();
- + }
- + }
- + }
- +
- + // Remove player from his party
- + if (player.getParty() != null)
- + {
- + L2Party party = player.getParty();
- + party.removePartyMember(player);
- + }
- +
- + player.teleToLocation(_teamsX.get(_teams.indexOf(player._teamNameCTF)), _teamsY.get(_teams.indexOf(player._teamNameCTF)), _teamsZ.get(_teams.indexOf(player._teamNameCTF)));
- + }
- + }
- + }
- + }, 15000);
- + }
- + _teleport = true;
- + }
- +
- + public static boolean teleportAutoStart()
- + {
- + if (!_joining || _started || _teleport)
- + {
- + return false;
- + }
- +
- + if (Config.CTF_EVEN_TEAMS.equals("SHUFFLE") && checkMinPlayers(_playersShuffle.size()))
- + {
- + removeOfflinePlayers();
- + shuffleTeams();
- + }
- + else if (Config.CTF_EVEN_TEAMS.equals("SHUFFLE") && !checkMinPlayers(_playersShuffle.size()))
- + {
- + AnnounceToPlayers(true, "CTF Event: Not enough players registered.");
- + return false;
- + }
- +
- + _joining = false;
- + setUserData();
- +
- + if (Config.CTF_BASE_TELEPORT_FIRST)
- + {
- + AnnounceToPlayers(true, "CTF Event: Teleporting to team base. The fight will being in 20 seconds!");
- +
- + for (L2PcInstance player : _players)
- + {
- + if (player != null)
- + {
- + if (Config.CTF_ON_START_UNSUMMON_PET)
- + {
- + // Remove Summon's buffs
- + if (player.getPet() != null)
- + {
- + L2Summon summon = player.getPet();
- + for (L2Effect e : summon.getAllEffects())
- + {
- + if (e != null)
- + {
- + e.exit();
- + }
- + }
- +
- + if (summon instanceof L2PetInstance)
- + {
- + summon.unSummon(player);
- + }
- + }
- + }
- +
- + if (Config.CTF_ON_START_REMOVE_ALL_EFFECTS)
- + {
- + for (L2Effect e : player.getAllEffects())
- + {
- + if (e != null)
- + {
- + e.exit();
- + }
- + }
- + }
- +
- + // Remove player from his party
- + if (player.getParty() != null)
- + {
- + L2Party party = player.getParty();
- + party.removePartyMember(player);
- + }
- +
- + player.teleToLocation(_teamsBaseX.get(_teams.indexOf(player._teamNameCTF)), _teamsBaseY.get(_teams.indexOf(player._teamNameCTF)), _teamsBaseZ.get(_teams.indexOf(player._teamNameCTF)));
- + }
- + }
- + ThreadPoolManager.getInstance().scheduleGeneral(new BaseTeleportTask(true), 30000);
- + }
- + else
- + {
- + AnnounceToPlayers(false, "CTF Event: Teleporting to team spot in 15 seconds!");
- +
- + ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
- + {
- + @Override
- + public void run()
- + {
- + spawnAllFlags();
- +
- + for (L2PcInstance player : _players)
- + {
- + if (player != null)
- + {
- + if (Config.CTF_ON_START_UNSUMMON_PET)
- + {
- + // Remove Summon's buffs
- + if (player.getPet() != null)
- + {
- + L2Summon summon = player.getPet();
- + for (L2Effect e : summon.getAllEffects())
- + {
- + if (e != null)
- + {
- + e.exit();
- + }
- + }
- +
- + if (summon instanceof L2PetInstance)
- + {
- + summon.unSummon(player);
- + }
- + }
- + }
- +
- + if (Config.CTF_ON_START_REMOVE_ALL_EFFECTS)
- + {
- + for (L2Effect e : player.getAllEffects())
- + {
- + if (e != null)
- + {
- + e.exit();
- + }
- + }
- + }
- +
- + // Remove player from his party
- + if (player.getParty() != null)
- + {
- + L2Party party = player.getParty();
- + party.removePartyMember(player);
- + }
- +
- + player.teleToLocation(_teamsX.get(_teams.indexOf(player._teamNameCTF)), _teamsY.get(_teams.indexOf(player._teamNameCTF)), _teamsZ.get(_teams.indexOf(player._teamNameCTF)));
- + }
- + }
- + }
- + }, 15000);
- + }
- + _teleport = true;
- + return true;
- + }
- +
- + public static void startEvent(L2PcInstance activeChar)
- + {
- + if (!startEventOk())
- + {
- + if (Config.DEBUG)
- + {
- + _log.fine("CTF Engine[startEvent(" + activeChar.getName() + ")]: startEventOk() = false");
- + }
- + return;
- + }
- +
- + _teleport = false;
- +
- + _started = true;
- + StartEvent();
- + }
- +
- + public static void setJoinTime(int time)
- + {
- + _joinTime = time;
- + }
- +
- + public static void setEventTime(int time)
- + {
- + _eventTime = time;
- + }
- +
- + public static boolean startAutoEvent()
- + {
- + if (!startEventOk())
- + {
- + if (Config.DEBUG)
- + {
- + _log.fine("CTF Engine[startEvent]: startEventOk() = false");
- + }
- + return false;
- + }
- +
- + _teleport = false;
- +
- + _started = true;
- + return true;
- + }
- +
- + public static synchronized void autoEvent()
- + {
- + if (startAutoJoin())
- + {
- + if (_joinTime > 0)
- + {
- + waiter(_joinTime * 60 * 1000); // minutes for join event
- + }
- + else if (_joinTime <= 0)
- + {
- + abortEvent();
- + return;
- + }
- + if (teleportAutoStart())
- + {
- + AnnounceToPlayers(false, "CTF Event: Started. Go Capture the Flags!");
- + waiter(1 * 1 * 1000); // 1 seconds wait time until start fight after teleported
- + if (startAutoEvent())
- + {
- + waiter(_eventTime * 60 * 1000); // minutes for event time
- + finishEvent();
- + }
- + }
- + else if (!teleportAutoStart())
- + {
- + abortEvent();
- + }
- + }
- + }
- +
- + // a scheduled time to remove the flag after a user set time _flagHoldTime
- + private static void flagHoldTimer(final L2PcInstance _player, final long interval)
- + {
- + ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
- + {
- + @Override
- + public void run()
- + {
- + if (_started)
- + {
- + try
- + // just to be sure
- + {
- + long countDown = System.currentTimeMillis();
- + int seconds = (int) interval;
- +
- + while (((countDown + (interval * 1000)) > System.currentTimeMillis()) && (_flagsNotRemoved.get(_teams.indexOf(_player._teamNameCTF)) != false))
- + {
- + seconds--;
- +
- + switch (seconds)
- + {
- + case 600: // 10 minutes left
- + if ((_player != null) && _player._haveFlagCTF)
- + {
- + _player.sendMessage("You have 10 minutes to capture the flag or it will be returned.");
- + }
- + break;
- + case 300: // 5 minutes left
- + if ((_player != null) && _player._haveFlagCTF)
- + {
- + _player.sendMessage("You have 5 minutes to capture the flag or it will be returned.");
- + }
- + break;
- + case 240: // 4 minutes left
- + if ((_player != null) && _player._haveFlagCTF)
- + {
- + _player.sendMessage("You have 5 minutes to capture the flag or it will be returned.");
- + }
- + break;
- + case 180: // 3 minutes left
- + if ((_player != null) && _player._haveFlagCTF)
- + {
- + _player.sendMessage("You have 3 minutes to capture the flag or it will be returned.");
- + }
- + break;
- + case 120: // 2 minutes left
- + if ((_player != null) && _player._haveFlagCTF)
- + {
- + _player.sendMessage("You have 2 minutes to capture the flag or it will be returned.");
- + }
- + break;
- + case 60: // 1 minute left
- + if ((_player != null) && _player._haveFlagCTF)
- + {
- + _player.sendMessage("You have 1 minute to capture the flag or it will be returned.");
- + }
- + break;
- + case 30: // 30 seconds left
- + if ((_player != null) && _player._haveFlagCTF)
- + {
- + _player.sendMessage("You have 30 seconds to capture the flag or it will be returned.");
- + }
- + break;
- + case 10: // 10 seconds left
- + if ((_player != null) && _player._haveFlagCTF)
- + {
- + _player.sendMessage("You have 10 seconds to capture the flag or it will be returned.");
- + }
- + break;
- + case 1: // 1 seconds left
- + if ((_player != null) && _player._haveFlagCTF)
- + {
- + removeFlagFromPlayer(_player);
- + _flagsTaken.set(_teams.indexOf(_player._teamNameHaveFlagCTF), false);
- + spawnFlag(_player._teamNameHaveFlagCTF);
- + _player.sendMessage("You've held the flag for too long. The enemy flag has been returned.");
- + AnnounceToPlayers(false, "CTF Event: " + _player.getName() + " held the flag for too long. " + _player._teamNameCTF + " flag has been returned.");
- + }
- + break;
- + }
- + long startOneSecondWaiterStartTime = System.currentTimeMillis();
- +
- + // only the try catch with Thread.sleep(1000) give bad countdown on high wait times
- + while ((startOneSecondWaiterStartTime + 1000) > System.currentTimeMillis())
- + {
- + try
- + {
- + Thread.sleep(1);
- + }
- + catch (InterruptedException ie)
- + {
- + }
- + }
- + }
- + }
- + catch (Exception e)
- + {
- + _log.warning("Exception: CTF.flagHoldTimer(): " + e.getMessage());
- + }
- + }
- + }
- + }, 1);
- + }
- +
- + private static synchronized void waiter(long interval)
- + {
- + long startWaiterTime = System.currentTimeMillis();
- + int seconds = (int) (interval / 1000);
- +
- + while ((startWaiterTime + interval) > System.currentTimeMillis())
- + {
- + seconds--; // here because we don't want to see two time announce at the same time
- +
- + if (_joining || _started || _teleport)
- + {
- + switch (seconds)
- + {
- + case 3600: // 1 hour left
- + if (_joining)
- + {
- + AnnounceToPlayers(true, "CTF Event: " + (seconds / 60 / 60) + " hour(s) until registration ends! Use .joinctf command to register.");
- + }
- + else if (_started)
- + {
- + AnnounceToPlayers(false, "CTF Event: " + (seconds / 60 / 60) + " hour(s) until event ends!");
- + }
- +
- + break;
- + case 600: // 10 minutes left
- + case 300: // 5 minutes left
- + case 60: // 1 minute left
- + if (_joining)
- + {
- + removeOfflinePlayers();
- + AnnounceToPlayers(true, "CTF Event: " + (seconds / 60) + " minute(s) until registration ends! Use .joinctf command to register.");
- + }
- + else if (_started)
- + {
- + AnnounceToPlayers(false, "CTF Event: " + (seconds / 60) + " minute(s) until event ends!");
- + }
- +
- + break;
- +
- + case 5: // 5 seconds left
- +
- + if (_joining)
- + {
- + AnnounceToPlayers(true, "CTF Event: " + seconds + " second(s) until registration ends! Use .joinctf command to register.");
- + }
- + else if (_teleport)
- + {
- + AnnounceToPlayers(false, "CTF Event: " + seconds + " seconds(s) until ends starts!");
- + }
- + else if (_started)
- + {
- + AnnounceToPlayers(false, "CTF Event: " + seconds + " second(s) until event ends!");
- + }
- +
- + break;
- + }
- + }
- +
- + long startOneSecondWaiterStartTime = System.currentTimeMillis();
- +
- + // only the try catch with Thread.sleep(1000) give bad countdown on high wait times
- + while ((startOneSecondWaiterStartTime + 1000) > System.currentTimeMillis())
- + {
- + try
- + {
- + Thread.sleep(1);
- + }
- + catch (InterruptedException ie)
- + {
- + }
- + }
- + }
- + }
- +
- + private static boolean startEventOk()
- + {
- + if (_joining || !_teleport || _started)
- + {
- + return false;
- + }
- +
- + if (Config.CTF_EVEN_TEAMS.equals("NO") || Config.CTF_EVEN_TEAMS.equals("BALANCE"))
- + {
- + if (_teamPlayersCount.contains(0))
- + {
- + return false;
- + }
- + }
- + else if (Config.CTF_EVEN_TEAMS.equals("SHUFFLE"))
- + {
- + Vector<L2PcInstance> playersShuffleTemp = new Vector<L2PcInstance>();
- + int loopCount = 0;
- +
- + loopCount = _playersShuffle.size();
- +
- + for (int i = 0; i < loopCount; i++)
- + {
- + if (_playersShuffle != null)
- + {
- + playersShuffleTemp.add(_playersShuffle.get(i));
- + }
- + }
- +
- + _playersShuffle = playersShuffleTemp;
- + playersShuffleTemp.clear();
- +
- + // if (_playersShuffle.size() < (_teams.size()*2)){
- + // return false;
- + // }
- + }
- +
- + return true;
- + }
- +
- + public static void shuffleTeams()
- + {
- + int teamCount = 0, playersCount = 0;
- +
- + for (;;)
- + {
- + if (_playersShuffle.isEmpty())
- + {
- + break;
- + }
- +
- + int playerToAddIndex = Rnd.nextInt(_playersShuffle.size());
- + L2PcInstance player = null;
- + player = _playersShuffle.get(playerToAddIndex);
- + player._originalNameColorCTF = player.getAppearance().getNameColor();
- + player._originalKarmaCTF = player.getKarma();
- +
- + _players.add(player);
- + _players.get(playersCount)._teamNameCTF = _teams.get(teamCount);
- + _savePlayers.add(_players.get(playersCount).getName());
- + _savePlayerTeams.add(_teams.get(teamCount));
- + playersCount++;
- +
- + if (teamCount == (_teams.size() - 1))
- + {
- + teamCount = 0;
- + }
- + else
- + {
- + teamCount++;
- + }
- +
- + _playersShuffle.remove(playerToAddIndex);
- + }
- + }
- +
- + public static void setUserData()
- + {
- + for (L2PcInstance player : _players)
- + {
- + if (_teams.indexOf(player._teamNameCTF) == 0)
- + {
- + player.setTeam(2);
- + player.setKarma(0);
- + player.broadcastUserInfo();
- + }
- + else
- + {
- + player.setTeam(_teams.indexOf(player._teamNameCTF));
- + }
- + player.setKarma(0);
- + player.broadcastUserInfo();
- + }
- + }
- +
- + public static void finishEvent()
- + {
- + if (!finishEventOk())
- + {
- + if (Config.DEBUG)
- + {
- + _log.fine("CTF Engine[finishEvent]: finishEventOk() = false");
- + }
- + return;
- + }
- +
- + _started = false;
- + unspawnEventNpc();
- + unspawnAllFlags();
- + processTopTeam();
- +
- + if (_topScore != 0)
- + {
- + playKneelAnimation(_topTeam);
- + }
- +
- + if (Config.CTF_ANNOUNCE_TEAM_STATS)
- + {
- + AnnounceToPlayers(true, _eventName + " Team Statistics:");
- + for (String team : _teams)
- + {
- + int _flags_ = teamFlagCount(team);
- + AnnounceToPlayers(true, "Team: " + team + " - Flags taken: " + _flags_);
- + }
- + }
- +
- + teleportFinish();
- + }
- +
- + // show loosers and winners animations
- + public static void playKneelAnimation(String teamName)
- + {
- + for (L2PcInstance player : _players)
- + {
- + if ((player != null) && player.isOnline() && (player._inEventCTF == true))
- + {
- + if (!player._teamNameCTF.equals(teamName))
- + {
- + player.broadcastPacket(new SocialAction(player, 7));
- + }
- + else if (player._teamNameCTF.equals(teamName))
- + {
- + player.broadcastPacket(new SocialAction(player, 3));
- + }
- + }
- + }
- + }
- +
- + private static boolean finishEventOk()
- + {
- + if (!_started)
- + {
- + return false;
- + }
- +
- + return true;
- + }
- +
- + /*
- + * Erro nas mensagens public static void rewardTeam(String teamName) { for (L2PcInstance player : _players) { if (player != null) { if (player._teamNameCTF.equals(teamName)) { player.addItem("CTF Event: " + _eventName, _rewardId, _rewardAmount, player, true); NpcHtmlMessage nhm = new
- + * NpcHtmlMessage(0); TextBuilder replyMSG = new TextBuilder(); int count = 0; replyMSG.append("<html><body><center><font color=\"FF66OO\">PG-L][ Rare CTF Event</font><br>Your team won!<br></center>"); replyMSG.append("<center>-= <font color=\"99CC00\">Best Flag Runners</font> =-</center><br>");
- + * replyMSG.append("<table width=\"200\" align=\"center\"><tr align=\"center\"><td>"); for (String team : _teams) { replyMSG.append("<font color=\"LEVEL\">" + team + "</font>"); for (L2PcInstance p : _players) { if (_playerScores.containsKey(p.getName())) { if (p._teamNameCTF.equals(team)) {
- + * replyMSG.append("<br>" + ++count + ". " + p.getName() + " - " + _playerScores.get(p.getName())); } } } if (((_teams.indexOf(team) + 1) % 2) != 0) { if (team == _teams.lastElement()) replyMSG.append("</td></tr></table></body></html>"); else replyMSG.append("</td><td>"); } else { if (team ==
- + * _teams.lastElement()) replyMSG.append("</td></tr></table></body></html>"); else replyMSG.append("</td></tr><tr><td>"); } count = 0; } nhm.setHtml(replyMSG.toString()); player.sendPacket(nhm); // Send a Server->Client ActionFailed to the L2PcInstance in order to avoid that the client wait
- + * another packet player.sendPacket(ActionFailed.STATIC_PACKET); } else { NpcHtmlMessage nhm = new NpcHtmlMessage(0); TextBuilder replyMSG = new TextBuilder(); int count = 0;
- + * replyMSG.append("<html><body><center><font color=\"FF66OO\">PG-L][ Rare CTF Event</font><br>Better luck next time!<br></center>"); replyMSG.append("<center>-= <font color=\"99CC00\">Best Flag Runners</font> =-</center><br>");
- + * replyMSG.append("<table width=\"200\" align=\"center\"><center><tr align=\"center\"><td>"); for (String team : _teams) { replyMSG.append("<font color=\"LEVEL\">" + team + "</font>"); for (L2PcInstance p : _players) { if (_playerScores.containsKey(p.getName())) { if
- + * (p._teamNameCTF.equals(team)) { replyMSG.append("<br>" + ++count + ". " + p.getName() + " - " + _playerScores.get(p.getName())); } } } if (((_teams.indexOf(team) + 1) % 2) != 0) { if (team == _teams.lastElement()) replyMSG.append("</td></tr></table></body></html>"); else
- + * replyMSG.append("</td><td>"); } else { if (team == _teams.lastElement()) replyMSG.append("</td></tr></table></body></html>"); else replyMSG.append("</td></tr><tr><td>"); } count = 0; } nhm.setHtml(replyMSG.toString()); player.sendPacket(nhm); // Send a Server->Client ActionFailed to the
- + * L2PcInstance in order to avoid that the client wait another packet player.sendPacket(ActionFailed.STATIC_PACKET); } } } }
- + */
- +
- + public static void rewardTeam(String teamName)
- + {
- + for (L2PcInstance player : _players)
- + {
- + if (player != null)
- + {
- + if (player._teamNameCTF.equals(teamName))
- + {
- + player.addItem("CTF Event: " + _eventName, _rewardId, _rewardAmount, player, true);
- +
- + NpcHtmlMessage nhm = new NpcHtmlMessage(5);
- + TextBuilder replyMSG = new TextBuilder();
- +
- + replyMSG.append("<html><body>Your team wins the event. Look in your inventory for the reward.</body></html>");
- +
- + nhm.setHtml(replyMSG.toString());
- + player.sendPacket(nhm);
- +
- + // Send a Server->Client ActionFailed to the L2PcInstance in order to avoid that the client wait another packet
- + player.sendPacket(ActionFailed.STATIC_PACKET);
- + }
- + }
- + }
- + }
- +
- + public static void abortEvent()
- + {
- + if (!_joining && !_teleport && !_started)
- + {
- + GmListTable.broadcastMessageToGMs("Failed aborting CTF: No CTF instance has been started.");
- + return;
- + }
- +
- + if (_joining && !_teleport && !_started)
- + {
- + unspawnEventNpc();
- + cleanCTF();
- + _joining = false;
- + AnnounceToPlayers(true, "CTF Event: Match aborted!");
- + return;
- + }
- + _joining = false;
- + _teleport = false;
- + _started = false;
- + unspawnEventNpc();
- + unspawnAllFlags();
- + teleportFinish();
- + }
- +
- + public static void dumpData()
- + {
- + _log.warning("");
- + _log.warning("");
- +
- + if (!_joining && !_teleport && !_started)
- + {
- + _log.warning("<<---------------------------------->>");
- + _log.warning(">> CTF Engine infos dump (INACTIVE) <<");
- + _log.warning("<<--^----^^-----^----^^------^^----->>");
- + }
- + else if (_joining && !_teleport && !_started)
- + {
- + _log.warning("<<--------------------------------->>");
- + _log.warning(">> CTF Engine infos dump (JOINING) <<");
- + _log.warning("<<--^----^^-----^----^^------^----->>");
- + }
- + else if (!_joining && _teleport && !_started)
- + {
- + _log.warning("<<---------------------------------->>");
- + _log.warning(">> CTF Engine infos dump (TELEPORT) <<");
- + _log.warning("<<--^----^^-----^----^^------^^----->>");
- + }
- + else if (!_joining && !_teleport && _started)
- + {
- + _log.warning("<<--------------------------------->>");
- + _log.warning(">> CTF Engine infos dump (STARTED) <<");
- + _log.warning("<<--^----^^-----^----^^------^----->>");
- + }
- +
- + _log.warning("Name: " + _eventName);
- + _log.warning("Desc: " + _eventDesc);
- + _log.warning("Join location: " + _joiningLocationName);
- + _log.warning("Min lvl: " + _minlvl);
- + _log.warning("Max lvl: " + _maxlvl);
- + _log.warning("");
- + _log.warning("##########################");
- + _log.warning("# _teams(Vector<String>) #");
- + _log.warning("##########################");
- +
- + for (String team : _teams)
- + {
- + _log.warning(team + " Flags Taken :" + _teamPointsCount.get(_teams.indexOf(team)));
- + }
- +
- + if (Config.CTF_EVEN_TEAMS.equals("SHUFFLE"))
- + {
- + _log.warning("");
- + _log.warning("#########################################");
- + _log.warning("# _playersShuffle(Vector<L2PcInstance>) #");
- + _log.warning("#########################################");
- +
- + for (L2PcInstance player : _playersShuffle)
- + {
- + if (player != null)
- + {
- + _log.warning("Name: " + player.getName());
- + }
- + }
- + }
- +
- + _log.warning("");
- + _log.warning("##################################");
- + _log.warning("# _players(Vector<L2PcInstance>) #");
- + _log.warning("##################################");
- +
- + for (L2PcInstance player : _players)
- + {
- + if (player != null)
- + {
- + _log.warning("Name: " + player.getName() + " Team: " + player._teamNameCTF + " Flags :" + player._countCTFflags);
- + }
- + }
- +
- + _log.warning("");
- + _log.warning("#####################################################################");
- + _log.warning("# _savePlayers(Vector<String>) and _savePlayerTeams(Vector<String>) #");
- + _log.warning("#####################################################################");
- +
- + for (String player : _savePlayers)
- + {
- + _log.warning("Name: " + player + " Team: " + _savePlayerTeams.get(_savePlayers.indexOf(player)));
- + }
- +
- + _log.warning("");
- + _log.warning("");
- + _log.warning("**********==CTF==************");
- + _log.warning("CTF._teamPointsCount:" + _teamPointsCount.toString());
- + _log.warning("CTF._flagIds:" + _flagIds.toString());
- + _log.warning("CTF._flagSpawns:" + _flagSpawns.toString());
- + _log.warning("CTF._throneSpawns:" + _throneSpawns.toString());
- + _log.warning("CTF._flagsTaken:" + _flagsTaken.toString());
- + _log.warning("CTF._flagsX:" + _flagsX.toString());
- + _log.warning("CTF._flagsY:" + _flagsY.toString());
- + _log.warning("CTF._flagsZ:" + _flagsZ.toString());
- + _log.warning("************EOF**************");
- + _log.warning("");
- + }
- +
- + public static void loadData()
- + {
- + _eventName = new String();
- + _eventDesc = new String();
- + _topTeam = new String();
- + _joiningLocationName = new String();
- + _teams = new Vector<String>();
- + _savePlayers = new Vector<String>();
- + _savePlayerTeams = new Vector<String>();
- + _players = new Vector<L2PcInstance>();
- + _playersShuffle = new Vector<L2PcInstance>();
- + _teamPlayersCount = new Vector<Integer>();
- + _teamPointsCount = new Vector<Integer>();
- + _teamColors = new Vector<Integer>();
- + _teamsX = new Vector<Integer>();
- + _teamsY = new Vector<Integer>();
- + _teamsZ = new Vector<Integer>();
- + _teamsBaseX = new Vector<Integer>();
- + _teamsBaseY = new Vector<Integer>();
- + _teamsBaseZ = new Vector<Integer>();
- + _playerScores = new FastMap<String, Integer>();
- +
- + _throneSpawns = new Vector<L2Spawn>();
- + _flagSpawns = new Vector<L2Spawn>();
- + _flagsTaken = new Vector<Boolean>();
- + _flagIds = new Vector<Integer>();
- + _flagsX = new Vector<Integer>();
- + _flagsY = new Vector<Integer>();
- + _flagsZ = new Vector<Integer>();
- + _flagsNotRemoved = new Vector<Boolean>();
- +
- + _joining = false;
- + _teleport = false;
- + _started = false;
- + _sitForced = false;
- + _npcId = 0;
- + _npcX = 0;
- + _npcY = 0;
- + _npcZ = 0;
- + _npcHeading = 0;
- + _rewardId = 0;
- + _rewardAmount = 0;
- + _topScore = 0;
- + _minlvl = 0;
- + _maxlvl = 0;
- + _joinTime = 0;
- + _eventTime = 0;
- + _minPlayers = 0;
- + _maxPlayers = 0;
- + _flagHoldTime = 0;
- +
- + Connection con = null;
- + try
- + {
- + PreparedStatement statement;
- + ResultSet rs;
- +
- + con = L2DatabaseFactory.getInstance().getConnection();
- +
- + statement = con.prepareStatement("Select * from ctf");
- + rs = statement.executeQuery();
- +
- + int teams = 0;
- +
- + while (rs.next())
- + {
- + _eventName = rs.getString("eventName");
- + _eventDesc = rs.getString("eventDesc");
- + _joiningLocationName = rs.getString("joiningLocation");
- + _minlvl = rs.getInt("minlvl");
- + _maxlvl = rs.getInt("maxlvl");
- + _npcId = rs.getInt("npcId");
- + _npcX = rs.getInt("npcX");
- + _npcY = rs.getInt("npcY");
- + _npcZ = rs.getInt("npcZ");
- + _npcHeading = rs.getInt("npcHeading");
- + _rewardId = rs.getInt("rewardId");
- + _rewardAmount = rs.getInt("rewardAmount");
- + teams = rs.getInt("teamsCount");
- + _joinTime = rs.getInt("joinTime");
- + _eventTime = rs.getInt("eventTime");
- + _minPlayers = rs.getInt("minPlayers");
- + _maxPlayers = rs.getInt("maxPlayers");
- + _flagHoldTime = rs.getInt("flagHoldTime");
- + }
- + statement.close();
- +
- + int index = -1;
- + if (teams > 0)
- + {
- + index = 0;
- + }
- + while ((index < teams) && (index > -1))
- + {
- + statement = con.prepareStatement("Select * from ctf_teams where teamId = ?");
- + statement.setInt(1, index);
- + rs = statement.executeQuery();
- + while (rs.next())
- + {
- + _teams.add(rs.getString("teamName"));
- + _teamPlayersCount.add(0);
- + _teamPointsCount.add(0);
- + _teamColors.add(0);
- + _teamsX.add(0);
- + _teamsY.add(0);
- + _teamsZ.add(0);
- + _teamsX.set(index, rs.getInt("teamX"));
- + _teamsY.set(index, rs.getInt("teamY"));
- + _teamsZ.set(index, rs.getInt("teamZ"));
- + _teamColors.set(index, rs.getInt("teamColor"));
- + _flagsX.add(0);
- + _flagsY.add(0);
- + _flagsZ.add(0);
- + _flagsX.set(index, rs.getInt("flagX"));
- + _flagsY.set(index, rs.getInt("flagY"));
- + _flagsZ.set(index, rs.getInt("flagZ"));
- + if (Config.CTF_BASE_TELEPORT_FIRST)
- + {
- + _teamsBaseX.add(0);
- + _teamsBaseY.add(0);
- + _teamsBaseZ.add(0);
- + _teamsBaseX.set(index, rs.getInt("teamBaseX"));
- + _teamsBaseY.set(index, rs.getInt("teamBaseY"));
- + _teamsBaseZ.set(index, rs.getInt("teamBaseZ"));
- + }
- + _flagSpawns.add(null);
- + _flagIds.add(_FlagNPC);
- + _flagsTaken.add(false);
- + _flagsNotRemoved.add(false);
- + }
- + index++;
- + statement.close();
- + }
- + }
- + catch (Exception e)
- + {
- + _log.warning("Exception: CTF.loadData(): " + e.getMessage());
- + }
- + finally
- + {
- + try
- + {
- + if (con != null)
- + {
- + con.close();
- + }
- + }
- + catch (SQLException e)
- + {
- + e.printStackTrace();
- + }
- + }
- + }
- +
- + public static void saveData()
- + {
- + Connection con = null;
- + try
- + {
- + con = L2DatabaseFactory.getInstance().getConnection();
- + PreparedStatement statement;
- +
- + statement = con.prepareStatement("Delete from ctf");
- + statement.execute();
- + statement.close();
- +
- + statement = con.prepareStatement("INSERT INTO ctf (eventName, eventDesc, joiningLocation, minlvl, maxlvl, npcId, npcX, npcY, npcZ, npcHeading, rewardId, rewardAmount, teamsCount, joinTime, eventTime, minPlayers, maxPlayers, flagHoldTime) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
- + statement.setString(1, _eventName);
- + statement.setString(2, _eventDesc);
- + statement.setString(3, _joiningLocationName);
- + statement.setInt(4, _minlvl);
- + statement.setInt(5, _maxlvl);
- + statement.setInt(6, _npcId);
- + statement.setInt(7, _npcX);
- + statement.setInt(8, _npcY);
- + statement.setInt(9, _npcZ);
- + statement.setInt(10, _npcHeading);
- + statement.setInt(11, _rewardId);
- + statement.setInt(12, _rewardAmount);
- + statement.setInt(13, _teams.size());
- + statement.setInt(14, _joinTime);
- + statement.setInt(15, _eventTime);
- + statement.setInt(16, _minPlayers);
- + statement.setInt(17, _maxPlayers);
- + statement.setLong(18, _flagHoldTime);
- + statement.execute();
- + statement.close();
- +
- + statement = con.prepareStatement("Delete from ctf_teams");
- + statement.execute();
- + statement.close();
- +
- + for (String teamName : _teams)
- + {
- + int index = _teams.indexOf(teamName);
- +
- + if (index == -1)
- + {
- + return;
- + }
- + if (Config.CTF_BASE_TELEPORT_FIRST)
- + {
- + statement = con.prepareStatement("INSERT INTO ctf_teams (teamId ,teamName, teamX, teamY, teamZ, teamColor, flagX, flagY, flagZ, teamBaseX, teamBaseY, teamBaseZ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
- + statement.setInt(1, index);
- + statement.setString(2, teamName);
- + statement.setInt(3, _teamsX.get(index));
- + statement.setInt(4, _teamsY.get(index));
- + statement.setInt(5, _teamsZ.get(index));
- + statement.setInt(6, _teamColors.get(index));
- + statement.setInt(7, _flagsX.get(index));
- + statement.setInt(8, _flagsY.get(index));
- + statement.setInt(9, _flagsZ.get(index));
- + statement.setInt(10, _teamsBaseX.get(index));
- + statement.setInt(11, _teamsBaseY.get(index));
- + statement.setInt(12, _teamsBaseZ.get(index));
- + statement.execute();
- + statement.close();
- + }
- + else
- + {
- + statement = con.prepareStatement("INSERT INTO ctf_teams (teamId ,teamName, teamX, teamY, teamZ, teamColor, flagX, flagY, flagZ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)");
- + statement.setInt(1, index);
- + statement.setString(2, teamName);
- + statement.setInt(3, _teamsX.get(index));
- + statement.setInt(4, _teamsY.get(index));
- + statement.setInt(5, _teamsZ.get(index));
- + statement.setInt(6, _teamColors.get(index));
- + statement.setInt(7, _flagsX.get(index));
- + statement.setInt(8, _flagsY.get(index));
- + statement.setInt(9, _flagsZ.get(index));
- + statement.execute();
- + statement.close();
- + }
- + }
- + }
- + catch (Exception e)
- + {
- + _log.warning("Exception: CTF.saveData(): " + e.getMessage());
- + }
- + finally
- + {
- + try
- + {
- + if (con != null)
- + {
- + con.close();
- + }
- + }
- + catch (SQLException e)
- + {
- + e.printStackTrace();
- + }
- + }
- + }
- +
- + public static void showEventHtml(L2PcInstance eventPlayer, String objectId)
- + {
- + try
- + {
- + NpcHtmlMessage adminReply = new NpcHtmlMessage(0);
- + TextBuilder replyMSG = new TextBuilder();
- +
- + replyMSG.append("<html><body>");
- + replyMSG.append("CTF Match<br><br><br>");
- + replyMSG.append("Current event...<br>");
- + replyMSG.append(" ... description: <font color=\"00FF00\">" + _eventDesc + "</font><br>");
- + if (Config.CTF_ANNOUNCE_REWARD)
- + {
- + replyMSG.append(" ... reward: (" + _rewardAmount + ") " + ItemTable.getInstance().getTemplate(_rewardId).getName() + "<br>");
- + }
- +
- + if (!_started && !_joining)
- + {
- + replyMSG.append("<center>Wait till the admin/gm start the participation.</center>");
- + }
- + else if (Config.CTF_EVEN_TEAMS.equals("SHUFFLE") && !checkMaxPlayers(_playersShuffle.size()))
- + {
- + if (!CTF._started)
- + {
- + replyMSG.append("<font color=\"FFFF00\">The event has reached its maximum capacity.</font><br>Keep checking, someone may crit and you can steal their spot.");
- + }
- + }
- + else if (eventPlayer.isCursedWeaponEquipped() && !Config.CTF_JOIN_CURSED)
- + {
- + replyMSG.append("<font color=\"FFFF00\">You can't participate in this event with a cursed Weapon.</font><br>");
- + }
- + else if (!_started && _joining && (eventPlayer.getLevel() >= _minlvl) && (eventPlayer.getLevel() <= _maxlvl))
- + {
- + if (_players.contains(eventPlayer) || checkShufflePlayers(eventPlayer))
- + {
- + if (Config.CTF_EVEN_TEAMS.equals("NO") || Config.CTF_EVEN_TEAMS.equals("BALANCE"))
- + {
- + replyMSG.append("You are already participating in team <font color=\"LEVEL\">" + eventPlayer._teamNameCTF + "</font><br><br>");
- + }
- + else if (Config.CTF_EVEN_TEAMS.equals("SHUFFLE"))
- + {
- + replyMSG.append("You are already participating!<br><br>");
- + }
- +
- + replyMSG.append("<table border=\"0\"><tr>");
- + replyMSG.append("<td width=\"200\">Wait till event start or</td>");
- + replyMSG.append("<td width=\"60\"><center><button value=\"remove\" action=\"bypass -h npc_" + objectId + "_ctf_player_leave\" width=50 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></center></td>");
- + replyMSG.append("<td width=\"100\">your participation!</td>");
- + replyMSG.append("</tr></table>");
- + }
- + else
- + {
- + replyMSG.append("<td width=\"200\">Your level : <font color=\"00FF00\">" + eventPlayer.getLevel() + "</font></td><br>");
- + replyMSG.append("<td width=\"200\">Min level : <font color=\"00FF00\">" + _minlvl + "</font></td><br>");
- + replyMSG.append("<td width=\"200\">Max level : <font color=\"00FF00\">" + _maxlvl + "</font></td><br><br>");
- +
- + if (Config.CTF_EVEN_TEAMS.equals("NO") || Config.CTF_EVEN_TEAMS.equals("BALANCE"))
- + {
- + replyMSG.append("<center><table border=\"0\">");
- +
- + for (String team : _teams)
- + {
- + replyMSG.append("<tr><td width=\"100\"><font color=\"LEVEL\">" + team + "</font> (" + teamPlayersCount(team) + " joined)</td>");
- + replyMSG.append("<td width=\"60\"><button value=\"Join\" action=\"bypass -h npc_" + objectId + "_ctf_player_join " + team + "\" width=50 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>");
- + }
- +
- + replyMSG.append("</table></center>");
- + }
- + else if (Config.CTF_EVEN_TEAMS.equals("SHUFFLE"))
- + {
- + replyMSG.append("<center><table border=\"0\">");
- +
- + for (String team : _teams)
- + {
- + replyMSG.append("<tr><td width=\"100\"><font color=\"LEVEL\">" + team + "</font></td>");
- + }
- +
- + replyMSG.append("</table></center><br>");
- +
- + replyMSG.append("<button value=\"Join\" action=\"bypass -h npc_" + objectId + "_ctf_player_join eventShuffle\" width=50 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
- + replyMSG.append("Teams will be randomly generated!");
- + }
- + }
- + }
- + else if (_started && !_joining)
- + {
- + replyMSG.append("<center>CTF match is in progress.</center>");
- + }
- + else if ((eventPlayer.getLevel() < _minlvl) || (eventPlayer.getLevel() > _maxlvl))
- + {
- + replyMSG.append("Your lvl : <font color=\"00FF00\">" + eventPlayer.getLevel() + "</font><br>");
- + replyMSG.append("Min level : <font color=\"00FF00\">" + _minlvl + "</font><br>");
- + replyMSG.append("Max level : <font color=\"00FF00\">" + _maxlvl + "</font><br><br>");
- + replyMSG.append("<font color=\"FFFF00\">You can't participatein this event.</font><br>");
- + }
- + // Show how many players joined & how many are still needed to join
- + replyMSG.append("<br>There are " + _playersShuffle.size() + " player(s) participating in this event.<br>");
- + if (_joining)
- + {
- + if (_playersShuffle.size() < _minPlayers)
- + {
- + int playersNeeded = _minPlayers - _playersShuffle.size();
- + replyMSG.append("The event will not start unless " + playersNeeded + " more player(s) joins!");
- + }
- + }
- +
- + replyMSG.append("</body></html>");
- + adminReply.setHtml(replyMSG.toString());
- + eventPlayer.sendPacket(adminReply);
- +
- + // Send a Server->Client ActionFailed to the L2PcInstance in order to avoid that the client wait another packet
- + eventPlayer.sendPacket(ActionFailed.STATIC_PACKET);
- + }
- + catch (Exception e)
- + {
- + _log.warning("CTF Engine[showEventHtlm(" + eventPlayer.getName() + ", " + objectId + ")]: exception" + e.getMessage());
- + }
- + }
- +
- + public static void addPlayer(L2PcInstance player, String teamName)
- + {
- + if (!addPlayerOk(teamName, player))
- + {
- + return;
- + }
- +
- + if (Config.CTF_EVEN_TEAMS.equals("NO") || Config.CTF_EVEN_TEAMS.equals("BALANCE"))
- + {
- + player._teamNameCTF = teamName;
- + _players.add(player);
- + setTeamPlayersCount(teamName, teamPlayersCount(teamName) + 1);
- + }
- + else if (Config.CTF_EVEN_TEAMS.equals("SHUFFLE"))
- + {
- + _playersShuffle.add(player);
- + }
- +
- + player._inEventCTF = true;
- + player._countCTFflags = 0;
- + }
- +
- + public static synchronized void removeOfflinePlayers()
- + {
- + try
- + {
- + if (_playersShuffle == null)
- + {
- + return;
- + }
- + else if (_playersShuffle.isEmpty())
- + {
- + return;
- + }
- + else if (_playersShuffle.size() > 0)
- + {
- + for (L2PcInstance player : _playersShuffle)
- + {
- + if (player == null)
- + {
- + _playersShuffle.remove(player);
- + }
- + else if (!player.isOnline() || player.isInJail())
- + {
- + removePlayer(player);
- + }
- + if ((_playersShuffle.size() == 0) || _playersShuffle.isEmpty())
- + {
- + break;
- + }
- + }
- + }
- + }
- + catch (Exception e)
- + {
- + _log.warning("CTF Engine exception: " + e.getMessage());
- + return;
- + }
- + }
- +
- + public static boolean checkShufflePlayers(L2PcInstance eventPlayer)
- + {
- + try
- + {
- + for (L2PcInstance player : _playersShuffle)
- + {
- + if ((player == null) || !player.isOnline())
- + {
- + _playersShuffle.remove(player);
- + eventPlayer._inEventCTF = false;
- + continue;
- + }
- + else if (player.getObjectId() == eventPlayer.getObjectId())
- + {
- + eventPlayer._inEventCTF = true;
- + eventPlayer._countCTFflags = 0;
- + return true;
- + }
- + // this 1 is incase player got new objectid after DC or reconnect
- + else if (player.getName().equals(eventPlayer.getName()))
- + {
- + _playersShuffle.remove(player);
- + _playersShuffle.add(eventPlayer);
- + eventPlayer._inEventCTF = true;
- + eventPlayer._countCTFflags = 0;
- + return true;
- + }
- + }
- + }
- + catch (Exception e)
- + {
- + }
- + return false;
- + }
- +
- + public static boolean addPlayerOk(String teamName, L2PcInstance eventPlayer)
- + {
- + try
- + {
- + if (checkShufflePlayers(eventPlayer) || eventPlayer._inEventCTF)
- + {
- + eventPlayer.sendMessage("You are already participating in the event!");
- + return false;
- + }
- +
- + for (L2PcInstance player : _players)
- + {
- + if (player.getObjectId() == eventPlayer.getObjectId())
- + {
- + eventPlayer.sendMessage("You are already participating in the event!");
- + return false;
- + }
- + else if (player.getName() == eventPlayer.getName())
- + {
- + eventPlayer.sendMessage("You are already participating in the event!");
- + return false;
- + }
- + }
- + if (_players.contains(eventPlayer))
- + {
- + eventPlayer.sendMessage("You are already participating in the event!");
- + return false;
- + }
- + }
- + catch (Exception e)
- + {
- + _log.warning("CTF Siege Engine exception: " + e.getMessage());
- + }
- +
- + if (Config.CTF_EVEN_TEAMS.equals("NO"))
- + {
- + return true;
- + }
- + else if (Config.CTF_EVEN_TEAMS.equals("BALANCE"))
- + {
- + boolean allTeamsEqual = true;
- + int countBefore = -1;
- +
- + for (int playersCount : _teamPlayersCount)
- + {
- + if (countBefore == -1)
- + {
- + countBefore = playersCount;
- + }
- +
- + if (countBefore != playersCount)
- + {
- + allTeamsEqual = false;
- + break;
- + }
- +
- + countBefore = playersCount;
- + }
- +
- + if (allTeamsEqual)
- + {
- + return true;
- + }
- +
- + countBefore = Integer.MAX_VALUE;
- +
- + for (int teamPlayerCount : _teamPlayersCount)
- + {
- + if (teamPlayerCount < countBefore)
- + {
- + countBefore = teamPlayerCount;
- + }
- + }
- +
- + Vector<String> joinableTeams = new Vector<String>();
- +
- + for (String team : _teams)
- + {
- + if (teamPlayersCount(team) == countBefore)
- + {
- + joinableTeams.add(team);
- + }
- + }
- +
- + if (joinableTeams.contains(teamName))
- + {
- + return true;
- + }
- + }
- + else if (Config.CTF_EVEN_TEAMS.equals("SHUFFLE"))
- + {
- + return true;
- + }
- +
- + eventPlayer.sendMessage("Too many players in team \"" + teamName + "\"");
- + return false;
- + }
- +
- + public static synchronized void addDisconnectedPlayer(L2PcInstance player)
- + {
- + /*
- + * !!! CAUTION !!! Do NOT fix multiple object Ids on this event or you will ruin the flag reposition check!!! All Multiple object Ids will be collected by the Garbage Collector, after the event ends, memory sweep is made!!!
- + */
- +
- + if ((Config.CTF_EVEN_TEAMS.equals("SHUFFLE") && (_teleport || _started)) || (Config.CTF_EVEN_TEAMS.equals("NO") || (Config.CTF_EVEN_TEAMS.equals("BALANCE") && (_teleport || _started))))
- + {
- + if (Config.CTF_ON_START_REMOVE_ALL_EFFECTS)
- + {
- + for (L2Effect e : player.getAllEffects())
- + {
- + if (e != null)
- + {
- + e.exit();
- + }
- + }
- + }
- +
- + player._teamNameCTF = _savePlayerTeams.get(_savePlayers.indexOf(player.getName()));
- + for (L2PcInstance p : _players)
- + {
- + if (p == null)
- + {
- + continue;
- + }
- + // check by name incase player got new objectId
- + else if (p.getName().equals(player.getName()))
- + {
- + player._originalNameColorCTF = player.getAppearance().getNameColor();
- + player._originalKarmaCTF = player.getKarma();
- + player._inEventCTF = true;
- + player._countCTFflags = p._countCTFflags;
- + _players.remove(p); // removing old object id from vector
- + _players.add(player); // adding new objectId to vector
- + break;
- + }
- + }
- + player.setTeam(_teams.indexOf(player._teamNameCTF));
- + player.setKarma(0);
- + player.broadcastUserInfo();
- + if (Config.CTF_BASE_TELEPORT_FIRST)
- + {
- + player.sendMessage("We missed you! You will be sent back into battle in 10 seconds!");
- +
- + player.teleToLocation(_teamsBaseX.get(_teams.indexOf(player._teamNameCTF)), _teamsBaseY.get(_teams.indexOf(player._teamNameCTF)), _teamsBaseZ.get(_teams.indexOf(player._teamNameCTF)));
- +
- + ThreadPoolManager.getInstance().scheduleGeneral(new BaseTeleportTask(player, false), 10000);
- + }
- + else
- + {
- + player.teleToLocation(_teamsX.get(_teams.indexOf(player._teamNameCTF)), _teamsY.get(_teams.indexOf(player._teamNameCTF)), _teamsZ.get(_teams.indexOf(player._teamNameCTF)));
- + }
- + Started(player);
- + CheckRestoreFlags();
- + }
- + }
- +
- + public static void removePlayer(L2PcInstance player)
- + {
- + if (player._inEventCTF)
- + {
- + if (!_joining)
- + {
- + player.getAppearance().setNameColor(player._originalNameColorCTF);
- + player.setKarma(player._originalKarmaCTF);
- + player.broadcastUserInfo();
- + }
- + player._teamNameCTF = new String();
- + player._countCTFflags = 0;
- + player._inEventCTF = false;
- +
- + if ((Config.CTF_EVEN_TEAMS.equals("NO") || Config.CTF_EVEN_TEAMS.equals("BALANCE")) && _players.contains(player))
- + {
- + setTeamPlayersCount(player._teamNameCTF, teamPlayersCount(player._teamNameCTF) - 1);
- + _players.remove(player);
- + }
- + else if (Config.CTF_EVEN_TEAMS.equals("SHUFFLE") && (!_playersShuffle.isEmpty() && _playersShuffle.contains(player)))
- + {
- + _playersShuffle.remove(player);
- + }
- + }
- + }
- +
- + public static void cleanCTFEvent()
- + {
- + _log.warning("CTF : Cleaning players.");
- + for (L2PcInstance player : _players)
- + {
- + if (player != null)
- + {
- + if (player._haveFlagCTF)
- + {
- + removeFlagFromPlayer(player);
- + }
- + else
- + {
- + player.getInventory().destroyItemByItemId("", CTF._FLAG_IN_HAND_ITEM_ID, 1, player, null);
- + }
- + player._haveFlagCTF = false;
- + removePlayer(player);
- + if (_savePlayers.contains(player.getName()))
- + {
- + _savePlayers.remove(player.getName());
- + }
- + player._inEventCTF = false;
- + }
- + }
- + if ((_playersShuffle != null) && !_playersShuffle.isEmpty())
- + {
- + for (L2PcInstance player : _playersShuffle)
- + {
- + if (player != null)
- + {
- + player._inEventCTF = false;
- + }
- + }
- + }
- + _log.warning("CTF : Cleaning teams and flags.");
- + for (String team : _teams)
- + {
- + int index = _teams.indexOf(team);
- + _teamPointsCount.set(index, 0);
- + _flagSpawns.set(index, null);
- + _flagsTaken.set(index, false);
- + _teamPlayersCount.set(index, 0);
- + _teamPointsCount.set(index, 0);
- + _flagsNotRemoved.set(index, false);
- + }
- + _topScore = 0;
- + _topTeam = new String();
- + _players = new Vector<L2PcInstance>();
- + _playersShuffle = new Vector<L2PcInstance>();
- + _savePlayers = new Vector<String>();
- + _savePlayerTeams = new Vector<String>();
- + _teamPointsCount = new Vector<Integer>();
- + _flagSpawns = new Vector<L2Spawn>();
- + _flagsTaken = new Vector<Boolean>();
- + _teamPlayersCount = new Vector<Integer>();
- + _flagsNotRemoved = new Vector<Boolean>();
- + _playerScores = new FastMap<String, Integer>();
- + _log.warning("Cleaning CTF done.");
- + _log.warning("Loading new data from MySql");
- + loadData();
- + }
- +
- + public static void unspawnEventNpc()
- + {
- + if (_npcSpawn == null)
- + {
- + return;
- + }
- +
- + _npcSpawn.getLastSpawn().deleteMe();
- + _npcSpawn.stopRespawn();
- + SpawnTable.getInstance().deleteSpawn(_npcSpawn, true);
- + }
- +
- + public static void teleportFinish()
- + {
- + AnnounceToPlayers(false, "CTF Event: Teleport back to participation NPC in 15 seconds!");
- + ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
- + {
- + @Override
- + public void run()
- + {
- + for (L2PcInstance player : _players)
- + {
- + if (player != null)
- + {
- + if (player.isOnline())
- + {
- + player.setTeam(0);
- + player.broadcastUserInfo();
- + player.teleToLocation(_npcX, _npcY, _npcZ, false);
- + }
- +
- + else
- + {
- + Connection con = null;
- + try
- + {
- + con = L2DatabaseFactory.getInstance().getConnection();
- +
- + PreparedStatement statement = con.prepareStatement("UPDATE characters SET x=?, y=?, z=? WHERE char_name=?");
- + statement.setInt(1, _npcX);
- + statement.setInt(2, _npcY);
- + statement.setInt(3, _npcZ);
- + statement.setString(4, player.getName());
- + statement.execute();
- + statement.close();
- + }
- + catch (SQLException se)
- + {
- + _log.warning("CTF Engine exception: " + se.getMessage());
- + }
- + finally
- + {
- + try
- + {
- + if (con != null)
- + {
- + con.close();
- + }
- + }
- + catch (SQLException e)
- + {
- + e.printStackTrace();
- + }
- + }
- + }
- + }
- + }
- + cleanCTFEvent();
- + }
- + }, 15000);
- + }
- +
- + public static int teamFlagCount(String teamName)
- + {
- + int index = _teams.indexOf(teamName);
- +
- + if (index == -1)
- + {
- + return -1;
- + }
- +
- + return _teamPointsCount.get(index);
- + }
- +
- + public static void setTeamFlagCount(String teamName, int teamFlagCount)
- + {
- + int index = _teams.indexOf(teamName);
- +
- + if (index == -1)
- + {
- + return;
- + }
- +
- + _teamPointsCount.set(index, teamFlagCount);
- + }
- +
- + /**
- + * Used to calculate the event CTF area, so that players don't run off with the flag. Essential, since a player may take the flag just so other teams can't score points. This function is Only called upon ONE time on BEGINING OF EACH EVENT right after we spawn the flags.
- + */
- + private static void calculateOutSideOfCTFEvent()
- + {
- + if ((_teams == null) || (_flagSpawns == null) || (_teamsX == null) || (_teamsY == null) || (_teamsZ == null))
- + {
- + return;
- + }
- +
- + int division = _teams.size() * 2, pos = 0;
- + int[] locX = new int[division], locY = new int[division], locZ = new int[division];
- + // Get all coordinates inorder to create a polygon:
- + for (L2Spawn flag : _flagSpawns)
- + {
- + locX[pos] = flag.getLocx();
- + locY[pos] = flag.getLocy();
- + locZ[pos] = flag.getLocz();
- + pos++;
- + if (pos > (division / 2))
- + {
- + break;
- + }
- + }
- +
- + for (int x = 0; x < _teams.size(); x++)
- + {
- + locX[pos] = _teamsX.get(x);
- + locY[pos] = _teamsY.get(x);
- + locZ[pos] = _teamsZ.get(x);
- + pos++;
- + if (pos > division)
- + {
- + break;
- + }
- + }
- +
- + // find the polygon center, note that it's not the mathematical center of the polygon,
- + // rather than a point which centers all coordinates:
- + int centerX = 0, centerY = 0, centerZ = 0;
- + for (int x = 0; x < pos; x++)
- + {
- + centerX += (locX[x] / division);
- + centerY += (locY[x] / division);
- + centerZ += (locZ[x] / division);
- + }
- +
- + // now let's find the furthest distance from the "center" to the egg shaped sphere
- + // surrounding the polygon, size x1.5 (for maximum logical area to wander...):
- + int maxX = 0, maxY = 0, maxZ = 0;
- + for (int x = 0; x < pos; x++)
- + {
- + if (maxX < (2 * Math.abs(centerX - locX[x])))
- + {
- + maxX = (2 * Math.abs(centerX - locX[x]));
- + }
- + if (maxY < (2 * Math.abs(centerY - locY[x])))
- + {
- + maxY = (2 * Math.abs(centerY - locY[x]));
- + }
- + if (maxZ < (2 * Math.abs(centerZ - locZ[x])))
- + {
- + maxZ = (2 * Math.abs(centerZ - locZ[x]));
- + }
- + }
- +
- + // centerX,centerY,centerZ are the coordinates of the "event center".
- + // so let's save those coordinates to check on the players:
- + eventCenterX = centerX;
- + eventCenterY = centerY;
- + eventCenterZ = centerZ;
- + eventOffset = maxX;
- + if (eventOffset < maxY)
- + {
- + eventOffset = maxY;
- + }
- + if (eventOffset < maxZ)
- + {
- + eventOffset = maxZ;
- + }
- + }
- +
- + public static boolean isOutsideCTFArea(L2PcInstance _player)
- + {
- + if ((_player == null) || !_player.isOnline())
- + {
- + return true;
- + }
- + if (!((_player.getX() > (eventCenterX - eventOffset)) && (_player.getX() < (eventCenterX + eventOffset)) && (_player.getY() > (eventCenterY - eventOffset)) && (_player.getY() < (eventCenterY + eventOffset)) && (_player.getZ() > (eventCenterZ - eventOffset)) && (_player.getZ() < (eventCenterZ + eventOffset))))
- + {
- + return true;
- + }
- + return false;
- + }
- +
- + @SuppressWarnings("synthetic-access")
- + private static class SingletonHolder
- + {
- + protected static final CTFEvent _instance = new CTFEvent();
- + }
- +
- + /**
- + * @return
- + */
- + public static boolean isStarted()
- + {
- + // TODO Auto-generated method stub
- + return false;
- + }
- +
- + /**
- + * @return
- + */
- + public static int getCTFEventInstance()
- + {
- + // TODO Auto-generated method stub
- + return 0;
- + }
- +
- + /**
- + * @param objectId
- + * @return
- + */
- + public static int getParticipantTeamId(int objectId)
- + {
- + // TODO Auto-generated method stub
- + return 0;
- + }
- +
- + /**
- + *
- + */
- + public static void init()
- + {
- + // TODO Auto-generated method stub
- +
- + }
- +
- + /**
- + * @return
- + */
- + public static boolean startParticipation()
- + {
- + // TODO Auto-generated method stub
- + return false;
- + }
- +
- + /**
- + * @return
- + */
- + public static boolean startFight()
- + {
- + // TODO Auto-generated method stub
- + return false;
- + }
- +
- + /**
- + * @param string
- + */
- + public static void sysMsgToAllParticipants(String string)
- + {
- + // TODO Auto-generated method stub
- +
- + }
- +
- + /**
- + * @return
- + */
- + public static String calculateRewards()
- + {
- + // TODO Auto-generated method stub
- + return null;
- + }
- +
- + /**
- + *
- + */
- + public static void stopFight()
- + {
- + // TODO Auto-generated method stub
- +
- + }
- +
- + /**
- + * @return
- + */
- + public static boolean isInactive()
- + {
- + // TODO Auto-generated method stub
- + return false;
- + }
- +
- + /**
- + * @return
- + */
- + public static boolean isParticipating()
- + {
- + // TODO Auto-generated method stub
- + return false;
- + }
- +
- + /**
- + * @param objectId
- + * @return
- + */
- + public static boolean isPlayerParticipant(int objectId)
- + {
- + // TODO Auto-generated method stub
- + return false;
- + }
- +
- + /**
- + * @param player
- + * @param targetPlayer
- + * @param skill
- + * @return
- + */
- + public static boolean checkForCTFSkill(L2PcInstance player, L2PcInstance targetPlayer, L2Skill skill)
- + {
- + // TODO Auto-generated method stub
- + return false;
- + }
- +
- + /**
- + * @param objectId
- + * @return
- + */
- + public static boolean onItemSummon(int objectId)
- + {
- + // TODO Auto-generated method stub
- + return false;
- + }
- +
- + /**
- + * @param objectId
- + * @return
- + */
- + public static boolean onEscapeUse(int objectId)
- + {
- + // TODO Auto-generated method stub
- + return false;
- + }
- +
- + /**
- + * @param activeChar
- + */
- + public static void onLogin(L2PcInstance activeChar)
- + {
- + // TODO Auto-generated method stub
- +
- + }
- +
- + /**
- + * @param objectId
- + * @return
- + */
- + public static CTFEventTeam getParticipantEnemyTeam(int objectId)
- + {
- + // TODO Auto-generated method stub
- + return null;
- + }
- +
- + /**
- + * @param killer
- + * @param l2PcInstance
- + */
- + public static void onKill(L2Character killer, L2PcInstance l2PcInstance)
- + {
- + // TODO Auto-generated method stub
- +
- + }
- +
- + /**
- + * @param l2PcInstance
- + */
- + public static void onTeleported(L2PcInstance l2PcInstance)
- + {
- + // TODO Auto-generated method stub
- +
- + }
- +
- + /**
- + * @param l2PcInstance
- + */
- + public static void onLogout(L2PcInstance l2PcInstance)
- + {
- + // TODO Auto-generated method stub
- +
- + }
- +
- + /**
- + * @param objectId
- + */
- + public static void removeParticipant(int objectId)
- + {
- + // TODO Auto-generated method stub
- +
- + }
- +}
- Index: java/com/l2jserver/gameserver/model/actor/instance/L2DMEventNpcInstance.java
- ===================================================================
- --- java/com/l2jserver/gameserver/model/actor/instance/L2DMEventNpcInstance.java (revision 0)
- +++ java/com/l2jserver/gameserver/model/actor/instance/L2DMEventNpcInstance.java (working copy)
- @@ -0,0 +1,100 @@
- +/*
- + * This program is free software: you can redistribute it and/or modify it under
- + * the terms of the GNU General Public License as published by the Free Software
- + * Foundation, either version 3 of the License, or (at your option) any later
- + * version.
- + *
- + * This program is distributed in the hope that it will be useful, but WITHOUT
- + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- + * details.
- + *
- + * You should have received a copy of the GNU General Public License along with
- + * this program. If not, see <http://www.gnu.org/licenses/>.
- + */
- +
- +package com.l2jserver.gameserver.model.actor.instance;
- +
- +import com.l2jserver.Config;
- +import com.l2jserver.gameserver.cache.HtmCache;
- +import com.l2jserver.gameserver.model.actor.L2Npc;
- +import com.l2jserver.gameserver.model.actor.templates.L2NpcTemplate;
- +import com.l2jserver.gameserver.model.entity.DMEvent;
- +import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
- +import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
- +
- +public class L2DMEventNpcInstance extends L2Npc
- +{
- + private static final String htmlPath="data/html/mods/DMEvent/";
- +
- + public L2DMEventNpcInstance(int objectId, L2NpcTemplate template)
- + {
- + super(objectId, template);
- + setInstanceType(InstanceType.L2DMEventNpcInstance);
- + }
- +
- + @Override
- + public void onBypassFeedback(L2PcInstance playerInstance, String command)
- + {
- + DMEvent.onBypass(command, playerInstance);
- + }
- +
- + @Override
- + public void showChatWindow(L2PcInstance playerInstance, int val)
- + {
- + if (playerInstance == null)
- + return;
- +
- + if (DMEvent.isParticipating())
- + {
- + final boolean isParticipant = DMEvent.isPlayerParticipant(playerInstance.getObjectId());
- + final String htmContent;
- +
- + if (!isParticipant)
- + htmContent = HtmCache.getInstance().getHtm(playerInstance.getHtmlPrefix(), htmlPath + "Participation.htm");
- + else
- + htmContent = HtmCache.getInstance().getHtm(playerInstance.getHtmlPrefix(), htmlPath + "RemoveParticipation.htm");
- +
- + if (htmContent != null)
- + {
- + int[] teamsPlayerCounts = DMEvent.getTeamsPlayerCounts();
- + NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(getObjectId());
- +
- + npcHtmlMessage.setHtml(htmContent);
- + npcHtmlMessage.replace("%objectId%", String.valueOf(getObjectId()));
- + npcHtmlMessage.replace("%team1name%", Config.DM_EVENT_TEAM_1_NAME);
- + npcHtmlMessage.replace("%team1playercount%", String.valueOf(teamsPlayerCounts[0]));
- + npcHtmlMessage.replace("%team2name%", Config.DM_EVENT_TEAM_2_NAME);
- + npcHtmlMessage.replace("%team2playercount%", String.valueOf(teamsPlayerCounts[1]));
- + npcHtmlMessage.replace("%playercount%", String.valueOf(teamsPlayerCounts[0]+teamsPlayerCounts[1]));
- + if (!isParticipant)
- + npcHtmlMessage.replace("%fee%", DMEvent.getParticipationFee());
- +
- + playerInstance.sendPacket(npcHtmlMessage);
- + }
- + }
- + else if (DMEvent.isStarting() || DMEvent.isStarted())
- + {
- + final String htmContent = HtmCache.getInstance().getHtm(playerInstance.getHtmlPrefix(), htmlPath + "Status.htm");
- +
- + if (htmContent != null)
- + {
- + int[] teamsPlayerCounts = DMEvent.getTeamsPlayerCounts();
- + int[] teamsPointsCounts = DMEvent.getTeamsPoints();
- + NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(getObjectId());
- +
- + npcHtmlMessage.setHtml(htmContent);
- + //npcHtmlMessage.replace("%objectId%", String.valueOf(getObjectId()));
- + npcHtmlMessage.replace("%team1name%", Config.DM_EVENT_TEAM_1_NAME);
- + npcHtmlMessage.replace("%team1playercount%", String.valueOf(teamsPlayerCounts[0]));
- + npcHtmlMessage.replace("%team1points%", String.valueOf(teamsPointsCounts[0]));
- + npcHtmlMessage.replace("%team2name%", Config.DM_EVENT_TEAM_2_NAME);
- + npcHtmlMessage.replace("%team2playercount%", String.valueOf(teamsPlayerCounts[1]));
- + npcHtmlMessage.replace("%team2points%", String.valueOf(teamsPointsCounts[1])); // <---- array index from 0 to 1 thx DaRkRaGe
- + playerInstance.sendPacket(npcHtmlMessage);
- + }
- + }
- +
- + playerInstance.sendPacket(ActionFailed.STATIC_PACKET);
- + }
- +}
- Index: java/com/l2jserver/gameserver/model/L2Object.java
- ===================================================================
- --- java/com/l2jserver/gameserver/model/L2Object.java (revision 65)
- +++ java/com/l2jserver/gameserver/model/L2Object.java (working copy)
- @@ -173,6 +173,8 @@
- L2ClanHallDoormenInstance(L2DoormenInstance),
- // Custom
- L2ClassMasterInstance(L2NpcInstance),
- + L2CTFEventNpcInstance(L2Npc),
- + L2DMEventNpcInstance(L2Npc),
- L2NpcBufferInstance(L2Npc),
- L2TvTEventNpcInstance(L2Npc),
- L2TvTRoundEventNpcInstance(L2Npc),
- Index: java/com/l2jserver/gameserver/model/entity/DMEventTeleporter.java
- ===================================================================
- --- java/com/l2jserver/gameserver/model/entity/DMEventTeleporter.java (revision 0)
- +++ java/com/l2jserver/gameserver/model/entity/DMEventTeleporter.java (working copy)
- @@ -0,0 +1,115 @@
- +/*
- + * This program is free software: you can redistribute it and/or modify it under
- + * the terms of the GNU General Public License as published by the Free Software
- + * Foundation, either version 3 of the License, or (at your option) any later
- + * version.
- + *
- + * This program is distributed in the hope that it will be useful, but WITHOUT
- + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- + * details.
- + *
- + * You should have received a copy of the GNU General Public License along with
- + * this program. If not, see <http://www.gnu.org/licenses/>.
- + */
- +
- +package com.l2jserver.gameserver.model.entity;
- +
- +import com.l2jserver.Config;
- +import com.l2jserver.gameserver.ThreadPoolManager;
- +import com.l2jserver.gameserver.model.actor.L2Summon;
- +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
- +import com.l2jserver.util.Rnd;
- +
- +/**
- + * @author FBIagent, edited U3Games
- + */
- +
- +public class DMEventTeleporter implements Runnable
- +{
- + /** The instance of the player to teleport */
- + private L2PcInstance _activeChar = null;
- + /** Coordinates of the spot to teleport to */
- + private int[] _coordinates = new int[3];
- + /** Admin removed this player from event */
- + private boolean _adminRemove = false;
- +
- + /**
- + * Initialize the teleporter and start the delayed task.
- + * @param activeChar
- + * @param coordinates
- + * @param fastSchedule
- + * @param adminRemove
- + */
- + public DMEventTeleporter(L2PcInstance activeChar, int[] coordinates, boolean fastSchedule, boolean adminRemove)
- + {
- + _activeChar = activeChar;
- + _coordinates = coordinates;
- + _adminRemove = adminRemove;
- +
- + long delay = (DMEvent.isStarted() ? Config.DM_EVENT_RESPAWN_TELEPORT_DELAY : Config.DM_EVENT_START_LEAVE_TELEPORT_DELAY) * 1000;
- +
- + ThreadPoolManager.getInstance().scheduleGeneral(this, fastSchedule ? 0 : delay);
- + }
- +
- + /**
- + * The task method to teleport the player<br>
- + * 1. Unsummon pet if there is one<br>
- + * 2. Remove all effects<br>
- + * 3. Revive and full heal the player<br>
- + * 4. Teleport the player<br>
- + * 5. Broadcast status and user info<br><br>
- + *
- + * @see java.lang.Runnable#run()
- + */
- + public void run()
- + {
- + if (_activeChar == null)
- + return;
- +
- + L2Summon summon = _activeChar.getPet();
- +
- + if (summon != null)
- + summon.unSummon(_activeChar);
- +
- + if (Config.DM_EVENT_EFFECTS_REMOVAL == 0
- + || (Config.DM_EVENT_EFFECTS_REMOVAL == 1 && (_activeChar.getTeam() == 0 || (_activeChar.isInDuel() && _activeChar.getDuelState() != Duel.DUELSTATE_INTERRUPTED))))
- + _activeChar.stopAllEffectsExceptThoseThatLastThroughDeath();
- +
- + if (_activeChar.isInDuel())
- + _activeChar.setDuelState(Duel.DUELSTATE_INTERRUPTED);
- +
- + int DMInstance = DMEvent.getDMEventInstance();
- + if (DMInstance != 0)
- + {
- + if (DMEvent.isStarted() && !_adminRemove)
- + {
- + _activeChar.setInstanceId(DMInstance);
- + }
- + else
- + {
- + _activeChar.setInstanceId(0);
- + }
- + }
- + else
- + {
- + _activeChar.setInstanceId(0);
- + }
- +
- + _activeChar.doRevive();
- +
- + _activeChar.teleToLocation( _coordinates[ 0 ] + Rnd.get(101)-50, _coordinates[ 1 ] + Rnd.get(101)-50, _coordinates[ 2 ], false );
- +
- + if (DMEvent.isStarted() && !_adminRemove)
- + _activeChar.setTeam(DMEvent.getParticipantTeamId(_activeChar.getObjectId()) + 1);
- + else
- + _activeChar.setTeam(0);
- +
- + _activeChar.setCurrentCp(_activeChar.getMaxCp());
- + _activeChar.setCurrentHp(_activeChar.getMaxHp());
- + _activeChar.setCurrentMp(_activeChar.getMaxMp());
- +
- + _activeChar.broadcastStatusUpdate();
- + _activeChar.broadcastUserInfo();
- + }
- +}
- Index: java/com/l2jserver/gameserver/instancemanager/HandysBlockCheckerManager.java
- ===================================================================
- --- java/com/l2jserver/gameserver/instancemanager/HandysBlockCheckerManager.java (revision 65)
- +++ java/com/l2jserver/gameserver/instancemanager/HandysBlockCheckerManager.java (working copy)
- @@ -23,6 +23,8 @@
- import com.l2jserver.gameserver.ThreadPoolManager;
- import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
- import com.l2jserver.gameserver.model.entity.BlockCheckerEngine;
- +import com.l2jserver.gameserver.model.entity.CTFEvent;
- +import com.l2jserver.gameserver.model.entity.DMEvent;
- import com.l2jserver.gameserver.model.entity.TvTEvent;
- import com.l2jserver.gameserver.model.entity.TvTRoundEvent;
- import com.l2jserver.gameserver.model.itemcontainer.PcInventory;
- @@ -40,7 +42,7 @@
- * as the clearance of the participants list or liberate the arena.
- * @author BiggBoss
- */
- -public final class HandysBlockCheckerManager
- +public final class HandysBlockCheckerManager
- {
- // All the participants and their team classified by arena
- private static final ArenaParticipantsHolder[] _arenaPlayers = new ArenaParticipantsHolder[4];
- @@ -100,7 +102,7 @@
- {
- _arenaVotes.put(arena, 0);
- }
- -
- +
- protected HandysBlockCheckerManager()
- {
- // Initialize arena status
- @@ -119,7 +121,7 @@
- {
- return _arenaPlayers[arena];
- }
- -
- +
- /**
- * Initializes the participants holder
- */
- @@ -135,7 +137,7 @@
- * Add the player to the specified arena (through the specified arena manager) and send the needed server -> client packets
- * @param player
- * @param arenaId
- - * @return
- + * @return
- */
- public boolean addPlayerToArena(L2PcInstance player, int arenaId)
- {
- @@ -155,23 +157,35 @@
- return false;
- }
- }
- -
- +
- if (player.isCursedWeaponEquipped())
- {
- player.sendPacket(SystemMessageId.CANNOT_REGISTER_PROCESSING_CURSED_WEAPON);
- return false;
- }
- + if (CTFEvent.isPlayerParticipant(player.getObjectId()) || player.isInOlympiadMode())
- + {
- + player.sendMessage("Couldnt register you due other event participation");
- + return false;
- + }
- +
- + if (DMEvent.isPlayerParticipant(player.getObjectId()) || player.isInOlympiadMode())
- + {
- + player.sendMessage("Couldnt register you due other event participation");
- + return false;
- + }
- +
- if (TvTEvent.isPlayerParticipant(player.getObjectId()) || TvTRoundEvent.isPlayerParticipant(player.getObjectId()) || player.isInOlympiadMode())
- {
- player.sendMessage("Couldnt register you due other event participation");
- return false;
- }
- -
- +
- if (OlympiadManager.getInstance().isRegistered(player))
- {
- OlympiadManager.getInstance().unRegisterNoble(player);
- - player.sendPacket(SystemMessageId.COLISEUM_OLYMPIAD_KRATEIS_APPLICANTS_CANNOT_PARTICIPATE);
- + player.sendPacket(SystemMessageId.COLISEUM_OLYMPIAD_KRATEIS_APPLICANTS_CANNOT_PARTICIPATE);
- }
- // if(UnderGroundColiseum.getInstance().isRegisteredPlayer(player))
- @@ -210,7 +224,7 @@
- * Will remove the specified player from the specified team and arena and will send the needed packet to all his team mates / enemy team mates
- * @param player
- * @param arenaId
- - * @param team
- + * @param team
- */
- public void removePlayer(L2PcInstance player, int arenaId, int team)
- {
- @@ -295,7 +309,7 @@
- public boolean arenaIsBeingUsed(int arenaId)
- {
- if ((arenaId < 0) || (arenaId > 3))
- - {
- + {
- return false;
- }
- return _arenaStatus.get(arenaId);
- @@ -507,6 +521,7 @@
- private class PenaltyRemove implements Runnable
- {
- private final Integer objectId;
- +
- public PenaltyRemove(Integer id)
- {
- objectId = id;
- Index: java/com/l2jserver/gameserver/model/entity/DMManager.java
- ===================================================================
- --- java/com/l2jserver/gameserver/model/entity/DMManager.java (revision 0)
- +++ java/com/l2jserver/gameserver/model/entity/DMManager.java (working copy)
- @@ -0,0 +1,298 @@
- +/*
- + * This program is free software: you can redistribute it and/or modify it under
- + * the terms of the GNU General Public License as published by the Free Software
- + * Foundation, either version 3 of the License, or (at your option) any later
- + * version.
- + *
- + * This program is distributed in the hope that it will be useful, but WITHOUT
- + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- + * details.
- + *
- + * You should have received a copy of the GNU General Public License along with
- + * this program. If not, see <http://www.gnu.org/licenses/>.
- + */
- +package com.l2jserver.gameserver.model.entity;
- +
- +import java.util.Calendar;
- +import java.util.concurrent.ScheduledFuture;
- +import java.util.logging.Logger;
- +
- +import com.l2jserver.Config;
- +import com.l2jserver.gameserver.Announcements;
- +import com.l2jserver.gameserver.ThreadPoolManager;
- +
- +
- +/**
- + * @author FBIagent
- + */
- +
- +public class DMManager
- +{
- + protected static final Logger _log = Logger.getLogger(DMManager.class.getName());
- +
- + /** Task for event cycles<br> */
- + private DMStartTask _task;
- +
- + /**
- + * New instance only by getInstance()<br>
- + */
- + private DMManager()
- + {
- + if (Config.DM_EVENT_ENABLED)
- + {
- + DMEvent.init();
- +
- + this.scheduleEventStart();
- + _log.info("DMEventEngine[DMManager.DMManager()]: Started.");
- + }
- + else
- + {
- + _log.info("DMEventEngine[DMManager.DMManager()]: Engine is disabled.");
- + }
- + }
- +
- + /**
- + * Initialize new/Returns the one and only instance<br><br>
- + *
- + * @return DMManager<br>
- + */
- + public static DMManager getInstance()
- + {
- + return SingletonHolder._instance;
- + }
- +
- + /**
- + * Starts DMStartTask
- + */
- + public void scheduleEventStart()
- + {
- + try
- + {
- + Calendar currentTime = Calendar.getInstance();
- + Calendar nextStartTime = null;
- + Calendar testStartTime = null;
- + for (String timeOfDay : Config.DM_EVENT_INTERVAL)
- + {
- + // Creating a Calendar object from the specified interval value
- + 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 the date is in the past, make it the next day (Example: Checking for "1:00", when the time is 23:57.)
- + if (testStartTime.getTimeInMillis() < currentTime.getTimeInMillis())
- + {
- + testStartTime.add(Calendar.DAY_OF_MONTH, 1);
- + }
- + // Check for the test date to be the minimum (smallest in the specified list)
- + if (nextStartTime == null || testStartTime.getTimeInMillis() < nextStartTime.getTimeInMillis())
- + {
- + nextStartTime = testStartTime;
- + }
- + }
- + _task = new DMStartTask(nextStartTime.getTimeInMillis());
- + ThreadPoolManager.getInstance().executeTask(_task);
- + }
- + catch (Exception e)
- + {
- + _log.warning("DMEventEngine[DMManager.scheduleEventStart()]: Error figuring out a start time. Check DMEventInterval in config file.");
- + }
- + }
- +
- + /**
- + * Method to start participation
- + */
- + public void startReg()
- + {
- + if (!DMEvent.startParticipation())
- + {
- + Announcements.getInstance().announceToAll("DM Event: Event was cancelled.");
- + _log.warning("DMEventEngine[DMManager.run()]: Error spawning event npc for participation.");
- +
- + this.scheduleEventStart();
- + }
- + else
- + {
- + Announcements.getInstance().announceToAll("DM Event: Registration opened for " + Config.DM_EVENT_PARTICIPATION_TIME
- + + " minute(s).");
- +
- + // schedule registration end
- + _task.setStartTime(System.currentTimeMillis() + 60000L * Config.DM_EVENT_PARTICIPATION_TIME);
- + ThreadPoolManager.getInstance().executeTask(_task);
- + }
- + }
- +
- + /**
- + * Method to start the fight
- + */
- + public void startEvent()
- + {
- + if (!DMEvent.startFight())
- + {
- + Announcements.getInstance().announceToAll("DM Event: Event cancelled due to lack of Participation.");
- + _log.info("DMEventEngine[DMManager.run()]: Lack of registration, abort event.");
- +
- + this.scheduleEventStart();
- + }
- + else
- + {
- + DMEvent.sysMsgToAllParticipants("DM Event: Teleporting participants to an arena in "
- + + Config.DM_EVENT_START_LEAVE_TELEPORT_DELAY + " second(s).");
- + _task.setStartTime(System.currentTimeMillis() + 60000L * Config.DM_EVENT_RUNNING_TIME);
- + ThreadPoolManager.getInstance().executeTask(_task);
- + }
- + }
- +
- + /**
- + * Method to end the event and reward
- + */
- + public void endEvent()
- + {
- + Announcements.getInstance().announceToAll(DMEvent.calculateRewards());
- + DMEvent.sysMsgToAllParticipants("DM Event: Teleporting back to the registration npc in "
- + + Config.DM_EVENT_START_LEAVE_TELEPORT_DELAY + " second(s).");
- + DMEvent.stopFight();
- +
- + this.scheduleEventStart();
- + }
- +
- + public void skipDelay()
- + {
- + if (_task.nextRun.cancel(false))
- + {
- + _task.setStartTime(System.currentTimeMillis());
- + ThreadPoolManager.getInstance().executeTask(_task);
- + }
- + }
- +
- + /**
- + * Class for DM cycles
- + */
- + class DMStartTask implements Runnable
- + {
- + private long _startTime;
- + public ScheduledFuture<?> nextRun;
- +
- + public DMStartTask(long startTime)
- + {
- + _startTime = startTime;
- + }
- +
- + public void setStartTime(long startTime)
- + {
- + _startTime = startTime;
- + }
- +
- + /**
- + * @see java.lang.Runnable#run()
- + */
- + public void run()
- + {
- + int delay = (int) Math.round((_startTime - System.currentTimeMillis()) / 1000.0);
- +
- + if (delay > 0)
- + {
- + this.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
- + {
- + // start
- + if (DMEvent.isInactive())
- + {
- + DMManager.this.startReg();
- + }
- + else if (DMEvent.isParticipating())
- + {
- + DMManager.this.startEvent();
- + }
- + else
- + {
- + DMManager.this.endEvent();
- + }
- + }
- +
- + if (delay > 0)
- + {
- + nextRun = ThreadPoolManager.getInstance().scheduleGeneral(this, nextMsg * 1000);
- + }
- + }
- +
- + private void announce(long time)
- + {
- + if (time >= 3600 && time % 3600 == 0)
- + {
- + if (DMEvent.isParticipating())
- + {
- + Announcements.getInstance().announceToAll("DM Event: " + (time / 60 / 60) + " hour(s) until registration is closed!");
- + }
- + else if (DMEvent.isStarted())
- + {
- + DMEvent.sysMsgToAllParticipants("DM Event: " + (time / 60 / 60) + " hour(s) until event is finished!");
- + }
- + }
- + else if (time >= 60)
- + {
- + if (DMEvent.isParticipating())
- + {
- + Announcements.getInstance().announceToAll("DM Event: " + (time / 60) + " minute(s) until registration is closed!");
- + }
- + else if (DMEvent.isStarted())
- + {
- + DMEvent.sysMsgToAllParticipants("DM Event: " + (time / 60) + " minute(s) until the event is finished!");
- + }
- + }
- + else
- + {
- + if (DMEvent.isParticipating())
- + {
- + Announcements.getInstance().announceToAll("DM Event: " + time + " second(s) until registration is closed!");
- + }
- + else if (DMEvent.isStarted())
- + {
- + DMEvent.sysMsgToAllParticipants("DM Event: " + time + " second(s) until the event is finished!");
- + }
- + }
- + }
- + }
- +
- + @SuppressWarnings("synthetic-access")
- + private static class SingletonHolder
- + {
- + protected static final DMManager _instance = new DMManager();
- + }
- +}
- Index: java/com/l2jserver/gameserver/model/skills/L2Skill.java
- ===================================================================
- --- java/com/l2jserver/gameserver/model/skills/L2Skill.java (revision 65)
- +++ java/com/l2jserver/gameserver/model/skills/L2Skill.java (working copy)
- @@ -48,6 +48,8 @@
- import com.l2jserver.gameserver.model.conditions.Condition;
- import com.l2jserver.gameserver.model.effects.EffectTemplate;
- import com.l2jserver.gameserver.model.effects.L2Effect;
- +import com.l2jserver.gameserver.model.entity.CTFEvent;
- +import com.l2jserver.gameserver.model.entity.DMEvent;
- import com.l2jserver.gameserver.model.entity.TvTEvent;
- import com.l2jserver.gameserver.model.entity.TvTRoundEvent;
- import com.l2jserver.gameserver.model.holders.ItemHolder;
- @@ -1556,6 +1558,16 @@
- }
- }
- + if (!CTFEvent.checkForCTFSkill(player, targetPlayer, skill))
- + {
- + return false;
- + }
- +
- + if (!DMEvent.checkForDMSkill(player, targetPlayer, skill))
- + {
- + return false;
- + }
- +
- if (!TvTEvent.checkForTvTSkill(player, targetPlayer, skill))
- {
- return false;
- Index: java/com/l2jserver/gameserver/model/olympiad/OlympiadManager.java
- ===================================================================
- --- java/com/l2jserver/gameserver/model/olympiad/OlympiadManager.java (revision 65)
- +++ java/com/l2jserver/gameserver/model/olympiad/OlympiadManager.java (working copy)
- @@ -28,6 +28,8 @@
- import com.l2jserver.gameserver.model.L2World;
- import com.l2jserver.gameserver.model.StatsSet;
- import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
- +import com.l2jserver.gameserver.model.entity.CTFEvent;
- +import com.l2jserver.gameserver.model.entity.DMEvent;
- import com.l2jserver.gameserver.model.entity.TvTEvent;
- import com.l2jserver.gameserver.model.entity.TvTRoundEvent;
- import com.l2jserver.gameserver.network.SystemMessageId;
- @@ -493,13 +495,25 @@
- player.sendMessage("You can't join olympiad while participating on TvT Event.");
- return false;
- }
- -
- +
- if (TvTRoundEvent.isPlayerParticipant(charId))
- {
- player.sendMessage("You can't join olympiad while participating on TvT Round Event.");
- return false;
- }
- -
- +
- + if (CTFEvent.isPlayerParticipant(charId))
- + {
- + player.sendMessage("You can't join olympiad while participating on CTF Event.");
- + return false;
- + }
- +
- + if (DMEvent.isPlayerParticipant(charId))
- + {
- + player.sendMessage("You can't join olympiad while participating on DM Event.");
- + return false;
- + }
- +
- if (isRegistered(noble, player, true))
- {
- return false;
- Index: java/com/l2jserver/gameserver/model/entity/CTFEventTeleporter.java
- ===================================================================
- --- java/com/l2jserver/gameserver/model/entity/CTFEventTeleporter.java (revision 0)
- +++ java/com/l2jserver/gameserver/model/entity/CTFEventTeleporter.java (working copy)
- @@ -0,0 +1,115 @@
- +/*
- + * This program is free software: you can redistribute it and/or modify it under
- + * the terms of the GNU General Public License as published by the Free Software
- + * Foundation, either version 3 of the License, or (at your option) any later
- + * version.
- + *
- + * This program is distributed in the hope that it will be useful, but WITHOUT
- + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- + * details.
- + *
- + * You should have received a copy of the GNU General Public License along with
- + * this program. If not, see <http://www.gnu.org/licenses/>.
- + */
- +
- +package com.l2jserver.gameserver.model.entity;
- +
- +import com.l2jserver.Config;
- +import com.l2jserver.gameserver.ThreadPoolManager;
- +import com.l2jserver.gameserver.model.actor.L2Summon;
- +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
- +import com.l2jserver.util.Rnd;
- +
- +/**
- + * @author FBIagent, edited U3Games
- + */
- +
- +public class CTFEventTeleporter implements Runnable
- +{
- + /** The instance of the player to teleport */
- + private L2PcInstance _playerInstance = null;
- + /** Coordinates of the spot to teleport to */
- + private int[] _coordinates = new int[3];
- + /** Admin removed this player from event */
- + private boolean _adminRemove = false;
- +
- + /**
- + * Initialize the teleporter and start the delayed task.
- + * @param playerInstance
- + * @param coordinates
- + * @param fastSchedule
- + * @param adminRemove
- + */
- + public CTFEventTeleporter(L2PcInstance playerInstance, int[] coordinates, boolean fastSchedule, boolean adminRemove)
- + {
- + _playerInstance = playerInstance;
- + _coordinates = coordinates;
- + _adminRemove = adminRemove;
- +
- + long delay = (CTFEvent.isStarted() ? Config.CTF_EVENT_RESPAWN_TELEPORT_DELAY : Config.CTF_EVENT_START_LEAVE_TELEPORT_DELAY) * 1000;
- +
- + ThreadPoolManager.getInstance().scheduleGeneral(this, fastSchedule ? 0 : delay);
- + }
- +
- + /**
- + * The task method to teleport the player<br>
- + * 1. Unsummon pet if there is one<br>
- + * 2. Remove all effects<br>
- + * 3. Revive and full heal the player<br>
- + * 4. Teleport the player<br>
- + * 5. Broadcast status and user info<br><br>
- + *
- + * @see java.lang.Runnable#run()
- + */
- + public void run()
- + {
- + if (_playerInstance == null)
- + return;
- +
- + L2Summon summon = _playerInstance.getPet();
- +
- + if (summon != null)
- + summon.unSummon(_playerInstance);
- +
- + if (Config.CTF_EVENT_EFFECTS_REMOVAL == 0
- + || (Config.CTF_EVENT_EFFECTS_REMOVAL == 1 && (_playerInstance.getTeam() == 0 || (_playerInstance.isInDuel() && _playerInstance.getDuelState() != Duel.DUELSTATE_INTERRUPTED))))
- + _playerInstance.stopAllEffectsExceptThoseThatLastThroughDeath();
- +
- + if (_playerInstance.isInDuel())
- + _playerInstance.setDuelState(Duel.DUELSTATE_INTERRUPTED);
- +
- + int CTFInstance = CTFEvent.getCTFEventInstance();
- + if (CTFInstance != 0)
- + {
- + if (CTFEvent.isStarted() && !_adminRemove)
- + {
- + _playerInstance.setInstanceId(CTFInstance);
- + }
- + else
- + {
- + _playerInstance.setInstanceId(0);
- + }
- + }
- + else
- + {
- + _playerInstance.setInstanceId(0);
- + }
- +
- + _playerInstance.doRevive();
- +
- + _playerInstance.teleToLocation( _coordinates[ 0 ] + Rnd.get(101)-50, _coordinates[ 1 ] + Rnd.get(101)-50, _coordinates[ 2 ], false );
- +
- + if (CTFEvent.isStarted() && !_adminRemove)
- + _playerInstance.setTeam(CTFEvent.getParticipantTeamId(_playerInstance.getObjectId()) + 1);
- + else
- + _playerInstance.setTeam(0);
- +
- + _playerInstance.setCurrentCp(_playerInstance.getMaxCp());
- + _playerInstance.setCurrentHp(_playerInstance.getMaxHp());
- + _playerInstance.setCurrentMp(_playerInstance.getMaxMp());
- +
- + _playerInstance.broadcastStatusUpdate();
- + _playerInstance.broadcastUserInfo();
- + }
- +}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement