Add FormattedText functionality to the right of the operand
This commit is contained in:
2 files changed
+11
-1
No files matched your search
@@ -27,7 +27,7 @@ public class FormattedTextValue extends StringValue
|
|||||||
@Override
|
@Override
|
||||||
public Value clone()
|
public Value clone()
|
||||||
{
|
{
|
||||||
return new FormattedTextValue(text);
|
return new FormattedTextValue(text.shallowCopy());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import carpet.script.exception.InternalExpressionException;
|
|||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import com.google.gson.JsonPrimitive;
|
import com.google.gson.JsonPrimitive;
|
||||||
import net.minecraft.nbt.Tag;
|
import net.minecraft.nbt.Tag;
|
||||||
|
import net.minecraft.text.BaseText;
|
||||||
|
import net.minecraft.text.LiteralText;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -79,6 +81,14 @@ public abstract class Value implements Comparable<Value>, Cloneable
|
|||||||
|
|
||||||
public Value add(Value o) {
|
public Value add(Value o) {
|
||||||
String lstr = this.getString();
|
String lstr = this.getString();
|
||||||
|
if (o instanceof FormattedTextValue)
|
||||||
|
{
|
||||||
|
if (lstr == null)
|
||||||
|
return ((FormattedTextValue) o).clone();
|
||||||
|
BaseText newText = new LiteralText(lstr);
|
||||||
|
newText.append(((FormattedTextValue) o).getText().shallowCopy());
|
||||||
|
return new FormattedTextValue(newText);
|
||||||
|
}
|
||||||
if (lstr == null) // null
|
if (lstr == null) // null
|
||||||
return new StringValue(o.getString());
|
return new StringValue(o.getString());
|
||||||
String rstr = o.getString();
|
String rstr = o.getString();
|
||||||
|
|||||||
Reference in new issue
Block a user