refactor Item to api addon

This commit is contained in:
dfsek
2021-08-03 12:53:40 -07:00
parent 32cc38c6b2
commit 9718c99149
90 changed files with 252 additions and 243 deletions

View File

@@ -0,0 +1,7 @@
package com.dfsek.terra.addons.terrascript.api;
/**
* Arguments passed to {@link Item}s by the implementation
*/
public interface ImplementationArguments {
}

View File

@@ -0,0 +1,9 @@
package com.dfsek.terra.addons.terrascript.api;
import java.util.Map;
public interface Item<T> {
T apply(ImplementationArguments implementationArguments, Map<String, Variable<?>> variableMap);
Position getPosition();
}

View File

@@ -0,0 +1,16 @@
package com.dfsek.terra.addons.terrascript.api;
public class Position {
private final int line;
private final int index;
public Position(int line, int index) {
this.line = line;
this.index = index;
}
@Override
public String toString() {
return (line + 1) + ":" + index;
}
}

View File

@@ -0,0 +1,19 @@
package com.dfsek.terra.addons.terrascript.api;
public interface Returnable<T> extends Item<T> {
ReturnType returnType();
enum ReturnType {
NUMBER(true), STRING(true), BOOLEAN(false), VOID(false), OBJECT(false);
private final boolean comparable;
ReturnType(boolean comparable) {
this.comparable = comparable;
}
public boolean isComparable() {
return comparable;
}
}
}

View File

@@ -0,0 +1,11 @@
package com.dfsek.terra.addons.terrascript.api;
public interface Variable<T> {
T getValue();
void setValue(T value);
Returnable.ReturnType getType();
Position getPosition();
}