Unhardcoded timed hunting zone data.

This commit is contained in:
MobiusDevelopment
2021-04-29 22:15:31 +00:00
parent e66e2668c3
commit 79e2ecfb01
107 changed files with 3674 additions and 2535 deletions

View File

@@ -104,7 +104,6 @@ public class Config
private static final String RATES_CONFIG_FILE = "./config/Rates.ini";
private static final String SERVER_CONFIG_FILE = "./config/Server.ini";
private static final String TELNET_CONFIG_FILE = "./config/Telnet.ini";
private static final String TIME_LIMITED_ZONE_CONFIG_FILE = "./config/TimeLimitedZones.ini";
private static final String TRAINING_CAMP_CONFIG_FILE = "./config/TrainingCamp.ini";
private static final String CHAT_FILTER_FILE = "./config/chatfilter.txt";
private static final String HEXID_FILE = "./config/hexid.txt";
@@ -839,10 +838,6 @@ public class Config
public static String TELNET_HOSTNAME;
public static List<String> TELNET_HOSTS;
public static int TELNET_PORT;
public static long TIME_LIMITED_ZONE_INITIAL_TIME;
public static long TIME_LIMITED_MAX_ADDED_TIME;
public static long TIME_LIMITED_ZONE_RESET_DELAY;
public static long TIME_LIMITED_ZONE_TELEPORT_FEE;
public static boolean TRAINING_CAMP_ENABLE;
public static boolean TRAINING_CAMP_PREMIUM_ONLY;
public static int TRAINING_CAMP_MAX_DURATION;
@@ -1988,13 +1983,6 @@ public class Config
TELNET_PASSWORD = telnetSettings.getString("Password", "");
TELNET_HOSTS = Arrays.asList(telnetSettings.getString("ListOfHosts", "127.0.0.1,::1").split(","));
// Load Time Limited Zone config file (if exists)
final PropertiesParser timeLimitedZoneSettings = new PropertiesParser(TIME_LIMITED_ZONE_CONFIG_FILE);
TIME_LIMITED_ZONE_INITIAL_TIME = timeLimitedZoneSettings.getLong("InitialTime", 3600000);
TIME_LIMITED_MAX_ADDED_TIME = timeLimitedZoneSettings.getLong("MaximumAddedTime", 18000000);
TIME_LIMITED_ZONE_RESET_DELAY = timeLimitedZoneSettings.getLong("ResetDelay", 36000000);
TIME_LIMITED_ZONE_TELEPORT_FEE = timeLimitedZoneSettings.getLong("TeleportFee", 150000);
// Load Training Camp config file (if exists)
final PropertiesParser trainingCampSettings = new PropertiesParser(TRAINING_CAMP_CONFIG_FILE);
TRAINING_CAMP_ENABLE = trainingCampSettings.getBoolean("TrainingCampEnable", false);

View File

@@ -104,6 +104,7 @@ import org.l2jmobius.gameserver.data.xml.SpawnData;
import org.l2jmobius.gameserver.data.xml.StaticObjectData;
import org.l2jmobius.gameserver.data.xml.TeleportListData;
import org.l2jmobius.gameserver.data.xml.TeleporterData;
import org.l2jmobius.gameserver.data.xml.TimedHuntingZoneData;
import org.l2jmobius.gameserver.data.xml.TransformData;
import org.l2jmobius.gameserver.data.xml.VariationData;
import org.l2jmobius.gameserver.geoengine.GeoEngine;
@@ -351,6 +352,7 @@ public class GameServer
CrestTable.getInstance();
TeleportListData.getInstance();
TeleporterData.getInstance();
TimedHuntingZoneData.getInstance();
MatchingRoomManager.getInstance();
PetitionManager.getInstance();
CursedWeaponsManager.getInstance();

View File

