Sync with L2JServer Jan 28th 2015.

This commit is contained in:
mobius
2015-01-29 05:18:04 +00:00
parent 59e1db4a68
commit 2cb3a52ed2
224 changed files with 4690 additions and 835 deletions

View File

@ -76,8 +76,8 @@ public class ItemInfo
private int[] _option;
private int _appearanceId;
private long _appearanceTime;
private int _visualId;
private long _visualExpiration;
/**
* Get all information from L2ItemInstance to generate ItemInfo.
@ -151,8 +151,8 @@ public class ItemInfo
_elemDefAttr[i] = item.getElementDefAttr(i);
}
_option = item.getEnchantOptions();
_appearanceId = item.getAppearanceId();
_appearanceTime = item.getAppearanceTime();
_visualId = item.getVisualId();
_visualExpiration = item.getAppearanceTime();
}
public ItemInfo(L2ItemInstance item, int change)
@ -212,8 +212,8 @@ public class ItemInfo
_elemDefAttr[i] = item.getElementDefAttr(i);
}
_option = item.getEnchantOptions();
_appearanceId = item.getAppearanceId();
_appearanceTime = item.getAppearanceTime();
_visualId = item.getVisualId();
_visualExpiration = item.getVisualExpiration();
}
public ItemInfo(Product item)
@ -303,8 +303,8 @@ public class ItemInfo
_elemDefAttr[i] = item.getElementDefAttr(i);
}
_option = item.getEnchantOptions();
_appearanceId = item.getAppearanceId();
_appearanceTime = item.getAppearanceTime();
_visualId = item.getAppearanceId();
_visualExpiration = item.getAppearanceTime();
}
public int getObjectId()
@ -392,13 +392,13 @@ public class ItemInfo
return _option;
}
public int getAppearanceId()
public int getVisualId()
{
return _appearanceId;
return _visualId;
}
public long getAppearanceTime()
public long getVisualExpiration()
{
return _appearanceTime;
return _visualExpiration;
}
}

View File

@ -18,6 +18,7 @@
*/
package com.l2jserver.gameserver.model;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@ -30,6 +31,7 @@ import javolution.util.FastMap;
import com.l2jserver.gameserver.model.holders.MinionHolder;
import com.l2jserver.gameserver.model.holders.SkillHolder;
import com.l2jserver.gameserver.model.interfaces.IParserAdvUtils;
import com.l2jserver.util.TimeUtil;
/**
* This class is meant to hold a set of (key,value) pairs.<br>
@ -509,6 +511,28 @@ public class StatsSet implements IParserAdvUtils
return String.valueOf(val);
}
@Override
public Duration getDuration(String key)
{
Object val = _set.get(key);
if (val == null)
{
throw new IllegalArgumentException("String value required, but not specified");
}
return TimeUtil.parseDuration(String.valueOf(val));
}
@Override
public Duration getDuration(String key, Duration defaultValue)
{
Object val = _set.get(key);
if (val == null)
{
return defaultValue;
}
return TimeUtil.parseDuration(String.valueOf(val));
}
@Override
@SuppressWarnings("unchecked")
public <T extends Enum<T>> T getEnum(String key, Class<T> enumClass)

View File

@ -50,8 +50,8 @@ public class TradeItem
private final int _mana;
private final boolean _isTimeLimited;
private final int _time;
private final int _appearanceId;
private final long _appearanceTime;
private final int _visualId;
private final long _visualExpiration;
public TradeItem(L2ItemInstance item, long count, long price)
{
@ -76,8 +76,8 @@ public class TradeItem
_mana = item.getMana();
_isTimeLimited = item.isTimeLimitedItem();
_time = item.isTimeLimitedItem() ? (int) (item.getRemainingTime() / 1000) : -9999;
_appearanceId = item.getAppearanceId();
_appearanceTime = item.getAppearanceTime();
_visualId = item.getVisualId();
_visualExpiration = item.getAppearanceTime();
}
public TradeItem(L2Item item, long count, long price, int enchantLevel, int attackAttribute, int attackAttributeValue, int defenseAttributes[], int appearanceId)
@ -104,8 +104,8 @@ public class TradeItem
_mana = -1;
_isTimeLimited = false;
_time = -9999;
_appearanceId = appearanceId;
_appearanceTime = -1;
_visualId = appearanceId;
_visualExpiration = -1;
}
public TradeItem(TradeItem item, long count, long price, int enchantLevel, int attackAttribute, int attackAttributeValue, int defenseAttributes[], int appearanceId)
@ -132,8 +132,8 @@ public class TradeItem
_mana = item.getMana();
_isTimeLimited = item.isTimeLimitedItem();
_time = item.isTimeLimitedItem() ? (int) (item.getRemainingTime() / 1000) : -9999;
_appearanceId = item.getAppearanceId();
_appearanceTime = item.getAppearanceTime();
_visualId = item.getVisualId();
_visualExpiration = item.getVisualExpiration();
}
public L2ItemInstance getItemInstance()
@ -251,14 +251,14 @@ public class TradeItem
return _isTimeLimited;
}
public int getAppearanceId()
public int getVisualId()
{
return _appearanceId;
return _visualId;
}
public long getAppearanceTime()
public long getVisualExpiration()
{
return _appearanceTime;
return _visualExpiration;
}
public int getRemainingTime()

View File

@ -131,7 +131,7 @@ public class TradeList
{
el[i] = item.getElementDefAttr((byte) i);
}
item = new TradeItem(item, item.getCount(), item.getPrice(), item.getEnchant(), item.getAttackElementType(), item.getAttackElementPower(), el, item.getAppearanceId());
item = new TradeItem(item, item.getCount(), item.getPrice(), item.getEnchant(), item.getAttackElementType(), item.getAttackElementPower(), el, item.getVisualId());
inventory.adjustAvailableItem(item);
list.add(item);
}

View File

@ -41,6 +41,7 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentSkipListMap;
import java.util.concurrent.Future;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.ReentrantLock;
import java.util.logging.Level;
@ -766,6 +767,12 @@ public final class L2PcInstance extends L2Playable
private int _activeEnchantAttrItemId = ID_NONE;
private long _activeEnchantTimestamp = 0;
private int _firstCompoundOID = -1;
private int _secondCompoundOID = -1;
private L2ItemInstance _usingAStone = null;
private L2ItemInstance _appearanceItem = null;
private L2ItemInstance _targetAppearanceItem = null;
protected boolean _inventoryDisable = false;
/** Player's cubics. */
private final Map<Integer, L2CubicInstance> _cubics = new ConcurrentSkipListMap<>();
@ -13614,6 +13621,13 @@ public final class L2PcInstance extends L2Playable
return -1;
}
public int getBirthdays()
{
long time = (System.currentTimeMillis() - getCreateDate().getTimeInMillis()) / 1000;
time /= TimeUnit.DAYS.toMillis(365);
return (int) time;
}
/**
* list of character friends
*/
@ -15078,9 +15092,6 @@ public final class L2PcInstance extends L2Playable
_vitalityPoints = points;
}
int _firstCompoundOID = -1;
int _secondCompoundOID = -1;
public int getFirstCompoundOID()
{
return _firstCompoundOID;
@ -15101,8 +15112,6 @@ public final class L2PcInstance extends L2Playable
_secondCompoundOID = secondCompoundOID;
}
L2ItemInstance _usingAStone = null;
public L2ItemInstance getUsingAppearanceStone()
{
return _usingAStone;
@ -15113,9 +15122,6 @@ public final class L2PcInstance extends L2Playable
_usingAStone = stone;
}
L2ItemInstance _appearanceItem = null;
L2ItemInstance _targetAppearanceItem = null;
public L2ItemInstance getAppearanceItem()
{
return _appearanceItem;
@ -15135,4 +15141,21 @@ public final class L2PcInstance extends L2Playable
{
_targetAppearanceItem = item;
}
/**
* @return the prime shop points of the player.
*/
public int getPrimePoints()
{
return getAccountVariables().getInt("PrimePoints", 0);
}
/**
* Sets prime shop for current player.
* @param points
*/
public void setPrimePoints(int points)
{
getAccountVariables().set("PrimePoints", points);
}
}

