Addition of Training Camp.

Adapted from: L2jUnity free files.
This commit is contained in:
MobiusDev
2017-11-17 00:36:36 +00:00
parent 2084ed23e8
commit 0eb87bc2d6
122 changed files with 5454 additions and 33 deletions

View File

@@ -100,6 +100,7 @@ public final class Config
public static final String SERVER_CONFIG_FILE = "./config/Server.ini";
public static final String SIEGE_CONFIG_FILE = "./config/Siege.ini";
public static final String TELNET_CONFIG_FILE = "./config/Telnet.ini";
public static final String TRAINING_CAMP_CONFIG_FILE = "./config/TrainingCamp.ini";
public static final String CHAT_FILTER_FILE = "./config/chatfilter.txt";
public static final String HEXID_FILE = "./config/hexid.txt";
public static final String IPCONFIG_FILE = "./config/ipconfig.xml";
@@ -852,6 +853,11 @@ public final class Config
public static String TELNET_HOSTNAME;
public static List<String> TELNET_HOSTS;
public static int TELNET_PORT;
public static boolean TRAINING_CAMP_ENABLE;
public static boolean TRAINING_CAMP_PREMIUM_ONLY;
public static int TRAINING_CAMP_MAX_DURATION;
public static int TRAINING_CAMP_MIN_LEVEL;
public static int TRAINING_CAMP_MAX_LEVEL;
public static boolean SHOW_LICENCE;
public static boolean SHOW_PI_AGREEMENT;
public static boolean ACCEPT_NEW_GAMESERVER;
@@ -1740,6 +1746,15 @@ public final class Config
TELNET_PASSWORD = telnetSettings.getString("Password", "");
TELNET_HOSTS = Arrays.asList(telnetSettings.getString("ListOfHosts", "127.0.0.1,::1").split(","));
// Load Training Camp config file (if exists)
final PropertiesParser trainingCampSettings = new PropertiesParser(TRAINING_CAMP_CONFIG_FILE);
TRAINING_CAMP_ENABLE = trainingCampSettings.getBoolean("TrainingCampEnable", false);
TRAINING_CAMP_PREMIUM_ONLY = trainingCampSettings.getBoolean("TrainingCampPremiumOnly", false);
TRAINING_CAMP_MAX_DURATION = trainingCampSettings.getInt("TrainingCampDuration", 18000);
TRAINING_CAMP_MIN_LEVEL = trainingCampSettings.getInt("TrainingCampMinLevel", 18);
TRAINING_CAMP_MAX_LEVEL = trainingCampSettings.getInt("TrainingCampMaxLevel", 127);
// MMO
final PropertiesParser mmoSettings = new PropertiesParser(MMO_CONFIG_FILE);

View File

