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) {
|
static void register (CommandDispatcher dispatcher) {
|
||||||
final LiteralCommandNode node = dispatcher.register(
|
final LiteralCommandNode node = dispatcher.register(
|
||||||
literal("clearchat")
|
literal("clearchat")
|
||||||
.requires(source -> source.hasPermissionLevel(2))
|
.requires(CommandClearChat::requirement)
|
||||||
.executes(CommandClearChat::clearChatCommand)
|
.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) {
|
static int clearChatCommand (CommandContext<ServerCommandSource> context) {
|
||||||
|
@ -33,4 +33,8 @@ public interface CommandClearChat {
|
||||||
|
|
||||||
return Command.SINGLE_SUCCESS;
|
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) {
|
static void register (CommandDispatcher dispatcher) {
|
||||||
final LiteralCommandNode node = dispatcher.register(
|
final LiteralCommandNode node = dispatcher.register(
|
||||||
literal("destroyentities")
|
literal("destroyentities")
|
||||||
.requires(source -> source.hasPermissionLevel(2))
|
.requires(CommandDestroyEntities::requirement)
|
||||||
// .executes(CommandDestroyEntities::destroyEntitiesCommand)
|
// .executes(CommandDestroyEntities::destroyEntitiesCommand)
|
||||||
);
|
);
|
||||||
|
|
||||||
dispatcher.register(literal("de").redirect(node));
|
dispatcher.register(literal("de").requires(CommandDestroyEntities::requirement).redirect(node));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int destroyEntitiesCommand (CommandContext<ServerCommandSource> context) {
|
static int destroyEntitiesCommand (CommandContext<ServerCommandSource> context) {
|
||||||
|
@ -53,4 +53,8 @@ public interface CommandDestroyEntities {
|
||||||
|
|
||||||
return Command.SINGLE_SUCCESS;
|
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) {
|
static void register (CommandDispatcher dispatcher) {
|
||||||
final LiteralCommandNode node = dispatcher.register(
|
final LiteralCommandNode node = dispatcher.register(
|
||||||
literal("jumpscare")
|
literal("jumpscare")
|
||||||
.requires(source -> source.hasPermissionLevel(2))
|
.requires(CommandJumpscare::requirement)
|
||||||
.then(
|
.then(
|
||||||
argument("targets", players())
|
argument("targets", players())
|
||||||
.executes(CommandJumpscare::jumpscareCommand)
|
.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 {
|
static int jumpscareCommand (CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
|
||||||
|
@ -65,4 +65,8 @@ public interface CommandJumpscare {
|
||||||
|
|
||||||
return Command.SINGLE_SUCCESS;
|
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) {
|
public static void register (CommandDispatcher dispatcher) {
|
||||||
final LiteralCommandNode node = dispatcher.register(
|
final LiteralCommandNode node = dispatcher.register(
|
||||||
literal("ping")
|
literal("ping")
|
||||||
.requires(source -> source.hasPermissionLevel(2))
|
.requires(CommandPing::requirement)
|
||||||
.executes(CommandPing::pingCommand)
|
.executes(CommandPing::pingCommand)
|
||||||
.then(
|
.then(
|
||||||
argument("target", player())
|
argument("target", player())
|
||||||
|
@ -26,8 +26,8 @@ public abstract class CommandPing {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
dispatcher.register(literal("delay").redirect(node));
|
dispatcher.register(literal("delay").requires(CommandPing::requirement).executes(CommandPing::pingCommand).redirect(node));
|
||||||
dispatcher.register(literal("ms").redirect(node));
|
dispatcher.register(literal("ms").requires(CommandPing::requirement).executes(CommandPing::pingCommand).redirect(node));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int pingCommand (CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
|
public static int pingCommand (CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
|
||||||
|
@ -89,4 +89,8 @@ public abstract class CommandPing {
|
||||||
|
|
||||||
return highlighting;
|
return highlighting;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static boolean requirement (ServerCommandSource source) {
|
||||||
|
return source.hasPermissionLevel(2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ public interface CommandPumpkin {
|
||||||
.requires(source -> source.hasPermissionLevel(2))
|
.requires(source -> source.hasPermissionLevel(2))
|
||||||
.then(
|
.then(
|
||||||
argument("targets", players())
|
argument("targets", players())
|
||||||
// .executes(CommandPumpkin::pumpkinCommand)
|
.executes(CommandPumpkin::pumpkinCommand)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -34,11 +34,11 @@ public interface CommandPumpkin {
|
||||||
static int pumpkinCommand (CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
|
static int pumpkinCommand (CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
|
||||||
final ServerCommandSource source = context.getSource();
|
final ServerCommandSource source = context.getSource();
|
||||||
final Collection<ServerPlayerEntity> players = getPlayers(context, "targets");
|
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) {
|
for (ServerPlayerEntity player : players) {
|
||||||
final PlayerInventory inventory = player.getInventory();
|
final PlayerInventory inventory = player.getInventory();
|
||||||
inventory.setStack(PlayerInventory.ARMOR_SLOTS[3], new ItemStack(pumpkin));
|
inventory.setStack(39, new ItemStack(carvedPumpkin));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (players.size() == 1) {
|
if (players.size() == 1) {
|
||||||
|
|
|
@ -3,6 +3,7 @@ package land.chipmunk.kaboomfabric.extras.commands;
|
||||||
import com.mojang.brigadier.Command;
|
import com.mojang.brigadier.Command;
|
||||||
import com.mojang.brigadier.CommandDispatcher;
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
import com.mojang.brigadier.context.CommandContext;
|
import com.mojang.brigadier.context.CommandContext;
|
||||||
|
import com.mojang.brigadier.tree.LiteralCommandNode;
|
||||||
import static net.minecraft.server.command.CommandManager.literal;
|
import static net.minecraft.server.command.CommandManager.literal;
|
||||||
import net.minecraft.server.command.ServerCommandSource;
|
import net.minecraft.server.command.ServerCommandSource;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
|
@ -15,11 +16,13 @@ import java.net.InetAddress;
|
||||||
|
|
||||||
public abstract class CommandServerInfo {
|
public abstract class CommandServerInfo {
|
||||||
public static void register (CommandDispatcher dispatcher) {
|
public static void register (CommandDispatcher dispatcher) {
|
||||||
dispatcher.register(
|
final LiteralCommandNode node = dispatcher.register(
|
||||||
literal("serverinfo")
|
literal("serverinfo")
|
||||||
.requires(source -> source.hasPermissionLevel(2))
|
.requires(CommandServerInfo::requirement)
|
||||||
.executes(CommandServerInfo::serverInfoCommand)
|
.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) {
|
private static void sendInfoMessage (ServerCommandSource source, String description, String value) {
|
||||||
|
@ -93,4 +96,8 @@ public abstract class CommandServerInfo {
|
||||||
|
|
||||||
return Command.SINGLE_SUCCESS;
|
return Command.SINGLE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static boolean requirement (ServerCommandSource source) {
|
||||||
|
return source.hasPermissionLevel(2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue