diff --git a/src/com/massivecraft/mcore5/store/Coll.java b/src/com/massivecraft/mcore5/store/Coll.java index 7f92c2a1..0ffd099b 100644 --- a/src/com/massivecraft/mcore5/store/Coll.java +++ b/src/com/massivecraft/mcore5/store/Coll.java @@ -8,7 +8,7 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentSkipListMap; import java.util.concurrent.ConcurrentSkipListSet; import java.util.concurrent.CopyOnWriteArrayList; @@ -230,10 +230,11 @@ public class Coll> implements CollInterface> implements CollInterface lastMtime = new ConcurrentHashMap(); - protected Map lastRaw = new ConcurrentHashMap(); - protected Set lastDefault = Collections.newSetFromMap(new ConcurrentHashMap()); + protected Map lastMtime; + protected Map lastRaw; + protected Set lastDefault; protected synchronized void clearSynclog(L id) { @@ -308,6 +309,7 @@ public class Coll> implements CollInterface> implements CollInterface> implements CollInterface db, MPlugin mplugin, String idStrategyName, String name, Class entityClass, Class idClass, boolean creative) + public Coll(Db db, MPlugin mplugin, String idStrategyName, String name, Class entityClass, Class idClass, boolean creative, Comparator idComparator, Comparator entityComparator) { // Setup the name and the parsed parts this.name = name; @@ -582,20 +591,20 @@ public class Coll> implements CollInterface(); - this.entities = new ConcurrentSkipListSet(); - this.id2entity = new ConcurrentHashMap(); - this.entity2id = new ConcurrentHashMap(); + this.ids = new ConcurrentSkipListSet(idComparator); + this.entities = new ConcurrentSkipListSet(entityComparator); + this.id2entity = new ConcurrentSkipListMap(idComparator); + this.entity2id = new ConcurrentSkipListMap(entityComparator); // IDENTIFIED CHANGES - this.localAttachIds = Collections.newSetFromMap(new ConcurrentHashMap()); - this.localDetachIds = Collections.newSetFromMap(new ConcurrentHashMap()); - this.changedIds = Collections.newSetFromMap(new ConcurrentHashMap()); + this.localAttachIds = new ConcurrentSkipListSet(idComparator); + this.localDetachIds = new ConcurrentSkipListSet(idComparator); + this.changedIds = new ConcurrentSkipListSet(idComparator); // SYNCLOG - this.lastMtime = new ConcurrentHashMap(); - this.lastRaw = new ConcurrentHashMap(); - this.lastDefault = Collections.newSetFromMap(new ConcurrentHashMap()); + this.lastMtime = new ConcurrentSkipListMap(idComparator); + this.lastRaw = new ConcurrentSkipListMap(idComparator); + this.lastDefault = new ConcurrentSkipListSet(idComparator); final Coll me = this; this.tickTask = new Runnable() @@ -604,6 +613,11 @@ public class Coll> implements CollInterface db, MPlugin mplugin, String idStrategyName, String name, Class entityClass, Class idClass, boolean creative) + { + this(db, mplugin, idStrategyName, name, entityClass, idClass, creative, null, null); + } + public Coll(MPlugin mplugin, String idStrategyName, String name, Class entityClass, Class idClass, boolean creative) { this(MCore.getDb(), mplugin, idStrategyName, name, entityClass, idClass, creative); diff --git a/src/com/massivecraft/mcore5/store/Entity.java b/src/com/massivecraft/mcore5/store/Entity.java index 7c61ba77..75691d0d 100644 --- a/src/com/massivecraft/mcore5/store/Entity.java +++ b/src/com/massivecraft/mcore5/store/Entity.java @@ -18,6 +18,10 @@ public abstract class Entity, L extends Comparable val) { this.coll = val; } public Coll getColl() { return this.coll; } + protected transient L id; + protected void setid(L id) { this.id = id; } + public L getId() { return this.id; } + public String getUniverse() { Coll coll = this.getColl(); @@ -53,13 +57,6 @@ public abstract class Entity, L extends Comparable coll = this.getColl(); - if (coll == null) return null; - return coll.getId(this); - } - public void changed() { L id = this.getId();