Allowed Custom Heads to be in Faction Upgrades
This commit is contained in:
@@ -4,11 +4,17 @@ import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.util.Placeholder;
|
||||
import com.massivecraft.factions.util.XMaterial;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.UUID;
|
||||
|
||||
public enum UpgradeType {
|
||||
|
||||
@@ -59,6 +65,20 @@ public enum UpgradeType {
|
||||
meta.setLore(FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().replacePlaceholders(config.getStringList("Lore"), new Placeholder("{level}", level + ""))));
|
||||
meta.setDisplayName(FactionsPlugin.getInstance().color(config.getString("Name")));
|
||||
item.setItemMeta(meta);
|
||||
if (XMaterial.matchXMaterial(item) == XMaterial.PLAYER_HEAD && config.isSet("Texture")) {
|
||||
SkullMeta skullMeta = (SkullMeta) meta;
|
||||
GameProfile profile = new GameProfile(UUID.randomUUID(), null);
|
||||
profile.getProperties().put("textures", new Property("textures", config.getString("Texture")));
|
||||
Field profileField;
|
||||
try {
|
||||
profileField = meta.getClass().getDeclaredField("profile");
|
||||
profileField.setAccessible(true);
|
||||
profileField.set(meta, profile);
|
||||
} catch (IllegalAccessException | NoSuchFieldException | SecurityException | IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
item.setItemMeta(skullMeta);
|
||||
}
|
||||
}
|
||||
return this.updateLevelStatus(item, level);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user