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

54 lines
2.5 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
2024-06-14 01:32:45 +02:00
index 5a709e301b336ee2fc62b422a2f3d878b81f9743..f9ecdb537b7cbf4a97888a88a61686d9a2847cd6 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
2024-06-13 22:57:13 +02:00
@@ -1062,6 +1062,11 @@ public abstract class PlayerList {
2021-06-11 14:02:28 +02:00
}
private void sendPlayerPermissionLevel(ServerPlayer player, int permissionLevel) {
+ // Paper start - Add sendOpLevel API
+ this.sendPlayerPermissionLevel(player, permissionLevel, true);
2021-06-11 14:02:28 +02:00
+ }
+ public void sendPlayerPermissionLevel(ServerPlayer player, int permissionLevel, boolean recalculatePermissions) {
+ // Paper end - Add sendOpLevel API
if (player.connection != null) {
2021-06-11 14:02:28 +02:00
byte b0;
2024-06-13 22:57:13 +02:00
@@ -1076,8 +1081,10 @@ public abstract class PlayerList {
player.connection.send(new ClientboundEntityEventPacket(player, b0));
2021-06-11 14:02:28 +02:00
}
+ if (recalculatePermissions) { // Paper - Add sendOpLevel API
player.getBukkitEntity().recalculatePermissions(); // CraftBukkit
this.server.getCommands().sendCommands(player);
+ } // Paper - Add sendOpLevel API
2021-06-11 14:02:28 +02:00
}
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
2024-06-13 22:57:13 +02:00
index 721f4fb6bc18fc3ca6a22e8a42f564220042fa42..0c224de84b797856814f5378c87e6d048205e8d9 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
2024-06-13 22:57:13 +02:00
@@ -677,6 +677,15 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
2021-06-11 14:02:28 +02:00
}
// Paper end
+ // Paper start - Add sendOpLevel API
2021-06-11 14:02:28 +02:00
+ @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 - Add sendOpLevel API
+
2021-06-14 21:58:32 +02:00
@Override
public void setCompassTarget(Location loc) {
Preconditions.checkArgument(loc != null, "Location cannot be null");