@@ -0,0 +1,186 @@
/*
* 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.data.xml;
import java.io.File;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Logger;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.l2jmobius.commons.util.IXmlReader;
import org.l2jmobius.gameserver.model.Location;
import org.l2jmobius.gameserver.model.holders.TimedHuntingZoneHolder;
/**
* @author Mobius
*/
public class TimedHuntingZoneData implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(TimedHuntingZoneData.class.getName());
private final Map<Integer, TimedHuntingZoneHolder> _timedHuntingZoneData = new HashMap<>();
protected TimedHuntingZoneData()
{
load();
}
@Override
public void load()
{
_timedHuntingZoneData.clear();
parseDatapackFile("data/TimedHuntingZoneData.xml");
if (!_timedHuntingZoneData.isEmpty())
{
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _timedHuntingZoneData.size() + " timed hunting zones.");
}
else
{
LOGGER.info(getClass().getSimpleName() + ": System is disabled.");
}
}
@Override
public void parseDocument(Document doc, File f)
{
for (Node xmlNode = doc.getFirstChild(); xmlNode != null; xmlNode = xmlNode.getNextSibling())
{
if ("list".equalsIgnoreCase(xmlNode.getNodeName()))
{
final NamedNodeMap listAttributes = xmlNode.getAttributes();
final Node attribute = listAttributes.getNamedItem("enabled");
if ((attribute != null) && Boolean.parseBoolean(attribute.getNodeValue()))
{
for (Node listNode = xmlNode.getFirstChild(); listNode != null; listNode = listNode.getNextSibling())
{
if ("zone".equalsIgnoreCase(listNode.getNodeName()))
{
final NamedNodeMap zoneAttributes = listNode.getAttributes();
int id = parseInteger(zoneAttributes, "id");
String name = parseString(zoneAttributes, "name", "");
int initialTime = 0;
int maxAddedTime = 0;
int resetDelay = 0;
int entryItemId = 57;
int entryFee = 150000;
int minLevel = 1;
int maxLevel = 999;
int remainRefillTime = 3600;
int refillTimeMax = 3600;
boolean weekly = false;
Location enterLocation = null;
for (Node zoneNode = listNode.getFirstChild(); zoneNode != null; zoneNode = zoneNode.getNextSibling())
{
switch (zoneNode.getNodeName())
{
case "enterLocation":
{
final String[] coordinates = zoneNode.getTextContent().split(",");
enterLocation = new Location(Integer.parseInt(coordinates[0]), Integer.parseInt(coordinates[1]), Integer.parseInt(coordinates[2]));
break;
}
case "initialTime":
{
initialTime = Integer.parseInt(zoneNode.getTextContent());
break;
}
case "maxAddedTime":
{
maxAddedTime = Integer.parseInt(zoneNode.getTextContent());
break;
}
case "resetDelay":
{
resetDelay = Integer.parseInt(zoneNode.getTextContent());
break;
}
case "entryItemId":
{
entryItemId = Integer.parseInt(zoneNode.getTextContent());
break;
}
case "entryFee":
{
entryFee = Integer.parseInt(zoneNode.getTextContent());
break;
}
case "minLevel":
{
minLevel = Integer.parseInt(zoneNode.getTextContent());
break;
}
case "maxLevel":
{
maxLevel = Integer.parseInt(zoneNode.getTextContent());
break;
}
case "remainRefillTime":
{
remainRefillTime = Integer.parseInt(zoneNode.getTextContent());
break;
}
case "refillTimeMax":
{
refillTimeMax = Integer.parseInt(zoneNode.getTextContent());
break;
}
case "weekly":
{
weekly = Boolean.parseBoolean(zoneNode.getTextContent());
break;
}
}
}
_timedHuntingZoneData.put(id, new TimedHuntingZoneHolder(id, name, initialTime, maxAddedTime, resetDelay, entryItemId, entryFee, minLevel, maxLevel, remainRefillTime, refillTimeMax, weekly, enterLocation));
}
}
}
}
}
}
public TimedHuntingZoneHolder getHuntingZone(int zoneId)
{
return _timedHuntingZoneData.get(zoneId);
}
public Collection<TimedHuntingZoneHolder> getAllHuntingZones()
{
return _timedHuntingZoneData.values();
}
public int getSize()
{
return _timedHuntingZoneData.size();
}
public static TimedHuntingZoneData getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final TimedHuntingZoneData INSTANCE = new TimedHuntingZoneData();
}
}

