mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-23 17:09:29 +00:00
62 lines
2.2 KiB
Diff
62 lines
2.2 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 c8d8ab8e5d8d0a986ff023ce1e195667472d7798..b44e3c4fed830ead7c786ed7b3fad4789f185ead 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
@@ -25,6 +25,11 @@ import java.util.Optional;
|
|
import java.util.Set;
|
|
import java.util.UUID;
|
|
import java.util.WeakHashMap;
|
|
+// KeYi start
|
|
+import java.util.concurrent.CompletableFuture;
|
|
+import java.util.concurrent.ExecutorService;
|
|
+import java.util.concurrent.Executors;
|
|
+// KeYi end
|
|
import java.util.logging.Level;
|
|
import java.util.logging.Logger;
|
|
import javax.annotation.Nullable;
|
|
@@ -148,6 +153,7 @@ import org.bukkit.event.player.PlayerUnregisterChannelEvent;
|
|
import org.bukkit.inventory.EquipmentSlot;
|
|
import org.bukkit.inventory.InventoryView.Property;
|
|
import org.bukkit.inventory.ItemStack;
|
|
+import org.bukkit.inventory.meta.SkullMeta;
|
|
import org.bukkit.map.MapCursor;
|
|
import org.bukkit.map.MapView;
|
|
import org.bukkit.metadata.MetadataValue;
|
|
@@ -3188,4 +3194,28 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|
return this.spigot;
|
|
}
|
|
// Spigot end
|
|
+
|
|
+ // KeYi start
|
|
+ @Override
|
|
+ public ItemStack getSkull() {
|
|
+ ItemStack skull = new ItemStack(Material.PLAYER_HEAD, 1);
|
|
+ SkullMeta meta = (SkullMeta) skull.getItemMeta();
|
|
+
|
|
+ meta.setOwningPlayer(this);
|
|
+
|
|
+ skull.setItemMeta(meta);
|
|
+
|
|
+ return skull;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public CompletableFuture<ItemStack> getSkullAsynchronously() {
|
|
+ ExecutorService executorService = Executors.newCachedThreadPool();
|
|
+
|
|
+ CompletableFuture<ItemStack> future = (CompletableFuture<ItemStack>) executorService.submit(() -> getSkull());
|
|
+ executorService.shutdown();
|
|
+
|
|
+ return future;
|
|
+ }
|
|
+ // KeYi end
|
|
}
|