Skip to content

Commit

Permalink
fix #3
Browse files Browse the repository at this point in the history
  • Loading branch information
CodedSakura committed Dec 16, 2024
1 parent 8032879 commit 6338f3f
Showing 1 changed file with 7 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package dev.codedsakura.blossom.echest;

import com.mojang.brigadier.Command;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import dev.codedsakura.blossom.lib.BlossomLib;
import dev.codedsakura.blossom.lib.config.ConfigManager;
import dev.codedsakura.blossom.lib.permissions.Permissions;
import dev.codedsakura.blossom.lib.text.TextUtils;
import dev.codedsakura.blossom.lib.utils.CustomLogger;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
import net.minecraft.screen.GenericContainerScreenHandler;
import net.minecraft.screen.SimpleNamedScreenHandlerFactory;
import net.minecraft.server.command.ServerCommandSource;
Expand All @@ -28,16 +27,12 @@ public class BlossomEnderChest implements ModInitializer {

@Override
public void onInitialize() {
ServerLifecycleEvents.SERVER_STARTED.register(server -> {
CommandDispatcher<ServerCommandSource> dispatcher = server.getCommandManager().getDispatcher();
LOGGER.debug("registering commands: {}", String.join(", ", CONFIG.commands));
Arrays.stream(CONFIG.commands)
.forEach(cmdName -> dispatcher
.register(literal(cmdName)
.requires(Permissions.require("blossom.ender-chest", true)
.and(Permissions.require("blossom.ender-chest.disallowed", false).negate()))
.executes(this::run)));
});
LOGGER.debug("loaded commands: {}", String.join(", ", CONFIG.commands));
Arrays.stream(CONFIG.commands)
.forEach(cmdName -> BlossomLib.addCommand(literal(cmdName)
.requires(Permissions.require("blossom.ender-chest", true)
.and(Permissions.require("blossom.ender-chest.disallowed", false).negate()))
.executes(this::run)));
}

private int run(CommandContext<ServerCommandSource> ctx) throws CommandSyntaxException {
Expand Down

0 comments on commit 6338f3f

Please sign in to comment.