Refactored the BaseActionSource (#3063)

* Refactored the BaseActionSource

It now uses an interface `IActionSource` instead of a concrete class and further
subclasses. 

Instead of relying on a specific class for a certain action type, it now
uses methods with Optional as return values to determine a player or
machine issuing an action. Refer to the JavaDocs for the exact behaviour.

* `IActionHost` no longer extends `IGridHost`

It never used the additional functionality and if needed the `IGridNode`
will also provide a reference to the corresponding `IGridHost`.

Due to most crafting related GUIs being hardcoded to `IGridHost`, 
they no longer work when `IActionHost` is not extending it. Actually
`IActionHost` is the better solution for it, as it prevents us from looking
the grid up via the `IGridHost` and potentially finding a wrong grid.

* Interfaces now only lock the currently worked slot.

This allows `DualityInterface#onChangeInventory` to update slots of the same interface, should they be the source for a requested item and therefore updating their working set accordingly to queue further crafting requests for unfulfilled stack requirements.
This commit is contained in:
yueh
2017-09-12 11:39:00 +02:00
committed by GitHub
parent 771a944058
commit 970630a90d
81 changed files with 572 additions and 465 deletions
+6 -5
View File
@@ -67,7 +67,7 @@ import appeng.api.networking.events.MENetworkCraftingCpuChange;
import appeng.api.networking.events.MENetworkCraftingPatternChange;
import appeng.api.networking.events.MENetworkEventSubscribe;
import appeng.api.networking.events.MENetworkPostCacheConstruction;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.networking.storage.IStorageGrid;
import appeng.api.storage.ICellProvider;
import appeng.api.storage.IMEInventoryHandler;
@@ -80,6 +80,7 @@ import appeng.crafting.CraftingLink;
import appeng.crafting.CraftingLinkNexus;
import appeng.crafting.CraftingWatcher;
import appeng.me.cluster.implementations.CraftingCPUCluster;
import appeng.me.helpers.BaseActionSource;
import appeng.me.helpers.GenericInterestManager;
import appeng.tile.crafting.TileCraftingStorageTile;
import appeng.tile.crafting.TileCraftingTile;
@@ -431,7 +432,7 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
}
@Override
public IAEStack injectItems( IAEStack input, final Actionable type, final BaseActionSource src )
public IAEStack injectItems( IAEStack input, final Actionable type, final IActionSource src )
{
for( final CraftingCPUCluster cpu : this.craftingCPUClusters )
{
@@ -442,7 +443,7 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
}
@Override
public IAEStack extractItems( final IAEStack request, final Actionable mode, final BaseActionSource src )
public IAEStack extractItems( final IAEStack request, final Actionable mode, final IActionSource src )
{
return null;
}
@@ -498,7 +499,7 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
}
@Override
public Future<ICraftingJob> beginCraftingJob( final World world, final IGrid grid, final BaseActionSource actionSrc, final IAEItemStack slotItem, final ICraftingCallback cb )
public Future<ICraftingJob> beginCraftingJob( final World world, final IGrid grid, final IActionSource actionSrc, final IAEItemStack slotItem, final ICraftingCallback cb )
{
if( world == null || grid == null || actionSrc == null || slotItem == null )
{
@@ -511,7 +512,7 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
}
@Override
public ICraftingLink submitJob( final ICraftingJob job, final ICraftingRequester requestingMachine, final ICraftingCPU target, final boolean prioritizePower, final BaseActionSource src )
public ICraftingLink submitJob( final ICraftingJob job, final ICraftingRequester requestingMachine, final ICraftingCPU target, final boolean prioritizePower, final IActionSource src )
{
if( job.isSimulation() )
{
+10 -9
View File
@@ -34,10 +34,9 @@ import appeng.api.networking.IGridNode;
import appeng.api.networking.IGridStorage;
import appeng.api.networking.events.MENetworkCellArrayUpdate;
import appeng.api.networking.events.MENetworkEventSubscribe;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionHost;
import appeng.api.networking.security.IActionSource;
import appeng.api.networking.security.ISecurityGrid;
import appeng.api.networking.security.MachineSource;
import appeng.api.networking.storage.IStackWatcher;
import appeng.api.networking.storage.IStackWatcherHost;
import appeng.api.networking.storage.IStorageGrid;
@@ -50,7 +49,9 @@ import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IAEStack;
import appeng.api.storage.data.IItemList;
import appeng.me.helpers.BaseActionSource;
import appeng.me.helpers.GenericInterestManager;
import appeng.me.helpers.MachineSource;
import appeng.me.storage.ItemWatcher;
import appeng.me.storage.NetworkInventoryHandler;
@@ -161,7 +162,7 @@ public class GridStorageCache implements IStorageGrid
this.inactiveCellProviders.remove( cc );
this.activeCellProviders.add( cc );
BaseActionSource actionSrc = new BaseActionSource();
IActionSource actionSrc = new BaseActionSource();
if( cc instanceof IActionHost )
{
actionSrc = new MachineSource( (IActionHost) cc );
@@ -188,7 +189,7 @@ public class GridStorageCache implements IStorageGrid
this.activeCellProviders.remove( cc );
this.inactiveCellProviders.add( cc );
BaseActionSource actionSrc = new BaseActionSource();
IActionSource actionSrc = new BaseActionSource();
if( cc instanceof IActionHost )
{
@@ -254,7 +255,7 @@ public class GridStorageCache implements IStorageGrid
tracker.applyChanges();
}
private void postChangesToNetwork( final StorageChannel chan, final int upOrDown, final IItemList availableItems, final BaseActionSource src )
private void postChangesToNetwork( final StorageChannel chan, final int upOrDown, final IItemList availableItems, final IActionSource src )
{
switch( chan )
{
@@ -317,7 +318,7 @@ public class GridStorageCache implements IStorageGrid
}
@Override
public void postAlterationOfStoredItems( final StorageChannel chan, final Iterable<? extends IAEStack> input, final BaseActionSource src )
public void postAlterationOfStoredItems( final StorageChannel chan, final Iterable<? extends IAEStack> input, final IActionSource src )
{
if( chan == StorageChannel.ITEMS )
{
@@ -371,9 +372,9 @@ public class GridStorageCache implements IStorageGrid
final StorageChannel channel;
final int up_or_down;
final IItemList list;
final BaseActionSource src;
final IActionSource src;
public CellChangeTrackerRecord( final StorageChannel channel, final int i, final IMEInventoryHandler<? extends IAEStack> h, final BaseActionSource actionSrc )
public CellChangeTrackerRecord( final StorageChannel channel, final int i, final IMEInventoryHandler<? extends IAEStack> h, final IActionSource actionSrc )
{
this.channel = channel;
this.up_or_down = i;
@@ -404,7 +405,7 @@ public class GridStorageCache implements IStorageGrid
final List<CellChangeTrackerRecord> data = new LinkedList<>();
public void postChanges( final StorageChannel channel, final int i, final IMEInventoryHandler<? extends IAEStack> h, final BaseActionSource actionSrc )
public void postChanges( final StorageChannel channel, final int i, final IMEInventoryHandler<? extends IAEStack> h, final IActionSource actionSrc )
{
this.data.add( new CellChangeTrackerRecord( channel, i, h, actionSrc ) );
}
+7 -7
View File
@@ -36,7 +36,7 @@ import com.google.common.collect.Lists;
import appeng.api.config.AccessRestriction;
import appeng.api.config.Actionable;
import appeng.api.networking.events.MENetworkStorageEvent;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.IMEMonitorHandlerReceiver;
@@ -86,7 +86,7 @@ public class NetworkMonitor<T extends IAEStack<T>> implements IMEMonitor<T>
}
@Override
public T extractItems( final T request, final Actionable mode, final BaseActionSource src )
public T extractItems( final T request, final Actionable mode, final IActionSource src )
{
if( mode == Actionable.SIMULATE )
{
@@ -150,7 +150,7 @@ public class NetworkMonitor<T extends IAEStack<T>> implements IMEMonitor<T>
}
@Override
public T injectItems( final T input, final Actionable mode, final BaseActionSource src )
public T injectItems( final T input, final Actionable mode, final IActionSource src )
{
if( mode == Actionable.SIMULATE )
{
@@ -207,7 +207,7 @@ public class NetworkMonitor<T extends IAEStack<T>> implements IMEMonitor<T>
return this.listeners.entrySet().iterator();
}
private T monitorDifference( final IAEStack original, final T leftOvers, final boolean extraction, final BaseActionSource src )
private T monitorDifference( final IAEStack original, final T leftOvers, final boolean extraction, final IActionSource src )
{
final T diff = (T) original.copy();
@@ -228,7 +228,7 @@ public class NetworkMonitor<T extends IAEStack<T>> implements IMEMonitor<T>
return leftOvers;
}
private void notifyListenersOfChange( final Iterable<T> diff, final BaseActionSource src )
private void notifyListenersOfChange( final Iterable<T> diff, final IActionSource src )
{
this.hasChanged = true;
final Iterator<Entry<IMEMonitorHandlerReceiver<T>, Object>> i = this.getListeners();
@@ -248,12 +248,12 @@ public class NetworkMonitor<T extends IAEStack<T>> implements IMEMonitor<T>
}
}
private void postChangesToListeners( final Iterable<T> changes, final BaseActionSource src )
private void postChangesToListeners( final Iterable<T> changes, final IActionSource src )
{
this.postChange( true, changes, src );
}
protected void postChange( final boolean add, final Iterable<T> changes, final BaseActionSource src )
protected void postChange( final boolean add, final Iterable<T> changes, final IActionSource src )
{
if( this.localDepthSemaphore > 0 || GLOBAL_DEPTH.contains( this ) )
{
@@ -55,8 +55,7 @@ import appeng.api.networking.crafting.ICraftingPatternDetails;
import appeng.api.networking.crafting.ICraftingRequester;
import appeng.api.networking.energy.IEnergyGrid;
import appeng.api.networking.events.MENetworkCraftingCpuChange;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.MachineSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.networking.storage.IStorageGrid;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.IMEMonitorHandlerReceiver;
@@ -73,6 +72,7 @@ import appeng.crafting.CraftingWatcher;
import appeng.crafting.MECraftingInventory;
import appeng.me.cache.CraftingGridCache;
import appeng.me.cluster.IAECluster;
import appeng.me.helpers.MachineSource;
import appeng.tile.crafting.TileCraftingMonitorTile;
import appeng.tile.crafting.TileCraftingTile;
import appeng.util.Platform;
@@ -236,7 +236,7 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU
return false;
}
public IAEStack injectItems( final IAEStack input, final Actionable type, final BaseActionSource src )
public IAEStack injectItems( final IAEStack input, final Actionable type, final IActionSource src )
{
if( !( input instanceof IAEItemStack ) )
{
@@ -365,7 +365,7 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU
return input;
}
private void postChange( final IAEItemStack diff, final BaseActionSource src )
private void postChange( final IAEItemStack diff, final IActionSource src )
{
final Iterator<Entry<IMEMonitorHandlerReceiver<IAEItemStack>, Object>> i = this.getListeners();
@@ -469,7 +469,7 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU
{
return null;
}
return (TileCraftingTile) this.machineSrc.via;
return (TileCraftingTile) this.machineSrc.machine().get();
}
private IGrid getGrid()
@@ -844,7 +844,7 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU
this.markDirty();
}
public ICraftingLink submitJob( final IGrid g, final ICraftingJob job, final BaseActionSource src, final ICraftingRequester requestingMachine )
public ICraftingLink submitJob( final IGrid g, final ICraftingJob job, final IActionSource src, final ICraftingRequester requestingMachine )
{
if( !this.tasks.isEmpty() || !this.waitingFor.isEmpty() )
{
@@ -935,7 +935,7 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU
}
@Override
public BaseActionSource getActionSource()
public IActionSource getActionSource()
{
return this.machineSrc;
}
@@ -0,0 +1,50 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.me.helpers;
import java.util.Optional;
import net.minecraft.entity.player.EntityPlayer;
import appeng.api.networking.security.IActionHost;
import appeng.api.networking.security.IActionSource;
public class BaseActionSource implements IActionSource
{
@Override
public Optional<EntityPlayer> player()
{
return Optional.empty();
}
@Override
public Optional<IActionHost> machine()
{
return Optional.empty();
}
@Override
public <T> Optional<T> context( Class<T> key )
{
return Optional.empty();
}
}
@@ -0,0 +1,58 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.me.helpers;
import java.util.Optional;
import net.minecraft.entity.player.EntityPlayer;
import appeng.api.networking.security.IActionHost;
import appeng.api.networking.security.IActionSource;
public class MachineSource implements IActionSource
{
private final IActionHost via;
public MachineSource( final IActionHost v )
{
this.via = v;
}
@Override
public Optional<EntityPlayer> player()
{
return Optional.empty();
}
@Override
public Optional<IActionHost> machine()
{
return Optional.of( this.via );
}
@Override
public <T> Optional<T> context( Class<T> key )
{
return Optional.empty();
}
}
@@ -0,0 +1,62 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.me.helpers;
import java.util.Optional;
import com.google.common.base.Preconditions;
import net.minecraft.entity.player.EntityPlayer;
import appeng.api.networking.security.IActionHost;
import appeng.api.networking.security.IActionSource;
public class PlayerSource implements IActionSource
{
private final EntityPlayer player;
private final IActionHost via;
public PlayerSource( final EntityPlayer p, final IActionHost v )
{
Preconditions.checkNotNull( p );
this.player = p;
this.via = v;
}
@Override
public Optional<EntityPlayer> player()
{
return Optional.of( this.player );
}
@Override
public Optional<IActionHost> machine()
{
return Optional.ofNullable( this.via );
}
@Override
public <T> Optional<T> context( Class<T> key )
{
return Optional.empty();
}
}
@@ -33,7 +33,7 @@ import appeng.api.config.Actionable;
import appeng.api.config.FuzzyMode;
import appeng.api.exceptions.AppEngException;
import appeng.api.implementations.items.IStorageCell;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.storage.ICellInventory;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.IMEInventoryHandler;
@@ -202,7 +202,7 @@ public class CellInventory implements ICellInventory
}
@Override
public IAEItemStack injectItems( final IAEItemStack input, final Actionable mode, final BaseActionSource src )
public IAEItemStack injectItems( final IAEItemStack input, final Actionable mode, final IActionSource src )
{
if( input == null )
{
@@ -299,7 +299,7 @@ public class CellInventory implements ICellInventory
}
@Override
public IAEItemStack extractItems( final IAEItemStack request, final Actionable mode, final BaseActionSource src )
public IAEItemStack extractItems( final IAEItemStack request, final Actionable mode, final IActionSource src )
{
if( request == null )
{
@@ -24,7 +24,7 @@ import net.minecraft.item.ItemStack;
import appeng.api.AEApi;
import appeng.api.config.AccessRestriction;
import appeng.api.config.Actionable;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEItemStack;
@@ -58,7 +58,7 @@ public class CreativeCellInventory implements IMEInventoryHandler<IAEItemStack>
}
@Override
public IAEItemStack injectItems( final IAEItemStack input, final Actionable mode, final BaseActionSource src )
public IAEItemStack injectItems( final IAEItemStack input, final Actionable mode, final IActionSource src )
{
final IAEItemStack local = this.itemListCache.findPrecise( input );
if( local == null )
@@ -70,7 +70,7 @@ public class CreativeCellInventory implements IMEInventoryHandler<IAEItemStack>
}
@Override
public IAEItemStack extractItems( final IAEItemStack request, final Actionable mode, final BaseActionSource src )
public IAEItemStack extractItems( final IAEItemStack request, final Actionable mode, final IActionSource src )
{
final IAEItemStack local = this.itemListCache.findPrecise( request );
if( local == null )
@@ -23,7 +23,7 @@ import net.minecraft.item.ItemStack;
import appeng.api.config.Actionable;
import appeng.api.implementations.tiles.IChestOrDrive;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.storage.ICellHandler;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.data.IAEStack;
@@ -46,7 +46,7 @@ public class DriveWatcher<T extends IAEStack<T>> extends MEInventoryHandler<T>
}
@Override
public T injectItems( final T input, final Actionable type, final BaseActionSource src )
public T injectItems( final T input, final Actionable type, final IActionSource src )
{
final long size = input.getStackSize();
@@ -67,7 +67,7 @@ public class DriveWatcher<T extends IAEStack<T>> extends MEInventoryHandler<T>
}
@Override
public T extractItems( final T request, final Actionable type, final BaseActionSource src )
public T extractItems( final T request, final Actionable type, final IActionSource src )
{
final T a = super.extractItems( request, type, src );
@@ -19,7 +19,7 @@
package appeng.me.storage;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.networking.ticking.TickRateModulation;
@@ -28,6 +28,6 @@ public interface ITickingMonitor
TickRateModulation onTick();
void setActionSource( BaseActionSource actionSource );
void setActionSource( IActionSource actionSource );
}
@@ -22,7 +22,7 @@ package appeng.me.storage;
import appeng.api.config.AccessRestriction;
import appeng.api.config.Actionable;
import appeng.api.config.IncludeExclude;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.StorageChannel;
@@ -96,7 +96,7 @@ public class MEInventoryHandler<T extends IAEStack<T>> implements IMEInventoryHa
}
@Override
public T injectItems( final T input, final Actionable type, final BaseActionSource src )
public T injectItems( final T input, final Actionable type, final IActionSource src )
{
if( !this.canAccept( input ) )
{
@@ -107,7 +107,7 @@ public class MEInventoryHandler<T extends IAEStack<T>> implements IMEInventoryHa
}
@Override
public T extractItems( final T request, final Actionable type, final BaseActionSource src )
public T extractItems( final T request, final Actionable type, final IActionSource src )
{
if( !this.hasReadAccess )
{
@@ -32,7 +32,7 @@ import appeng.api.AEApi;
import appeng.api.config.AccessRestriction;
import appeng.api.config.Actionable;
import appeng.api.config.StorageFilter;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.networking.ticking.TickRateModulation;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.IMEMonitorHandlerReceiver;
@@ -51,7 +51,7 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>, ITickingMo
private final IItemList<IAEItemStack> list = AEApi.instance().storage().createItemList();
private final HashMap<IMEMonitorHandlerReceiver<IAEItemStack>, Object> listeners = new HashMap<>();
private final NavigableMap<Integer, CachedItemStack> memory;
private BaseActionSource mySource;
private IActionSource mySource;
private StorageFilter mode = StorageFilter.EXTRACTABLE_ONLY;
public MEMonitorIInventory( final InventoryAdaptor adaptor )
@@ -73,7 +73,7 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>, ITickingMo
}
@Override
public IAEItemStack injectItems( final IAEItemStack input, final Actionable type, final BaseActionSource src )
public IAEItemStack injectItems( final IAEItemStack input, final Actionable type, final IActionSource src )
{
ItemStack out = ItemStack.EMPTY;
@@ -103,7 +103,7 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>, ITickingMo
}
@Override
public IAEItemStack extractItems( final IAEItemStack request, final Actionable type, final BaseActionSource src )
public IAEItemStack extractItems( final IAEItemStack request, final Actionable type, final IActionSource src )
{
ItemStack out = ItemStack.EMPTY;
@@ -325,13 +325,13 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>, ITickingMo
this.mode = mode;
}
private BaseActionSource getActionSource()
private IActionSource getActionSource()
{
return this.mySource;
}
@Override
public void setActionSource( final BaseActionSource mySource )
public void setActionSource( final IActionSource mySource )
{
this.mySource = mySource;
}
@@ -23,7 +23,7 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.Map.Entry;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.networking.storage.IBaseMonitor;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.IMEMonitor;
@@ -39,7 +39,7 @@ public class MEMonitorPassThrough<T extends IAEStack<T>> extends MEPassThrough<T
{
private final HashMap<IMEMonitorHandlerReceiver<T>, Object> listeners = new HashMap<>();
private BaseActionSource changeSource;
private IActionSource changeSource;
private IMEMonitor<T> monitor;
public MEMonitorPassThrough( final IMEInventory<T> i, final StorageChannel channel )
@@ -118,7 +118,7 @@ public class MEMonitorPassThrough<T extends IAEStack<T>> extends MEPassThrough<T
}
@Override
public void postChange( final IBaseMonitor<T> monitor, final Iterable<T> change, final BaseActionSource source )
public void postChange( final IBaseMonitor<T> monitor, final Iterable<T> change, final IActionSource source )
{
final Iterator<Entry<IMEMonitorHandlerReceiver<T>, Object>> i = this.listeners.entrySet().iterator();
while( i.hasNext() )
@@ -155,12 +155,12 @@ public class MEMonitorPassThrough<T extends IAEStack<T>> extends MEPassThrough<T
}
}
private BaseActionSource getChangeSource()
private IActionSource getChangeSource()
{
return this.changeSource;
}
public void setChangeSource( final BaseActionSource changeSource )
public void setChangeSource( final IActionSource changeSource )
{
this.changeSource = changeSource;
}
@@ -21,7 +21,7 @@ package appeng.me.storage;
import appeng.api.config.AccessRestriction;
import appeng.api.config.Actionable;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.StorageChannel;
@@ -52,13 +52,13 @@ public class MEPassThrough<T extends IAEStack<T>> implements IMEInventoryHandler
}
@Override
public T injectItems( final T input, final Actionable type, final BaseActionSource src )
public T injectItems( final T input, final Actionable type, final IActionSource src )
{
return this.internal.injectItems( input, type, src );
}
@Override
public T extractItems( final T request, final Actionable type, final BaseActionSource src )
public T extractItems( final T request, final Actionable type, final IActionSource src )
{
return this.internal.extractItems( request, type, src );
}
@@ -32,10 +32,8 @@ import appeng.api.config.Actionable;
import appeng.api.config.SecurityPermissions;
import appeng.api.networking.IGrid;
import appeng.api.networking.IGridNode;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.networking.security.ISecurityGrid;
import appeng.api.networking.security.MachineSource;
import appeng.api.networking.security.PlayerSource;
import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEStack;
@@ -77,7 +75,7 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
}
@Override
public T injectItems( T input, final Actionable type, final BaseActionSource src )
public T injectItems( T input, final Actionable type, final IActionSource src )
{
if( this.diveList( this, type ) )
{
@@ -137,20 +135,20 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
return false;
}
private boolean testPermission( final BaseActionSource src, final SecurityPermissions permission )
private boolean testPermission( final IActionSource src, final SecurityPermissions permission )
{
if( src.isPlayer() )
if( src.player().isPresent() )
{
if( !this.security.hasPermission( ( (PlayerSource) src ).player, permission ) )
if( !this.security.hasPermission( src.player().get(), permission ) )
{
return true;
}
}
else if( src.isMachine() )
else if( src.machine().isPresent() )
{
if( this.security.isAvailable() )
{
final IGridNode n = ( (MachineSource) src ).via.getActionableNode();
final IGridNode n = src.machine().get().getActionableNode();
if( n == null )
{
return true;
@@ -197,7 +195,7 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
}
@Override
public T extractItems( T request, final Actionable mode, final BaseActionSource src )
public T extractItems( T request, final Actionable mode, final IActionSource src )
{
if( this.diveList( this, mode ) )
{
@@ -21,7 +21,7 @@ package appeng.me.storage;
import appeng.api.config.AccessRestriction;
import appeng.api.config.Actionable;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEStack;
@@ -32,13 +32,13 @@ public class NullInventory<T extends IAEStack<T>> implements IMEInventoryHandler
{
@Override
public T injectItems( final T input, final Actionable mode, final BaseActionSource src )
public T injectItems( final T input, final Actionable mode, final IActionSource src )
{
return input;
}
@Override
public T extractItems( final T request, final Actionable mode, final BaseActionSource src )
public T extractItems( final T request, final Actionable mode, final IActionSource src )
{
return null;
}
@@ -26,8 +26,7 @@ import appeng.api.config.AccessRestriction;
import appeng.api.config.Actionable;
import appeng.api.config.SecurityPermissions;
import appeng.api.implementations.items.IBiometricCard;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.PlayerSource;
import appeng.api.networking.security.IActionSource;
import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEItemStack;
@@ -48,7 +47,7 @@ public class SecurityStationInventory implements IMEInventoryHandler<IAEItemStac
}
@Override
public IAEItemStack injectItems( final IAEItemStack input, final Actionable type, final BaseActionSource src )
public IAEItemStack injectItems( final IAEItemStack input, final Actionable type, final IActionSource src )
{
if( this.hasPermission( src ) )
{
@@ -70,13 +69,13 @@ public class SecurityStationInventory implements IMEInventoryHandler<IAEItemStac
return input;
}
private boolean hasPermission( final BaseActionSource src )
private boolean hasPermission( final IActionSource src )
{
if( src.isPlayer() )
if( src.player().isPresent() )
{
try
{
return this.securityTile.getProxy().getSecurity().hasPermission( ( (PlayerSource) src ).player, SecurityPermissions.SECURITY );
return this.securityTile.getProxy().getSecurity().hasPermission( src.player().get(), SecurityPermissions.SECURITY );
}
catch( final GridAccessException e )
{
@@ -87,7 +86,7 @@ public class SecurityStationInventory implements IMEInventoryHandler<IAEItemStac
}
@Override
public IAEItemStack extractItems( final IAEItemStack request, final Actionable mode, final BaseActionSource src )
public IAEItemStack extractItems( final IAEItemStack request, final Actionable mode, final IActionSource src )
{
if( this.hasPermission( src ) )
{