View File

@@ -83,6 +83,7 @@ import org.l2jmobius.gameserver.data.xml.SendMessageLocalisationData;
import org.l2jmobius.gameserver.data.xml.SkillData;
import org.l2jmobius.gameserver.data.xml.SkillTreeData;
import org.l2jmobius.gameserver.data.xml.SymbolSealData;
import org.l2jmobius.gameserver.data.xml.TimedHuntingZoneData;
import org.l2jmobius.gameserver.enums.AdminTeleportType;
import org.l2jmobius.gameserver.enums.BroochJewel;
import org.l2jmobius.gameserver.enums.CastleSide;
@@ -231,6 +232,7 @@ import org.l2jmobius.gameserver.model.holders.RecipeHolder;
import org.l2jmobius.gameserver.model.holders.SellBuffHolder;
import org.l2jmobius.gameserver.model.holders.SkillUseHolder;
import org.l2jmobius.gameserver.model.holders.SubClassHolder;
import org.l2jmobius.gameserver.model.holders.TimedHuntingZoneHolder;
import org.l2jmobius.gameserver.model.holders.TrainingHolder;
import org.l2jmobius.gameserver.model.instancezone.Instance;
import org.l2jmobius.gameserver.model.interfaces.ILocational;
@@ -14276,12 +14278,6 @@ public class PlayerInstance extends Playable
return _autoUseSettings;
}
public boolean isInTimedHuntingZone(int x, int y)
{
return isInTimedHuntingZone(1, x, y) // Storm Isle
|| isInTimedHuntingZone(6, x, y); // Primeval Isle
}
public boolean isInTimedHuntingZone(int zoneId)
{
return isInTimedHuntingZone(zoneId, getX(), getY());
@@ -14289,18 +14285,21 @@ public class PlayerInstance extends Playable
public boolean isInTimedHuntingZone(int zoneId, int locX, int locY)
{
final int x = ((locX - World.WORLD_X_MIN) >> 15) + World.TILE_X_MIN;
final int y = ((locY - World.WORLD_Y_MIN) >> 15) + World.TILE_Y_MIN;
switch (zoneId)
final TimedHuntingZoneHolder holder = TimedHuntingZoneData.getInstance().getHuntingZone(zoneId);
if (holder == null)
{
case 1: // Storm Isle
return false;
}
return (holder.getMapX() == (((locX - World.WORLD_X_MIN) >> 15) + World.TILE_X_MIN)) && (holder.getMapY() == (((locY - World.WORLD_Y_MIN) >> 15) + World.TILE_Y_MIN));
}
public boolean isInTimedHuntingZone(int x, int y)
{
for (TimedHuntingZoneHolder holder : TimedHuntingZoneData.getInstance().getAllHuntingZones())
{
if (isInTimedHuntingZone(holder.getZoneId(), x, y))
{
return (x == 25) && (y == 23);
}
case 6: // Primeval Isle
{
return (x == 20) && (y == 17);
return true;
}
}
return false;
@@ -14344,8 +14343,13 @@ public class PlayerInstance extends Playable
}
}
public long getTimedHuntingZoneRemainingTime(int zoneId)
public int getTimedHuntingZoneRemainingTime(int zoneId)
{
return Math.max(getVariables().getLong(PlayerVariables.HUNTING_ZONE_TIME + zoneId, 0), 0);
return Math.max(getVariables().getInt(PlayerVariables.HUNTING_ZONE_TIME + zoneId, 0), 0);
}
public long getTimedHuntingZoneInitialEntry(int zoneId)
{
return Math.max(getVariables().getLong(PlayerVariables.HUNTING_ZONE_ENTRY + zoneId, 0), 0);
}
}

