Moved potatoToItemStack to potato

Makes things neeater
This commit is contained in:
alisolarflare 2016-11-19 21:12:16 -05:00
parent 60730ac994
commit fb41e090b8
2 changed files with 20 additions and 26 deletions

View file

@ -4,7 +4,11 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
public class DebugPotato { public class DebugPotato {
private List<String> message; private List<String> message;
@ -106,4 +110,19 @@ public class DebugPotato {
} }
return newMessage; 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<String> message = new ArrayList<String>();
message.add("nullMessage");
meta.setLore(message);
}else{
meta.setLore(this.getMessage());
}
potato.setItemMeta(meta);
potato.addUnsafeEnchantment(Enchantment.ARROW_FIRE, 10);
return potato;
}
} }

View file

@ -1,35 +1,10 @@
package buttondevteam.lib; 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.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
public class DebugPotatoAPI { 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<String> message = new ArrayList<String>();
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) { public static void SendDebugPotato(DebugPotato dp, Player player) {
player.getInventory().addItem(CreateDebugPotato(dp)); player.getInventory().addItem(dp.toItemStack());
player.getWorld().playSound(player.getLocation(), Sound.ENTITY_SLIME_SQUISH, 0, 0);
return; return;
} }
} }