Refactored StorageChannel enum into an interface (#3138)
This replaces the static enum with a more dynamic interface providing factory methods for handling network storage.
This commit is contained in:
@@ -37,7 +37,8 @@ import appeng.api.storage.ICellInventory;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
import appeng.api.storage.ISaveProvider;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.IStorageChannel;
|
||||
import appeng.api.storage.channels.IItemStorageChannel;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.core.AEConfig;
|
||||
@@ -197,7 +198,7 @@ public class CellInventory implements ICellInventory
|
||||
|
||||
private boolean isEmpty( final IMEInventory meInventory )
|
||||
{
|
||||
return meInventory.getAvailableItems( AEApi.instance().storage().createItemList() ).isEmpty();
|
||||
return meInventory.getAvailableItems( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList() ).isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -275,12 +276,12 @@ public class CellInventory implements ICellInventory
|
||||
final ItemStack toWrite = sharedItemStack.copy();
|
||||
toWrite.setCount( remainingItemCount );
|
||||
|
||||
this.cellItems.add( AEItemStack.create( toWrite ) );
|
||||
this.cellItems.add( AEItemStack.fromItemStack( toWrite ) );
|
||||
this.updateItemCount( toWrite.getCount() );
|
||||
|
||||
this.saveChanges();
|
||||
}
|
||||
return AEItemStack.create( toReturn );
|
||||
return AEItemStack.fromItemStack( toReturn );
|
||||
}
|
||||
|
||||
if( mode == Actionable.MODULATE )
|
||||
@@ -343,7 +344,7 @@ public class CellInventory implements ICellInventory
|
||||
{
|
||||
if( this.cellItems == null )
|
||||
{
|
||||
this.cellItems = AEApi.instance().storage().createItemList();
|
||||
this.cellItems = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList();
|
||||
this.loadCellItems();
|
||||
}
|
||||
|
||||
@@ -424,7 +425,7 @@ public class CellInventory implements ICellInventory
|
||||
{
|
||||
if( this.cellItems == null )
|
||||
{
|
||||
this.cellItems = AEApi.instance().storage().createItemList();
|
||||
this.cellItems = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList();
|
||||
}
|
||||
|
||||
this.cellItems.resetStatus(); // clears totals and stuff.
|
||||
@@ -471,7 +472,7 @@ public class CellInventory implements ICellInventory
|
||||
{
|
||||
try
|
||||
{
|
||||
this.cellItems.add( AEItemStack.create( t ) );
|
||||
this.cellItems.add( AEItemStack.fromItemStack( t ) );
|
||||
}
|
||||
catch( Throwable ex )
|
||||
{
|
||||
@@ -497,9 +498,9 @@ public class CellInventory implements ICellInventory
|
||||
}
|
||||
|
||||
@Override
|
||||
public StorageChannel getChannel()
|
||||
public IStorageChannel getChannel()
|
||||
{
|
||||
return StorageChannel.ITEMS;
|
||||
return AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -31,7 +31,7 @@ import appeng.api.implementations.items.IUpgradeModule;
|
||||
import appeng.api.storage.ICellInventory;
|
||||
import appeng.api.storage.ICellInventoryHandler;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.channels.IItemStorageChannel;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.util.Platform;
|
||||
@@ -45,12 +45,12 @@ public class CellInventoryHandler extends MEInventoryHandler<IAEItemStack> imple
|
||||
|
||||
CellInventoryHandler( final IMEInventory c )
|
||||
{
|
||||
super( c, StorageChannel.ITEMS );
|
||||
super( c, AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
|
||||
|
||||
final ICellInventory ci = this.getCellInv();
|
||||
if( ci != null )
|
||||
{
|
||||
final IItemList<IAEItemStack> priorityList = AEApi.instance().storage().createItemList();
|
||||
final IItemList<IAEItemStack> priorityList = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList();
|
||||
|
||||
final IItemHandler upgrades = ci.getUpgradesInventory();
|
||||
final IItemHandler config = ci.getConfigInventory();
|
||||
@@ -86,7 +86,7 @@ public class CellInventoryHandler extends MEInventoryHandler<IAEItemStack> imple
|
||||
final ItemStack is = config.getStackInSlot( x );
|
||||
if( !is.isEmpty() )
|
||||
{
|
||||
priorityList.add( AEItemStack.create( is ) );
|
||||
priorityList.add( AEItemStack.fromItemStack( is ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,8 @@ import appeng.api.config.AccessRestriction;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.networking.security.IActionSource;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.IStorageChannel;
|
||||
import appeng.api.storage.channels.IItemStorageChannel;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.items.contents.CellConfig;
|
||||
@@ -36,7 +37,7 @@ import appeng.util.item.AEItemStack;
|
||||
public class CreativeCellInventory implements IMEInventoryHandler<IAEItemStack>
|
||||
{
|
||||
|
||||
private final IItemList<IAEItemStack> itemListCache = AEApi.instance().storage().createItemList();
|
||||
private final IItemList<IAEItemStack> itemListCache = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList();
|
||||
|
||||
protected CreativeCellInventory( final ItemStack o )
|
||||
{
|
||||
@@ -45,7 +46,7 @@ public class CreativeCellInventory implements IMEInventoryHandler<IAEItemStack>
|
||||
{
|
||||
if( !is.isEmpty() )
|
||||
{
|
||||
final IAEItemStack i = AEItemStack.create( is );
|
||||
final IAEItemStack i = AEItemStack.fromItemStack( is );
|
||||
i.setStackSize( Integer.MAX_VALUE );
|
||||
this.itemListCache.add( i );
|
||||
}
|
||||
@@ -92,9 +93,9 @@ public class CreativeCellInventory implements IMEInventoryHandler<IAEItemStack>
|
||||
}
|
||||
|
||||
@Override
|
||||
public StorageChannel getChannel()
|
||||
public IStorageChannel getChannel()
|
||||
{
|
||||
return StorageChannel.ITEMS;
|
||||
return AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -25,7 +25,7 @@ import appeng.api.config.IncludeExclude;
|
||||
import appeng.api.networking.security.IActionSource;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.IStorageChannel;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.util.prioritylist.DefaultPriorityList;
|
||||
@@ -45,7 +45,7 @@ public class MEInventoryHandler<T extends IAEStack<T>> implements IMEInventoryHa
|
||||
private boolean hasReadAccess;
|
||||
private boolean hasWriteAccess;
|
||||
|
||||
public MEInventoryHandler( final IMEInventory<T> i, final StorageChannel channel )
|
||||
public MEInventoryHandler( final IMEInventory<T> i, final IStorageChannel<T> channel )
|
||||
{
|
||||
if( i instanceof IMEInventoryHandler )
|
||||
{
|
||||
@@ -129,7 +129,7 @@ public class MEInventoryHandler<T extends IAEStack<T>> implements IMEInventoryHa
|
||||
}
|
||||
|
||||
@Override
|
||||
public StorageChannel getChannel()
|
||||
public IStorageChannel getChannel()
|
||||
{
|
||||
return this.internal.getChannel();
|
||||
}
|
||||
|
||||
@@ -36,7 +36,8 @@ import appeng.api.networking.security.IActionSource;
|
||||
import appeng.api.networking.ticking.TickRateModulation;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.IMEMonitorHandlerReceiver;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.IStorageChannel;
|
||||
import appeng.api.storage.channels.IItemStorageChannel;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.util.InventoryAdaptor;
|
||||
@@ -48,7 +49,7 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>, ITickingMo
|
||||
{
|
||||
|
||||
private final InventoryAdaptor adaptor;
|
||||
private final IItemList<IAEItemStack> list = AEApi.instance().storage().createItemList();
|
||||
private final IItemList<IAEItemStack> list = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList();
|
||||
private final HashMap<IMEMonitorHandlerReceiver<IAEItemStack>, Object> listeners = new HashMap<>();
|
||||
private final NavigableMap<Integer, CachedItemStack> memory;
|
||||
private IActionSource mySource;
|
||||
@@ -134,9 +135,9 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>, ITickingMo
|
||||
}
|
||||
|
||||
@Override
|
||||
public StorageChannel getChannel()
|
||||
public IStorageChannel getChannel()
|
||||
{
|
||||
return StorageChannel.ITEMS;
|
||||
return AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -180,7 +181,10 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>, ITickingMo
|
||||
final int newSize = ( newIS.isEmpty() ? 0 : newIS.getCount() );
|
||||
final int diff = newSize - ( oldIS.isEmpty() ? 0 : oldIS.getCount() );
|
||||
|
||||
final IAEItemStack stack = ( old == null || old.aeStack == null ? AEApi.instance().storage().createItemStack( newIS ) : old.aeStack.copy() );
|
||||
final IAEItemStack stack = ( old == null || old.aeStack == null ? AEApi.instance()
|
||||
.storage()
|
||||
.getStorageChannel( IItemStorageChannel.class )
|
||||
.createStack( newIS ) : old.aeStack.copy() );
|
||||
if( stack != null )
|
||||
{
|
||||
stack.setStackSize( newSize );
|
||||
@@ -352,7 +356,7 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>, ITickingMo
|
||||
else
|
||||
{
|
||||
this.itemStack = is.copy();
|
||||
this.aeStack = AEApi.instance().storage().createItemStack( is );
|
||||
this.aeStack = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createStack( is );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ import appeng.api.networking.storage.IBaseMonitor;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.IMEMonitorHandlerReceiver;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.IStorageChannel;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.util.Platform;
|
||||
@@ -42,7 +42,7 @@ public class MEMonitorPassThrough<T extends IAEStack<T>> extends MEPassThrough<T
|
||||
private IActionSource changeSource;
|
||||
private IMEMonitor<T> monitor;
|
||||
|
||||
public MEMonitorPassThrough( final IMEInventory<T> i, final StorageChannel channel )
|
||||
public MEMonitorPassThrough( final IMEInventory<T> i, final IStorageChannel channel )
|
||||
{
|
||||
super( i, channel );
|
||||
if( i instanceof IMEMonitor )
|
||||
|
||||
@@ -24,7 +24,7 @@ import appeng.api.config.Actionable;
|
||||
import appeng.api.networking.security.IActionSource;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.IStorageChannel;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
|
||||
@@ -32,10 +32,10 @@ import appeng.api.storage.data.IItemList;
|
||||
public class MEPassThrough<T extends IAEStack<T>> implements IMEInventoryHandler<T>
|
||||
{
|
||||
|
||||
private final StorageChannel wrappedChannel;
|
||||
private final IStorageChannel wrappedChannel;
|
||||
private IMEInventory<T> internal;
|
||||
|
||||
public MEPassThrough( final IMEInventory<T> i, final StorageChannel channel )
|
||||
public MEPassThrough( final IMEInventory<T> i, final IStorageChannel channel )
|
||||
{
|
||||
this.wrappedChannel = channel;
|
||||
this.setInternal( i );
|
||||
@@ -70,7 +70,7 @@ public class MEPassThrough<T extends IAEStack<T>> implements IMEInventoryHandler
|
||||
}
|
||||
|
||||
@Override
|
||||
public StorageChannel getChannel()
|
||||
public IStorageChannel getChannel()
|
||||
{
|
||||
return this.internal.getChannel();
|
||||
}
|
||||
@@ -111,7 +111,7 @@ public class MEPassThrough<T extends IAEStack<T>> implements IMEInventoryHandler
|
||||
return true;
|
||||
}
|
||||
|
||||
StorageChannel getWrappedChannel()
|
||||
IStorageChannel getWrappedChannel()
|
||||
{
|
||||
return this.wrappedChannel;
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.security.IActionSource;
|
||||
import appeng.api.networking.security.ISecurityGrid;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.IStorageChannel;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.me.cache.SecurityCache;
|
||||
@@ -50,12 +50,12 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
|
||||
private static final Comparator<Integer> PRIORITY_SORTER = ( o1, o2 ) -> ItemSorters.compareInt( o2, o1 );
|
||||
|
||||
private static int currentPass = 0;
|
||||
private final StorageChannel myChannel;
|
||||
private final IStorageChannel<T> myChannel;
|
||||
private final SecurityCache security;
|
||||
private final NavigableMap<Integer, List<IMEInventoryHandler<T>>> priorityInventory;
|
||||
private int myPass = 0;
|
||||
|
||||
public NetworkInventoryHandler( final StorageChannel chan, final SecurityCache security )
|
||||
public NetworkInventoryHandler( final IStorageChannel<T> chan, final SecurityCache security )
|
||||
{
|
||||
this.myChannel = chan;
|
||||
this.security = security;
|
||||
@@ -240,7 +240,7 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemList<T> getAvailableItems( IItemList out )
|
||||
public IItemList<T> getAvailableItems( IItemList<T> out )
|
||||
{
|
||||
if( this.diveIteration( this, Actionable.SIMULATE ) )
|
||||
{
|
||||
@@ -286,7 +286,7 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
|
||||
}
|
||||
|
||||
@Override
|
||||
public StorageChannel getChannel()
|
||||
public IStorageChannel<T> getChannel()
|
||||
{
|
||||
return this.myChannel;
|
||||
}
|
||||
|
||||
@@ -19,11 +19,13 @@
|
||||
package appeng.me.storage;
|
||||
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.AccessRestriction;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.networking.security.IActionSource;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.IStorageChannel;
|
||||
import appeng.api.storage.channels.IItemStorageChannel;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
|
||||
@@ -50,9 +52,9 @@ public class NullInventory<T extends IAEStack<T>> implements IMEInventoryHandler
|
||||
}
|
||||
|
||||
@Override
|
||||
public StorageChannel getChannel()
|
||||
public IStorageChannel getChannel()
|
||||
{
|
||||
return StorageChannel.ITEMS;
|
||||
return AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -28,7 +28,8 @@ import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.implementations.items.IBiometricCard;
|
||||
import appeng.api.networking.security.IActionSource;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.IStorageChannel;
|
||||
import appeng.api.storage.channels.IItemStorageChannel;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.me.GridAccessException;
|
||||
@@ -38,7 +39,7 @@ import appeng.tile.misc.TileSecurityStation;
|
||||
public class SecurityStationInventory implements IMEInventoryHandler<IAEItemStack>
|
||||
{
|
||||
|
||||
private final IItemList<IAEItemStack> storedItems = AEApi.instance().storage().createItemList();
|
||||
private final IItemList<IAEItemStack> storedItems = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList();
|
||||
private final TileSecurityStation securityTile;
|
||||
|
||||
public SecurityStationInventory( final TileSecurityStation ts )
|
||||
@@ -120,9 +121,9 @@ public class SecurityStationInventory implements IMEInventoryHandler<IAEItemStac
|
||||
}
|
||||
|
||||
@Override
|
||||
public StorageChannel getChannel()
|
||||
public IStorageChannel getChannel()
|
||||
{
|
||||
return StorageChannel.ITEMS;
|
||||
return AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user