From a400bb9acba7659c6c110ed63742ae15506b6ca8 Mon Sep 17 00:00:00 2001 From: alisolarflare Date: Sat, 19 Nov 2016 13:32:49 -0500 Subject: [PATCH] Adjusted Meta setting --- src/alisolarflare/components/BaseCommand.java | 7 +++++-- src/alisolarflare/components/insurance/Insurance.java | 6 +++++- .../components/insurance/getInsuranceBar.java | 2 +- .../components/insurance/getInsuranceBlock.java | 2 +- .../components/insurance/getInsuranceNugget.java | 2 +- 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/alisolarflare/components/BaseCommand.java b/src/alisolarflare/components/BaseCommand.java index 31980f1..83c20d8 100644 --- a/src/alisolarflare/components/BaseCommand.java +++ b/src/alisolarflare/components/BaseCommand.java @@ -8,14 +8,17 @@ import org.bukkit.Sound; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; import buttondevteam.lib.chat.TBMCCommandBase; public abstract class BaseCommand extends TBMCCommandBase{ public static ItemStack CreateDebugPotato(List message){ ItemStack potato = new ItemStack(Material.BAKED_POTATO); - potato.getItemMeta().setDisplayName("Spicy Debug Potato"); - potato.getItemMeta().setLore(message); + ItemMeta meta = potato.getItemMeta(); + meta.setDisplayName("Spicy Debug Potato"); + meta.setLore(message); + potato.setItemMeta(meta); potato.addUnsafeEnchantment(Enchantment.ARROW_FIRE, 10); return potato; } diff --git a/src/alisolarflare/components/insurance/Insurance.java b/src/alisolarflare/components/insurance/Insurance.java index 50805cc..10fba5d 100644 --- a/src/alisolarflare/components/insurance/Insurance.java +++ b/src/alisolarflare/components/insurance/Insurance.java @@ -6,6 +6,7 @@ import java.util.List; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; import alisolarflare.components.BaseCommand; @@ -51,7 +52,10 @@ public abstract class Insurance { insuranceItem = BaseCommand.CreateDebugPotato(lore); } insuranceItem.addUnsafeEnchantment(Enchantment.DURABILITY, 10); - insuranceItem.getItemMeta().setLore(lore); + ItemMeta meta = insuranceItem.getItemMeta(); + meta.setLore(lore); + meta.setDisplayName("Insurance " + insuranceType.toString()); + insuranceItem.setItemMeta(meta); return insuranceItem; } public static ItemStack getInsurance(InsuranceType insuranceType, int amount){ diff --git a/src/alisolarflare/components/insurance/getInsuranceBar.java b/src/alisolarflare/components/insurance/getInsuranceBar.java index c0a268e..e58331b 100644 --- a/src/alisolarflare/components/insurance/getInsuranceBar.java +++ b/src/alisolarflare/components/insurance/getInsuranceBar.java @@ -16,7 +16,7 @@ public class getInsuranceBar extends ModCommand { @Override public boolean OnCommand(CommandSender sender, String alias, String[] args) { Player player = (Player) sender; - if (args.length > 0 || StringUtils.isNumeric(args[0])){ + if (args.length > 0 && StringUtils.isNumeric(args[0])){ //player.getInventory().addItem(Insurance.getInsurance(InsuranceType.Ingot, Integer.parseInt(args[0]))); }else{ //player.getInventory().addItem(Insurance.getInsurance(InsuranceType.Ingot)); diff --git a/src/alisolarflare/components/insurance/getInsuranceBlock.java b/src/alisolarflare/components/insurance/getInsuranceBlock.java index 223db3e..29ef322 100644 --- a/src/alisolarflare/components/insurance/getInsuranceBlock.java +++ b/src/alisolarflare/components/insurance/getInsuranceBlock.java @@ -12,7 +12,7 @@ public class getInsuranceBlock extends ModCommand { @Override public boolean OnCommand(CommandSender sender, String alias, String[] args) { Player player = (Player) sender; - if (args.length > 0 || StringUtils.isNumeric(args[0])){ + if (args.length > 0 && StringUtils.isNumeric(args[0])){ player.getInventory().addItem(Insurance.getInsurance(InsuranceType.Block, Integer.parseInt(args[0]))); }else{ player.getInventory().addItem(Insurance.getInsurance(InsuranceType.Block)); diff --git a/src/alisolarflare/components/insurance/getInsuranceNugget.java b/src/alisolarflare/components/insurance/getInsuranceNugget.java index c1a0ad3..e6de4f4 100644 --- a/src/alisolarflare/components/insurance/getInsuranceNugget.java +++ b/src/alisolarflare/components/insurance/getInsuranceNugget.java @@ -12,7 +12,7 @@ public class getInsuranceNugget extends ModCommand { @Override public boolean OnCommand(CommandSender sender, String alias, String[] args) { Player player = (Player) sender; - if (args.length > 0 || StringUtils.isNumeric(args[0])){ + if (args.length > 0 && StringUtils.isNumeric(args[0])){ player.getInventory().addItem(Insurance.getInsurance(InsuranceType.Nugget, Integer.parseInt(args[0]))); }else{ player.getInventory().addItem(Insurance.getInsurance(InsuranceType.Nugget));