View File

@@ -0,0 +1,136 @@
/*
* 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 org.l2jmobius.gameserver.model.Location;
import org.l2jmobius.gameserver.model.World;
/**
* @author Mobius
*/
public class TimedHuntingZoneHolder
{
private final int _id;
private final String _name;
private final int _initialTime;
private final int _maximumAddedTime;
private final int _resetDelay;
private final int _entryItemId;
private final int _entryFee;
private final int _minLevel;
private final int _maxLevel;
private final int _remainRefillTime;
private final int _refillTimeMax;
private final boolean _weekly;
private final Location _enterLocation;
private final int _mapX;
private final int _mapY;
public TimedHuntingZoneHolder(int id, String name, int initialTime, int maximumAddedTime, int resetDelay, int entryItemId, int entryFee, int minLevel, int maxLevel, int remainRefillTime, int refillTimeMax, boolean weekly, Location enterLocation)
{
_id = id;
_name = name;
_initialTime = initialTime;
_maximumAddedTime = maximumAddedTime;
_resetDelay = resetDelay;
_entryItemId = entryItemId;
_entryFee = entryFee;
_minLevel = minLevel;
_maxLevel = maxLevel;
_remainRefillTime = remainRefillTime;
_refillTimeMax = refillTimeMax;
_weekly = weekly;
_enterLocation = enterLocation;
_mapX = ((_enterLocation.getX() - World.WORLD_X_MIN) >> 15) + World.TILE_X_MIN;
_mapY = ((_enterLocation.getY() - World.WORLD_Y_MIN) >> 15) + World.TILE_Y_MIN;
}
public int getZoneId()
{
return _id;
}
public String getZoneName()
{
return _name;
}
public int getInitialTime()
{
return _initialTime;
}
public int getMaximumAddedTime()
{
return _maximumAddedTime;
}
public int getResetDelay()
{
return _resetDelay;
}
public int getEntryItemId()
{
return _entryItemId;
}
public int getEntryFee()
{
return _entryFee;
}
public int getMinLevel()
{
return _minLevel;
}
public int getMaxLevel()
{
return _maxLevel;
}
public int getRemainRefillTime()
{
return _remainRefillTime;
}
public int getRefillTimeMax()
{
return _refillTimeMax;
}
public boolean isWeekly()
{
return _weekly;
}
public Location getEnterLocation()
{
return _enterLocation;
}
public int getMapX()
{
return _mapX;
}
public int getMapY()
{
return _mapY;
}
}

View File

