From 90493ea64a8acaad3facf9f96957342ee23c1717 Mon Sep 17 00:00:00 2001 From: Moulberry Date: Wed, 27 Mar 2024 17:45:52 +0800 Subject: [PATCH] Bypass permission check if player is opped --- src/main/java/com/moulberry/axiom/AxiomPaper.java | 8 ++++++-- .../com/moulberry/axiom/packet/HelloPacketListener.java | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/moulberry/axiom/AxiomPaper.java b/src/main/java/com/moulberry/axiom/AxiomPaper.java index 57e0edf..0a7f84b 100644 --- a/src/main/java/com/moulberry/axiom/AxiomPaper.java +++ b/src/main/java/com/moulberry/axiom/AxiomPaper.java @@ -194,7 +194,7 @@ public class AxiomPaper extends JavaPlugin implements Listener { for (Player player : Bukkit.getServer().getOnlinePlayers()) { if (activeAxiomPlayers.contains(player.getUniqueId())) { - if (!player.hasPermission("axiom.*")) { + if (!this.hasAxiomPermission(player)) { FriendlyByteBuf buf = new FriendlyByteBuf(Unpooled.buffer()); buf.writeBoolean(false); byte[] bytes = new byte[buf.writerIndex()]; @@ -280,8 +280,12 @@ public class AxiomPaper extends JavaPlugin implements Listener { return this.logLargeBlockBufferChanges; } + public boolean hasAxiomPermission(Player player) { + return player.hasPermission("axiom.*") || player.isOp(); + } + public boolean canUseAxiom(Player player) { - return player.hasPermission("axiom.*") && activeAxiomPlayers.contains(player.getUniqueId()); + return hasAxiomPermission(player) && activeAxiomPlayers.contains(player.getUniqueId()); } public @Nullable RateLimiter getBlockBufferRateLimiter(UUID uuid) { diff --git a/src/main/java/com/moulberry/axiom/packet/HelloPacketListener.java b/src/main/java/com/moulberry/axiom/packet/HelloPacketListener.java index 1e16f0b..7c61eba 100644 --- a/src/main/java/com/moulberry/axiom/packet/HelloPacketListener.java +++ b/src/main/java/com/moulberry/axiom/packet/HelloPacketListener.java @@ -41,7 +41,7 @@ public class HelloPacketListener implements PluginMessageListener { @Override public void onPluginMessageReceived(@NotNull String channel, @NotNull Player player, @NotNull byte[] message) { - if (!player.hasPermission("axiom.*")) { + if (!this.plugin.hasAxiomPermission(player)) { return; }