From ae8a1b13fad645a6cb4f41839dc225fce6463916 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Z=C3=BCnd?= Date: Fri, 3 Jan 2025 03:28:50 +0100 Subject: [PATCH] cleanup: Deprecate and remove usages of GridCacheWrapper (#650) --- src/main/java/appeng/me/Grid.java | 8 ++++---- src/main/java/appeng/me/GridCacheWrapper.java | 1 + src/main/java/appeng/me/NetworkEventBus.java | 5 +++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/appeng/me/Grid.java b/src/main/java/appeng/me/Grid.java index 7d23a68ca95..bee3ddf7f13 100644 --- a/src/main/java/appeng/me/Grid.java +++ b/src/main/java/appeng/me/Grid.java @@ -36,7 +36,7 @@ public class Grid implements IGrid { private final NetworkEventBus eventBus = new NetworkEventBus(); private final Map, MachineSet> machines = new HashMap<>(); - private final Map, GridCacheWrapper> caches = new HashMap<>(); + private final Map, IGridCache> caches = new HashMap<>(); private GridNode pivot; private int priority; // how import is this network? private GridStorage myStorage; @@ -56,7 +56,7 @@ public Grid(final GridNode center) { final Class valueClass = value.getClass(); this.eventBus.readClass(key, valueClass); - this.caches.put(key, new GridCacheWrapper(value)); + this.caches.put(key, value); } this.postEvent(new MENetworkPostCacheConstruction()); @@ -73,7 +73,7 @@ IGridStorage getMyStorage() { return this.myStorage; } - Map, GridCacheWrapper> getCaches() { + Map, IGridCache> getCaches() { return this.caches; } @@ -179,7 +179,7 @@ void add(final GridNode gridNode) { @Override @SuppressWarnings("unchecked") public C getCache(final Class iface) { - return (C) this.caches.get(iface).getCache(); + return (C) this.caches.get(iface); } @Override diff --git a/src/main/java/appeng/me/GridCacheWrapper.java b/src/main/java/appeng/me/GridCacheWrapper.java index 929d003381c..0665419cd1f 100644 --- a/src/main/java/appeng/me/GridCacheWrapper.java +++ b/src/main/java/appeng/me/GridCacheWrapper.java @@ -15,6 +15,7 @@ import appeng.api.networking.IGridNode; import appeng.api.networking.IGridStorage; +/** @deprecated Use `.getClass().getName()` on IGridCache instances directly instead of `getName` */ public class GridCacheWrapper implements IGridCache { private final IGridCache myCache; diff --git a/src/main/java/appeng/me/NetworkEventBus.java b/src/main/java/appeng/me/NetworkEventBus.java index e5ed4b00c51..60fbd75e8db 100644 --- a/src/main/java/appeng/me/NetworkEventBus.java +++ b/src/main/java/appeng/me/NetworkEventBus.java @@ -19,6 +19,7 @@ import java.util.Map; import java.util.Map.Entry; +import appeng.api.networking.IGridCache; import appeng.api.networking.IGridNode; import appeng.api.networking.events.MENetworkEvent; import appeng.api.networking.events.MENetworkEventSubscribe; @@ -79,10 +80,10 @@ MENetworkEvent postEvent(final Grid g, final MENetworkEvent e) { if (subscribers != null) { for (final Entry subscriber : subscribers.entrySet()) { final MENetworkEventInfo target = subscriber.getValue(); - final GridCacheWrapper cache = g.getCaches().get(subscriber.getKey()); + final IGridCache cache = g.getCaches().get(subscriber.getKey()); if (cache != null) { x++; - target.invoke(cache.getCache(), e); + target.invoke(cache, e); } for (final IGridNode obj : g.getMachines(subscriber.getKey())) {