From fb41e090b80e742379fd55ee95c02fd8ad144059 Mon Sep 17 00:00:00 2001 From: alisolarflare Date: Sat, 19 Nov 2016 21:12:16 -0500 Subject: [PATCH] Moved potatoToItemStack to potato Makes things neeater --- .../java/buttondevteam/lib/DebugPotato.java | 19 +++++++++++++ .../buttondevteam/lib/DebugPotatoAPI.java | 27 +------------------ 2 files changed, 20 insertions(+), 26 deletions(-) diff --git a/src/main/java/buttondevteam/lib/DebugPotato.java b/src/main/java/buttondevteam/lib/DebugPotato.java index d55f124..adb3c65 100644 --- a/src/main/java/buttondevteam/lib/DebugPotato.java +++ b/src/main/java/buttondevteam/lib/DebugPotato.java @@ -4,7 +4,11 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import org.bukkit.Material; +import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; public class DebugPotato { private List message; @@ -106,4 +110,19 @@ public class DebugPotato { } return newMessage; } + public ItemStack toItemStack() { + ItemStack potato = new ItemStack(Material.BAKED_POTATO); + ItemMeta meta = potato.getItemMeta(); + meta.setDisplayName(this.getType() == null ? "Spicy Debug Potato" : this.getType()); + if (this.getMessage() == null){ + List message = new ArrayList(); + message.add("nullMessage"); + meta.setLore(message); + }else{ + meta.setLore(this.getMessage()); + } + potato.setItemMeta(meta); + potato.addUnsafeEnchantment(Enchantment.ARROW_FIRE, 10); + return potato; + } } diff --git a/src/main/java/buttondevteam/lib/DebugPotatoAPI.java b/src/main/java/buttondevteam/lib/DebugPotatoAPI.java index be138c8..99c690e 100644 --- a/src/main/java/buttondevteam/lib/DebugPotatoAPI.java +++ b/src/main/java/buttondevteam/lib/DebugPotatoAPI.java @@ -1,35 +1,10 @@ package buttondevteam.lib; -import java.util.ArrayList; -import java.util.List; - -import org.bukkit.Material; -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; public class DebugPotatoAPI { - private static ItemStack CreateDebugPotato(DebugPotato dp) { - ItemStack potato = new ItemStack(Material.BAKED_POTATO); - ItemMeta meta = potato.getItemMeta(); - meta.setDisplayName(dp.getType() == null ? "Spicy Debug Potato" : dp.getType()); - if (dp.getMessage() == null){ - List message = new ArrayList(); - message.add("nullMessage"); - meta.setLore(message); - }else{ - meta.setLore(dp.getMessage()); - } - potato.setItemMeta(meta); - potato.addUnsafeEnchantment(Enchantment.ARROW_FIRE, 10); - return potato; - } - public static void SendDebugPotato(DebugPotato dp, Player player) { - player.getInventory().addItem(CreateDebugPotato(dp)); - player.getWorld().playSound(player.getLocation(), Sound.ENTITY_SLIME_SQUISH, 0, 0); + player.getInventory().addItem(dp.toItemStack()); return; } }