@@ -37,6 +37,7 @@ public final class ExperienceData implements IGameXmlReader
private static final Logger LOGGER = Logger.getLogger(ExperienceData.class.getName());
private final Map<Integer, Long> _expTable = new HashMap<>();
private final Map<Integer, Double> _traningRateTable = new HashMap<>();
private byte MAX_LEVEL;
private byte MAX_PET_LEVEL;
@@ -53,6 +54,7 @@ public final class ExperienceData implements IGameXmlReader
public void load()
{
_expTable.clear();
_traningRateTable.clear();
parseDatapackFile("data/stats/experience.xml");
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _expTable.size() + " levels.");
LOGGER.info(getClass().getSimpleName() + ": Max Player Level is: " + (MAX_LEVEL - 1));
@@ -89,6 +91,7 @@ public final class ExperienceData implements IGameXmlReader
break;
}
_expTable.put(maxLevel, parseLong(attrs, "tolevel"));
_traningRateTable.put(maxLevel, parseDouble(attrs, "trainingRate"));
}
}
}
@@ -107,6 +110,15 @@ public final class ExperienceData implements IGameXmlReader
return _expTable.get(level);
}
public double getTrainingRate(int level)
{
if (level > Config.PLAYER_MAXIMUM_LEVEL)
{
level = Config.PLAYER_MAXIMUM_LEVEL;
}
return _traningRateTable.get(level);
}
/**
* Gets the max level.
* @return the maximum level acquirable by a player.

View File

@@ -407,7 +407,7 @@ public class CeremonyOfChaosManager extends AbstractEventManager<CeremonyOfChaos
@Override
@RegisterEvent(EventType.ON_PLAYER_LOGOUT)
@RegisterType(ListenerRegisterType.GLOBAL_PLAYERS)
@RegisterType(ListenerRegisterType.GLOBAL)
public void OnPlayerLogout(OnPlayerLogout event)
{
if (getState() == CeremonyOfChaosState.REGISTRATION)

View File

@@ -214,6 +214,7 @@ import com.l2jmobius.gameserver.model.holders.MovieHolder;
import com.l2jmobius.gameserver.model.holders.PlayerEventHolder;
import com.l2jmobius.gameserver.model.holders.SellBuffHolder;
import com.l2jmobius.gameserver.model.holders.SkillUseHolder;
import com.l2jmobius.gameserver.model.holders.TrainingHolder;
import com.l2jmobius.gameserver.model.instancezone.Instance;
import com.l2jmobius.gameserver.model.interfaces.ILocational;
import com.l2jmobius.gameserver.model.itemcontainer.Inventory;
@@ -846,6 +847,10 @@ public final class L2PcInstance extends L2Playable
_PvPRegTask = null;
}
// Training Camp
private final static String TRAINING_CAMP_VAR = "TRAINING_CAMP";
private final static String TRAINING_CAMP_DURATION = "TRAINING_CAMP_DURATION";
// Save responder name for log it
private String _lastPetitionGmName = null;
@@ -14011,4 +14016,40 @@ public final class L2PcInstance extends L2Playable
}
return false;
}
public TrainingHolder getTraingCampInfo()
{
final String info = getAccountVariables().getString(TRAINING_CAMP_VAR, null);
if (info == null)
{
return null;
}
return new TrainingHolder(Integer.parseInt(info.split(";")[0]), Integer.parseInt(info.split(";")[1]), Integer.parseInt(info.split(";")[2]), Long.parseLong(info.split(";")[3]), Long.parseLong(info.split(";")[4]));
}
public void setTraingCampInfo(TrainingHolder holder)
{
getAccountVariables().set(TRAINING_CAMP_VAR, holder.getObjectId() + ";" + holder.getClassIndex() + ";" + holder.getLevel() + ";" + holder.getStartTime() + ";" + holder.getEndTime());
}
public void removeTraingCampInfo()
{
getAccountVariables().remove(TRAINING_CAMP_VAR);
}
public long getTraingCampDuration()
{
return getAccountVariables().getLong(TRAINING_CAMP_DURATION, 0L);
}
public void setTraingCampDuration(long duration)
{
getAccountVariables().set(TRAINING_CAMP_DURATION, duration);
}
public boolean isInTraingCamp()
{
final TrainingHolder trainingHolder = getTraingCampInfo();
return (trainingHolder != null) && (trainingHolder.getEndTime() > 0);
}
}

View File

@@ -195,7 +195,7 @@ public abstract class AbstractEventManager<T extends AbstractEvent<?>>extends Ab
/* ********************** */
@RegisterEvent(EventType.ON_PLAYER_LOGOUT)
@RegisterType(ListenerRegisterType.GLOBAL_PLAYERS)
@RegisterType(ListenerRegisterType.GLOBAL)
public void OnPlayerLogout(OnPlayerLogout event)
{
final L2PcInstance player = event.getActiveChar();

View File

@@ -0,0 +1,110 @@
/*
* 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 com.l2jmobius.gameserver.model.holders;
import java.io.Serializable;
import java.util.concurrent.TimeUnit;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
/**
* @author Sdw
*/
public class TrainingHolder implements Serializable
{
private final int _objectId;
private final int _classIndex;
private final int _level;
private final long _startTime;
private long _endTime = -1;
private static final long TRAINING_DIVIDER = TimeUnit.SECONDS.toMinutes(Config.TRAINING_CAMP_MAX_DURATION);
public TrainingHolder(int objectId, int classIndex, int level, long startTime, long endTime)
{
_objectId = objectId;
_classIndex = classIndex;
_level = level;
_startTime = startTime;
_endTime = endTime;
}
public long getEndTime()
{
return _endTime;
}
public void setEndTime(long endTime)
{
_endTime = endTime;
}
public int getObjectId()
{
return _objectId;
}
public int getClassIndex()
{
return _classIndex;
}
public int getLevel()
{
return _level;
}
public long getStartTime()
{
return _startTime;
}
public boolean isTraining()
{
return _endTime == -1;
}
public boolean isValid(L2PcInstance player)
{
return Config.TRAINING_CAMP_ENABLE && (player.getObjectId() == _objectId) && (player.getClassIndex() == _classIndex);
}
public long getElapsedTime(long time, TimeUnit unit)
{
return unit.convert(time - _startTime, TimeUnit.MILLISECONDS);
}
public long getRemainingTime()
{
return TimeUnit.SECONDS.toMinutes(Config.TRAINING_CAMP_MAX_DURATION - getElapsedTime(System.currentTimeMillis(), TimeUnit.SECONDS));
}
public long getRemainingTime(long time)
{
return TimeUnit.SECONDS.toMinutes(Config.TRAINING_CAMP_MAX_DURATION - time);
}
public long getTrainingTime(TimeUnit unit)
{
return Math.min(unit.convert(Config.TRAINING_CAMP_MAX_DURATION, TimeUnit.SECONDS), unit.convert(_endTime - _startTime, TimeUnit.MILLISECONDS));
}
public static long getTrainingDivider()
{
return TRAINING_DIVIDER;
}
}

View File

@@ -81,6 +81,7 @@ import com.l2jmobius.gameserver.network.clientpackets.pledgebonus.RequestPledgeB
import com.l2jmobius.gameserver.network.clientpackets.pledgebonus.RequestPledgeBonusRewardList;
import com.l2jmobius.gameserver.network.clientpackets.primeshop.RequestBRBuyProduct;
import com.l2jmobius.gameserver.network.clientpackets.primeshop.RequestBRGamePoint;
import com.l2jmobius.gameserver.network.clientpackets.primeshop.RequestBRPresentBuyProduct;
import com.l2jmobius.gameserver.network.clientpackets.primeshop.RequestBRProductInfo;
import com.l2jmobius.gameserver.network.clientpackets.primeshop.RequestBRProductList;
import com.l2jmobius.gameserver.network.clientpackets.primeshop.RequestBRRecentProductList;
@@ -90,6 +91,7 @@ import com.l2jmobius.gameserver.network.clientpackets.shuttle.CannotMoveAnymoreI
import com.l2jmobius.gameserver.network.clientpackets.shuttle.MoveToLocationInShuttle;
import com.l2jmobius.gameserver.network.clientpackets.shuttle.RequestShuttleGetOff;
import com.l2jmobius.gameserver.network.clientpackets.shuttle.RequestShuttleGetOn;
import com.l2jmobius.gameserver.network.clientpackets.training.NotifyTrainingRoomEnd;
/**
* @author Sdw
@@ -271,7 +273,7 @@ public enum ExIncomingPackets implements IIncomingPackets<L2GameClient>
SEND_CHANGE_ATTRIBUTE_TARGET_ITEM(0xB0, SendChangeAttributeTargetItem::new, ConnectionState.IN_GAME),
REQUEST_CHANGE_ATTRIBUTE_ITEM(0xB1, RequestChangeAttributeItem::new, ConnectionState.IN_GAME),
REQUEST_CHANGE_ATTRIBUTE_CANCEL(0xB2, RequestChangeAttributeCancel::new, ConnectionState.IN_GAME),
REQUEST_BR_PRESENT_BUY_PRODUCT(0xB3, null, ConnectionState.IN_GAME),
REQUEST_BR_PRESENT_BUY_PRODUCT(0xB3, RequestBRPresentBuyProduct::new, ConnectionState.IN_GAME),
CONFIRM_MENTEE_ADD(0xB4, ConfirmMenteeAdd::new, ConnectionState.IN_GAME),
REQUEST_MENTOR_CANCEL(0xB5, RequestMentorCancel::new, ConnectionState.IN_GAME),
REQUEST_MENTOR_LIST(0xB6, RequestMentorList::new, ConnectionState.IN_GAME),
@@ -333,7 +335,7 @@ public enum ExIncomingPackets implements IIncomingPackets<L2GameClient>
EX_PC_CAFE_REQUEST_OPEN_WINDOW_WITHOUT_NPC(0xF0, ExPCCafeRequestOpenWindowWithoutNPC::new, ConnectionState.IN_GAME),
REQUEST_LUCKY_GAME_START_INFO(0xF1, RequestLuckyGameStartInfo::new, ConnectionState.IN_GAME),
REQUEST_LUCKY_GAME_PLAY(0xF2, RequestLuckyGamePlay::new, ConnectionState.IN_GAME),
NOTIFY_TRAINING_ROOM_END(0xF3, null, ConnectionState.IN_GAME),
NOTIFY_TRAINING_ROOM_END(0xF3, NotifyTrainingRoomEnd::new, ConnectionState.IN_GAME),
REQUEST_NEW_ENCHANT_PUSH_ONE(0xF4, RequestNewEnchantPushOne::new, ConnectionState.IN_GAME),
REQUEST_NEW_ENCHANT_REMOVE_ONE(0xF5, RequestNewEnchantRemoveOne::new, ConnectionState.IN_GAME),
REQUEST_NEW_ENCHANT_PUSH_TWO(0xF6, RequestNewEnchantPushTwo::new, ConnectionState.IN_GAME),

View File

@@ -650,6 +650,8 @@ public enum OutgoingPackets
EX_ENCHANT_TWO_REMOVE_FAIL(0xFE, 0x16F),
EX_ENCHANT_SUCESS(0xFE, 0x170),
EX_ENCHANT_FAIL(0xFE, 0x171),
EX_ENCHANT_RETRY_TO_PUT_ITEM_OK(0xFE, 0x172),
EX_ENCHANT_RETRY_TO_PUT_ITEM_FAIL(0xFE, 0x173),
EX_ACCOUNT_ATTENDANCE_INFO(0xFE, 0x174),
EX_WORLD_CHAT_CNT(0xFE, 0x175),
EX_ALCHEMY_SKILL_LIST(0xFE, 0x176),

View File

@@ -0,0 +1,102 @@
/*
* 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 com.l2jmobius.gameserver.network.clientpackets;
import com.l2jmobius.commons.network.PacketReader;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.request.CompoundRequest;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
import com.l2jmobius.gameserver.network.L2GameClient;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.network.serverpackets.ExEnchantRetryToPutItemFail;
import com.l2jmobius.gameserver.network.serverpackets.ExEnchantRetryToPutItemOk;
/**
* @author Sdw
*/
public class RequestNewEnchantRetryToPutItems implements IClientIncomingPacket
{
private int _firstItemObjectId;
private int _secondItemObjectId;
@Override
public boolean read(L2GameClient client, PacketReader packet)
{
_firstItemObjectId = packet.readD();
_secondItemObjectId = packet.readD();
return true;
}
@Override
public void run(L2GameClient client)
{
final L2PcInstance activeChar = client.getActiveChar();
if (activeChar == null)
{
return;
}
else if (activeChar.isInStoreMode())
{
client.sendPacket(SystemMessageId.YOU_CANNOT_DO_THAT_WHILE_IN_A_PRIVATE_STORE_OR_PRIVATE_WORKSHOP);
client.sendPacket(ExEnchantRetryToPutItemFail.STATIC_PACKET);
return;
}
else if (activeChar.isProcessingTransaction() || activeChar.isProcessingRequest())
{
client.sendPacket(SystemMessageId.YOU_CANNOT_USE_THIS_SYSTEM_DURING_TRADING_PRIVATE_STORE_AND_WORKSHOP_SETUP);
client.sendPacket(ExEnchantRetryToPutItemFail.STATIC_PACKET);
return;
}
final CompoundRequest request = new CompoundRequest(activeChar);
if (!activeChar.addRequest(request))
{
client.sendPacket(ExEnchantRetryToPutItemFail.STATIC_PACKET);
return;
}
// Make sure player owns first item.
request.setItemOne(_firstItemObjectId);
final L2ItemInstance itemOne = request.getItemOne();
if (itemOne == null)
{
client.sendPacket(ExEnchantRetryToPutItemFail.STATIC_PACKET);
activeChar.removeRequest(request.getClass());
return;
}
// Make sure player owns second item.
request.setItemTwo(_secondItemObjectId);
final L2ItemInstance itemTwo = request.getItemTwo();
if (itemTwo == null)
{
client.sendPacket(ExEnchantRetryToPutItemFail.STATIC_PACKET);
activeChar.removeRequest(request.getClass());
return;
}
// Not implemented or not able to merge!
if ((itemOne.getItem().getCompoundItem() == 0) || (itemOne.getItem().getCompoundChance() == 0))
{
client.sendPacket(ExEnchantRetryToPutItemFail.STATIC_PACKET);
activeChar.removeRequest(request.getClass());
return;
}
client.sendPacket(ExEnchantRetryToPutItemOk.STATIC_PACKET);
}
}

View File

@@ -0,0 +1,234 @@
/*
* 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 com.l2jmobius.gameserver.network.clientpackets.primeshop;
import java.util.Calendar;
import com.l2jmobius.Config;
import com.l2jmobius.commons.network.PacketReader;
import com.l2jmobius.gameserver.data.sql.impl.CharNameTable;
import com.l2jmobius.gameserver.data.xml.impl.PrimeShopData;
import com.l2jmobius.gameserver.enums.MailType;
import com.l2jmobius.gameserver.instancemanager.MailManager;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.request.PrimeShopRequest;
import com.l2jmobius.gameserver.model.entity.Message;
import com.l2jmobius.gameserver.model.itemcontainer.Inventory;
import com.l2jmobius.gameserver.model.itemcontainer.Mail;
import com.l2jmobius.gameserver.model.primeshop.PrimeShopGroup;
import com.l2jmobius.gameserver.model.primeshop.PrimeShopItem;
import com.l2jmobius.gameserver.network.L2GameClient;
import com.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import com.l2jmobius.gameserver.network.serverpackets.primeshop.ExBRBuyProduct;
import com.l2jmobius.gameserver.network.serverpackets.primeshop.ExBRBuyProduct.ExBrProductReplyType;
import com.l2jmobius.gameserver.network.serverpackets.primeshop.ExBRGamePoint;
import com.l2jmobius.gameserver.util.Util;
/**
* @author Gnacik, UnAfraid
*/
public final class RequestBRPresentBuyProduct implements IClientIncomingPacket
{
private static final int HERO_COINS = 23805;
private int _brId;
private int _count;
private String _charName;
private String _mailTitle;
private String _mailBody;
@Override
public boolean read(L2GameClient client, PacketReader packet)
{
_brId = packet.readD();
_count = packet.readD();
_charName = packet.readS();
_mailTitle = packet.readS();
_mailBody = packet.readS();
return true;
}
@Override
public void run(L2GameClient client)
{
final L2PcInstance activeChar = client.getActiveChar();
if (activeChar == null)
{
return;
}
final int receiverId = CharNameTable.getInstance().getIdByName(_charName);
if (receiverId <= 0)
{
activeChar.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.INVALID_USER));
return;
}
if (activeChar.hasItemRequest() || activeChar.hasRequest(PrimeShopRequest.class))
{
activeChar.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.INVALID_USER_STATE));
return;
}
activeChar.addRequest(new PrimeShopRequest(activeChar));
final PrimeShopGroup item = PrimeShopData.getInstance().getItem(_brId);
if (validatePlayer(item, _count, activeChar))
{
final int price = (item.getPrice() * _count);
final int paymentId = validatePaymentId(activeChar, item, price);
if (paymentId < 0)
{
activeChar.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.LACK_OF_POINT));
activeChar.removeRequest(PrimeShopRequest.class);
return;
}
else if (paymentId > 0)
{
if (!activeChar.destroyItemByItemId("PrimeShop-" + item.getBrId(), paymentId, price, activeChar, true))
{
activeChar.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.LACK_OF_POINT));
activeChar.removeRequest(PrimeShopRequest.class);
return;
}
}
else if (paymentId == 0)
{
if (activeChar.getPrimePoints() < price)
{
activeChar.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.LACK_OF_POINT));
activeChar.removeRequest(PrimeShopRequest.class);
return;
}
activeChar.setPrimePoints(activeChar.getPrimePoints() - price);
}
activeChar.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.SUCCESS));
activeChar.sendPacket(new ExBRGamePoint(activeChar));
final Message mail = new Message(receiverId, _mailTitle, _mailBody, MailType.PRIME_SHOP_GIFT);
final Mail attachement = mail.createAttachments();
for (PrimeShopItem subItem : item.getItems())
{
attachement.addItem("Prime Shop Gift", subItem.getId(), subItem.getCount(), activeChar, this);
}
MailManager.getInstance().sendMessage(mail);
}
activeChar.removeRequest(PrimeShopRequest.class);
}
/**
* @param item
* @param count
* @param player
* @return
*/
private static boolean validatePlayer(PrimeShopGroup item, int count, L2PcInstance player)
{
final long currentTime = System.currentTimeMillis() / 1000;
if (item == null)
{
player.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.INVALID_PRODUCT));
Util.handleIllegalPlayerAction(player, "Player " + player.getName() + " tried to buy invalid brId from Prime", Config.DEFAULT_PUNISH);
return false;
}
else if ((count < 1) || (count > 99))
{
Util.handleIllegalPlayerAction(player, "Player " + player.getName() + " tried to buy invalid itemcount [" + count + "] from Prime", Config.DEFAULT_PUNISH);
player.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.INVALID_USER_STATE));
return false;
}
else if ((item.getMinLevel() > 0) && (item.getMinLevel() > player.getLevel()))
{
player.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.INVALID_USER));
return false;
}
else if ((item.getMaxLevel() > 0) && (item.getMaxLevel() < player.getLevel()))
{
player.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.INVALID_USER));
return false;
}
else if ((item.getMinBirthday() > 0) && (item.getMinBirthday() > player.getBirthdays()))
{
player.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.INVALID_USER_STATE));
return false;
}
else if ((item.getMaxBirthday() > 0) && (item.getMaxBirthday() < player.getBirthdays()))
{
player.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.INVALID_USER_STATE));
return false;
}
else if ((Calendar.getInstance().get(Calendar.DAY_OF_WEEK) & item.getDaysOfWeek()) == 0)
{
player.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.NOT_DAY_OF_WEEK));
return false;
}
else if ((item.getStartSale() > 1) && (item.getStartSale() > currentTime))
{
player.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.BEFORE_SALE_DATE));
return false;
}
else if ((item.getEndSale() > 1) && (item.getEndSale() < currentTime))
{
player.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.AFTER_SALE_DATE));
return false;
}
final int weight = item.getWeight() * count;
final long slots = item.getCount() * count;
if (player.getInventory().validateWeight(weight))
{
if (!player.getInventory().validateCapacity(slots))
{
player.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.INVENTROY_OVERFLOW));
return false;
}
}
else
{
player.sendPacket(new ExBRBuyProduct(ExBrProductReplyType.INVENTROY_OVERFLOW));
return false;
}
return true;
}
private static int validatePaymentId(L2PcInstance player, PrimeShopGroup item, long amount)
{
switch (item.getPaymentType())
{
case 0: // Prime points
{
return 0;
}
case 1: // Adenas
{
return Inventory.ADENA_ID;
}
case 2: // Hero coins
{
return HERO_COINS;
}
}
return -1;
}
}

