Skip to content

Commit 6ce1947

Browse files
committed
* Made changes
1 parent e36aa51 commit 6ce1947

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/main/java/com/github/sanctum/labyrinth/library/StringUtils.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.github.sanctum.labyrinth.library;
22

33
import com.github.sanctum.labyrinth.formatting.string.ColoredString;
4+
import java.util.ArrayList;
5+
import java.util.List;
46
import java.util.regex.Pattern;
57
import me.clip.placeholderapi.PlaceholderAPI;
68
import org.bukkit.Bukkit;
@@ -46,4 +48,25 @@ public static String translate(OfflinePlayer source, String text) {
4648
return translate(text);
4749
}
4850

51+
/**
52+
* Similar to the {@link String#join(CharSequence, CharSequence...)} method append a specified element
53+
* to the end of each list entry except for the last one.
54+
*
55+
* @param delimiter The character to append.
56+
* @param list The list to append characters to.
57+
* @return A new list of strings containing the previous entries with the newly
58+
* appended delimiters.
59+
*/
60+
public static List<String> join(CharSequence delimiter, List<String> list) {
61+
List<String> array = new ArrayList<>();
62+
for (int i = 0; i < list.size(); i++) {
63+
if (i != list.size() - 1) {
64+
array.add(list.get(i) + "\n");
65+
} else {
66+
array.add(list.get(i));
67+
}
68+
}
69+
return array;
70+
}
71+
4972
}

src/main/java/com/github/sanctum/labyrinth/library/TextLib.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ private TextLib() { }
174174
public static TextComponent formatHoverMeta(Player source, TextComponent component, String... messages) {
175175
List<Content> array = new ArrayList<>();
176176
for (String msg : messages) {
177-
array.add(new Text(StringUtils.translate(source, msg)));
177+
array.add(new Text(StringUtils.translate(source, msg) + "\n"));
178178
}
179179
component.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, array));
180180
return component;

0 commit comments

Comments
 (0)