Allowed Custom Heads to be in Faction Upgrades

This commit is contained in:
Driftay 2020-01-04 12:42:53 -05:00
parent d538502457
commit 086ec3e145
3 changed files with 54 additions and 12 deletions

10
pom.xml
View File

@ -385,6 +385,12 @@
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<dependency>
<groupId>com.mojang</groupId>
<artifactId>authlib</artifactId>
<version>1.5.21</version>
<scope>compile</scope>
</dependency>
<dependency> <dependency>
<groupId>me.rayzr522</groupId> <groupId>me.rayzr522</groupId>
<artifactId>jsonmessage</artifactId> <artifactId>jsonmessage</artifactId>
@ -405,6 +411,10 @@
<name>bintray</name> <name>bintray</name>
<url>http://jcenter.bintray.com</url> <url>http://jcenter.bintray.com</url>
</repository> </repository>
<repository>
<id>mojang-repo</id>
<url>https://libraries.minecraft.net/</url>
</repository>
<repository> <repository>
<id>net.coreprotect</id> <id>net.coreprotect</id>
<url>http://maven.playpro.com/</url> <url>http://maven.playpro.com/</url>

View File

@ -4,11 +4,17 @@ import com.massivecraft.factions.Faction;
import com.massivecraft.factions.FactionsPlugin; import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.util.Placeholder; import com.massivecraft.factions.util.Placeholder;
import com.massivecraft.factions.util.XMaterial; 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.configuration.ConfigurationSection;
import org.bukkit.enchantments.Enchantment; 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.lang.reflect.Field;
import java.util.UUID;
public enum UpgradeType { 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.setLore(FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().replacePlaceholders(config.getStringList("Lore"), new Placeholder("{level}", level + ""))));
meta.setDisplayName(FactionsPlugin.getInstance().color(config.getString("Name"))); meta.setDisplayName(FactionsPlugin.getInstance().color(config.getString("Name")));
item.setItemMeta(meta); 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); return this.updateLevelStatus(item, level);
} }

View File

@ -918,7 +918,8 @@ fupgrades:
level-3: 750000 level-3: 750000
DisplayItem: DisplayItem:
Name: '&c&lGrowth Speed' 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: Lore:
- '&7&oIncrease growth &c&ospeed&7&o of crops in &c&oclaims.' - '&7&oIncrease growth &c&ospeed&7&o of crops in &c&oclaims.'
- '&7&oChance to Grow Two Levels.' - '&7&oChance to Grow Two Levels.'
@ -947,7 +948,8 @@ fupgrades:
level-3: 6000000 level-3: 6000000
DisplayItem: DisplayItem:
Name: '&c&lEXP Drop Rate' 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: Lore:
- '&7&oIncreased Vanilla &e&oEXP&7&o gained from &c&omonsters&7&o.' - '&7&oIncreased Vanilla &e&oEXP&7&o gained from &c&omonsters&7&o.'
- '&7&oYour current level is &e&l&o{level}' - '&7&oYour current level is &e&l&o{level}'
@ -975,7 +977,8 @@ fupgrades:
level-3: 3000000 level-3: 3000000
DisplayItem: DisplayItem:
Name: '&c&lFaction Power' 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: Lore:
- '&a&oIncrease&7&o the amount of &c&opower' - '&a&oIncrease&7&o the amount of &c&opower'
- '&7&oyour &a&ofaction has&7&o.' - '&7&oyour &a&ofaction has&7&o.'
@ -998,7 +1001,8 @@ fupgrades:
level-1: 1000000 level-1: 1000000
DisplayItem: DisplayItem:
Name: '&c&lUnbreakable Redstone' 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: Lore:
- '&7&oPrevents &e&owater&7&o from being' - '&7&oPrevents &e&owater&7&o from being'
- '&7&oable to break &c&oredstone' - '&7&oable to break &c&oredstone'
@ -1019,7 +1023,8 @@ fupgrades:
level-3: 3000000 level-3: 3000000
DisplayItem: DisplayItem:
Name: '&c&lSpawn Rate' 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: Lore:
- '&c&oDecreased&7&o mob spawner delay in &a&oclaims&7&o.' - '&c&oDecreased&7&o mob spawner delay in &a&oclaims&7&o.'
- '&7&oYour current level is &e&l&o{level}' - '&7&oYour current level is &e&l&o{level}'
@ -1047,7 +1052,8 @@ fupgrades:
level-3: 6000000 level-3: 6000000
DisplayItem: DisplayItem:
Name: '&c&lDamage Reduction' 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: Lore:
- '&a&oReduce&7&o the amount of &a&odamage taken&7&o in faction claims.' - '&a&oReduce&7&o the amount of &a&odamage taken&7&o in faction claims.'
- '&7&oYour current level is &e&l&o{level}' - '&7&oYour current level is &e&l&o{level}'
@ -1075,7 +1081,8 @@ fupgrades:
level-3: 6000000 level-3: 6000000
DisplayItem: DisplayItem:
Name: '&c&lDamage Increase' 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: Lore:
- '&a&oIncrease&7&o the amount of &a&odamage given&7&o.' - '&a&oIncrease&7&o the amount of &a&odamage given&7&o.'
- '&7&oYour current level is &e&l&o{level}' - '&7&oYour current level is &e&l&o{level}'
@ -1103,7 +1110,8 @@ fupgrades:
level-3: 6000000 level-3: 6000000
DisplayItem: DisplayItem:
Name: '&c&lTNT Bank' 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: Lore:
- '&a&oUpgrade&7&o your &a&ofactions tnt&7&o limit.' - '&a&oUpgrade&7&o your &a&ofactions tnt&7&o limit.'
- '&7&oYour current level is &e&l&o{level}' - '&7&oYour current level is &e&l&o{level}'
@ -1131,7 +1139,8 @@ fupgrades:
level-3: 3000000 level-3: 3000000
DisplayItem: DisplayItem:
Name: '&c&lWarps' 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: Lore:
- '&a&oIncrease&7&o the &a&ofaction warp&7&o limit.' - '&a&oIncrease&7&o the &a&ofaction warp&7&o limit.'
- '&7&oYour current level is &e&l&o{level}' - '&7&oYour current level is &e&l&o{level}'
@ -1160,7 +1169,8 @@ fupgrades:
level-3: 3000000 level-3: 3000000
DisplayItem: DisplayItem:
Name: '&c&lFaction Chest' 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: Lore:
- '&a&oIncreased&7&o Faction Chest Size.' - '&a&oIncreased&7&o Faction Chest Size.'
- '&7&oYour current level is &e&l&o{level}' - '&7&oYour current level is &e&l&o{level}'
@ -1188,7 +1198,8 @@ fupgrades:
level-3: 3000000 level-3: 3000000
DisplayItem: DisplayItem:
Name: '&c&lFaction Members' 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: Lore:
- '&a&oIncrease&7&o the &a&ofaction member&7&o limit.' - '&a&oIncrease&7&o the &a&ofaction member&7&o limit.'
- '&7&oYour current level is &e&l&o{level}' - '&7&oYour current level is &e&l&o{level}'
@ -1217,7 +1228,8 @@ fupgrades:
level-3: 3000000 level-3: 3000000
DisplayItem: DisplayItem:
Name: '&c&lReinforced Armor' 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: Lore:
- '&a&oDecreases&7&o damage done &a&oto armor&7&o.' - '&a&oDecreases&7&o damage done &a&oto armor&7&o.'
- '&7&oYour current level is &e&l&o{level}' - '&7&oYour current level is &e&l&o{level}'