View File

@@ -0,0 +1,66 @@
/*
* 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 com.l2jmobius.gameserver.network.clientpackets.training;
import com.l2jmobius.commons.network.PacketReader;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.holders.TrainingHolder;
import com.l2jmobius.gameserver.network.L2GameClient;
import com.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import com.l2jmobius.gameserver.network.serverpackets.training.ExTrainingZone_Leaving;
/**
* @author Sdw
*/
public class NotifyTrainingRoomEnd implements IClientIncomingPacket
{
@Override
public boolean read(L2GameClient client, PacketReader packet)
{
// Nothing to read
return true;
}
@Override
public void run(L2GameClient client)
{
final L2PcInstance activeChar = client.getActiveChar();
if (activeChar == null)
{
return;
}
final TrainingHolder holder = activeChar.getTraingCampInfo();
if (holder == null)
{
return;
}
if (holder.isTraining())
{
holder.setEndTime(System.currentTimeMillis());
activeChar.enableAllSkills();
activeChar.setIsInvul(false);
activeChar.setInvisible(false);
activeChar.setIsImmobilized(false);
activeChar.teleToLocation(activeChar.getLastLocation());
activeChar.sendPacket(ExTrainingZone_Leaving.STATIC_PACKET);
holder.setEndTime(System.currentTimeMillis());
activeChar.setTraingCampInfo(holder);
}
}
}

