Skip to content

Commit

Permalink
* Made changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Hempfest committed Apr 4, 2021
1 parent e36aa51 commit 6ce1947
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.github.sanctum.labyrinth.library;

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

/**
* Similar to the {@link String#join(CharSequence, CharSequence...)} method append a specified element
* to the end of each list entry except for the last one.
*
* @param delimiter The character to append.
* @param list The list to append characters to.
* @return A new list of strings containing the previous entries with the newly
* appended delimiters.
*/
public static List<String> join(CharSequence delimiter, List<String> list) {
List<String> array = new ArrayList<>();
for (int i = 0; i < list.size(); i++) {
if (i != list.size() - 1) {
array.add(list.get(i) + "\n");
} else {
array.add(list.get(i));
}
}
return array;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ private TextLib() { }
public static TextComponent formatHoverMeta(Player source, TextComponent component, String... messages) {
List<Content> array = new ArrayList<>();
for (String msg : messages) {
array.add(new Text(StringUtils.translate(source, msg)));
array.add(new Text(StringUtils.translate(source, msg) + "\n"));
}
component.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, array));
return component;
Expand Down

0 comments on commit 6ce1947

Please sign in to comment.