Lower char limit for GUI lore newline, fixes #53

This commit is contained in:
HappyPikachu 2015-03-16 15:48:05 -04:00
parent 7298c490c7
commit 14d9636b09
2 changed files with 6 additions and 5 deletions

View File

@ -3377,10 +3377,9 @@ if (quest != null) {
meta.setDisplayName(ChatColor.DARK_PURPLE + Quests.parseString(quests.get(i).getName(), npc));
if (!meta.hasLore()) {
String lore = ChatColor.DARK_GREEN + quests.get(i).description;
LinkedList<String> lines = new LinkedList<String>();
lines = MiscUtil.makeLines(lore, " ", 100);
lines = MiscUtil.makeLines(quests.get(i).description, " ", 40, ChatColor.DARK_GREEN);
meta.setLore(lines);
}

View File

@ -1,6 +1,8 @@
package me.blackvein.quests.util;
import java.util.LinkedList;
import org.bukkit.ChatColor;
import org.bukkit.entity.EntityType;
public class MiscUtil {
@ -116,7 +118,7 @@ public class MiscUtil {
return s.trim().equals("") ? null : s.trim();
}
public static LinkedList<String> makeLines(String s, String wordDelimiter, int lineLength) {
public static LinkedList<String> makeLines(String s, String wordDelimiter, int lineLength, ChatColor lineColor) {
LinkedList<String> toReturn = new LinkedList<String>();
String[] split = s.split(wordDelimiter);
@ -126,7 +128,7 @@ public class MiscUtil {
for (String piece : split) {
if ((currentLength + piece.length()) > (lineLength + 1)) {
toReturn.add(line.replaceAll("^" + wordDelimiter, ""));
toReturn.add(lineColor + line.replaceAll("^" + wordDelimiter, ""));
line = piece + wordDelimiter;
currentLength = piece.length() + 1;
} else {
@ -137,7 +139,7 @@ public class MiscUtil {
}
if(line.equals("") == false)
toReturn.add(line);
toReturn.add(lineColor + line);
return toReturn;