Standardize permission nodes

This commit is contained in:
Alessandro Proto 2024-10-23 12:19:24 +02:00
parent 4899a2c14d
commit e3f0d0f72d
4 changed files with 20 additions and 8 deletions

View file

@ -41,21 +41,25 @@ public class RccServer implements ModInitializer {
private static int currentPlayerCount = 0; private static int currentPlayerCount = 0;
private static RccServer INSTANCE; private static RccServer INSTANCE;
public static RccServer getInstance() { public static RccServer getInstance() {
return INSTANCE; return INSTANCE;
} }
private ServiceServer serviceServer; private ServiceServer serviceServer;
public ServiceServer serviceServer() { public ServiceServer serviceServer() {
return serviceServer; return serviceServer;
} }
private LuckPerms luckPerms; private LuckPerms luckPerms;
public LuckPerms luckPerms() { public LuckPerms luckPerms() {
return luckPerms; return luckPerms;
} }
private AfkTracker afkTracker; private AfkTracker afkTracker;
public AfkTracker afkTracker() { public AfkTracker afkTracker() {
return afkTracker; return afkTracker;
} }
@ -84,6 +88,10 @@ public class RccServer implements ModInitializer {
CommandRegistrationCallback.EVENT.register(AfkCommand::register); CommandRegistrationCallback.EVENT.register(AfkCommand::register);
CommandRegistrationCallback.EVENT.register(TellCommand::register); CommandRegistrationCallback.EVENT.register(TellCommand::register);
CommandRegistrationCallback.EVENT.register(ReplyCommand::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); FlyCommand.register(dispatcher, registryAccess, environment);
GodCommand.register(dispatcher, registryAccess, environment); GodCommand.register(dispatcher, registryAccess, environment);
}); });

View file

@ -13,7 +13,7 @@ import static net.minecraft.server.command.CommandManager.literal;
public class AfkCommand { public class AfkCommand {
public static void register(CommandDispatcher<ServerCommandSource> dispatcher, CommandRegistryAccess registryAccess, CommandManager.RegistrationEnvironment environment) { public static void register(CommandDispatcher<ServerCommandSource> dispatcher, CommandRegistryAccess registryAccess, CommandManager.RegistrationEnvironment environment) {
var rootCommand = literal("afk") var rootCommand = literal("afk")
.requires(Permissions.require("rcc.afk.command", true)) .requires(Permissions.require("rcc.command.afk", true))
.executes(context -> { .executes(context -> {
if(!context.getSource().isExecutedByPlayer()) { if(!context.getSource().isExecutedByPlayer()) {

View file

@ -3,6 +3,7 @@ package cc.reconnected.server.commands;
import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType; import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.context.CommandContext; import com.mojang.brigadier.context.CommandContext;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.minecraft.command.CommandRegistryAccess; import net.minecraft.command.CommandRegistryAccess;
import net.minecraft.server.command.CommandManager; import net.minecraft.server.command.CommandManager;
import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.command.ServerCommandSource;
@ -16,6 +17,7 @@ import static net.minecraft.server.command.CommandManager.*;
public class ReplyCommand { public class ReplyCommand {
public static void register(CommandDispatcher<ServerCommandSource> dispatcher, CommandRegistryAccess registryAccess, CommandManager.RegistrationEnvironment environment) { public static void register(CommandDispatcher<ServerCommandSource> dispatcher, CommandRegistryAccess registryAccess, CommandManager.RegistrationEnvironment environment) {
var messageNode = dispatcher.register(literal("reply") var messageNode = dispatcher.register(literal("reply")
.requires(Permissions.require("rcc.command.tell", true))
.then(argument("message", StringArgumentType.greedyString()) .then(argument("message", StringArgumentType.greedyString())
.executes(ReplyCommand::execute))); .executes(ReplyCommand::execute)));

View file

@ -5,6 +5,7 @@ import cc.reconnected.server.parser.MarkdownParser;
import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType; import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.context.CommandContext; 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.MiniMessage;
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder; import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
import net.minecraft.command.CommandRegistryAccess; import net.minecraft.command.CommandRegistryAccess;
@ -26,6 +27,7 @@ public class TellCommand {
public static void register(CommandDispatcher<ServerCommandSource> dispatcher, CommandRegistryAccess registryAccess, CommandManager.RegistrationEnvironment environment) { public static void register(CommandDispatcher<ServerCommandSource> dispatcher, CommandRegistryAccess registryAccess, CommandManager.RegistrationEnvironment environment) {
var messageNode = dispatcher.register(literal("msg") var messageNode = dispatcher.register(literal("msg")
.requires(Permissions.require("rcc.command.tell", true))
.then(argument("player", StringArgumentType.word()) .then(argument("player", StringArgumentType.word())
.suggests((context, builder) -> { .suggests((context, builder) -> {
var playerManager = context.getSource().getServer().getPlayerManager(); var playerManager = context.getSource().getServer().getPlayerManager();