@@ -16,13 +16,15 @@
*/
package org.l2jmobius.gameserver.model.zone.type;
import org.l2jmobius.gameserver.data.xml.TimedHuntingZoneData;
import org.l2jmobius.gameserver.enums.TeleportWhereType;
import org.l2jmobius.gameserver.instancemanager.MapRegionManager;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.holders.TimedHuntingZoneHolder;
import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.model.zone.ZoneType;
import org.l2jmobius.gameserver.network.serverpackets.sessionzones.TimedHuntingZoneExit;
import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneExit;
/**
* @author Mobius
@@ -42,17 +44,23 @@ public class TimedHuntingZone extends ZoneType
{
player.setInsideZone(ZoneId.TIMED_HUNTING, true);
final long stormIsleExitTime = player.getTimedHuntingZoneRemainingTime(1);
final long primevalIsleExitTime = player.getTimedHuntingZoneRemainingTime(6);
if ((stormIsleExitTime > 0) && player.isInTimedHuntingZone(1))
for (TimedHuntingZoneHolder holder : TimedHuntingZoneData.getInstance().getAllHuntingZones())
{
player.startTimedHuntingZone(1, stormIsleExitTime);
if (!player.isInTimedHuntingZone(holder.getZoneId()))
{
continue;
}
final int remainingTime = player.getTimedHuntingZoneRemainingTime(holder.getZoneId());
if (remainingTime > 0)
{
player.startTimedHuntingZone(holder.getZoneId(), remainingTime);
return;
}
break;
}
else if ((primevalIsleExitTime > 0) && player.isInTimedHuntingZone(6))
{
player.startTimedHuntingZone(6, primevalIsleExitTime);
}
else if (!player.isGM())
if (!player.isGM())
{
player.teleToLocation(MapRegionManager.getInstance().getTeleToLocation(player, TeleportWhereType.TOWN));
}

View File

@@ -75,6 +75,8 @@ import org.l2jmobius.gameserver.network.clientpackets.ensoul.RequestTryEnSoulExt
import org.l2jmobius.gameserver.network.clientpackets.equipmentupgrade.RequestUpgradeSystemResult;
import org.l2jmobius.gameserver.network.clientpackets.faction.RequestUserFactionInfo;
import org.l2jmobius.gameserver.network.clientpackets.friend.RequestFriendDetailInfo;
import org.l2jmobius.gameserver.network.clientpackets.huntingzones.ExTimedHuntingZoneEnter;
import org.l2jmobius.gameserver.network.clientpackets.huntingzones.ExTimedHuntingZoneList;
import org.l2jmobius.gameserver.network.clientpackets.luckygame.RequestLuckyGamePlay;
import org.l2jmobius.gameserver.network.clientpackets.luckygame.RequestLuckyGameStartInfo;
import org.l2jmobius.gameserver.network.clientpackets.mentoring.ConfirmMenteeAdd;
@@ -111,8 +113,6 @@ import org.l2jmobius.gameserver.network.clientpackets.ranking.RequestRankingChar
import org.l2jmobius.gameserver.network.clientpackets.ranking.RequestRankingCharRankers;
import org.l2jmobius.gameserver.network.clientpackets.sayune.RequestFlyMove;
import org.l2jmobius.gameserver.network.clientpackets.sayune.RequestFlyMoveStart;
import org.l2jmobius.gameserver.network.clientpackets.sessionzones.ExTimedHuntingZoneEnter;
import org.l2jmobius.gameserver.network.clientpackets.sessionzones.ExTimedHuntingZoneList;
import org.l2jmobius.gameserver.network.clientpackets.shuttle.CannotMoveAnymoreInShuttle;
import org.l2jmobius.gameserver.network.clientpackets.shuttle.MoveToLocationInShuttle;
import org.l2jmobius.gameserver.network.clientpackets.shuttle.RequestShuttleGetOff;

View File

@@ -14,12 +14,14 @@
* 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.network.clientpackets.sessionzones;
package org.l2jmobius.gameserver.network.clientpackets.huntingzones;
import org.l2jmobius.Config;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.commons.util.Chronos;
import org.l2jmobius.gameserver.data.xml.TimedHuntingZoneData;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.holders.TimedHuntingZoneHolder;
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
import org.l2jmobius.gameserver.model.olympiad.OlympiadManager;
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
import org.l2jmobius.gameserver.network.GameClient;
@@ -85,52 +87,52 @@ public class ExTimedHuntingZoneEnter implements IClientIncomingPacket
return;
}
if (((_zoneId == 1) && (player.getLevel() < 100)) //
|| ((_zoneId == 6) && (player.getLevel() < 105)) //
)
final TimedHuntingZoneHolder holder = TimedHuntingZoneData.getInstance().getHuntingZone(_zoneId);
if (holder == null)
{
return;
}
if ((player.getLevel() < holder.getMinLevel()) || (player.getLevel() > holder.getMaxLevel()))
{
player.sendMessage("Your level does not correspond the zone equivalent.");
return;
}
final long currentTime = Chronos.currentTimeMillis();
long endTime = currentTime + player.getTimedHuntingZoneRemainingTime(_zoneId);
final long lastEntryTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_ENTRY + _zoneId, 0);
if ((lastEntryTime + Config.TIME_LIMITED_ZONE_RESET_DELAY) < currentTime)
if ((lastEntryTime + holder.getResetDelay()) < currentTime)
{
if (endTime == currentTime)
{
endTime += Config.TIME_LIMITED_ZONE_INITIAL_TIME;
endTime += holder.getInitialTime();
player.getVariables().set(PlayerVariables.HUNTING_ZONE_ENTRY + _zoneId, currentTime);
}
}
if (endTime > currentTime)
{
if (player.getAdena() > Config.TIME_LIMITED_ZONE_TELEPORT_FEE)
if (holder.getEntryItemId() == Inventory.ADENA_ID)
{
player.reduceAdena("TimedHuntingZone", Config.TIME_LIMITED_ZONE_TELEPORT_FEE, player, true);
if (player.getAdena() > holder.getEntryFee())
{
player.reduceAdena("TimedHuntingZone", holder.getEntryFee(), player, true);
}
else
{
player.sendPacket(SystemMessageId.NOT_ENOUGH_ADENA);
return;
}
}
else
else if (!player.destroyItemByItemId("TimedHuntingZone", holder.getEntryItemId(), holder.getEntryFee(), player, true))
{
player.sendPacket(SystemMessageId.NOT_ENOUGH_ADENA);
player.sendPacket(SystemMessageId.YOU_DO_NOT_HAVE_ENOUGH_REQUIRED_ITEMS);
return;
}
player.getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, endTime - currentTime);
switch (_zoneId)
{
case 1: // Storm Isle
{
player.teleToLocation(194291, 176604, -1888);
break;
}
case 6: // Primeval Isle
{
player.teleToLocation(9400, -21720, -3634);
break;
}
}
player.teleToLocation(holder.getEnterLocation());
}
else
{

View File

@@ -14,13 +14,13 @@
* 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.network.clientpackets.sessionzones;
package org.l2jmobius.gameserver.network.clientpackets.huntingzones;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.sessionzones.TimedHuntingZoneList;
import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneList;
/**
* @author Mobius

View File

@@ -14,7 +14,7 @@
* 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.network.serverpackets.sessionzones;
package org.l2jmobius.gameserver.network.serverpackets.huntingzones;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.network.OutgoingPackets;

View File

@@ -14,7 +14,7 @@
* 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.network.serverpackets.sessionzones;
package org.l2jmobius.gameserver.network.serverpackets.huntingzones;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.network.OutgoingPackets;

View File

@@ -0,0 +1,72 @@
/*
* 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.network.serverpackets.huntingzones;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.commons.util.Chronos;
import org.l2jmobius.gameserver.data.xml.TimedHuntingZoneData;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.holders.TimedHuntingZoneHolder;
import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* @author Mobius
*/
public class TimedHuntingZoneList implements IClientOutgoingPacket
{
private final PlayerInstance _player;
private final boolean _isInTimedHuntingZone;
public TimedHuntingZoneList(PlayerInstance player)
{
_player = player;
_isInTimedHuntingZone = player.isInsideZone(ZoneId.TIMED_HUNTING);
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_TIME_RESTRICT_FIELD_LIST.writeId(packet);
int remainingTime;
final long currentTime = Chronos.currentTimeMillis();
packet.writeD(TimedHuntingZoneData.getInstance().getSize()); // zone count
for (TimedHuntingZoneHolder holder : TimedHuntingZoneData.getInstance().getAllHuntingZones())
{
packet.writeD(holder.getEntryFee() == 0 ? 0 : 1); // required item count
packet.writeD(holder.getEntryItemId());
packet.writeQ(holder.getEntryFee());
packet.writeD(holder.isWeekly() ? 0 : 1); // reset cycle
packet.writeD(holder.getZoneId());
packet.writeD(holder.getMinLevel());
packet.writeD(holder.getMaxLevel());
packet.writeD(holder.getInitialTime() / 1000); // remain time base
remainingTime = _player.getTimedHuntingZoneRemainingTime(holder.getZoneId());
if ((remainingTime == 0) && ((_player.getTimedHuntingZoneInitialEntry(1) + holder.getResetDelay()) < currentTime))
{
remainingTime = holder.getInitialTime();
}
packet.writeD(remainingTime / 1000); // remain time
packet.writeD(holder.getMaximumAddedTime() / 1000);
packet.writeD(holder.getRemainRefillTime());
packet.writeD(holder.getRefillTimeMax());
packet.writeC(!_isInTimedHuntingZone || _player.isInTimedHuntingZone(holder.getZoneId()) ? 1 : 0); // field activated
}
return true;
}
}