View File

@@ -0,0 +1,39 @@
/*
* 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 com.l2jmobius.gameserver.network.serverpackets;
import com.l2jmobius.commons.network.PacketWriter;
import com.l2jmobius.gameserver.network.OutgoingPackets;
/**
* @author Sdw
*/
public class ExEnchantRetryToPutItemFail implements IClientOutgoingPacket
{
public static final ExEnchantRetryToPutItemFail STATIC_PACKET = new ExEnchantRetryToPutItemFail();
private ExEnchantRetryToPutItemFail()
{
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_ENCHANT_RETRY_TO_PUT_ITEM_FAIL.writeId(packet);
return true;
}
}

View File

@@ -0,0 +1,39 @@
/*
* 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 com.l2jmobius.gameserver.network.serverpackets;
import com.l2jmobius.commons.network.PacketWriter;
import com.l2jmobius.gameserver.network.OutgoingPackets;
/**
* @author Sdw
*/
public class ExEnchantRetryToPutItemOk implements IClientOutgoingPacket
{
public static final ExEnchantRetryToPutItemOk STATIC_PACKET = new ExEnchantRetryToPutItemOk();
private ExEnchantRetryToPutItemOk()
{
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_ENCHANT_RETRY_TO_PUT_ITEM_OK.writeId(packet);
return true;
}
}

