2022-02-27 17:29:41 +00:00
|
|
|
package com.alttd.chat.objects;
|
|
|
|
|
|
2022-10-08 09:05:56 +00:00
|
|
|
import net.kyori.adventure.text.Component;
|
|
|
|
|
import net.kyori.adventure.text.TextReplacementConfig;
|
|
|
|
|
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
|
|
|
|
|
2022-02-27 17:29:41 +00:00
|
|
|
public class ModifiableString {
|
2022-10-08 09:05:56 +00:00
|
|
|
private Component text;
|
2022-02-27 17:29:41 +00:00
|
|
|
|
2022-10-08 09:05:56 +00:00
|
|
|
public ModifiableString(Component text) {
|
|
|
|
|
this.text = text;
|
2022-02-27 17:29:41 +00:00
|
|
|
}
|
|
|
|
|
|
2022-10-08 09:05:56 +00:00
|
|
|
public void string(Component text) {
|
|
|
|
|
this.text = text;
|
2022-02-27 17:29:41 +00:00
|
|
|
}
|
|
|
|
|
|
2022-10-09 17:32:51 +00:00
|
|
|
public void replace(TextReplacementConfig textReplacementConfig) {
|
|
|
|
|
text = text.replaceText(textReplacementConfig);
|
2022-10-08 22:36:07 +00:00
|
|
|
}
|
|
|
|
|
|
2022-02-27 17:29:41 +00:00
|
|
|
public String string() {
|
2022-10-08 09:05:56 +00:00
|
|
|
return PlainTextComponentSerializer.plainText().serialize(text);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Component component() {
|
|
|
|
|
return text;
|
2022-02-27 17:29:41 +00:00
|
|
|
}
|
|
|
|
|
}
|