View File

@@ -1,100 +0,0 @@
/*
* 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.network.serverpackets.sessionzones;
import org.l2jmobius.Config;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.commons.util.Chronos;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* @author Mobius
*/
public class TimedHuntingZoneList implements IClientOutgoingPacket
{
private final PlayerInstance _player;
private final boolean _isInTimedHuntingZone;
public TimedHuntingZoneList(PlayerInstance player)
{
_player = player;
_isInTimedHuntingZone = player.isInsideZone(ZoneId.TIMED_HUNTING);
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_TIME_RESTRICT_FIELD_LIST.writeId(packet);
final long currentTime = Chronos.currentTimeMillis();
long endTime;
packet.writeD(2); // zone count
// Storm Isle
packet.writeD(1); // required item count
packet.writeD(57); // item id
packet.writeQ(Config.TIME_LIMITED_ZONE_TELEPORT_FEE); // item count
packet.writeD(1); // reset cycle
packet.writeD(1); // zone id
packet.writeD(100); // min level
packet.writeD(120); // max level
packet.writeD((int) (Config.TIME_LIMITED_ZONE_INITIAL_TIME / 1000)); // remain time base?
endTime = _player.getTimedHuntingZoneRemainingTime(1);
if (endTime > 0)
{
endTime += currentTime;
}
if ((endTime + Config.TIME_LIMITED_ZONE_RESET_DELAY) < currentTime)
{
endTime = currentTime + Config.TIME_LIMITED_ZONE_INITIAL_TIME;
}
packet.writeD((int) (Math.max(endTime - currentTime, 0)) / 1000); // remain time
packet.writeD((int) (Config.TIME_LIMITED_MAX_ADDED_TIME / 1000));
packet.writeD(3600); // remain refill time
packet.writeD(3600); // refill time max
packet.writeC(_isInTimedHuntingZone ? 0 : 1); // field activated
// Primeval Isle
packet.writeD(1); // required item count
packet.writeD(57); // item id
packet.writeQ(Config.TIME_LIMITED_ZONE_TELEPORT_FEE); // item count
packet.writeD(1); // reset cycle
packet.writeD(6); // zone id
packet.writeD(105); // min level
packet.writeD(120); // max level
packet.writeD((int) (Config.TIME_LIMITED_ZONE_INITIAL_TIME / 1000)); // remain time base?
endTime = _player.getTimedHuntingZoneRemainingTime(6);
if (endTime > 0)
{
endTime += currentTime;
}
if ((endTime + Config.TIME_LIMITED_ZONE_RESET_DELAY) < currentTime)
{
endTime = currentTime + Config.TIME_LIMITED_ZONE_INITIAL_TIME;
}
packet.writeD((int) (Math.max(endTime - currentTime, 0)) / 1000); // remain time
packet.writeD((int) (Config.TIME_LIMITED_MAX_ADDED_TIME / 1000));
packet.writeD(3600); // remain refill time
packet.writeD(3600); // refill time max
packet.writeC(_isInTimedHuntingZone ? 0 : 1); // field activated
return true;
}
}