From 5f9502bf10e1a618f9e6a0d989ecf8e2eca45706 Mon Sep 17 00:00:00 2001 From: alisolarflare Date: Sat, 19 Nov 2016 14:21:01 -0500 Subject: [PATCH] Adjusted so that error messages fit --- plugin.yml | 2 +- src/alisolarflare/components/BaseCommand.java | 28 +++++++++++++++++-- .../components/insurance/getInsuranceBar.java | 5 +--- .../metrics/commands/GetLoginMetrics.java | 5 ---- 4 files changed, 28 insertions(+), 12 deletions(-) diff --git a/plugin.yml b/plugin.yml index e8a276a..57cf268 100644 --- a/plugin.yml +++ b/plugin.yml @@ -59,7 +59,7 @@ commands: description: activate every player's power setproximitylocation: description: sets one of two proximity blocks to create a space that players can change their flairs with using flairportals. Ask ali XD - getLoginMetrics: + getloginmetrics: description: Gets metrics getinsurance: description: Gets insurance diff --git a/src/alisolarflare/components/BaseCommand.java b/src/alisolarflare/components/BaseCommand.java index 83c20d8..8818639 100644 --- a/src/alisolarflare/components/BaseCommand.java +++ b/src/alisolarflare/components/BaseCommand.java @@ -1,5 +1,6 @@ package alisolarflare.components; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -25,14 +26,37 @@ public abstract class BaseCommand extends TBMCCommandBase{ 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){ + 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/getInsuranceBar.java b/src/alisolarflare/components/insurance/getInsuranceBar.java index 78e859b..4e7a95f 100644 --- a/src/alisolarflare/components/insurance/getInsuranceBar.java +++ b/src/alisolarflare/components/insurance/getInsuranceBar.java @@ -16,10 +16,7 @@ public class getInsuranceBar extends ModCommand { player.getInventory().addItem(Insurance.getInsurance(InsuranceType.Ingot, Integer.parseInt(args[0]))); }else{ player.getInventory().addItem(Insurance.getInsurance(InsuranceType.Ingot)); - - SendDebugPotato(player, "Hwat the fuck!"); } - return false; + return true; } - } diff --git a/src/alisolarflare/components/metrics/commands/GetLoginMetrics.java b/src/alisolarflare/components/metrics/commands/GetLoginMetrics.java index 59a6828..9536258 100644 --- a/src/alisolarflare/components/metrics/commands/GetLoginMetrics.java +++ b/src/alisolarflare/components/metrics/commands/GetLoginMetrics.java @@ -22,9 +22,4 @@ public class GetLoginMetrics extends ModCommand{ } return true; } - @Override - public String GetCommandPath(){ - return "getLoginMetrics"; - } - }