diff --git a/src/main/java/land/chipmunk/kaboomfabric/extras/commands/CommandClearChat.java b/src/main/java/land/chipmunk/kaboomfabric/extras/commands/CommandClearChat.java index eb1c5c8..fcdcfb1 100644 --- a/src/main/java/land/chipmunk/kaboomfabric/extras/commands/CommandClearChat.java +++ b/src/main/java/land/chipmunk/kaboomfabric/extras/commands/CommandClearChat.java @@ -15,11 +15,11 @@ public interface CommandClearChat { static void register (CommandDispatcher dispatcher) { final LiteralCommandNode node = dispatcher.register( literal("clearchat") - .requires(source -> source.hasPermissionLevel(2)) + .requires(CommandClearChat::requirement) .executes(CommandClearChat::clearChatCommand) ); - dispatcher.register(literal("cc").redirect(node)); + dispatcher.register(literal("cc").requires(CommandClearChat::requirement).executes(CommandClearChat::clearChatCommand).redirect(node)); } static int clearChatCommand (CommandContext context) { @@ -33,4 +33,8 @@ public interface CommandClearChat { return Command.SINGLE_SUCCESS; } + + static boolean requirement (ServerCommandSource source) { + return source.hasPermissionLevel(2); + } } diff --git a/src/main/java/land/chipmunk/kaboomfabric/extras/commands/CommandDestroyEntities.java b/src/main/java/land/chipmunk/kaboomfabric/extras/commands/CommandDestroyEntities.java index 69a1dfd..6f861a4 100644 --- a/src/main/java/land/chipmunk/kaboomfabric/extras/commands/CommandDestroyEntities.java +++ b/src/main/java/land/chipmunk/kaboomfabric/extras/commands/CommandDestroyEntities.java @@ -18,11 +18,11 @@ public interface CommandDestroyEntities { static void register (CommandDispatcher dispatcher) { final LiteralCommandNode node = dispatcher.register( literal("destroyentities") - .requires(source -> source.hasPermissionLevel(2)) + .requires(CommandDestroyEntities::requirement) // .executes(CommandDestroyEntities::destroyEntitiesCommand) ); - dispatcher.register(literal("de").redirect(node)); + dispatcher.register(literal("de").requires(CommandDestroyEntities::requirement).redirect(node)); } static int destroyEntitiesCommand (CommandContext context) { @@ -53,4 +53,8 @@ public interface CommandDestroyEntities { return Command.SINGLE_SUCCESS; } + + static boolean requirement (ServerCommandSource source) { + return source.hasPermissionLevel(2); + } } diff --git a/src/main/java/land/chipmunk/kaboomfabric/extras/commands/CommandJumpscare.java b/src/main/java/land/chipmunk/kaboomfabric/extras/commands/CommandJumpscare.java index 2cb892e..aedb09f 100644 --- a/src/main/java/land/chipmunk/kaboomfabric/extras/commands/CommandJumpscare.java +++ b/src/main/java/land/chipmunk/kaboomfabric/extras/commands/CommandJumpscare.java @@ -25,14 +25,14 @@ public interface CommandJumpscare { static void register (CommandDispatcher dispatcher) { final LiteralCommandNode node = dispatcher.register( literal("jumpscare") - .requires(source -> source.hasPermissionLevel(2)) + .requires(CommandJumpscare::requirement) .then( argument("targets", players()) .executes(CommandJumpscare::jumpscareCommand) ) ); - dispatcher.register(literal("scare").redirect(node)); + dispatcher.register(literal("scare").requires(CommandJumpscare::requirement).redirect(node)); } static int jumpscareCommand (CommandContext context) throws CommandSyntaxException { @@ -65,4 +65,8 @@ public interface CommandJumpscare { return Command.SINGLE_SUCCESS; } + + static boolean requirement (ServerCommandSource source) { + return source.hasPermissionLevel(2); + } } diff --git a/src/main/java/land/chipmunk/kaboomfabric/extras/commands/CommandPing.java b/src/main/java/land/chipmunk/kaboomfabric/extras/commands/CommandPing.java index ca81c51..800c8b0 100644 --- a/src/main/java/land/chipmunk/kaboomfabric/extras/commands/CommandPing.java +++ b/src/main/java/land/chipmunk/kaboomfabric/extras/commands/CommandPing.java @@ -18,7 +18,7 @@ public abstract class CommandPing { public static void register (CommandDispatcher dispatcher) { final LiteralCommandNode node = dispatcher.register( literal("ping") - .requires(source -> source.hasPermissionLevel(2)) + .requires(CommandPing::requirement) .executes(CommandPing::pingCommand) .then( argument("target", player()) @@ -26,8 +26,8 @@ public abstract class CommandPing { ) ); - dispatcher.register(literal("delay").redirect(node)); - dispatcher.register(literal("ms").redirect(node)); + dispatcher.register(literal("delay").requires(CommandPing::requirement).executes(CommandPing::pingCommand).redirect(node)); + dispatcher.register(literal("ms").requires(CommandPing::requirement).executes(CommandPing::pingCommand).redirect(node)); } public static int pingCommand (CommandContext context) throws CommandSyntaxException { @@ -89,4 +89,8 @@ public abstract class CommandPing { return highlighting; } + + static boolean requirement (ServerCommandSource source) { + return source.hasPermissionLevel(2); + } } diff --git a/src/main/java/land/chipmunk/kaboomfabric/extras/commands/CommandPumpkin.java b/src/main/java/land/chipmunk/kaboomfabric/extras/commands/CommandPumpkin.java index 04721eb..214c576 100644 --- a/src/main/java/land/chipmunk/kaboomfabric/extras/commands/CommandPumpkin.java +++ b/src/main/java/land/chipmunk/kaboomfabric/extras/commands/CommandPumpkin.java @@ -26,7 +26,7 @@ public interface CommandPumpkin { .requires(source -> source.hasPermissionLevel(2)) .then( argument("targets", players()) - // .executes(CommandPumpkin::pumpkinCommand) + .executes(CommandPumpkin::pumpkinCommand) ) ); } @@ -34,11 +34,11 @@ public interface CommandPumpkin { static int pumpkinCommand (CommandContext context) throws CommandSyntaxException { final ServerCommandSource source = context.getSource(); final Collection players = getPlayers(context, "targets"); - final Item pumpkin = Registries.ITEM.get(new Identifier("minecraft", "pumpkin")); + final Item carvedPumpkin = Registries.ITEM.get(new Identifier("minecraft", "carved_pumpkin")); for (ServerPlayerEntity player : players) { final PlayerInventory inventory = player.getInventory(); - inventory.setStack(PlayerInventory.ARMOR_SLOTS[3], new ItemStack(pumpkin)); + inventory.setStack(39, new ItemStack(carvedPumpkin)); } if (players.size() == 1) { diff --git a/src/main/java/land/chipmunk/kaboomfabric/extras/commands/CommandServerInfo.java b/src/main/java/land/chipmunk/kaboomfabric/extras/commands/CommandServerInfo.java index 9121d3c..94e315e 100644 --- a/src/main/java/land/chipmunk/kaboomfabric/extras/commands/CommandServerInfo.java +++ b/src/main/java/land/chipmunk/kaboomfabric/extras/commands/CommandServerInfo.java @@ -3,6 +3,7 @@ package land.chipmunk.kaboomfabric.extras.commands; import com.mojang.brigadier.Command; import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.context.CommandContext; +import com.mojang.brigadier.tree.LiteralCommandNode; import static net.minecraft.server.command.CommandManager.literal; import net.minecraft.server.command.ServerCommandSource; import net.minecraft.text.Text; @@ -15,11 +16,13 @@ import java.net.InetAddress; public abstract class CommandServerInfo { public static void register (CommandDispatcher dispatcher) { - dispatcher.register( + final LiteralCommandNode node = dispatcher.register( literal("serverinfo") - .requires(source -> source.hasPermissionLevel(2)) + .requires(CommandServerInfo::requirement) .executes(CommandServerInfo::serverInfoCommand) ); + + dispatcher.register(literal("specs").requires(CommandServerInfo::requirement).executes(CommandServerInfo::serverInfoCommand).redirect(node)); } private static void sendInfoMessage (ServerCommandSource source, String description, String value) { @@ -93,4 +96,8 @@ public abstract class CommandServerInfo { return Command.SINGLE_SUCCESS; } + + static boolean requirement (ServerCommandSource source) { + return source.hasPermissionLevel(2); + } }