mirror of
https://github.com/FabricMC/fabric.git
synced 2024-11-26 17:46:25 -05:00
Fix command test
This commit is contained in:
parent
346247d7d1
commit
1405d94241
1 changed files with 0 additions and 13 deletions
|
@ -32,7 +32,6 @@ import net.minecraft.text.LiteralText;
|
|||
import net.fabricmc.api.ModInitializer;
|
||||
import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback;
|
||||
import net.fabricmc.fabric.api.event.server.ServerTickCallback;
|
||||
import net.fabricmc.fabric.api.event.server.ServerStopCallback;
|
||||
|
||||
public class CommandTest implements ModInitializer {
|
||||
private static final Logger LOGGER = LogManager.getLogger(CommandTest.class);
|
||||
|
@ -40,17 +39,10 @@ public class CommandTest implements ModInitializer {
|
|||
private static final SimpleCommandExceptionType WRONG_SIDE_SHOULD_BE_DEDICATED = new SimpleCommandExceptionType(new LiteralText("This command was registered incorrectly. Should only be present on an dedicated server but was ran on an integrated server!"));
|
||||
|
||||
private boolean hasTested = false;
|
||||
private boolean hasRegistered = false;
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
CommandRegistrationCallback.EVENT.register((dispatcher, dedicated) -> {
|
||||
if (this.hasRegistered) {
|
||||
throw new AssertionError("Commands should not be registered twice per server instance!");
|
||||
}
|
||||
|
||||
this.hasRegistered = true;
|
||||
|
||||
// A command that exists on both types of servers
|
||||
dispatcher.register(literal("fabric_common_test_command").executes(this::executeCommonCommand));
|
||||
|
||||
|
@ -109,11 +101,6 @@ public class CommandTest implements ModInitializer {
|
|||
this.hasTested = true;
|
||||
CommandTest.LOGGER.info("The command tests have passed! Please make sure you execute the three commands for extra safety.");
|
||||
});
|
||||
|
||||
ServerStopCallback.EVENT.register(server -> {
|
||||
// When the server shuts down, we reset the registered flag.
|
||||
this.hasRegistered = false;
|
||||
});
|
||||
}
|
||||
|
||||
private int executeCommonCommand(CommandContext<ServerCommandSource> context) {
|
||||
|
|
Loading…
Reference in a new issue