This commit is contained in:
rockyhawk64 2022-08-15 14:57:48 +10:00
parent 39b3e5917a
commit 57864c13d5
3 changed files with 9 additions and 7 deletions

View File

@ -1,4 +1,4 @@
version: 3.18.1.1 version: 3.18.1.2
main: me.rockyhawk.commandpanels.CommandPanels main: me.rockyhawk.commandpanels.CommandPanels
name: CommandPanels name: CommandPanels
author: RockyHawk author: RockyHawk

View File

@ -15,6 +15,7 @@ import org.bukkit.block.banner.PatternType;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.enchantments.EnchantmentWrapper;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemFlag;
@ -251,11 +252,11 @@ public class ItemCreation {
EnchantMeta = s.getItemMeta(); EnchantMeta = s.getItemMeta();
assert EnchantMeta != null; assert EnchantMeta != null;
for(String enchantment : itemSection.getStringList("enchanted")){ for(String enchantment : itemSection.getStringList("enchanted")){
EnchantMeta.addEnchant(Objects.requireNonNull(Enchantment.getByKey(NamespacedKey.minecraft(enchantment.split("\\s")[0].toLowerCase()))), Integer.parseInt(enchantment.split("\\s")[1]), true); EnchantMeta.addEnchant(Objects.requireNonNull(EnchantmentWrapper.getByKey(NamespacedKey.minecraft(enchantment.split("\\s")[0].toLowerCase()))), Integer.parseInt(enchantment.split("\\s")[1]), true);
} }
s.setItemMeta(EnchantMeta); s.setItemMeta(EnchantMeta);
}else if (Objects.requireNonNull(itemSection.getString("enchanted")).trim().equalsIgnoreCase("true")) { }else if (Objects.requireNonNull(itemSection.getString("enchanted")).trim().equalsIgnoreCase("true")) {
//if used if enchanted is set to true //is used if enchanted is set to true
EnchantMeta = s.getItemMeta(); EnchantMeta = s.getItemMeta();
assert EnchantMeta != null; assert EnchantMeta != null;
EnchantMeta.addEnchant(Enchantment.KNOCKBACK, 1, false); EnchantMeta.addEnchant(Enchantment.KNOCKBACK, 1, false);
@ -265,7 +266,7 @@ public class ItemCreation {
//if used to ensure enchanted does not equal false but equals something else //if used to ensure enchanted does not equal false but equals something else
EnchantMeta = s.getItemMeta(); EnchantMeta = s.getItemMeta();
assert EnchantMeta != null; assert EnchantMeta != null;
EnchantMeta.addEnchant(Objects.requireNonNull(Enchantment.getByKey(NamespacedKey.minecraft(Objects.requireNonNull(itemSection.getString("enchanted")).split("\\s")[0].toLowerCase()))), Integer.parseInt(Objects.requireNonNull(itemSection.getString("enchanted")).split("\\s")[1]), true); EnchantMeta.addEnchant(Objects.requireNonNull(EnchantmentWrapper.getByKey(NamespacedKey.minecraft(Objects.requireNonNull(itemSection.getString("enchanted")).split("\\s")[0].toLowerCase()))), Integer.parseInt(Objects.requireNonNull(itemSection.getString("enchanted")).split("\\s")[1]), true);
s.setItemMeta(EnchantMeta); s.setItemMeta(EnchantMeta);
} }
} catch (Exception ench) { } catch (Exception ench) {
@ -284,6 +285,7 @@ public class ItemCreation {
BannerMeta bannerMeta = (BannerMeta) s.getItemMeta(); BannerMeta bannerMeta = (BannerMeta) s.getItemMeta();
List<Pattern> patterns = new ArrayList<>(); //Load patterns in order top to bottom List<Pattern> patterns = new ArrayList<>(); //Load patterns in order top to bottom
for (String temp : itemSection.getStringList("banner")) { for (String temp : itemSection.getStringList("banner")) {
temp = plugin.tex.placeholders(panel,position,p,temp);
String[] dyePattern = temp.split(","); String[] dyePattern = temp.split(",");
patterns.add(new Pattern(DyeColor.valueOf(dyePattern[0]), PatternType.valueOf(dyePattern[1]))); //load patterns in config: RED:STRIPE_TOP patterns.add(new Pattern(DyeColor.valueOf(dyePattern[0]), PatternType.valueOf(dyePattern[1]))); //load patterns in config: RED:STRIPE_TOP
} }
@ -299,7 +301,7 @@ public class ItemCreation {
try { try {
if (s.getType() == Material.LEATHER_BOOTS || s.getType() == Material.LEATHER_LEGGINGS || s.getType() == Material.LEATHER_CHESTPLATE || s.getType() == Material.LEATHER_HELMET) { if (s.getType() == Material.LEATHER_BOOTS || s.getType() == Material.LEATHER_LEGGINGS || s.getType() == Material.LEATHER_CHESTPLATE || s.getType() == Material.LEATHER_HELMET) {
LeatherArmorMeta leatherMeta = (LeatherArmorMeta) s.getItemMeta(); LeatherArmorMeta leatherMeta = (LeatherArmorMeta) s.getItemMeta();
String colourCode = itemSection.getString("leatherarmor"); String colourCode = plugin.tex.placeholdersNoColour(panel,position,p,itemSection.getString("leatherarmor"));
assert colourCode != null; assert colourCode != null;
if (!colourCode.contains(",")) { if (!colourCode.contains(",")) {
//use a color name //use a color name
@ -329,7 +331,7 @@ public class ItemCreation {
//if the item is a potion, give it an effect //if the item is a potion, give it an effect
try { try {
PotionMeta potionMeta = (PotionMeta)s.getItemMeta(); PotionMeta potionMeta = (PotionMeta)s.getItemMeta();
String[] effectType = itemSection.getString("potion").split("\\s"); String[] effectType = plugin.tex.placeholdersNoColour(panel,position,p,itemSection.getString("potion")).split("\\s");
assert potionMeta != null; assert potionMeta != null;
boolean extended = false; boolean extended = false;
boolean upgraded = false; boolean upgraded = false;

View File

@ -23,7 +23,7 @@ public class BasicTags implements Listener {
@EventHandler @EventHandler
public void commandTag(CommandTagEvent e){ public void commandTag(CommandTagEvent e){
if(e.name.equalsIgnoreCase("cpc")){ if(e.name.equalsIgnoreCase("cpc") || e.name.equalsIgnoreCase("commandpanelclose")){
e.commandTagUsed(); e.commandTagUsed();
//unclosable panels are at the Top only //unclosable panels are at the Top only