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 a973d0032da0e2540dc4ed5b28850fb147e01ac6..a7ec827bac431e7022a07e9071dcec5b7e54da2f 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java @@ -1086,6 +1086,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; @@ -1100,8 +1105,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 bf9844dcff3ceca0f059baad5569a168597e7c4a..f46cd227faa3cfc9a8c660516afd8e0209f991d6 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -588,6 +588,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().sendPlayerPermissionLevel(this.getHandle(), level, false); + } // Paper end @Override