From 086ec3e145aa5f0839998d830b4e248fa9f9e59a Mon Sep 17 00:00:00 2001 From: Driftay Date: Sat, 4 Jan 2020 12:42:53 -0500 Subject: [PATCH] Allowed Custom Heads to be in Faction Upgrades --- pom.xml | 10 ++++++ .../factions/zcore/fupgrades/UpgradeType.java | 20 +++++++++++ src/main/resources/config.yml | 36 ++++++++++++------- 3 files changed, 54 insertions(+), 12 deletions(-) diff --git a/pom.xml b/pom.xml index c26f0b14..3df591f0 100644 --- a/pom.xml +++ b/pom.xml @@ -385,6 +385,12 @@ + + com.mojang + authlib + 1.5.21 + compile + me.rayzr522 jsonmessage @@ -405,6 +411,10 @@ bintray http://jcenter.bintray.com + + mojang-repo + https://libraries.minecraft.net/ + net.coreprotect http://maven.playpro.com/ diff --git a/src/main/java/com/massivecraft/factions/zcore/fupgrades/UpgradeType.java b/src/main/java/com/massivecraft/factions/zcore/fupgrades/UpgradeType.java index 7bed847a..8a100afe 100644 --- a/src/main/java/com/massivecraft/factions/zcore/fupgrades/UpgradeType.java +++ b/src/main/java/com/massivecraft/factions/zcore/fupgrades/UpgradeType.java @@ -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); } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index ae1850bd..eb376d95 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -918,7 +918,8 @@ fupgrades: level-3: 750000 DisplayItem: Name: '&c&lGrowth Speed' - Type: WHEAT + Type: WHEAT #MUST BE PLAYER_HEAD FOR TEXTURE TO WORK! + Texture: '' #Hash of skull here from minecraft-heads.com Lore: - '&7&oIncrease growth &c&ospeed&7&o of crops in &c&oclaims.' - '&7&oChance to Grow Two Levels.' @@ -947,7 +948,8 @@ fupgrades: level-3: 6000000 DisplayItem: Name: '&c&lEXP Drop Rate' - Type: EXP_BOTTLE + Type: EXP_BOTTLE #MUST BE PLAYER_HEAD FOR TEXTURE TO WORK! + Texture: '' #Hash of skull here from minecraft-heads.com Lore: - '&7&oIncreased Vanilla &e&oEXP&7&o gained from &c&omonsters&7&o.' - '&7&oYour current level is &e&l&o{level}' @@ -975,7 +977,8 @@ fupgrades: level-3: 3000000 DisplayItem: Name: '&c&lFaction Power' - Type: NETHER_STAR + Type: NETHER_STAR #MUST BE PLAYER_HEAD FOR TEXTURE TO WORK! + Texture: '' #Hash of skull here from minecraft-heads.com Lore: - '&a&oIncrease&7&o the amount of &c&opower' - '&7&oyour &a&ofaction has&7&o.' @@ -998,7 +1001,8 @@ fupgrades: level-1: 1000000 DisplayItem: Name: '&c&lUnbreakable Redstone' - Type: REDSTONE + Type: REDSTONE #MUST BE PLAYER_HEAD FOR TEXTURE TO WORK! + Texture: '' #Hash of skull here from minecraft-heads.com Lore: - '&7&oPrevents &e&owater&7&o from being' - '&7&oable to break &c&oredstone' @@ -1019,7 +1023,8 @@ fupgrades: level-3: 3000000 DisplayItem: Name: '&c&lSpawn Rate' - Type: MOB_SPAWNER + Type: MOB_SPAWNER #MUST BE PLAYER_HEAD FOR TEXTURE TO WORK! + Texture: '' #Hash of skull here from minecraft-heads.com Lore: - '&c&oDecreased&7&o mob spawner delay in &a&oclaims&7&o.' - '&7&oYour current level is &e&l&o{level}' @@ -1047,7 +1052,8 @@ fupgrades: level-3: 6000000 DisplayItem: Name: '&c&lDamage Reduction' - Type: GOLD_CHESTPLATE + Type: GOLD_CHESTPLATE #MUST BE PLAYER_HEAD FOR TEXTURE TO WORK! + Texture: '' #Hash of skull here from minecraft-heads.com Lore: - '&a&oReduce&7&o the amount of &a&odamage taken&7&o in faction claims.' - '&7&oYour current level is &e&l&o{level}' @@ -1075,7 +1081,8 @@ fupgrades: level-3: 6000000 DisplayItem: Name: '&c&lDamage Increase' - Type: DIAMOND_SWORD + Type: DIAMOND_SWORD #MUST BE PLAYER_HEAD FOR TEXTURE TO WORK! + Texture: '' #Hash of skull here from minecraft-heads.com Lore: - '&a&oIncrease&7&o the amount of &a&odamage given&7&o.' - '&7&oYour current level is &e&l&o{level}' @@ -1103,7 +1110,8 @@ fupgrades: level-3: 6000000 DisplayItem: Name: '&c&lTNT Bank' - Type: TNT + Type: TNT #MUST BE PLAYER_HEAD FOR TEXTURE TO WORK! + Texture: '' #Hash of skull here from minecraft-heads.com Lore: - '&a&oUpgrade&7&o your &a&ofactions tnt&7&o limit.' - '&7&oYour current level is &e&l&o{level}' @@ -1131,7 +1139,8 @@ fupgrades: level-3: 3000000 DisplayItem: Name: '&c&lWarps' - Type: EYE_OF_ENDER + Type: EYE_OF_ENDER #MUST BE PLAYER_HEAD FOR TEXTURE TO WORK! + Texture: '' #Hash of skull here from minecraft-heads.com Lore: - '&a&oIncrease&7&o the &a&ofaction warp&7&o limit.' - '&7&oYour current level is &e&l&o{level}' @@ -1160,7 +1169,8 @@ fupgrades: level-3: 3000000 DisplayItem: Name: '&c&lFaction Chest' - Type: CHEST + Type: CHEST #MUST BE PLAYER_HEAD FOR TEXTURE TO WORK! + Texture: '' #Hash of skull here from minecraft-heads.com Lore: - '&a&oIncreased&7&o Faction Chest Size.' - '&7&oYour current level is &e&l&o{level}' @@ -1188,7 +1198,8 @@ fupgrades: level-3: 3000000 DisplayItem: Name: '&c&lFaction Members' - Type: PAPER + Type: PAPER #MUST BE PLAYER_HEAD FOR TEXTURE TO WORK! + Texture: '' #Hash of skull here from minecraft-heads.com Lore: - '&a&oIncrease&7&o the &a&ofaction member&7&o limit.' - '&7&oYour current level is &e&l&o{level}' @@ -1217,7 +1228,8 @@ fupgrades: level-3: 3000000 DisplayItem: Name: '&c&lReinforced Armor' - Type: DIAMOND_CHESTPLATE + Type: DIAMOND_CHESTPLATE #MUST BE PLAYER_HEAD FOR TEXTURE TO WORK! + Texture: '' #Hash of skull here from minecraft-heads.com Lore: - '&a&oDecreases&7&o damage done &a&oto armor&7&o.' - '&7&oYour current level is &e&l&o{level}'