aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0530-Add-sendOpLevel-API.patch
blob: 9278d614ffa4cc46bf5e9e3f031f7663806eab49 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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 9b56415f1a03423f29822839ce27bbdf33bb91d5..89d18ae87029b82beea5e1bd69580f54f600696f 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -1080,6 +1080,11 @@ public abstract class PlayerList {
     }
 
     private void sendPlayerPermissionLevel(ServerPlayer player, int permissionLevel) {
+        // Paper start - add recalculatePermissions parameter
+        this.sendPlayerPermissionLevel(player, permissionLevel, true);
+    }
+    public void sendPlayerPermissionLevel(ServerPlayer player, int permissionLevel, boolean recalculatePermissions) {
+        // Paper end
         if (player.connection != null) {
             byte b0;
 
@@ -1094,8 +1099,10 @@ public abstract class PlayerList {
             player.connection.send(new ClientboundEntityEventPacket(player, b0));
         }
 
+        if (recalculatePermissions) { // Paper
         player.getBukkitEntity().recalculatePermissions(); // CraftBukkit
         this.server.getCommands().sendCommands(player);
+        } // Paper
     }
 
     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 1f742a39d1f31ef27cb4e662a6c3935600728d0b..69d0694f2f25ce51f40c7cd283e1591fe05ffe2c 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -628,6 +628,15 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
     }
     // Paper end
 
+    // Paper start - 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 - sendOpLevel API
+
     @Override
     public void setCompassTarget(Location loc) {
         Preconditions.checkArgument(loc != null, "Location cannot be null");