-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathChatUtils.java
More file actions
120 lines (107 loc) · 3.81 KB
/
ChatUtils.java
File metadata and controls
120 lines (107 loc) · 3.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
package wtf.nucker.spigotutilities.utils;
import org.apache.commons.lang.StringEscapeUtils;
import org.bukkit.ChatColor;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* This class has a bunch of useful methods and variables
*/
public class ChatUtils {
/**
* Good sized bar for scoreboards
*/
public static final String SB_BAR = ChatColor.STRIKETHROUGH + "----------------------";
/**
* Good sized bar for guis
*/
public static final String MENU_BAR = ChatColor.STRIKETHROUGH + "------------------------";
/**
* Good sized bar for information messages
*/
public static final String CHAT_BAR = ChatColor.STRIKETHROUGH + "------------------------------------------------";
/**
* No text in the message, adds a bit of space between a message
*/
public static final String BLANK_MESSAGE = String.join("", Collections.nCopies(150, " \n"));
/**
* A shorter method for the bukkit method ChatColor#translateAlternateColorCodes.
* Dosent require a altColorChar param, this is provided in the method as '&'
* @param string the string you want translating
* @return the translated string
*/
public static String translate(String string) {
if(string == null) return null;
return ChatColor.translateAlternateColorCodes('&', string);
}
/**
* A shorter method for the bukkit method ChatColor#translateAlternateColorCodes.
* Dosent require a altColorChar param, this is provided in the method as '&'
* This methods supports lists
* @param lines the list of strings you want to translate
* @return each string in your list being translated
*/
public static List<String> translate(List<String> lines) {
List<String> strings = new ArrayList<>();
if(lines == null) return null;
for (String line : lines) {
strings.add(ChatColor.translateAlternateColorCodes('&', line));
}
return strings;
}
/**
* A shorter method for the bukkit method ChatColor#translateAlternateColorCodes.
* Dosent require a altColorChar param, this is provided in the method as '&'
* This methods supports string arrays
* @param lines the list of strings you want to translate
* @return each string in your list being translated
*/
public static String[] translate(String[] lines) {
List<String> res = new ArrayList<>();
if(lines == null) return null;
for(String line : lines) {
res.add(ChatUtils.translate(line);
}
return res.toArray(new String[res.size()]);
}
/**
* A useful enum with a bunch of symbols you may want to access
*/
public enum Symbols {
/**
* Returns "❤" symbol
*/
HEALTH(StringEscapeUtils.unescapeJava("\u2764")),
/**
* Returns "«" symbol
*/
ARROW_LEFT(StringEscapeUtils.unescapeJava("\u00AB")),
/**
* Returns "»" symbol
*/
ARROW_RIGHT(StringEscapeUtils.unescapeJava("\u00BB")),
/**
* Returns "✖" symbol
*/
CROSS(StringEscapeUtils.unescapeJava("\u2716")),
/**
* Returns "⚠" symbol
*/
WARNING(StringEscapeUtils.unescapeJava("\u26A0"));
private final String symbol;
/**
* The constructor for the symbol enum
* @param symbol the symbol unicode
*/
Symbols(String symbol) {
this.symbol = symbol;
}
/**
* A method to get the unicode symbol
* @return the symbol
*/
public String getSymbol() {
return symbol;
}
}
}