Skip to content

Commit

Permalink
Move command registration to the right place
Browse files Browse the repository at this point in the history
- Related to: 699cade

(cherry picked from commit 18d6964)
  • Loading branch information
edoren committed Oct 26, 2024
1 parent c543a43 commit af2b170
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 11 additions & 0 deletions common/src/main/java/me/edoren/skin_changer/SkinChanger.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
package me.edoren.skin_changer;

import com.mojang.brigadier.CommandDispatcher;
import dev.architectury.event.events.client.ClientLifecycleEvent;
import dev.architectury.event.events.common.CommandRegistrationEvent;
import dev.architectury.event.events.common.LifecycleEvent;
import dev.architectury.platform.Platform;
import dev.architectury.utils.Env;
import me.edoren.skin_changer.client.ClientController;
import me.edoren.skin_changer.common.NetworkContext;
import me.edoren.skin_changer.server.ServerController;
import me.edoren.skin_changer.server.SkinsCommand;
import net.minecraft.client.Minecraft;
import net.minecraft.commands.CommandBuildContext;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.server.MinecraftServer;

public final class SkinChanger {
Expand All @@ -17,6 +23,7 @@ public SkinChanger() {
ClientLifecycleEvent.CLIENT_SETUP.register(this::onClientSetup);
}
LifecycleEvent.SERVER_STARTED.register(this::onServerStarted);
CommandRegistrationEvent.EVENT.register(this::onCommandRegistration);
}

void onSetup() {
Expand All @@ -30,4 +37,8 @@ void onClientSetup(Minecraft client) {
void onServerStarted(MinecraftServer server) {
ServerController.GetInstance().initialize(server);
}

void onCommandRegistration(CommandDispatcher<CommandSourceStack> commandSourceStackCommandDispatcher, CommandBuildContext commandBuildContext, Commands.CommandSelection commandSelection) {
SkinsCommand.register(commandSourceStackCommandDispatcher);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ public static ServerController GetInstance() {
}

public void initialize(MinecraftServer server) {
SkinsCommand.register(server.getFunctions().getDispatcher());

Path savesFolder = server.getWorldPath(LevelResource.ROOT);
File skinChangerFolder = Paths.get(savesFolder.toString(), Constants.MOD_ID).normalize().toFile();

Expand Down

0 comments on commit af2b170

Please sign in to comment.