Add null checks
This commit is contained in:
@@ -203,12 +203,20 @@ public class API implements IRSAPI {
|
|||||||
@Override
|
@Override
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public IStorageDisk<ItemStack> createDefaultItemDisk(ServerWorld world, int capacity) {
|
public IStorageDisk<ItemStack> createDefaultItemDisk(ServerWorld world, int capacity) {
|
||||||
|
if (world == null) {
|
||||||
|
throw new IllegalArgumentException("World cannot be null");
|
||||||
|
}
|
||||||
|
|
||||||
return new ItemStorageDisk(world, capacity);
|
return new ItemStorageDisk(world, capacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public IStorageDisk<FluidStack> createDefaultFluidDisk(ServerWorld world, int capacity) {
|
public IStorageDisk<FluidStack> createDefaultFluidDisk(ServerWorld world, int capacity) {
|
||||||
|
if (world == null) {
|
||||||
|
throw new IllegalArgumentException("World cannot be null");
|
||||||
|
}
|
||||||
|
|
||||||
return new FluidStorageDisk(world, capacity);
|
return new FluidStorageDisk(world, capacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -16,6 +16,10 @@ public class FluidStorageDiskFactory implements IStorageDiskFactory<FluidStack>
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IStorageDisk<FluidStack> createFromNbt(ServerWorld world, CompoundNBT tag) {
|
public IStorageDisk<FluidStack> createFromNbt(ServerWorld world, CompoundNBT tag) {
|
||||||
|
if (world == null) {
|
||||||
|
throw new IllegalArgumentException("World cannot be null");
|
||||||
|
}
|
||||||
|
|
||||||
FluidStorageDisk disk = new FluidStorageDisk(world, tag.getInt(FluidStorageDisk.NBT_CAPACITY));
|
FluidStorageDisk disk = new FluidStorageDisk(world, tag.getInt(FluidStorageDisk.NBT_CAPACITY));
|
||||||
|
|
||||||
ListNBT list = tag.getList(FluidStorageDisk.NBT_FLUIDS, Constants.NBT.TAG_COMPOUND);
|
ListNBT list = tag.getList(FluidStorageDisk.NBT_FLUIDS, Constants.NBT.TAG_COMPOUND);
|
||||||
@@ -33,6 +37,10 @@ public class FluidStorageDiskFactory implements IStorageDiskFactory<FluidStack>
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IStorageDisk<FluidStack> create(ServerWorld world, int capacity) {
|
public IStorageDisk<FluidStack> create(ServerWorld world, int capacity) {
|
||||||
|
if (world == null) {
|
||||||
|
throw new IllegalArgumentException("World cannot be null");
|
||||||
|
}
|
||||||
|
|
||||||
return new FluidStorageDisk(world, capacity);
|
return new FluidStorageDisk(world, capacity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -17,6 +17,10 @@ public class ItemStorageDiskFactory implements IStorageDiskFactory<ItemStack> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IStorageDisk<ItemStack> createFromNbt(ServerWorld world, CompoundNBT tag) {
|
public IStorageDisk<ItemStack> createFromNbt(ServerWorld world, CompoundNBT tag) {
|
||||||
|
if (world == null) {
|
||||||
|
throw new IllegalArgumentException("World cannot be null");
|
||||||
|
}
|
||||||
|
|
||||||
ItemStorageDisk disk = new ItemStorageDisk(world, tag.getInt(ItemStorageDisk.NBT_CAPACITY));
|
ItemStorageDisk disk = new ItemStorageDisk(world, tag.getInt(ItemStorageDisk.NBT_CAPACITY));
|
||||||
|
|
||||||
ListNBT list = tag.getList(ItemStorageDisk.NBT_ITEMS, Constants.NBT.TAG_COMPOUND);
|
ListNBT list = tag.getList(ItemStorageDisk.NBT_ITEMS, Constants.NBT.TAG_COMPOUND);
|
||||||
@@ -34,6 +38,10 @@ public class ItemStorageDiskFactory implements IStorageDiskFactory<ItemStack> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IStorageDisk<ItemStack> create(ServerWorld world, int capacity) {
|
public IStorageDisk<ItemStack> create(ServerWorld world, int capacity) {
|
||||||
|
if (world == null) {
|
||||||
|
throw new IllegalArgumentException("World cannot be null");
|
||||||
|
}
|
||||||
|
|
||||||
return new ItemStorageDisk(world, capacity);
|
return new ItemStorageDisk(world, capacity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user