testserver/patches/server/0569-Add-sendOpLevel-API.patch

52 lines
2.3 KiB
Diff
Raw Normal View History

2021-06-11 12:02:28 +00:00
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 54fff5ebefa04f64ed1abfd12ebf48762015fae3..c4f5a3bf60302743329b17f9b2dffcee9c1e5ab3 100644
2021-06-11 12:02:28 +00:00
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -1130,6 +1130,11 @@ public abstract class PlayerList {
2021-06-11 12:02:28 +00:00
}
private void sendPlayerPermissionLevel(ServerPlayer player, int permissionLevel) {
+ // Paper start - add recalculatePermissions parameter
+ this.sendPlayerPermissionLevel(player, permissionLevel, true);
2021-06-11 12:02:28 +00:00
+ }
+ public void sendPlayerPermissionLevel(ServerPlayer player, int permissionLevel, boolean recalculatePermissions) {
2021-06-11 12:02:28 +00:00
+ // Paper end
if (player.connection != null) {
2021-06-11 12:02:28 +00:00
byte b0;
@@ -1144,8 +1149,10 @@ public abstract class PlayerList {
player.connection.send(new ClientboundEntityEventPacket(player, b0));
2021-06-11 12:02:28 +00:00
}
+ if (recalculatePermissions) { // Paper
player.getBukkitEntity().recalculatePermissions(); // CraftBukkit
this.server.getCommands().sendCommands(player);
2021-06-11 12:02:28 +00:00
+ } // Paper
}
2022-06-08 07:30:41 +00:00
public boolean isWhiteListed(GameProfile profile) {
2021-06-11 12:02:28 +00:00
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 6731b20689ad3781d2b800826d059044c2c75c66..50a6aaa4216ba39f2b3b480be7b5953acac08847 100644
2021-06-11 12:02:28 +00:00
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -612,6 +612,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
2021-06-11 12:02:28 +00:00
? (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);
2021-06-11 12:02:28 +00:00
+ }
// Paper end
2021-06-14 19:58:32 +00:00
@Override