diff --git a/AnarchyExploitFixesFolia/src/main/java/me/moomoo/anarchyexploitfixes/utils/models/ExpiringSet.java b/AnarchyExploitFixesFolia/src/main/java/me/moomoo/anarchyexploitfixes/utils/models/ExpiringSet.java index 2aa49553e..41f3588d5 100644 --- a/AnarchyExploitFixesFolia/src/main/java/me/moomoo/anarchyexploitfixes/utils/models/ExpiringSet.java +++ b/AnarchyExploitFixesFolia/src/main/java/me/moomoo/anarchyexploitfixes/utils/models/ExpiringSet.java @@ -9,7 +9,7 @@ public final class ExpiringSet { private final Cache cache; - private final Object PRESENT = new Object(); // Dummy value to associate with an Object in the backing Cache + private static final Object PRESENT = new Object(); // Dummy value to associate with an Object in the backing Cache public ExpiringSet(long duration, TimeUnit unit) { this.cache = Caffeine.newBuilder().expireAfterWrite(duration, unit).build(); diff --git a/AnarchyExploitFixesFolia/src/main/java/me/moomoo/anarchyexploitfixes/utils/models/TPSCache.java b/AnarchyExploitFixesFolia/src/main/java/me/moomoo/anarchyexploitfixes/utils/models/TPSCache.java index f8f316a08..b301172b5 100755 --- a/AnarchyExploitFixesFolia/src/main/java/me/moomoo/anarchyexploitfixes/utils/models/TPSCache.java +++ b/AnarchyExploitFixesFolia/src/main/java/me/moomoo/anarchyexploitfixes/utils/models/TPSCache.java @@ -34,20 +34,19 @@ final class Default implements TPSCache { private final Server server; private final Cache cached_tps; - private final Object TPS_KEY; + private static final Object TPS_KEY = new Object(); // Dummy value to associate with tps in the backing Cache Default(JavaPlugin plugin, long checkDelayMillis) { this.server = plugin.getServer(); this.cached_tps = Caffeine.newBuilder().expireAfterWrite(Duration.ofMillis(checkDelayMillis)).build(); - this.TPS_KEY = new Object(); // Dummy value to associate with tps in the backing Cache } @Override public double getGlobalTPS() { - Double tps = this.cached_tps.getIfPresent(this.TPS_KEY); + Double tps = this.cached_tps.getIfPresent(TPS_KEY); if (tps == null) { tps = this.server.getTPS()[0]; - this.cached_tps.put(this.TPS_KEY, tps); + this.cached_tps.put(TPS_KEY, tps); } return tps; } diff --git a/AnarchyExploitFixesLegacy/src/main/java/me/moomoo/anarchyexploitfixes/utils/models/ExpiringSet.java b/AnarchyExploitFixesLegacy/src/main/java/me/moomoo/anarchyexploitfixes/utils/models/ExpiringSet.java index 2aa49553e..41f3588d5 100644 --- a/AnarchyExploitFixesLegacy/src/main/java/me/moomoo/anarchyexploitfixes/utils/models/ExpiringSet.java +++ b/AnarchyExploitFixesLegacy/src/main/java/me/moomoo/anarchyexploitfixes/utils/models/ExpiringSet.java @@ -9,7 +9,7 @@ public final class ExpiringSet { private final Cache cache; - private final Object PRESENT = new Object(); // Dummy value to associate with an Object in the backing Cache + private static final Object PRESENT = new Object(); // Dummy value to associate with an Object in the backing Cache public ExpiringSet(long duration, TimeUnit unit) { this.cache = Caffeine.newBuilder().expireAfterWrite(duration, unit).build(); diff --git a/AnarchyExploitFixesLegacy/src/main/java/me/moomoo/anarchyexploitfixes/utils/models/TPSCache.java b/AnarchyExploitFixesLegacy/src/main/java/me/moomoo/anarchyexploitfixes/utils/models/TPSCache.java index f2c371b17..10b878f1d 100755 --- a/AnarchyExploitFixesLegacy/src/main/java/me/moomoo/anarchyexploitfixes/utils/models/TPSCache.java +++ b/AnarchyExploitFixesLegacy/src/main/java/me/moomoo/anarchyexploitfixes/utils/models/TPSCache.java @@ -11,12 +11,11 @@ public final class TPSCache { private final Server server; private final Cache cached_tps; - private final Object TPS_KEY; + private static final Object TPS_KEY = new Object(); TPSCache(Server server, long checkDelayMillis) { this.server = server; this.cached_tps = Caffeine.newBuilder().expireAfterWrite(Duration.ofMillis(checkDelayMillis)).build(); - this.TPS_KEY = new Object(); // Dummy value to associate with tps in the backing Cache } public static TPSCache create(long checkDelayMillis) { @@ -24,10 +23,10 @@ public static TPSCache create(long checkDelayMillis) { } public double getTPS() { - Double tps = this.cached_tps.getIfPresent(this.TPS_KEY); + Double tps = this.cached_tps.getIfPresent(TPS_KEY); if (tps == null) { tps = this.server.getTPS()[0]; - this.cached_tps.put(this.TPS_KEY, tps); + this.cached_tps.put(TPS_KEY, tps); } return tps; }