Adapting Appearance Stone system from L2jServer.
This commit is contained in:
@@ -19,7 +19,6 @@
|
||||
package com.l2jserver.gameserver.model.items;
|
||||
|
||||
import com.l2jserver.gameserver.model.StatsSet;
|
||||
import com.l2jserver.gameserver.model.entity.AppearanceStone;
|
||||
import com.l2jserver.gameserver.model.holders.SkillHolder;
|
||||
import com.l2jserver.gameserver.model.items.type.ArmorType;
|
||||
import com.l2jserver.gameserver.model.skills.Skill;
|
||||
@@ -118,10 +117,4 @@ public final class L2Armor extends L2Item
|
||||
}
|
||||
return _enchant4Skill.getSkill();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AppearanceStone getAppearanceStone()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@@ -21,10 +21,8 @@ package com.l2jserver.gameserver.model.items;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
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;
|
||||
import com.l2jserver.gameserver.model.itemcontainer.Inventory;
|
||||
import com.l2jserver.gameserver.model.items.type.EtcItemType;
|
||||
import com.l2jserver.util.StringUtil;
|
||||
@@ -39,7 +37,6 @@ public final class L2EtcItem extends L2Item
|
||||
private final boolean _isBlessed;
|
||||
private final List<L2ExtractableProduct> _extractableItems;
|
||||
private final boolean _isInfinite;
|
||||
private final AppearanceStone _appearanceStone;
|
||||
|
||||
/**
|
||||
* Constructor for EtcItem.
|
||||
@@ -123,7 +120,6 @@ public final class L2EtcItem extends L2Item
|
||||
}
|
||||
|
||||
_isInfinite = set.getBoolean("is_infinite", false);
|
||||
_appearanceStone = (_handler != null) && _handler.equals("Appearance") ? AppearanceItemData.getInstance().getStone(getId()) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -175,10 +171,4 @@ public final class L2EtcItem extends L2Item
|
||||
{
|
||||
return _isInfinite;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AppearanceStone getAppearanceStone()
|
||||
{
|
||||
return _appearanceStone;
|
||||
}
|
||||
}
|
||||
|
@@ -35,7 +35,6 @@ import com.l2jserver.gameserver.model.actor.L2Character;
|
||||
import com.l2jserver.gameserver.model.actor.L2Summon;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.conditions.Condition;
|
||||
import com.l2jserver.gameserver.model.entity.AppearanceStone;
|
||||
import com.l2jserver.gameserver.model.events.ListenersContainer;
|
||||
import com.l2jserver.gameserver.model.holders.SkillHolder;
|
||||
import com.l2jserver.gameserver.model.interfaces.IIdentifiable;
|
||||
@@ -964,6 +963,4 @@ public abstract class L2Item extends ListenersContainer implements IIdentifiable
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public abstract AppearanceStone getAppearanceStone();
|
||||
}
|
||||
|
@@ -64,9 +64,6 @@ public class L2WarehouseItem
|
||||
|
||||
private final int _time;
|
||||
|
||||
private final int _appearanceId;
|
||||
private final long _appearanceTime;
|
||||
|
||||
public L2WarehouseItem(L2ItemInstance item)
|
||||
{
|
||||
_item = item.getItem();
|
||||
@@ -97,8 +94,6 @@ public class L2WarehouseItem
|
||||
_elemDefAttr[i] = item.getElementDefAttr(i);
|
||||
}
|
||||
_enchantOptions = item.getEnchantOptions();
|
||||
_appearanceId = item.getVisualId();
|
||||
_appearanceTime = item.getAppearanceTime();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -301,14 +296,4 @@ public class L2WarehouseItem
|
||||
{
|
||||
return _item.toString();
|
||||
}
|
||||
|
||||
public int getAppearanceId()
|
||||
{
|
||||
return _appearanceId;
|
||||
}
|
||||
|
||||
public long getAppearanceTime()
|
||||
{
|
||||
return _appearanceTime;
|
||||
}
|
||||
}
|
||||
|
@@ -26,7 +26,6 @@ import com.l2jserver.gameserver.model.actor.L2Npc;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.conditions.Condition;
|
||||
import com.l2jserver.gameserver.model.conditions.ConditionGameChance;
|
||||
import com.l2jserver.gameserver.model.entity.AppearanceStone;
|
||||
import com.l2jserver.gameserver.model.events.EventDispatcher;
|
||||
import com.l2jserver.gameserver.model.events.impl.character.npc.OnNpcSkillSee;
|
||||
import com.l2jserver.gameserver.model.holders.SkillHolder;
|
||||
@@ -450,10 +449,4 @@ public final class L2Weapon extends L2Item
|
||||
caster.sendPacket(sm);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AppearanceStone getAppearanceStone()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* 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.items.appearance;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public enum AppearanceHandType
|
||||
{
|
||||
NONE,
|
||||
ONE_HANDED,
|
||||
TWO_HANDED,
|
||||
}
|
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* 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.items.appearance;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public enum AppearanceMagicType
|
||||
{
|
||||
NONE,
|
||||
MAGICAL,
|
||||
PHYISICAL,
|
||||
}
|
@@ -0,0 +1,210 @@
|
||||
/*
|
||||
* 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.items.appearance;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import com.l2jserver.gameserver.datatables.ItemTable;
|
||||
import com.l2jserver.gameserver.enums.Race;
|
||||
import com.l2jserver.gameserver.model.StatsSet;
|
||||
import com.l2jserver.gameserver.model.items.L2Item;
|
||||
import com.l2jserver.gameserver.model.items.type.ArmorType;
|
||||
import com.l2jserver.gameserver.model.items.type.CrystalType;
|
||||
import com.l2jserver.gameserver.model.items.type.WeaponType;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class AppearanceStone
|
||||
{
|
||||
private final int _id;
|
||||
private final int _cost;
|
||||
private final int _visualId;
|
||||
private final long _lifeTime;
|
||||
private final AppearanceType _type;
|
||||
private final WeaponType _weaponType;
|
||||
private final ArmorType _armorType;
|
||||
private final AppearanceHandType _handType;
|
||||
private final AppearanceMagicType _magicType;
|
||||
private List<CrystalType> _crystalTypes;
|
||||
private List<AppearanceTargetType> _targetTypes;
|
||||
private List<Integer> _bodyParts;
|
||||
private List<Race> _races;
|
||||
private List<Race> _racesNot;
|
||||
|
||||
public AppearanceStone(StatsSet set)
|
||||
{
|
||||
_id = set.getInt("id");
|
||||
_visualId = set.getInt("visualId", 0);
|
||||
_cost = set.getInt("cost", 0);
|
||||
_lifeTime = set.getDuration("lifeTime", Duration.ofSeconds(0)).toMillis();
|
||||
_type = set.getEnum("type", AppearanceType.class, AppearanceType.NONE);
|
||||
_weaponType = set.getEnum("weaponType", WeaponType.class, WeaponType.NONE);
|
||||
_armorType = set.getEnum("armorType", ArmorType.class, ArmorType.NONE);
|
||||
_handType = set.getEnum("handType", AppearanceHandType.class, AppearanceHandType.NONE);
|
||||
_magicType = set.getEnum("magicType", AppearanceMagicType.class, AppearanceMagicType.NONE);
|
||||
|
||||
final CrystalType crystalType = set.getEnum("crystalType", CrystalType.class, CrystalType.NONE);
|
||||
if (crystalType != CrystalType.NONE)
|
||||
{
|
||||
addCrystalType(crystalType);
|
||||
}
|
||||
final AppearanceTargetType targetType = set.getEnum("targetType", AppearanceTargetType.class, AppearanceTargetType.NONE);
|
||||
if (targetType != AppearanceTargetType.NONE)
|
||||
{
|
||||
addTargetType(targetType);
|
||||
}
|
||||
|
||||
final int bodyPart = ItemTable._slots.get(set.getString("bodyPart", "none"));
|
||||
if (bodyPart != L2Item.SLOT_NONE)
|
||||
{
|
||||
addBodyPart(bodyPart);
|
||||
}
|
||||
|
||||
final Race race = set.getEnum("race", Race.class, Race.NONE);
|
||||
if (race != Race.NONE)
|
||||
{
|
||||
addRace(race);
|
||||
}
|
||||
|
||||
final Race raceNot = set.getEnum("raceNot", Race.class, Race.NONE);
|
||||
if (raceNot != Race.NONE)
|
||||
{
|
||||
addRaceNot(raceNot);
|
||||
}
|
||||
}
|
||||
|
||||
public int getId()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
public int getVisualId()
|
||||
{
|
||||
return _visualId;
|
||||
}
|
||||
|
||||
public int getCost()
|
||||
{
|
||||
return _cost;
|
||||
}
|
||||
|
||||
public long getLifeTime()
|
||||
{
|
||||
return _lifeTime;
|
||||
}
|
||||
|
||||
public AppearanceType getType()
|
||||
{
|
||||
return _type;
|
||||
}
|
||||
|
||||
public WeaponType getWeaponType()
|
||||
{
|
||||
return _weaponType;
|
||||
}
|
||||
|
||||
public ArmorType getArmorType()
|
||||
{
|
||||
return _armorType;
|
||||
}
|
||||
|
||||
public AppearanceHandType getHandType()
|
||||
{
|
||||
return _handType;
|
||||
}
|
||||
|
||||
public AppearanceMagicType getMagicType()
|
||||
{
|
||||
return _magicType;
|
||||
}
|
||||
|
||||
public void addCrystalType(CrystalType type)
|
||||
{
|
||||
if (_crystalTypes == null)
|
||||
{
|
||||
_crystalTypes = new ArrayList<>();
|
||||
}
|
||||
_crystalTypes.add(type);
|
||||
}
|
||||
|
||||
public List<CrystalType> getCrystalTypes()
|
||||
{
|
||||
return _crystalTypes != null ? _crystalTypes : Collections.emptyList();
|
||||
}
|
||||
|
||||
public void addTargetType(AppearanceTargetType type)
|
||||
{
|
||||
if (_targetTypes == null)
|
||||
{
|
||||
_targetTypes = new ArrayList<>();
|
||||
}
|
||||
_targetTypes.add(type);
|
||||
}
|
||||
|
||||
public List<AppearanceTargetType> getTargetTypes()
|
||||
{
|
||||
return _targetTypes != null ? _targetTypes : Collections.emptyList();
|
||||
}
|
||||
|
||||
public void addBodyPart(Integer part)
|
||||
{
|
||||
if (_bodyParts == null)
|
||||
{
|
||||
_bodyParts = new ArrayList<>();
|
||||
}
|
||||
_bodyParts.add(part);
|
||||
}
|
||||
|
||||
public List<Integer> getBodyParts()
|
||||
{
|
||||
return _bodyParts != null ? _bodyParts : Collections.emptyList();
|
||||
}
|
||||
|
||||
public void addRace(Race race)
|
||||
{
|
||||
if (_races == null)
|
||||
{
|
||||
_races = new ArrayList<>();
|
||||
}
|
||||
_races.add(race);
|
||||
}
|
||||
|
||||
public List<Race> getRaces()
|
||||
{
|
||||
return _races != null ? _races : Collections.emptyList();
|
||||
}
|
||||
|
||||
public void addRaceNot(Race race)
|
||||
{
|
||||
if (_racesNot == null)
|
||||
{
|
||||
_racesNot = new ArrayList<>();
|
||||
}
|
||||
_racesNot.add(race);
|
||||
}
|
||||
|
||||
public List<Race> getRacesNot()
|
||||
{
|
||||
return _racesNot != null ? _racesNot : Collections.emptyList();
|
||||
}
|
||||
}
|
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* 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.items.appearance;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public enum AppearanceTargetType
|
||||
{
|
||||
NONE,
|
||||
WEAPON,
|
||||
ARMOR,
|
||||
ACCESSORY,
|
||||
ALL
|
||||
}
|
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* 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.items.appearance;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public enum AppearanceType
|
||||
{
|
||||
NONE,
|
||||
NORMAL,
|
||||
BLESSED,
|
||||
FIXED,
|
||||
RESTORE;
|
||||
}
|
@@ -37,12 +37,14 @@ import com.l2jserver.Config;
|
||||
import com.l2jserver.L2DatabaseFactory;
|
||||
import com.l2jserver.gameserver.GeoData;
|
||||
import com.l2jserver.gameserver.ThreadPoolManager;
|
||||
import com.l2jserver.gameserver.data.xml.impl.AppearanceItemData;
|
||||
import com.l2jserver.gameserver.data.xml.impl.EnchantItemOptionsData;
|
||||
import com.l2jserver.gameserver.data.xml.impl.OptionData;
|
||||
import com.l2jserver.gameserver.datatables.ItemTable;
|
||||
import com.l2jserver.gameserver.enums.InstanceType;
|
||||
import com.l2jserver.gameserver.enums.ItemLocation;
|
||||
import com.l2jserver.gameserver.enums.ShotType;
|
||||
import com.l2jserver.gameserver.enums.UserInfoType;
|
||||
import com.l2jserver.gameserver.idfactory.IdFactory;
|
||||
import com.l2jserver.gameserver.instancemanager.ItemsOnGroundManager;
|
||||
import com.l2jserver.gameserver.instancemanager.MercTicketManager;
|
||||
@@ -69,14 +71,17 @@ import com.l2jserver.gameserver.model.items.L2Armor;
|
||||
import com.l2jserver.gameserver.model.items.L2EtcItem;
|
||||
import com.l2jserver.gameserver.model.items.L2Item;
|
||||
import com.l2jserver.gameserver.model.items.L2Weapon;
|
||||
import com.l2jserver.gameserver.model.items.appearance.AppearanceStone;
|
||||
import com.l2jserver.gameserver.model.items.type.EtcItemType;
|
||||
import com.l2jserver.gameserver.model.items.type.ItemType;
|
||||
import com.l2jserver.gameserver.model.options.EnchantOptions;
|
||||
import com.l2jserver.gameserver.model.options.Options;
|
||||
import com.l2jserver.gameserver.model.stats.functions.AbstractFunction;
|
||||
import com.l2jserver.gameserver.model.variables.ItemVariables;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.DropItem;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExAdenaInvenCount;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExUserInfoEquipSlot;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExUserInfoInvenWeight;
|
||||
import com.l2jserver.gameserver.network.serverpackets.GetItem;
|
||||
import com.l2jserver.gameserver.network.serverpackets.InventoryUpdate;
|
||||
@@ -163,6 +168,7 @@ public final class L2ItemInstance extends L2Object
|
||||
|
||||
private ScheduledFuture<?> itemLootShedule = null;
|
||||
private ScheduledFuture<?> _lifeTimeTask;
|
||||
private ScheduledFuture<?> _appearanceLifeTimeTask;
|
||||
|
||||
private final DropProtection _dropProtection = new DropProtection();
|
||||
|
||||
@@ -170,9 +176,6 @@ public final class L2ItemInstance extends L2Object
|
||||
|
||||
private final List<Options> _enchantOptions = new ArrayList<>();
|
||||
|
||||
private int _appearanceId = 0;
|
||||
private long _appearanceTime = -1;
|
||||
|
||||
/**
|
||||
* Constructor of the L2ItemInstance from the objectId and the itemId.
|
||||
* @param objectId : int designating the ID of the object in the world
|
||||
@@ -1502,8 +1505,8 @@ public final class L2ItemInstance extends L2Object
|
||||
public static L2ItemInstance restoreFromDb(int ownerId, ResultSet rs)
|
||||
{
|
||||
L2ItemInstance inst = null;
|
||||
int objectId, item_id, loc_data, enchant_level, custom_type1, custom_type2, manaLeft, appearance_id;
|
||||
long time, count, appearance_time;
|
||||
int objectId, item_id, loc_data, enchant_level, custom_type1, custom_type2, manaLeft;
|
||||
long time, count;
|
||||
ItemLocation loc;
|
||||
try
|
||||
{
|
||||
@@ -1517,8 +1520,6 @@ public final class L2ItemInstance extends L2Object
|
||||
custom_type2 = rs.getInt("custom_type2");
|
||||
manaLeft = rs.getInt("mana_left");
|
||||
time = rs.getLong("time");
|
||||
appearance_id = rs.getInt("appearance_id");
|
||||
appearance_time = rs.getLong("appearance_time");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -1545,8 +1546,6 @@ public final class L2ItemInstance extends L2Object
|
||||
// Setup life time for shadow weapons
|
||||
inst._mana = manaLeft;
|
||||
inst._time = time;
|
||||
inst._appearanceId = appearance_id;
|
||||
inst._appearanceTime = appearance_time;
|
||||
|
||||
// load augmentation and elemental enchant
|
||||
if (inst.isEquipable())
|
||||
@@ -1665,7 +1664,7 @@ public final class L2ItemInstance extends L2Object
|
||||
}
|
||||
|
||||
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("UPDATE items SET owner_id=?,count=?,loc=?,loc_data=?,enchant_level=?,custom_type1=?,custom_type2=?,mana_left=?,time=?,appearance_id=?,appearance_time=? " + "WHERE object_id = ?"))
|
||||
PreparedStatement ps = con.prepareStatement("UPDATE items SET owner_id=?,count=?,loc=?,loc_data=?,enchant_level=?,custom_type1=?,custom_type2=?,mana_left=?,time=? " + "WHERE object_id = ?"))
|
||||
{
|
||||
ps.setInt(1, _ownerId);
|
||||
ps.setLong(2, getCount());
|
||||
@@ -1676,9 +1675,7 @@ public final class L2ItemInstance extends L2Object
|
||||
ps.setInt(7, getCustomType2());
|
||||
ps.setInt(8, getMana());
|
||||
ps.setLong(9, getTime());
|
||||
ps.setInt(10, getVisualId());
|
||||
ps.setLong(11, getAppearanceTime());
|
||||
ps.setInt(12, getObjectId());
|
||||
ps.setInt(10, getObjectId());
|
||||
ps.executeUpdate();
|
||||
_existsInDb = true;
|
||||
_storedInDb = true;
|
||||
@@ -2260,27 +2257,101 @@ public final class L2ItemInstance extends L2Object
|
||||
_lifeTimeTask.cancel(false);
|
||||
_lifeTimeTask = null;
|
||||
}
|
||||
|
||||
if ((_appearanceLifeTimeTask != null) && !_appearanceLifeTimeTask.isDone())
|
||||
{
|
||||
_appearanceLifeTimeTask.cancel(false);
|
||||
_appearanceLifeTimeTask = null;
|
||||
}
|
||||
}
|
||||
|
||||
public final ItemVariables getVariables()
|
||||
{
|
||||
final ItemVariables vars = getScript(ItemVariables.class);
|
||||
return vars != null ? vars : addScript(new ItemVariables(getObjectId()));
|
||||
}
|
||||
|
||||
public int getVisualId()
|
||||
{
|
||||
return _appearanceId;
|
||||
final int visualId = getVariables().getInt(ItemVariables.VISUAL_ID, 0);
|
||||
if (visualId > 0)
|
||||
{
|
||||
final int appearanceStoneId = getVariables().getInt(ItemVariables.VISUAL_APPEARANCE_STONE_ID, 0);
|
||||
if (appearanceStoneId > 0)
|
||||
{
|
||||
final AppearanceStone stone = AppearanceItemData.getInstance().getStone(appearanceStoneId);
|
||||
if (stone != null)
|
||||
{
|
||||
final L2PcInstance player = getActingPlayer();
|
||||
if (player != null)
|
||||
{
|
||||
if (!stone.getRaces().isEmpty() && !stone.getRaces().contains(player.getRace()))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (!stone.getRacesNot().isEmpty() && stone.getRacesNot().contains(player.getRace()))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return visualId;
|
||||
}
|
||||
|
||||
public void setAppearanceId(int appearanceId)
|
||||
public void setVisualId(int visualId)
|
||||
{
|
||||
_storedInDb = false;
|
||||
_appearanceId = appearanceId;
|
||||
getVariables().set(ItemVariables.VISUAL_ID, visualId);
|
||||
}
|
||||
|
||||
public long getAppearanceTime()
|
||||
public long getVisualLifeTime()
|
||||
{
|
||||
_storedInDb = false;
|
||||
return _appearanceTime;
|
||||
return getVariables().getLong(ItemVariables.VISUAL_APPEARANCE_LIFE_TIME, 0);
|
||||
}
|
||||
|
||||
public void setAppearanceTime(long appearanceTime)
|
||||
public void scheduleVisualLifeTime()
|
||||
{
|
||||
_appearanceTime = appearanceTime;
|
||||
if (_appearanceLifeTimeTask != null)
|
||||
{
|
||||
_appearanceLifeTimeTask.cancel(false);
|
||||
}
|
||||
if (getVisualLifeTime() > 0)
|
||||
{
|
||||
final long time = getVisualLifeTime() - System.currentTimeMillis();
|
||||
if (time > 0)
|
||||
{
|
||||
_appearanceLifeTimeTask = ThreadPoolManager.getInstance().scheduleGeneral(this::onVisualLifeTimeEnd, time);
|
||||
}
|
||||
else
|
||||
{
|
||||
ThreadPoolManager.getInstance().executeGeneral(this::onVisualLifeTimeEnd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private final void onVisualLifeTimeEnd()
|
||||
{
|
||||
final ItemVariables vars = getVariables();
|
||||
vars.remove(ItemVariables.VISUAL_ID);
|
||||
vars.remove(ItemVariables.VISUAL_APPEARANCE_STONE_ID);
|
||||
vars.remove(ItemVariables.VISUAL_APPEARANCE_LIFE_TIME);
|
||||
vars.storeMe();
|
||||
|
||||
final L2PcInstance player = getActingPlayer();
|
||||
if (player != null)
|
||||
{
|
||||
final InventoryUpdate iu = new InventoryUpdate();
|
||||
iu.addModifiedItem(this);
|
||||
player.broadcastUserInfo(UserInfoType.APPAREANCE);
|
||||
player.sendPacket(new ExUserInfoEquipSlot(player));
|
||||
player.sendPacket(iu);
|
||||
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.S1_HAS_BEEN_RESTORED_TO_ITS_PREVIOUS_APPEARANCE_AS_ITS_TEMPORARY_MODIFICATION_HAS_EXPIRED).addItemName(this));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isAppearanceable()
|
||||
{
|
||||
return isWeapon() || isArmor();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user