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