From e807bfc793542658e5de01e156e5b0ddddf17799 Mon Sep 17 00:00:00 2001 From: Chaos Date: Sun, 20 Feb 2022 15:11:33 +0100 Subject: [PATCH] fix(schemnode_cache): Normalize Cache Keys Signed-off-by: Chaos --- SpigotCore_Main/src/de/steamwar/sql/SchematicNode.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/SpigotCore_Main/src/de/steamwar/sql/SchematicNode.java b/SpigotCore_Main/src/de/steamwar/sql/SchematicNode.java index 7640395..9a90105 100644 --- a/SpigotCore_Main/src/de/steamwar/sql/SchematicNode.java +++ b/SpigotCore_Main/src/de/steamwar/sql/SchematicNode.java @@ -450,8 +450,10 @@ public class SchematicNode { if (sws) { s = s.substring(1); } - if(TAB_CACHE.containsKey(user.getId()) && TAB_CACHE.get(user.getId()).containsKey(s)) { - return new ArrayList<>(TAB_CACHE.get(user.getId()).get(s)); + int index = s.lastIndexOf("/"); + String cacheKey = index == -1 ? "" : s.substring(0, index); + if(TAB_CACHE.containsKey(user.getId()) && TAB_CACHE.get(user.getId()).containsKey(cacheKey)) { + return new ArrayList<>(TAB_CACHE.get(user.getId()).get(cacheKey)); } List list = new ArrayList<>(); if (s.contains("/")) { @@ -465,7 +467,7 @@ public class SchematicNode { nodes.forEach(node -> list.add((sws ? "/" : "") + node.getName() + (node.isDir() ? "/" : ""))); } list.remove("//copy"); - Objects.requireNonNull(TAB_CACHE.putIfAbsent(user.getId(), new HashMap<>())).putIfAbsent(s, list); + Objects.requireNonNull(TAB_CACHE.putIfAbsent(user.getId(), new HashMap<>())).putIfAbsent(cacheKey, list); return list; }