forked from kaboom-fabric/extras
fix aliases and pumpkin
This commit is contained in:
parent
50974d6ecc
commit
221fc39a01
6 changed files with 37 additions and 14 deletions
|
@ -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<ServerCommandSource> context) {
|
||||
|
@ -33,4 +33,8 @@ public interface CommandClearChat {
|
|||
|
||||
return Command.SINGLE_SUCCESS;
|
||||
}
|
||||
|
||||
static boolean requirement (ServerCommandSource source) {
|
||||
return source.hasPermissionLevel(2);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<ServerCommandSource> context) {
|
||||
|
@ -53,4 +53,8 @@ public interface CommandDestroyEntities {
|
|||
|
||||
return Command.SINGLE_SUCCESS;
|
||||
}
|
||||
|
||||
static boolean requirement (ServerCommandSource source) {
|
||||
return source.hasPermissionLevel(2);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<ServerCommandSource> context) throws CommandSyntaxException {
|
||||
|
@ -65,4 +65,8 @@ public interface CommandJumpscare {
|
|||
|
||||
return Command.SINGLE_SUCCESS;
|
||||
}
|
||||
|
||||
static boolean requirement (ServerCommandSource source) {
|
||||
return source.hasPermissionLevel(2);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<ServerCommandSource> context) throws CommandSyntaxException {
|
||||
|
@ -89,4 +89,8 @@ public abstract class CommandPing {
|
|||
|
||||
return highlighting;
|
||||
}
|
||||
|
||||
static boolean requirement (ServerCommandSource source) {
|
||||
return source.hasPermissionLevel(2);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<ServerCommandSource> context) throws CommandSyntaxException {
|
||||
final ServerCommandSource source = context.getSource();
|
||||
final Collection<ServerPlayerEntity> 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) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue