mirror of
https://github.com/JonasunderscoreJones/BetterConsoleMC.git
synced 2025-10-24 14:19:19 +02:00
fixed only 1 command being registered
This commit is contained in:
parent
f4ef7ba992
commit
bdb60f3ebe
2 changed files with 17 additions and 5 deletions
|
|
@ -2,17 +2,17 @@ package me.jonasjones.betterconsolemc;
|
|||
|
||||
import me.jonasjones.betterconsolemc.cmdconfig.CmdConfigHandler;
|
||||
import me.jonasjones.betterconsolemc.cmdconfig.CmdConfigs;
|
||||
import me.jonasjones.betterconsolemc.command.GameCommandHandler;
|
||||
import me.jonasjones.betterconsolemc.modconfig.ModConfigs;
|
||||
import me.jonasjones.betterconsolemc.util.CommandPreRegistry;
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
import static me.jonasjones.betterconsolemc.command.GameCommandHandler.registerCommands;
|
||||
|
||||
public class BetterConsoleMC implements ModInitializer {
|
||||
// This logger is used to write text to the console and the log file.
|
||||
// It is considered best practice to use your mod id as the logger's name.
|
||||
|
|
|
|||
|
|
@ -3,8 +3,10 @@ package me.jonasjones.betterconsolemc.command;
|
|||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import me.jonasjones.betterconsolemc.BetterConsoleMC;
|
||||
import me.jonasjones.betterconsolemc.cmdconfig.CmdConfigHandler;
|
||||
import me.jonasjones.betterconsolemc.system.ShellCommand;
|
||||
import me.jonasjones.betterconsolemc.util.CommandPreRegistry;
|
||||
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
|
||||
import net.minecraft.command.CommandRegistryAccess;
|
||||
import net.minecraft.server.command.CommandManager;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
|
|
@ -13,11 +15,21 @@ import net.minecraft.text.Text;
|
|||
import static me.jonasjones.betterconsolemc.BetterConsoleMC.COMMANDPREREGISTRY;
|
||||
|
||||
public class GameCommandHandler {
|
||||
public static void register(CommandDispatcher<ServerCommandSource> serverCommandSourceCommandDispatcher, CommandRegistryAccess commandRegistryAccess, CommandManager.RegistrationEnvironment registrationEnvironment) {
|
||||
|
||||
serverCommandSourceCommandDispatcher.register((CommandManager.literal(COMMANDPREREGISTRY.getIngamecommand()).requires(source -> source.hasPermissionLevel(COMMANDPREREGISTRY.getPermissionLevel()))
|
||||
public static void registerCommands() {
|
||||
CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> {
|
||||
for (CommandPreRegistry commandPreRegistry : CmdConfigHandler.FULLREG) {
|
||||
COMMANDPREREGISTRY = commandPreRegistry;
|
||||
register(dispatcher, registryAccess, environment, COMMANDPREREGISTRY);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void register(CommandDispatcher<ServerCommandSource> serverCommandSourceCommandDispatcher, CommandRegistryAccess commandRegistryAccess, CommandManager.RegistrationEnvironment registrationEnvironment, CommandPreRegistry commandPreRegistry) {
|
||||
|
||||
serverCommandSourceCommandDispatcher.register((CommandManager.literal(commandPreRegistry.getIngamecommand()).requires(source -> source.hasPermissionLevel(commandPreRegistry.getPermissionLevel()))
|
||||
.executes((context -> {
|
||||
context.getSource().sendFeedback(() -> runCommand(COMMANDPREREGISTRY, context), COMMANDPREREGISTRY.doBroadcastToOp());
|
||||
context.getSource().sendFeedback(() -> runCommand(commandPreRegistry, context), commandPreRegistry.doBroadcastToOp());
|
||||
return 1;
|
||||
})))
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue