From 525d904f8f368cc7334e1c42e0b0744a3fd75fa4 Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Thu, 5 Mar 2015 00:14:09 +0100 Subject: [PATCH] Not going to be lazy --- .../massivecraft/massivecore/store/Coll.java | 28 ++++++------------- .../massivecore/store/CollInterface.java | 3 -- .../massivecore/store/SenderColl.java | 10 +++---- 3 files changed, 13 insertions(+), 28 deletions(-) diff --git a/src/com/massivecraft/massivecore/store/Coll.java b/src/com/massivecraft/massivecore/store/Coll.java index 5c8cfc2e..3836bbb9 100644 --- a/src/com/massivecraft/massivecore/store/Coll.java +++ b/src/com/massivecraft/massivecore/store/Coll.java @@ -90,14 +90,11 @@ public class Coll implements CollInterface // STORAGE // -------------------------------------------- // - // All - protected Set ids; - // Loaded protected Map id2entity; protected Map entity2id; - @Override public Collection getIds() { return Collections.unmodifiableCollection(this.ids); } + @Override public Collection getIds() { return Collections.unmodifiableCollection(this.id2entity.keySet()); } @Override public Map getId2entity() { return Collections.unmodifiableMap(this.id2entity); } @Override @@ -127,7 +124,7 @@ public class Coll implements CollInterface { String id = this.fixId(oid); if (id == null) return false; - return this.ids.contains(id); + return this.id2entity.containsKey(id); } @Override public Map getEntity2id() { return Collections.unmodifiableMap(this.entity2id); } @@ -166,10 +163,6 @@ public class Coll implements CollInterface // BEHAVIOR // -------------------------------------------- // - protected boolean lazy; - @Override public boolean isLazy() { return this.lazy; } - @Override public void setLazy(boolean lazy) { this.lazy = lazy; } - protected boolean creative; @Override public boolean isCreative() { return this.creative; } @Override public void setCreative(boolean creative) { this.creative = creative; } @@ -331,7 +324,6 @@ public class Coll implements CollInterface } // Attach - this.ids.add(id); this.id2entity.put(id, entity); this.entity2id.put(entity, id); @@ -514,8 +506,6 @@ public class Coll implements CollInterface this.entity2id.remove(entity); - this.ids.remove(id); - // Remove entity reference info if (entity instanceof Entity) { @@ -830,7 +820,7 @@ public class Coll implements CollInterface // Compile a list of all ids (both remote and local) Set allids = new HashSet(); allids.addAll(id2RemoteMtime.keySet()); - allids.addAll(this.ids); + allids.addAll(this.id2entity.keySet()); // Check for modifications for (String id : allids) @@ -876,7 +866,7 @@ public class Coll implements CollInterface // CONSTRUCT // -------------------------------------------- // - public Coll(String name, Class entityClass, Db db, Plugin plugin, boolean lazy, boolean creative, boolean lowercasing, Comparator idComparator, Comparator entityComparator) + public Coll(String name, Class entityClass, Db db, Plugin plugin, boolean creative, boolean lowercasing, Comparator idComparator, Comparator entityComparator) { // Setup the name and the parsed parts this.name = name; @@ -892,8 +882,7 @@ public class Coll implements CollInterface } // WHAT DO WE HANDLE? - this.entityClass = entityClass; - this.lazy = lazy; + this.entityClass = entityClass; this.creative = creative; this.lowercasing = lowercasing; @@ -908,7 +897,6 @@ public class Coll implements CollInterface // Avoid "Classname cannot be cast to java.lang.Comparable" error in ConcurrentSkipListMap entityComparator = HashCodeComparator.get(); } - this.ids = new ConcurrentSkipListSet(idComparator); this.id2entity = new ConcurrentSkipListMap(idComparator); this.entity2id = new ConcurrentSkipListMap(entityComparator); @@ -929,14 +917,14 @@ public class Coll implements CollInterface }; } - public Coll(String name, Class entityClass, Db db, Plugin plugin, boolean lazy, boolean creative, boolean lowercasing) + public Coll(String name, Class entityClass, Db db, Plugin plugin, boolean creative, boolean lowercasing) { - this(name, entityClass, db, plugin, lazy, creative, lowercasing, null, null); + this(name, entityClass, db, plugin, creative, lowercasing, null, null); } public Coll(String name, Class entityClass, Db db, Plugin plugin) { - this(name, entityClass, db, plugin, false, false, false); + this(name, entityClass, db, plugin, false, false); } @Override diff --git a/src/com/massivecraft/massivecore/store/CollInterface.java b/src/com/massivecraft/massivecore/store/CollInterface.java index f8975b91..6de606db 100644 --- a/src/com/massivecraft/massivecore/store/CollInterface.java +++ b/src/com/massivecraft/massivecore/store/CollInterface.java @@ -56,9 +56,6 @@ public interface CollInterface // BEHAVIOR // -------------------------------------------- // - public boolean isLazy(); - public void setLazy(boolean lazy); - public boolean isCreative(); public void setCreative(boolean creative); diff --git a/src/com/massivecraft/massivecore/store/SenderColl.java b/src/com/massivecraft/massivecore/store/SenderColl.java index daba4013..f94a3b86 100644 --- a/src/com/massivecraft/massivecore/store/SenderColl.java +++ b/src/com/massivecraft/massivecore/store/SenderColl.java @@ -19,19 +19,19 @@ public class SenderColl> extends Coll implements Se // CONSTRUCT // -------------------------------------------- // - public SenderColl(String name, Class entityClass, Db db, Plugin plugin, boolean lazy, boolean creative, boolean lowercasing, Comparator idComparator, Comparator entityComparator) + public SenderColl(String name, Class entityClass, Db db, Plugin plugin, boolean creative, boolean lowercasing, Comparator idComparator, Comparator entityComparator) { - super(name, entityClass, db, plugin, lazy, creative, lowercasing, idComparator, entityComparator); + super(name, entityClass, db, plugin, creative, lowercasing, idComparator, entityComparator); } - public SenderColl(String name, Class entityClass, Db db, Plugin plugin, boolean lazy, boolean creative, boolean lowercasing) + public SenderColl(String name, Class entityClass, Db db, Plugin plugin, boolean creative, boolean lowercasing) { - super(name, entityClass, db, plugin, lazy, creative, lowercasing); + super(name, entityClass, db, plugin, creative, lowercasing); } public SenderColl(String name, Class entityClass, Db db, Plugin plugin) { - super(name, entityClass, db, plugin, true, true, true); + super(name, entityClass, db, plugin, true, true); } // -------------------------------------------- //