aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0474-Add-sendOpLevel-API.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patches/server/0474-Add-sendOpLevel-API.patch')
-rw-r--r--patches/server/0474-Add-sendOpLevel-API.patch53
1 files changed, 53 insertions, 0 deletions
diff --git a/patches/server/0474-Add-sendOpLevel-API.patch b/patches/server/0474-Add-sendOpLevel-API.patch
new file mode 100644
index 0000000000..ad4f27d640
--- /dev/null
+++ b/patches/server/0474-Add-sendOpLevel-API.patch
@@ -0,0 +1,53 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Mariell Hoversholm <[email protected]>
+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 846132dad557b04a3d52184cfb1c0dd35673f8c6..5100b2d00452f97849239ca32164eed4345e4024 100644
+--- a/src/main/java/net/minecraft/server/players/PlayerList.java
++++ b/src/main/java/net/minecraft/server/players/PlayerList.java
+@@ -1062,6 +1062,11 @@ public abstract class PlayerList {
+ }
+
+ private void sendPlayerPermissionLevel(ServerPlayer player, int permissionLevel) {
++ // Paper start - Add sendOpLevel API
++ this.sendPlayerPermissionLevel(player, permissionLevel, true);
++ }
++ public void sendPlayerPermissionLevel(ServerPlayer player, int permissionLevel, boolean recalculatePermissions) {
++ // Paper end - Add sendOpLevel API
+ if (player.connection != null) {
+ byte b0;
+
+@@ -1076,8 +1081,10 @@ public abstract class PlayerList {
+ player.connection.send(new ClientboundEntityEventPacket(player, b0));
+ }
+
++ if (recalculatePermissions) { // Paper - Add sendOpLevel API
+ player.getBukkitEntity().recalculatePermissions(); // CraftBukkit
+ this.server.getCommands().sendCommands(player);
++ } // Paper - Add sendOpLevel API
+ }
+
+ public boolean isWhiteListed(GameProfile profile) {
+diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+index 803a1d9350276c44eef622436cc4026460436ae7..6924bf3fad82cd055523af835a83aa0ca3490625 100644
+--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+@@ -677,6 +677,15 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
+ }
+ // Paper end
+
++ // Paper start - Add sendOpLevel API
++ @Override
++ public void sendOpLevel(byte level) {
++ Preconditions.checkArgument(level >= 0 && level <= 4, "Level must be within [0, 4]");
++
++ this.getHandle().getServer().getPlayerList().sendPlayerPermissionLevel(this.getHandle(), level, false);
++ }
++ // Paper end - Add sendOpLevel API
++
+ @Override
+ public void setCompassTarget(Location loc) {
+ Preconditions.checkArgument(loc != null, "Location cannot be null");