Updated Cell Registry safety and docs (#3383)
The Cell registry now ensures that the first handler is our own as other addons might depend on it. Updated docs to match the new requirements. Made internal handler classes final.
This commit is contained in:
@@ -41,7 +41,7 @@ import appeng.me.storage.CellInventoryHandler;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class BasicCellHandler implements ICellHandler
|
||||
public final class BasicCellHandler implements ICellHandler
|
||||
{
|
||||
|
||||
@Override
|
||||
|
||||
@@ -22,6 +22,9 @@ package appeng.core.features.registries.cell;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.base.Verify;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.storage.ICellHandler;
|
||||
@@ -43,12 +46,15 @@ public class CellRegistry implements ICellRegistry
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCellHandler( final ICellHandler h )
|
||||
public void addCellHandler( final ICellHandler handler )
|
||||
{
|
||||
if( h != null )
|
||||
{
|
||||
this.handlers.add( h );
|
||||
}
|
||||
Preconditions.checkNotNull( handler, "Called before FMLInitializationEvent." );
|
||||
Preconditions.checkArgument( !this.handlers.contains( handler ), "Tried to register the same handler instance twice." );
|
||||
|
||||
this.handlers.add( handler );
|
||||
|
||||
// Verify that the first entry is always our own handler.
|
||||
Verify.verify( this.handlers.get( 0 ) instanceof BasicCellHandler );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -38,7 +38,7 @@ import appeng.me.storage.CreativeCellInventory;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class CreativeCellHandler implements ICellHandler
|
||||
public final class CreativeCellHandler implements ICellHandler
|
||||
{
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user