Security Update.
This commit is contained in:
Vendored
+43
-2
@@ -1,12 +1,16 @@
|
||||
package appeng.me.cache;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.Set;
|
||||
|
||||
import appeng.api.networking.events.MENetworkStorageEvent;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
import appeng.api.storage.MEMonitorHandler;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.me.storage.ItemWatcher;
|
||||
|
||||
public class NetworkMonitor<T extends IAEStack<T>> extends MEMonitorHandler<T>
|
||||
{
|
||||
@@ -16,6 +20,11 @@ public class NetworkMonitor<T extends IAEStack<T>> extends MEMonitorHandler<T>
|
||||
|
||||
boolean sendEvent = false;
|
||||
|
||||
public void forceUpdate()
|
||||
{
|
||||
hasChanged = true;
|
||||
}
|
||||
|
||||
public NetworkMonitor(GridStorageCache cache, StorageChannel chan) {
|
||||
super( null );
|
||||
myGridCache = cache;
|
||||
@@ -24,8 +33,21 @@ public class NetworkMonitor<T extends IAEStack<T>> extends MEMonitorHandler<T>
|
||||
|
||||
final static public LinkedList depth = new LinkedList();
|
||||
|
||||
private BaseActionSource src;
|
||||
|
||||
public void setSource(BaseActionSource src)
|
||||
{
|
||||
this.src = src;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void postChange(T diff)
|
||||
protected BaseActionSource getSource()
|
||||
{
|
||||
return src;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void postChange(T diff, BaseActionSource src)
|
||||
{
|
||||
if ( depth.contains( this ) )
|
||||
return;
|
||||
@@ -33,7 +55,26 @@ public class NetworkMonitor<T extends IAEStack<T>> extends MEMonitorHandler<T>
|
||||
depth.push( this );
|
||||
|
||||
sendEvent = true;
|
||||
super.postChange( diff );
|
||||
super.postChange( diff, src );
|
||||
|
||||
if ( myGridCache.interests.containsKey( diff ) )
|
||||
{
|
||||
Set<ItemWatcher> list = myGridCache.interests.get( diff );
|
||||
if ( !list.isEmpty() )
|
||||
{
|
||||
IItemList<T> myStorageList = getStorageList();
|
||||
|
||||
IAEStack fullStack = myStorageList.findPrecise( diff );
|
||||
if ( fullStack == null )
|
||||
{
|
||||
fullStack = diff.copy();
|
||||
fullStack.setStackSize( 0 );
|
||||
}
|
||||
|
||||
for (ItemWatcher iw : list)
|
||||
iw.getHost().onStackChange( myStorageList, fullStack, diff, src, getChannel() );
|
||||
}
|
||||
}
|
||||
|
||||
Object last = depth.pop();
|
||||
if ( last != this )
|
||||
|
||||
@@ -11,6 +11,7 @@ import net.minecraftforge.common.ForgeDirection;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.AccessRestriction;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.networking.ticking.TickRateModulation;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
@@ -56,6 +57,8 @@ public class MEMonitorIInventory implements IMEInventory<IAEItemStack>, IMEMonit
|
||||
final IItemList<IAEItemStack> list = new ItemList();
|
||||
final HashMap<IMEMonitorHandlerReciever<IAEItemStack>, Object> listeners = new HashMap();
|
||||
|
||||
public BaseActionSource mySource;
|
||||
|
||||
@Override
|
||||
public void addListener(IMEMonitorHandlerReciever<IAEItemStack> l, Object verificationToken)
|
||||
{
|
||||
@@ -241,7 +244,7 @@ public class MEMonitorIInventory implements IMEInventory<IAEItemStack>, IMEMonit
|
||||
Entry<IMEMonitorHandlerReciever<IAEItemStack>, Object> l = i.next();
|
||||
IMEMonitorHandlerReciever<IAEItemStack> key = l.getKey();
|
||||
if ( key.isValid( l.getValue() ) )
|
||||
key.postChange( a );
|
||||
key.postChange( this, a, mySource );
|
||||
else
|
||||
i.remove();
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.IMEMonitorHandlerReciever;
|
||||
@@ -18,6 +19,8 @@ public class MEMonitorPassthu<T extends IAEStack<T>> extends MEPassthru<T> imple
|
||||
HashMap<IMEMonitorHandlerReciever<T>, Object> listeners = new HashMap();
|
||||
IMEMonitor<T> monitor;
|
||||
|
||||
public BaseActionSource changeSource;
|
||||
|
||||
public MEMonitorPassthu(IMEInventory<T> i) {
|
||||
super( i );
|
||||
if ( i instanceof IMEMonitor )
|
||||
@@ -42,7 +45,7 @@ public class MEMonitorPassthu<T extends IAEStack<T>> extends MEPassthru<T> imple
|
||||
if ( monitor != null )
|
||||
monitor.addListener( this, monitor );
|
||||
|
||||
Platform.postListChanges( before, after, this );
|
||||
Platform.postListChanges( before, after, this, changeSource );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -72,7 +75,7 @@ public class MEMonitorPassthu<T extends IAEStack<T>> extends MEPassthru<T> imple
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postChange(T change)
|
||||
public void postChange(IMEMonitor<T> monitor, T change, BaseActionSource source)
|
||||
{
|
||||
Iterator<Entry<IMEMonitorHandlerReciever<T>, Object>> i = listeners.entrySet().iterator();
|
||||
while (i.hasNext())
|
||||
@@ -80,7 +83,7 @@ public class MEMonitorPassthu<T extends IAEStack<T>> extends MEPassthru<T> imple
|
||||
Entry<IMEMonitorHandlerReciever<T>, Object> e = i.next();
|
||||
IMEMonitorHandlerReciever<T> recv = e.getKey();
|
||||
if ( recv.isValid( e.getValue() ) )
|
||||
recv.postChange( change );
|
||||
recv.postChange( this, change, source );
|
||||
else
|
||||
i.remove();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user