From c63bebdce14b85781a746b046c11c4e3a8b98d88 Mon Sep 17 00:00:00 2001 From: Sollace Date: Mon, 4 Sep 2023 23:40:41 +0100 Subject: [PATCH] Move the admin and debug commands to a /unicopia command --- .../unicopia/command/CastCommand.java | 10 ++-- .../unicopia/command/Commands.java | 22 ++------ .../unicopia/command/DisguiseCommand.java | 11 ++-- .../unicopia/command/EmoteCommand.java | 8 +-- .../unicopia/command/GravityCommand.java | 32 +++++------- .../unicopia/command/ManaCommand.java | 50 +++++++++---------- .../unicopia/command/RacelistCommand.java | 23 +++------ .../unicopia/command/SpeciesCommand.java | 25 ++++------ .../unicopia/command/TraitCommand.java | 42 +++++++--------- .../unicopia/command/UnicopiaCommand.java | 23 +++++++++ .../unicopia/command/WorldTribeCommand.java | 14 ++---- 11 files changed, 115 insertions(+), 145 deletions(-) create mode 100644 src/main/java/com/minelittlepony/unicopia/command/UnicopiaCommand.java diff --git a/src/main/java/com/minelittlepony/unicopia/command/CastCommand.java b/src/main/java/com/minelittlepony/unicopia/command/CastCommand.java index f114dca9..1983c550 100644 --- a/src/main/java/com/minelittlepony/unicopia/command/CastCommand.java +++ b/src/main/java/com/minelittlepony/unicopia/command/CastCommand.java @@ -8,9 +8,9 @@ import com.minelittlepony.unicopia.ability.magic.spell.PlaceableSpell; import com.minelittlepony.unicopia.ability.magic.spell.effect.CustomisedSpellType; import com.minelittlepony.unicopia.ability.magic.spell.effect.SpellType; import com.minelittlepony.unicopia.ability.magic.spell.trait.SpellTraits; -import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.arguments.FloatArgumentType; import com.mojang.brigadier.builder.ArgumentBuilder; +import com.mojang.brigadier.builder.LiteralArgumentBuilder; import com.mojang.brigadier.context.CommandContext; import com.mojang.brigadier.exceptions.CommandSyntaxException; @@ -26,9 +26,8 @@ import net.minecraft.util.math.Vec2f; import net.minecraft.util.math.Vec3d; public class CastCommand { - public static void register(CommandDispatcher dispatcher, CommandRegistryAccess registries) { - dispatcher.register( - CommandManager.literal("cast").requires(s -> s.hasPermissionLevel(2)) + public static LiteralArgumentBuilder create(CommandRegistryAccess registries) { + return CommandManager.literal("cast").requires(s -> s.hasPermissionLevel(2)) .then( buildBranches( CommandManager.argument("spell", RegistryKeyArgumentType.registryKey(SpellType.REGISTRY_KEY)), @@ -41,8 +40,7 @@ public class CastCommand { CommandManager.argument("traits", TraitsArgumentType.traits()), CastCommand::getTraits )) - ) - ); + ); } private static ArgumentBuilder buildBranches(ArgumentBuilder builder, diff --git a/src/main/java/com/minelittlepony/unicopia/command/Commands.java b/src/main/java/com/minelittlepony/unicopia/command/Commands.java index d41831f9..8fba093e 100644 --- a/src/main/java/com/minelittlepony/unicopia/command/Commands.java +++ b/src/main/java/com/minelittlepony/unicopia/command/Commands.java @@ -6,35 +6,21 @@ import com.minelittlepony.unicopia.Unicopia; import com.minelittlepony.unicopia.ability.magic.spell.trait.Trait; import com.minelittlepony.unicopia.client.render.PlayerPoser.Animation; import com.minelittlepony.unicopia.command.ManaCommand.ManaType; - import net.fabricmc.fabric.api.command.v2.ArgumentTypeRegistry; -import net.fabricmc.loader.api.FabricLoader; import net.minecraft.command.argument.serialize.ConstantArgumentSerializer; -import net.minecraft.server.MinecraftServer; public class Commands { - @SuppressWarnings("deprecation") public static void bootstrap() { ArgumentTypeRegistry.registerArgumentType(Unicopia.id("animation"), Animation.ArgumentType.class, ConstantArgumentSerializer.of(Animation::argument)); ArgumentTypeRegistry.registerArgumentType(Unicopia.id("animation_recipient"), Animation.Recipient.ArgumentType.class, ConstantArgumentSerializer.of(Animation.Recipient::argument)); ArgumentTypeRegistry.registerArgumentType(Unicopia.id("mana_type"), ManaType.ArgumentType.class, ConstantArgumentSerializer.of(ManaType::argument)); ArgumentTypeRegistry.registerArgumentType(Unicopia.id("trait_type"), Trait.ArgumentType.class, ConstantArgumentSerializer.of(Trait::argument)); ArgumentTypeRegistry.registerArgumentType(Unicopia.id("spell_traits"), TraitsArgumentType.class, ConstantArgumentSerializer.of(TraitsArgumentType::traits)); + CommandRegistrationCallback.EVENT.register((dispatcher, registries, environment) -> { - RacelistCommand.register(dispatcher); - EmoteCommand.register(dispatcher); - SpeciesCommand.register(dispatcher, environment); - WorldTribeCommand.register(dispatcher); - - GravityCommand.register(dispatcher); - DisguiseCommand.register(dispatcher, registries); - CastCommand.register(dispatcher, registries); - TraitCommand.register(dispatcher); - ManaCommand.register(dispatcher); - - if (FabricLoader.getInstance().getGameInstance() instanceof MinecraftServer server) { - server.setFlightEnabled(true); - } + dispatcher.register(EmoteCommand.create()); + dispatcher.register(SpeciesCommand.create(environment)); + dispatcher.register(UnicopiaCommand.create(registries, environment)); }); } } diff --git a/src/main/java/com/minelittlepony/unicopia/command/DisguiseCommand.java b/src/main/java/com/minelittlepony/unicopia/command/DisguiseCommand.java index 8dbca1b1..d6ee2434 100644 --- a/src/main/java/com/minelittlepony/unicopia/command/DisguiseCommand.java +++ b/src/main/java/com/minelittlepony/unicopia/command/DisguiseCommand.java @@ -9,9 +9,9 @@ import com.minelittlepony.unicopia.ability.magic.spell.CastingMethod; import com.minelittlepony.unicopia.ability.magic.spell.effect.SpellType; import com.minelittlepony.unicopia.entity.player.Pony; import com.mojang.authlib.GameProfile; -import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.arguments.StringArgumentType; import com.mojang.brigadier.builder.ArgumentBuilder; +import com.mojang.brigadier.builder.LiteralArgumentBuilder; import com.mojang.brigadier.context.CommandContext; import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.mojang.brigadier.exceptions.SimpleCommandExceptionType; @@ -34,10 +34,8 @@ import net.minecraft.world.GameRules; public class DisguiseCommand { private static final SimpleCommandExceptionType FAILED_EXCEPTION = new SimpleCommandExceptionType(Text.translatable("commands.disguise.notfound")); - public static void register(CommandDispatcher dispatcher, CommandRegistryAccess registries) { - dispatcher.register(CommandManager - .literal("disguise") - .requires(s -> s.hasPermissionLevel(2)) + public static LiteralArgumentBuilder create(CommandRegistryAccess registries) { + return CommandManager.literal("disguise").requires(s -> s.hasPermissionLevel(2)) .executes(context -> reveal(context.getSource(), context.getSource().getPlayer())) .then( CommandManager.argument("target", EntityArgumentType.players()) @@ -45,8 +43,7 @@ public class DisguiseCommand { .then(buildPlayerDisguise(context -> EntityArgumentType.getPlayer(context, "target"))) ) .then(buildEntityDisguise(context -> context.getSource().getPlayer(), registries)) - .then(buildPlayerDisguise(context -> context.getSource().getPlayer())) - ); + .then(buildPlayerDisguise(context -> context.getSource().getPlayer())); } private static ArgumentBuilder buildEntityDisguise(Arg targetOp, CommandRegistryAccess registries) { diff --git a/src/main/java/com/minelittlepony/unicopia/command/EmoteCommand.java b/src/main/java/com/minelittlepony/unicopia/command/EmoteCommand.java index ddba2882..8048fe91 100644 --- a/src/main/java/com/minelittlepony/unicopia/command/EmoteCommand.java +++ b/src/main/java/com/minelittlepony/unicopia/command/EmoteCommand.java @@ -2,16 +2,16 @@ package com.minelittlepony.unicopia.command; import com.minelittlepony.unicopia.client.render.PlayerPoser.Animation; import com.minelittlepony.unicopia.entity.player.Pony; -import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.arguments.IntegerArgumentType; +import com.mojang.brigadier.builder.LiteralArgumentBuilder; import com.mojang.brigadier.exceptions.CommandSyntaxException; import net.minecraft.server.command.CommandManager; import net.minecraft.server.command.ServerCommandSource; public class EmoteCommand { - static void register(CommandDispatcher dispatcher) { - dispatcher.register(CommandManager + static LiteralArgumentBuilder create() { + return CommandManager .literal("emote") .then(CommandManager.argument("animation", Animation.argument()).executes(source -> apply( source.getSource(), @@ -31,7 +31,7 @@ public class EmoteCommand { IntegerArgumentType.getInteger(source, "duration") ) )) - ))); + )); } static int apply(ServerCommandSource source, Animation animation, Animation.Recipient recipient) throws CommandSyntaxException { diff --git a/src/main/java/com/minelittlepony/unicopia/command/GravityCommand.java b/src/main/java/com/minelittlepony/unicopia/command/GravityCommand.java index b0cbeab3..c99aa75b 100644 --- a/src/main/java/com/minelittlepony/unicopia/command/GravityCommand.java +++ b/src/main/java/com/minelittlepony/unicopia/command/GravityCommand.java @@ -5,7 +5,6 @@ import java.util.stream.Stream; import com.google.common.collect.Streams; import com.minelittlepony.unicopia.entity.player.Pony; -import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.arguments.FloatArgumentType; import com.mojang.brigadier.builder.LiteralArgumentBuilder; import com.mojang.brigadier.exceptions.CommandSyntaxException; @@ -19,24 +18,19 @@ import net.minecraft.world.GameRules; class GravityCommand { - static void register(CommandDispatcher dispatcher) { - LiteralArgumentBuilder builder = CommandManager - .literal("gravity") - .requires(s -> s.hasPermissionLevel(2)); - - builder.then(CommandManager.literal("get") - .executes(context -> get(context.getSource(), context.getSource().getPlayer(), true)) - .then(CommandManager.argument("target", EntityArgumentType.player()) - .executes(context -> get(context.getSource(), EntityArgumentType.getPlayer(context, "target"), false)) - )); - builder.then(CommandManager.literal("set") - .then(CommandManager.argument("gravity", FloatArgumentType.floatArg(-99, 99)) - .executes(context -> set(context.getSource(), context.getSource().getPlayer(), FloatArgumentType.getFloat(context, "gravity"), true)) - .then(CommandManager.argument("target", EntityArgumentType.player()) - .executes(context -> set(context.getSource(), EntityArgumentType.getPlayer(context, "target"), FloatArgumentType.getFloat(context, "gravity"), false)) - ))); - - dispatcher.register(builder); + static LiteralArgumentBuilder create() { + return CommandManager.literal("gravity").requires(s -> s.hasPermissionLevel(2)) + .then(CommandManager.literal("get") + .executes(context -> get(context.getSource(), context.getSource().getPlayer(), true)) + .then(CommandManager.argument("target", EntityArgumentType.player()) + .executes(context -> get(context.getSource(), EntityArgumentType.getPlayer(context, "target"), false)) + )) + .then(CommandManager.literal("set") + .then(CommandManager.argument("gravity", FloatArgumentType.floatArg(-99, 99)) + .executes(context -> set(context.getSource(), context.getSource().getPlayer(), FloatArgumentType.getFloat(context, "gravity"), true)) + .then(CommandManager.argument("target", EntityArgumentType.player()) + .executes(context -> set(context.getSource(), EntityArgumentType.getPlayer(context, "target"), FloatArgumentType.getFloat(context, "gravity"), false)) + ))); } static int get(ServerCommandSource source, PlayerEntity player, boolean isSelf) throws CommandSyntaxException { diff --git a/src/main/java/com/minelittlepony/unicopia/command/ManaCommand.java b/src/main/java/com/minelittlepony/unicopia/command/ManaCommand.java index ccbf5ed6..e58208ac 100644 --- a/src/main/java/com/minelittlepony/unicopia/command/ManaCommand.java +++ b/src/main/java/com/minelittlepony/unicopia/command/ManaCommand.java @@ -4,8 +4,8 @@ import java.util.function.Function; import com.minelittlepony.unicopia.entity.player.MagicReserves; import com.minelittlepony.unicopia.entity.player.Pony; -import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.arguments.FloatArgumentType; +import com.mojang.brigadier.builder.LiteralArgumentBuilder; import net.minecraft.command.argument.EnumArgumentType; import net.minecraft.server.command.CommandManager; @@ -14,34 +14,30 @@ import net.minecraft.text.Text; import net.minecraft.util.StringIdentifiable; public class ManaCommand { - static void register(CommandDispatcher dispatcher) { - dispatcher.register(CommandManager - .literal("mana").requires(s -> s.hasPermissionLevel(2)) - .then(CommandManager.argument("type", ManaType.argument()).executes(source -> { - var type = source.getArgument("type", ManaType.class); - var pony = Pony.of(source.getSource().getPlayer()); - var bar = type.getBar(pony.getMagicalReserves()); + static LiteralArgumentBuilder create() { + return CommandManager.literal("mana").requires(s -> s.hasPermissionLevel(2)) + .then(CommandManager.argument("type", ManaType.argument()).executes(source -> { + var type = source.getArgument("type", ManaType.class); + var pony = Pony.of(source.getSource().getPlayer()); + var bar = type.getBar(pony.getMagicalReserves()); - source.getSource().getPlayer().sendMessage(Text.literal(type.name() + " is " + bar.get() + "/" + bar.getMax())); - return 0; - }) - .then(CommandManager.argument("value", FloatArgumentType.floatArg()).executes(source -> { - var type = source.getArgument("type", ManaType.class); - var pony = Pony.of(source.getSource().getPlayer()); - var bar = type.getBar(pony.getMagicalReserves()); + source.getSource().getPlayer().sendMessage(Text.literal(type.name() + " is " + bar.get() + "/" + bar.getMax())); + return 0; + }) + .then(CommandManager.argument("value", FloatArgumentType.floatArg()).executes(source -> { + var type = source.getArgument("type", ManaType.class); + var pony = Pony.of(source.getSource().getPlayer()); + var bar = type.getBar(pony.getMagicalReserves()); - float value = source.getArgument("value", Float.class); - while (type == ManaType.XP && value > 1) { - pony.getLevel().add(1); - value -= 1; - } - - bar.set(value); - source.getSource().getPlayer().sendMessage(Text.literal("Set " + type.name() + " to " + bar.get() + "/" + bar.getMax())); - return 0; - })) - ) - ); + float value = source.getArgument("value", Float.class); + while (type == ManaType.XP && value > 1) { + pony.getLevel().add(1); + value -= 1; + } + bar.set(value); + source.getSource().getPlayer().sendMessage(Text.literal("Set " + type.name() + " to " + bar.get() + "/" + bar.getMax())); + return 0; + }))); } enum ManaType implements CommandArgumentEnum { diff --git a/src/main/java/com/minelittlepony/unicopia/command/RacelistCommand.java b/src/main/java/com/minelittlepony/unicopia/command/RacelistCommand.java index 6e66b3f6..333da868 100644 --- a/src/main/java/com/minelittlepony/unicopia/command/RacelistCommand.java +++ b/src/main/java/com/minelittlepony/unicopia/command/RacelistCommand.java @@ -3,10 +3,8 @@ package com.minelittlepony.unicopia.command; import java.util.function.Function; import com.minelittlepony.unicopia.*; -import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.builder.LiteralArgumentBuilder; -import net.minecraft.command.argument.RegistryKeyArgumentType; import net.minecraft.server.command.CommandManager; import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.network.ServerPlayerEntity; @@ -15,13 +13,10 @@ import net.minecraft.util.Formatting; class RacelistCommand { - static void register(CommandDispatcher dispatcher) { - LiteralArgumentBuilder builder = CommandManager.literal("racelist").requires(s -> s.hasPermissionLevel(4)); - - RegistryKeyArgumentType raceArgument = Race.argument(); - - builder.then(CommandManager.literal("allow") - .then(CommandManager.argument("race", raceArgument) + static LiteralArgumentBuilder create() { + return CommandManager.literal("racelist").requires(s -> s.hasPermissionLevel(3)) + .then(CommandManager.literal("allow") + .then(CommandManager.argument("race", Race.argument()) .executes(context -> toggle(context.getSource(), context.getSource().getPlayer(), Race.fromArgument(context, "race"), "allowed", race -> { if (race.isUnset()) { @@ -34,9 +29,9 @@ class RacelistCommand { return result; })) - )); - builder.then(CommandManager.literal("disallow") - .then(CommandManager.argument("race", raceArgument) + )) + .then(CommandManager.literal("disallow") + .then(CommandManager.argument("race", Race.argument()) .executes(context -> toggle(context.getSource(), context.getSource().getPlayer(), Race.fromArgument(context, "race"), "disallowed", race -> { boolean result = Unicopia.getConfig().speciesWhiteList.get().remove(race.getId().toString()); @@ -44,9 +39,7 @@ class RacelistCommand { return result; })) - )); - - dispatcher.register(builder); + )); } static int toggle(ServerCommandSource source, ServerPlayerEntity player, Race race, String action, Function func) { diff --git a/src/main/java/com/minelittlepony/unicopia/command/SpeciesCommand.java b/src/main/java/com/minelittlepony/unicopia/command/SpeciesCommand.java index 2a18cb47..6f93995b 100644 --- a/src/main/java/com/minelittlepony/unicopia/command/SpeciesCommand.java +++ b/src/main/java/com/minelittlepony/unicopia/command/SpeciesCommand.java @@ -5,7 +5,6 @@ import com.minelittlepony.unicopia.Unicopia; import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.network.Channel; import com.minelittlepony.unicopia.network.MsgTribeSelect; -import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.builder.LiteralArgumentBuilder; import net.minecraft.command.argument.EntityArgumentType; @@ -22,8 +21,8 @@ import net.minecraft.util.Identifier; import net.minecraft.world.GameRules; class SpeciesCommand { - static void register(CommandDispatcher dispatcher, RegistrationEnvironment environment) { - LiteralArgumentBuilder builder = CommandManager.literal("race"); + static LiteralArgumentBuilder create(RegistrationEnvironment environment) { + LiteralArgumentBuilder builder = CommandManager.literal("tribe"); if (environment.dedicated) { if (Unicopia.getConfig().enableCheats.get()) { @@ -35,29 +34,25 @@ class SpeciesCommand { RegistryKeyArgumentType raceArgument = Race.argument(); - builder.then(CommandManager.literal("get") + return builder + .then(CommandManager.literal("get") .executes(context -> get(context.getSource(), context.getSource().getPlayer(), true)) .then(CommandManager.argument("target", EntityArgumentType.player()) .executes(context -> get(context.getSource(), EntityArgumentType.getPlayer(context, "target"), false)) - )); - - builder.then(CommandManager.literal("set") + )) + .then(CommandManager.literal("set") .then(CommandManager.argument("race", raceArgument) .executes(context -> set(context.getSource(), context.getSource().getPlayer(), Race.fromArgument(context, "race"), true)) .then(CommandManager.argument("target", EntityArgumentType.player()) .executes(context -> set(context.getSource(), EntityArgumentType.getPlayer(context, "target"), Race.fromArgument(context, "race"), false))) - )); - - builder.then(CommandManager.literal("describe") + )) + .then(CommandManager.literal("describe") .then(CommandManager.argument("race", raceArgument) .executes(context -> describe(context.getSource().getPlayer(), Race.fromArgument(context, "race"))) - )); - - builder.then(CommandManager.literal("list") + )) + .then(CommandManager.literal("list") .executes(context -> list(context.getSource().getPlayer()) )); - - dispatcher.register(builder); } static int set(ServerCommandSource source, PlayerEntity player, Race race, boolean isSelf) { diff --git a/src/main/java/com/minelittlepony/unicopia/command/TraitCommand.java b/src/main/java/com/minelittlepony/unicopia/command/TraitCommand.java index 8f8af6d4..04bcf078 100644 --- a/src/main/java/com/minelittlepony/unicopia/command/TraitCommand.java +++ b/src/main/java/com/minelittlepony/unicopia/command/TraitCommand.java @@ -3,7 +3,6 @@ package com.minelittlepony.unicopia.command; import com.minelittlepony.unicopia.ability.magic.spell.trait.SpellTraits; import com.minelittlepony.unicopia.ability.magic.spell.trait.Trait; import com.minelittlepony.unicopia.entity.player.Pony; -import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.arguments.FloatArgumentType; import com.mojang.brigadier.builder.LiteralArgumentBuilder; import com.mojang.brigadier.exceptions.CommandSyntaxException; @@ -16,29 +15,24 @@ import net.minecraft.text.*; import net.minecraft.util.Hand; class TraitCommand { - static void register(CommandDispatcher dispatcher) { - LiteralArgumentBuilder builder = CommandManager - .literal("trait") - .requires(s -> s.hasPermissionLevel(2)); - - builder.then(CommandManager.literal("add") - .then(CommandManager.argument("trait", Trait.argument()) - .then(CommandManager.argument("value", FloatArgumentType.floatArg()).executes(source -> add( - source.getSource(), - source.getSource().getPlayer(), - source.getArgument("trait", Trait.class), - FloatArgumentType.getFloat(source, "value") - ))) - )); - builder.then(CommandManager.literal("remove") - .then(CommandManager.argument("trait", Trait.argument()).executes(source -> remove( - source.getSource(), - source.getSource().getPlayer(), - source.getArgument("trait", Trait.class) - )) - )); - - dispatcher.register(builder); + static LiteralArgumentBuilder create() { + return CommandManager.literal("trait").requires(s -> s.hasPermissionLevel(2)) + .then(CommandManager.literal("add") + .then(CommandManager.argument("trait", Trait.argument()) + .then(CommandManager.argument("value", FloatArgumentType.floatArg()).executes(source -> add( + source.getSource(), + source.getSource().getPlayer(), + source.getArgument("trait", Trait.class), + FloatArgumentType.getFloat(source, "value") + ))) + )) + .then(CommandManager.literal("remove") + .then(CommandManager.argument("trait", Trait.argument()).executes(source -> remove( + source.getSource(), + source.getSource().getPlayer(), + source.getArgument("trait", Trait.class) + )) + )); } static int add(ServerCommandSource source, PlayerEntity player, Trait trait, float amount) throws CommandSyntaxException { diff --git a/src/main/java/com/minelittlepony/unicopia/command/UnicopiaCommand.java b/src/main/java/com/minelittlepony/unicopia/command/UnicopiaCommand.java new file mode 100644 index 00000000..c2678484 --- /dev/null +++ b/src/main/java/com/minelittlepony/unicopia/command/UnicopiaCommand.java @@ -0,0 +1,23 @@ +package com.minelittlepony.unicopia.command; + +import com.mojang.brigadier.builder.LiteralArgumentBuilder; + +import net.minecraft.command.CommandRegistryAccess; +import net.minecraft.server.command.CommandManager; +import net.minecraft.server.command.CommandManager.RegistrationEnvironment; +import net.minecraft.server.command.ServerCommandSource; + +class UnicopiaCommand { + public static LiteralArgumentBuilder create(CommandRegistryAccess registries, RegistrationEnvironment environment) { + return CommandManager.literal("unicopia") + .then(EmoteCommand.create()) + .then(SpeciesCommand.create(environment)) + .then(RacelistCommand.create()) + .then(WorldTribeCommand.create()) + .then(GravityCommand.create()) + .then(DisguiseCommand.create(registries)) + .then(CastCommand.create(registries)) + .then(TraitCommand.create()) + .then(ManaCommand.create()); + } +} diff --git a/src/main/java/com/minelittlepony/unicopia/command/WorldTribeCommand.java b/src/main/java/com/minelittlepony/unicopia/command/WorldTribeCommand.java index 4538b5d0..e09b9af1 100644 --- a/src/main/java/com/minelittlepony/unicopia/command/WorldTribeCommand.java +++ b/src/main/java/com/minelittlepony/unicopia/command/WorldTribeCommand.java @@ -2,7 +2,6 @@ package com.minelittlepony.unicopia.command; import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.server.world.UnicopiaWorldProperties; -import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.builder.LiteralArgumentBuilder; import com.mojang.brigadier.exceptions.CommandSyntaxException; @@ -11,17 +10,12 @@ import net.minecraft.server.command.ServerCommandSource; import net.minecraft.text.Text; class WorldTribeCommand { - static void register(CommandDispatcher dispatcher) { - LiteralArgumentBuilder builder = CommandManager - .literal("worldtribe") - .requires(s -> s.hasPermissionLevel(4)); - - builder.then(CommandManager.literal("get").executes(context -> get(context.getSource()))); - builder.then(CommandManager.literal("set") + static LiteralArgumentBuilder create() { + return CommandManager.literal("worldtribe").requires(s -> s.hasPermissionLevel(3)) + .then(CommandManager.literal("get").executes(context -> get(context.getSource()))) + .then(CommandManager.literal("set") .then(CommandManager.argument("race", Race.argument()) .executes(context -> set(context.getSource(), Race.fromArgument(context, "race"))))); - - dispatcher.register(builder); } static int get(ServerCommandSource source) throws CommandSyntaxException {