View File

@@ -0,0 +1,62 @@
/*
* 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 com.l2jmobius.gameserver.network.serverpackets.training;
import com.l2jmobius.Config;
import com.l2jmobius.commons.network.PacketWriter;
import com.l2jmobius.gameserver.data.xml.impl.ExperienceData;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.OutgoingPackets;
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* @author Sdw
*/
public class ExTrainingZone_Admission implements IClientOutgoingPacket
{
private final long _timeElapsed;
private final long _timeRemaining;
private final double _maxExp;
private final double _maxSp;
public ExTrainingZone_Admission(L2PcInstance player)
{
_timeElapsed = 0;
_timeRemaining = Config.TRAINING_CAMP_MAX_DURATION;
_maxExp = (ExperienceData.getInstance().getExpForLevel(player.getLevel()) * ExperienceData.getInstance().getTrainingRate(player.getLevel())) / Config.TRAINING_CAMP_MAX_DURATION;
_maxSp = _maxExp / 250d;
}
public ExTrainingZone_Admission(int level, long timeElapsed, long timeRemaing)
{
_timeElapsed = timeElapsed;
_timeRemaining = timeRemaing;
_maxExp = (ExperienceData.getInstance().getExpForLevel(level) * ExperienceData.getInstance().getTrainingRate(level)) / Config.TRAINING_CAMP_MAX_DURATION;
_maxSp = _maxExp / 250d;
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_TRAINING_ZONE_ADMISSION.writeId(packet);
packet.writeD((int) _timeElapsed); // Training time elapsed in minutes, max : 600 - 10hr RU / 300 - 5hr NA
packet.writeD((int) _timeRemaining); // Time remaining in seconds, max : 36000 - 10hr RU / 18000 - 5hr NA
packet.writeF(_maxExp); // Training time elapsed in minutes * this value = acquired exp IN GAME DOESN'T SEEM LIKE THE FIELD IS LIMITED
packet.writeF(_maxSp); // Training time elapsed in minutes * this value = acquired sp IN GAME LIMITED TO INTEGER.MAX_VALUE SO THE MULTIPLY WITH REMAINING TIME CANT EXCEED IT (so field max value can't exceed 3579139.0 for 10hr) !! // Note real sp gain is exp gained / 250
return true;
}
}

View File

@@ -0,0 +1,36 @@
/*
* 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 com.l2jmobius.gameserver.network.serverpackets.training;
import com.l2jmobius.commons.network.PacketWriter;
import com.l2jmobius.gameserver.network.OutgoingPackets;
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* @author Sdw
*/
public class ExTrainingZone_Leaving implements IClientOutgoingPacket
{
public static ExTrainingZone_Leaving STATIC_PACKET = new ExTrainingZone_Leaving();
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_TRAINING_ZONE_LEAVING.writeId(packet);
return true;
}
}