/
SText.java
48 lines (39 loc) · 1.19 KB
/
SText.java
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
package org.ships.implementation.sponge.text;
import org.core.text.Text;
import org.core.text.TextColours;
import org.spongepowered.api.text.serializer.TextSerializers;
public class SText implements Text {
protected org.spongepowered.api.text.Text text;
public SText(org.spongepowered.api.text.Text text){
this.text = text;
}
public org.spongepowered.api.text.Text toSponge(){
return this.text;
}
@Override
public boolean equals(Object obj){
if(!(obj instanceof Text)){
return false;
}
Text text = (Text) obj;
return this.toPlain().equals(text.toPlain());
}
@Override
public boolean equalsExact(String chars) {
return equals(new SText(TextSerializers.FORMATTING_CODE.deserialize(chars)));
}
@Override
public String toPlain() {
String plain = this.text.toPlain();
plain = TextColours.stripColours(plain);
return plain;
}
@Override
public Text append(Text... text) {
SText text2 = this;
for(Text toAdd : text){
text2 = new SText(text2.text.toBuilder().append(((SText)toAdd).text).build());
}
return text2;
}
}