diff --git a/src/main/java/net/minestom/server/instance/BlockModifier.java b/src/main/java/net/minestom/server/instance/BlockModifier.java index d11fb1eff..f1bae62d6 100644 --- a/src/main/java/net/minestom/server/instance/BlockModifier.java +++ b/src/main/java/net/minestom/server/instance/BlockModifier.java @@ -23,10 +23,13 @@ public interface BlockModifier { } default void setBlock(BlockPosition blockPosition, Block block) { + Check.notNull(blockPosition, "The block position cannot be null"); + Check.notNull(block, "The block cannot be null"); setBlock(blockPosition.getX(), blockPosition.getY(), blockPosition.getZ(), block); } default void setBlockStateId(BlockPosition blockPosition, short blockStateId) { + Check.notNull(blockPosition, "The block position cannot be null"); setBlockStateId(blockPosition.getX(), blockPosition.getY(), blockPosition.getZ(), blockStateId); } @@ -49,6 +52,7 @@ public interface BlockModifier { } default void setCustomBlock(BlockPosition blockPosition, String customBlockId) { + Check.notNull(blockPosition, "The block position cannot be null"); setCustomBlock(blockPosition.getX(), blockPosition.getY(), blockPosition.getZ(), customBlockId); } @@ -58,4 +62,9 @@ public interface BlockModifier { setSeparateBlocks(x, y, z, blockStateId, customBlockId, null); } + default void setSeparateBlocks(BlockPosition blockPosition, short blockStateId, short customBlockId) { + Check.notNull(blockPosition, "The block position cannot be null"); + setSeparateBlocks(blockPosition.getX(), blockPosition.getY(), blockPosition.getZ(), blockStateId, customBlockId, null); + } + } diff --git a/src/main/java/net/minestom/server/timer/SchedulerManager.java b/src/main/java/net/minestom/server/timer/SchedulerManager.java index c8bdad954..375baadc0 100644 --- a/src/main/java/net/minestom/server/timer/SchedulerManager.java +++ b/src/main/java/net/minestom/server/timer/SchedulerManager.java @@ -12,6 +12,7 @@ import java.util.concurrent.atomic.AtomicInteger; */ public class SchedulerManager { + private boolean instanced; // A counter for all normal tasks private final AtomicInteger counter; // A counter for all shutdown tasks @@ -29,6 +30,11 @@ public class SchedulerManager { * Default constructor */ public SchedulerManager() { + if (instanced) { + throw new IllegalStateException("You cannot instantiate a SchedulerManager," + + " use MinecraftServer.getSchedulerManager()"); + } + this.instanced = true; this.counter = new AtomicInteger(); this.shutdownCounter = new AtomicInteger();