From 04f03eb14a4f382fb4cb97aec4f7258a811c3085 Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Fri, 3 Oct 2014 11:23:25 +0200 Subject: [PATCH] The SenderEntity fixId does not have do be recursive. --- .../massivecraft/massivecore/store/Coll.java | 2 +- .../massivecore/store/SenderColl.java | 28 +++++++++++++++---- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/massivecraft/massivecore/store/Coll.java b/src/main/java/com/massivecraft/massivecore/store/Coll.java index 72d6da46..7e873562 100644 --- a/src/main/java/com/massivecraft/massivecore/store/Coll.java +++ b/src/main/java/com/massivecraft/massivecore/store/Coll.java @@ -149,7 +149,7 @@ public class Coll implements CollInterface if (oid == null) return null; String ret = null; - if (oid instanceof String) + if (oid instanceof String) { ret = (String)oid; } diff --git a/src/main/java/com/massivecraft/massivecore/store/SenderColl.java b/src/main/java/com/massivecraft/massivecore/store/SenderColl.java index 40fa87ee..b44b017f 100644 --- a/src/main/java/com/massivecraft/massivecore/store/SenderColl.java +++ b/src/main/java/com/massivecraft/massivecore/store/SenderColl.java @@ -41,20 +41,36 @@ public class SenderColl> extends Coll implements Se @Override public String fixId(Object oid) { + // A null oid should always return null. if (oid == null) return null; - if (oid instanceof String) + String ret = null; + + if (oid instanceof String) { - String ret = (String)oid; - return this.isLowercasing() ? ret.toLowerCase() : ret; + ret = (String)oid; + } + else if (oid.getClass() == this.entityClass) + { + ret = this.entity2id.get(oid); } - if (oid.getClass() == this.entityClass) + if (ret == null) { - return fixId(this.entity2id.get(oid)); + ret = IdUtil.getId(oid); } - return fixId(IdUtil.getId(oid)); + if (ret == null) + { + return null; + } + + if (this.isLowercasing()) + { + ret = ret.toLowerCase(); + } + + return ret; } // -------------------------------------------- //