From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Mariell Hoversholm 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 fbe10666c4ec6caa95aa38a6f99ccca700e9a4d2..061bba184c8bc2569ce1d413435ec1360fa14007 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java @@ -1025,6 +1025,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; @@ -1039,8 +1044,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 a631d35100b1910b717e359d3f27918a95a7a2cf..14adc60ba3e76ce71bc957d0a41383c3f1413b34 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -682,6 +682,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");