MStore fixes and don't confuse same priority with equality.

This commit is contained in:
Olof Larsson 2014-10-07 12:29:50 +02:00
parent 43ec0d3eb1
commit bfd4b5c7b8
6 changed files with 37 additions and 31 deletions

View File

@ -28,11 +28,4 @@ public class MassiveCoreMConfColl extends Coll<MassiveCoreMConf>
MassiveCoreMConf.i = this.get(MassiveCore.INSTANCE, true);
}
@Override
public synchronized void loadFromRemote(Object oid)
{
super.loadFromRemote(oid);
if ( ! this.inited()) return;
}
}

View File

@ -22,7 +22,15 @@ public class PriorityComparator implements Comparator<Prioritized>
if (two == null) return 1;
if (one == null) return -1;
return Integer.valueOf(one.getPriority()).compareTo(two.getPriority());
int ret = Integer.valueOf(one.getPriority()).compareTo(two.getPriority());
// We should only return 0 if the items actually are equal.
if (ret == 0 && ! one.equals(two))
{
ret = two.hashCode() - one.hashCode();
}
return ret;
}
}

View File

@ -22,7 +22,15 @@ public class ReversePriorityComparator implements Comparator<Prioritized>
if (two == null) return -1;
if (one == null) return 1;
return Integer.valueOf(two.getPriority()).compareTo(one.getPriority());
int ret = Integer.valueOf(two.getPriority()).compareTo(one.getPriority());
// We should only return 0 if the items actually are equal.
if (ret == 0 && ! one.equals(two))
{
ret = one.hashCode() - two.hashCode();
}
return ret;
}
}

View File

@ -566,33 +566,27 @@ public class Coll<E> implements CollInterface<E>
}
}
@SuppressWarnings("unchecked")
@Override
public synchronized void loadFromRemote(Object oid)
public synchronized void loadFromRemote(Object oid, Entry<JsonElement, Long> entry, boolean entrySupplied)
{
if (oid == null) throw new NullPointerException("oid");
String id = this.fixId(oid);
this.clearIdentifiedChanges(id);
Entry<JsonElement, Long> entry = null;
try
if ( ! entrySupplied)
{
entry = this.getDriver().load(this, id);
try
{
entry = this.getDriver().load(this, id);
}
catch (Exception e)
{
logLoadError(id, e.getMessage());
return;
}
}
catch (Exception e)
{
logLoadError(id, e.getMessage());
return;
}
loadFromRemote(id, entry);
}
@SuppressWarnings("unchecked")
private void loadFromRemote(Object oid, Entry<JsonElement, Long> entry)
{
if (oid == null) throw new NullPointerException("oid");
String id = this.fixId(oid);
if (entry == null)
{
@ -773,7 +767,7 @@ public class Coll<E> implements CollInterface<E>
break;
case REMOTE_ALTER:
case REMOTE_ATTACH:
this.loadFromRemote(id);
this.loadFromRemote(id, null, false);
if (this.inited())
{
this.addSyncCount(TOTAL, true);
@ -860,7 +854,7 @@ public class Coll<E> implements CollInterface<E>
{
String id = idToEntry.getKey();
Entry<JsonElement, Long> entry = idToEntry.getValue();
loadFromRemote(id, entry);
loadFromRemote(id, entry, true);
}
}
@ -949,6 +943,7 @@ public class Coll<E> implements CollInterface<E>
if (this.inited()) return;
this.initLoadAllFromRemote();
// this.syncAll();
name2instance.put(this.getName(), this);
}

View File

@ -4,10 +4,12 @@ import java.util.Collection;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.bukkit.plugin.Plugin;
import com.massivecraft.massivecore.Predictate;
import com.massivecraft.massivecore.xlib.gson.JsonElement;
public interface CollInterface<E>
{
@ -131,7 +133,7 @@ public interface CollInterface<E>
public E removeAtLocal(Object oid);
public void removeAtRemote(Object oid);
public void saveToRemote(Object oid);
public void loadFromRemote(Object oid);
public void loadFromRemote(Object oid, Entry<JsonElement, Long> entry, boolean entrySupplied);
// -------------------------------------------- //
// SYNC EXAMINE AND DO

View File

@ -134,7 +134,7 @@ public abstract class Entity<E extends Entity<E>> implements Comparable<E>
String id = this.getId();
if (id == null) return;
this.getColl().loadFromRemote(id);
this.getColl().loadFromRemote(id, null, false);
}
// -------------------------------------------- //