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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
|
package de.cowtipper.cowlection.util;
import net.minecraft.event.ClickEvent;
import net.minecraft.event.HoverEvent;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IChatComponent;
public class MooChatComponent extends ChatComponentText {
public MooChatComponent(String msg) {
super(msg);
}
public MooChatComponent black() {
setChatStyle(getChatStyle().setColor(EnumChatFormatting.BLACK));
return this;
}
public MooChatComponent darkBlue() {
setChatStyle(getChatStyle().setColor(EnumChatFormatting.DARK_BLUE));
return this;
}
public MooChatComponent darkGreen() {
setChatStyle(getChatStyle().setColor(EnumChatFormatting.DARK_GREEN));
return this;
}
public MooChatComponent darkAqua() {
setChatStyle(getChatStyle().setColor(EnumChatFormatting.DARK_AQUA));
return this;
}
public MooChatComponent darkRed() {
setChatStyle(getChatStyle().setColor(EnumChatFormatting.DARK_RED));
return this;
}
public MooChatComponent darkPurple() {
setChatStyle(getChatStyle().setColor(EnumChatFormatting.DARK_PURPLE));
return this;
}
public MooChatComponent gold() {
setChatStyle(getChatStyle().setColor(EnumChatFormatting.GOLD));
return this;
}
public MooChatComponent gray() {
setChatStyle(getChatStyle().setColor(EnumChatFormatting.GRAY));
return this;
}
public MooChatComponent darkGray() {
setChatStyle(getChatStyle().setColor(EnumChatFormatting.DARK_GRAY));
return this;
}
public MooChatComponent blue() {
setChatStyle(getChatStyle().setColor(EnumChatFormatting.BLUE));
return this;
}
public MooChatComponent green() {
setChatStyle(getChatStyle().setColor(EnumChatFormatting.GREEN));
return this;
}
public MooChatComponent aqua() {
setChatStyle(getChatStyle().setColor(EnumChatFormatting.AQUA));
return this;
}
public MooChatComponent red() {
setChatStyle(getChatStyle().setColor(EnumChatFormatting.RED));
return this;
}
public MooChatComponent lightPurple() {
setChatStyle(getChatStyle().setColor(EnumChatFormatting.LIGHT_PURPLE));
return this;
}
public MooChatComponent yellow() {
setChatStyle(getChatStyle().setColor(EnumChatFormatting.YELLOW));
return this;
}
public MooChatComponent white() {
setChatStyle(getChatStyle().setColor(EnumChatFormatting.WHITE));
return this;
}
public MooChatComponent obfuscated() {
setChatStyle(getChatStyle().setObfuscated(true));
return this;
}
public MooChatComponent bold() {
setChatStyle(getChatStyle().setBold(true));
return this;
}
public MooChatComponent strikethrough() {
setChatStyle(getChatStyle().setStrikethrough(true));
return this;
}
public MooChatComponent underline() {
setChatStyle(getChatStyle().setUnderlined(true));
return this;
}
public MooChatComponent italic() {
setChatStyle(getChatStyle().setItalic(true));
return this;
}
public MooChatComponent reset() {
setChatStyle(getChatStyle().setParentStyle(null).setBold(false).setItalic(false).setObfuscated(false).setUnderlined(false).setStrikethrough(false));
return this;
}
public MooChatComponent setHover(IChatComponent hover) {
setChatStyle(getChatStyle().setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hover)));
return this;
}
public MooChatComponent setUrl(String url) {
setUrl(url, new KeyValueTooltipComponent("Click to visit", url));
return this;
}
public MooChatComponent setUrl(String url, String hover) {
setUrl(url, new MooChatComponent(hover).yellow());
return this;
}
public MooChatComponent setUrl(String url, IChatComponent hover) {
setChatStyle(getChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, url)));
setHover(hover);
return this;
}
public MooChatComponent setSuggestCommand(String command) {
setChatStyle(getChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, command)));
setHover(new KeyValueChatComponent("Run", command, " "));
return this;
}
/**
* Appends the given component in a new line, without inheriting formatting of previous siblings.
*
* @see ChatComponentText#appendSibling appendSibling
*/
public MooChatComponent appendFreshSibling(IChatComponent sibling) {
this.siblings.add(new ChatComponentText("\n").appendSibling(sibling));
return this;
}
@Deprecated
public MooChatComponent appendKeyValue(String key, String value) {
appendSibling(new MooChatComponent("\n").appendFreshSibling(new KeyValueChatComponent(key, value)));
return this;
}
public static class KeyValueChatComponent extends MooChatComponent {
public KeyValueChatComponent(String key, String value) {
this(key, value, ": ");
}
public KeyValueChatComponent(String key, String value, String separator) {
super(key);
appendText(separator);
gold().appendSibling(new MooChatComponent(value).yellow());
}
}
public static class KeyValueTooltipComponent extends MooChatComponent {
public KeyValueTooltipComponent(String key, String value) {
super(key);
appendText(": ");
gray().appendSibling(new MooChatComponent(value).yellow());
}
}
}
|