From a3277dbcfac8228247beb19057b7f495dd164e78 Mon Sep 17 00:00:00 2001 From: Eduardo Alonso Date: Sat, 13 Oct 2018 21:14:00 +0200 Subject: [PATCH] Fix cache format * Now the JSON object is formatted correctly --- .../windows/WindowsHabboClient.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/main/protocol/memory/habboclient/windows/WindowsHabboClient.java b/src/main/protocol/memory/habboclient/windows/WindowsHabboClient.java index 969ca26..fa0ef39 100644 --- a/src/main/protocol/memory/habboclient/windows/WindowsHabboClient.java +++ b/src/main/protocol/memory/habboclient/windows/WindowsHabboClient.java @@ -5,6 +5,7 @@ import main.protocol.HConnection; import main.protocol.HMessage; import main.protocol.TrafficListener; import main.protocol.memory.habboclient.HabboClient; +import org.json.simple.JSONObject; import java.io.BufferedReader; import java.io.File; @@ -32,7 +33,11 @@ public class WindowsHabboClient extends HabboClient { private String production = ""; private String getOffsetsCacheKey() { - return production + "-RC4Offsets"; + return "RC4Offsets"; + } + + private String getOffsetsRevision() { + return production; } @Override @@ -54,7 +59,14 @@ public class WindowsHabboClient extends HabboClient { private ArrayList readPossibleBytes(boolean useCache) throws IOException, URISyntaxException { ProcessBuilder pb = null; - List cachedOffsets = (List) Cacher.get(getOffsetsCacheKey()); + JSONObject revisionList = (JSONObject) Cacher.get(getOffsetsCacheKey()); + + if (revisionList == null) { + Cacher.put(getOffsetsCacheKey(), new JSONObject()); + revisionList = (JSONObject) Cacher.get(getOffsetsCacheKey()); // refresh + } + + List cachedOffsets = (List) revisionList.get(getOffsetsRevision()); StringJoiner joiner = new StringJoiner(" "); if (useCache) { @@ -96,7 +108,8 @@ public class WindowsHabboClient extends HabboClient { possibleData.add(line); } } - Cacher.put(getOffsetsCacheKey(), cachedOffsets); + revisionList.put(getOffsetsRevision(), cachedOffsets); + Cacher.put(getOffsetsCacheKey(), revisionList); p.destroy(); return possibleData; }