Paper/patches/server/0566-Add-sendOpLevel-API.patch

52 lines
2.3 KiB
Diff
Raw Normal View History

2021-06-11 14:02:28 +02: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
2022-06-08 09:30:41 +02:00
index 9a27895d9528dd10e196fe7e7d2fb9d7561fa704..7662e4f590d9e3146783239a662b452741b97147 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -1123,6 +1123,11 @@ public abstract class PlayerList {
2021-06-11 14:02:28 +02:00
}
private void sendPlayerPermissionLevel(ServerPlayer player, int permissionLevel) {
+ // Paper start - add recalculatePermissions parameter
+ this.sendPlayerPermissionLevel(player, permissionLevel, true);
2021-06-11 14:02:28 +02:00
+ }
+ public void sendPlayerPermissionLevel(ServerPlayer player, int permissionLevel, boolean recalculatePermissions) {
2021-06-11 14:02:28 +02:00
+ // Paper end
if (player.connection != null) {
2021-06-11 14:02:28 +02:00
byte b0;
@@ -1137,8 +1142,10 @@ public abstract class PlayerList {
player.connection.send(new ClientboundEntityEventPacket(player, b0));
2021-06-11 14:02:28 +02:00
}
+ if (recalculatePermissions) { // Paper
player.getBukkitEntity().recalculatePermissions(); // CraftBukkit
this.server.getCommands().sendCommands(player);
2021-06-11 14:02:28 +02:00
+ } // Paper
}
2022-06-08 09:30:41 +02:00
public boolean isWhiteListed(GameProfile profile) {
2021-06-11 14:02:28 +02:00
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index d4348385ee8330398bfe543311c9256e93334861..91027504dd2963806ec52f773fc768a1288e15f2 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -606,6 +606,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
2021-06-11 14:02:28 +02: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 14:02:28 +02:00
+ }
// Paper end
2021-06-14 21:58:32 +02:00
@Override