From a40dcdaf9d432af771b6588571122e65738a78f1 Mon Sep 17 00:00:00 2001 From: Basique Date: Wed, 7 Aug 2024 01:11:39 +0300 Subject: [PATCH] move permissions to one class --- .../impl/command/PurgeCommand.java | 5 +- .../pingspam/commands/AliasCommand.java | 14 +-- .../pingspam/commands/GroupCommand.java | 10 +- .../pingspam/commands/PingSpamCommands.java | 4 +- .../pingspam/commands/mail/ClearCommand.java | 4 +- .../pingspam/commands/mail/DeleteCommand.java | 6 +- .../pingspam/commands/mail/ListCommand.java | 4 +- .../pingspam/commands/mail/SendCommand.java | 8 +- .../pingspam/logic/IgnoreLogic.java | 3 +- .../pingspam/logic/PingLogic.java | 13 ++- .../pingspam/logic/PingspamPermissions.java | 100 ++++++++++++++++++ .../pingspam/network/ServerNetworkLogic.java | 10 +- 12 files changed, 139 insertions(+), 42 deletions(-) create mode 100644 src/main/java/me/basiqueevangelist/pingspam/logic/PingspamPermissions.java diff --git a/src/main/java/me/basiqueevangelist/onedatastore/impl/command/PurgeCommand.java b/src/main/java/me/basiqueevangelist/onedatastore/impl/command/PurgeCommand.java index 845268a..2f765fd 100644 --- a/src/main/java/me/basiqueevangelist/onedatastore/impl/command/PurgeCommand.java +++ b/src/main/java/me/basiqueevangelist/onedatastore/impl/command/PurgeCommand.java @@ -11,11 +11,10 @@ import me.basiqueevangelist.onedatastore.api.DataStore; import me.basiqueevangelist.onedatastore.impl.OneDataStoreInit; import me.basiqueevangelist.onedatastore.impl.OneDataStoreState; -import me.lucko.fabric.api.permissions.v0.Permissions; +import me.basiqueevangelist.pingspam.logic.PingspamPermissions; import net.minecraft.command.CommandSource; import net.minecraft.command.argument.GameProfileArgumentType; import net.minecraft.command.argument.IdentifierArgumentType; -import net.minecraft.server.command.CommandManager; import net.minecraft.server.command.ServerCommandSource; import net.minecraft.text.Text; import net.minecraft.util.Formatting; @@ -39,7 +38,7 @@ public static void register(CommandDispatcher dispatcher) { dispatcher.register( literal("onedatastore") .then(literal("purge") - .requires(Permissions.require("onedatastore.purge", 4)) + .requires(PingspamPermissions::purge) .then(literal("player") .then(argument("target", GameProfileArgumentType.gameProfile()) .executes(PurgeCommand::purgePlayer))) diff --git a/src/main/java/me/basiqueevangelist/pingspam/commands/AliasCommand.java b/src/main/java/me/basiqueevangelist/pingspam/commands/AliasCommand.java index 0ddd1fd..6680d85 100644 --- a/src/main/java/me/basiqueevangelist/pingspam/commands/AliasCommand.java +++ b/src/main/java/me/basiqueevangelist/pingspam/commands/AliasCommand.java @@ -12,10 +12,10 @@ import me.basiqueevangelist.onedatastore.api.DataStore; import me.basiqueevangelist.pingspam.PingSpam; import me.basiqueevangelist.pingspam.data.PingspamPlayerData; +import me.basiqueevangelist.pingspam.logic.PingspamPermissions; import me.basiqueevangelist.pingspam.network.ServerNetworkLogic; import me.basiqueevangelist.pingspam.utils.CommandUtil; import me.basiqueevangelist.pingspam.logic.NameLogic; -import me.lucko.fabric.api.permissions.v0.Permissions; import net.minecraft.command.argument.GameProfileArgumentType; import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.network.ServerPlayerEntity; @@ -48,11 +48,11 @@ public static void register(CommandDispatcher dispatcher) { .then(literal("list") .executes(AliasCommand::listAliases)) .then(literal("add") - .requires(x -> Permissions.check(x, "pingspam.alias.own.add", true)) + .requires(PingspamPermissions::addOwnAlias) .then(argument("alias", StringArgumentType.string()) .executes(AliasCommand::addAliases))) .then(literal("remove") - .requires(x -> Permissions.check(x, "pingspam.alias.own.remove", true)) + .requires(PingspamPermissions::removeOwnAlias) .then(argument("alias", StringArgumentType.string()) .executes(AliasCommand::removeAlias) .suggests(AliasCommand::suggestOwnAliases))) @@ -62,11 +62,11 @@ public static void register(CommandDispatcher dispatcher) { .then(literal("list") .executes(AliasCommand::listPlayerAliases)) .then(literal("add") - .requires(x -> Permissions.check(x, "pingspam.alias.player.add", 2)) + .requires(PingspamPermissions::addPlayerAlias) .then(argument("alias", StringArgumentType.string()) .executes(AliasCommand::addPlayerAlias))) .then(literal("remove") - .requires(x -> Permissions.check(x, "pingspam.alias.player.remove", 2)) + .requires(PingspamPermissions::removePlayerAlias) .then(argument("alias", StringArgumentType.string()) .executes(AliasCommand::removePlayerAlias) .suggests(AliasCommand::suggestPlayerAliases)))))) @@ -142,7 +142,7 @@ private static int addPlayerAlias(CommandContext ctx) throw if (NameLogic.isValidName(src.getServer(), newAlias, false)) throw ALIAS_COLLISION.create(); - if (data.aliases().size() >= ALIAS_LIMIT && !Permissions.check(src, "pingspam.bypass.aliaslimit", 2)) + if (data.aliases().size() >= ALIAS_LIMIT && !PingspamPermissions.bypassAliasLimit(src)) throw TOO_MANY_ALIASES.create(); data.aliases().add(newAlias); @@ -243,7 +243,7 @@ private static int addAliases(CommandContext ctx) throws Co if (NameLogic.isValidName(src.getServer(), newAlias, false)) throw ALIAS_COLLISION.create(); - if (data.aliases().size() >= ALIAS_LIMIT && !Permissions.check(src, "pingspam.bypass.aliaslimit", 2)) + if (data.aliases().size() >= ALIAS_LIMIT && !PingspamPermissions.bypassAliasLimit(src)) throw TOO_MANY_ALIASES.create(); data.aliases().add(newAlias); diff --git a/src/main/java/me/basiqueevangelist/pingspam/commands/GroupCommand.java b/src/main/java/me/basiqueevangelist/pingspam/commands/GroupCommand.java index 692ae5a..ed3a27f 100644 --- a/src/main/java/me/basiqueevangelist/pingspam/commands/GroupCommand.java +++ b/src/main/java/me/basiqueevangelist/pingspam/commands/GroupCommand.java @@ -14,11 +14,11 @@ import me.basiqueevangelist.onedatastore.api.DataStore; import me.basiqueevangelist.pingspam.PingSpam; import me.basiqueevangelist.pingspam.data.PingspamPlayerData; +import me.basiqueevangelist.pingspam.logic.PingspamPermissions; import me.basiqueevangelist.pingspam.network.ServerNetworkLogic; import me.basiqueevangelist.pingspam.utils.CommandUtil; import me.basiqueevangelist.pingspam.logic.NameLogic; import me.basiqueevangelist.pingspam.utils.NameUtil; -import me.lucko.fabric.api.permissions.v0.Permissions; import net.minecraft.command.argument.GameProfileArgumentType; import net.minecraft.server.command.ServerCommandSource; import net.minecraft.text.Text; @@ -50,21 +50,21 @@ public static void register(CommandDispatcher dispatcher) { .then(literal("list") .executes(GroupCommand::listPlayersInGroup)) .then(literal("add") - .requires(Permissions.require("pingspam.group.player.add", 2)) + .requires(PingspamPermissions::addGroupPlayer) .then(argument("player", GameProfileArgumentType.gameProfile()) .suggests(CommandUtil::suggestPlayers) .executes(GroupCommand::addPlayerToGroup))) .then(literal("remove") - .requires(Permissions.require("pingspam.group.player.add", 2)) + .requires(PingspamPermissions::addGroupPlayer) .then(argument("player", GameProfileArgumentType.gameProfile()) .suggests(CommandUtil::suggestPlayers) .executes(GroupCommand::removePlayerFromGroup))) .then(literal("pingable") - .requires(Permissions.require("pingspam.group.configure", 2)) + .requires(PingspamPermissions::configureGroup) .then(argument("value", BoolArgumentType.bool()) .executes(GroupCommand::configurePingable))) .then(literal("haschat") - .requires(Permissions.require("pingspam.group.configure", 2)) + .requires(PingspamPermissions::configureGroup) .then(argument("value", BoolArgumentType.bool()) .executes(GroupCommand::configureGroupChat))) )) diff --git a/src/main/java/me/basiqueevangelist/pingspam/commands/PingSpamCommands.java b/src/main/java/me/basiqueevangelist/pingspam/commands/PingSpamCommands.java index 447dad7..fec46db 100644 --- a/src/main/java/me/basiqueevangelist/pingspam/commands/PingSpamCommands.java +++ b/src/main/java/me/basiqueevangelist/pingspam/commands/PingSpamCommands.java @@ -3,7 +3,7 @@ import com.mojang.brigadier.CommandDispatcher; import me.basiqueevangelist.pingspam.PingSpam; import me.basiqueevangelist.pingspam.commands.mail.*; -import me.lucko.fabric.api.permissions.v0.Permissions; +import me.basiqueevangelist.pingspam.logic.PingspamPermissions; import net.minecraft.command.CommandRegistryAccess; import net.minecraft.server.command.CommandManager; import net.minecraft.server.command.ServerCommandSource; @@ -27,7 +27,7 @@ public static void register(CommandDispatcher dispatcher, C dispatcher.register( literal("pingspam") .then(literal("reload") - .requires(x -> Permissions.check(x, "pingspam.reload", 2)) + .requires(PingspamPermissions::reload) .executes(ctx -> { PingSpam.CONFIG.load(); diff --git a/src/main/java/me/basiqueevangelist/pingspam/commands/mail/ClearCommand.java b/src/main/java/me/basiqueevangelist/pingspam/commands/mail/ClearCommand.java index cbc06ee..ca0e35a 100644 --- a/src/main/java/me/basiqueevangelist/pingspam/commands/mail/ClearCommand.java +++ b/src/main/java/me/basiqueevangelist/pingspam/commands/mail/ClearCommand.java @@ -7,9 +7,9 @@ import me.basiqueevangelist.onedatastore.api.DataStore; import me.basiqueevangelist.pingspam.PingSpam; import me.basiqueevangelist.pingspam.data.PechkinPlayerData; +import me.basiqueevangelist.pingspam.logic.PingspamPermissions; import me.basiqueevangelist.pingspam.utils.CommandUtil; import me.basiqueevangelist.pingspam.utils.NameUtil; -import me.lucko.fabric.api.permissions.v0.Permissions; import net.minecraft.command.argument.GameProfileArgumentType; import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.network.ServerPlayerEntity; @@ -29,7 +29,7 @@ public static void register(CommandDispatcher dispatcher) { .then(literal("clear") .executes(ClearCommand::clear) .then(argument("player", GameProfileArgumentType.gameProfile()) - .requires(Permissions.require("pechkin.clear.other", 2)) + .requires(PingspamPermissions::clearOtherMail) .suggests(CommandUtil::suggestPlayersExceptSelf) .executes(ClearCommand::clearOther)))); } diff --git a/src/main/java/me/basiqueevangelist/pingspam/commands/mail/DeleteCommand.java b/src/main/java/me/basiqueevangelist/pingspam/commands/mail/DeleteCommand.java index 729dd5d..f4a664e 100644 --- a/src/main/java/me/basiqueevangelist/pingspam/commands/mail/DeleteCommand.java +++ b/src/main/java/me/basiqueevangelist/pingspam/commands/mail/DeleteCommand.java @@ -9,8 +9,8 @@ import me.basiqueevangelist.pingspam.PingSpam; import me.basiqueevangelist.pingspam.data.PechkinPlayerData; import me.basiqueevangelist.pingspam.hack.StateTracker; +import me.basiqueevangelist.pingspam.logic.PingspamPermissions; import me.basiqueevangelist.pingspam.utils.CommandUtil; -import me.lucko.fabric.api.permissions.v0.Permissions; import net.minecraft.command.argument.GameProfileArgumentType; import net.minecraft.command.argument.UuidArgumentType; import net.minecraft.server.command.ServerCommandSource; @@ -37,8 +37,8 @@ public static void register(CommandDispatcher dispatcher) { .then(argument("message", UuidArgumentType.uuid()) .executes(DeleteCommand::deleteList))) .then(literal("delete_list_other") - .requires(Permissions.require("pechkin.list.other", 2)) - .requires(Permissions.require("pechkin.delete.other", 2)) + .requires(PingspamPermissions::listOtherMail) + .requires(PingspamPermissions::deleteOtherMail) .then(argument("player", GameProfileArgumentType.gameProfile()) .then(argument("message", UuidArgumentType.uuid()) .executes(DeleteCommand::deleteListOther)))) diff --git a/src/main/java/me/basiqueevangelist/pingspam/commands/mail/ListCommand.java b/src/main/java/me/basiqueevangelist/pingspam/commands/mail/ListCommand.java index 5a3ba15..b04f1b1 100644 --- a/src/main/java/me/basiqueevangelist/pingspam/commands/mail/ListCommand.java +++ b/src/main/java/me/basiqueevangelist/pingspam/commands/mail/ListCommand.java @@ -8,10 +8,10 @@ import me.basiqueevangelist.pingspam.PingSpam; import me.basiqueevangelist.pingspam.data.MailMessage; import me.basiqueevangelist.pingspam.data.PechkinPlayerData; +import me.basiqueevangelist.pingspam.logic.PingspamPermissions; import me.basiqueevangelist.pingspam.utils.TimeUtils; import me.basiqueevangelist.pingspam.utils.CommandUtil; import me.basiqueevangelist.pingspam.utils.NameUtil; -import me.lucko.fabric.api.permissions.v0.Permissions; import net.minecraft.command.argument.GameProfileArgumentType; import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.network.ServerPlayerEntity; @@ -32,7 +32,7 @@ public static void register(CommandDispatcher dispatcher) { .executes(ListCommand::list) .then(argument("player", GameProfileArgumentType.gameProfile()) .suggests(CommandUtil::suggestPlayersExceptSelf) - .requires(Permissions.require("pechkin.list.other", 2)) + .requires(PingspamPermissions::listOtherMail) .executes(ListCommand::listOther))) .executes(ListCommand::list)); } diff --git a/src/main/java/me/basiqueevangelist/pingspam/commands/mail/SendCommand.java b/src/main/java/me/basiqueevangelist/pingspam/commands/mail/SendCommand.java index ef6ecb8..181dd18 100644 --- a/src/main/java/me/basiqueevangelist/pingspam/commands/mail/SendCommand.java +++ b/src/main/java/me/basiqueevangelist/pingspam/commands/mail/SendCommand.java @@ -11,8 +11,8 @@ import me.basiqueevangelist.pingspam.data.PechkinPlayerData; import me.basiqueevangelist.pingspam.logic.IgnoreLogic; import me.basiqueevangelist.pingspam.logic.MailLogic; +import me.basiqueevangelist.pingspam.logic.PingspamPermissions; import me.basiqueevangelist.pingspam.utils.CommandUtil; -import me.lucko.fabric.api.permissions.v0.Permissions; import net.minecraft.command.argument.GameProfileArgumentType; import net.minecraft.command.argument.MessageArgumentType; import net.minecraft.server.command.ServerCommandSource; @@ -40,12 +40,12 @@ public static void register(CommandDispatcher dispatcher) { .then(argument("player", GameProfileArgumentType.gameProfile()) .suggests(CommandUtil::suggestPlayers) .then(argument("message", MessageArgumentType.message()) - .requires(Permissions.require("pechkin.send", true)) + .requires(PingspamPermissions::sendMail) .executes(SendCommand::send))))); dispatcher.register(literal("r") .then(argument("message", MessageArgumentType.message()) - .requires(Permissions.require("pechkin.send", true)) + .requires(PingspamPermissions::sendMail) .executes(SendCommand::reply))); } @@ -82,7 +82,7 @@ private static void sendMessage(ServerCommandSource src, ServerPlayerEntity send IgnoreLogic.throwIfIgnored(sender, recipientId); - if (!Permissions.check(sender, "pechkin.bypass.cooldown", 2)) { + if (!PingspamPermissions.bypassCooldown(sender)) { int sendCost = PingSpam.CONFIG.getConfig().mail.sendCost; if (!senderData.leakyBucket().hasEnoughFor(sendCost)) diff --git a/src/main/java/me/basiqueevangelist/pingspam/logic/IgnoreLogic.java b/src/main/java/me/basiqueevangelist/pingspam/logic/IgnoreLogic.java index 409e00f..1fb2cbf 100644 --- a/src/main/java/me/basiqueevangelist/pingspam/logic/IgnoreLogic.java +++ b/src/main/java/me/basiqueevangelist/pingspam/logic/IgnoreLogic.java @@ -4,7 +4,6 @@ import com.mojang.brigadier.exceptions.SimpleCommandExceptionType; import me.basiqueevangelist.onedatastore.api.DataStore; import me.basiqueevangelist.pingspam.PingSpam; -import me.lucko.fabric.api.permissions.v0.Permissions; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.text.Text; @@ -18,7 +17,7 @@ private IgnoreLogic() { } public static boolean isIgnored(ServerPlayerEntity player, UUID by) { - if (Permissions.check(player, "pingspam.bypass.ignore", 2)) return false; + if (PingspamPermissions.bypassIgnore(player)) return false; return DataStore.getFor(player.server).getPlayer(by, PingSpam.PLAYER_DATA).ignoredPlayers().contains(player.getUuid()); } diff --git a/src/main/java/me/basiqueevangelist/pingspam/logic/PingLogic.java b/src/main/java/me/basiqueevangelist/pingspam/logic/PingLogic.java index 6e4d225..abec8b4 100644 --- a/src/main/java/me/basiqueevangelist/pingspam/logic/PingLogic.java +++ b/src/main/java/me/basiqueevangelist/pingspam/logic/PingLogic.java @@ -7,7 +7,6 @@ import me.basiqueevangelist.pingspam.data.PingspamPlayerData; import me.basiqueevangelist.pingspam.utils.NameUtil; import me.basiqueevangelist.pingspam.utils.PlayerUtils; -import me.lucko.fabric.api.permissions.v0.Permissions; import net.minecraft.server.MinecraftServer; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.sound.SoundCategory; @@ -60,7 +59,7 @@ public static ProcessedPing processPings(MinecraftServer server, Text messageCon private static void processMention(ProcessedPing result, String mention, Text message) { switch (mention) { case "everyone": - if (result.sender == null || Permissions.check(result.sender, "pingspam.ping.everyone", 2)) { + if (result.sender == null || PingspamPermissions.pingEveryone(result.sender)) { for (UUID playerId : PlayerUtils.getAllPlayers(result.server)) { pingPlayer(result, playerId, message); } @@ -70,7 +69,7 @@ private static void processMention(ProcessedPing result, String mention, Text me } break; case "online": - if (result.sender == null || Permissions.check(result.sender, "pingspam.ping.online", 2)) { + if (result.sender == null || PingspamPermissions.pingOnline(result.sender)) { for (ServerPlayerEntity player : result.server.getPlayerManager().getPlayerList()) { pingPlayer(result, player.getUuid(), message); } @@ -80,7 +79,7 @@ private static void processMention(ProcessedPing result, String mention, Text me } break; case "offline": - if (result.sender == null || Permissions.check(result.sender, "pingspam.ping.offline", 2)) { + if (result.sender == null || PingspamPermissions.pingOffline(result.sender)) { for (PlayerDataEntry entry : DataStore.getFor(result.server).players()) { if (result.server.getPlayerManager().getPlayer(entry.playerId()) != null) continue; @@ -94,7 +93,7 @@ private static void processMention(ProcessedPing result, String mention, Text me default: PingspamGroupData pingGroup = DataStore.getFor(result.server).get(PingSpam.GLOBAL_DATA).groups().get(mention); if (pingGroup != null && pingGroup.isPingable()) { - if (result.sender == null || Permissions.check(result.sender, "pingspam.ping.group", true)) { + if (result.sender == null || PingspamPermissions.pingGroup(result.sender)) { for (UUID playerId : pingGroup.members()) { pingPlayer(result, playerId, message); } @@ -122,14 +121,14 @@ private static void processMention(ProcessedPing result, String mention, Text me PingspamPlayerData foundData = DataStore.getFor(result.server).getPlayer(foundPlayerId, PingSpam.PLAYER_DATA); - if (result.sender != null && !Permissions.check(result.sender, "pingspam.bypass.ignore", 2)) { + if (result.sender != null && !PingspamPermissions.bypassIgnore(result.sender)) { if (foundData.ignoredPlayers().contains(result.sender.getUuid())) { PingLogic.sendPingError(result.sender, NameUtil.getNameFromUUID(foundPlayerId) + " has ignored you, they won't receive your ping."); break; } } - if (result.sender != null && !Permissions.check(result.sender, "pingspam.ping.player", true)) { + if (result.sender != null && !PingspamPermissions.pingPlayer(result.sender)) { PingLogic.sendPingError(result.sender, "You do not have enough permissions to ping @" + mention + "!"); return; } diff --git a/src/main/java/me/basiqueevangelist/pingspam/logic/PingspamPermissions.java b/src/main/java/me/basiqueevangelist/pingspam/logic/PingspamPermissions.java new file mode 100644 index 0000000..b80721b --- /dev/null +++ b/src/main/java/me/basiqueevangelist/pingspam/logic/PingspamPermissions.java @@ -0,0 +1,100 @@ +package me.basiqueevangelist.pingspam.logic; + +import me.lucko.fabric.api.permissions.v0.Permissions; +import net.minecraft.command.CommandSource; +import net.minecraft.server.network.ServerPlayerEntity; + +@SuppressWarnings("BooleanMethodIsAlwaysInverted") +public final class PingspamPermissions { + private PingspamPermissions() { } + + //region /pingspam alias + public static boolean addOwnAlias(CommandSource source) { + return Permissions.check(source, "pingspam.alias.own.add", true); + } + + public static boolean removeOwnAlias(CommandSource source) { + return Permissions.check(source, "pingspam.alias.own.remove", true); + } + + public static boolean addPlayerAlias(CommandSource source) { + return Permissions.check(source, "pingspam.alias.player.add", 2); + } + + public static boolean removePlayerAlias(CommandSource source) { + return Permissions.check(source, "pingspam.alias.player.remove", 2); + } + //endregion + + //region /pingspam group + public static boolean addGroupPlayer(CommandSource source) { + return Permissions.check(source, "pingspam.group.player.add", 2); + } + + public static boolean configureGroup(CommandSource source) { + return Permissions.check(source, "pingspam.group.configure", 2); + } + //endregion + + //region bypass* + public static boolean bypassAliasLimit(CommandSource source) { + return Permissions.check(source, "pingspam.bypass.aliaslimit", 2); + } + + public static boolean bypassIgnore(ServerPlayerEntity source) { + return Permissions.check(source, "pingspam.bypass.ignore", 2); + } + + public static boolean bypassCooldown(ServerPlayerEntity source) { + return Permissions.check(source, "pechkin.bypass.cooldown", 2); + } + //endregion + + //region ping* + public static boolean pingEveryone(ServerPlayerEntity source) { + return Permissions.check(source, "pingspam.ping.everyone", 2); + } + + public static boolean pingOnline(ServerPlayerEntity source) { + return Permissions.check(source, "pingspam.ping.online", 2); + } + + public static boolean pingOffline(ServerPlayerEntity source) { + return Permissions.check(source, "pingspam.ping.offline", 2); + } + + public static boolean pingPlayer(ServerPlayerEntity source) { + return Permissions.check(source, "pingspam.ping.player", true); + } + + public static boolean pingGroup(ServerPlayerEntity source) { + return Permissions.check(source, "pingspam.ping.group", true); + } + //endregion + + //region /mail + public static boolean sendMail(CommandSource source) { + return Permissions.check(source, "pechkin.send", true); + } + + public static boolean clearOtherMail(CommandSource source) { + return Permissions.check(source, "pechkin.clear.other", 2); + } + + public static boolean listOtherMail(CommandSource source) { + return Permissions.check(source, "pechkin.list.other", 2); + } + + public static boolean deleteOtherMail(CommandSource source) { + return Permissions.check(source, "pechkin.delete.other", 2); + } + //endregion + + public static boolean purge(CommandSource source) { + return Permissions.check(source, "onedatastore.purge", 4); + } + + public static boolean reload(CommandSource source) { + return Permissions.check(source, "pingspam.reload", 2); + } +} diff --git a/src/main/java/me/basiqueevangelist/pingspam/network/ServerNetworkLogic.java b/src/main/java/me/basiqueevangelist/pingspam/network/ServerNetworkLogic.java index 78732bb..a8a5750 100644 --- a/src/main/java/me/basiqueevangelist/pingspam/network/ServerNetworkLogic.java +++ b/src/main/java/me/basiqueevangelist/pingspam/network/ServerNetworkLogic.java @@ -3,7 +3,7 @@ import me.basiqueevangelist.onedatastore.api.DataStore; import me.basiqueevangelist.pingspam.PingSpam; import me.basiqueevangelist.pingspam.logic.NameLogic; -import me.lucko.fabric.api.permissions.v0.Permissions; +import me.basiqueevangelist.pingspam.logic.PingspamPermissions; import net.fabricmc.fabric.api.networking.v1.PacketByteBufs; import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; import net.minecraft.network.ClientConnection; @@ -39,10 +39,10 @@ public static void sendServerAnnouncement(ServerPlayerEntity player, ClientConne newBuf.writeCollection(possibleNames, PacketByteBuf::writeString); var payload = new AnnounceS2CPayload( - Permissions.check(player, "pingspam.ping.everyone", 2), - Permissions.check(player, "pingspam.ping.online", 2), - Permissions.check(player, "pingspam.ping.offline", 2), - Permissions.check(player, "pingspam.ping.player", true), + PingspamPermissions.pingEveryone(player), + PingspamPermissions.pingOnline(player), + PingspamPermissions.pingOffline(player), + PingspamPermissions.pingPlayer(player), possibleNames );