3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-15 20:40:07 +01:00
Paper/Spigot-Server-Patches/0650-Add-sendOpLevel-API.patch

52 Zeilen
2.3 KiB
Diff

2020-12-29 15:04:24 +01: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 0a84f70371dc458ccaa567e917706ecd8b6bbefa..5a371a7ce4cc70d5916b87874a960427c882f9b1 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -1129,6 +1129,11 @@ public abstract class PlayerList {
2020-12-29 15:04:24 +01:00
}
private void a(EntityPlayer entityplayer, int i) {
+ // Paper start - add recalculatePermissions parameter
+ this.sendPlayerOperatorStatus(entityplayer, i, true);
+ }
+ public void sendPlayerOperatorStatus(EntityPlayer entityplayer, int i, boolean recalculatePermissions) {
+ // Paper end
if (entityplayer.playerConnection != null) {
byte b0;
@@ -1143,8 +1148,10 @@ public abstract class PlayerList {
2020-12-29 15:04:24 +01:00
entityplayer.playerConnection.sendPacket(new PacketPlayOutEntityStatus(entityplayer, b0));
}
+ if (recalculatePermissions) { // Paper
entityplayer.getBukkitEntity().recalculatePermissions(); // CraftBukkit
this.server.getCommandDispatcher().a(entityplayer);
+ } // Paper
}
// Paper start
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 9fdd17865bf8fe0fd0704846652b8f593808f664..21304d60f90dbf2254ebf19cfda372f8c6d7c7f1 100644
2020-12-29 15:04:24 +01:00
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -2288,6 +2288,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
2020-12-29 15:04:24 +01: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().getMinecraftServer().getPlayerList().sendPlayerOperatorStatus(this.getHandle(), level, false);
+ }
// Paper end
// Spigot start