diff --git a/src/api/java/appeng/api/networking/IGrid.java b/src/api/java/appeng/api/networking/IGrid.java index d06ba8d7e..0f2fbfb1c 100644 --- a/src/api/java/appeng/api/networking/IGrid.java +++ b/src/api/java/appeng/api/networking/IGrid.java @@ -24,6 +24,8 @@ package appeng.api.networking; +import javax.annotation.Nonnull; + import appeng.api.networking.events.MENetworkEvent; import appeng.api.util.IReadOnlyCollection; @@ -43,7 +45,8 @@ public interface IGrid * * @return the IGridCache you requested. */ - C getCache( Class iface ); + @Nonnull + C getCache( @Nonnull Class iface ); /** * Post an event into the network event bus. @@ -52,7 +55,8 @@ public interface IGrid * * @return returns ev back to original poster */ - MENetworkEvent postEvent( MENetworkEvent ev ); + @Nonnull + MENetworkEvent postEvent( @Nonnull MENetworkEvent ev ); /** * Post an event into the network event bus, but direct it at a single node. @@ -61,7 +65,8 @@ public interface IGrid * * @return returns ev back to original poster */ - MENetworkEvent postEventTo( IGridNode node, MENetworkEvent ev ); + @Nonnull + MENetworkEvent postEventTo( @Nonnull IGridNode node, @Nonnull MENetworkEvent ev ); /** * get a list of the diversity of classes, you can use this to better detect which machines your interested in, @@ -69,6 +74,7 @@ public interface IGrid * * @return IReadOnlyCollection of all available host types (Of Type IGridHost). */ + @Nonnull IReadOnlyCollection> getMachinesClasses(); /** @@ -78,11 +84,13 @@ public interface IGrid * * @return IMachineSet of all nodes belonging to hosts of specified class. */ - IMachineSet getMachines( Class gridHostClass ); + @Nonnull + IMachineSet getMachines( @Nonnull Class gridHostClass ); /** * @return IReadOnlyCollection for all nodes on the network, node visitors are preferred. */ + @Nonnull IReadOnlyCollection getNodes(); /** @@ -93,5 +101,6 @@ public interface IGrid /** * @return the node considered the pivot point of the grid. */ + @Nonnull IGridNode getPivot(); } \ No newline at end of file diff --git a/src/api/java/appeng/api/networking/IGridBlock.java b/src/api/java/appeng/api/networking/IGridBlock.java index 87baf84de..d6e1822aa 100644 --- a/src/api/java/appeng/api/networking/IGridBlock.java +++ b/src/api/java/appeng/api/networking/IGridBlock.java @@ -26,6 +26,10 @@ package appeng.api.networking; import java.util.EnumSet; +import javax.annotation.Nonnegative; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; @@ -49,6 +53,7 @@ public interface IGridBlock * * @return ae/t to use. */ + @Nonnegative double getIdlePowerUsage(); /** @@ -56,10 +61,11 @@ public interface IGridBlock * * @return Set of flags for this IGridBlock */ + @Nonnull EnumSet getFlags(); /** - * generally speaking you will return true for this, the one exception is buses, or worm holes where the node + * Generally speaking you will return true for this, the one exception is buses, or worm holes where the node * represents something that isn't a real connection in the world, but rather one represented internally to the * block. * @@ -68,37 +74,46 @@ public interface IGridBlock boolean isWorldAccessible(); /** + * Must not return when {@link #isWorldAccessible()} is true. + * Otherwise the behavior is unspecified. + * * @return current location of this node */ + @Nonnull DimensionalCoord getLocation(); /** * @return Transparent, or a valid color, NULL IS NOT A VALID RETURN */ + @Nonnull AEColor getGridColor(); /** * Notifies your IGridBlock that changes were made to your connections */ - void onGridNotification( GridNotification notification ); + void onGridNotification( @Nonnull GridNotification notification ); /** * Update Blocks network/connection/booting status. grid, * * @param grid grid * @param channelsInUse used channels + * @deprecated to be removed in rv7 */ + @Deprecated void setNetworkStatus( IGrid grid, int channelsInUse ); /** * Determine which sides of the block can be connected too, only used when isWorldAccessible returns true, not used * for {@link IPart} implementations. */ + @Nonnull EnumSet getConnectableSides(); /** * @return the IGridHost for the node, this will be an IGridPart or a TileEntity generally speaking. */ + @Nonnull IGridHost getMachine(); /** @@ -111,5 +126,6 @@ public interface IGridBlock * * @return the render item stack to use to render this node, null is valid, and will not show this node. */ + @Nullable ItemStack getMachineRepresentation(); } diff --git a/src/api/java/appeng/api/networking/IGridCache.java b/src/api/java/appeng/api/networking/IGridCache.java index e692f2372..634ed1b6a 100644 --- a/src/api/java/appeng/api/networking/IGridCache.java +++ b/src/api/java/appeng/api/networking/IGridCache.java @@ -24,6 +24,9 @@ package appeng.api.networking; +import javax.annotation.Nonnull; + + /** * Allows you to create a network wise service, AE2 uses these for providing * item, spatial, and tunnel services. @@ -50,7 +53,7 @@ public interface IGridCache * @param gridNode removed from that grid * @param machine to be removed machine */ - void removeNode( IGridNode gridNode, IGridHost machine ); + void removeNode( @Nonnull IGridNode gridNode, @Nonnull IGridHost machine ); /** * informs you cache that a machine was added to the grid. @@ -62,7 +65,7 @@ public interface IGridCache * @param gridNode added to grid node * @param machine to be added machine */ - void addNode( IGridNode gridNode, IGridHost machine ); + void addNode( @Nonnull IGridNode gridNode, @Nonnull IGridHost machine ); /** * Called when a grid splits into two grids, AE will call a split as it @@ -71,7 +74,7 @@ public interface IGridCache * * @param destinationStorage storage which receives half of old grid */ - void onSplit( IGridStorage destinationStorage ); + void onSplit( @Nonnull IGridStorage destinationStorage ); /** * Called when two grids merge into one, AE will call a join as it @@ -80,12 +83,12 @@ public interface IGridCache * * @param sourceStorage old storage */ - void onJoin( IGridStorage sourceStorage ); + void onJoin( @Nonnull IGridStorage sourceStorage ); /** * Called when saving changes, * * @param destinationStorage storage */ - void populateGridStorage( IGridStorage destinationStorage ); + void populateGridStorage( @Nonnull IGridStorage destinationStorage ); } diff --git a/src/api/java/appeng/api/networking/IGridCacheRegistry.java b/src/api/java/appeng/api/networking/IGridCacheRegistry.java index b54df8dae..47601abf5 100644 --- a/src/api/java/appeng/api/networking/IGridCacheRegistry.java +++ b/src/api/java/appeng/api/networking/IGridCacheRegistry.java @@ -24,7 +24,9 @@ package appeng.api.networking; -import java.util.HashMap; +import java.util.Map; + +import javax.annotation.Nonnull; /** @@ -38,14 +40,14 @@ public interface IGridCacheRegistry * * @param iface grid cache class */ - void registerGridCache( Class iface, Class implementation ); + void registerGridCache( @Nonnull Class iface, @Nonnull Class implementation ); /** * requests a new INSTANCE of a grid cache for use, used internally * * @param grid grid * - * @return a new HashMap of IGridCaches from the registry, called from IGrid when constructing a new grid. + * @return a new Map of IGridCaches from the registry, called from IGrid when constructing a new grid. */ - HashMap, IGridCache> createCacheInstance( IGrid grid ); + Map, IGridCache> createCacheInstance( IGrid grid ); } diff --git a/src/api/java/appeng/api/networking/IGridConnection.java b/src/api/java/appeng/api/networking/IGridConnection.java index 20cbcbe49..85ff26690 100644 --- a/src/api/java/appeng/api/networking/IGridConnection.java +++ b/src/api/java/appeng/api/networking/IGridConnection.java @@ -24,6 +24,8 @@ package appeng.api.networking; +import javax.annotation.Nonnull; + import appeng.api.util.AEPartLocation; @@ -45,6 +47,7 @@ public interface IGridConnection * * @return the IGridNode which represents the opposite side of the connection. */ + @Nonnull IGridNode getOtherSide( IGridNode gridNode ); /** @@ -54,6 +57,7 @@ public interface IGridConnection * * @return the direction of the connection, only valid for in world connections. */ + @Nonnull AEPartLocation getDirection( IGridNode gridNode ); /** @@ -65,11 +69,13 @@ public interface IGridConnection /** * @return node A */ + @Nonnull IGridNode a(); /** * @return node B */ + @Nonnull IGridNode b(); /** diff --git a/src/api/java/appeng/api/networking/IGridConnectionVisitor.java b/src/api/java/appeng/api/networking/IGridConnectionVisitor.java index 1842589e0..84cd12f91 100644 --- a/src/api/java/appeng/api/networking/IGridConnectionVisitor.java +++ b/src/api/java/appeng/api/networking/IGridConnectionVisitor.java @@ -24,6 +24,9 @@ package appeng.api.networking; +import javax.annotation.Nonnull; + + public interface IGridConnectionVisitor extends IGridVisitor { @@ -32,5 +35,5 @@ public interface IGridConnectionVisitor extends IGridVisitor * * @param n the connection. */ - void visitConnection( IGridConnection n ); + void visitConnection( @Nonnull IGridConnection n ); } diff --git a/src/api/java/appeng/api/networking/IGridHelper.java b/src/api/java/appeng/api/networking/IGridHelper.java index 40a766909..b79b6a76b 100644 --- a/src/api/java/appeng/api/networking/IGridHelper.java +++ b/src/api/java/appeng/api/networking/IGridHelper.java @@ -24,12 +24,14 @@ package appeng.api.networking; +import javax.annotation.Nonnull; + import appeng.api.exceptions.FailedConnectionException; /** * A helper responsible for creating new {@link IGridNode}, {@link IGridConnection} or potentially similar tasks. - * + * * @author yueh * @version rv5 * @since rv5 @@ -39,7 +41,7 @@ public interface IGridHelper /** * Create a grid node for your {@link IGridHost} - * + * * The passed {@link IGridBlock} represents the definition for properties like connectable sides. * Refer to its documentation for further details. * @@ -47,18 +49,20 @@ public interface IGridHelper * * @return grid node of block */ - IGridNode createGridNode( IGridBlock block ); + @Nonnull + IGridNode createGridNode( @Nonnull IGridBlock block ); /** * Create a direct connection between two {@link IGridNode}. - * + * * This will be considered as having a distance of 1, regardless of the location of both nodes. - * + * * @param a to be connected gridnode * @param b to be connected gridnode * * @throws appeng.api.exceptions.FailedConnectionException */ - IGridConnection createGridConnection( IGridNode a, IGridNode b ) throws FailedConnectionException; + @Nonnull + IGridConnection createGridConnection( @Nonnull IGridNode a, @Nonnull IGridNode b ) throws FailedConnectionException; } \ No newline at end of file diff --git a/src/api/java/appeng/api/networking/IGridHost.java b/src/api/java/appeng/api/networking/IGridHost.java index bd272c895..3738d778b 100644 --- a/src/api/java/appeng/api/networking/IGridHost.java +++ b/src/api/java/appeng/api/networking/IGridHost.java @@ -24,6 +24,9 @@ package appeng.api.networking; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + import net.minecraft.tileentity.TileEntity; import appeng.api.parts.IPart; @@ -49,7 +52,8 @@ public interface IGridHost * @return a new IGridNode, create these with * AEApi.INSTANCE().createGridNode( MyIGridBlock ) */ - IGridNode getGridNode( AEPartLocation dir ); + @Nullable + IGridNode getGridNode( @Nonnull AEPartLocation dir ); /** * Determines how cables render when they connect to this block. Priority is @@ -57,7 +61,8 @@ public interface IGridHost * * @param dir direction */ - AECableType getCableConnectionType( AEPartLocation dir ); + @Nonnull + AECableType getCableConnectionType( @Nonnull AEPartLocation dir ); /** * break this host, its violating security rules, just break your block, or part. diff --git a/src/api/java/appeng/api/networking/IGridMultiblock.java b/src/api/java/appeng/api/networking/IGridMultiblock.java index 7c3844bb7..f99b1b174 100644 --- a/src/api/java/appeng/api/networking/IGridMultiblock.java +++ b/src/api/java/appeng/api/networking/IGridMultiblock.java @@ -26,6 +26,8 @@ package appeng.api.networking; import java.util.Iterator; +import javax.annotation.Nonnull; + /** * An extension of IGridBlock, only means something when your getFlags() contains REQUIRE_CHANNEL, when done properly it @@ -40,5 +42,6 @@ public interface IGridMultiblock extends IGridBlock * * @return an iterator that will iterate all the nodes for the multiblock. ( read-only iterator expected. ) */ + @Nonnull Iterator getMultiblockNodes(); } diff --git a/src/api/java/appeng/api/networking/IGridNode.java b/src/api/java/appeng/api/networking/IGridNode.java index 667db3876..729c420f3 100644 --- a/src/api/java/appeng/api/networking/IGridNode.java +++ b/src/api/java/appeng/api/networking/IGridNode.java @@ -26,6 +26,8 @@ package appeng.api.networking; import java.util.EnumSet; +import javax.annotation.Nonnull; + import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; @@ -50,7 +52,7 @@ public interface IGridNode * * @param visitor visitor */ - void beginVisit( IGridVisitor visitor ); + void beginVisit( @Nonnull IGridVisitor visitor ); /** * inform the node that your IGridBlock has changed its internal state, and force the node to update. @@ -68,6 +70,7 @@ public interface IGridNode * * @return grid host */ + @Nonnull IGridHost getMachine(); /** @@ -75,6 +78,7 @@ public interface IGridNode * * @return grid */ + @Nonnull IGrid getGrid(); /** @@ -86,11 +90,13 @@ public interface IGridNode /** * @return the world the node is located in */ + @Nonnull World getWorld(); /** * @return a set of the connected sides, INTERNAL represents an invisible connection */ + @Nonnull EnumSet getConnectedSides(); /** @@ -98,11 +104,13 @@ public interface IGridNode * * @return grid connections */ + @Nonnull IReadOnlyCollection getConnections(); /** * @return the IGridBlock for this node */ + @Nonnull IGridBlock getGridBlock(); /** @@ -122,7 +130,7 @@ public interface IGridNode * @param name nbt name * @param nodeData to be loaded data */ - void loadFromNBT( String name, NBTTagCompound nodeData ); + void loadFromNBT( @Nonnull String name, @Nonnull NBTTagCompound nodeData ); /** * this should be called for each node you maintain, you can save all your nodes to the same tag with different @@ -131,7 +139,7 @@ public interface IGridNode * @param name nbt name * @param nodeData to be saved data */ - void saveToNBT( String name, NBTTagCompound nodeData ); + void saveToNBT( @Nonnull String name, @Nonnull NBTTagCompound nodeData ); /** * @return if the node's channel requirements are currently met, use this for display purposes, use isActive for @@ -146,7 +154,7 @@ public interface IGridNode * * @return true if has flag */ - boolean hasFlag( GridFlags flag ); + boolean hasFlag( @Nonnull GridFlags flag ); /** * @return the ownerID this represents the person who placed the node. diff --git a/src/api/java/appeng/api/networking/IGridStorage.java b/src/api/java/appeng/api/networking/IGridStorage.java index 0f9e9b7b5..f380ffe43 100644 --- a/src/api/java/appeng/api/networking/IGridStorage.java +++ b/src/api/java/appeng/api/networking/IGridStorage.java @@ -24,6 +24,8 @@ package appeng.api.networking; +import javax.annotation.Nonnull; + import net.minecraft.nbt.NBTTagCompound; @@ -33,6 +35,7 @@ public interface IGridStorage /** * @return an NBTTagCompound that can be read, and written too. */ + @Nonnull NBTTagCompound dataObject(); /** diff --git a/src/api/java/appeng/api/networking/IGridVisitor.java b/src/api/java/appeng/api/networking/IGridVisitor.java index 41ac4f475..d9386fdea 100644 --- a/src/api/java/appeng/api/networking/IGridVisitor.java +++ b/src/api/java/appeng/api/networking/IGridVisitor.java @@ -24,6 +24,9 @@ package appeng.api.networking; +import javax.annotation.Nonnull; + + /** * Simple Visitor pattern access to network nodes. */ @@ -39,5 +42,5 @@ public interface IGridVisitor * * @return true to continue visiting nodes beyond this node. */ - boolean visitNode( IGridNode n ); + boolean visitNode( @Nonnull IGridNode n ); } diff --git a/src/api/java/appeng/api/networking/IMachineSet.java b/src/api/java/appeng/api/networking/IMachineSet.java index 7d57b52cf..5d19ee18a 100644 --- a/src/api/java/appeng/api/networking/IMachineSet.java +++ b/src/api/java/appeng/api/networking/IMachineSet.java @@ -24,6 +24,8 @@ package appeng.api.networking; +import javax.annotation.Nonnull; + import appeng.api.util.IReadOnlyCollection; @@ -33,5 +35,6 @@ public interface IMachineSet extends IReadOnlyCollection /** * @return the machine class for this set. */ + @Nonnull Class getMachineClass(); } diff --git a/src/api/java/appeng/api/networking/crafting/ICraftingCallback.java b/src/api/java/appeng/api/networking/crafting/ICraftingCallback.java index 096b72260..f86780b55 100644 --- a/src/api/java/appeng/api/networking/crafting/ICraftingCallback.java +++ b/src/api/java/appeng/api/networking/crafting/ICraftingCallback.java @@ -24,6 +24,9 @@ package appeng.api.networking.crafting; +import javax.annotation.Nonnull; + + public interface ICraftingCallback { @@ -32,5 +35,5 @@ public interface ICraftingCallback * * @param job - final job */ - void calculationComplete( ICraftingJob job ); + void calculationComplete( @Nonnull ICraftingJob job ); } diff --git a/src/api/java/appeng/api/networking/energy/IAEPowerStorage.java b/src/api/java/appeng/api/networking/energy/IAEPowerStorage.java index 7cb1ac10f..30220d9b8 100644 --- a/src/api/java/appeng/api/networking/energy/IAEPowerStorage.java +++ b/src/api/java/appeng/api/networking/energy/IAEPowerStorage.java @@ -24,6 +24,8 @@ package appeng.api.networking.energy; +import javax.annotation.Nonnull; + import appeng.api.config.AccessRestriction; import appeng.api.config.Actionable; @@ -42,7 +44,7 @@ public interface IAEPowerStorage extends IEnergySource * * @return amount of power which was unable to be stored */ - double injectAEPower( double amt, Actionable mode ); + double injectAEPower( double amt, @Nonnull Actionable mode ); /** * @return the current maximum power ( this can change :P ) @@ -67,5 +69,6 @@ public interface IAEPowerStorage extends IEnergySource * * @return access restriction what the network can do */ + @Nonnull AccessRestriction getPowerFlow(); } \ No newline at end of file diff --git a/src/api/java/appeng/api/networking/energy/IEnergyGrid.java b/src/api/java/appeng/api/networking/energy/IEnergyGrid.java index 666b35321..fa4efa71b 100644 --- a/src/api/java/appeng/api/networking/energy/IEnergyGrid.java +++ b/src/api/java/appeng/api/networking/energy/IEnergyGrid.java @@ -24,6 +24,9 @@ package appeng.api.networking.energy; +import javax.annotation.Nonnegative; +import javax.annotation.Nonnull; + import appeng.api.config.Actionable; import appeng.api.networking.IGridCache; import appeng.api.networking.events.MENetworkPowerStatusChange; @@ -38,17 +41,20 @@ public interface IEnergyGrid extends IGridCache, IEnergySource, IEnergyGridProvi /** * @return the current calculated idle energy drain each tick, is used internally to drain power for each tick. */ + @Nonnegative double getIdlePowerUsage(); /** * @return the average power drain over the past 10 ticks, includes idle usage during this time, and all use of * extractPower. */ + @Nonnegative double getAvgPowerUsage(); /** * @return the average energy injected into the system per tick, for the last 10 ticks. */ + @Nonnegative double getAvgPowerInjection(); /** @@ -79,13 +85,15 @@ public interface IEnergyGrid extends IGridCache, IEnergySource, IEnergyGridProvi * * @return the amount of power that the network has OVER the limit. */ - double injectPower( double amt, Actionable mode ); + @Nonnegative + double injectPower( @Nonnegative double amt, @Nonnull Actionable mode ); /** * this is should be considered an estimate, and not relied upon for real calculations. * * @return estimated available power. */ + @Nonnegative double getStoredPower(); /** @@ -93,6 +101,7 @@ public interface IEnergyGrid extends IGridCache, IEnergySource, IEnergyGridProvi * * @return estimated available power. */ + @Nonnegative double getMaxStoredPower(); /** @@ -101,5 +110,6 @@ public interface IEnergyGrid extends IGridCache, IEnergySource, IEnergyGridProvi * * @return Amount of power required to charge the grid, in AE. */ - double getEnergyDemand( double maxRequired ); + @Nonnegative + double getEnergyDemand( @Nonnegative double maxRequired ); } diff --git a/src/api/java/appeng/api/networking/energy/IEnergySource.java b/src/api/java/appeng/api/networking/energy/IEnergySource.java index b1185dfa2..45bdbc807 100644 --- a/src/api/java/appeng/api/networking/energy/IEnergySource.java +++ b/src/api/java/appeng/api/networking/energy/IEnergySource.java @@ -24,6 +24,9 @@ package appeng.api.networking.energy; +import javax.annotation.Nonnegative; +import javax.annotation.Nonnull; + import appeng.api.config.Actionable; import appeng.api.config.PowerMultiplier; @@ -39,5 +42,6 @@ public interface IEnergySource * * @return returns extracted power. */ - double extractAEPower( double amt, Actionable mode, PowerMultiplier usePowerMultiplier ); + @Nonnegative + double extractAEPower( @Nonnegative double amt, @Nonnull Actionable mode, @Nonnull PowerMultiplier usePowerMultiplier ); } diff --git a/src/api/java/appeng/api/networking/energy/IEnergyWatcher.java b/src/api/java/appeng/api/networking/energy/IEnergyWatcher.java index a75871470..809a92e8c 100644 --- a/src/api/java/appeng/api/networking/energy/IEnergyWatcher.java +++ b/src/api/java/appeng/api/networking/energy/IEnergyWatcher.java @@ -24,6 +24,9 @@ package appeng.api.networking.energy; +import javax.annotation.Nonnegative; + + /** * DO NOT IMPLEMENT. * @@ -39,7 +42,7 @@ public interface IEnergyWatcher * @param amount * @return true, if successfully added. */ - boolean add( double amount ); + boolean add( @Nonnegative double amount ); /** * Remove a specific threshold from the watcher. @@ -47,7 +50,7 @@ public interface IEnergyWatcher * @param amount * @return true, if successfully removed. */ - boolean remove( double amount ); + boolean remove( @Nonnegative double amount ); /** * Removes all thresholds and resets the watcher to a clean state. diff --git a/src/api/java/appeng/api/networking/energy/IEnergyWatcherHost.java b/src/api/java/appeng/api/networking/energy/IEnergyWatcherHost.java index 5f5237f0d..e9b7c81c2 100644 --- a/src/api/java/appeng/api/networking/energy/IEnergyWatcherHost.java +++ b/src/api/java/appeng/api/networking/energy/IEnergyWatcherHost.java @@ -24,6 +24,9 @@ package appeng.api.networking.energy; +import javax.annotation.Nonnull; + + public interface IEnergyWatcherHost { @@ -33,12 +36,12 @@ public interface IEnergyWatcherHost * * @param newWatcher new watcher */ - void updateWatcher( IEnergyWatcher newWatcher ); + void updateWatcher( @Nonnull IEnergyWatcher newWatcher ); /** * Called when a threshold is crossed. * * @param energyGrid grid */ - void onThresholdPass( IEnergyGrid energyGrid ); + void onThresholdPass( @Nonnull IEnergyGrid energyGrid ); } diff --git a/src/api/java/appeng/api/networking/pathing/IPathingGrid.java b/src/api/java/appeng/api/networking/pathing/IPathingGrid.java index f9a592eee..8dc84df58 100644 --- a/src/api/java/appeng/api/networking/pathing/IPathingGrid.java +++ b/src/api/java/appeng/api/networking/pathing/IPathingGrid.java @@ -24,6 +24,8 @@ package appeng.api.networking.pathing; +import javax.annotation.Nonnull; + import appeng.api.networking.IGridCache; @@ -39,6 +41,7 @@ public interface IPathingGrid extends IGridCache * @return the controller state of the network, useful if you want to * require a controller for a feature. */ + @Nonnull ControllerState getControllerState(); /** diff --git a/src/api/java/appeng/api/networking/security/IActionHost.java b/src/api/java/appeng/api/networking/security/IActionHost.java index 02cd2c413..908e17445 100644 --- a/src/api/java/appeng/api/networking/security/IActionHost.java +++ b/src/api/java/appeng/api/networking/security/IActionHost.java @@ -24,6 +24,8 @@ package appeng.api.networking.security; +import javax.annotation.Nonnull; + import appeng.api.networking.IGridNode; @@ -38,5 +40,6 @@ public interface IActionHost * @return the the gridnode that actions from this IGridHost are preformed * by. */ + @Nonnull IGridNode getActionableNode(); } diff --git a/src/api/java/appeng/api/networking/security/ISecurityGrid.java b/src/api/java/appeng/api/networking/security/ISecurityGrid.java index 9dd0ad09a..77b49366d 100644 --- a/src/api/java/appeng/api/networking/security/ISecurityGrid.java +++ b/src/api/java/appeng/api/networking/security/ISecurityGrid.java @@ -24,6 +24,9 @@ package appeng.api.networking.security; +import javax.annotation.Nonnegative; +import javax.annotation.Nonnull; + import net.minecraft.entity.player.EntityPlayer; import appeng.api.config.SecurityPermissions; @@ -46,7 +49,7 @@ public interface ISecurityGrid extends IGridCache * * @return true if the player has permissions. */ - boolean hasPermission( EntityPlayer player, SecurityPermissions perm ); + boolean hasPermission( @Nonnull EntityPlayer player, @Nonnull SecurityPermissions perm ); /** * Check if a player has permissions. @@ -56,7 +59,7 @@ public interface ISecurityGrid extends IGridCache * * @return true if the player has permissions. */ - boolean hasPermission( int playerID, SecurityPermissions perm ); + boolean hasPermission( @Nonnegative int playerID, @Nonnull SecurityPermissions perm ); /** * @return PlayerID of the admin, or owner, this is the person who placed the security block. diff --git a/src/api/java/appeng/api/networking/security/ISecurityProvider.java b/src/api/java/appeng/api/networking/security/ISecurityProvider.java index 049d2e640..6cd6a2d5f 100644 --- a/src/api/java/appeng/api/networking/security/ISecurityProvider.java +++ b/src/api/java/appeng/api/networking/security/ISecurityProvider.java @@ -25,7 +25,7 @@ package appeng.api.networking.security; import java.util.EnumSet; -import java.util.HashMap; +import java.util.Map; import appeng.api.config.SecurityPermissions; @@ -48,7 +48,7 @@ public interface ISecurityProvider * * @param playerPerms player permissions */ - void readPermissions( HashMap> playerPerms ); + void readPermissions( Map> playerPerms ); /** * @return is security on or off? diff --git a/src/api/java/appeng/api/networking/security/ISecurityRegistry.java b/src/api/java/appeng/api/networking/security/ISecurityRegistry.java index 77ed8df33..29c4f12ee 100644 --- a/src/api/java/appeng/api/networking/security/ISecurityRegistry.java +++ b/src/api/java/appeng/api/networking/security/ISecurityRegistry.java @@ -26,6 +26,8 @@ package appeng.api.networking.security; import java.util.EnumSet; +import javax.annotation.Nonnull; + import appeng.api.config.SecurityPermissions; @@ -41,5 +43,5 @@ public interface ISecurityRegistry * @param playerID player id * @param permissions permissions of player */ - void addPlayer( int playerID, EnumSet permissions ); + void addPlayer( int playerID, @Nonnull EnumSet permissions ); } diff --git a/src/api/java/appeng/api/networking/ticking/IGridTickable.java b/src/api/java/appeng/api/networking/ticking/IGridTickable.java index c5d103509..9fe4ac792 100644 --- a/src/api/java/appeng/api/networking/ticking/IGridTickable.java +++ b/src/api/java/appeng/api/networking/ticking/IGridTickable.java @@ -24,6 +24,8 @@ package appeng.api.networking.ticking; +import javax.annotation.Nonnull; + import appeng.api.networking.IGridNode; @@ -45,18 +47,18 @@ public interface IGridTickable */ /** - * You can return null, if you wish to tick using MC's ticking mechanism, or - * you can return a valid TickingRequest to tell AE a guide for which type - * of responsiveness your device wants. + * Return a valid TickingRequest to tell AE a guide for which type of + * responsiveness your device wants. * - * this will be called for your tile any time your tile changes grids, this + * This will be called for your tile any time your tile changes grids, this * can happen at any time, so if your using the sleep feature you may wish * to preserve your sleep, in the result of this method. or you can simply * reset it. * - * @return null or a valid new TickingRequest + * @return a valid new TickingRequest */ - TickingRequest getTickingRequest( IGridNode node ); + @Nonnull + TickingRequest getTickingRequest( @Nonnull IGridNode node ); /** * AE lets you adjust your tick rate based on the results of your tick, if @@ -67,11 +69,12 @@ public interface IGridTickable * * Note: this is never called if you return null from getTickingRequest. * - * @param TicksSinceLastCall the number of world ticks that were skipped since your last + * @param ticksSinceLastCall the number of world ticks that were skipped since your last * tick, you can use this to adjust speed of processing or adjust * your tick rate. * * @return tick rate adjustment. */ - TickRateModulation tickingRequest( IGridNode node, int TicksSinceLastCall ); + @Nonnull + TickRateModulation tickingRequest( @Nonnull IGridNode node, int ticksSinceLastCall ); } diff --git a/src/api/java/appeng/api/networking/ticking/ITickManager.java b/src/api/java/appeng/api/networking/ticking/ITickManager.java index 6c5d7de82..5294cdb4b 100644 --- a/src/api/java/appeng/api/networking/ticking/ITickManager.java +++ b/src/api/java/appeng/api/networking/ticking/ITickManager.java @@ -24,6 +24,8 @@ package appeng.api.networking.ticking; +import javax.annotation.Nonnull; + import appeng.api.networking.IGridCache; import appeng.api.networking.IGridNode; @@ -42,7 +44,7 @@ public interface ITickManager extends IGridCache * * @param node gridnode */ - boolean alertDevice( IGridNode node ); + boolean alertDevice( @Nonnull IGridNode node ); /** * disables ticking for your device. @@ -51,7 +53,7 @@ public interface ITickManager extends IGridCache * * @return if the call was successful. */ - boolean sleepDevice( IGridNode node ); + boolean sleepDevice( @Nonnull IGridNode node ); /** * enables ticking for your device, undoes a sleepDevice call. @@ -60,5 +62,5 @@ public interface ITickManager extends IGridCache * * @return if the call was successful. */ - boolean wakeDevice( IGridNode node ); + boolean wakeDevice( @Nonnull IGridNode node ); } diff --git a/src/main/java/appeng/helpers/PlayerSecurityWrapper.java b/src/main/java/appeng/helpers/PlayerSecurityWrapper.java index 27889752a..a79e4207d 100644 --- a/src/main/java/appeng/helpers/PlayerSecurityWrapper.java +++ b/src/main/java/appeng/helpers/PlayerSecurityWrapper.java @@ -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> target; - public PlayerSecurityWrapper( final HashMap> playerPerms ) + public PlayerSecurityWrapper( final Map> playerPerms ) { this.target = playerPerms; } diff --git a/src/main/java/appeng/me/cache/TickManagerCache.java b/src/main/java/appeng/me/cache/TickManagerCache.java index ab5760dcd..0f3e0a359 100644 --- a/src/main/java/appeng/me/cache/TickManagerCache.java +++ b/src/main/java/appeng/me/cache/TickManagerCache.java @@ -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 ); diff --git a/src/main/java/appeng/tile/misc/TileSecurityStation.java b/src/main/java/appeng/tile/misc/TileSecurityStation.java index b8de0c164..abc309e34 100644 --- a/src/main/java/appeng/tile/misc/TileSecurityStation.java +++ b/src/main/java/appeng/tile/misc/TileSecurityStation.java @@ -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> playerPerms ) + public void readPermissions( final Map> playerPerms ) { final IPlayerRegistry pr = AEApi.instance().registries().players();