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:
yueh
2018-05-27 21:15:35 +02:00
committed by GitHub
parent 3e09c49e03
commit bf4818cf97
4 changed files with 23 additions and 8 deletions
@@ -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