mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-17 22:00:08 +00:00
refactor Item to api addon
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
package com.dfsek.terra.addons.terrascript.api;
|
||||
|
||||
/**
|
||||
* Arguments passed to {@link Item}s by the implementation
|
||||
*/
|
||||
public interface ImplementationArguments {
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
Reference in New Issue
Block a user