Small fixes and formatting
This commit is contained in:
parent
96daaf032d
commit
1748bc0461
1 changed files with 17 additions and 13 deletions
|
@ -12,7 +12,7 @@ import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
public class DebugPotatoAPI {
|
public class DebugPotatoAPI {
|
||||||
public static ItemStack CreateDebugPotato(List<String> message){
|
public static ItemStack CreateDebugPotato(List<String> message) {
|
||||||
ItemStack potato = new ItemStack(Material.BAKED_POTATO);
|
ItemStack potato = new ItemStack(Material.BAKED_POTATO);
|
||||||
ItemMeta meta = potato.getItemMeta();
|
ItemMeta meta = potato.getItemMeta();
|
||||||
meta.setDisplayName("Spicy Debug Potato");
|
meta.setDisplayName("Spicy Debug Potato");
|
||||||
|
@ -21,34 +21,38 @@ public class DebugPotatoAPI {
|
||||||
potato.addUnsafeEnchantment(Enchantment.ARROW_FIRE, 10);
|
potato.addUnsafeEnchantment(Enchantment.ARROW_FIRE, 10);
|
||||||
return potato;
|
return potato;
|
||||||
}
|
}
|
||||||
public static ItemStack CreateDebugPotato(String message){
|
|
||||||
return CreateDebugPotato(Arrays.asList(message));
|
public static ItemStack CreateDebugPotato(String message) {
|
||||||
|
return CreateDebugPotato(WordWrap(message));
|
||||||
}
|
}
|
||||||
public static void SendDebugPotato(Player player, List<String> message){
|
|
||||||
|
public static void SendDebugPotato(Player player, List<String> message) {
|
||||||
player.getInventory().addItem(CreateDebugPotato(message));
|
player.getInventory().addItem(CreateDebugPotato(message));
|
||||||
player.getWorld().playSound(player.getLocation(), Sound.ENTITY_SLIME_SQUISH, 0, 0);
|
player.getWorld().playSound(player.getLocation(), Sound.ENTITY_SLIME_SQUISH, 0, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
public static void SendDebugPotato(Player player, String[] message){
|
|
||||||
|
public static void SendDebugPotato(Player player, String[] message) {
|
||||||
SendDebugPotato(player, Arrays.asList(message));
|
SendDebugPotato(player, Arrays.asList(message));
|
||||||
}
|
}
|
||||||
public static void SendDebugPotato(Player player, String message){
|
|
||||||
|
public static void SendDebugPotato(Player player, String message) {
|
||||||
SendDebugPotato(player, StringToMessage(message));
|
SendDebugPotato(player, WordWrap(message));
|
||||||
}
|
}
|
||||||
public static List<String> StringToMessage(String message){
|
|
||||||
|
public static List<String> WordWrap(String message) {
|
||||||
String[] splitString = message.split("\\s+");
|
String[] splitString = message.split("\\s+");
|
||||||
List<String> newMessage = new ArrayList<String>();
|
List<String> newMessage = new ArrayList<String>();
|
||||||
String currentLine = "";
|
String currentLine = "";
|
||||||
int currentLineLength = 0;
|
int currentLineLength = 0;
|
||||||
int wordlength;
|
int wordlength;
|
||||||
int maxLineLength = 40;
|
int maxLineLength = 40;
|
||||||
for (String word : splitString){
|
for (String word : splitString) {
|
||||||
wordlength = word.length();
|
wordlength = word.length();
|
||||||
if (currentLineLength == 0 || (currentLineLength + wordlength) < maxLineLength){
|
if (currentLineLength == 0 || (currentLineLength + wordlength) < maxLineLength) {
|
||||||
currentLine += word + " ";
|
currentLine += word + " ";
|
||||||
currentLineLength += wordlength +1;
|
currentLineLength += wordlength + 1;
|
||||||
}else{
|
} else {
|
||||||
newMessage.add(currentLine);
|
newMessage.add(currentLine);
|
||||||
currentLine = word + " ";
|
currentLine = word + " ";
|
||||||
currentLineLength = word.length();
|
currentLineLength = word.length();
|
||||||
|
|
Loading…
Reference in a new issue