9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-19 15:09:25 +00:00
Files
Leaf/leaf-server/paper-patches/features/0008-KeYi-Player-Skull-API.patch
Dreeam c36c34cf85 Updated Upstream (Paper/Gale)
Upstream has released updates that appear to apply and compile correctly

Paper Changes:
PaperMC/Paper@9b1798d6 Simplify custom payload handling (#12347)

Gale Changes:
Dreeam-qwq/Gale@ffc98037 Updated Upstream (Paper)
2025-03-27 16:24:19 -04:00

45 lines
2.0 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: nostalgic853 <yuu8583@proton.me>
Date: Sun, 20 Nov 2022 00:20:00 +0800
Subject: [PATCH] KeYi: Player Skull API
Original license: MIT
Original project: https://github.com/KeYiMC/KeYi
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 3ba69aa0ac247ecb3406664af606126b30c56ff9..e0ab197ef364b7a95e1f5beade5f55c2744b8edc 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -3719,4 +3719,31 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
this.getHandle().connection.send(new net.minecraft.network.protocol.game.ClientboundPlayerCombatKillPacket(getEntityId(), io.papermc.paper.adventure.PaperAdventure.asVanilla(message)));
}
// Purpur end - Death screen API
+
+ // Leaf start - KeYi - Player Skull API
+ @Override
+ public ItemStack getSkull() {
+ ItemStack skull = new ItemStack(Material.PLAYER_HEAD, 1);
+ org.bukkit.inventory.meta.SkullMeta meta = (org.bukkit.inventory.meta.SkullMeta) skull.getItemMeta();
+
+ meta.setOwningPlayer(this);
+ skull.setItemMeta(meta);
+
+ return skull;
+ }
+
+ @Override
+ @Deprecated(forRemoval = true)
+ public CompletableFuture<ItemStack> getSkullAsynchronously() {
+ org.apache.logging.log4j.LogManager.getLogger("Leaf")
+ .warn("You should not use this method: Player#getSkullAsynchronously(), cause low performance, " +
+ "and will be removed in the future.");
+ java.util.concurrent.ExecutorService executorService = java.util.concurrent.Executors.newCachedThreadPool();
+
+ CompletableFuture<ItemStack> future = (CompletableFuture<ItemStack>) executorService.submit(this::getSkull);
+ executorService.shutdown();
+
+ return future;
+ }
+ // Leaf end - KeYi - Player Skull API
}