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 8b683ffd930155adf7b1cd1088322621d4e0a037..e287ed6e916e750ac8e87a5025b9f1503470d1cf 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java @@ -1079,6 +1079,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; @@ -1093,8 +1098,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 c4b5267263fdf5b1a7d94ac3f5fd5212d026cefd..48e6d04473a5c7c66f0d66b8aa119e8da755f321 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -662,6 +662,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