use CommandRegistrationCallback

This commit is contained in:
Pierre Kisters 2020-08-24 02:08:46 +02:00
parent 86f5179ce1
commit 23306329af
2 changed files with 6 additions and 8 deletions

View File

@ -4,6 +4,7 @@ import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import it.unimi.dsi.fastutil.longs.Long2ObjectLinkedOpenHashMap;
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerChunkEvents;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
@ -103,6 +104,7 @@ public class DynmapPlugin {
plugin = this;
// Fabric events persist between server instances
ServerLifecycleEvents.SERVER_STARTING.register(this::serverStart);
CommandRegistrationCallback.EVENT.register((dispatcher, dedicated) -> registerCommands(dispatcher));
CustomServerLifecycleEvents.SERVER_STARTED_PRE_WORLD_LOAD.register(this::serverStarted);
ServerLifecycleEvents.SERVER_STOPPING.register(this::serverStop);
}
@ -297,7 +299,6 @@ public class DynmapPlugin {
this.server = server;
this.fserver = new FabricServer(this, server);
this.onEnable();
plugin.onStarting(server.getCommandManager().getDispatcher());
}
private void serverStarted(MinecraftServer server) {
@ -481,9 +482,7 @@ public class DynmapPlugin {
private DmarkerCommand dmarkerCmd;
private DynmapExpCommand dynmapexpCmd;
public void onStarting(CommandDispatcher<ServerCommandSource> cd) {
/* Register command hander */
// TODO: Use CommandRegistrationCallback
public void registerCommands(CommandDispatcher<ServerCommandSource> cd) {
dynmapCmd = new DynmapCommand(this);
dmapCmd = new DmapCommand(this);
dmarkerCmd = new DmarkerCommand(this);

View File

@ -4,6 +4,7 @@ import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import it.unimi.dsi.fastutil.longs.Long2ObjectLinkedOpenHashMap;
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerChunkEvents;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
@ -103,6 +104,7 @@ public class DynmapPlugin {
plugin = this;
// Fabric events persist between server instances
ServerLifecycleEvents.SERVER_STARTING.register(this::serverStart);
CommandRegistrationCallback.EVENT.register((dispatcher, dedicated) -> registerCommands(dispatcher));
CustomServerLifecycleEvents.SERVER_STARTED_PRE_WORLD_LOAD.register(this::serverStarted);
ServerLifecycleEvents.SERVER_STOPPING.register(this::serverStop);
}
@ -283,7 +285,6 @@ public class DynmapPlugin {
this.server = server;
this.fserver = new FabricServer(this, server);
this.onEnable();
plugin.onStarting(server.getCommandManager().getDispatcher());
}
private void serverStarted(MinecraftServer server) {
@ -469,9 +470,7 @@ public class DynmapPlugin {
private DmarkerCommand dmarkerCmd;
private DynmapExpCommand dynmapexpCmd;
public void onStarting(CommandDispatcher<ServerCommandSource> cd) {
/* Register command hander */
// TODO: Use CommandRegistrationCallback
public void registerCommands(CommandDispatcher<ServerCommandSource> cd) {
dynmapCmd = new DynmapCommand(this);
dmapCmd = new DmapCommand(this);
dmarkerCmd = new DmarkerCommand(this);