remove decimal on whole numbers (keeps parity with old scripts)

This commit is contained in:
dfsek
2022-06-14 22:18:31 -07:00
parent 8c9afc4592
commit e5fa4fd1f1

View File

@@ -7,8 +7,6 @@
package com.dfsek.terra.addons.terrascript.parser.lang.operations;
import java.util.function.Supplier;
import com.dfsek.terra.addons.terrascript.parser.lang.ImplementationArguments;
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
import com.dfsek.terra.addons.terrascript.parser.lang.Scope;
@@ -27,6 +25,17 @@ public class ConcatenationOperation extends BinaryOperation<Object, Object> {
@Override
public Object apply(ImplementationArguments implementationArguments, Scope scope) {
return left.apply(implementationArguments, scope).toString() + right.apply(implementationArguments, scope).toString();
return toString(left.apply(implementationArguments, scope)) + toString(right.apply(implementationArguments, scope));
}
private static String toString(Object object) {
String s = object.toString();
if(object instanceof Double) {
int l = s.length();
if(s.charAt(l - 2) == '.' && s.charAt(l - 1) == '0') {
s = s.substring(0, s.length() - 2);
}
}
return s;
}
}