Paper/patches/server/0599-Add-sendOpLevel-API.patch
MiniDigger 4104545b11 remove system property for book size limits
"It was from a different time before books were as jank as they are now. As time has gone on they've only proven to be worse and worse."
2021-06-17 21:12:40 +02:00

66 lines
2.8 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Mariell Hoversholm <proximyst@proximyst.com>
Date: Tue, 29 Dec 2020 15:03:03 +0100
Subject: [PATCH] Add sendOpLevel API
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
index 7ed8baf2942744c4f9cd1bf05aded6c9bc90f542..077a62f66af639f4506bc4d740e5906b9a5bee2e 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -1115,22 +1115,29 @@ public abstract class PlayerList {
}
private void sendPlayerPermissionLevel(ServerPlayer player, int permissionLevel) {
- if (player.connection != null) {
+ // Paper start - add recalculatePermissions parameter
+ this.sendPlayerOperatorStatus(player, permissionLevel, true);
+ }
+ public void sendPlayerOperatorStatus(ServerPlayer entityplayer, int i, boolean recalculatePermissions) {
+ // Paper end
+ if (entityplayer.connection != null) {
byte b0;
- if (permissionLevel <= 0) {
+ if (i <= 0) {
b0 = 24;
- } else if (permissionLevel >= 4) {
+ } else if (i >= 4) {
b0 = 28;
} else {
- b0 = (byte) (24 + permissionLevel);
+ b0 = (byte) (24 + i);
}
- player.connection.send(new ClientboundEntityEventPacket(player, b0));
+ entityplayer.connection.send(new ClientboundEntityEventPacket(entityplayer, b0));
}
- player.getBukkitEntity().recalculatePermissions(); // CraftBukkit
- this.server.getCommands().sendCommands(player);
+ if (recalculatePermissions) { // Paper
+ entityplayer.getBukkitEntity().recalculatePermissions(); // CraftBukkit
+ this.server.getCommands().sendCommands(entityplayer);
+ } // Paper
}
// Paper start
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index f0ea99248db07e3b992fed5d950014bcbc951370..85187e7b0d965b7930e6b2ab8d321d6d27211a35 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -552,6 +552,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
? (org.bukkit.entity.Firework) entity.getBukkitEntity()
: null;
}
+
+ @Override
+ public void sendOpLevel(byte level) {
+ Preconditions.checkArgument(level >= 0 && level <= 4, "Level must be within [0, 4]");
+
+ this.getHandle().getServer().getPlayerList().sendPlayerOperatorStatus(this.getHandle(), level, false);
+ }
// Paper end
@Override