From f3283c5fd365dee75ec25ab93b463d0bcf029602 Mon Sep 17 00:00:00 2001 From: alisolarflare Date: Sat, 19 Nov 2016 14:47:14 -0500 Subject: [PATCH] Added DebugPotatoAPI --- src/alisolarflare/components/BaseCommand.java | 56 ------------------ .../debugPotatos/DebugPotatoAPI.java | 59 +++++++++++++++++++ .../components/insurance/Insurance.java | 4 +- 3 files changed, 61 insertions(+), 58 deletions(-) create mode 100644 src/alisolarflare/components/debugPotatos/DebugPotatoAPI.java diff --git a/src/alisolarflare/components/BaseCommand.java b/src/alisolarflare/components/BaseCommand.java index 8818639..59a09db 100644 --- a/src/alisolarflare/components/BaseCommand.java +++ b/src/alisolarflare/components/BaseCommand.java @@ -1,62 +1,6 @@ package alisolarflare.components; -import java.util.ArrayList; -import java.util.Arrays; -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; - import buttondevteam.lib.chat.TBMCCommandBase; public abstract class BaseCommand extends TBMCCommandBase{ - public static ItemStack CreateDebugPotato(List message){ - ItemStack potato = new ItemStack(Material.BAKED_POTATO); - ItemMeta meta = potato.getItemMeta(); - meta.setDisplayName("Spicy Debug Potato"); - meta.setLore(message); - potato.setItemMeta(meta); - potato.addUnsafeEnchantment(Enchantment.ARROW_FIRE, 10); - return potato; - } - public static ItemStack CreateDebugPotato(String message){ - return CreateDebugPotato(Arrays.asList(message)); - } - public static void SendDebugPotato(Player player, List message){ - player.getInventory().addItem(CreateDebugPotato(message)); - player.getWorld().playSound(player.getLocation(), Sound.ENTITY_SLIME_SQUISH, 0, 0); - return; - } - public static void SendDebugPotato(Player player, String[] message){ - SendDebugPotato(player, Arrays.asList(message)); - } - public static void SendDebugPotato(Player player, String message){ - - SendDebugPotato(player, StringToMessage(message)); - } - public static List StringToMessage(String message){ - String[] splitString = message.split("\\s+"); - List newMessage = new ArrayList(); - String currentLine = ""; - int currentLineLength = 0; - int wordlength; - int maxLineLength = 40; - for (String word : splitString){ - wordlength = word.length(); - if (currentLineLength == 0 || (currentLineLength + wordlength) < maxLineLength){ - currentLine += word + " "; - currentLineLength += wordlength +1; - }else{ - newMessage.add(currentLine); - currentLine = word + " "; - currentLineLength = word.length(); - } - } - return newMessage; - } - } diff --git a/src/alisolarflare/components/debugPotatos/DebugPotatoAPI.java b/src/alisolarflare/components/debugPotatos/DebugPotatoAPI.java new file mode 100644 index 0000000..8d3bdee --- /dev/null +++ b/src/alisolarflare/components/debugPotatos/DebugPotatoAPI.java @@ -0,0 +1,59 @@ +package alisolarflare.components.debugPotatos; + +import java.util.ArrayList; +import java.util.Arrays; +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 { + public static ItemStack CreateDebugPotato(List message){ + ItemStack potato = new ItemStack(Material.BAKED_POTATO); + ItemMeta meta = potato.getItemMeta(); + meta.setDisplayName("Spicy Debug Potato"); + meta.setLore(message); + potato.setItemMeta(meta); + potato.addUnsafeEnchantment(Enchantment.ARROW_FIRE, 10); + return potato; + } + public static ItemStack CreateDebugPotato(String message){ + return CreateDebugPotato(Arrays.asList(message)); + } + public static void SendDebugPotato(Player player, List message){ + player.getInventory().addItem(CreateDebugPotato(message)); + player.getWorld().playSound(player.getLocation(), Sound.ENTITY_SLIME_SQUISH, 0, 0); + return; + } + public static void SendDebugPotato(Player player, String[] message){ + SendDebugPotato(player, Arrays.asList(message)); + } + public static void SendDebugPotato(Player player, String message){ + + SendDebugPotato(player, StringToMessage(message)); + } + public static List StringToMessage(String message){ + String[] splitString = message.split("\\s+"); + List newMessage = new ArrayList(); + String currentLine = ""; + int currentLineLength = 0; + int wordlength; + int maxLineLength = 40; + for (String word : splitString){ + wordlength = word.length(); + if (currentLineLength == 0 || (currentLineLength + wordlength) < maxLineLength){ + currentLine += word + " "; + currentLineLength += wordlength +1; + }else{ + newMessage.add(currentLine); + currentLine = word + " "; + currentLineLength = word.length(); + } + } + return newMessage; + } +} diff --git a/src/alisolarflare/components/insurance/Insurance.java b/src/alisolarflare/components/insurance/Insurance.java index a46d861..72a34b9 100644 --- a/src/alisolarflare/components/insurance/Insurance.java +++ b/src/alisolarflare/components/insurance/Insurance.java @@ -8,7 +8,7 @@ import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; -import alisolarflare.components.BaseCommand; +import alisolarflare.components.debugPotatos.DebugPotatoAPI; public abstract class Insurance { public static enum InsuranceType{ @@ -56,7 +56,7 @@ public abstract class Insurance { Insurance.class.getPackage().getName() + ".", "Contact a developer with a screenshot of this message" ); - insuranceItem = BaseCommand.CreateDebugPotato(lore); + insuranceItem = DebugPotatoAPI.CreateDebugPotato(lore); } insuranceItem.addUnsafeEnchantment(Enchantment.DURABILITY, 10); ItemMeta meta = insuranceItem.getItemMeta();