Skip to content

Commit

Permalink
cleanup: Deprecate and remove usages of GridCacheWrapper (#650)
Browse files Browse the repository at this point in the history
  • Loading branch information
szuend authored Jan 3, 2025
1 parent 1f18578 commit ae8a1b1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/main/java/appeng/me/Grid.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class Grid implements IGrid {

private final NetworkEventBus eventBus = new NetworkEventBus();
private final Map<Class<? extends IGridHost>, MachineSet> machines = new HashMap<>();
private final Map<Class<? extends IGridCache>, GridCacheWrapper> caches = new HashMap<>();
private final Map<Class<? extends IGridCache>, IGridCache> caches = new HashMap<>();
private GridNode pivot;
private int priority; // how import is this network?
private GridStorage myStorage;
Expand All @@ -56,7 +56,7 @@ public Grid(final GridNode center) {
final Class<? extends IGridCache> valueClass = value.getClass();

this.eventBus.readClass(key, valueClass);
this.caches.put(key, new GridCacheWrapper(value));
this.caches.put(key, value);
}

this.postEvent(new MENetworkPostCacheConstruction());
Expand All @@ -73,7 +73,7 @@ IGridStorage getMyStorage() {
return this.myStorage;
}

Map<Class<? extends IGridCache>, GridCacheWrapper> getCaches() {
Map<Class<? extends IGridCache>, IGridCache> getCaches() {
return this.caches;
}

Expand Down Expand Up @@ -179,7 +179,7 @@ void add(final GridNode gridNode) {
@Override
@SuppressWarnings("unchecked")
public <C extends IGridCache> C getCache(final Class<? extends IGridCache> iface) {
return (C) this.caches.get(iface).getCache();
return (C) this.caches.get(iface);
}

@Override
Expand Down
1 change: 1 addition & 0 deletions src/main/java/appeng/me/GridCacheWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/appeng/me/NetworkEventBus.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -79,10 +80,10 @@ MENetworkEvent postEvent(final Grid g, final MENetworkEvent e) {
if (subscribers != null) {
for (final Entry<Class, MENetworkEventInfo> 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())) {
Expand Down

0 comments on commit ae8a1b1

Please sign in to comment.