|
|
@ -30,6 +30,7 @@ import org.pmw.tinylog.Logger; |
|
|
|
import java.sql.ResultSet; |
|
|
|
import java.sql.ResultSet; |
|
|
|
import java.sql.SQLException; |
|
|
|
import java.sql.SQLException; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.ArrayList; |
|
|
|
|
|
|
|
import java.util.EnumSet; |
|
|
|
import java.util.Iterator; |
|
|
|
import java.util.Iterator; |
|
|
|
import java.util.concurrent.ConcurrentHashMap; |
|
|
|
import java.util.concurrent.ConcurrentHashMap; |
|
|
|
import java.util.concurrent.locks.ReentrantLock; |
|
|
|
import java.util.concurrent.locks.ReentrantLock; |
|
|
@ -44,7 +45,7 @@ public class Item extends AbstractWorldObject { |
|
|
|
public ReentrantLock lootLock = new ReentrantLock(); |
|
|
|
public ReentrantLock lootLock = new ReentrantLock(); |
|
|
|
public int ownerID; //may be character, account, npc, mob
|
|
|
|
public int ownerID; //may be character, account, npc, mob
|
|
|
|
public float drop_chance; |
|
|
|
public float drop_chance; |
|
|
|
private int flags; //1 = isIDed
|
|
|
|
public EnumSet<Enum.ItemFlags> flags; //1 = isIDed
|
|
|
|
public int numberOfItems; |
|
|
|
public int numberOfItems; |
|
|
|
public float durabilityCurrent; |
|
|
|
public float durabilityCurrent; |
|
|
|
public int chargesRemaining; |
|
|
|
public int chargesRemaining; |
|
|
@ -148,7 +149,16 @@ public class Item extends AbstractWorldObject { |
|
|
|
|
|
|
|
|
|
|
|
this.numberOfItems = rs.getInt("item_numberOfItems"); |
|
|
|
this.numberOfItems = rs.getInt("item_numberOfItems"); |
|
|
|
|
|
|
|
|
|
|
|
this.flags = rs.getInt("item_flags"); |
|
|
|
String flagString = rs.getString("item_flags"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (String itemFlag : flagString.split(";")) |
|
|
|
|
|
|
|
this.flags.add(Enum.ItemFlags.valueOf(itemFlag)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Empty flags should default to template
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (this.flags.isEmpty()) |
|
|
|
|
|
|
|
this.flags.addAll(this.template.item_flags); |
|
|
|
|
|
|
|
|
|
|
|
this.dateToUpgrade = rs.getLong("item_dateToUpgrade"); |
|
|
|
this.dateToUpgrade = rs.getLong("item_dateToUpgrade"); |
|
|
|
this.value = rs.getInt("item_value"); |
|
|
|
this.value = rs.getInt("item_value"); |
|
|
|
|
|
|
|
|
|
|
@ -244,7 +254,7 @@ public class Item extends AbstractWorldObject { |
|
|
|
int effectsSize = item.effects.size(); |
|
|
|
int effectsSize = item.effects.size(); |
|
|
|
ArrayList<Effect> effs = null; |
|
|
|
ArrayList<Effect> effs = null; |
|
|
|
Effect nextE = null; |
|
|
|
Effect nextE = null; |
|
|
|
if (effectsSize > 0 && item.isID()) { |
|
|
|
if (effectsSize > 0 && item.flags.contains(ItemFlags.Identified)) { |
|
|
|
effs = new ArrayList<>(item.effects.values()); |
|
|
|
effs = new ArrayList<>(item.effects.values()); |
|
|
|
|
|
|
|
|
|
|
|
//Don't send effects that have a token of 1
|
|
|
|
//Don't send effects that have a token of 1
|
|
|
@ -266,7 +276,7 @@ public class Item extends AbstractWorldObject { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (effectsSize > 0) |
|
|
|
if (effectsSize > 0) |
|
|
|
if (item.isID()) |
|
|
|
if (item.flags.contains(ItemFlags.Identified)) |
|
|
|
writer.putInt(36); //Magical, blue name
|
|
|
|
writer.putInt(36); //Magical, blue name
|
|
|
|
else |
|
|
|
else |
|
|
|
writer.putInt(40); //Magical, unidentified
|
|
|
|
writer.putInt(40); //Magical, unidentified
|
|
|
@ -754,24 +764,6 @@ public class Item extends AbstractWorldObject { |
|
|
|
return amount; |
|
|
|
return amount; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public boolean isID() { |
|
|
|
|
|
|
|
return ((this.flags & 1) > 0); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setIsID(boolean value) { |
|
|
|
|
|
|
|
if (value) |
|
|
|
|
|
|
|
this.flags |= 1; |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
this.flags &= ~1; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setIsComplete(boolean value) { |
|
|
|
|
|
|
|
if (value) |
|
|
|
|
|
|
|
this.flags |= 2; |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
this.flags &= ~2; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public boolean isComplete() { |
|
|
|
public boolean isComplete() { |
|
|
|
return this.dateToUpgrade < System.currentTimeMillis() + 1000; |
|
|
|
return this.dateToUpgrade < System.currentTimeMillis() + 1000; |
|
|
|
} |
|
|
|
} |
|
|
@ -783,14 +775,6 @@ public class Item extends AbstractWorldObject { |
|
|
|
return ret; |
|
|
|
return ret; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public int getFlags() { |
|
|
|
|
|
|
|
return this.flags; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setFlags(int value) { |
|
|
|
|
|
|
|
this.flags = value; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void addBonus(AbstractEffectModifier key, float amount) { |
|
|
|
public void addBonus(AbstractEffectModifier key, float amount) { |
|
|
|
if (this.bonuses.containsKey(key)) |
|
|
|
if (this.bonuses.containsKey(key)) |
|
|
|
this.bonuses.put(key, (this.bonuses.get(key) + amount)); |
|
|
|
this.bonuses.put(key, (this.bonuses.get(key) + amount)); |
|
|
@ -1192,7 +1176,7 @@ public class Item extends AbstractWorldObject { |
|
|
|
public int getValue() { |
|
|
|
public int getValue() { |
|
|
|
|
|
|
|
|
|
|
|
if (this.value == 0) |
|
|
|
if (this.value == 0) |
|
|
|
if (this.isID()) { |
|
|
|
if (this.flags.contains(ItemFlags.Identified)) { |
|
|
|
return this.getMagicValue(); |
|
|
|
return this.getMagicValue(); |
|
|
|
} else |
|
|
|
} else |
|
|
|
return this.template.item_value; |
|
|
|
return this.template.item_value; |
|
|
|