2021-06-11 12:02:28 +00:00
|
|
|
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
|
2021-06-14 19:58:32 +00:00
|
|
|
index 9a37a962b141e9faecc9f6f4906a9d727d20c20a..d01712cad42c078a726d6f757a4d8f0e3f186274 100644
|
2021-06-11 12:02:28 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
|
2021-06-14 19:58:32 +00:00
|
|
|
@@ -1113,22 +1113,29 @@ public abstract class PlayerList {
|
2021-06-11 12:02:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
2021-06-14 19:58:32 +00:00
|
|
|
index 9236027beb13ae4f2e35c46f6c176fd5d7d20b4f..a9fdf153a9442830c7ce9e8fb6147b2c7b33db55 100644
|
2021-06-11 12:02:28 +00:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
2021-06-14 19:58:32 +00:00
|
|
|
@@ -548,6 +548,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
2021-06-11 12:02:28 +00:00
|
|
|
? (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
|
|
|
|
|
2021-06-14 19:58:32 +00:00
|
|
|
@Override
|