3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-15 12:30:06 +01:00
Paper/patches/server/0496-Add-sendOpLevel-API.patch
2024-01-25 00:41:51 +01:00

54 Zeilen
2.5 KiB
Diff

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 e629a560ae2163ea45ede727b97a301e8fa6f1e8..f336b52a529c3c0ddccb36ace8b441fba61b99dd 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -1100,6 +1100,11 @@ public abstract class PlayerList {
}
private void sendPlayerPermissionLevel(ServerPlayer player, int permissionLevel) {
+ // Paper start - Add sendOpLevel API
+ this.sendPlayerPermissionLevel(player, permissionLevel, true);
+ }
+ public void sendPlayerPermissionLevel(ServerPlayer player, int permissionLevel, boolean recalculatePermissions) {
+ // Paper end - Add sendOpLevel API
if (player.connection != null) {
byte b0;
@@ -1114,8 +1119,10 @@ public abstract class PlayerList {
player.connection.send(new ClientboundEntityEventPacket(player, b0));
}
+ if (recalculatePermissions) { // Paper - Add sendOpLevel API
player.getBukkitEntity().recalculatePermissions(); // CraftBukkit
this.server.getCommands().sendCommands(player);
+ } // Paper - Add sendOpLevel API
}
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 eccc82f4c8eeb3a2b6ae2abbd1a38d447a2bfda8..537590236e9a0ac2946953ebbebe0044e17ccc72 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -591,6 +591,15 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
}
// Paper end
+ // Paper start - Add sendOpLevel API
+ @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 - Add sendOpLevel API
+
@Override
public void setCompassTarget(Location loc) {
Preconditions.checkArgument(loc != null, "Location cannot be null");