Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/game/config/AdminCommands.xml b/L2J_Mobius_CT_2.6_HighFive/dist/game/config/AdminCommands.xml
- index f5dcd3b..db67d4b 100644
- --- a/L2J_Mobius_CT_2.6_HighFive/dist/game/config/AdminCommands.xml
- +++ b/L2J_Mobius_CT_2.6_HighFive/dist/game/config/AdminCommands.xml
- @@ -562,6 +562,11 @@
- <admin command="admin_stats" accessLevel="100" />
- <admin command="admin_skill_test" accessLevel="100" />
- + <!-- ADMIN TVT EVENT -->
- + <admin command="admin_tvt_add" accessLevel="100" />
- + <admin command="admin_tvt_remove" accessLevel="100" />
- + <admin command="admin_tvt_advance" accessLevel="100" />
- +
- <!-- ADMIN VITALITY -->
- <admin command="admin_set_vitality" accessLevel="100" />
- <admin command="admin_set_vitality_level" accessLevel="100" />
- diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/game/config/Custom/TeamVersusTeam.ini b/L2J_Mobius_CT_2.6_HighFive/dist/game/config/Custom/TeamVersusTeam.ini
- new file mode 100644
- index 0000000..b72ff18
- --- /dev/null
- +++ b/L2J_Mobius_CT_2.6_HighFive/dist/game/config/Custom/TeamVersusTeam.ini
- @@ -0,0 +1,116 @@
- +# ---------------------------------------------------------------------------
- +# Team vs. Team Event Engine (by HorridoJoho)
- +# ---------------------------------------------------------------------------
- +
- +# <u><b><font color="red">WARNING: this mod require custom NPC table support turned on !</font></b></u>
- +# CustomNpcTable = True in General.properties
- +# ---------------------------------------------------------------------------
- +# Enable/Disable TvTEvent System
- +# Default: False
- +TvTEventEnabled = True
- +
- +# TvT in instance
- +# Default: False
- +TvTEventInInstance = True
- +
- +# Id of the instance template for TvT
- +# Default: 3049 (coliseum.xml)
- +TvTEventInstanceId = 3049
- +
- +# Times TvT will occur (24h format).
- +# Default: 9:00,15:00,21:00,3:00
- +TvTEventInterval = 9:00,16:10,21:00,3:00
- +
- +# Registration timer from start of event (in minutes).
- +# Default: 30
- +TvTEventParticipationTime = 5
- +
- +# Event running time (in minutes).
- +# Default: 20
- +TvTEventRunningTime = 20
- +
- +# TvT Event NPC (create a custom npc of type L2TvTEventNpc).
- +# Default: 70010
- +TvTEventParticipationNpcId = 70010
- +
- +# TvT Event Participation Fee (itemId, number). Fee is not returned.
- +# Example: 57,100000
- +# Default: 0,0
- +TvTEventParticipationFee = 0,0
- +
- +# Location for TvTEvent NPC to spawn in form x,y,z[,heading]
- +# Default: 83425,148585,-3406
- +TvTEventParticipationNpcCoordinates = 83425,148585,-3406
- +
- +# Minimum amount of players allowed in each team.
- +# Default: 1
- +TvTEventMinPlayersInTeams = 1
- +# Maximum amount of players allowed in each team.
- +# Default: 20
- +TvTEventMaxPlayersInTeams = 20
- +
- +# Minimum level of players that may join the event.
- +# Default: 1
- +TvTEventMinPlayerLevel = 1
- +# Maximum level of players that may join the event.
- +# Default: 85
- +TvTEventMaxPlayerLevel = 85
- +
- +# Respawn delay timer (in seconds).
- +# Default: 10
- +TvTEventRespawnTeleportDelay = 10
- +# Exit delay timer (in seconds).
- +# Default: 10
- +TvTEventStartLeaveTeleportDelay = 10
- +
- +# First Team - Name, Start/Death x,y,z location.
- +TvTEventTeam1Name = Team1
- +TvTEventTeam1Coordinates = 148695,46725,-3414
- +
- +# Second Team - Name, Start/Death x,y,z location.
- +TvTEventTeam2Name = Team2
- +TvTEventTeam2Coordinates = 149999,46728,-3414
- +
- +# Reward for winning team.
- +# Example: TvTEventReward = itemId,amount;itemId,amount;itemId,amount
- +TvTEventReward = 57,100000
- +
- +# TvTEvent Rules
- +TvTEventTargetTeamMembersAllowed = True
- +TvTEventScrollsAllowed = False
- +TvTEventPotionsAllowed = False
- +TvTEventSummonByItemAllowed = False
- +
- +# Door ID's to open/close on start/end.
- +# Not supported in instance, use xml template for defining doors.
- +# Example: TvTDoorsToOpen = 1;2;3;4;5;6
- +TvTDoorsToOpen =
- +TvTDoorsToClose =
- +
- +# Should both teams get reward if there's a tie?
- +TvTRewardTeamTie = False
- +
- +# Participant's effects handling on teleport/death.
- +# Effects lasting through death never removed.
- +# 0 - always remove all effects.
- +# 1 - remove all effects only during port to event (noblesse blessing can be used)
- +# 2 - never remove any effect
- +# Default: 0
- +TvTEventEffectsRemoval = 0
- +
- +# Fighter-class participants will be buffed with those buffs each respawn
- +# Format: skill1Id,skill1Level;skill2Id,skill2Level...
- +# Example: 1504,1;1501,1;1502,1;1499,1
- +TvTEventFighterBuffs =
- +
- +# Mage-class participants will be buffed with those buffs each respawn
- +# Format: skill1Id,skill1Level;skill2Id,skill2Level...
- +# Example: 1504,1;1500,1;1501,1;1085,3
- +TvTEventMageBuffs =
- +
- +# Maximum number of allowed participants per IP address (dualbox check)
- +# Default: 0 (no limits)
- +TvTEventMaxParticipantsPerIP = 0
- +
- +# Voiced command (.tvt) working during TVT event to get information about event status
- +TvTAllowVoicedInfoCommand = True
- diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/CursedWeaponEquipped.html b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/CursedWeaponEquipped.html
- new file mode 100644
- index 0000000..77e95f2
- --- /dev/null
- +++ b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/CursedWeaponEquipped.html
- @@ -0,0 +1,8 @@
- +<html>
- + <head>
- + <title>TvT Event</title>
- + </head>
- + <body>
- + Cursed weapon holders are not allowed to participate.
- + </body>
- +</html>
- \ No newline at end of file
- diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/IPRestriction.html b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/IPRestriction.html
- new file mode 100644
- index 0000000..74d580f
- --- /dev/null
- +++ b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/IPRestriction.html
- @@ -0,0 +1,8 @@
- +<html>
- + <head>
- + <title>TvT Event</title>
- + </head>
- + <body>
- + Maximum of %max% participant(s) per IP address is allowed.
- + </body>
- +</html>
- \ No newline at end of file
- diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/Karma.html b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/Karma.html
- new file mode 100644
- index 0000000..4ad6698
- --- /dev/null
- +++ b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/Karma.html
- @@ -0,0 +1,8 @@
- +<html>
- + <head>
- + <title>TvT Event</title>
- + </head>
- + <body>
- + Chaotic players are not allowed to participate.
- + </body>
- +</html>
- \ No newline at end of file
- diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/Level.html b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/Level.html
- new file mode 100644
- index 0000000..5d1e0d7
- --- /dev/null
- +++ b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/Level.html
- @@ -0,0 +1,8 @@
- +<html>
- + <head>
- + <title>TvT Event</title>
- + </head>
- + <body>
- + Only players from level %min% to level %max% are allowed to participate.
- + </body>
- +</html>
- \ No newline at end of file
- diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/Olympiad.html b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/Olympiad.html
- new file mode 100644
- index 0000000..b482928
- --- /dev/null
- +++ b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/Olympiad.html
- @@ -0,0 +1,8 @@
- +<html>
- + <head>
- + <title>TvT Event</title>
- + </head>
- + <body>
- + You can not participate while registered for Olympiad.
- + </body>
- +</html>
- \ No newline at end of file
- diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/Participation.html b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/Participation.html
- new file mode 100644
- index 0000000..65db8d2
- --- /dev/null
- +++ b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/Participation.html
- @@ -0,0 +1,13 @@
- +<html>
- + <head>
- + <title>TvT Event</title>
- + </head>
- + <body>
- + Registration for TvT Event:<br>
- + <center>
- + %playercount% players in.<br>
- + Participation Fee: %fee%<br>
- + <button action="bypass -h Quest TvTManager join" value="Participate" width="200" height="31" back="L2UI_CT1.OlympiadWnd_DF_Apply_Down" fore="L2UI_CT1.OlympiadWnd_DF_Apply">
- + </center>
- + </body>
- +</html>
- \ No newline at end of file
- diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/ParticipationFee.html b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/ParticipationFee.html
- new file mode 100644
- index 0000000..9aea7de
- --- /dev/null
- +++ b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/ParticipationFee.html
- @@ -0,0 +1,8 @@
- +<html>
- + <head>
- + <title>TvT Event</title>
- + </head>
- + <body>
- + You need %fee% for participation.
- + </body>
- +</html>
- \ No newline at end of file
- diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/Registered.html b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/Registered.html
- new file mode 100644
- index 0000000..f6eb819
- --- /dev/null
- +++ b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/Registered.html
- @@ -0,0 +1,8 @@
- +<html>
- + <head>
- + <title>TvT Event</title>
- + </head>
- + <body>
- + You are registered for a TvT Event.
- + </body>
- +</html>
- \ No newline at end of file
- diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/RemoveParticipation.html b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/RemoveParticipation.html
- new file mode 100644
- index 0000000..110efb0
- --- /dev/null
- +++ b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/RemoveParticipation.html
- @@ -0,0 +1,13 @@
- +<html>
- + <head>
- + </head><title>TvT Event</title>
- + </head>
- + <body>
- + Cancel registration for TvT Event:<br>
- + You are already registered for this event. Do you wish to cancel your participation in this Event?<br>
- + <center>
- + Participation fee is not returned!<br>
- + <button action="bypass -h Quest TvTManager remove" msg="1480" value="Cancel" width="200" height="31" back="L2UI_CT1.OlympiadWnd_DF_Back_Down" fore="L2UI_CT1.OlympiadWnd_DF_Back">
- + </center>
- + </body>
- +</html>
- \ No newline at end of file
- diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/Reward.html b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/Reward.html
- new file mode 100644
- index 0000000..be404a4
- --- /dev/null
- +++ b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/Reward.html
- @@ -0,0 +1,9 @@
- +<html>
- + <head>
- + <title>TvT Event</title>
- + </head>
- + <body>
- + <font color="LEVEL">Your team won the event!</font><br>
- + Look in your inventory, there should be your reward.
- + </body>
- +</html>
- \ No newline at end of file
- diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/Status.html b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/Status.html
- new file mode 100644
- index 0000000..9da25b6
- --- /dev/null
- +++ b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/Status.html
- @@ -0,0 +1,12 @@
- +<html>
- + <head>
- + <title>TvT Event</title>
- + </head>
- + <body>
- + Status:<br>
- + <center>
- + %team1name% with %team1playercount% players and %team1points% points.<br>
- + %team2name% with %team2playercount% players and %team2points% points.
- + </center>
- + </body>
- +</html>
- \ No newline at end of file
- diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/TeamsFull.html b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/TeamsFull.html
- new file mode 100644
- index 0000000..3117072
- --- /dev/null
- +++ b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/TeamsFull.html
- @@ -0,0 +1,8 @@
- +<html>
- + <head>
- + <title>TvT Event</title>
- + </head>
- + <body>
- + The event is full! Only %max% players are allowed per team.
- + </body>
- +</html>
- \ No newline at end of file
- diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/TvTManager.java b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/TvTManager.java
- new file mode 100644
- index 0000000..8fa27b4
- --- /dev/null
- +++ b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/TvTManager.java
- @@ -0,0 +1,220 @@
- +/*
- + * This file is part of the L2J Mobius project.
- + *
- + * 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 custom.events.TvT.TvTManager;
- +
- +import org.l2jmobius.Config;
- +import org.l2jmobius.gameserver.handler.IVoicedCommandHandler;
- +import org.l2jmobius.gameserver.handler.VoicedCommandHandler;
- +import org.l2jmobius.gameserver.instancemanager.AntiFeedManager;
- +import org.l2jmobius.gameserver.instancemanager.events.TvTEvent;
- +import org.l2jmobius.gameserver.model.actor.Npc;
- +import org.l2jmobius.gameserver.model.actor.Player;
- +import org.l2jmobius.gameserver.model.olympiad.OlympiadManager;
- +import org.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
- +
- +import ai.AbstractNpcAI;
- +
- +/**
- + * TvT Manager AI.
- + * @author Zoey76
- + */
- +public class TvTManager extends AbstractNpcAI implements IVoicedCommandHandler
- +{
- + private static final int MANAGER_ID = 70010;
- + private static final String[] COMMANDS =
- + {
- + "tvt",
- + "tvtjoin",
- + "tvtleave"
- + };
- +
- + public TvTManager()
- + {
- + addFirstTalkId(MANAGER_ID);
- + addTalkId(MANAGER_ID);
- + addStartNpc(MANAGER_ID);
- +
- + if (Config.TVT_ALLOW_VOICED_COMMAND)
- + {
- + VoicedCommandHandler.getInstance().registerHandler(this);
- + }
- + }
- +
- + @Override
- + public String onAdvEvent(String event, Npc npc, Player player)
- + {
- + if ((player == null) || !TvTEvent.isParticipating())
- + {
- + return super.onAdvEvent(event, npc, player);
- + }
- +
- + String htmltext = null;
- + switch (event)
- + {
- + case "join":
- + {
- + final int playerLevel = player.getLevel();
- + final int team1Count = TvTEvent.getTeamsPlayerCounts()[0];
- + final int team2Count = TvTEvent.getTeamsPlayerCounts()[1];
- + if (player.isCursedWeaponEquipped())
- + {
- + htmltext = getHtm(player, "CursedWeaponEquipped.html");
- + }
- + else if (OlympiadManager.getInstance().isRegistered(player))
- + {
- + htmltext = getHtm(player, "Olympiad.html");
- + }
- + else if (player.getKarma() > 0)
- + {
- + htmltext = getHtm(player, "Karma.html");
- + }
- + else if ((playerLevel < Config.TVT_EVENT_MIN_LEVEL) || (playerLevel > Config.TVT_EVENT_MAX_LEVEL))
- + {
- + htmltext = getHtm(player, "Level.html");
- + htmltext = htmltext.replace("%min%", String.valueOf(Config.TVT_EVENT_MIN_LEVEL));
- + htmltext = htmltext.replace("%max%", String.valueOf(Config.TVT_EVENT_MAX_LEVEL));
- + }
- + else if ((team1Count == Config.TVT_EVENT_MAX_PLAYERS_IN_TEAMS) && (team2Count == Config.TVT_EVENT_MAX_PLAYERS_IN_TEAMS))
- + {
- + htmltext = getHtm(player, "TeamsFull.html");
- + htmltext = htmltext.replace("%max%", String.valueOf(Config.TVT_EVENT_MAX_PLAYERS_IN_TEAMS));
- + }
- + else if ((Config.TVT_EVENT_MAX_PARTICIPANTS_PER_IP > 0) && !AntiFeedManager.getInstance().tryAddPlayer(AntiFeedManager.TVT_ID, player, Config.TVT_EVENT_MAX_PARTICIPANTS_PER_IP))
- + {
- + htmltext = getHtm(player, "IPRestriction.html");
- + htmltext = htmltext.replace("%max%", String.valueOf(AntiFeedManager.getInstance().getLimit(player, Config.TVT_EVENT_MAX_PARTICIPANTS_PER_IP)));
- + }
- + else if (TvTEvent.needParticipationFee() && !TvTEvent.hasParticipationFee(player))
- + {
- + htmltext = getHtm(player, "ParticipationFee.html");
- + htmltext = htmltext.replace("%fee%", TvTEvent.getParticipationFee());
- + }
- + else if (TvTEvent.addParticipant(player))
- + {
- + htmltext = getHtm(player, "Registered.html");
- + }
- + break;
- + }
- + case "remove":
- + {
- + if (TvTEvent.removeParticipant(player.getObjectId()))
- + {
- + if (Config.TVT_EVENT_MAX_PARTICIPANTS_PER_IP > 0)
- + {
- + AntiFeedManager.getInstance().removePlayer(AntiFeedManager.TVT_ID, player);
- + }
- + htmltext = getHtm(player, "Unregistered.html");
- + }
- + else
- + {
- + player.sendMessage("You cannot unregister to this event.");
- + }
- + break;
- + }
- + }
- + return htmltext;
- + }
- +
- + @Override
- + public String onFirstTalk(Npc npc, Player player)
- + {
- + String htmltext = null;
- + if (TvTEvent.isParticipating())
- + {
- + final boolean isParticipant = TvTEvent.isPlayerParticipant(player.getObjectId());
- + final int[] teamsPlayerCounts = TvTEvent.getTeamsPlayerCounts();
- + htmltext = getHtm(player, (!isParticipant ? "Participation.html" : "RemoveParticipation.html"));
- + htmltext = htmltext.replace("%objectId%", String.valueOf(npc.getObjectId()));
- + htmltext = htmltext.replace("%team1name%", Config.TVT_EVENT_TEAM_1_NAME);
- + htmltext = htmltext.replace("%team1playercount%", String.valueOf(teamsPlayerCounts[0]));
- + htmltext = htmltext.replace("%team2name%", Config.TVT_EVENT_TEAM_2_NAME);
- + htmltext = htmltext.replace("%team2playercount%", String.valueOf(teamsPlayerCounts[1]));
- + htmltext = htmltext.replace("%playercount%", String.valueOf(teamsPlayerCounts[0] + teamsPlayerCounts[1]));
- + if (!isParticipant)
- + {
- + htmltext = htmltext.replace("%fee%", TvTEvent.getParticipationFee());
- + }
- + }
- + else if (TvTEvent.isStarting() || TvTEvent.isStarted())
- + {
- + htmltext = getTvTStatus(player);
- + }
- + return htmltext;
- + }
- +
- + @Override
- + public boolean useVoicedCommand(String command, Player player, String params)
- + {
- + String html = null;
- + switch (command)
- + {
- + case "tvt":
- + {
- + if (TvTEvent.isStarting() || TvTEvent.isStarted())
- + {
- + html = getTvTStatus(player);
- + }
- + else
- + {
- + html = "The event has not started.";
- + }
- + break;
- + }
- + case "tvtjoin":
- + {
- + html = onAdvEvent("join", null, player);
- + break;
- + }
- + case "tvtleave":
- + {
- + html = onAdvEvent("remove", null, player);
- + break;
- + }
- + }
- +
- + if (html != null)
- + {
- + player.sendPacket(new NpcHtmlMessage(html));
- + }
- + return true;
- + }
- +
- + private String getTvTStatus(Player player)
- + {
- + final int[] teamsPlayerCounts = TvTEvent.getTeamsPlayerCounts();
- + final int[] teamsPointsCounts = TvTEvent.getTeamsPoints();
- + String htmltext = getHtm(player, "Status.html");
- + htmltext = htmltext.replace("%team1name%", Config.TVT_EVENT_TEAM_1_NAME);
- + htmltext = htmltext.replace("%team1playercount%", String.valueOf(teamsPlayerCounts[0]));
- + htmltext = htmltext.replace("%team1points%", String.valueOf(teamsPointsCounts[0]));
- + htmltext = htmltext.replace("%team2name%", Config.TVT_EVENT_TEAM_2_NAME);
- + htmltext = htmltext.replace("%team2playercount%", String.valueOf(teamsPlayerCounts[1]));
- + htmltext = htmltext.replace("%team2points%", String.valueOf(teamsPointsCounts[1]));
- + return htmltext;
- + }
- +
- + @Override
- + public String[] getVoicedCommandList()
- + {
- + return COMMANDS;
- + }
- +
- + public static void main(String[] args)
- + {
- + new TvTManager();
- + }
- +}
- diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/Unregistered.html b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/Unregistered.html
- new file mode 100644
- index 0000000..0223caf
- --- /dev/null
- +++ b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/Unregistered.html
- @@ -0,0 +1,8 @@
- +<html>
- + <head>
- + <title>TvT Event</title>
- + </head>
- + <body>
- + You have been unregistered from the TvT Event.
- + </body>
- +</html>
- \ No newline at end of file
- diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/MasterHandler.java b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/MasterHandler.java
- index 58c86d8..411c1bc 100644
- --- a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/MasterHandler.java
- +++ b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/MasterHandler.java
- @@ -71,6 +71,7 @@
- import handlers.admincommandhandlers.AdminEffects;
- import handlers.admincommandhandlers.AdminElement;
- import handlers.admincommandhandlers.AdminEnchant;
- +import handlers.admincommandhandlers.AdminEventEngine;
- import handlers.admincommandhandlers.AdminEvents;
- import handlers.admincommandhandlers.AdminExpSp;
- import handlers.admincommandhandlers.AdminFakePlayers;
- @@ -130,6 +131,7 @@
- import handlers.admincommandhandlers.AdminTerritoryWar;
- import handlers.admincommandhandlers.AdminTest;
- import handlers.admincommandhandlers.AdminTransform;
- +import handlers.admincommandhandlers.AdminTvTEvent;
- import handlers.admincommandhandlers.AdminVitality;
- import handlers.admincommandhandlers.AdminZone;
- import handlers.admincommandhandlers.AdminZones;
- /**
- @@ -348,6 +351,7 @@
- AdminElement.class,
- AdminEnchant.class,
- AdminEvents.class,
- + AdminEventEngine.class,
- AdminExpSp.class,
- AdminFakePlayers.class,
- AdminFence.class,
- @@ -406,6 +410,7 @@
- AdminTerritoryWar.class,
- AdminTest.class,
- AdminTransform.class,
- + AdminTvTEvent.class,
- AdminVitality.class,
- AdminZone.class,
- },
- diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/admincommandhandlers/AdminEventEngine.java b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/admincommandhandlers/AdminEventEngine.java
- new file mode 100644
- index 0000000..dde9416
- --- /dev/null
- +++ b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/admincommandhandlers/AdminEventEngine.java
- @@ -0,0 +1,556 @@
- +/*
- + * This file is part of the L2J Mobius project.
- + *
- + * 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 handlers.admincommandhandlers;
- +
- +import java.io.BufferedInputStream;
- +import java.io.BufferedReader;
- +import java.io.DataInputStream;
- +import java.io.File;
- +import java.io.FileInputStream;
- +import java.io.FileOutputStream;
- +import java.io.InputStreamReader;
- +import java.io.PrintStream;
- +import java.util.StringTokenizer;
- +import java.util.logging.Logger;
- +
- +import org.l2jmobius.Config;
- +import org.l2jmobius.commons.util.Rnd;
- +import org.l2jmobius.gameserver.data.xml.AdminData;
- +import org.l2jmobius.gameserver.data.xml.TransformData;
- +import org.l2jmobius.gameserver.handler.IAdminCommandHandler;
- +import org.l2jmobius.gameserver.instancemanager.events.GameEvent;
- +import org.l2jmobius.gameserver.instancemanager.events.GameEvent.EventState;
- +import org.l2jmobius.gameserver.model.World;
- +import org.l2jmobius.gameserver.model.actor.Player;
- +import org.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
- +import org.l2jmobius.gameserver.network.serverpackets.PlaySound;
- +import org.l2jmobius.gameserver.util.Broadcast;
- +
- +/**
- + * This class handles following admin commands: - admin = shows menu
- + * @version $Revision: 1.3.2.1.2.4 $ $Date: 2005/04/11 10:06:06 $
- + */
- +public class AdminEventEngine implements IAdminCommandHandler
- +{
- + private static final Logger LOGGER = Logger.getLogger(AdminEventEngine.class.getName());
- +
- + private static final String[] ADMIN_COMMANDS =
- + {
- + "admin_event",
- + "admin_event_new",
- + "admin_event_choose",
- + "admin_event_store",
- + "admin_event_set",
- + "admin_event_change_teams_number",
- + "admin_event_announce",
- + "admin_event_panel",
- + "admin_event_control_begin",
- + "admin_event_control_teleport",
- + "admin_add",
- + "admin_event_see",
- + "admin_event_del",
- + "admin_delete_buffer",
- + "admin_event_control_sit",
- + "admin_event_name",
- + "admin_event_control_kill",
- + "admin_event_control_res",
- + "admin_event_control_transform",
- + "admin_event_control_untransform",
- + "admin_event_control_prize",
- + "admin_event_control_chatban",
- + "admin_event_control_kick",
- + "admin_event_control_finish"
- + };
- +
- + private static String tempBuffer = "";
- + private static String tempName = "";
- + private static boolean npcsDeleted = false;
- +
- + @Override
- + public boolean useAdminCommand(String command, Player activeChar)
- + {
- + StringTokenizer st = new StringTokenizer(command);
- + final String actualCommand = st.nextToken();
- + try
- + {
- + if (actualCommand.equals("admin_event"))
- + {
- + if (GameEvent.eventState != EventState.OFF)
- + {
- + showEventControl(activeChar);
- + }
- + else
- + {
- + showMainPage(activeChar);
- + }
- + }
- +
- + else if (actualCommand.equals("admin_event_new"))
- + {
- + showNewEventPage(activeChar);
- + }
- + else if (actualCommand.startsWith("admin_add"))
- + {
- + // There is an exception here for not using the ST. We use spaces (ST delim) for the event info.
- + tempBuffer += command.substring(10);
- + showNewEventPage(activeChar);
- +
- + }
- + else if (actualCommand.startsWith("admin_event_see"))
- + {
- + // There is an exception here for not using the ST. We use spaces (ST delim) for the event name.
- + final String eventName = command.substring(16);
- + try
- + {
- + final NpcHtmlMessage adminReply = new NpcHtmlMessage();
- + final DataInputStream in = new DataInputStream(new BufferedInputStream(new FileInputStream(Config.DATAPACK_ROOT + "/data/events/" + eventName)));
- + final BufferedReader inbr = new BufferedReader(new InputStreamReader(in));
- + adminReply.setFile(null, "data/html/mods/EventEngine/Participation.htm");
- + adminReply.replace("%eventName%", eventName);
- + adminReply.replace("%eventCreator%", inbr.readLine());
- + adminReply.replace("%eventInfo%", inbr.readLine());
- + adminReply.replace("npc_%objectId%_event_participate", "admin_event"); // Weird, but nice hack, isnt it? :)
- + adminReply.replace("button value=\"Participate\"", "button value=\"Back\"");
- + activeChar.sendPacket(adminReply);
- + inbr.close();
- + }
- + catch (Exception e)
- + {
- + LOGGER.warning("Problem with AdminEventEngine: " + e.getMessage());
- + }
- + }
- + else if (actualCommand.startsWith("admin_event_del"))
- + {
- + // There is an exception here for not using the ST. We use spaces (ST delim) for the event name.
- + final String eventName = command.substring(16);
- + final File file = new File(Config.DATAPACK_ROOT + "/data/events/" + eventName);
- + file.delete();
- + showMainPage(activeChar);
- + }
- + else if (actualCommand.startsWith("admin_event_name"))
- + {
- + // There is an exception here for not using the ST. We use spaces (ST delim) for the event name.
- + tempName += command.substring(17);
- + showNewEventPage(activeChar);
- + }
- + else if (actualCommand.equalsIgnoreCase("admin_delete_buffer"))
- + {
- + tempBuffer = "";
- + showNewEventPage(activeChar);
- + }
- + else if (actualCommand.startsWith("admin_event_store"))
- + {
- + try
- + {
- + final FileOutputStream file = new FileOutputStream(new File(Config.DATAPACK_ROOT, "data/events/" + tempName));
- + final PrintStream p = new PrintStream(file);
- + p.println(activeChar.getName());
- + p.println(tempBuffer);
- + file.close();
- + p.close();
- + }
- + catch (Exception e)
- + {
- + LOGGER.warning("Problem with AdminEventEngine: " + e.getMessage());
- + }
- +
- + tempBuffer = "";
- + tempName = "";
- + showMainPage(activeChar);
- + }
- + else if (actualCommand.startsWith("admin_event_set"))
- + {
- + // There is an exception here for not using the ST. We use spaces (ST delim) for the event name.
- + GameEvent._eventName = command.substring(16);
- + showEventParameters(activeChar, 2);
- + }
- + else if (actualCommand.startsWith("admin_event_change_teams_number"))
- + {
- + showEventParameters(activeChar, Integer.parseInt(st.nextToken()));
- + }
- + else if (actualCommand.startsWith("admin_event_panel"))
- + {
- + showEventControl(activeChar);
- + }
- + else if (actualCommand.startsWith("admin_event_announce"))
- + {
- + GameEvent._npcId = Integer.parseInt(st.nextToken());
- + GameEvent._teamsNumber = Integer.parseInt(st.nextToken());
- + String temp = " ";
- + String temp2 = "";
- + while (st.hasMoreElements())
- + {
- + temp += st.nextToken() + " ";
- + }
- +
- + st = new StringTokenizer(temp, "-");
- + Integer i = 1;
- +
- + while (st.hasMoreElements())
- + {
- + temp2 = st.nextToken();
- + if (!temp2.equals(" "))
- + {
- + GameEvent._teamNames.put(i++, temp2.substring(1, temp2.length() - 1));
- + }
- + }
- +
- + activeChar.sendMessage(GameEvent.startEventParticipation());
- + Broadcast.toAllOnlinePlayers(activeChar.getName() + " has started an event. You will find a participation NPC somewhere around you.");
- +
- + final PlaySound snd = new PlaySound(1, "B03_F", 0, 0, 0, 0, 0);
- + activeChar.sendPacket(snd);
- + activeChar.broadcastPacket(snd);
- +
- + final NpcHtmlMessage adminReply = new NpcHtmlMessage();
- + final String replyMSG = "<html><title>[ EVENT ENGINE ]</title><body><br><center>The event <font color=\"LEVEL\">" + GameEvent._eventName + "</font> has been announced, now you can type //event_panel to see the event panel control</center><br></body></html>";
- + adminReply.setHtml(replyMSG);
- + activeChar.sendPacket(adminReply);
- + }
- + else if (actualCommand.startsWith("admin_event_control_begin"))
- + {
- + // Starts the event and sends a message of the result
- + activeChar.sendMessage(GameEvent.startEvent());
- + showEventControl(activeChar);
- + }
- + else if (actualCommand.startsWith("admin_event_control_finish"))
- + {
- + // Finishes the event and sends a message of the result
- + activeChar.sendMessage(GameEvent.finishEvent());
- + }
- + else if (actualCommand.startsWith("admin_event_control_teleport"))
- + {
- + while (st.hasMoreElements()) // Every next ST should be a team number
- + {
- + final int teamId = Integer.parseInt(st.nextToken());
- + for (Player player : GameEvent._teams.get(teamId))
- + {
- + player.setTitle(GameEvent._teamNames.get(teamId));
- + player.teleToLocation(activeChar.getLocation(), true);
- + player.setInstanceId(activeChar.getInstanceId());
- + }
- + }
- + showEventControl(activeChar);
- + }
- + else if (actualCommand.startsWith("admin_event_control_sit"))
- + {
- + while (st.hasMoreElements()) // Every next ST should be a team number
- + {
- + // Integer.parseInt(st.nextToken()) == teamId
- + for (Player player : GameEvent._teams.get(Integer.parseInt(st.nextToken())))
- + {
- + if (player.getEventStatus() == null)
- + {
- + continue;
- + }
- +
- + player.getEventStatus().setSitForced(!player.getEventStatus().isSitForced());
- + if (player.getEventStatus().isSitForced())
- + {
- + player.sitDown();
- + }
- + else
- + {
- + player.standUp();
- + }
- + }
- + }
- + showEventControl(activeChar);
- + }
- + else if (actualCommand.startsWith("admin_event_control_kill"))
- + {
- + while (st.hasMoreElements()) // Every next ST should be a team number
- + {
- + for (Player player : GameEvent._teams.get(Integer.parseInt(st.nextToken())))
- + {
- + player.reduceCurrentHp(player.getMaxHp() + player.getMaxCp() + 1, activeChar, null);
- + }
- + }
- + showEventControl(activeChar);
- + }
- + else if (actualCommand.startsWith("admin_event_control_res"))
- + {
- + while (st.hasMoreElements()) // Every next ST should be a team number
- + {
- + for (Player player : GameEvent._teams.get(Integer.parseInt(st.nextToken())))
- + {
- + if ((player == null) || !player.isDead())
- + {
- + continue;
- + }
- + player.restoreExp(100.0);
- + player.doRevive();
- + player.setCurrentHpMp(player.getMaxHp(), player.getMaxMp());
- + player.setCurrentCp(player.getMaxCp());
- + }
- + }
- + showEventControl(activeChar);
- + }
- + else if (actualCommand.startsWith("admin_event_control_transform"))
- + {
- + final int teamId = Integer.parseInt(st.nextToken());
- + final int[] transIds = new int[st.countTokens()];
- + int i = 0;
- + while (st.hasMoreElements()) // Every next ST should be a transform ID
- + {
- + transIds[i++] = Integer.parseInt(st.nextToken());
- + }
- +
- + for (Player player : GameEvent._teams.get(teamId))
- + {
- + final int transId = transIds[Rnd.get(transIds.length)];
- + if (!TransformData.getInstance().transformPlayer(transId, player))
- + {
- + AdminData.getInstance().broadcastMessageToGMs("EventEngine: Unknow transformation id: " + transId);
- + }
- + }
- + showEventControl(activeChar);
- + }
- + else if (actualCommand.startsWith("admin_event_control_untransform"))
- + {
- + while (st.hasMoreElements()) // Every next ST should be a team number
- + {
- + for (Player player : GameEvent._teams.get(Integer.parseInt(st.nextToken())))
- + {
- + player.stopTransformation(true);
- + }
- + }
- + showEventControl(activeChar);
- + }
- + else if (actualCommand.startsWith("admin_event_control_kick"))
- + {
- + if (st.hasMoreElements()) // If has next token, it should be player name.
- + {
- + while (st.hasMoreElements())
- + {
- + final Player player = World.getInstance().getPlayer(st.nextToken());
- + if (player != null)
- + {
- + GameEvent.removeAndResetPlayer(player);
- + }
- + }
- + }
- + else
- + {
- + if ((activeChar.getTarget() != null) && (activeChar.getTarget().isPlayer()))
- + {
- + GameEvent.removeAndResetPlayer((Player) activeChar.getTarget());
- + }
- + }
- + showEventControl(activeChar);
- + }
- + else if (actualCommand.startsWith("admin_event_control_prize"))
- + {
- + final int[] teamIds = new int[st.countTokens() - 2];
- + int i = 0;
- + while ((st.countTokens() - 2) > 0) // The last 2 tokens are used for "n" and "item id"
- + {
- + teamIds[i++] = Integer.parseInt(st.nextToken());
- + }
- +
- + final String[] n = st.nextToken().split("\\*");
- + final int itemId = Integer.parseInt(st.nextToken());
- + for (int teamId : teamIds)
- + {
- + rewardTeam(activeChar, teamId, Integer.parseInt(n[0]), itemId, n.length == 2 ? n[1] : "");
- + }
- + showEventControl(activeChar);
- + }
- + }
- + catch (Exception e)
- + {
- + AdminData.getInstance().broadcastMessageToGMs("EventEngine: Error! Possible blank boxes while executing a command which requires a value in the box?");
- + }
- + return true;
- + }
- +
- + @Override
- + public String[] getAdminCommandList()
- + {
- + return ADMIN_COMMANDS;
- + }
- +
- + private String showStoredEvents()
- + {
- + final File dir = new File(Config.DATAPACK_ROOT, "/data/events");
- + if (dir.isFile())
- + {
- + return "<font color=\"FF0000\">The directory '" + dir.getAbsolutePath() + "' is a file or is corrupted!</font><br>";
- + }
- +
- + String note = "";
- + if (!dir.exists())
- + {
- + note = "<font color=\"FF0000\">The directory '" + dir.getAbsolutePath() + "' does not exist!</font><br><font color=\"0099FF\">Trying to create it now...<br></font><br>";
- + if (dir.mkdirs())
- + {
- + note += "<font color=\"006600\">The directory '" + dir.getAbsolutePath() + "' has been created!</font><br>";
- + }
- + else
- + {
- + note += "<font color=\"FF0000\">The directory '" + dir.getAbsolutePath() + "' hasn't been created!</font><br>";
- + return note;
- + }
- + }
- +
- + final String[] files = dir.list();
- + final StringBuilder result = new StringBuilder(files.length * 500);
- + result.append("<table>");
- + for (String fileName : files)
- + {
- + result.append("<tr><td align=center>");
- + result.append(fileName);
- + result.append(" </td></tr><tr><td><table cellspacing=0><tr><td><button value=\"Select Event\" action=\"bypass -h admin_event_set ");
- + result.append(fileName);
- + result.append("\" width=90 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td><button value=\"View Event\" action=\"bypass -h admin_event_see ");
- + result.append(fileName);
- + result.append("\" width=90 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td><button value=\"Delete Event\" action=\"bypass -h admin_event_del ");
- + result.append(fileName);
- + result.append("\" width=90 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr></table></td></tr><tr><td> </td></tr><tr><td> </td></tr>");
- + }
- +
- + result.append("</table>");
- +
- + return note + result;
- + }
- +
- + public void showMainPage(Player activeChar)
- + {
- + final NpcHtmlMessage adminReply = new NpcHtmlMessage();
- + final String replyMSG = "<html><title>[ L2J EVENT ENGINE ]</title><body><br><center><button value=\"Create NEW event \" action=\"bypass -h admin_event_new\" width=150 height=32 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"><center><br><font color=LEVEL>Stored Events:</font><br></center>" + showStoredEvents() + "</body></html>";
- + adminReply.setHtml(replyMSG);
- + activeChar.sendPacket(adminReply);
- + }
- +
- + public void showNewEventPage(Player activeChar)
- + {
- + final NpcHtmlMessage adminReply = new NpcHtmlMessage();
- + final StringBuilder replyMSG = new StringBuilder(512);
- + replyMSG.append("<html><title>[ L2J EVENT ENGINE ]</title><body><br><br><center><font color=LEVEL>Event name:</font><br>");
- + if (tempName.isEmpty())
- + {
- + replyMSG.append("You can also use //event_name text to insert a new title");
- + replyMSG.append("<center><multiedit var=\"name\" width=260 height=24> <button value=\"Set Event Name\" action=\"bypass -h admin_event_name $name\" width=120 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
- + }
- + else
- + {
- + replyMSG.append(tempName);
- + }
- +
- + replyMSG.append("<br><br><font color=LEVEL>Event description:</font><br></center>");
- + if (tempBuffer.isEmpty())
- + {
- + replyMSG.append("You can also use //add text to add text or //delete_buffer to remove the text.");
- + }
- + else
- + {
- + replyMSG.append(tempBuffer);
- + }
- +
- + replyMSG.append("<center><multiedit var=\"txt\" width=270 height=100> <button value=\"Add text\" action=\"bypass -h admin_add $txt\" width=120 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
- + replyMSG.append("<button value=\"Remove text\" action=\"bypass -h admin_delete_buffer\" width=120 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
- + if (!(tempName.isEmpty() && tempBuffer.isEmpty()))
- + {
- + replyMSG.append("<br><button value=\"Store Event Data\" action=\"bypass -h admin_event_store\" width=160 height=32 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
- + }
- +
- + replyMSG.append("</center></body></html>");
- +
- + adminReply.setHtml(replyMSG.toString());
- + activeChar.sendPacket(adminReply);
- + }
- +
- + public void showEventParameters(Player activeChar, int teamnumbers)
- + {
- + final NpcHtmlMessage adminReply = new NpcHtmlMessage();
- + final StringBuilder sb = new StringBuilder();
- + sb.append("<html><body><title>[ L2J EVENT ENGINE ]</title><br><center> Current event: <font color=\"LEVEL\">");
- + sb.append(GameEvent._eventName);
- + sb.append("</font></center><br>INFO: To start an event, you must first set the number of teams, then type their names in the boxes and finally type the NPC ID that will be the event manager (can be any existing npc) next to the \"Announce Event!\" button.<br><table width=100%>");
- + sb.append("<tr><td><button value=\"Announce Event!\" action=\"bypass -h admin_event_announce $event_npcid ");
- + sb.append(teamnumbers);
- + sb.append(" ");
- + for (int i = 1; (i - 1) < teamnumbers; i++) // Event announce params
- + {
- + sb.append("$event_teams_name");
- + sb.append(i);
- + sb.append(" - ");
- + }
- + sb.append("\" width=140 height=32 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>");
- + sb.append("<td><edit var=\"event_npcid\" width=100 height=20></td></tr>");
- + sb.append("<tr><td><button value=\"Set number of teams\" action=\"bypass -h admin_event_change_teams_number $event_teams_number\" width=140 height=32 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>");
- + sb.append("<td><edit var=\"event_teams_number\" width=100 height=20></td></tr>");
- + sb.append("</table><br><center><br><br>");
- + sb.append("<font color=\"LEVEL\">Teams' names:</font><br><table width=100% cellspacing=8>");
- + for (int i = 1; (i - 1) < teamnumbers; i++) // Team names params
- + {
- + sb.append("<tr><td align=center>Team #");
- + sb.append(i);
- + sb.append(" name:</td><td><edit var=\"event_teams_name");
- + sb.append(i);
- + sb.append("\" width=150 height=15></td></tr>");
- + }
- + sb.append("</table></body></html>");
- +
- + adminReply.setHtml(sb.toString());
- + activeChar.sendPacket(adminReply);
- + }
- +
- + private void showEventControl(Player activeChar)
- + {
- + final NpcHtmlMessage adminReply = new NpcHtmlMessage();
- + final StringBuilder sb = new StringBuilder();
- + sb.append("<html><title>[ EVENT ENGINE ]</title><body><br><center>Current event: <font color=\"LEVEL\">");
- + sb.append(GameEvent._eventName);
- + sb.append("</font></center><br><table cellspacing=-1 width=280><tr><td align=center>Type the team ID(s) that will be affected by the commands. Commands with '*' work with only 1 team ID in the field, while '!' - none.</td></tr><tr><td align=center><edit var=\"team_number\" width=100 height=15></td></tr>");
- + sb.append("<tr><td> </td></tr><tr><td><table width=200>");
- + if (!npcsDeleted)
- + {
- + sb.append("<tr><td><button value=\"Start!\" action=\"bypass -h admin_event_control_begin\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td><font color=\"LEVEL\">Destroys all event npcs so no more people can't participate now on</font></td></tr>");
- + }
- +
- + sb.append("<tr><td> </td></tr><tr><td><button value=\"Teleport\" action=\"bypass -h admin_event_control_teleport $team_number\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td><font color=\"LEVEL\">Teleports the specified team to your position</font></td></tr><tr><td> </td></tr><tr><td><button value=\"Sit/Stand\" action=\"bypass -h admin_event_control_sit $team_number\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td><font color=\"LEVEL\">Sits/Stands up the team</font></td></tr><tr><td> </td></tr><tr><td><button value=\"Kill\" action=\"bypass -h admin_event_control_kill $team_number\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td><font color=\"LEVEL\">Finish with the life of all the players in the selected team</font></td></tr><tr><td> </td></tr><tr><td><button value=\"Resurrect\" action=\"bypass -h admin_event_control_res $team_number\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td><font color=\"LEVEL\">Resurrect Team's members</font></td></tr><tr><td> </td></tr><tr><td><table cellspacing=-1><tr><td><button value=\"Transform*\" action=\"bypass -h admin_event_control_transform $team_number $transf_id\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr><tr><td><edit var=\"transf_id\" width=98 height=15></td></tr></table></td><td><font color=\"LEVEL\">Transforms the team into the transformation with the ID specified. Multiple IDs result in randomly chosen one for each player.</font></td></tr><tr><td> </td></tr><tr><td><button value=\"UnTransform\" action=\"bypass -h admin_event_control_untransform $team_number\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td><font color=\"LEVEL\">Untransforms the team</font></td></tr><tr><td> </td></tr><tr><td><table cellspacing=-1><tr><td><button value=\"Give Item\" action=\"bypass -h admin_event_control_prize $team_number $n $id\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr></table><table><tr><td width=32>Num</td><td><edit var=\"n\" width=60 height=15></td></tr><tr><td>ID</td><td><edit var=\"id\" width=60 height=15></td></tr></table></td><td><font color=\"LEVEL\">Give the specified item id to every single member of the team, you can put 5*level, 5*kills or 5 in the number field for example</font></td></tr><tr><td> </td></tr><tr><td><table cellspacing=-1><tr><td><button value=\"Kick Player\" action=\"bypass -h admin_event_control_kick $player_name\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr><tr><td><edit var=\"player_name\" width=98 height=15></td></tr></table></td><td><font color=\"LEVEL\">Kicks the specified player(s) from the event. Blank field kicks target.</font></td></tr><tr><td> </td></tr><tr><td><button value=\"End!\" action=\"bypass -h admin_event_control_finish\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td><font color=\"LEVEL\">Will finish the event teleporting back all the players</font></td></tr><tr><td> </td></tr></table></td></tr></table></body></html>");
- + adminReply.setHtml(sb.toString());
- + activeChar.sendPacket(adminReply);
- + }
- +
- + private void rewardTeam(Player activeChar, int team, int n, int id, String type)
- + {
- + int num = n;
- + for (Player player : GameEvent._teams.get(team))
- + {
- + if (type.equalsIgnoreCase("level"))
- + {
- + num = n * player.getLevel();
- + }
- + else if (type.equalsIgnoreCase("kills") && (player.getEventStatus() != null))
- + {
- + num = n * player.getEventStatus().getKills().size();
- + }
- + else
- + {
- + num = n;
- + }
- +
- + player.addItem("Event", id, num, activeChar, true);
- +
- + final NpcHtmlMessage adminReply = new NpcHtmlMessage();
- + adminReply.setHtml("<html><body>CONGRATULATIONS! You should have been rewarded.</body></html>");
- + player.sendPacket(adminReply);
- + }
- + }
- +}
- diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/admincommandhandlers/AdminTvTEvent.java b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/admincommandhandlers/AdminTvTEvent.java
- new file mode 100644
- index 0000000..8c1c73f
- --- /dev/null
- +++ b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/admincommandhandlers/AdminTvTEvent.java
- @@ -0,0 +1,109 @@
- +/*
- + * This file is part of the L2J Mobius project.
- + *
- + * 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 handlers.admincommandhandlers;
- +
- +import org.l2jmobius.Config;
- +import org.l2jmobius.gameserver.handler.IAdminCommandHandler;
- +import org.l2jmobius.gameserver.instancemanager.events.TvTEvent;
- +import org.l2jmobius.gameserver.instancemanager.events.TvTEventTeleporter;
- +import org.l2jmobius.gameserver.instancemanager.events.TvTManager;
- +import org.l2jmobius.gameserver.model.WorldObject;
- +import org.l2jmobius.gameserver.model.actor.Player;
- +import org.l2jmobius.gameserver.util.BuilderUtil;
- +
- +/**
- + * @author HorridoJoho
- + */
- +public class AdminTvTEvent implements IAdminCommandHandler
- +{
- + private static final String[] ADMIN_COMMANDS =
- + {
- + "admin_tvt_add",
- + "admin_tvt_remove",
- + "admin_tvt_advance"
- + };
- +
- + @Override
- + public boolean useAdminCommand(String command, Player activeChar)
- + {
- + if (command.equals("admin_tvt_add"))
- + {
- + final WorldObject target = activeChar.getTarget();
- + if ((target == null) || !target.isPlayer())
- + {
- + BuilderUtil.sendSysMessage(activeChar, "You should select a player!");
- + return true;
- + }
- +
- + add(activeChar, (Player) target);
- + }
- + else if (command.equals("admin_tvt_remove"))
- + {
- + final WorldObject target = activeChar.getTarget();
- + if ((target == null) || !target.isPlayer())
- + {
- + BuilderUtil.sendSysMessage(activeChar, "You should select a player!");
- + return true;
- + }
- +
- + remove(activeChar, (Player) target);
- + }
- + else if (command.equals("admin_tvt_advance"))
- + {
- + TvTManager.getInstance().skipDelay();
- + }
- +
- + return true;
- + }
- +
- + @Override
- + public String[] getAdminCommandList()
- + {
- + return ADMIN_COMMANDS;
- + }
- +
- + private void add(Player activeChar, Player Player)
- + {
- + if (Player.isOnEvent())
- + {
- + BuilderUtil.sendSysMessage(activeChar, "Player already participated in the event!");
- + return;
- + }
- +
- + if (!TvTEvent.addParticipant(Player))
- + {
- + BuilderUtil.sendSysMessage(activeChar, "Player instance could not be added, it seems to be null!");
- + return;
- + }
- +
- + if (TvTEvent.isStarted())
- + {
- + new TvTEventTeleporter(Player, TvTEvent.getParticipantTeamCoordinates(Player.getObjectId()), true, false);
- + }
- + }
- +
- + private void remove(Player activeChar, Player Player)
- + {
- + if (!TvTEvent.removeParticipant(Player.getObjectId()))
- + {
- + BuilderUtil.sendSysMessage(activeChar, "Player is not part of the event!");
- + return;
- + }
- +
- + new TvTEventTeleporter(Player, Config.TVT_EVENT_PARTICIPATION_NPC_COORDINATES, true, true);
- + }
- +}
- \ No newline at end of file
- diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/Config.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/Config.java
- index f984695..516c492 100644
- --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/Config.java
- +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/Config.java
- @@ -147,6 +147,9 @@
- private static final String CUSTOM_WAREHOUSE_SORTING_CONFIG_FILE = "./config/Custom/WarehouseSorting.ini";
- private static final String CUSTOM_WEDDING_CONFIG_FILE = "./config/Custom/Wedding.ini";
- private static final String CUSTOM_WALKER_BOT_PROTECTION_CONFIG_FILE = "./config/Custom/WalkerBotProtection.ini";
- private static final String CUSTOM_SUB_STUCK_CONFIG_FILE = "./config/Custom/SubStuck.ini";
- + private static final String VOTE_SYSTEM_FILE = "./config/Custom/votesystemm.ini";
- // --------------------------------------------------
- // Variable Definitions
- @@ -1351,6 +1395,46 @@
- public static long SELLBUFF_MAX_PRICE;
- public static int SELLBUFF_MAX_BUFFS;
- /** SUBSTUCK MOD **/
- public static boolean ACUMULATIVE_SUBCLASS_SKILLS;
- public static boolean ACUMULATIVE_SUBCLASS_PASIVE;
- public static boolean ACUMULATIVE_SUBCLASS_DONT_SKILLS;
- public static String[] ACUMULATIVE_SUBCLASS_DONT_SKILLS_ID;
- +
- + /** TVT MOD **/
- + public static boolean TVT_EVENT_ENABLED;
- + public static boolean TVT_EVENT_IN_INSTANCE;
- + public static int TVT_EVENT_INSTANCE_ID;
- + public static String[] TVT_EVENT_INTERVAL;
- + public static int TVT_EVENT_PARTICIPATION_TIME;
- + public static int TVT_EVENT_RUNNING_TIME;
- + public static int TVT_EVENT_PARTICIPATION_NPC_ID;
- + public static int[] TVT_EVENT_PARTICIPATION_NPC_COORDINATES = new int[4];
- + public static int[] TVT_EVENT_PARTICIPATION_FEE = new int[2];
- + public static int TVT_EVENT_MIN_PLAYERS_IN_TEAMS;
- + public static int TVT_EVENT_MAX_PLAYERS_IN_TEAMS;
- + public static int TVT_EVENT_RESPAWN_TELEPORT_DELAY;
- + public static int TVT_EVENT_START_LEAVE_TELEPORT_DELAY;
- + public static String TVT_EVENT_TEAM_1_NAME;
- + public static int[] TVT_EVENT_TEAM_1_COORDINATES = new int[3];
- + public static String TVT_EVENT_TEAM_2_NAME;
- + public static int[] TVT_EVENT_TEAM_2_COORDINATES = new int[3];
- + public static List<int[]> TVT_EVENT_REWARDS;
- + public static boolean TVT_EVENT_TARGET_TEAM_MEMBERS_ALLOWED;
- + public static boolean TVT_EVENT_SCROLL_ALLOWED;
- + public static boolean TVT_EVENT_POTIONS_ALLOWED;
- + public static boolean TVT_EVENT_SUMMON_BY_ITEM_ALLOWED;
- + public static List<Integer> TVT_DOORS_IDS_TO_OPEN;
- + public static List<Integer> TVT_DOORS_IDS_TO_CLOSE;
- + public static boolean TVT_REWARD_TEAM_TIE;
- + public static byte TVT_EVENT_MIN_LEVEL;
- + public static byte TVT_EVENT_MAX_LEVEL;
- + public static int TVT_EVENT_EFFECTS_REMOVAL;
- + public static Map<Integer, Integer> TVT_EVENT_FIGHTER_BUFFS;
- + public static Map<Integer, Integer> TVT_EVENT_MAGE_BUFFS;
- + public static int TVT_EVENT_MAX_PARTICIPANTS_PER_IP;
- + public static boolean TVT_ALLOW_VOICED_COMMAND;
- +
- public static boolean ENABLE_GUI;
- public static boolean DARK_THEME;
- @@ -3125,6 +3252,217 @@
- SELLBUFF_MAX_PRICE = sellBuffConfig.getLong("MaximumPrice", 100000000);
- SELLBUFF_MAX_BUFFS = sellBuffConfig.getInt("MaxBuffs", 15);
- // Load substuck config file (if exists)
- final PropertiesParser substuckConfig = new PropertiesParser(CUSTOM_SUB_STUCK_CONFIG_FILE);
- ACUMULATIVE_SUBCLASS_SKILLS = substuckConfig.getBoolean("AcumulativeSkills", false);
- ACUMULATIVE_SUBCLASS_PASIVE = substuckConfig.getBoolean("AcumulativeSkillsPasive", false);
- ACUMULATIVE_SUBCLASS_DONT_SKILLS = substuckConfig.getBoolean("DontAcumulativeSkills", true);
- ACUMULATIVE_SUBCLASS_DONT_SKILLS_ID = substuckConfig.getString("DontAcumulativeSkillsId", "351").split(";");
- +
- + // Load TeamVersusTeam config file (if exists)
- + final PropertiesParser TeamVersusTeam = new PropertiesParser(CUSTOM_TVT_CONFIG_FILE);
- + TVT_EVENT_ENABLED = TeamVersusTeam.getBoolean("TvTEventEnabled", false);
- + TVT_EVENT_IN_INSTANCE = TeamVersusTeam.getBoolean("TvTEventInInstance", false);
- + TVT_EVENT_INSTANCE_ID = TeamVersusTeam.getInt("TvTEventInstanceId", 3049);
- + TVT_EVENT_INTERVAL = TeamVersusTeam.getString("TvTEventInterval", "20:00").split(",");
- + TVT_EVENT_PARTICIPATION_TIME = TeamVersusTeam.getInt("TvTEventParticipationTime", 3600);
- + TVT_EVENT_RUNNING_TIME = TeamVersusTeam.getInt("TvTEventRunningTime", 1800);
- + TVT_EVENT_PARTICIPATION_NPC_ID = TeamVersusTeam.getInt("TvTEventParticipationNpcId", 0);
- + if (TVT_EVENT_PARTICIPATION_NPC_ID == 0)
- + {
- + TVT_EVENT_ENABLED = false;
- + LOGGER.warning("TvTEventEngine[Config.load()]: invalid config property -> TvTEventParticipationNpcId");
- + }
- + else
- + {
- + String[] tvtNpcCoords = TeamVersusTeam.getString("TvTEventParticipationNpcCoordinates", "0,0,0").split(",");
- + if (tvtNpcCoords.length < 3)
- + {
- + TVT_EVENT_ENABLED = false;
- + LOGGER.warning("TvTEventEngine[Config.load()]: invalid config property -> TvTEventParticipationNpcCoordinates");
- + }
- + else
- + {
- + TVT_EVENT_REWARDS = new ArrayList<>();
- + TVT_DOORS_IDS_TO_OPEN = new ArrayList<>();
- + TVT_DOORS_IDS_TO_CLOSE = new ArrayList<>();
- + TVT_EVENT_PARTICIPATION_NPC_COORDINATES = new int[4];
- + TVT_EVENT_TEAM_1_COORDINATES = new int[3];
- + TVT_EVENT_TEAM_2_COORDINATES = new int[3];
- + TVT_EVENT_PARTICIPATION_NPC_COORDINATES[0] = Integer.parseInt(tvtNpcCoords[0]);
- + TVT_EVENT_PARTICIPATION_NPC_COORDINATES[1] = Integer.parseInt(tvtNpcCoords[1]);
- + TVT_EVENT_PARTICIPATION_NPC_COORDINATES[2] = Integer.parseInt(tvtNpcCoords[2]);
- + if (tvtNpcCoords.length == 4)
- + {
- + TVT_EVENT_PARTICIPATION_NPC_COORDINATES[3] = Integer.parseInt(tvtNpcCoords[3]);
- + }
- + TVT_EVENT_MIN_PLAYERS_IN_TEAMS = TeamVersusTeam.getInt("TvTEventMinPlayersInTeams", 1);
- + TVT_EVENT_MAX_PLAYERS_IN_TEAMS = TeamVersusTeam.getInt("TvTEventMaxPlayersInTeams", 20);
- + TVT_EVENT_MIN_LEVEL = TeamVersusTeam.getByte("TvTEventMinPlayerLevel", (byte) 1);
- + TVT_EVENT_MAX_LEVEL = TeamVersusTeam.getByte("TvTEventMaxPlayerLevel", (byte) 80);
- + TVT_EVENT_RESPAWN_TELEPORT_DELAY = TeamVersusTeam.getInt("TvTEventRespawnTeleportDelay", 20);
- + TVT_EVENT_START_LEAVE_TELEPORT_DELAY = TeamVersusTeam.getInt("TvTEventStartLeaveTeleportDelay", 20);
- + TVT_EVENT_EFFECTS_REMOVAL = TeamVersusTeam.getInt("TvTEventEffectsRemoval", 0);
- + TVT_EVENT_MAX_PARTICIPANTS_PER_IP = TeamVersusTeam.getInt("TvTEventMaxParticipantsPerIP", 0);
- + TVT_ALLOW_VOICED_COMMAND = TeamVersusTeam.getBoolean("TvTAllowVoicedInfoCommand", false);
- + TVT_EVENT_TEAM_1_NAME = TeamVersusTeam.getString("TvTEventTeam1Name", "Team1");
- + tvtNpcCoords = TeamVersusTeam.getString("TvTEventTeam1Coordinates", "0,0,0").split(",");
- + if (tvtNpcCoords.length < 3)
- + {
- + TVT_EVENT_ENABLED = false;
- + LOGGER.warning("TvTEventEngine[Config.load()]: invalid config property -> TvTEventTeam1Coordinates");
- + }
- + else
- + {
- + TVT_EVENT_TEAM_1_COORDINATES[0] = Integer.parseInt(tvtNpcCoords[0]);
- + TVT_EVENT_TEAM_1_COORDINATES[1] = Integer.parseInt(tvtNpcCoords[1]);
- + TVT_EVENT_TEAM_1_COORDINATES[2] = Integer.parseInt(tvtNpcCoords[2]);
- + TVT_EVENT_TEAM_2_NAME = TeamVersusTeam.getString("TvTEventTeam2Name", "Team2");
- + tvtNpcCoords = TeamVersusTeam.getString("TvTEventTeam2Coordinates", "0,0,0").split(",");
- + if (tvtNpcCoords.length < 3)
- + {
- + TVT_EVENT_ENABLED = false;
- + LOGGER.warning("TvTEventEngine[Config.load()]: invalid config property -> TvTEventTeam2Coordinates");
- + }
- + else
- + {
- + TVT_EVENT_TEAM_2_COORDINATES[0] = Integer.parseInt(tvtNpcCoords[0]);
- + TVT_EVENT_TEAM_2_COORDINATES[1] = Integer.parseInt(tvtNpcCoords[1]);
- + TVT_EVENT_TEAM_2_COORDINATES[2] = Integer.parseInt(tvtNpcCoords[2]);
- + tvtNpcCoords = TeamVersusTeam.getString("TvTEventParticipationFee", "0,0").split(",");
- + try
- + {
- + TVT_EVENT_PARTICIPATION_FEE[0] = Integer.parseInt(tvtNpcCoords[0]);
- + TVT_EVENT_PARTICIPATION_FEE[1] = Integer.parseInt(tvtNpcCoords[1]);
- + }
- + catch (NumberFormatException nfe)
- + {
- + if (tvtNpcCoords.length > 0)
- + {
- + LOGGER.warning("TvTEventEngine[Config.load()]: invalid config property -> TvTEventParticipationFee");
- + }
- + }
- + tvtNpcCoords = TeamVersusTeam.getString("TvTEventReward", "57,100000").split(";");
- + for (String reward : tvtNpcCoords)
- + {
- + final String[] rewardSplit = reward.split(",");
- + if (rewardSplit.length != 2)
- + {
- + LOGGER.warning("TvTEventEngine[Config.load()]: invalid config property -> TvTEventReward \"" + reward + "\"");
- + }
- + else
- + {
- + try
- + {
- + TVT_EVENT_REWARDS.add(new int[]
- + {
- + Integer.parseInt(rewardSplit[0]),
- + Integer.parseInt(rewardSplit[1])
- + });
- + }
- + catch (NumberFormatException nfe)
- + {
- + if (!reward.isEmpty())
- + {
- + LOGGER.warning("TvTEventEngine[Config.load()]: invalid config property -> TvTEventReward \"" + reward + "\"");
- + }
- + }
- + }
- + }
- + TVT_EVENT_TARGET_TEAM_MEMBERS_ALLOWED = TeamVersusTeam.getBoolean("TvTEventTargetTeamMembersAllowed", true);
- + TVT_EVENT_SCROLL_ALLOWED = TeamVersusTeam.getBoolean("TvTEventScrollsAllowed", false);
- + TVT_EVENT_POTIONS_ALLOWED = TeamVersusTeam.getBoolean("TvTEventPotionsAllowed", false);
- + TVT_EVENT_SUMMON_BY_ITEM_ALLOWED = TeamVersusTeam.getBoolean("TvTEventSummonByItemAllowed", false);
- + TVT_REWARD_TEAM_TIE = TeamVersusTeam.getBoolean("TvTRewardTeamTie", false);
- + tvtNpcCoords = TeamVersusTeam.getString("TvTDoorsToOpen", "").split(";");
- + for (String door : tvtNpcCoords)
- + {
- + try
- + {
- + TVT_DOORS_IDS_TO_OPEN.add(Integer.parseInt(door));
- + }
- + catch (NumberFormatException nfe)
- + {
- + if (!door.isEmpty())
- + {
- + LOGGER.warning("TvTEventEngine[Config.load()]: invalid config property -> TvTDoorsToOpen \"" + door + "\"");
- + }
- + }
- + }
- + tvtNpcCoords = TeamVersusTeam.getString("TvTDoorsToClose", "").split(";");
- + for (String door : tvtNpcCoords)
- + {
- + try
- + {
- + TVT_DOORS_IDS_TO_CLOSE.add(Integer.parseInt(door));
- + }
- + catch (NumberFormatException nfe)
- + {
- + if (!door.isEmpty())
- + {
- + LOGGER.warning("TvTEventEngine[Config.load()]: invalid config property -> TvTDoorsToClose \"" + door + "\"");
- + }
- + }
- + }
- + tvtNpcCoords = TeamVersusTeam.getString("TvTEventFighterBuffs", "").split(";");
- + if (!tvtNpcCoords[0].isEmpty())
- + {
- + TVT_EVENT_FIGHTER_BUFFS = new HashMap<>(tvtNpcCoords.length);
- + for (String skill : tvtNpcCoords)
- + {
- + final String[] skillSplit = skill.split(",");
- + if (skillSplit.length != 2)
- + {
- + LOGGER.warning("TvTEventEngine[Config.load()]: invalid config property -> TvTEventFighterBuffs \"" + skill + "\"");
- + }
- + else
- + {
- + try
- + {
- + TVT_EVENT_FIGHTER_BUFFS.put(Integer.parseInt(skillSplit[0]), Integer.parseInt(skillSplit[1]));
- + }
- + catch (NumberFormatException nfe)
- + {
- + if (!skill.isEmpty())
- + {
- + LOGGER.warning("TvTEventEngine[Config.load()]: invalid config property -> TvTEventFighterBuffs \"" + skill + "\"");
- + }
- + }
- + }
- + }
- + }
- + tvtNpcCoords = TeamVersusTeam.getString("TvTEventMageBuffs", "").split(";");
- + if (!tvtNpcCoords[0].isEmpty())
- + {
- + TVT_EVENT_MAGE_BUFFS = new HashMap<>(tvtNpcCoords.length);
- + for (String skill : tvtNpcCoords)
- + {
- + final String[] skillSplit = skill.split(",");
- + if (skillSplit.length != 2)
- + {
- + LOGGER.warning("TvTEventEngine[Config.load()]: invalid config property -> TvTEventMageBuffs \"" + skill + "\"");
- + }
- + else
- + {
- + try
- + {
- + TVT_EVENT_MAGE_BUFFS.put(Integer.parseInt(skillSplit[0]), Integer.parseInt(skillSplit[1]));
- + }
- + catch (NumberFormatException nfe)
- + {
- + if (!skill.isEmpty())
- + {
- + LOGGER.warning("TvTEventEngine[Config.load()]: invalid config property -> TvTEventMageBuffs \"" + skill + "\"");
- + }
- + }
- + }
- + }
- + }
- + }
- + }
- + }
- + }
- +
- // Load ServerTime config file (if exists)
- final PropertiesParser serverTimeConfig = new PropertiesParser(CUSTOM_SERVER_TIME_CONFIG_FILE);
- DISPLAY_SERVER_TIME = serverTimeConfig.getBoolean("DisplayServerTime", false);
- @@ -3161,6 +3499,7 @@
- // Load WalkerBotProtection config file (if exists)
- final PropertiesParser walkerBotProtectionConfig = new PropertiesParser(CUSTOM_WALKER_BOT_PROTECTION_CONFIG_FILE);
- L2WALKER_PROTECTION = walkerBotProtectionConfig.getBoolean("L2WalkerProtection", false);
- +
- }
- else if (SERVER_MODE == ServerMode.LOGIN)
- {
- diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/GameServer.java
- index 192c862..636ef8a 100644
- --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/GameServer.java
- +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/GameServer.java
- @@ -137,6 +137,7 @@
- import org.l2jmobius.gameserver.instancemanager.TerritoryWarManager;
- import org.l2jmobius.gameserver.instancemanager.WalkingManager;
- import org.l2jmobius.gameserver.instancemanager.ZoneManager;
- +import org.l2jmobius.gameserver.instancemanager.events.TvTManager;
- import org.l2jmobius.gameserver.instancemanager.games.Lottery;
- import org.l2jmobius.gameserver.instancemanager.games.MonsterRace;
- import org.l2jmobius.gameserver.model.AutoSpawnHandler;
- public class GameServer
- {
- @@ -430,6 +440,8 @@
- LOGGER.info("IdManager: Free ObjectID's remaining: " + IdManager.getInstance().size());
- + TvTManager.getInstance();
- +
- if ((Config.OFFLINE_TRADE_ENABLE || Config.OFFLINE_CRAFT_ENABLE) && Config.RESTORE_OFFLINERS)
- {
- OfflineTraderTable.getInstance().restoreOfflineTraders();
- diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/instancemanager/events/EventTask.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/instancemanager/events/EventTask.java
- new file mode 100644
- index 0000000..ec9409c
- --- /dev/null
- +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/instancemanager/events/EventTask.java
- @@ -0,0 +1,27 @@
- +/*
- + * This file is part of the L2J Mobius project.
- + *
- + * 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 org.l2jmobius.gameserver.instancemanager.events;
- +
- +/**
- + * @author Shyla
- + */
- +public interface EventTask extends Runnable
- +{
- + String getEventIdentifier();
- +
- + String getEventStartTime(); // hh:mm (es. 01:05)
- +}
- diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/instancemanager/events/GameEvent.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/instancemanager/events/GameEvent.java
- new file mode 100644
- index 0000000..35c9498
- --- /dev/null
- +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/instancemanager/events/GameEvent.java
- @@ -0,0 +1,544 @@
- +/*
- + * This file is part of the L2J Mobius project.
- + *
- + * 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 org.l2jmobius.gameserver.instancemanager.events;
- +
- +import java.io.BufferedReader;
- +import java.io.FileReader;
- +import java.util.ArrayList;
- +import java.util.Collection;
- +import java.util.Comparator;
- +import java.util.HashMap;
- +import java.util.LinkedHashMap;
- +import java.util.LinkedList;
- +import java.util.List;
- +import java.util.Map;
- +import java.util.Map.Entry;
- +import java.util.concurrent.ConcurrentHashMap;
- +import java.util.concurrent.CopyOnWriteArrayList;
- +import java.util.logging.Level;
- +import java.util.logging.Logger;
- +
- +import org.l2jmobius.Config;
- +import org.l2jmobius.gameserver.cache.HtmCache;
- +import org.l2jmobius.gameserver.data.SpawnTable;
- +import org.l2jmobius.gameserver.data.xml.NpcData;
- +import org.l2jmobius.gameserver.instancemanager.AntiFeedManager;
- +import org.l2jmobius.gameserver.model.Spawn;
- +import org.l2jmobius.gameserver.model.World;
- +import org.l2jmobius.gameserver.model.actor.Npc;
- +import org.l2jmobius.gameserver.model.actor.Player;
- +import org.l2jmobius.gameserver.model.holders.PlayerEventHolder;
- +import org.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
- +import org.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
- +
- +/**
- + * @author Nik
- + * @Since 2011/05/17 21:51:39
- + */
- +public class GameEvent
- +{
- + protected static final Logger LOGGER = Logger.getLogger(GameEvent.class.getName());
- + public static EventState eventState = EventState.OFF;
- + public static String _eventName = "";
- + public static String _eventCreator = "";
- + public static String _eventInfo = "";
- + public static int _teamsNumber = 0;
- + public static final Map<Integer, String> _teamNames = new ConcurrentHashMap<>();
- + public static final Collection<Player> _registeredPlayers = ConcurrentHashMap.newKeySet();
- + public static final Map<Integer, List<Player>> _teams = new ConcurrentHashMap<>();
- + public static int _npcId = 0;
- + private static final Map<Player, PlayerEventHolder> _connectionLossData = new ConcurrentHashMap<>();
- +
- + public enum EventState
- + {
- + OFF, // Not running
- + STANDBY, // Waiting for participants to register
- + ON // Registration is over and the event has started.
- + }
- +
- + /**
- + * @param player
- + * @return The team ID where the player is in, or -1 if player is null or team not found.
- + */
- + public static int getPlayerTeamId(Player player)
- + {
- + if (player == null)
- + {
- + return -1;
- + }
- +
- + for (Entry<Integer, List<Player>> team : _teams.entrySet())
- + {
- + if (team.getValue().contains(player))
- + {
- + return team.getKey();
- + }
- + }
- +
- + return -1;
- + }
- +
- + public static List<Player> getTopNKillers(int n)
- + {
- + final Map<Player, Integer> tmp = new HashMap<>();
- + for (List<Player> teamList : _teams.values())
- + {
- + for (Player player : teamList)
- + {
- + if (player.getEventStatus() == null)
- + {
- + continue;
- + }
- + tmp.put(player, player.getEventStatus().getKills().size());
- + }
- + }
- +
- + sortByValue(tmp);
- + return tmp.size() <= n ? new ArrayList<>(tmp.keySet()) : (new ArrayList<>(tmp.keySet())).subList(1, n);
- + }
- +
- + public static void showEventHtml(Player player, String objectid)
- + {
- + // TODO: work on this
- + if (eventState == EventState.STANDBY)
- + {
- + try
- + {
- + final String htmContent;
- + final NpcHtmlMessage html = new NpcHtmlMessage(Integer.parseInt(objectid));
- + if (_registeredPlayers.contains(player))
- + {
- + htmContent = HtmCache.getInstance().getHtm(player, "data/html/mods/EventEngine/Participating.htm");
- + }
- + else
- + {
- + htmContent = HtmCache.getInstance().getHtm(player, "data/html/mods/EventEngine/Participation.htm");
- + }
- +
- + if (htmContent != null)
- + {
- + html.setHtml(htmContent);
- + }
- +
- + html.replace("%objectId%", objectid); // Yeah, we need this.
- + html.replace("%eventName%", _eventName);
- + html.replace("%eventCreator%", _eventCreator);
- + html.replace("%eventInfo%", _eventInfo);
- + player.sendPacket(html);
- + }
- + catch (Exception e)
- + {
- + LOGGER.log(Level.WARNING, "Exception on showEventHtml(): " + e.getMessage(), e);
- + }
- + }
- + }
- +
- + /**
- + * Spawns an event participation NPC near the player. The npc id used to spawning is GameEvent._npcId
- + * @param target
- + */
- + public static void spawnEventNpc(Player target)
- + {
- + try
- + {
- + final Spawn spawn = new Spawn(_npcId);
- + spawn.setXYZ(target.getX() + 50, target.getY() + 50, target.getZ());
- + spawn.setAmount(1);
- + spawn.setHeading(target.getHeading());
- + spawn.stopRespawn();
- + SpawnTable.getInstance().addNewSpawn(spawn, false);
- + spawn.init();
- + spawn.getLastSpawn().setCurrentHp(999999999);
- + spawn.getLastSpawn().setTitle(_eventName);
- + spawn.getLastSpawn().setEventMob(true);
- + // spawn.getLastSpawn().decayMe();
- + // spawn.getLastSpawn().spawnMe(spawn.getLastSpawn().getX(), spawn.getLastSpawn().getY(), spawn.getLastSpawn().getZ());
- + spawn.getLastSpawn().broadcastPacket(new MagicSkillUse(spawn.getLastSpawn(), spawn.getLastSpawn(), 1034, 1, 1, 1));
- +
- + // _npcs.add(spawn.getLastSpawn());
- + }
- + catch (Exception e)
- + {
- + LOGGER.log(Level.WARNING, "Exception on spawn(): " + e.getMessage(), e);
- + }
- + }
- +
- + /**
- + * Zoey76: TODO: Rewrite this in a way that doesn't iterate over all spawns.
- + */
- + public static void unspawnEventNpcs()
- + {
- + SpawnTable.getInstance().forEachSpawn(spawn ->
- + {
- + final Npc npc = spawn.getLastSpawn();
- + if ((npc != null) && npc.isEventMob())
- + {
- + npc.deleteMe();
- + spawn.stopRespawn();
- + SpawnTable.getInstance().deleteSpawn(spawn, false);
- + }
- + return true;
- + });
- + }
- +
- + /**
- + * @param player
- + * @return False: If player is null, his event status is null or the event state is off. True: if the player is inside the _registeredPlayers list while the event state is STANDBY. If the event state is ON, it will check if the player is inside in one of the teams.
- + */
- + public static boolean isParticipant(Player player)
- + {
- + if ((player == null) || (player.getEventStatus() == null))
- + {
- + return false;
- + }
- +
- + switch (eventState)
- + {
- + case OFF:
- + {
- + return false;
- + }
- + case STANDBY:
- + {
- + return _registeredPlayers.contains(player);
- + }
- + case ON:
- + {
- + for (List<Player> teamList : _teams.values())
- + {
- + if (teamList.contains(player))
- + {
- + return true;
- + }
- + }
- + }
- + }
- + return false;
- + }
- +
- + /**
- + * Adds the player to the list of participants. If the event state is NOT STANDBY, the player wont be registered.
- + * @param player
- + */
- + public static void registerPlayer(Player player)
- + {
- + if (eventState != EventState.STANDBY)
- + {
- + player.sendMessage("The registration period for this event is over.");
- + return;
- + }
- +
- + if ((Config.DUALBOX_CHECK_MAX_L2EVENT_PARTICIPANTS_PER_IP == 0) || AntiFeedManager.getInstance().tryAddPlayer(AntiFeedManager.L2EVENT_ID, player, Config.DUALBOX_CHECK_MAX_L2EVENT_PARTICIPANTS_PER_IP))
- + {
- + _registeredPlayers.add(player);
- + }
- + else
- + {
- + player.sendMessage("You have reached the maximum allowed participants per IP.");
- + }
- + }
- +
- + /**
- + * Removes the player from the participating players and the teams and restores his init stats before he registered at the event (loc, pvp, pk, title etc)
- + * @param player
- + */
- + public static void removeAndResetPlayer(Player player)
- + {
- + try
- + {
- + if (isParticipant(player))
- + {
- + if (player.isDead())
- + {
- + player.restoreExp(100.0);
- + player.doRevive();
- + player.setCurrentHpMp(player.getMaxHp(), player.getMaxMp());
- + player.setCurrentCp(player.getMaxCp());
- + }
- +
- + player.decayMe();
- + player.spawnMe(player.getX(), player.getY(), player.getZ());
- + player.broadcastUserInfo();
- +
- + player.stopTransformation(true);
- + }
- +
- + if (player.getEventStatus() != null)
- + {
- + player.getEventStatus().restorePlayerStats();
- + }
- +
- + player.setEventStatus(null);
- +
- + _registeredPlayers.remove(player);
- + final int teamId = getPlayerTeamId(player);
- + if (_teams.containsKey(teamId))
- + {
- + _teams.get(teamId).remove(player);
- + }
- + }
- + catch (Exception e)
- + {
- + LOGGER.log(Level.WARNING, "Error at unregisterAndResetPlayer in the event:" + e.getMessage(), e);
- + }
- + }
- +
- + /**
- + * The player's event status will be saved at _connectionLossData
- + * @param player
- + */
- + public static void savePlayerEventStatus(Player player)
- + {
- + _connectionLossData.put(player, player.getEventStatus());
- + }
- +
- + /**
- + * If _connectionLossData contains the player, it will restore the player's event status. Also it will remove the player from the _connectionLossData.
- + * @param player
- + */
- + public static void restorePlayerEventStatus(Player player)
- + {
- + if (_connectionLossData.containsKey(player))
- + {
- + player.setEventStatus(_connectionLossData.get(player));
- + _connectionLossData.remove(player);
- + }
- + }
- +
- + /**
- + * If the event is ON or STANDBY, it will not start. Sets the event state to STANDBY and spawns registration NPCs
- + * @return a string with information if the event participation has been successfully started or not.
- + */
- + public static String startEventParticipation()
- + {
- + try
- + {
- + switch (eventState)
- + {
- + case ON:
- + {
- + return "Cannot start event, it is already on.";
- + }
- + case STANDBY:
- + {
- + return "Cannot start event, it is on standby mode.";
- + }
- + case OFF: // Event is off, so no problem turning it on.
- + {
- + eventState = EventState.STANDBY;
- + break;
- + }
- + }
- +
- + // Register the event at AntiFeedManager and clean it for just in case if the event is already registered.
- + AntiFeedManager.getInstance().registerEvent(AntiFeedManager.L2EVENT_ID);
- + AntiFeedManager.getInstance().clear(AntiFeedManager.L2EVENT_ID);
- +
- + // Just in case
- + unspawnEventNpcs();
- + _registeredPlayers.clear();
- + // _npcs.clear();
- + if (NpcData.getInstance().getTemplate(_npcId) == null)
- + {
- + return "Cannot start event, invalid npc id.";
- + }
- +
- + try (FileReader fr = new FileReader(Config.DATAPACK_ROOT + "/data/events/" + _eventName);
- + BufferedReader br = new BufferedReader(fr))
- + {
- + _eventCreator = br.readLine();
- + _eventInfo = br.readLine();
- + }
- +
- + final List<Player> temp = new LinkedList<>();
- + for (Player player : World.getInstance().getPlayers())
- + {
- + if (!player.isOnline())
- + {
- + continue;
- + }
- +
- + if (!temp.contains(player))
- + {
- + spawnEventNpc(player);
- + temp.add(player);
- + }
- + World.getInstance().forEachVisibleObject(player, Player.class, playertemp ->
- + {
- + if ((Math.abs(playertemp.getX() - player.getX()) < 1000) && (Math.abs(playertemp.getY() - player.getY()) < 1000) && (Math.abs(playertemp.getZ() - player.getZ()) < 1000))
- + {
- + temp.add(playertemp);
- + }
- + });
- + }
- + }
- + catch (Exception e)
- + {
- + LOGGER.warning("Event: " + e.getMessage());
- + return "Cannot start event participation, an error has occured.";
- + }
- +
- + return "The event participation has been successfully started.";
- + }
- +
- + /**
- + * If the event is ON or OFF, it will not start. Sets the event state to ON, creates the teams, adds the registered players ordered by level at the teams and adds a new event status to the players.
- + * @return a string with information if the event has been successfully started or not.
- + */
- + public static String startEvent()
- + {
- + try
- + {
- + switch (eventState)
- + {
- + case ON:
- + {
- + return "Cannot start event, it is already on.";
- + }
- + case STANDBY:
- + {
- + eventState = EventState.ON;
- + break;
- + }
- + case OFF: // Event is off, so no problem turning it on.
- + {
- + return "Cannot start event, it is off. Participation start is required.";
- + }
- + }
- +
- + // Clean the things we will use, just in case.
- + unspawnEventNpcs();
- + _teams.clear();
- + _connectionLossData.clear();
- +
- + // Insert empty lists at _teams.
- + for (int i = 0; i < _teamsNumber; i++)
- + {
- + _teams.put(i + 1, new CopyOnWriteArrayList<>());
- + }
- +
- + int i = 0;
- + while (!_registeredPlayers.isEmpty())
- + {
- + // Get the player with the biggest level
- + int max = 0;
- + Player biggestLvlPlayer = null;
- + for (Player player : _registeredPlayers)
- + {
- + if (player == null)
- + {
- + continue;
- + }
- +
- + if (max < player.getLevel())
- + {
- + max = player.getLevel();
- + biggestLvlPlayer = player;
- + }
- + }
- +
- + if (biggestLvlPlayer == null)
- + {
- + continue;
- + }
- +
- + _registeredPlayers.remove(biggestLvlPlayer);
- + _teams.get(i + 1).add(biggestLvlPlayer);
- + biggestLvlPlayer.setEventStatus();
- + i = (i + 1) % _teamsNumber;
- + }
- + }
- + catch (Exception e)
- + {
- + LOGGER.warning("Event: " + e.getMessage());
- + return "Cannot start event, an error has occured.";
- + }
- +
- + return "The event has been successfully started.";
- + }
- +
- + /**
- + * If the event state is OFF, it will not finish. Sets the event state to OFF, unregisters and resets the players, unspawns and clers the event NPCs, clears the teams, registered players, connection loss data, sets the teams number to 0, sets the event name to empty.
- + * @return a string with information if the event has been successfully stopped or not.
- + */
- + public static String finishEvent()
- + {
- + switch (eventState)
- + {
- + case OFF:
- + {
- + return "Cannot finish event, it is already off.";
- + }
- + case STANDBY:
- + {
- + for (Player player : _registeredPlayers)
- + {
- + removeAndResetPlayer(player);
- + }
- +
- + unspawnEventNpcs();
- + // _npcs.clear();
- + _registeredPlayers.clear();
- + _teams.clear();
- + _connectionLossData.clear();
- + _teamsNumber = 0;
- + _eventName = "";
- + eventState = EventState.OFF;
- + return "The event has been stopped at STANDBY mode, all players unregistered and all event npcs unspawned.";
- + }
- + case ON:
- + {
- + for (List<Player> teamList : _teams.values())
- + {
- + for (Player player : teamList)
- + {
- + removeAndResetPlayer(player);
- + }
- + }
- +
- + eventState = EventState.OFF;
- + AntiFeedManager.getInstance().clear(AntiFeedManager.TVT_ID);
- + unspawnEventNpcs(); // Just in case
- + // _npcs.clear();
- + _registeredPlayers.clear();
- + _teams.clear();
- + _connectionLossData.clear();
- + _teamsNumber = 0;
- + _eventName = "";
- + _npcId = 0;
- + _eventCreator = "";
- + _eventInfo = "";
- + return "The event has been stopped, all players unregistered and all event npcs unspawned.";
- + }
- + }
- +
- + return "The event has been successfully finished.";
- + }
- +
- + private static Map<Player, Integer> sortByValue(Map<Player, Integer> unsortMap)
- + {
- + final List<Entry<Player, Integer>> list = new LinkedList<>(unsortMap.entrySet());
- + list.sort(Comparator.comparing(Entry::getValue));
- +
- + final Map<Player, Integer> sortedMap = new LinkedHashMap<>();
- + for (Entry<Player, Integer> entry : list)
- + {
- + sortedMap.put(entry.getKey(), entry.getValue());
- + }
- + return sortedMap;
- + }
- +}
- diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/instancemanager/events/TvTEvent.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/instancemanager/events/TvTEvent.java
- new file mode 100644
- index 0000000..456c25f
- --- /dev/null
- +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/instancemanager/events/TvTEvent.java
- @@ -0,0 +1,1097 @@
- +/*
- + * This file is part of the L2J Mobius project.
- + *
- + * 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 org.l2jmobius.gameserver.instancemanager.events;
- +
- +import java.util.HashMap;
- +import java.util.List;
- +import java.util.Map;
- +import java.util.Map.Entry;
- +import java.util.logging.Level;
- +import java.util.logging.Logger;
- +
- +import org.l2jmobius.Config;
- +import org.l2jmobius.commons.util.Rnd;
- +import org.l2jmobius.gameserver.cache.HtmCache;
- +import org.l2jmobius.gameserver.data.ItemTable;
- +import org.l2jmobius.gameserver.data.SpawnTable;
- +import org.l2jmobius.gameserver.data.xml.DoorData;
- +import org.l2jmobius.gameserver.data.xml.SkillData;
- +import org.l2jmobius.gameserver.enums.ChatType;
- +import org.l2jmobius.gameserver.instancemanager.AntiFeedManager;
- +import org.l2jmobius.gameserver.instancemanager.InstanceManager;
- +import org.l2jmobius.gameserver.model.Spawn;
- +import org.l2jmobius.gameserver.model.World;
- +import org.l2jmobius.gameserver.model.actor.Creature;
- +import org.l2jmobius.gameserver.model.actor.Npc;
- +import org.l2jmobius.gameserver.model.actor.Player;
- +import org.l2jmobius.gameserver.model.actor.Summon;
- +import org.l2jmobius.gameserver.model.actor.instance.Door;
- +import org.l2jmobius.gameserver.model.events.EventDispatcher;
- +import org.l2jmobius.gameserver.model.events.impl.events.OnTvTEventFinish;
- +import org.l2jmobius.gameserver.model.events.impl.events.OnTvTEventKill;
- +import org.l2jmobius.gameserver.model.events.impl.events.OnTvTEventRegistrationStart;
- +import org.l2jmobius.gameserver.model.events.impl.events.OnTvTEventStart;
- +import org.l2jmobius.gameserver.model.instancezone.Instance;
- +import org.l2jmobius.gameserver.model.itemcontainer.PlayerInventory;
- +import org.l2jmobius.gameserver.model.skill.Skill;
- +import org.l2jmobius.gameserver.network.SystemMessageId;
- +import org.l2jmobius.gameserver.network.serverpackets.CreatureSay;
- +import org.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
- +import org.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
- +import org.l2jmobius.gameserver.network.serverpackets.StatusUpdate;
- +import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
- +
- +/**
- + * @author HorridoJoho
- + */
- +public class TvTEvent
- +{
- + enum EventState
- + {
- + INACTIVE,
- + INACTIVATING,
- + PARTICIPATING,
- + STARTING,
- + STARTED,
- + REWARDING
- + }
- +
- + protected static final Logger LOGGER = Logger.getLogger(TvTEvent.class.getName());
- +
- + private static final String HTML_PATH = "data/scripts/custom/events/TvT/TvTManager/";
- +
- + private static TvTEventTeam[] _teams = new TvTEventTeam[2];
- + private static EventState _state = EventState.INACTIVE;
- + private static Spawn _npcSpawn = null;
- + private static Npc _lastNpcSpawn = null;
- + private static int _TvTEventInstance = 0;
- +
- + private TvTEvent()
- + {
- + // Prevent external initialization.
- + }
- +
- + /**
- + * Teams initializing
- + */
- + public static void init()
- + {
- + AntiFeedManager.getInstance().registerEvent(AntiFeedManager.TVT_ID);
- + _teams[0] = new TvTEventTeam(Config.TVT_EVENT_TEAM_1_NAME, Config.TVT_EVENT_TEAM_1_COORDINATES);
- + _teams[1] = new TvTEventTeam(Config.TVT_EVENT_TEAM_2_NAME, Config.TVT_EVENT_TEAM_2_COORDINATES);
- + }
- +
- + /**
- + * Starts the participation of the TvTEvent<br>
- + * 1. Get NpcTemplate by Config.TVT_EVENT_PARTICIPATION_NPC_ID<br>
- + * 2. Try to spawn a new npc of it
- + * @return boolean: true if success, otherwise false
- + */
- + public static boolean startParticipation()
- + {
- + try
- + {
- + _npcSpawn = new Spawn(Config.TVT_EVENT_PARTICIPATION_NPC_ID);
- + _npcSpawn.setXYZ(Config.TVT_EVENT_PARTICIPATION_NPC_COORDINATES[0], Config.TVT_EVENT_PARTICIPATION_NPC_COORDINATES[1], Config.TVT_EVENT_PARTICIPATION_NPC_COORDINATES[2]);
- + _npcSpawn.setAmount(1);
- + _npcSpawn.setHeading(Config.TVT_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("TvT 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)
- + {
- + LOGGER.log(Level.WARNING, "TvTEventEngine[TvTEvent.startParticipation()]: exception: " + e.getMessage(), e);
- + return false;
- + }
- +
- + setState(EventState.PARTICIPATING);
- + EventDispatcher.getInstance().notifyEventAsync(new OnTvTEventRegistrationStart());
- + return true;
- + }
- +
- + private static int highestLevelPcInstanceOf(Map<Integer, Player> players)
- + {
- + int maxLevel = Integer.MIN_VALUE;
- + int maxLevelId = -1;
- + for (Player player : players.values())
- + {
- + if (player.getLevel() >= maxLevel)
- + {
- + maxLevel = player.getLevel();
- + maxLevelId = player.getObjectId();
- + }
- + }
- + return maxLevelId;
- + }
- +
- + /**
- + * Starts the TvTEvent fight<br>
- + * 1. Set state EventState.STARTING<br>
- + * 2. Close doors specified in configs<br>
- + * 3. Abort if not enough participants(return false)<br>
- + * 4. Set state EventState.STARTED<br>
- + * 5. Teleport all participants to team spot
- + * @return boolean: true if success, otherwise false
- + */
- + public static boolean startFight()
- + {
- + // Set state to STARTING
- + setState(EventState.STARTING);
- +
- + // Randomize and balance team distribution
- + final Map<Integer, Player> allParticipants = new HashMap<>();
- + allParticipants.putAll(_teams[0].getParticipatedPlayers());
- + allParticipants.putAll(_teams[1].getParticipatedPlayers());
- + _teams[0].cleanMe();
- + _teams[1].cleanMe();
- +
- + if (needParticipationFee())
- + {
- + for (Player player : allParticipants.values())
- + {
- + if (!hasParticipationFee(player))
- + {
- + allParticipants.remove(player.getObjectId());
- + }
- + }
- + }
- +
- + final int[] balance =
- + {
- + 0,
- + 0
- + };
- + int priority = 0;
- + int highestLevelPlayerId;
- + Player highestLevelPlayer;
- + // TODO: allParticipants should be sorted by level instead of using highestLevelPcInstanceOf for every fetch
- + while (!allParticipants.isEmpty())
- + {
- + // Priority team gets one player
- + highestLevelPlayerId = highestLevelPcInstanceOf(allParticipants);
- + highestLevelPlayer = allParticipants.get(highestLevelPlayerId);
- + allParticipants.remove(highestLevelPlayerId);
- + _teams[priority].addPlayer(highestLevelPlayer);
- + balance[priority] += highestLevelPlayer.getLevel();
- + // Exiting if no more players
- + if (allParticipants.isEmpty())
- + {
- + break;
- + }
- + // The other team gets one player
- + // TODO: Code not dry
- + priority = 1 - priority;
- + highestLevelPlayerId = highestLevelPcInstanceOf(allParticipants);
- + highestLevelPlayer = allParticipants.get(highestLevelPlayerId);
- + allParticipants.remove(highestLevelPlayerId);
- + _teams[priority].addPlayer(highestLevelPlayer);
- + balance[priority] += highestLevelPlayer.getLevel();
- + // Recalculating priority
- + priority = balance[0] > balance[1] ? 1 : 0;
- + }
- +
- + // Check for enought participants
- + if ((_teams[0].getParticipatedPlayerCount() < Config.TVT_EVENT_MIN_PLAYERS_IN_TEAMS) || (_teams[1].getParticipatedPlayerCount() < Config.TVT_EVENT_MIN_PLAYERS_IN_TEAMS))
- + {
- + // Set state INACTIVE
- + setState(EventState.INACTIVE);
- + // Cleanup of teams
- + _teams[0].cleanMe();
- + _teams[1].cleanMe();
- + // Unspawn the event NPC
- + unSpawnNpc();
- + AntiFeedManager.getInstance().clear(AntiFeedManager.TVT_ID);
- + return false;
- + }
- +
- + if (needParticipationFee())
- + {
- + for (Player player : _teams[0].getParticipatedPlayers().values())
- + {
- + if (!payParticipationFee(player))
- + {
- + _teams[0].removePlayer(player.getObjectId());
- + }
- + }
- + for (Player player : _teams[1].getParticipatedPlayers().values())
- + {
- + if (!payParticipationFee(player))
- + {
- + _teams[1].removePlayer(player.getObjectId());
- + }
- + }
- + }
- +
- + if (Config.TVT_EVENT_IN_INSTANCE)
- + {
- + try
- + {
- + _TvTEventInstance = InstanceManager.getInstance().createDynamicInstance(Config.TVT_EVENT_INSTANCE_ID).getId();
- + InstanceManager.getInstance().getInstance(_TvTEventInstance).setAllowSummon(false);
- + InstanceManager.getInstance().getInstance(_TvTEventInstance).setPvP(true);
- + InstanceManager.getInstance().getInstance(_TvTEventInstance).setEmptyDestroyTime((Config.TVT_EVENT_START_LEAVE_TELEPORT_DELAY * 1000) + 60000);
- + }
- + catch (Exception e)
- + {
- + _TvTEventInstance = 0;
- + LOGGER.log(Level.WARNING, "TvTEventEngine[TvTEvent.createDynamicInstance]: exception: " + e.getMessage(), e);
- + }
- + }
- +
- + // Opens all doors specified in configs for tvt
- + openDoors(Config.TVT_DOORS_IDS_TO_OPEN);
- + // Closes all doors specified in configs for tvt
- + closeDoors(Config.TVT_DOORS_IDS_TO_CLOSE);
- + // Set state STARTED
- + setState(EventState.STARTED);
- +
- + // Iterate over all teams
- + for (TvTEventTeam team : _teams)
- + {
- + // Iterate over all participated player instances in this team
- + for (Player Player : team.getParticipatedPlayers().values())
- + {
- + if (Player != null)
- + {
- + // Disable player revival.
- + Player.setCanRevive(false);
- + // Teleporter implements Runnable and starts itself
- + new TvTEventTeleporter(Player, team.getCoordinates(), false, false);
- + }
- + }
- + }
- +
- + // Notify to scripts.
- + EventDispatcher.getInstance().notifyEventAsync(new OnTvTEventStart());
- + return true;
- + }
- +
- + /**
- + * Calculates the TvTEvent 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
- + * @return String: winning team name
- + */
- + public static String calculateRewards()
- + {
- + if (_teams[0].getPoints() == _teams[1].getPoints())
- + {
- + // Check if one of the teams have no more players left
- + if ((_teams[0].getParticipatedPlayerCount() == 0) || (_teams[1].getParticipatedPlayerCount() == 0))
- + {
- + // set state to rewarding
- + setState(EventState.REWARDING);
- + // return here, the fight can't be completed
- + return "TvT Event: Event has ended. No team won due to inactivity!";
- + }
- +
- + // Both teams have equals points
- + sysMsgToAllParticipants("TvT Event: Event has ended, both teams have tied.");
- + if (Config.TVT_REWARD_TEAM_TIE)
- + {
- + rewardTeam(_teams[0]);
- + rewardTeam(_teams[1]);
- + return "TvT Event: Event has ended with both teams tying.";
- + }
- + return "TvT Event: Event has ended with both teams tying.";
- + }
- +
- + // Set state REWARDING so nobody can point anymore
- + setState(EventState.REWARDING);
- +
- + // Get team which has more points
- + final TvTEventTeam team = _teams[_teams[0].getPoints() > _teams[1].getPoints() ? 0 : 1];
- + rewardTeam(team);
- +
- + // Notify to scripts.
- + EventDispatcher.getInstance().notifyEventAsync(new OnTvTEventFinish());
- + return "TvT Event: Event finish. Team " + team.getName() + " won with " + team.getPoints() + " kills.";
- + }
- +
- + private static void rewardTeam(TvTEventTeam team)
- + {
- + // Iterate over all participated player instances of the winning team
- + for (Player Player : team.getParticipatedPlayers().values())
- + {
- + // Check for nullpointer
- + if (Player == null)
- + {
- + continue;
- + }
- +
- + SystemMessage systemMessage = null;
- +
- + // Iterate over all tvt event rewards
- + for (int[] reward : Config.TVT_EVENT_REWARDS)
- + {
- + final PlayerInventory inv = Player.getInventory();
- +
- + // Check for stackable item, non stackabe items need to be added one by one
- + if (ItemTable.getInstance().getTemplate(reward[0]).isStackable())
- + {
- + inv.addItem("TvT Event", reward[0], reward[1], Player, Player);
- + if (reward[1] > 1)
- + {
- + systemMessage = new SystemMessage(SystemMessageId.YOU_HAVE_EARNED_S2_S1_S);
- + systemMessage.addItemName(reward[0]);
- + systemMessage.addLong(reward[1]);
- + }
- + else
- + {
- + systemMessage = new SystemMessage(SystemMessageId.YOU_HAVE_EARNED_S1);
- + systemMessage.addItemName(reward[0]);
- + }
- +
- + Player.sendPacket(systemMessage);
- + }
- + else
- + {
- + for (int i = 0; i < reward[1]; ++i)
- + {
- + inv.addItem("TvT Event", reward[0], 1, Player, Player);
- + systemMessage = new SystemMessage(SystemMessageId.YOU_HAVE_EARNED_S1);
- + systemMessage.addItemName(reward[0]);
- + Player.sendPacket(systemMessage);
- + }
- + }
- + }
- +
- + final StatusUpdate statusUpdate = new StatusUpdate(Player);
- + final NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage();
- + statusUpdate.addAttribute(StatusUpdate.CUR_LOAD, Player.getCurrentLoad());
- + npcHtmlMessage.setHtml(HtmCache.getInstance().getHtm(Player, HTML_PATH + "Reward.html"));
- + Player.sendPacket(statusUpdate);
- + Player.sendPacket(npcHtmlMessage);
- + }
- + }
- +
- + /**
- + * Stops the TvTEvent fight<br>
- + * 1. Set state EventState.INACTIVATING<br>
- + * 2. Remove tvt npc from world<br>
- + * 3. Open doors specified in configs<br>
- + * 4. Teleport all participants back to participation npc location<br>
- + * 5. Teams cleaning<br>
- + * 6. Set state EventState.INACTIVE
- + */
- + public static void stopFight()
- + {
- + // Set state INACTIVATING
- + setState(EventState.INACTIVATING);
- + // Unspawn event npc
- + unSpawnNpc();
- + // Opens all doors specified in configs for tvt
- + openDoors(Config.TVT_DOORS_IDS_TO_CLOSE);
- + // Closes all doors specified in Configs for tvt
- + closeDoors(Config.TVT_DOORS_IDS_TO_OPEN);
- +
- + // Iterate over all teams
- + for (TvTEventTeam team : _teams)
- + {
- + for (Player Player : team.getParticipatedPlayers().values())
- + {
- + // Check for nullpointer
- + if (Player != null)
- + {
- + // Enable player revival.
- + Player.setCanRevive(true);
- + // Teleport back.
- + new TvTEventTeleporter(Player, Config.TVT_EVENT_PARTICIPATION_NPC_COORDINATES, false, false);
- + }
- + }
- + }
- +
- + // Cleanup of teams
- + _teams[0].cleanMe();
- + _teams[1].cleanMe();
- + // Set state INACTIVE
- + setState(EventState.INACTIVE);
- + AntiFeedManager.getInstance().clear(AntiFeedManager.TVT_ID);
- + }
- +
- + /**
- + * Adds a player to a TvTEvent team<br>
- + * 1. Calculate the id of the team in which the player should be added<br>
- + * 2. Add the player to the calculated team
- + * @param Player as Player
- + * @return boolean: true if success, otherwise false
- + */
- + public static synchronized boolean addParticipant(Player Player)
- + {
- + // Check for nullpoitner
- + if (Player == null)
- + {
- + return false;
- + }
- +
- + byte teamId = 0;
- +
- + // Check to which team the player should be added
- + if (_teams[0].getParticipatedPlayerCount() == _teams[1].getParticipatedPlayerCount())
- + {
- + teamId = (byte) Rnd.get(2);
- + }
- + else
- + {
- + teamId = (byte) (_teams[0].getParticipatedPlayerCount() > _teams[1].getParticipatedPlayerCount() ? 1 : 0);
- + }
- + Player.addEventListener(new TvTEventListener(Player));
- + return _teams[teamId].addPlayer(Player);
- + }
- +
- + /**
- + * Removes a TvTEvent player from it's team<br>
- + * 1. Get team id of the player<br>
- + * 2. Remove player from it's team
- + * @param playerObjectId
- + * @return boolean: true if success, otherwise false
- + */
- + public static boolean removeParticipant(int playerObjectId)
- + {
- + // Get the teamId of the player
- + final byte teamId = getParticipantTeamId(playerObjectId);
- +
- + // Check if the player is participant
- + if (teamId != -1)
- + {
- + // Remove the player from team
- + _teams[teamId].removePlayer(playerObjectId);
- +
- + final Player player = World.getInstance().getPlayer(playerObjectId);
- + if (player != null)
- + {
- + player.removeEventListener(TvTEventListener.class);
- + }
- + return true;
- + }
- + return false;
- + }
- +
- + public static boolean needParticipationFee()
- + {
- + return (Config.TVT_EVENT_PARTICIPATION_FEE[0] != 0) && (Config.TVT_EVENT_PARTICIPATION_FEE[1] != 0);
- + }
- +
- + public static boolean hasParticipationFee(Player Player)
- + {
- + return Player.getInventory().getInventoryItemCount(Config.TVT_EVENT_PARTICIPATION_FEE[0], -1) >= Config.TVT_EVENT_PARTICIPATION_FEE[1];
- + }
- +
- + public static boolean payParticipationFee(Player Player)
- + {
- + return Player.destroyItemByItemId("TvT Participation Fee", Config.TVT_EVENT_PARTICIPATION_FEE[0], Config.TVT_EVENT_PARTICIPATION_FEE[1], _lastNpcSpawn, true);
- + }
- +
- + public static String getParticipationFee()
- + {
- + final int itemId = Config.TVT_EVENT_PARTICIPATION_FEE[0];
- + final int itemNum = Config.TVT_EVENT_PARTICIPATION_FEE[1];
- + if ((itemId == 0) || (itemNum == 0))
- + {
- + return "-";
- + }
- + return itemNum + " " + ItemTable.getInstance().getTemplate(itemId).getName();
- + }
- +
- + /**
- + * Send a SystemMessage to all participated players<br>
- + * 1. Send the message to all players of team number one<br>
- + * 2. Send the message to all players of team number two
- + * @param message as String
- + */
- + public static void sysMsgToAllParticipants(String message)
- + {
- + for (Player Player : _teams[0].getParticipatedPlayers().values())
- + {
- + if (Player != null)
- + {
- + Player.sendMessage(message);
- + }
- + }
- +
- + for (Player Player : _teams[1].getParticipatedPlayers().values())
- + {
- + if (Player != null)
- + {
- + Player.sendMessage(message);
- + }
- + }
- + }
- +
- + private static Door getDoor(int doorId)
- + {
- + Door door = null;
- + if (_TvTEventInstance <= 0)
- + {
- + door = DoorData.getInstance().getDoor(doorId);
- + }
- + else
- + {
- + final Instance inst = InstanceManager.getInstance().getInstance(_TvTEventInstance);
- + if (inst != null)
- + {
- + door = inst.getDoor(doorId);
- + }
- + }
- + return door;
- + }
- +
- + /**
- + * Close doors specified in configs
- + * @param doors
- + */
- + private static void closeDoors(List<Integer> doors)
- + {
- + for (int doorId : doors)
- + {
- + final Door Door = getDoor(doorId);
- + if (Door != null)
- + {
- + Door.closeMe();
- + }
- + }
- + }
- +
- + /**
- + * Open doors specified in configs
- + * @param doors
- + */
- + private static void openDoors(List<Integer> doors)
- + {
- + for (int doorId : doors)
- + {
- + final Door Door = getDoor(doorId);
- + if (Door != null)
- + {
- + Door.openMe();
- + }
- + }
- + }
- +
- + /**
- + * UnSpawns the TvTEvent 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;
- + }
- +
- + /**
- + * Called when a player logs in
- + * @param Player as Player
- + */
- + public static void onLogin(Player Player)
- + {
- + if ((Player == null) || (!isStarting() && !isStarted()))
- + {
- + return;
- + }
- +
- + final byte teamId = getParticipantTeamId(Player.getObjectId());
- + if (teamId == -1)
- + {
- + return;
- + }
- +
- + _teams[teamId].addPlayer(Player);
- + new TvTEventTeleporter(Player, _teams[teamId].getCoordinates(), true, false);
- + }
- +
- + /**
- + * Called when a player logs out
- + * @param Player as Player
- + */
- + public static void onLogout(Player Player)
- + {
- + if ((Player != null) && (isStarting() || isStarted() || isParticipating()) && removeParticipant(Player.getObjectId()))
- + {
- + Player.setXYZInvisible((Config.TVT_EVENT_PARTICIPATION_NPC_COORDINATES[0] + Rnd.get(101)) - 50, (Config.TVT_EVENT_PARTICIPATION_NPC_COORDINATES[1] + Rnd.get(101)) - 50, Config.TVT_EVENT_PARTICIPATION_NPC_COORDINATES[2]);
- + }
- + }
- +
- + /**
- + * Called on every onAction in PlayerIstance
- + * @param Player
- + * @param targetedPlayerObjectId
- + * @return boolean: true if player is allowed to target, otherwise false
- + */
- + public static boolean onAction(Player Player, int targetedPlayerObjectId)
- + {
- + if ((Player == null) || !isStarted())
- + {
- + return true;
- + }
- +
- + if (Player.isGM())
- + {
- + return true;
- + }
- +
- + final byte playerTeamId = getParticipantTeamId(Player.getObjectId());
- + final byte targetedPlayerTeamId = getParticipantTeamId(targetedPlayerObjectId);
- + if (((playerTeamId != -1) && (targetedPlayerTeamId == -1)) || ((playerTeamId == -1) && (targetedPlayerTeamId != -1)))
- + {
- + return false;
- + }
- +
- + if ((playerTeamId != -1) && (targetedPlayerTeamId != -1) && (playerTeamId == targetedPlayerTeamId) && (Player.getObjectId() != targetedPlayerObjectId) && !Config.TVT_EVENT_TARGET_TEAM_MEMBERS_ALLOWED)
- + {
- + return false;
- + }
- +
- + return true;
- + }
- +
- + /**
- + * Called on every scroll use
- + * @param playerObjectId
- + * @return boolean: true if player is allowed to use scroll, otherwise false
- + */
- + public static boolean onScrollUse(int playerObjectId)
- + {
- + if (!isStarted())
- + {
- + return true;
- + }
- +
- + if (isPlayerParticipant(playerObjectId) && !Config.TVT_EVENT_SCROLL_ALLOWED)
- + {
- + return false;
- + }
- +
- + return true;
- + }
- +
- + /**
- + * Called on every potion use
- + * @param playerObjectId
- + * @return boolean: true if player is allowed to use potions, otherwise false
- + */
- + public static boolean onPotionUse(int playerObjectId)
- + {
- + if (!isStarted())
- + {
- + return true;
- + }
- +
- + if (isPlayerParticipant(playerObjectId) && !Config.TVT_EVENT_POTIONS_ALLOWED)
- + {
- + return false;
- + }
- +
- + return true;
- + }
- +
- + /**
- + * Called on every escape use(thanks to nbd)
- + * @param playerObjectId
- + * @return boolean: true if player is not in tvt event, otherwise false
- + */
- + public static boolean onEscapeUse(int playerObjectId)
- + {
- + if (!isStarted())
- + {
- + return true;
- + }
- +
- + if (isPlayerParticipant(playerObjectId))
- + {
- + return false;
- + }
- +
- + return true;
- + }
- +
- + /**
- + * Called on every summon item use
- + * @param playerObjectId
- + * @return boolean: true if player is allowed to summon by item, otherwise false
- + */
- + public static boolean onItemSummon(int playerObjectId)
- + {
- + if (!isStarted())
- + {
- + return true;
- + }
- +
- + if (isPlayerParticipant(playerObjectId) && !Config.TVT_EVENT_SUMMON_BY_ITEM_ALLOWED)
- + {
- + return false;
- + }
- +
- + return true;
- + }
- +
- + /**
- + * Is called when a player is killed
- + * @param killerCharacter as Creature
- + * @param killedPlayer as Player
- + */
- + public static void onKill(Creature killerCharacter, Player killedPlayer)
- + {
- + if ((killedPlayer == null) || !isStarted())
- + {
- + return;
- + }
- +
- + final byte killedTeamId = getParticipantTeamId(killedPlayer.getObjectId());
- + if (killedTeamId == -1)
- + {
- + return;
- + }
- +
- + new TvTEventTeleporter(killedPlayer, _teams[killedTeamId].getCoordinates(), false, false);
- + if (killerCharacter == null)
- + {
- + return;
- + }
- +
- + Player killerPlayer = null;
- + if (killerCharacter.isPet() || killerCharacter.isServitor())
- + {
- + killerPlayer = ((Summon) killerCharacter).getOwner();
- + if (killerPlayer == null)
- + {
- + return;
- + }
- + }
- + else if (killerCharacter.isPlayer())
- + {
- + killerPlayer = (Player) killerCharacter;
- + }
- + else
- + {
- + return;
- + }
- +
- + final byte killerTeamId = getParticipantTeamId(killerPlayer.getObjectId());
- + if ((killerTeamId != -1) && (killedTeamId != -1) && (killerTeamId != killedTeamId))
- + {
- + final TvTEventTeam killerTeam = _teams[killerTeamId];
- + killerTeam.increasePoints();
- +
- + final CreatureSay cs = new CreatureSay(killerPlayer, ChatType.WHISPER, killerPlayer.getName(), "I have killed " + killedPlayer.getName() + "!");
- + for (Player Player : _teams[killerTeamId].getParticipatedPlayers().values())
- + {
- + if (Player != null)
- + {
- + Player.sendPacket(cs);
- + }
- + }
- +
- + // Notify to scripts.
- + EventDispatcher.getInstance().notifyEventAsync(new OnTvTEventKill(killerPlayer, killedPlayer, killerTeam));
- + }
- + }
- +
- + /**
- + * Called on Appearing packet received (player finished teleporting)
- + * @param Player
- + */
- + public static void onTeleported(Player Player)
- + {
- + if (!isStarted() || (Player == null) || !isPlayerParticipant(Player.getObjectId()))
- + {
- + return;
- + }
- +
- + if (Player.isMageClass())
- + {
- + if ((Config.TVT_EVENT_MAGE_BUFFS != null) && !Config.TVT_EVENT_MAGE_BUFFS.isEmpty())
- + {
- + for (Entry<Integer, Integer> e : Config.TVT_EVENT_MAGE_BUFFS.entrySet())
- + {
- + final Skill skill = SkillData.getInstance().getSkill(e.getKey(), e.getValue());
- + if (skill != null)
- + {
- + skill.applyEffects(Player, Player);
- + }
- + }
- + }
- + }
- + else if ((Config.TVT_EVENT_FIGHTER_BUFFS != null) && !Config.TVT_EVENT_FIGHTER_BUFFS.isEmpty())
- + {
- + for (Entry<Integer, Integer> e : Config.TVT_EVENT_FIGHTER_BUFFS.entrySet())
- + {
- + final Skill skill = SkillData.getInstance().getSkill(e.getKey(), e.getValue());
- + if (skill != null)
- + {
- + skill.applyEffects(Player, Player);
- + }
- + }
- + }
- + }
- +
- + /**
- + * @param source
- + * @param target
- + * @param skill
- + * @return true if player valid for skill
- + */
- + public static boolean checkForTvTSkill(Player source, Player target, Skill skill)
- + {
- + if (!isStarted())
- + {
- + return true;
- + }
- + // TvT is started
- + final int sourcePlayerId = source.getObjectId();
- + final int targetPlayerId = target.getObjectId();
- + final boolean isSourceParticipant = isPlayerParticipant(sourcePlayerId);
- + final boolean isTargetParticipant = isPlayerParticipant(targetPlayerId);
- +
- + // both players not participating
- + if (!isSourceParticipant && !isTargetParticipant)
- + {
- + return true;
- + }
- + // one player not participating
- + if (!(isSourceParticipant && isTargetParticipant))
- + {
- + return false;
- + }
- + // players in the different teams ?
- + if ((getParticipantTeamId(sourcePlayerId) != getParticipantTeamId(targetPlayerId)) && !skill.isBad())
- + {
- + return false;
- + }
- + return true;
- + }
- +
- + /**
- + * Sets the TvTEvent state
- + * @param state as EventState
- + */
- + private static void setState(EventState state)
- + {
- + synchronized (_state)
- + {
- + _state = state;
- + }
- + }
- +
- + /**
- + * Is TvTEvent inactive?
- + * @return boolean: true if event is inactive(waiting for next event cycle), otherwise false
- + */
- + public static boolean isInactive()
- + {
- + boolean isInactive;
- +
- + synchronized (_state)
- + {
- + isInactive = _state == EventState.INACTIVE;
- + }
- + return isInactive;
- + }
- +
- + /**
- + * Is TvTEvent in inactivating?
- + * @return boolean: true if event is in inactivating progress, otherwise false
- + */
- + public static boolean isInactivating()
- + {
- + boolean isInactivating;
- +
- + synchronized (_state)
- + {
- + isInactivating = _state == EventState.INACTIVATING;
- + }
- + return isInactivating;
- + }
- +
- + /**
- + * Is TvTEvent in participation?
- + * @return boolean: true if event is in participation progress, otherwise false
- + */
- + public static boolean isParticipating()
- + {
- + boolean isParticipating;
- +
- + synchronized (_state)
- + {
- + isParticipating = _state == EventState.PARTICIPATING;
- + }
- + return isParticipating;
- + }
- +
- + /**
- + * Is TvTEvent starting?
- + * @return boolean: true if event is starting up(setting up fighting spot, teleport players etc.), otherwise false
- + */
- + public static boolean isStarting()
- + {
- + boolean isStarting;
- +
- + synchronized (_state)
- + {
- + isStarting = _state == EventState.STARTING;
- + }
- + return isStarting;
- + }
- +
- + /**
- + * Is TvTEvent started?
- + * @return boolean: true if event is started, otherwise false
- + */
- + public static boolean isStarted()
- + {
- + boolean isStarted;
- +
- + synchronized (_state)
- + {
- + isStarted = _state == EventState.STARTED;
- + }
- + return isStarted;
- + }
- +
- + /**
- + * Is TvTEvent rewarding?
- + * @return boolean: true if event is currently rewarding, otherwise false
- + */
- + public static boolean isRewarding()
- + {
- + boolean isRewarding;
- +
- + synchronized (_state)
- + {
- + isRewarding = _state == EventState.REWARDING;
- + }
- + return isRewarding;
- + }
- +
- + /**
- + * Returns the team id of a player, if player is not participant it returns -1
- + * @param playerObjectId
- + * @return byte: team name of the given playerName, if not in event -1
- + */
- + public static byte getParticipantTeamId(int playerObjectId)
- + {
- + return (byte) (_teams[0].containsPlayer(playerObjectId) ? 0 : (_teams[1].containsPlayer(playerObjectId) ? 1 : -1));
- + }
- +
- + /**
- + * Returns the team of a player, if player is not participant it returns null
- + * @param playerObjectId
- + * @return TvTEventTeam: team of the given playerObjectId, if not in event null
- + */
- + public static TvTEventTeam getParticipantTeam(int playerObjectId)
- + {
- + return _teams[0].containsPlayer(playerObjectId) ? _teams[0] : (_teams[1].containsPlayer(playerObjectId) ? _teams[1] : null);
- + }
- +
- + /**
- + * Returns the enemy team of a player, if player is not participant it returns null
- + * @param playerObjectId
- + * @return TvTEventTeam: enemy team of the given playerObjectId, if not in event null
- + */
- + public static TvTEventTeam getParticipantEnemyTeam(int playerObjectId)
- + {
- + return (_teams[0].containsPlayer(playerObjectId) ? _teams[1] : (_teams[1].containsPlayer(playerObjectId) ? _teams[0] : null));
- + }
- +
- + /**
- + * Returns the team coordinates in which the player is in, if player is not in a team return null
- + * @param playerObjectId
- + * @return int[]: coordinates of teams, 2 elements, index 0 for team 1 and index 1 for team 2
- + */
- + public static int[] getParticipantTeamCoordinates(int playerObjectId)
- + {
- + return _teams[0].containsPlayer(playerObjectId) ? _teams[0].getCoordinates() : (_teams[1].containsPlayer(playerObjectId) ? _teams[1].getCoordinates() : null);
- + }
- +
- + /**
- + * Is given player participant of the event?
- + * @param playerObjectId
- + * @return boolean: true if player is participant, ohterwise false
- + */
- + public static boolean isPlayerParticipant(int playerObjectId)
- + {
- + return (isParticipating() || isStarting() || isStarted()) && (_teams[0].containsPlayer(playerObjectId) || _teams[1].containsPlayer(playerObjectId));
- + }
- +
- + /**
- + * Returns participated player count
- + * @return int: amount of players registered in the event
- + */
- + public static int getParticipatedPlayersCount()
- + {
- + return !isParticipating() && !isStarting() && !isStarted() ? 0 : _teams[0].getParticipatedPlayerCount() + _teams[1].getParticipatedPlayerCount();
- + }
- +
- + /**
- + * Returns teams names
- + * @return String[]: names of teams, 2 elements, index 0 for team 1 and index 1 for team 2
- + */
- + public static String[] getTeamNames()
- + {
- + return new String[]
- + {
- + _teams[0].getName(),
- + _teams[1].getName()
- + };
- + }
- +
- + /**
- + * Returns player count of both teams
- + * @return int[]: player count of teams, 2 elements, index 0 for team 1 and index 1 for team 2
- + */
- + public static int[] getTeamsPlayerCounts()
- + {
- + return new int[]
- + {
- + _teams[0].getParticipatedPlayerCount(),
- + _teams[1].getParticipatedPlayerCount()
- + };
- + }
- +
- + /**
- + * Returns points count of both teams
- + * @return int[]: points of teams, 2 elements, index 0 for team 1 and index 1 for team 2
- + */
- + public static int[] getTeamsPoints()
- + {
- + return new int[]
- + {
- + _teams[0].getPoints(),
- + _teams[1].getPoints()
- + };
- + }
- +
- + public static int getTvTEventInstance()
- + {
- + return _TvTEventInstance;
- + }
- +}
- diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/instancemanager/events/TvTEventListener.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/instancemanager/events/TvTEventListener.java
- new file mode 100644
- index 0000000..2af0e3f
- --- /dev/null
- +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/instancemanager/events/TvTEventListener.java
- @@ -0,0 +1,63 @@
- +/*
- + * This file is part of the L2J Mobius project.
- + *
- + * 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 org.l2jmobius.gameserver.instancemanager.events;
- +
- +import org.l2jmobius.gameserver.model.actor.Player;
- +import org.l2jmobius.gameserver.model.interfaces.IEventListener;
- +
- +/**
- + * @author UnAfraid
- + */
- +public class TvTEventListener implements IEventListener
- +{
- + private final Player _player;
- +
- + protected TvTEventListener(Player player)
- + {
- + _player = player;
- + }
- +
- + @Override
- + public boolean isOnEvent()
- + {
- + return TvTEvent.isStarted() && TvTEvent.isPlayerParticipant(_player.getObjectId());
- + }
- +
- + @Override
- + public boolean isBlockingExit()
- + {
- + return true;
- + }
- +
- + @Override
- + public boolean isBlockingDeathPenalty()
- + {
- + return true;
- + }
- +
- + @Override
- + public boolean canRevive()
- + {
- + return false;
- + }
- +
- + @Override
- + public Player getPlayer()
- + {
- + return _player;
- + }
- +}
- diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/instancemanager/events/TvTEventPlayer.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/instancemanager/events/TvTEventPlayer.java
- new file mode 100644
- index 0000000..692b4b8
- --- /dev/null
- +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/instancemanager/events/TvTEventPlayer.java
- @@ -0,0 +1,57 @@
- +/*
- + * This file is part of the L2J Mobius project.
- + *
- + * 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 org.l2jmobius.gameserver.instancemanager.events;
- +
- +import org.l2jmobius.gameserver.model.actor.Player;
- +
- +/**
- + * @author UnAfraid
- + */
- +public class TvTEventPlayer
- +{
- + private final Player _player;
- +
- + protected TvTEventPlayer(Player player)
- + {
- + _player = player;
- + }
- +
- + public boolean isOnEvent()
- + {
- + return TvTEvent.isStarted() && TvTEvent.isPlayerParticipant(_player.getObjectId());
- + }
- +
- + public boolean isBlockingExit()
- + {
- + return true;
- + }
- +
- + public boolean isBlockingDeathPenalty()
- + {
- + return true;
- + }
- +
- + public boolean canRevive()
- + {
- + return false;
- + }
- +
- + public Player getPlayer()
- + {
- + return _player;
- + }
- +}
- diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/instancemanager/events/TvTEventTeam.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/instancemanager/events/TvTEventTeam.java
- new file mode 100644
- index 0000000..49a7953
- --- /dev/null
- +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/instancemanager/events/TvTEventTeam.java
- @@ -0,0 +1,153 @@
- +/*
- + * This file is part of the L2J Mobius project.
- + *
- + * 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 org.l2jmobius.gameserver.instancemanager.events;
- +
- +import java.util.Map;
- +import java.util.concurrent.ConcurrentHashMap;
- +
- +import org.l2jmobius.gameserver.model.actor.Player;
- +
- +/**
- + * @author HorridoJoho
- + */
- +public class TvTEventTeam
- +{
- + /**
- + * The name of the team
- + */
- + private final String _name;
- + /**
- + * The team spot coordinated
- + */
- + private int[] _coordinates = new int[3];
- + /**
- + * The points of the team
- + */
- + private short _points;
- + /** Name and instance of all participated players in map. */
- + private final Map<Integer, Player> _participatedPlayers = new ConcurrentHashMap<>();
- +
- + /**
- + * C'tor initialize the team
- + * @param name as String
- + * @param coordinates as int[]
- + */
- + public TvTEventTeam(String name, int[] coordinates)
- + {
- + _name = name;
- + _coordinates = coordinates;
- + _points = 0;
- + }
- +
- + /**
- + * Adds a player to the team
- + * @param Player as Player
- + * @return boolean: true if success, otherwise false
- + */
- + public boolean addPlayer(Player Player)
- + {
- + if (Player == null)
- + {
- + return false;
- + }
- +
- + _participatedPlayers.put(Player.getObjectId(), Player);
- +
- + return true;
- + }
- +
- + /**
- + * Removes a player from the team
- + * @param playerObjectId
- + */
- + public void removePlayer(int playerObjectId)
- + {
- + _participatedPlayers.remove(playerObjectId);
- + }
- +
- + /**
- + * Increases the points of the team
- + */
- + public void increasePoints()
- + {
- + ++_points;
- + }
- +
- + /**
- + * Cleanup the team and make it ready for adding players again
- + */
- + public void cleanMe()
- + {
- + _participatedPlayers.clear();
- + _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)
- + {
- + return _participatedPlayers.containsKey(playerObjectId);
- + }
- +
- + /**
- + * Returns the name of the team
- + * @return String: name of the team
- + */
- + public String getName()
- + {
- + return _name;
- + }
- +
- + /**
- + * Returns the coordinates of the team spot
- + * @return int[]: team coordinates
- + */
- + public int[] getCoordinates()
- + {
- + return _coordinates;
- + }
- +
- + /**
- + * Returns the points of the team
- + * @return short: team points
- + */
- + public short getPoints()
- + {
- + return _points;
- + }
- +
- + /**
- + * Returns name and instance of all participated players in Map
- + * @return Map<String, Player>: map of players in this team
- + */
- + public Map<Integer, Player> getParticipatedPlayers()
- + {
- + return _participatedPlayers;
- + }
- +
- + /**
- + * Returns player count of this team
- + * @return int: number of players in team
- + */
- + public int getParticipatedPlayerCount()
- + {
- + return _participatedPlayers.size();
- + }
- +}
- diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/instancemanager/events/TvTEventTeleporter.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/instancemanager/events/TvTEventTeleporter.java
- new file mode 100644
- index 0000000..1ba695b
- --- /dev/null
- +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/instancemanager/events/TvTEventTeleporter.java
- @@ -0,0 +1,137 @@
- +/*
- + * This file is part of the L2J Mobius project.
- + *
- + * 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 org.l2jmobius.gameserver.instancemanager.events;
- +
- +import org.l2jmobius.Config;
- +import org.l2jmobius.commons.threads.ThreadPool;
- +import org.l2jmobius.commons.util.Rnd;
- +import org.l2jmobius.gameserver.enums.Team;
- +import org.l2jmobius.gameserver.model.Duel;
- +import org.l2jmobius.gameserver.model.actor.Player;
- +import org.l2jmobius.gameserver.model.actor.Summon;
- +
- +public class TvTEventTeleporter implements Runnable
- +{
- + /** The instance of the player to teleport */
- + private Player _Player = 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 Player
- + * @param coordinates
- + * @param fastSchedule
- + * @param adminRemove
- + */
- + public TvTEventTeleporter(Player Player, int[] coordinates, boolean fastSchedule, boolean adminRemove)
- + {
- + _Player = Player;
- + _coordinates = coordinates;
- + _adminRemove = adminRemove;
- + ThreadPool.schedule(this, fastSchedule ? 0 : (TvTEvent.isStarted() ? Config.TVT_EVENT_RESPAWN_TELEPORT_DELAY : Config.TVT_EVENT_START_LEAVE_TELEPORT_DELAY) * 1000);
- + }
- +
- + /**
- + * 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
- + */
- + @Override
- + public void run()
- + {
- + if (_Player == null)
- + {
- + return;
- + }
- +
- + final Summon summon = _Player.getSummon();
- + if (summon != null)
- + {
- + summon.unSummon(_Player);
- + }
- +
- + if ((Config.TVT_EVENT_EFFECTS_REMOVAL == 0) || ((Config.TVT_EVENT_EFFECTS_REMOVAL == 1) && ((_Player.getTeam() == Team.NONE) || (_Player.isInDuel() && (_Player.getDuelState() != Duel.DUELSTATE_INTERRUPTED)))))
- + {
- + _Player.stopAllEffectsExceptThoseThatLastThroughDeath();
- + }
- +
- + if (_Player.isInDuel())
- + {
- + _Player.setDuelState(Duel.DUELSTATE_INTERRUPTED);
- + }
- +
- + final int TvTInstance = TvTEvent.getTvTEventInstance();
- + if (TvTInstance != 0)
- + {
- + if (TvTEvent.isStarted() && !_adminRemove)
- + {
- + _Player.setInstanceId(TvTInstance);
- + }
- + else
- + {
- + _Player.setInstanceId(0);
- + }
- + }
- + else
- + {
- + _Player.setInstanceId(0);
- + }
- +
- + _Player.doRevive();
- +
- + _Player.teleToLocation((_coordinates[0] + Rnd.get(101)) - 50, (_coordinates[1] + Rnd.get(101)) - 50, _coordinates[2], false);
- + if (TvTEvent.isStarted() && !_adminRemove)
- + {
- + final int teamId = TvTEvent.getParticipantTeamId(_Player.getObjectId()) + 1;
- + switch (teamId)
- + {
- + case 0:
- + {
- + _Player.setTeam(Team.NONE);
- + break;
- + }
- + case 1:
- + {
- + _Player.setTeam(Team.BLUE);
- + break;
- + }
- + case 2:
- + {
- + _Player.setTeam(Team.RED);
- + break;
- + }
- + }
- + }
- + else
- + {
- + _Player.setTeam(Team.NONE);
- + }
- +
- + _Player.setCurrentCp(_Player.getMaxCp());
- + _Player.setCurrentHp(_Player.getMaxHp());
- + _Player.setCurrentMp(_Player.getMaxMp());
- +
- + _Player.broadcastStatusUpdate();
- + _Player.broadcastUserInfo();
- + }
- +}
- diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/instancemanager/events/TvTManager.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/instancemanager/events/TvTManager.java
- new file mode 100644
- index 0000000..9806f64
- --- /dev/null
- +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/instancemanager/events/TvTManager.java
- @@ -0,0 +1,287 @@
- +/*
- + * This file is part of the L2J Mobius project.
- + *
- + * 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 org.l2jmobius.gameserver.instancemanager.events;
- +
- +import java.util.Calendar;
- +import java.util.concurrent.ScheduledFuture;
- +import java.util.logging.Logger;
- +
- +import org.l2jmobius.Config;
- +import org.l2jmobius.commons.threads.ThreadPool;
- +import org.l2jmobius.gameserver.util.Broadcast;
- +
- +/**
- + * @author HorridoJoho
- + */
- +public class TvTManager
- +{
- + protected static final Logger LOGGER = Logger.getLogger(TvTManager.class.getName());
- +
- + /**
- + * Task for event cycles
- + */
- + private TvTStartTask _task;
- +
- + /**
- + * New instance only by getInstance()
- + */
- + protected TvTManager()
- + {
- + if (Config.TVT_EVENT_ENABLED)
- + {
- + TvTEvent.init();
- +
- + scheduleEventStart();
- + LOGGER.info("TvTEventEngine[TvTManager.TvTManager()]: Started.");
- + }
- + else
- + {
- + LOGGER.info("TvTEventEngine[TvTManager.TvTManager()]: Engine is disabled.");
- + }
- + }
- +
- + /**
- + * Initialize new/Returns the one and only instance
- + * @return TvTManager
- + */
- + public static TvTManager getInstance()
- + {
- + return SingletonHolder.INSTANCE;
- + }
- +
- + /**
- + * Starts TvTStartTask
- + */
- + public void scheduleEventStart()
- + {
- + try
- + {
- + final Calendar currentTime = Calendar.getInstance();
- + Calendar nextStartTime = null;
- + Calendar testStartTime = null;
- + for (String timeOfDay : Config.TVT_EVENT_INTERVAL)
- + {
- + // Creating a Calendar object from the specified interval value
- + testStartTime = Calendar.getInstance();
- + testStartTime.setLenient(true);
- + final 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;
- + }
- + }
- + if (nextStartTime != null)
- + {
- + _task = new TvTStartTask(nextStartTime.getTimeInMillis());
- + ThreadPool.execute(_task);
- + }
- + }
- + catch (Exception e)
- + {
- + LOGGER.warning("TvTEventEngine[TvTManager.scheduleEventStart()]: Error figuring out a start time. Check TvTEventInterval in config file.");
- + }
- + }
- +
- + /**
- + * Method to start participation
- + */
- + public void startReg()
- + {
- + if (!TvTEvent.startParticipation())
- + {
- + Broadcast.toAllOnlinePlayers("TvT Event: Event was cancelled.");
- + LOGGER.warning("TvTEventEngine[TvTManager.run()]: Error spawning event npc for participation.");
- + scheduleEventStart();
- + }
- + else
- + {
- + Broadcast.toAllOnlinePlayers("TvT Event: Registration opened for " + Config.TVT_EVENT_PARTICIPATION_TIME + " minute(s).");
- +
- + // schedule registration end
- + _task.setStartTime(System.currentTimeMillis() + (60000 * Config.TVT_EVENT_PARTICIPATION_TIME));
- + ThreadPool.execute(_task);
- + }
- + }
- +
- + /**
- + * Method to start the fight
- + */
- + public void startEvent()
- + {
- + if (!TvTEvent.startFight())
- + {
- + Broadcast.toAllOnlinePlayers("TvT Event: Event cancelled due to lack of Participation.");
- + LOGGER.info("TvTEventEngine[TvTManager.run()]: Lack of registration, abort event.");
- + scheduleEventStart();
- + }
- + else
- + {
- + TvTEvent.sysMsgToAllParticipants("TvT Event: Teleporting participants to an arena in " + Config.TVT_EVENT_START_LEAVE_TELEPORT_DELAY + " second(s).");
- + _task.setStartTime(System.currentTimeMillis() + (60000 * Config.TVT_EVENT_RUNNING_TIME));
- + ThreadPool.execute(_task);
- + }
- + }
- +
- + /**
- + * Method to end the event and reward
- + */
- + public void endEvent()
- + {
- + Broadcast.toAllOnlinePlayers(TvTEvent.calculateRewards());
- + TvTEvent.sysMsgToAllParticipants("TvT Event: Teleporting back to the registration npc in " + Config.TVT_EVENT_START_LEAVE_TELEPORT_DELAY + " second(s).");
- + TvTEvent.stopFight();
- +
- + scheduleEventStart();
- + }
- +
- + public void skipDelay()
- + {
- + if (_task.nextRun.cancel(false))
- + {
- + _task.setStartTime(System.currentTimeMillis());
- + ThreadPool.execute(_task);
- + }
- + }
- +
- + /**
- + * Class for TvT cycles
- + */
- + class TvTStartTask implements Runnable
- + {
- + private long _startTime;
- + public ScheduledFuture<?> nextRun;
- +
- + public TvTStartTask(long startTime)
- + {
- + _startTime = startTime;
- + }
- +
- + public void setStartTime(long startTime)
- + {
- + _startTime = startTime;
- + }
- +
- + @Override
- + public void run()
- + {
- + final int delay = (int) Math.round((_startTime - System.currentTimeMillis()) / 1000.0);
- + if (delay > 0)
- + {
- + announce(delay);
- + }
- +
- + int nextMsg = 0;
- + if (delay > 3600)
- + {
- + nextMsg = delay - 3600;
- + }
- + else if (delay > 1800)
- + {
- + nextMsg = delay - 1800;
- + }
- + else if (delay > 900)
- + {
- + nextMsg = delay - 900;
- + }
- + else if (delay > 600)
- + {
- + nextMsg = delay - 600;
- + }
- + else if (delay > 300)
- + {
- + nextMsg = delay - 300;
- + }
- + else if (delay > 60)
- + {
- + nextMsg = delay - 60;
- + }
- + else if (delay > 5)
- + {
- + nextMsg = delay - 5;
- + }
- + else if (delay > 0)
- + {
- + nextMsg = delay;
- + }
- + // start
- + else if (TvTEvent.isInactive())
- + {
- + startReg();
- + }
- + else if (TvTEvent.isParticipating())
- + {
- + startEvent();
- + }
- + else
- + {
- + endEvent();
- + }
- +
- + if (delay > 0)
- + {
- + nextRun = ThreadPool.schedule(this, nextMsg * 1000);
- + }
- + }
- +
- + private void announce(long time)
- + {
- + if ((time >= 3600) && ((time % 3600) == 0))
- + {
- + if (TvTEvent.isParticipating())
- + {
- + Broadcast.toAllOnlinePlayers("TvT Event: " + (time / 60 / 60) + " hour(s) until registration is closed!");
- + }
- + else if (TvTEvent.isStarted())
- + {
- + TvTEvent.sysMsgToAllParticipants("TvT Event: " + (time / 60 / 60) + " hour(s) until event is finished!");
- + }
- + }
- + else if (time >= 60)
- + {
- + if (TvTEvent.isParticipating())
- + {
- + Broadcast.toAllOnlinePlayers("TvT Event: " + (time / 60) + " minute(s) until registration is closed!");
- + }
- + else if (TvTEvent.isStarted())
- + {
- + TvTEvent.sysMsgToAllParticipants("TvT Event: " + (time / 60) + " minute(s) until the event is finished!");
- + }
- + }
- + else if (TvTEvent.isParticipating())
- + {
- + Broadcast.toAllOnlinePlayers("TvT Event: " + time + " second(s) until registration is closed!");
- + }
- + else if (TvTEvent.isStarted())
- + {
- + TvTEvent.sysMsgToAllParticipants("TvT Event: " + time + " second(s) until the event is finished!");
- + }
- + }
- + }
- +
- + private static class SingletonHolder
- + {
- + protected static final TvTManager INSTANCE = new TvTManager();
- + }
- +}
- diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/Npc.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/Npc.java
- index 5e6042b..4e8eddd 100644
- --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/Npc.java
- +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/Npc.java
- @@ -128,6 +128,7 @@
- /** The fortress index in the array of Fort this Npc belongs to */
- private int _fortIndex = -2;
- private boolean _isInTown = false;
- + private boolean _eventMob = false;
- /** True if this Npc is autoattackable **/
- private boolean _isAutoAttackable = false;
- /** Time of last social packet broadcast */
- @@ -2090,4 +2091,14 @@
- sb.append("]");
- return sb.toString();
- }
- +
- + public boolean isEventMob()
- + {
- + return _eventMob;
- + }
- +
- + public void setEventMob(boolean value)
- + {
- + _eventMob = value;
- + }
- }
- diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/Player.java
- index ec575d7..bd517ee 100644
- --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/Player.java
- +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/Player.java
- @@ -119,6 +119,8 @@
- import org.l2jmobius.gameserver.instancemanager.SiegeManager;
- import org.l2jmobius.gameserver.instancemanager.TerritoryWarManager;
- import org.l2jmobius.gameserver.instancemanager.ZoneManager;
- +import org.l2jmobius.gameserver.instancemanager.events.GameEvent;
- +import org.l2jmobius.gameserver.instancemanager.events.TvTEvent;
- import org.l2jmobius.gameserver.model.AccessLevel;
- import org.l2jmobius.gameserver.model.ArenaParticipantsHolder;
- import org.l2jmobius.gameserver.model.BlockList;
- @@ -208,6 +210,7 @@
- import org.l2jmobius.gameserver.model.holders.AdditionalSkillHolder;
- import org.l2jmobius.gameserver.model.holders.ItemHolder;
- import org.l2jmobius.gameserver.model.holders.MovieHolder;
- +import org.l2jmobius.gameserver.model.holders.PlayerEventHolder;
- import org.l2jmobius.gameserver.model.holders.SellBuffHolder;
- import org.l2jmobius.gameserver.model.holders.SkillHolder;
- import org.l2jmobius.gameserver.model.holders.SkillUseHolder;
- @@ -747,6 +752,9 @@
- protected Set<Integer> _activeSoulShots = ConcurrentHashMap.newKeySet(1);
- /** Event parameters */
- + private PlayerEventHolder eventStatus = null;
- +
- + /** Event parameters */
- private boolean _isRegisteredOnEvent = false;
- private boolean _isOnSoloEvent = false;
- private boolean _isOnEvent = false;
- @@ -5000,9 +5008,12 @@
- {
- if (pk != null)
- {
- - if (EventDispatcher.getInstance().hasListener(EventType.ON_PLAYER_PVP_KILL, this))
- + EventDispatcher.getInstance().notifyEventAsync(new OnPlayerPvPKill(pk, this), this);
- + TvTEvent.onKill(killer, this);
- +
- + if (GameEvent.isParticipant(pk))
- {
- - EventDispatcher.getInstance().notifyEventAsync(new OnPlayerPvPKill(pk, this), this);
- + pk.getEventStatus().getKills().add(this);
- }
- // pvp/pk item rewards
- @@ -14005,6 +14114,21 @@
- return _contactList;
- }
- + public void setEventStatus()
- + {
- + eventStatus = new PlayerEventHolder(this);
- + }
- +
- + public void setEventStatus(PlayerEventHolder pes)
- + {
- + eventStatus = pes;
- + }
- +
- + public PlayerEventHolder getEventStatus()
- + {
- + return eventStatus;
- + }
- +
- public long getNotMoveUntil()
- {
- return _notMoveUntil;
- diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerCallPc.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerCallPc.java
- index 90bb4fe..d6527f0 100644
- --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerCallPc.java
- +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerCallPc.java
- @@ -16,6 +16,7 @@
- */
- package org.l2jmobius.gameserver.model.conditions;
- +import org.l2jmobius.gameserver.instancemanager.events.TvTEvent;
- import org.l2jmobius.gameserver.model.actor.Creature;
- import org.l2jmobius.gameserver.model.actor.Player;
- import org.l2jmobius.gameserver.model.item.ItemTemplate;
- @@ -54,7 +55,7 @@
- {
- canCallPlayer = false;
- }
- - else if (player.isOnEvent())
- + else if (!TvTEvent.onEscapeUse(player.getObjectId()))
- {
- player.sendPacket(SystemMessageId.YOUR_TARGET_IS_IN_AN_AREA_WHICH_BLOCKS_SUMMONING);
- canCallPlayer = false;
- diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerCanEscape.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerCanEscape.java
- index 591bbf1..eed4f5f 100644
- --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerCanEscape.java
- +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerCanEscape.java
- @@ -18,6 +18,7 @@
- import org.l2jmobius.gameserver.enums.PlayerCondOverride;
- import org.l2jmobius.gameserver.instancemanager.GrandBossManager;
- +import org.l2jmobius.gameserver.instancemanager.events.TvTEvent;
- import org.l2jmobius.gameserver.model.actor.Creature;
- import org.l2jmobius.gameserver.model.actor.Player;
- import org.l2jmobius.gameserver.model.item.ItemTemplate;
- @@ -45,7 +46,7 @@
- {
- canTeleport = false;
- }
- - else if (player.isOnEvent())
- + else if (!TvTEvent.onEscapeUse(player.getObjectId()))
- {
- canTeleport = false;
- }
- diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerTvTEvent.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerTvTEvent.java
- new file mode 100644
- index 0000000..493aab9
- --- /dev/null
- +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerTvTEvent.java
- @@ -0,0 +1,47 @@
- +/*
- + * This file is part of the L2J Mobius project.
- + *
- + * 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 org.l2jmobius.gameserver.model.conditions;
- +
- +import org.l2jmobius.gameserver.instancemanager.events.TvTEvent;
- +import org.l2jmobius.gameserver.model.actor.Creature;
- +import org.l2jmobius.gameserver.model.actor.Player;
- +import org.l2jmobius.gameserver.model.item.ItemTemplate;
- +import org.l2jmobius.gameserver.model.skill.Skill;
- +
- +/**
- + * The Class ConditionPlayerTvTEvent.
- + */
- +public class ConditionPlayerTvTEvent extends Condition
- +{
- + private final boolean _value;
- +
- + /**
- + * Instantiates a new condition player tv t event.
- + * @param value the value
- + */
- + public ConditionPlayerTvTEvent(boolean value)
- + {
- + _value = value;
- + }
- +
- + @Override
- + public boolean testImpl(Creature effector, Creature effected, Skill skill, ItemTemplate item)
- + {
- + final Player player = effector.getActingPlayer();
- + return (player == null) || !TvTEvent.isStarted() ? !_value : TvTEvent.isPlayerParticipant(player.getObjectId()) == _value;
- + }
- +}
- diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/events/EventType.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/events/EventType.java
- index d8f84b7..7b913c5 100644
- --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/events/EventType.java
- +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/events/EventType.java
- @@ -92,6 +92,10 @@
- import org.l2jmobius.gameserver.model.events.impl.creature.player.inventory.OnPlayerItemPickup;
- import org.l2jmobius.gameserver.model.events.impl.creature.player.inventory.OnPlayerItemTransfer;
- import org.l2jmobius.gameserver.model.events.impl.creature.trap.OnTrapAction;
- +import org.l2jmobius.gameserver.model.events.impl.events.OnTvTEventFinish;
- +import org.l2jmobius.gameserver.model.events.impl.events.OnTvTEventKill;
- +import org.l2jmobius.gameserver.model.events.impl.events.OnTvTEventRegistrationStart;
- +import org.l2jmobius.gameserver.model.events.impl.events.OnTvTEventStart;
- import org.l2jmobius.gameserver.model.events.impl.item.OnItemBypassEvent;
- import org.l2jmobius.gameserver.model.events.impl.item.OnItemCreate;
- import org.l2jmobius.gameserver.model.events.impl.item.OnItemTalk;
- @@ -220,6 +224,12 @@
- // Trap events
- ON_TRAP_ACTION(OnTrapAction.class, void.class),
- + // TvT events.
- + ON_TVT_EVENT_FINISH(OnTvTEventFinish.class, void.class),
- + ON_TVT_EVENT_KILL(OnTvTEventKill.class, void.class),
- + ON_TVT_EVENT_REGISTRATION_START(OnTvTEventRegistrationStart.class, void.class),
- + ON_TVT_EVENT_START(OnTvTEventStart.class, void.class),
- +
- // Server events
- ON_SERVER_START(OnServerStart.class, void.class);
- diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/events/impl/events/OnTvTEventFinish.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/events/impl/events/OnTvTEventFinish.java
- new file mode 100644
- index 0000000..b20449d
- --- /dev/null
- +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/events/impl/events/OnTvTEventFinish.java
- @@ -0,0 +1,32 @@
- +/*
- + * This file is part of the L2J Mobius project.
- + *
- + * 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 org.l2jmobius.gameserver.model.events.impl.events;
- +
- +import org.l2jmobius.gameserver.model.events.EventType;
- +import org.l2jmobius.gameserver.model.events.impl.IBaseEvent;
- +
- +/**
- + * @author UnAfraid
- + */
- +public class OnTvTEventFinish implements IBaseEvent
- +{
- + @Override
- + public EventType getType()
- + {
- + return EventType.ON_TVT_EVENT_FINISH;
- + }
- +}
- diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/events/impl/events/OnTvTEventKill.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/events/impl/events/OnTvTEventKill.java
- new file mode 100644
- index 0000000..15900f2
- --- /dev/null
- +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/events/impl/events/OnTvTEventKill.java
- @@ -0,0 +1,60 @@
- +/*
- + * This file is part of the L2J Mobius project.
- + *
- + * 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 org.l2jmobius.gameserver.model.events.impl.events;
- +
- +import org.l2jmobius.gameserver.instancemanager.events.TvTEventTeam;
- +import org.l2jmobius.gameserver.model.actor.Player;
- +import org.l2jmobius.gameserver.model.events.EventType;
- +import org.l2jmobius.gameserver.model.events.impl.IBaseEvent;
- +
- +/**
- + * @author UnAfraid
- + */
- +public class OnTvTEventKill implements IBaseEvent
- +{
- + private final Player _killer;
- + private final Player _victim;
- + private final TvTEventTeam _killerTeam;
- +
- + public OnTvTEventKill(Player killer, Player victim, TvTEventTeam killerTeam)
- + {
- + _killer = killer;
- + _victim = victim;
- + _killerTeam = killerTeam;
- + }
- +
- + public Player getKiller()
- + {
- + return _killer;
- + }
- +
- + public Player getVictim()
- + {
- + return _victim;
- + }
- +
- + public TvTEventTeam getKillerTeam()
- + {
- + return _killerTeam;
- + }
- +
- + @Override
- + public EventType getType()
- + {
- + return EventType.ON_TVT_EVENT_KILL;
- + }
- +}
- diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/events/impl/events/OnTvTEventRegistrationStart.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/events/impl/events/OnTvTEventRegistrationStart.java
- new file mode 100644
- index 0000000..383858c
- --- /dev/null
- +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/events/impl/events/OnTvTEventRegistrationStart.java
- @@ -0,0 +1,32 @@
- +/*
- + * This file is part of the L2J Mobius project.
- + *
- + * 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 org.l2jmobius.gameserver.model.events.impl.events;
- +
- +import org.l2jmobius.gameserver.model.events.EventType;
- +import org.l2jmobius.gameserver.model.events.impl.IBaseEvent;
- +
- +/**
- + * @author UnAfraid
- + */
- +public class OnTvTEventRegistrationStart implements IBaseEvent
- +{
- + @Override
- + public EventType getType()
- + {
- + return EventType.ON_TVT_EVENT_REGISTRATION_START;
- + }
- +}
- diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/events/impl/events/OnTvTEventStart.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/events/impl/events/OnTvTEventStart.java
- new file mode 100644
- index 0000000..7f9293c
- --- /dev/null
- +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/events/impl/events/OnTvTEventStart.java
- @@ -0,0 +1,32 @@
- +/*
- + * This file is part of the L2J Mobius project.
- + *
- + * 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 org.l2jmobius.gameserver.model.events.impl.events;
- +
- +import org.l2jmobius.gameserver.model.events.EventType;
- +import org.l2jmobius.gameserver.model.events.impl.IBaseEvent;
- +
- +/**
- + * @author UnAfraid
- + */
- +public class OnTvTEventStart implements IBaseEvent
- +{
- + @Override
- + public EventType getType()
- + {
- + return EventType.ON_TVT_EVENT_START;
- + }
- +}
- diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/holders/PlayerEventHolder.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/holders/PlayerEventHolder.java
- new file mode 100644
- index 0000000..637ed7c
- --- /dev/null
- +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/holders/PlayerEventHolder.java
- @@ -0,0 +1,98 @@
- +/*
- + * This file is part of the L2J Mobius project.
- + *
- + * 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 org.l2jmobius.gameserver.model.holders;
- +
- +import java.util.Collection;
- +import java.util.concurrent.ConcurrentHashMap;
- +
- +import org.l2jmobius.gameserver.data.sql.ClanTable;
- +import org.l2jmobius.gameserver.model.Location;
- +import org.l2jmobius.gameserver.model.actor.Player;
- +
- +/**
- + * Player event holder, meant for restoring player after event has finished.<br>
- + * Allows you to restore following information about player:
- + * <ul>
- + * <li>Name</li>
- + * <li>Title</li>
- + * <li>Clan</li>
- + * <li>Location</li>
- + * <li>PvP Kills</li>
- + * <li>PK Kills</li>
- + * <li>Karma</li>
- + * </ul>
- + * @author Nik, xban1x
- + */
- +public class PlayerEventHolder
- +{
- + private final Player _player;
- + private final String _name;
- + private final String _title;
- + private final int _clanId;
- + private final Location _loc;
- + private final int _pvpKills;
- + private final int _pkKills;
- + private final int _karma;
- +
- + private final Collection<Player> _kills = ConcurrentHashMap.newKeySet();
- + private boolean _sitForced;
- +
- + public PlayerEventHolder(Player player)
- + {
- + this(player, false);
- + }
- +
- + public PlayerEventHolder(Player player, boolean sitForced)
- + {
- + _player = player;
- + _name = player.getName();
- + _title = player.getTitle();
- + _clanId = player.getClanId();
- + _loc = new Location(player);
- + _pvpKills = player.getPvpKills();
- + _pkKills = player.getPkKills();
- + _karma = player.getKarma();
- + _sitForced = sitForced;
- + }
- +
- + public void restorePlayerStats()
- + {
- + _player.setName(_name);
- + _player.setTitle(_title);
- + _player.setClan(ClanTable.getInstance().getClan(_clanId));
- + _player.teleToLocation(_loc, true);
- + _player.setPvpKills(_pvpKills);
- + _player.setPkKills(_pkKills);
- + _player.setKarma(_karma);
- +
- + }
- +
- + public void setSitForced(boolean sitForced)
- + {
- + _sitForced = sitForced;
- + }
- +
- + public boolean isSitForced()
- + {
- + return _sitForced;
- + }
- +
- + public Collection<Player> getKills()
- + {
- + return _kills;
- + }
- +}
- diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/interfaces/IEventListener.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/interfaces/IEventListener.java
- index 9d9191e..fa1cf40 100644
- --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/interfaces/IEventListener.java
- +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/interfaces/IEventListener.java
- @@ -39,4 +39,10 @@
- boolean canRevive();
- Player getPlayer();
- +
- + /**
- + * @return {@code true} if player is on event, {@code false} otherwise.
- + */
- + boolean isOnEvent();
- +
- }
- diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/olympiad/AbstractOlympiadGame.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/olympiad/AbstractOlympiadGame.java
- index 4850fb5..b25fab5 100644
- --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/olympiad/AbstractOlympiadGame.java
- +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/olympiad/AbstractOlympiadGame.java
- @@ -26,6 +26,7 @@
- import org.l2jmobius.gameserver.instancemanager.AntiFeedManager;
- import org.l2jmobius.gameserver.instancemanager.CastleManager;
- import org.l2jmobius.gameserver.instancemanager.FortManager;
- +import org.l2jmobius.gameserver.instancemanager.events.TvTEvent;
- import org.l2jmobius.gameserver.model.Location;
- import org.l2jmobius.gameserver.model.Party;
- import org.l2jmobius.gameserver.model.actor.Creature;
- @@ -123,7 +124,7 @@
- }
- // safety precautions
- - if (player.inObserverMode() || player.isRegisteredOnEvent())
- + if (player.inObserverMode() || TvTEvent.isPlayerParticipant(player.getObjectId()))
- {
- return new SystemMessage(SystemMessageId.YOUR_OPPONENT_DOES_NOT_MEET_THE_REQUIREMENTS_TO_DO_BATTLE_THE_MATCH_HAS_BEEN_CANCELLED);
- }
- diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/olympiad/OlympiadManager.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/olympiad/OlympiadManager.java
- index 0f8635c..5df2b1e 100644
- --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/olympiad/OlympiadManager.java
- +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/olympiad/OlympiadManager.java
- @@ -487,9 +487,9 @@
- }
- final int charId = noble.getObjectId();
- - if (noble.isRegisteredOnEvent())
- + if (noble.isOnEvent())
- {
- - player.sendMessage("You can't join olympiad while participating on an event.");
- + player.sendMessage("You can't join olympiad while participating on TvT Event.");
- return false;
- }
- diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/skill/Skill.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/skill/Skill.java
- index 905b723..7884aac 100644
- --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/skill/Skill.java
- +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/skill/Skill.java
- @@ -39,6 +39,7 @@
- import org.l2jmobius.gameserver.geoengine.GeoEngine;
- import org.l2jmobius.gameserver.handler.ITargetTypeHandler;
- import org.l2jmobius.gameserver.handler.TargetHandler;
- +import org.l2jmobius.gameserver.instancemanager.events.TvTEvent;
- import org.l2jmobius.gameserver.model.ExtractableProductItem;
- import org.l2jmobius.gameserver.model.ExtractableSkill;
- import org.l2jmobius.gameserver.model.StatSet;
- @@ -1131,6 +1132,11 @@
- return false;
- }
- + if (!TvTEvent.checkForTvTSkill(player, targetPlayer, skill))
- + {
- + return false;
- + }
- +
- if (!sourceInArena && !(targetPlayer.isInsideZone(ZoneId.PVP) && !targetPlayer.isInsideZone(ZoneId.SIEGE)))
- {
- if ((player.getAllyId() != 0) && (player.getAllyId() == targetPlayer.getAllyId()))
- diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java
- index 09c48ae..2b01d68 100644
- --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java
- +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java
- @@ -48,6 +48,7 @@
- import org.l2jmobius.gameserver.instancemanager.ServerRestartManager;
- import org.l2jmobius.gameserver.instancemanager.SiegeManager;
- import org.l2jmobius.gameserver.instancemanager.TerritoryWarManager;
- +import org.l2jmobius.gameserver.instancemanager.events.TvTEvent;
- import org.l2jmobius.gameserver.model.Couple;
- import org.l2jmobius.gameserver.model.World;
- import org.l2jmobius.gameserver.model.WorldObject;
- @@ -618,6 +619,8 @@
- player.sendPacket(ExNoticePostArrived.valueOf(false));
- }
- + TvTEvent.onLogin(player);
- +
- if (Config.WELCOME_MESSAGE_ENABLED)
- {
- player.sendPacket(new ExShowScreenMessage(Config.WELCOME_MESSAGE_TEXT, Config.WELCOME_MESSAGE_TIME));
- diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/util/DocumentBase.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/util/DocumentBase.java
- index e48286b..c7552f5 100644
- --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/util/DocumentBase.java
- +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/util/DocumentBase.java
- @@ -98,6 +98,7 @@
- import org.l2jmobius.gameserver.model.conditions.ConditionPlayerState;
- import org.l2jmobius.gameserver.model.conditions.ConditionPlayerSubclass;
- import org.l2jmobius.gameserver.model.conditions.ConditionPlayerTransformationId;
- +import org.l2jmobius.gameserver.model.conditions.ConditionPlayerTvTEvent;
- import org.l2jmobius.gameserver.model.conditions.ConditionPlayerVehicleMounted;
- import org.l2jmobius.gameserver.model.conditions.ConditionPlayerWeight;
- import org.l2jmobius.gameserver.model.conditions.ConditionSiegeZone;
- @@ -656,6 +657,12 @@
- cond = joinAnd(cond, new ConditionPlayerPledgeClass(pledgeClass));
- break;
- }
- + case "ontvtevent":
- + {
- + final boolean val = Boolean.parseBoolean(a.getNodeValue());
- + cond = joinAnd(cond, new ConditionPlayerTvTEvent(val));
- + break;
- + }
- case "clanhall":
- {
- final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ",");
- \ No newline at end of file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement