mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-03 23:17:48 +01:00
Prevent the instantiation of multiple SchedulerManager
This commit is contained in:
parent
1f2451f0b2
commit
e84bcdb0a1
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user