SteamWar/SpigotCore
Archiviert
13
0

Fixing Skull generation for 1.14+

Dieser Commit ist enthalten in:
Lixfel 2019-12-31 14:57:04 +01:00
Ursprung 5fe26b7d95
Commit 5efe47a619
7 geänderte Dateien mit 41 neuen und 26 gelöschten Zeilen

Datei anzeigen

@ -2,7 +2,7 @@ package de.steamwar.inventory;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.inventory.ItemStack;
class SWItem_10 { class SWItem_10 {
private SWItem_10(){} private SWItem_10(){}
@ -15,7 +15,7 @@ class SWItem_10 {
return SWItem_8.getDye(); return SWItem_8.getDye();
} }
static void setSkullOwner(OfflinePlayer player, SkullMeta meta){ static ItemStack setSkullOwner(OfflinePlayer player){
SWItem_8.setSkullOwner(player, meta); return SWItem_8.setSkullOwner(player);
} }
} }

Datei anzeigen

@ -2,6 +2,7 @@ package de.steamwar.inventory;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.inventory.meta.SkullMeta;
class SWItem_12 { class SWItem_12 {
@ -15,7 +16,12 @@ class SWItem_12 {
return SWItem_8.getDye(); return SWItem_8.getDye();
} }
static void setSkullOwner(OfflinePlayer player, SkullMeta meta){ static ItemStack setSkullOwner(OfflinePlayer player){
meta.setOwningPlayer(player); ItemStack head = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
SkullMeta headmeta = (SkullMeta) head.getItemMeta();
headmeta.setOwningPlayer(player);
headmeta.setDisplayName(player.getName());
head.setItemMeta(headmeta);
return head;
} }
} }

Datei anzeigen

@ -2,6 +2,7 @@ package de.steamwar.inventory;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.inventory.meta.SkullMeta;
class SWItem_14 { class SWItem_14 {
@ -48,7 +49,13 @@ class SWItem_14 {
} }
} }
static void setSkullOwner(OfflinePlayer player, SkullMeta meta){ static ItemStack setSkullOwner(OfflinePlayer player){
SWItem_12.setSkullOwner(player, meta); ItemStack head = new ItemStack(Material.PLAYER_HEAD, 1);
SkullMeta headmeta = (SkullMeta) head.getItemMeta();
assert headmeta != null;
headmeta.setOwningPlayer(player);
headmeta.setDisplayName(player.getName());
head.setItemMeta(headmeta);
return head;
} }
} }

Datei anzeigen

@ -2,7 +2,7 @@ package de.steamwar.inventory;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.inventory.ItemStack;
class SWItem_15 { class SWItem_15 {
private SWItem_15(){} private SWItem_15(){}
@ -15,7 +15,7 @@ class SWItem_15 {
return SWItem_14.getDye(colorCode); return SWItem_14.getDye(colorCode);
} }
static void setSkullOwner(OfflinePlayer player, SkullMeta meta){ static ItemStack setSkullOwner(OfflinePlayer player){
SWItem_12.setSkullOwner(player, meta); return SWItem_14.setSkullOwner(player);
} }
} }

Datei anzeigen

@ -2,6 +2,7 @@ package de.steamwar.inventory;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.inventory.meta.SkullMeta;
class SWItem_8 { class SWItem_8 {
@ -15,7 +16,12 @@ class SWItem_8 {
return Material.INK_SACK; return Material.INK_SACK;
} }
static void setSkullOwner(OfflinePlayer player, SkullMeta meta){ static ItemStack setSkullOwner(OfflinePlayer player){
meta.setOwner(player.getName()); ItemStack head = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
SkullMeta headmeta = (SkullMeta) head.getItemMeta();
headmeta.setOwner(player.getName());
headmeta.setDisplayName(player.getName());
head.setItemMeta(headmeta);
return head;
} }
} }

Datei anzeigen

@ -2,7 +2,7 @@ package de.steamwar.inventory;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.inventory.ItemStack;
class SWItem_9 { class SWItem_9 {
private SWItem_9(){} private SWItem_9(){}
@ -15,7 +15,7 @@ class SWItem_9 {
return SWItem_8.getDye(); return SWItem_8.getDye();
} }
static void setSkullOwner(OfflinePlayer player, SkullMeta meta){ static ItemStack setSkullOwner(OfflinePlayer player){
SWItem_8.setSkullOwner(player, meta); return SWItem_8.setSkullOwner(player);
} }
} }

Datei anzeigen

@ -7,7 +7,6 @@ import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SkullMeta;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -20,29 +19,26 @@ public class SWItem {
public static SWItem getPlayerSkull(OfflinePlayer player){ public static SWItem getPlayerSkull(OfflinePlayer player){
SWItem p = new SWItem(); SWItem p = new SWItem();
ItemStack head = new ItemStack(getMaterial("SKULL_ITEM"), 1, (short) 3); ItemStack head;
SkullMeta headmeta = (SkullMeta) head.getItemMeta();
switch(Core.getVersion()){ switch(Core.getVersion()){
case 8: case 8:
SWItem_8.setSkullOwner(player, headmeta); head = SWItem_8.setSkullOwner(player);
break; break;
case 9: case 9:
SWItem_9.setSkullOwner(player, headmeta); head = SWItem_9.setSkullOwner(player);
break; break;
case 10: case 10:
SWItem_10.setSkullOwner(player, headmeta); head = SWItem_10.setSkullOwner(player);
break; break;
case 14: case 14:
SWItem_14.setSkullOwner(player, headmeta); head = SWItem_14.setSkullOwner(player);
break; break;
case 15: case 15:
SWItem_15.setSkullOwner(player, headmeta); head = SWItem_15.setSkullOwner(player);
break; break;
default: default:
SWItem_12.setSkullOwner(player, headmeta); head = SWItem_12.setSkullOwner(player);
} }
headmeta.setDisplayName(player.getName());
head.setItemMeta(headmeta);
p.setItemStack(head); p.setItemStack(head);
return p; return p;
} }