|
@@ -55,11 +55,8 @@ import com.l2jserver.gameserver.templates.item.L2ItemType;
|
|
|
import com.l2jserver.gameserver.templates.item.L2Weapon;
|
|
|
import com.l2jserver.gameserver.util.GMAudit;
|
|
|
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
* This class manages items.
|
|
|
- *
|
|
|
* @version $Revision: 1.4.2.1.2.11 $ $Date: 2005/03/31 16:07:50 $
|
|
|
*/
|
|
|
public final class L2ItemInstance extends L2Object
|
|
@@ -68,7 +65,7 @@ public final class L2ItemInstance extends L2Object
|
|
|
private static final Logger _logItems = Logger.getLogger("item");
|
|
|
|
|
|
/** Enumeration of locations for item */
|
|
|
- public static enum ItemLocation
|
|
|
+ public static enum ItemLocation
|
|
|
{
|
|
|
VOID,
|
|
|
INVENTORY,
|
|
@@ -107,7 +104,7 @@ public final class L2ItemInstance extends L2Object
|
|
|
/** Location of the item : Inventory, PaperDoll, WareHouse */
|
|
|
private ItemLocation _loc;
|
|
|
|
|
|
- /** Slot where item is stored : Paperdoll slot, inventory order ...*/
|
|
|
+ /** Slot where item is stored : Paperdoll slot, inventory order ... */
|
|
|
private int _locData;
|
|
|
|
|
|
/** Level of enchantment of the item */
|
|
@@ -117,10 +114,10 @@ public final class L2ItemInstance extends L2Object
|
|
|
private boolean _wear;
|
|
|
|
|
|
/** Augmented Item */
|
|
|
- private L2Augmentation _augmentation=null;
|
|
|
+ private L2Augmentation _augmentation = null;
|
|
|
|
|
|
/** Shadow item */
|
|
|
- private int _mana=-1;
|
|
|
+ private int _mana = -1;
|
|
|
private boolean _consumingMana = false;
|
|
|
private static final int MANA_CONSUMPTION_RATE = 60000;
|
|
|
|
|
@@ -132,18 +129,18 @@ public final class L2ItemInstance extends L2Object
|
|
|
|
|
|
private boolean _published = false;
|
|
|
|
|
|
- public static final int CHARGED_NONE = 0;
|
|
|
- public static final int CHARGED_SOULSHOT = 1;
|
|
|
- public static final int CHARGED_SPIRITSHOT = 1;
|
|
|
- //public static final int CHARGED_BLESSED_SOULSHOT = 2; // It's a really exists? ;-)
|
|
|
- public static final int CHARGED_BLESSED_SPIRITSHOT = 2;
|
|
|
+ public static final int CHARGED_NONE = 0;
|
|
|
+ public static final int CHARGED_SOULSHOT = 1;
|
|
|
+ public static final int CHARGED_SPIRITSHOT = 1;
|
|
|
+ // public static final int CHARGED_BLESSED_SOULSHOT = 2; // It's a really exists? ;-)
|
|
|
+ public static final int CHARGED_BLESSED_SPIRITSHOT = 2;
|
|
|
|
|
|
/** Item charged with SoulShot (type of SoulShot) */
|
|
|
- private int _chargedSoulshot = CHARGED_NONE;
|
|
|
+ private int _chargedSoulshot = CHARGED_NONE;
|
|
|
/** Item charged with SpiritShot (type of SpiritShot) */
|
|
|
- private int _chargedSpiritshot = CHARGED_NONE;
|
|
|
+ private int _chargedSpiritshot = CHARGED_NONE;
|
|
|
|
|
|
- private boolean _chargedFishtshot = false;
|
|
|
+ private boolean _chargedFishtshot = false;
|
|
|
|
|
|
private boolean _protected;
|
|
|
|
|
@@ -151,7 +148,7 @@ public final class L2ItemInstance extends L2Object
|
|
|
public static final int ADDED = 1;
|
|
|
public static final int REMOVED = 3;
|
|
|
public static final int MODIFIED = 2;
|
|
|
- private int _lastChange = 2; //1 ??, 2 modified, 3 removed
|
|
|
+ private int _lastChange = 2; // 1 ??, 2 modified, 3 removed
|
|
|
private boolean _existsInDb; // if a record exists in DB.
|
|
|
private boolean _storedInDb; // if DB data is up-to-date.
|
|
|
|
|
@@ -163,6 +160,7 @@ public final class L2ItemInstance extends L2Object
|
|
|
public ScheduledFuture<?> _lifeTimeTask;
|
|
|
|
|
|
private final DropProtection _dropProtection = new DropProtection();
|
|
|
+
|
|
|
/**
|
|
|
* Constructor of the L2ItemInstance from the objectId and the itemId.
|
|
|
* @param objectId : int designating the ID of the object in the world
|
|
@@ -183,7 +181,7 @@ public final class L2ItemInstance extends L2Object
|
|
|
_type2 = 0;
|
|
|
_dropTime = 0;
|
|
|
_mana = _item.getDuration();
|
|
|
- _time = _item.getTime() == -1 ? -1 : System.currentTimeMillis() + ((long)_item.getTime()*60*1000);
|
|
|
+ _time = _item.getTime() == -1 ? -1 : System.currentTimeMillis() + ((long) _item.getTime() * 60 * 1000);
|
|
|
scheduleLifeTimeTask();
|
|
|
}
|
|
|
|
|
@@ -204,7 +202,7 @@ public final class L2ItemInstance extends L2Object
|
|
|
setCount(1);
|
|
|
_loc = ItemLocation.VOID;
|
|
|
_mana = _item.getDuration();
|
|
|
- _time = _item.getTime() == -1 ? -1 : System.currentTimeMillis() + ((long)_item.getTime()*60*1000);
|
|
|
+ _time = _item.getTime() == -1 ? -1 : System.currentTimeMillis() + ((long) _item.getTime() * 60 * 1000);
|
|
|
scheduleLifeTimeTask();
|
|
|
}
|
|
|
|
|
@@ -215,23 +213,23 @@ public final class L2ItemInstance extends L2Object
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Remove a L2ItemInstance from the world and send server->client GetItem packets.<BR><BR>
|
|
|
- *
|
|
|
- * <B><U> Actions</U> :</B><BR><BR>
|
|
|
- * <li>Send a Server->Client Packet GetItem to player that pick up and its _knowPlayers member </li>
|
|
|
- * <li>Remove the L2Object from the world</li><BR><BR>
|
|
|
- *
|
|
|
- * <FONT COLOR=#FF0000><B> <U>Caution</U> : This method DOESN'T REMOVE the object from _allObjects of L2World </B></FONT><BR><BR>
|
|
|
- *
|
|
|
- * <B><U> Assert </U> :</B><BR><BR>
|
|
|
- * <li> this instanceof L2ItemInstance</li>
|
|
|
- * <li> _worldRegion != null <I>(L2Object is visible at the beginning)</I></li><BR><BR>
|
|
|
- *
|
|
|
- * <B><U> Example of use </U> :</B><BR><BR>
|
|
|
- * <li> Do Pickup Item : PCInstance and Pet</li><BR><BR>
|
|
|
- *
|
|
|
+ * Remove a L2ItemInstance from the world and send server->client GetItem packets.<BR>
|
|
|
+ * <BR>
|
|
|
+ * <B><U> Actions</U> :</B><BR>
|
|
|
+ * <BR>
|
|
|
+ * <li>Send a Server->Client Packet GetItem to player that pick up and its _knowPlayers member</li> <li>Remove the L2Object from the world</li><BR>
|
|
|
+ * <BR>
|
|
|
+ * <FONT COLOR=#FF0000><B> <U>Caution</U> : This method DOESN'T REMOVE the object from _allObjects of L2World </B></FONT><BR>
|
|
|
+ * <BR>
|
|
|
+ * <B><U> Assert </U> :</B><BR>
|
|
|
+ * <BR>
|
|
|
+ * <li>this instanceof L2ItemInstance</li> <li>_worldRegion != null <I>(L2Object is visible at the beginning)</I></li><BR>
|
|
|
+ * <BR>
|
|
|
+ * <B><U> Example of use </U> :</B><BR>
|
|
|
+ * <BR>
|
|
|
+ * <li>Do Pickup Item : PCInstance and Pet</li><BR>
|
|
|
+ * <BR>
|
|
|
* @param player Player that pick up the item
|
|
|
- *
|
|
|
*/
|
|
|
public final void pickupMe(L2Character player)
|
|
|
{
|
|
@@ -260,8 +258,8 @@ public final class L2ItemInstance extends L2Object
|
|
|
|
|
|
if (!Config.DISABLE_TUTORIAL && (itemId == PcInventory.ADENA_ID || itemId == 6353))
|
|
|
{
|
|
|
- //Note from UnAfraid:
|
|
|
- //Unhardcode this?
|
|
|
+ // Note from UnAfraid:
|
|
|
+ // Unhardcode this?
|
|
|
L2PcInstance actor = player.getActingPlayer();
|
|
|
if (actor != null)
|
|
|
{
|
|
@@ -292,7 +290,10 @@ public final class L2ItemInstance extends L2Object
|
|
|
{
|
|
|
LogRecord record = new LogRecord(Level.INFO, "SETOWNER:" + process);
|
|
|
record.setLoggerName("item");
|
|
|
- record.setParameters(new Object[]{this, creator, reference});
|
|
|
+ record.setParameters(new Object[]
|
|
|
+ {
|
|
|
+ this, creator, reference
|
|
|
+ });
|
|
|
_logItems.log(record);
|
|
|
}
|
|
|
}
|
|
@@ -304,15 +305,13 @@ public final class L2ItemInstance extends L2Object
|
|
|
String referenceName = "no-reference";
|
|
|
if (reference instanceof L2Object)
|
|
|
{
|
|
|
- referenceName = (((L2Object)reference).getName() != null?((L2Object)reference).getName():"no-name");
|
|
|
+ referenceName = (((L2Object) reference).getName() != null ? ((L2Object) reference).getName() : "no-name");
|
|
|
}
|
|
|
else if (reference instanceof String)
|
|
|
- referenceName = (String)reference;
|
|
|
- String targetName = (creator.getTarget() != null?creator.getTarget().getName():"no-target");
|
|
|
+ referenceName = (String) reference;
|
|
|
+ String targetName = (creator.getTarget() != null ? creator.getTarget().getName() : "no-target");
|
|
|
if (Config.GMAUDIT)
|
|
|
- GMAudit.auditGMAction(creator.getName()+" ["+creator.getObjectId()+"]",
|
|
|
- process + "(id: "+getItemId()+" name: "+getName()+")", targetName,
|
|
|
- "L2Object referencing this action is: " + referenceName);
|
|
|
+ GMAudit.auditGMAction(creator.getName() + " [" + creator.getObjectId() + "]", process + "(id: " + getItemId() + " name: " + getName() + ")", targetName, "L2Object referencing this action is: " + referenceName);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -323,7 +322,8 @@ public final class L2ItemInstance extends L2Object
|
|
|
*/
|
|
|
public void setOwnerId(int owner_id)
|
|
|
{
|
|
|
- if (owner_id == _ownerId) return;
|
|
|
+ if (owner_id == _ownerId)
|
|
|
+ return;
|
|
|
|
|
|
_ownerId = owner_id;
|
|
|
_storedInDb = false;
|
|
@@ -348,7 +348,8 @@ public final class L2ItemInstance extends L2Object
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Sets the location of the item.<BR><BR>
|
|
|
+ * Sets the location of the item.<BR>
|
|
|
+ * <BR>
|
|
|
* <U><I>Remark :</I></U> If loc and loc_data different from database, say datas not up-to-date
|
|
|
* @param loc : ItemLocation (enumeration)
|
|
|
* @param loc_data : int designating the slot where the item is stored or the village for freights
|
|
@@ -368,7 +369,8 @@ public final class L2ItemInstance extends L2Object
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Sets the quantity of the item.<BR><BR>
|
|
|
+ * Sets the quantity of the item.<BR>
|
|
|
+ * <BR>
|
|
|
* @param count the new count to set
|
|
|
*/
|
|
|
public void setCount(long count)
|
|
@@ -391,7 +393,8 @@ public final class L2ItemInstance extends L2Object
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Sets the quantity of the item.<BR><BR>
|
|
|
+ * Sets the quantity of the item.<BR>
|
|
|
+ * <BR>
|
|
|
* <U><I>Remark :</I></U> If loc and loc_data different from database, say datas not up-to-date
|
|
|
* @param process : String Identifier of process triggering this action
|
|
|
* @param count : int
|
|
@@ -407,7 +410,7 @@ public final class L2ItemInstance extends L2Object
|
|
|
long old = getCount();
|
|
|
long max = getItemId() == ADENA_ID ? MAX_ADENA : Integer.MAX_VALUE;
|
|
|
|
|
|
- if ( count > 0 && getCount() > max - count)
|
|
|
+ if (count > 0 && getCount() > max - count)
|
|
|
{
|
|
|
setCount(max);
|
|
|
}
|
|
@@ -429,7 +432,10 @@ public final class L2ItemInstance extends L2Object
|
|
|
{
|
|
|
LogRecord record = new LogRecord(Level.INFO, "CHANGE:" + process);
|
|
|
record.setLoggerName("item");
|
|
|
- record.setParameters(new Object[]{this, "PrevCount("+old+")",creator, reference});
|
|
|
+ record.setParameters(new Object[]
|
|
|
+ {
|
|
|
+ this, "PrevCount(" + old + ")", creator, reference
|
|
|
+ });
|
|
|
_logItems.log(record);
|
|
|
}
|
|
|
}
|
|
@@ -441,16 +447,13 @@ public final class L2ItemInstance extends L2Object
|
|
|
String referenceName = "no-reference";
|
|
|
if (reference instanceof L2Object)
|
|
|
{
|
|
|
- referenceName = (((L2Object)reference).getName() != null?((L2Object)reference).getName():"no-name");
|
|
|
+ referenceName = (((L2Object) reference).getName() != null ? ((L2Object) reference).getName() : "no-name");
|
|
|
}
|
|
|
else if (reference instanceof String)
|
|
|
- referenceName = (String)reference;
|
|
|
- String targetName = (creator.getTarget() != null?creator.getTarget().getName():"no-target");
|
|
|
+ referenceName = (String) reference;
|
|
|
+ String targetName = (creator.getTarget() != null ? creator.getTarget().getName() : "no-target");
|
|
|
if (Config.GMAUDIT)
|
|
|
- GMAudit.auditGMAction(creator.getName()+" ["+creator.getObjectId()+"]",
|
|
|
- process + "(id: "+getItemId()+" objId: "+getObjectId()+
|
|
|
- " name: "+getName()+" count: "+count+")", targetName,
|
|
|
- "L2Object referencing this action is: " + referenceName);
|
|
|
+ GMAudit.auditGMAction(creator.getName() + " [" + creator.getObjectId() + "]", process + "(id: " + getItemId() + " objId: " + getObjectId() + " name: " + getName() + " count: " + count + ")", targetName, "L2Object referencing this action is: " + referenceName);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -478,7 +481,7 @@ public final class L2ItemInstance extends L2Object
|
|
|
*/
|
|
|
public boolean isEquipable()
|
|
|
{
|
|
|
- return !(_item.getBodyPart() == 0 || _item.getItemType() == L2EtcItemType.ARROW || _item.getItemType() == L2EtcItemType.BOLT || _item.getItemType() == L2EtcItemType.LURE );
|
|
|
+ return !(_item.getBodyPart() == 0 || _item.getItemType() == L2EtcItemType.ARROW || _item.getItemType() == L2EtcItemType.BOLT || _item.getItemType() == L2EtcItemType.LURE);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -513,26 +516,32 @@ public final class L2ItemInstance extends L2Object
|
|
|
{
|
|
|
return _type1;
|
|
|
}
|
|
|
+
|
|
|
public int getCustomType2()
|
|
|
{
|
|
|
return _type2;
|
|
|
}
|
|
|
+
|
|
|
public void setCustomType1(int newtype)
|
|
|
{
|
|
|
- _type1=newtype;
|
|
|
+ _type1 = newtype;
|
|
|
}
|
|
|
+
|
|
|
public void setCustomType2(int newtype)
|
|
|
{
|
|
|
- _type2=newtype;
|
|
|
+ _type2 = newtype;
|
|
|
}
|
|
|
+
|
|
|
public void setDropTime(long time)
|
|
|
{
|
|
|
- _dropTime=time;
|
|
|
+ _dropTime = time;
|
|
|
}
|
|
|
+
|
|
|
public long getDropTime()
|
|
|
{
|
|
|
return _dropTime;
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* Returns the type of item
|
|
|
* @return Enum
|
|
@@ -619,7 +628,6 @@ public final class L2ItemInstance extends L2Object
|
|
|
|
|
|
/**
|
|
|
* Returns the quantity of crystals for crystallization
|
|
|
- *
|
|
|
* @return int
|
|
|
*/
|
|
|
public final int getCrystalCount()
|
|
@@ -709,7 +717,7 @@ public final class L2ItemInstance extends L2Object
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @param isPrivateWareHouse
|
|
|
+ * @param isPrivateWareHouse
|
|
|
* @return if item can be deposited in warehouse or freight
|
|
|
*/
|
|
|
public boolean isDepositable(boolean isPrivateWareHouse)
|
|
@@ -740,12 +748,12 @@ public final class L2ItemInstance extends L2Object
|
|
|
{
|
|
|
return _item.isPotion();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public boolean isElixir()
|
|
|
{
|
|
|
return _item.isElixir();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public boolean isHeroItem()
|
|
|
{
|
|
|
return _item.isHeroItem();
|
|
@@ -771,25 +779,20 @@ public final class L2ItemInstance extends L2Object
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @param player
|
|
|
- * @param allowAdena
|
|
|
- * @param allowNonTradeable
|
|
|
+ * @param player
|
|
|
+ * @param allowAdena
|
|
|
+ * @param allowNonTradeable
|
|
|
* @return if item is available for manipulation
|
|
|
*/
|
|
|
public boolean isAvailable(L2PcInstance player, boolean allowAdena, boolean allowNonTradeable)
|
|
|
{
|
|
|
- return (
|
|
|
- (!isEquipped()) // Not equipped
|
|
|
- && (getItem().getType2() != L2Item.TYPE2_QUEST) // Not Quest Item
|
|
|
- && (getItem().getType2() != L2Item.TYPE2_MONEY || getItem().getType1() != L2Item.TYPE1_SHIELD_ARMOR) // not money, not shield
|
|
|
- && (player.getPet() == null || getObjectId() != player.getPet().getControlObjectId()) // Not Control item of currently summoned pet
|
|
|
- && (player.getActiveEnchantItem() != this) // Not momentarily used enchant scroll
|
|
|
- && (allowAdena || getItemId() != PcInventory.ADENA_ID) // Not Adena
|
|
|
- && (player.getCurrentSkill() == null || player.getCurrentSkill().getSkill().getItemConsumeId() != getItemId())
|
|
|
- && (!player.isCastingSimultaneouslyNow() || player.getLastSimultaneousSkillCast() == null || player.getLastSimultaneousSkillCast().getItemConsumeId() != getItemId())
|
|
|
- && (allowNonTradeable || isTradeable()
|
|
|
- && (!(getItem().getItemType() == L2EtcItemType.PET_COLLAR && player.havePetInvItems())))
|
|
|
- );
|
|
|
+ return ((!isEquipped()) // Not equipped
|
|
|
+ && (getItem().getType2() != L2Item.TYPE2_QUEST) // Not Quest Item
|
|
|
+ && (getItem().getType2() != L2Item.TYPE2_MONEY || getItem().getType1() != L2Item.TYPE1_SHIELD_ARMOR) // not money, not shield
|
|
|
+ && (player.getPet() == null || getObjectId() != player.getPet().getControlObjectId()) // Not Control item of currently summoned pet
|
|
|
+ && (player.getActiveEnchantItem() != this) // Not momentarily used enchant scroll
|
|
|
+ && (allowAdena || getItemId() != PcInventory.ADENA_ID) // Not Adena
|
|
|
+ && (player.getCurrentSkill() == null || player.getCurrentSkill().getSkill().getItemConsumeId() != getItemId()) && (!player.isCastingSimultaneouslyNow() || player.getLastSimultaneousSkillCast() == null || player.getLastSimultaneousSkillCast().getItemConsumeId() != getItemId()) && (allowNonTradeable || isTradeable() && (!(getItem().getItemType() == L2EtcItemType.PET_COLLAR && player.havePetInvItems()))));
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -812,7 +815,6 @@ public final class L2ItemInstance extends L2Object
|
|
|
_storedInDb = false;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* Returns whether this item is augmented or not
|
|
|
* @return true if augmented
|
|
@@ -848,7 +850,6 @@ public final class L2ItemInstance extends L2Object
|
|
|
|
|
|
/**
|
|
|
* Remove the augmentation
|
|
|
- *
|
|
|
*/
|
|
|
public void removeAugmentation()
|
|
|
{
|
|
@@ -871,7 +872,7 @@ public final class L2ItemInstance extends L2Object
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
- _log.log(Level.SEVERE, "Could not remove augmentation for item: "+this+" from DB:", e);
|
|
|
+ _log.log(Level.SEVERE, "Could not remove augmentation for item: " + this + " from DB:", e);
|
|
|
}
|
|
|
finally
|
|
|
{
|
|
@@ -913,7 +914,7 @@ public final class L2ItemInstance extends L2Object
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
- _log.log(Level.SEVERE, "Could not restore augmentation and elemental data for item " + this + " from DB: "+e.getMessage(), e);
|
|
|
+ _log.log(Level.SEVERE, "Could not restore augmentation and elemental data for item " + this + " from DB: " + e.getMessage(), e);
|
|
|
}
|
|
|
finally
|
|
|
{
|
|
@@ -938,7 +939,7 @@ public final class L2ItemInstance extends L2Object
|
|
|
else
|
|
|
{
|
|
|
statement.setInt(2, _augmentation.getAttributes());
|
|
|
- if(_augmentation.getSkill() == null)
|
|
|
+ if (_augmentation.getSkill() == null)
|
|
|
{
|
|
|
statement.setInt(3, 0);
|
|
|
statement.setInt(4, 0);
|
|
@@ -954,7 +955,7 @@ public final class L2ItemInstance extends L2Object
|
|
|
}
|
|
|
catch (SQLException e)
|
|
|
{
|
|
|
- _log.log(Level.SEVERE, "Could not update atributes for item: "+this+" from DB:", e);
|
|
|
+ _log.log(Level.SEVERE, "Could not update atributes for item: " + this + " from DB:", e);
|
|
|
|
|
|
}
|
|
|
finally
|
|
@@ -993,7 +994,7 @@ public final class L2ItemInstance extends L2Object
|
|
|
}
|
|
|
catch (SQLException e)
|
|
|
{
|
|
|
- _log.log(Level.SEVERE, "Could not update elementals for item: "+this+" from DB:", e);
|
|
|
+ _log.log(Level.SEVERE, "Could not update elementals for item: " + this + " from DB:", e);
|
|
|
}
|
|
|
finally
|
|
|
{
|
|
@@ -1054,7 +1055,7 @@ public final class L2ItemInstance extends L2Object
|
|
|
else if (_elementals != null)
|
|
|
{
|
|
|
Elementals elm = getElemental(element);
|
|
|
- if (elm != null )
|
|
|
+ if (elm != null)
|
|
|
return elm.getValue();
|
|
|
}
|
|
|
return 0;
|
|
@@ -1077,7 +1078,7 @@ public final class L2ItemInstance extends L2Object
|
|
|
else
|
|
|
{
|
|
|
elm = new Elementals(element, value);
|
|
|
- Elementals[] array = new Elementals[_elementals.length+1];
|
|
|
+ Elementals[] array = new Elementals[_elementals.length + 1];
|
|
|
System.arraycopy(_elementals, 0, array, 0, _elementals.length);
|
|
|
array[_elementals.length] = elm;
|
|
|
_elementals = array;
|
|
@@ -1130,7 +1131,7 @@ public final class L2ItemInstance extends L2Object
|
|
|
PreparedStatement statement = null;
|
|
|
if (element != -1)
|
|
|
{
|
|
|
- //Item can have still others
|
|
|
+ // Item can have still others
|
|
|
statement = con.prepareStatement("DELETE FROM item_elementals WHERE itemId = ? AND elemType = ?");
|
|
|
statement.setInt(2, element);
|
|
|
}
|
|
@@ -1146,7 +1147,7 @@ public final class L2ItemInstance extends L2Object
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
- _log.log(Level.SEVERE, "Could not remove elemental enchant for item: "+this+" from DB:", e);
|
|
|
+ _log.log(Level.SEVERE, "Could not remove elemental enchant for item: " + this + " from DB:", e);
|
|
|
}
|
|
|
finally
|
|
|
{
|
|
@@ -1155,8 +1156,7 @@ public final class L2ItemInstance extends L2Object
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Used to decrease mana
|
|
|
- * (mana means life time for shadow items)
|
|
|
+ * Used to decrease mana (mana means life time for shadow items)
|
|
|
*/
|
|
|
public static class ScheduleConsumeManaTask implements Runnable
|
|
|
{
|
|
@@ -1183,10 +1183,8 @@ public final class L2ItemInstance extends L2Object
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
- * Returns true if this item is a shadow item
|
|
|
- * Shadow items have a limited life-time
|
|
|
+ * Returns true if this item is a shadow item Shadow items have a limited life-time
|
|
|
* @return
|
|
|
*/
|
|
|
public boolean isShadowItem()
|
|
@@ -1204,10 +1202,7 @@ public final class L2ItemInstance extends L2Object
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Decreases the mana of this shadow item,
|
|
|
- * sends a inventory update
|
|
|
- * schedules a new consumption task if non is running
|
|
|
- * optionally one could force a new task
|
|
|
+ * Decreases the mana of this shadow item, sends a inventory update schedules a new consumption task if non is running optionally one could force a new task
|
|
|
* @param resetConsumingMana if true forces a new consumption task if item is equipped
|
|
|
*/
|
|
|
public void decreaseMana(boolean resetConsumingMana)
|
|
@@ -1216,10 +1211,7 @@ public final class L2ItemInstance extends L2Object
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Decreases the mana of this shadow item,
|
|
|
- * sends a inventory update
|
|
|
- * schedules a new consumption task if non is running
|
|
|
- * optionally one could force a new task
|
|
|
+ * Decreases the mana of this shadow item, sends a inventory update schedules a new consumption task if non is running optionally one could force a new task
|
|
|
* @param resetConsumingMana if forces a new consumption task if item is equipped
|
|
|
* @param count how much mana decrease
|
|
|
*/
|
|
@@ -1272,7 +1264,7 @@ public final class L2ItemInstance extends L2Object
|
|
|
{
|
|
|
L2ItemInstance[] unequiped = player.getInventory().unEquipItemInSlotAndRecord(getLocationSlot());
|
|
|
InventoryUpdate iu = new InventoryUpdate();
|
|
|
- for (L2ItemInstance item: unequiped)
|
|
|
+ for (L2ItemInstance item : unequiped)
|
|
|
{
|
|
|
player.checkSShotsMatch(null, item);
|
|
|
iu.addModifiedItem(item);
|
|
@@ -1345,7 +1337,7 @@ public final class L2ItemInstance extends L2Object
|
|
|
*/
|
|
|
public int getChargedSoulshot()
|
|
|
{
|
|
|
- return _chargedSoulshot;
|
|
|
+ return _chargedSoulshot;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -1356,6 +1348,7 @@ public final class L2ItemInstance extends L2Object
|
|
|
{
|
|
|
return _chargedSpiritshot;
|
|
|
}
|
|
|
+
|
|
|
public boolean getChargedFishshot()
|
|
|
{
|
|
|
return _chargedFishtshot;
|
|
@@ -1378,16 +1371,14 @@ public final class L2ItemInstance extends L2Object
|
|
|
{
|
|
|
_chargedSpiritshot = type;
|
|
|
}
|
|
|
+
|
|
|
public void setChargedFishshot(boolean type)
|
|
|
{
|
|
|
_chargedFishtshot = type;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * This function basically returns a set of functions from
|
|
|
- * L2Item/L2Armor/L2Weapon, but may add additional
|
|
|
- * functions, if this particular item instance is enhanched
|
|
|
- * for a particular player.
|
|
|
+ * This function basically returns a set of functions from L2Item/L2Armor/L2Weapon, but may add additional functions, if this particular item instance is enhanched for a particular player.
|
|
|
* @param player : L2Character designating the player
|
|
|
* @return Func[]
|
|
|
*/
|
|
@@ -1406,7 +1397,6 @@ public final class L2ItemInstance extends L2Object
|
|
|
|
|
|
/**
|
|
|
* Updates the database.<BR>
|
|
|
- *
|
|
|
* @param force if the update should necessarilly be done.
|
|
|
*/
|
|
|
public void updateDatabase(boolean force)
|
|
@@ -1417,10 +1407,7 @@ public final class L2ItemInstance extends L2Object
|
|
|
{
|
|
|
if (_existsInDb)
|
|
|
{
|
|
|
- if (_ownerId == 0
|
|
|
- || _loc == ItemLocation.VOID
|
|
|
- || _loc == ItemLocation.REFUND
|
|
|
- || (getCount() == 0 && _loc != ItemLocation.LEASE))
|
|
|
+ if (_ownerId == 0 || _loc == ItemLocation.VOID || _loc == ItemLocation.REFUND || (getCount() == 0 && _loc != ItemLocation.LEASE))
|
|
|
{
|
|
|
removeFromDb();
|
|
|
}
|
|
@@ -1431,10 +1418,7 @@ public final class L2ItemInstance extends L2Object
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- if (_ownerId == 0
|
|
|
- || _loc == ItemLocation.VOID
|
|
|
- || _loc == ItemLocation.REFUND
|
|
|
- || (getCount() == 0 && _loc != ItemLocation.LEASE))
|
|
|
+ if (_ownerId == 0 || _loc == ItemLocation.VOID || _loc == ItemLocation.REFUND || (getCount() == 0 && _loc != ItemLocation.LEASE))
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
@@ -1450,7 +1434,7 @@ public final class L2ItemInstance extends L2Object
|
|
|
/**
|
|
|
* Returns a L2ItemInstance stored in database from its objectID
|
|
|
* @param ownerId
|
|
|
- * @param rs
|
|
|
+ * @param rs
|
|
|
* @return L2ItemInstance
|
|
|
*/
|
|
|
public static L2ItemInstance restoreFromDb(int ownerId, ResultSet rs)
|
|
@@ -1467,17 +1451,20 @@ public final class L2ItemInstance extends L2Object
|
|
|
loc = ItemLocation.valueOf(rs.getString("loc"));
|
|
|
loc_data = rs.getInt("loc_data");
|
|
|
enchant_level = rs.getInt("enchant_level");
|
|
|
- custom_type1 = rs.getInt("custom_type1");
|
|
|
- custom_type2 = rs.getInt("custom_type2");
|
|
|
+ custom_type1 = rs.getInt("custom_type1");
|
|
|
+ custom_type2 = rs.getInt("custom_type2");
|
|
|
manaLeft = rs.getInt("mana_left");
|
|
|
time = rs.getLong("time");
|
|
|
- } catch (Exception e) {
|
|
|
- _log.log(Level.SEVERE, "Could not restore an item owned by "+ownerId+" from DB:", e);
|
|
|
+ }
|
|
|
+ catch (Exception e)
|
|
|
+ {
|
|
|
+ _log.log(Level.SEVERE, "Could not restore an item owned by " + ownerId + " from DB:", e);
|
|
|
return null;
|
|
|
}
|
|
|
L2Item item = ItemTable.getInstance().getTemplate(item_id);
|
|
|
- if (item == null) {
|
|
|
- _log.severe("Item item_id="+item_id+" not known, object_id="+objectId);
|
|
|
+ if (item == null)
|
|
|
+ {
|
|
|
+ _log.severe("Item item_id=" + item_id + " not known, object_id=" + objectId);
|
|
|
return null;
|
|
|
}
|
|
|
inst = new L2ItemInstance(objectId, item);
|
|
@@ -1495,7 +1482,7 @@ public final class L2ItemInstance extends L2Object
|
|
|
inst._mana = manaLeft;
|
|
|
inst._time = time;
|
|
|
|
|
|
- //load augmentation and elemental enchant
|
|
|
+ // load augmentation and elemental enchant
|
|
|
if (inst.isEquipable())
|
|
|
inst.restoreAttributes();
|
|
|
|
|
@@ -1503,26 +1490,25 @@ public final class L2ItemInstance extends L2Object
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Init a dropped L2ItemInstance and add it in the world as a visible object.<BR><BR>
|
|
|
- *
|
|
|
- * <B><U> Actions</U> :</B><BR><BR>
|
|
|
- * <li>Set the x,y,z position of the L2ItemInstance dropped and update its _worldregion </li>
|
|
|
- * <li>Add the L2ItemInstance dropped to _visibleObjects of its L2WorldRegion</li>
|
|
|
- * <li>Add the L2ItemInstance dropped in the world as a <B>visible</B> object</li><BR><BR>
|
|
|
- *
|
|
|
- * <FONT COLOR=#FF0000><B> <U>Caution</U> : This method DOESN'T ADD the object to _allObjects of L2World </B></FONT><BR><BR>
|
|
|
- *
|
|
|
- * <B><U> Assert </U> :</B><BR><BR>
|
|
|
- * <li> _worldRegion == null <I>(L2Object is invisible at the beginning)</I></li><BR><BR>
|
|
|
- *
|
|
|
- * <B><U> Example of use </U> :</B><BR><BR>
|
|
|
- * <li> Drop item</li>
|
|
|
- * <li> Call Pet</li><BR>
|
|
|
- *
|
|
|
+ * Init a dropped L2ItemInstance and add it in the world as a visible object.<BR>
|
|
|
+ * <BR>
|
|
|
+ * <B><U> Actions</U> :</B><BR>
|
|
|
+ * <BR>
|
|
|
+ * <li>Set the x,y,z position of the L2ItemInstance dropped and update its _worldregion</li> <li>Add the L2ItemInstance dropped to _visibleObjects of its L2WorldRegion</li> <li>Add the L2ItemInstance dropped in the world as a <B>visible</B> object</li><BR>
|
|
|
+ * <BR>
|
|
|
+ * <FONT COLOR=#FF0000><B> <U>Caution</U> : This method DOESN'T ADD the object to _allObjects of L2World </B></FONT><BR>
|
|
|
+ * <BR>
|
|
|
+ * <B><U> Assert </U> :</B><BR>
|
|
|
+ * <BR>
|
|
|
+ * <li>_worldRegion == null <I>(L2Object is invisible at the beginning)</I></li><BR>
|
|
|
+ * <BR>
|
|
|
+ * <B><U> Example of use </U> :</B><BR>
|
|
|
+ * <BR>
|
|
|
+ * <li>Drop item</li> <li>Call Pet</li><BR>
|
|
|
*/
|
|
|
public class ItemDropTask implements Runnable
|
|
|
{
|
|
|
- private int _x,_y,_z;
|
|
|
+ private int _x, _y, _z;
|
|
|
private final L2Character _dropper;
|
|
|
private final L2ItemInstance _itm;
|
|
|
|
|
@@ -1548,16 +1534,16 @@ public final class L2ItemInstance extends L2Object
|
|
|
_z = dropDest.getZ();
|
|
|
}
|
|
|
|
|
|
- if(_dropper != null)
|
|
|
+ if (_dropper != null)
|
|
|
setInstanceId(_dropper.getInstanceId()); // Inherit instancezone when dropped in visible world
|
|
|
else
|
|
|
setInstanceId(0); // No dropper? Make it a global item...
|
|
|
-
|
|
|
+
|
|
|
synchronized (_itm)
|
|
|
{
|
|
|
// Set the x,y,z position of the L2ItemInstance dropped and update its _worldregion
|
|
|
_itm.setIsVisible(true);
|
|
|
- _itm.getPosition().setWorldPosition(_x, _y ,_z);
|
|
|
+ _itm.getPosition().setWorldPosition(_x, _y, _z);
|
|
|
_itm.getPosition().setWorldRegion(L2World.getInstance().getRegion(getPosition().getWorldPosition()));
|
|
|
|
|
|
// Add the L2ItemInstance dropped to _visibleObjects of its L2WorldRegion
|
|
@@ -1565,7 +1551,7 @@ public final class L2ItemInstance extends L2Object
|
|
|
|
|
|
_itm.getPosition().getWorldRegion().addVisibleObject(_itm);
|
|
|
_itm.setDropTime(System.currentTimeMillis());
|
|
|
- _itm.setDropperObjectId(_dropper != null ? _dropper.getObjectId() : 0); //Set the dropper Id for the knownlist packets in sendInfo
|
|
|
+ _itm.setDropperObjectId(_dropper != null ? _dropper.getObjectId() : 0); // Set the dropper Id for the knownlist packets in sendInfo
|
|
|
|
|
|
// this can synchronize on others instancies, so it's out of
|
|
|
// synchronized, to avoid deadlocks
|
|
@@ -1573,7 +1559,7 @@ public final class L2ItemInstance extends L2Object
|
|
|
L2World.getInstance().addVisibleObject(_itm, _itm.getPosition().getWorldRegion());
|
|
|
if (Config.SAVE_DROPPED_ITEM)
|
|
|
ItemsOnGroundManager.getInstance().save(_itm);
|
|
|
- _itm.setDropperObjectId(0); //Set the dropper Id back to 0 so it no longer shows the drop packet
|
|
|
+ _itm.setDropperObjectId(0); // Set the dropper Id back to 0 so it no longer shows the drop packet
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1600,9 +1586,7 @@ public final class L2ItemInstance extends L2Object
|
|
|
try
|
|
|
{
|
|
|
con = L2DatabaseFactory.getInstance().getConnection();
|
|
|
- statement = con.prepareStatement(
|
|
|
- "UPDATE items SET owner_id=?,count=?,loc=?,loc_data=?,enchant_level=?,custom_type1=?,custom_type2=?,mana_left=?,time=? " +
|
|
|
- "WHERE object_id = ?");
|
|
|
+ statement = con.prepareStatement("UPDATE items SET owner_id=?,count=?,loc=?,loc_data=?,enchant_level=?,custom_type1=?,custom_type2=?,mana_left=?,time=? " + "WHERE object_id = ?");
|
|
|
statement.setInt(1, _ownerId);
|
|
|
statement.setLong(2, getCount());
|
|
|
statement.setString(3, _loc.name());
|
|
@@ -1620,7 +1604,7 @@ public final class L2ItemInstance extends L2Object
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
- _log.log(Level.SEVERE, "Could not update item "+this+" in DB: Reason: "+e.getMessage(), e);
|
|
|
+ _log.log(Level.SEVERE, "Could not update item " + this + " in DB: Reason: " + e.getMessage(), e);
|
|
|
}
|
|
|
finally
|
|
|
{
|
|
@@ -1643,9 +1627,7 @@ public final class L2ItemInstance extends L2Object
|
|
|
try
|
|
|
{
|
|
|
con = L2DatabaseFactory.getInstance().getConnection();
|
|
|
- statement = con.prepareStatement(
|
|
|
- "INSERT INTO items (owner_id,item_id,count,loc,loc_data,enchant_level,object_id,custom_type1,custom_type2,mana_left,time) " +
|
|
|
- "VALUES (?,?,?,?,?,?,?,?,?,?,?)");
|
|
|
+ statement = con.prepareStatement("INSERT INTO items (owner_id,item_id,count,loc,loc_data,enchant_level,object_id,custom_type1,custom_type2,mana_left,time) " + "VALUES (?,?,?,?,?,?,?,?,?,?,?)");
|
|
|
statement.setInt(1, _ownerId);
|
|
|
statement.setInt(2, _itemId);
|
|
|
statement.setLong(3, getCount());
|
|
@@ -1707,7 +1689,7 @@ public final class L2ItemInstance extends L2Object
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
- _log.log(Level.SEVERE, "Could not delete item "+this+" in DB: "+e.getMessage(), e);
|
|
|
+ _log.log(Level.SEVERE, "Could not delete item " + this + " in DB: " + e.getMessage(), e);
|
|
|
}
|
|
|
finally
|
|
|
{
|
|
@@ -1722,12 +1704,12 @@ public final class L2ItemInstance extends L2Object
|
|
|
@Override
|
|
|
public String toString()
|
|
|
{
|
|
|
- return _item+"["+getObjectId()+"]";
|
|
|
+ return _item + "[" + getObjectId() + "]";
|
|
|
}
|
|
|
|
|
|
public void resetOwnerTimer()
|
|
|
{
|
|
|
- if(itemLootShedule != null)
|
|
|
+ if (itemLootShedule != null)
|
|
|
itemLootShedule.cancel(true);
|
|
|
itemLootShedule = null;
|
|
|
}
|
|
@@ -1779,7 +1761,7 @@ public final class L2ItemInstance extends L2Object
|
|
|
|
|
|
public void restoreInitCount()
|
|
|
{
|
|
|
- if(_decrease)
|
|
|
+ if (_decrease)
|
|
|
setCount(_initCount);
|
|
|
}
|
|
|
|
|
@@ -1811,7 +1793,7 @@ public final class L2ItemInstance extends L2Object
|
|
|
{
|
|
|
L2ItemInstance[] unequiped = player.getInventory().unEquipItemInSlotAndRecord(getLocationSlot());
|
|
|
InventoryUpdate iu = new InventoryUpdate();
|
|
|
- for (L2ItemInstance item: unequiped)
|
|
|
+ for (L2ItemInstance item : unequiped)
|
|
|
{
|
|
|
player.checkSShotsMatch(null, item);
|
|
|
iu.addModifiedItem(item);
|
|
@@ -1847,7 +1829,8 @@ public final class L2ItemInstance extends L2Object
|
|
|
|
|
|
public void scheduleLifeTimeTask()
|
|
|
{
|
|
|
- if (!isTimeLimitedItem()) return;
|
|
|
+ if (!isTimeLimitedItem())
|
|
|
+ return;
|
|
|
if (getRemainingTime() <= 0)
|
|
|
endOfLife();
|
|
|
else
|
|
@@ -1927,7 +1910,8 @@ public final class L2ItemInstance extends L2Object
|
|
|
_published = true;
|
|
|
}
|
|
|
|
|
|
- /* (non-Javadoc)
|
|
|
+ /*
|
|
|
+ * (non-Javadoc)
|
|
|
* @see com.l2jserver.gameserver.model.L2Object#decayMe()
|
|
|
*/
|
|
|
@Override
|
|
@@ -1965,11 +1949,11 @@ public final class L2ItemInstance extends L2Object
|
|
|
L2PcInstance player = L2World.getInstance().getPlayer(getOwnerId());
|
|
|
int enchant = getEnchantLevel();
|
|
|
|
|
|
- if(player == null)
|
|
|
+ if (player == null)
|
|
|
return enchant;
|
|
|
|
|
|
if (player.isInOlympiadMode() && Config.ALT_OLY_ENCHANT_LIMIT >= 0 && enchant > Config.ALT_OLY_ENCHANT_LIMIT)
|
|
|
- enchant = Config.ALT_OLY_ENCHANT_LIMIT;
|
|
|
+ enchant = Config.ALT_OLY_ENCHANT_LIMIT;
|
|
|
|
|
|
return enchant;
|
|
|
}
|