View File

@ -27,20 +27,20 @@ public class AppearanceStone
{
public enum StoneType
{
None,
Normal,
Blessed,
Fixed,
Restore
NONE,
NORMAL,
BLESSED,
FIXED,
RESTORE
}
public enum AppearanceItemType
{
None,
Weapon,
Armor,
Accessory,
All
NONE,
WEAPON,
ARMOR,
ACCESSORY,
ALL
}
private final int _itemId;

View File

@ -25,6 +25,7 @@ import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ScheduledFuture;
import java.util.logging.Level;
@ -371,6 +372,12 @@ public final class Instance
_manualSpawn.clear();
}
public void removeSpawnedNpcs()
{
_npcs.stream().filter(Objects::nonNull).forEach(L2Npc::deleteMe);
_npcs.clear();
}
public void removeDoors()
{
for (L2DoorInstance door : _doors.values())

View File

@ -18,6 +18,8 @@
*/
package com.l2jserver.gameserver.model.interfaces;
import java.time.Duration;
/**
* More advanced interface for parsers.<br>
* Allows usage of get methods without fall back value.<br>
@ -42,6 +44,8 @@ public interface IParserAdvUtils extends IParserUtils
public String getString(String key);
public Duration getDuration(String key);
public <T extends Enum<T>> T getEnum(String key, Class<T> clazz);
}

View File

@ -18,6 +18,8 @@
*/
package com.l2jserver.gameserver.model.interfaces;
import java.time.Duration;
/**
* Simple interface for parser, enforces of a fall back value.<br>
* More suitable for developers not sure about their data.<br>
@ -41,5 +43,7 @@ public interface IParserUtils
public String getString(String key, String defaultValue);
public Duration getDuration(String key, Duration defaultValue);
public <T extends Enum<T>> T getEnum(String key, Class<T> clazz, T defaultValue);
}

View File

@ -1106,18 +1106,23 @@ public abstract class Inventory extends ItemContainer
return (item != null) ? item.getDisplayId() : 0;
}
/**
* Returns the visual id of the item in the paperdoll slot
* @param slot : int designating the slot
* @return int designating the ID of the item
*/
public int getPaperdollItemVisualId(int slot)
{
final L2ItemInstance item = _paperdoll[slot];
return (item != null) ? item.getVisualId() : 0;
}
public int getPaperdollAugmentationId(int slot)
{
final L2ItemInstance item = _paperdoll[slot];
return ((item != null) && (item.getAugmentation() != null)) ? item.getAugmentation().getAugmentationId() : 0;
}
public int getPaperdollVisualId(int slot)
{
final L2ItemInstance item = _paperdoll[slot];
return (item != null) ? item.getAppearanceId() : 0;
}
/**
* Returns the objectID associated to the item in the paperdoll slot
* @param slot : int pointing out the slot

View File

@ -21,7 +21,7 @@ package com.l2jserver.gameserver.model.items;
import java.util.ArrayList;
import java.util.List;
import com.l2jserver.gameserver.data.xml.impl.AppearanceStonesData;
import com.l2jserver.gameserver.data.xml.impl.AppearanceItemData;
import com.l2jserver.gameserver.model.L2ExtractableProduct;
import com.l2jserver.gameserver.model.StatsSet;
import com.l2jserver.gameserver.model.entity.AppearanceStone;
@ -123,7 +123,7 @@ public final class L2EtcItem extends L2Item
}
_isInfinite = set.getBoolean("is_infinite", false);
_appearanceStone = (_handler != null) && _handler.equalsIgnoreCase("ItemAppearance") ? AppearanceStonesData.getInstance().getStone(getId()) : null;
_appearanceStone = (_handler != null) && _handler.equals("Appearance") ? AppearanceItemData.getInstance().getStone(getId()) : null;
}
/**

View File

@ -97,7 +97,7 @@ public class L2WarehouseItem
_elemDefAttr[i] = item.getElementDefAttr(i);
}
_enchantOptions = item.getEnchantOptions();
_appearanceId = item.getAppearanceId();
_appearanceId = item.getVisualId();
_appearanceTime = item.getAppearanceTime();
}

View File

@ -1676,7 +1676,7 @@ public final class L2ItemInstance extends L2Object
ps.setInt(7, getCustomType2());
ps.setInt(8, getMana());
ps.setLong(9, getTime());
ps.setInt(10, getAppearanceId());
ps.setInt(10, getVisualId());
ps.setLong(11, getAppearanceTime());
ps.setInt(12, getObjectId());
ps.executeUpdate();
@ -2262,7 +2262,7 @@ public final class L2ItemInstance extends L2Object
}
}
public int getAppearanceId()
public int getVisualId()
{
return _appearanceId;
}

View File

@ -0,0 +1,205 @@
/*
* Copyright (C) 2004-2015 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server 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.
*
* L2J Server is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.model.primeshop;
import java.util.List;
import com.l2jserver.gameserver.model.StatsSet;
/**
* @author UnAfraid
*/
public class PrimeShopGroup
{
private final int _brId;
private final int _category;
private final int _paymentType;
private final int _price;
private final int _panelType;
private final int _recommended;
private final int _start;
private final int _end;
private final int _daysOfWeek;
private final int _startHour;
private final int _startMinute;
private final int _stopHour;
private final int _stopMinute;
private final int _stock;
private final int _maxStock;
private final int _salePercent;
private final int _minLevel;
private final int _maxLevel;
private final int _minBirthday;
private final int _maxBirthday;
private final int _restrictionDay;
private final int _availableCount;
private final List<PrimeShopItem> _items;
public PrimeShopGroup(StatsSet set, List<PrimeShopItem> items)
{
_brId = set.getInt("id");
_category = set.getInt("cat", 0);
_paymentType = set.getInt("paymentType", 0);
_price = set.getInt("price");
_panelType = set.getInt("panelType", 0);
_recommended = set.getInt("recommended", 0);
_start = set.getInt("startSale", 0);
_end = set.getInt("endSale", 0);
_daysOfWeek = set.getInt("daysOfWeek", 127);
_startHour = set.getInt("startHour", 0);
_startMinute = set.getInt("startMinute", 0);
_stopHour = set.getInt("stopHour", 0);
_stopMinute = set.getInt("stopMinute", 0);
_stock = set.getInt("stock", 0);
_maxStock = set.getInt("maxStock", -1);
_salePercent = set.getInt("salePercent", 0);
_minLevel = set.getInt("minLevel", 0);
_maxLevel = set.getInt("maxLevel", 0);
_minBirthday = set.getInt("minBirthday", 0);
_maxBirthday = set.getInt("maxBirthday", 0);
_restrictionDay = set.getInt("restrictionDay", 0);
_availableCount = set.getInt("availableCount", 0);
_items = items;
}
public int getBrId()
{
return _brId;
}
public int getCat()
{
return _category;
}
public int getPaymentType()
{
return _paymentType;
}
public int getPrice()
{
return _price;
}
public long getCount()
{
return _items.stream().mapToLong(PrimeShopItem::getCount).sum();
}
public int getWeight()
{
return _items.stream().mapToInt(PrimeShopItem::getWeight).sum();
}
public int getPanelType()
{
return _panelType;
}
public int getRecommended()
{
return _recommended;
}
public int getStartSale()
{
return _start;
}
public int getEndSale()
{
return _end;
}
public int getDaysOfWeek()
{
return _daysOfWeek;
}
public int getStartHour()
{
return _startHour;
}
public int getStartMinute()
{
return _startMinute;
}
public int getStopHour()
{
return _stopHour;
}
public int getStopMinute()
{
return _stopMinute;
}
public int getStock()
{
return _stock;
}
public int getTotal()
{
return _maxStock;
}
public int getSalePercent()
{
return _salePercent;
}
public int getMinLevel()
{
return _minLevel;
}
public int getMaxLevel()
{
return _maxLevel;
}
public int getMinBirthday()
{
return _minBirthday;
}
public int getMaxBirthday()
{
return _maxBirthday;
}
public int getRestrictionDay()
{
return _restrictionDay;
}
public int getAvailableCount()
{
return _availableCount;
}
public List<PrimeShopItem> getItems()
{
return _items;
}
}

View File

@ -0,0 +1,48 @@
/*
* Copyright (C) 2004-2015 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server 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.
*
* L2J Server is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.model.primeshop;
import com.l2jserver.gameserver.model.holders.ItemHolder;
/**
* @author UnAfraid
*/
public class PrimeShopItem extends ItemHolder
{
private final int _weight;
private final int _isTradable;
public PrimeShopItem(int itemId, int count, int weight, int isTradable)
{
super(itemId, count);
_weight = weight;
_isTradable = isTradable;
}
public int getWeight()
{
return _weight;
}
public int isTradable()
{
return _isTradable;
}
}

View File

@ -23,13 +23,14 @@ import java.util.concurrent.atomic.AtomicBoolean;
import javolution.util.FastMap;
import com.l2jserver.gameserver.model.StatsSet;
import com.l2jserver.gameserver.model.interfaces.IDeletable;
import com.l2jserver.gameserver.model.interfaces.IRestorable;
import com.l2jserver.gameserver.model.interfaces.IStorable;
/**
* @author UnAfraid
*/
public abstract class AbstractVariables extends StatsSet implements IRestorable, IStorable
public abstract class AbstractVariables extends StatsSet implements IRestorable, IStorable, IDeletable
{
private final AtomicBoolean _hasChanges = new AtomicBoolean(false);
@ -84,6 +85,21 @@ public abstract class AbstractVariables extends StatsSet implements IRestorable,
super.set(name, value);
}
/**
* Put's entry to the variables and marks as changed if required (<i>Useful when restoring to do not save them again</i>).
* @param name
* @param value
* @param markAsChanged
*/
public final void set(String name, String value, boolean markAsChanged)
{
if (markAsChanged)
{
_hasChanges.compareAndSet(false, true);
}
super.set(name, value);
}
/**
* Return true if there exists a record for the variable name.
* @param name

View File

@ -118,4 +118,27 @@ public class AccountVariables extends AbstractVariables
}
return true;
}
@Override
public boolean deleteMe()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection())
{
// Clear previous entries.
try (PreparedStatement st = con.prepareStatement(DELETE_QUERY))
{
st.setString(1, _accountName);
st.execute();
}
// Clear all entries
getSet().clear();
}
catch (Exception e)
{
_log.log(Level.WARNING, getClass().getSimpleName() + ": Couldn't delete variables for: " + _accountName, e);
return false;
}
return true;
}
}

View File

@ -44,4 +44,10 @@ public class NpcVariables extends AbstractVariables
{
return true;
}
@Override
public boolean deleteMe()
{
return true;
}
}

View File

@ -121,6 +121,29 @@ public class PlayerVariables extends AbstractVariables
return true;
}
@Override
public boolean deleteMe()
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection())
{
// Clear previous entries.
try (PreparedStatement st = con.prepareStatement(DELETE_QUERY))
{
st.setInt(1, _objectId);
st.execute();
}
// Clear all entries
getSet().clear();
}
catch (Exception e)
{
_log.log(Level.WARNING, getClass().getSimpleName() + ": Couldn't delete variables for: " + getPlayer(), e);
return false;
}
return true;
}
public L2PcInstance getPlayer()
{
return L2World.getInstance().getPlayer(_objectId);