9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2026-01-04 15:41:40 +00:00
Files
Leaf/leaf-server/paper-patches/features/0025-KeYi-Player-Skull-API.patch
Dreeam 3b162fb788 Move Purpur patches to first
To reduce the difficulty on maintenance and reduce chances to fix conflicts on updating
2025-10-01 18:27:42 -04:00

45 lines
1.9 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 4e24a177aed7eda0899b4a1a1e308f02a16c5718..2ab6ca0c7ec5e6358a0fd8e93852c99cb0456e18 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -3623,4 +3623,31 @@ public class CraftPlayer extends CraftHumanEntity implements Player, PluginMessa
public PlayerGameConnection getConnection() {
return this.getHandle().connection.playerGameConnection;
}
+
+ // 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
}