Updated Grid API (#3399)

* Updated Grid API

Added Nonull/Nullable/Nonnegative where applicable.
Deprecated unused methods
Changed concrete classes with interfaces (HashMap -> Map)
IGridTickable will no longer accept null as TickingRequest. Do not
implement it, if it should not tick.

* Renamed parameter to match conventions
This commit is contained in:
yueh
2018-05-27 21:16:01 +02:00
committed by GitHub
parent d7b97fa7b8
commit 044e639827
29 changed files with 193 additions and 75 deletions
@@ -20,7 +20,6 @@ package appeng.helpers;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
import appeng.api.config.SecurityPermissions;
@@ -32,7 +31,7 @@ public class PlayerSecurityWrapper implements ISecurityRegistry
private final Map<Integer, EnumSet<SecurityPermissions>> target;
public PlayerSecurityWrapper( final HashMap<Integer, EnumSet<SecurityPermissions>> playerPerms )
public PlayerSecurityWrapper( final Map<Integer, EnumSet<SecurityPermissions>> playerPerms )
{
this.target = playerPerms;
}
+26 -17
View File
@@ -22,6 +22,8 @@ package appeng.me.cache;
import java.util.HashMap;
import java.util.PriorityQueue;
import com.google.common.base.Preconditions;
import net.minecraft.crash.CrashReport;
import net.minecraft.crash.CrashReportCategory;
import net.minecraft.util.ReportedException;
@@ -156,25 +158,26 @@ public class TickManagerCache implements ITickManager
{
if( machine instanceof IGridTickable )
{
final TickingRequest tr = ( (IGridTickable) machine ).getTickingRequest( gridNode );
if( tr != null )
final IGridTickable tickable = ( (IGridTickable) machine );
final TickingRequest tr = tickable.getTickingRequest( gridNode );
Preconditions.checkNotNull( tr );
final TickTracker tt = new TickTracker( tr, gridNode, (IGridTickable) machine, this.currentTick, this );
if( tr.canBeAlerted )
{
final TickTracker tt = new TickTracker( tr, gridNode, (IGridTickable) machine, this.currentTick, this );
this.alertable.put( gridNode, tt );
}
if( tr.canBeAlerted )
{
this.alertable.put( gridNode, tt );
}
if( tr.isSleeping )
{
this.sleeping.put( gridNode, tt );
}
else
{
this.awake.put( gridNode, tt );
this.addToQueue( tt );
}
if( tr.isSleeping )
{
this.sleeping.put( gridNode, tt );
}
else
{
this.awake.put( gridNode, tt );
this.addToQueue( tt );
}
}
}
@@ -200,6 +203,8 @@ public class TickManagerCache implements ITickManager
@Override
public boolean alertDevice( final IGridNode node )
{
Preconditions.checkNotNull( node );
final TickTracker tt = this.alertable.get( node );
if( tt == null )
{
@@ -226,6 +231,8 @@ public class TickManagerCache implements ITickManager
@Override
public boolean sleepDevice( final IGridNode node )
{
Preconditions.checkNotNull( node );
if( this.awake.containsKey( node ) )
{
final TickTracker gt = this.awake.get( node );
@@ -241,6 +248,8 @@ public class TickManagerCache implements ITickManager
@Override
public boolean wakeDevice( final IGridNode node )
{
Preconditions.checkNotNull( node );
if( this.sleeping.containsKey( node ) )
{
final TickTracker gt = this.sleeping.get( node );
@@ -21,8 +21,8 @@ package appeng.tile.misc;
import java.io.IOException;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import io.netty.buffer.ByteBuf;
@@ -316,7 +316,7 @@ public class TileSecurityStation extends AENetworkTile implements ITerminalHost,
}
@Override
public void readPermissions( final HashMap<Integer, EnumSet<SecurityPermissions>> playerPerms )
public void readPermissions( final Map<Integer, EnumSet<SecurityPermissions>> playerPerms )
{
final IPlayerRegistry pr = AEApi.instance().registries().players();