mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-27 15:17:59 +01:00
Add a permission level requirement for the /race command
This commit is contained in:
parent
47e8995ad8
commit
1ca7407642
2 changed files with 14 additions and 2 deletions
|
@ -20,8 +20,10 @@ public class Commands {
|
|||
CommandRegistrationCallback.EVENT.register((dispatcher, access, environment) -> {
|
||||
RacelistCommand.register(dispatcher);
|
||||
EmoteCommand.register(dispatcher);
|
||||
if (Unicopia.getConfig().enableCheats.get() || environment.dedicated) {
|
||||
SpeciesCommand.register(dispatcher, environment);
|
||||
}
|
||||
if (Unicopia.getConfig().enableCheats.get()) {
|
||||
SpeciesCommand.register(dispatcher);
|
||||
GravityCommand.register(dispatcher);
|
||||
DisguiseCommand.register(dispatcher, access);
|
||||
if (Debug.DEBUG_COMMANDS) {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.minelittlepony.unicopia.command;
|
||||
|
||||
import com.minelittlepony.unicopia.Race;
|
||||
import com.minelittlepony.unicopia.Unicopia;
|
||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
|
@ -9,6 +10,7 @@ import net.minecraft.command.argument.EntityArgumentType;
|
|||
import net.minecraft.command.argument.RegistryKeyArgumentType;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.server.command.CommandManager;
|
||||
import net.minecraft.server.command.CommandManager.RegistrationEnvironment;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.text.MutableText;
|
||||
import net.minecraft.text.Text;
|
||||
|
@ -17,9 +19,17 @@ import net.minecraft.util.Identifier;
|
|||
import net.minecraft.world.GameRules;
|
||||
|
||||
class SpeciesCommand {
|
||||
static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
|
||||
static void register(CommandDispatcher<ServerCommandSource> dispatcher, RegistrationEnvironment environment) {
|
||||
LiteralArgumentBuilder<ServerCommandSource> builder = CommandManager.literal("race");
|
||||
|
||||
if (environment.dedicated) {
|
||||
if (Unicopia.getConfig().enableCheats.get()) {
|
||||
builder = builder.requires(source -> source.hasPermissionLevel(2));
|
||||
} else {
|
||||
builder = builder.requires(source -> source.hasPermissionLevel(4));
|
||||
}
|
||||
}
|
||||
|
||||
RegistryKeyArgumentType<Race> raceArgument = Race.argument();
|
||||
|
||||
builder.then(CommandManager.literal("get")
|
||||
|
|
Loading…
Reference in a new issue