Standardize permission nodes
This commit is contained in:
parent
4899a2c14d
commit
e3f0d0f72d
4 changed files with 20 additions and 8 deletions
|
@ -41,21 +41,25 @@ public class RccServer implements ModInitializer {
|
|||
private static int currentPlayerCount = 0;
|
||||
|
||||
private static RccServer INSTANCE;
|
||||
|
||||
public static RccServer getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
private ServiceServer serviceServer;
|
||||
|
||||
public ServiceServer serviceServer() {
|
||||
return serviceServer;
|
||||
}
|
||||
|
||||
private LuckPerms luckPerms;
|
||||
|
||||
public LuckPerms luckPerms() {
|
||||
return luckPerms;
|
||||
}
|
||||
|
||||
private AfkTracker afkTracker;
|
||||
|
||||
public AfkTracker afkTracker() {
|
||||
return afkTracker;
|
||||
}
|
||||
|
@ -84,6 +88,10 @@ public class RccServer implements ModInitializer {
|
|||
CommandRegistrationCallback.EVENT.register(AfkCommand::register);
|
||||
CommandRegistrationCallback.EVENT.register(TellCommand::register);
|
||||
CommandRegistrationCallback.EVENT.register(ReplyCommand::register);
|
||||
CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> {
|
||||
AfkCommand.register(dispatcher, registryAccess, environment);
|
||||
TellCommand.register(dispatcher, registryAccess, environment);
|
||||
ReplyCommand.register(dispatcher, registryAccess, environment);
|
||||
FlyCommand.register(dispatcher, registryAccess, environment);
|
||||
GodCommand.register(dispatcher, registryAccess, environment);
|
||||
});
|
||||
|
|
|
@ -13,7 +13,7 @@ import static net.minecraft.server.command.CommandManager.literal;
|
|||
public class AfkCommand {
|
||||
public static void register(CommandDispatcher<ServerCommandSource> dispatcher, CommandRegistryAccess registryAccess, CommandManager.RegistrationEnvironment environment) {
|
||||
var rootCommand = literal("afk")
|
||||
.requires(Permissions.require("rcc.afk.command", true))
|
||||
.requires(Permissions.require("rcc.command.afk", true))
|
||||
.executes(context -> {
|
||||
|
||||
if(!context.getSource().isExecutedByPlayer()) {
|
||||
|
|
|
@ -3,6 +3,7 @@ package cc.reconnected.server.commands;
|
|||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import me.lucko.fabric.api.permissions.v0.Permissions;
|
||||
import net.minecraft.command.CommandRegistryAccess;
|
||||
import net.minecraft.server.command.CommandManager;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
|
@ -16,6 +17,7 @@ import static net.minecraft.server.command.CommandManager.*;
|
|||
public class ReplyCommand {
|
||||
public static void register(CommandDispatcher<ServerCommandSource> dispatcher, CommandRegistryAccess registryAccess, CommandManager.RegistrationEnvironment environment) {
|
||||
var messageNode = dispatcher.register(literal("reply")
|
||||
.requires(Permissions.require("rcc.command.tell", true))
|
||||
.then(argument("message", StringArgumentType.greedyString())
|
||||
.executes(ReplyCommand::execute)));
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import cc.reconnected.server.parser.MarkdownParser;
|
|||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import me.lucko.fabric.api.permissions.v0.Permissions;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import net.minecraft.command.CommandRegistryAccess;
|
||||
|
@ -26,6 +27,7 @@ public class TellCommand {
|
|||
|
||||
public static void register(CommandDispatcher<ServerCommandSource> dispatcher, CommandRegistryAccess registryAccess, CommandManager.RegistrationEnvironment environment) {
|
||||
var messageNode = dispatcher.register(literal("msg")
|
||||
.requires(Permissions.require("rcc.command.tell", true))
|
||||
.then(argument("player", StringArgumentType.word())
|
||||
.suggests((context, builder) -> {
|
||||
var playerManager = context.getSource().getServer().getPlayerManager();
|
||||
|
|
Loading…
Reference in a new issue