PaperMC/Spigot-Server-Patches/0650-Add-sendOpLevel-API.patch

52 lines
2.2 KiB
Diff
Raw Normal View History

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/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
index f83159157d00a10a8bf93e723faf043706f83570..c970b8bec13741fcd4d5ce71fd77d0f9ed633088 100644
2020-12-29 15:04:24 +01:00
--- a/src/main/java/net/minecraft/server/PlayerList.java
+++ b/src/main/java/net/minecraft/server/PlayerList.java
2021-02-22 09:03:03 +01:00
@@ -1059,6 +1059,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;
2021-02-22 09:03:03 +01:00
@@ -1073,8 +1078,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 7d57a21517e6a7c3d3cb75ff1960f682dc7d2f50..4b214783ad4fabf5c2dc4c6c45635dc6e75f2113 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
@@ -2287,6 +2287,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