Permalink
Browse files

Events are refactored

  • Loading branch information...
LadyCailin committed Nov 15, 2018
1 parent a66f9ac commit 370cda3c377dd7a63c109329aca7537f223e5684
@@ -1108,7 +1108,7 @@ public CArray vector(Vector3D vector, Target t) {
* @param t the target
* @return the Vector
*/
public Vector3D vector(Construct c, Target t) {
public Vector3D vector(Mixed c, Target t) {
return vector(Vector3D.ZERO, c, t);
}
@@ -1121,7 +1121,7 @@ public Vector3D vector(Construct c, Target t) {
* @param t the target
* @return the Vector
*/
public Vector3D vector(Vector3D v, Construct c, Target t) {
public Vector3D vector(Vector3D v, Mixed c, Target t) {
if(c instanceof CArray) {
CArray va = (CArray) c;
double x = v.X();
@@ -1156,7 +1156,7 @@ public Vector3D vector(Vector3D v, Construct c, Target t) {
// fulfilling the todo?
return v;
} else {
throw new CREFormatException("Expecting an array, received " + c.getCType(), t);
throw new CREFormatException("Expecting an array, received " + c.typeof().getSimpleName(), t);
}
}
@@ -8,12 +8,12 @@
import com.laytonsmith.core.constructs.CDouble;
import com.laytonsmith.core.constructs.CInt;
import com.laytonsmith.core.constructs.CString;
import com.laytonsmith.core.constructs.Construct;
import com.laytonsmith.core.constructs.Target;
import com.laytonsmith.core.exceptions.CRE.CREFormatException;
import com.laytonsmith.core.exceptions.CRE.CREPluginInternalException;
import com.laytonsmith.core.exceptions.ConfigRuntimeException;
import com.laytonsmith.core.exceptions.PrefilterNonMatchException;
import com.laytonsmith.core.natives.interfaces.Mixed;
import java.util.Map;
@@ -66,27 +66,27 @@ private Prefilters() {
MACRO
}
public static void match(Map<String, Construct> map, String key,
public static void match(Map<String, Mixed> map, String key,
String actualValue, PrefilterType type) throws PrefilterNonMatchException {
match(map, key, new CString(actualValue, Target.UNKNOWN), type);
}
public static void match(Map<String, Construct> map, String key,
public static void match(Map<String, Mixed> map, String key,
int actualValue, PrefilterType type) throws PrefilterNonMatchException {
match(map, key, new CInt(actualValue, Target.UNKNOWN), type);
}
public static void match(Map<String, Construct> map, String key,
public static void match(Map<String, Mixed> map, String key,
double actualValue, PrefilterType type) throws PrefilterNonMatchException {
match(map, key, new CDouble(actualValue, Target.UNKNOWN), type);
}
public static void match(Map<String, Construct> map, String key,
public static void match(Map<String, Mixed> map, String key,
boolean actualValue, PrefilterType type) throws PrefilterNonMatchException {
match(map, key, CBoolean.get(actualValue), type);
}
public static void match(Map<String, Construct> map, String key,
public static void match(Map<String, Mixed> map, String key,
MCLocation actualValue, PrefilterType type) throws PrefilterNonMatchException {
match(map, key, ObjectGenerator.GetGenerator().location(actualValue, false), type);
}
@@ -96,8 +96,8 @@ public static void match(Map<String, Construct> map, String key,
* exception. If the value is not provided, or it does match, it returns void, which means that the test passed, and
* the event matches.
*/
public static void match(Map<String, Construct> map, String key,
Construct actualValue, PrefilterType type) throws PrefilterNonMatchException {
public static void match(Map<String, Mixed> map, String key,
Mixed actualValue, PrefilterType type) throws PrefilterNonMatchException {
if(map.containsKey(key)) {
switch(type) {
case ITEM_MATCH:
@@ -110,7 +110,7 @@ public static void match(Map<String, Construct> map, String key,
MathMatch(map.get(key), actualValue);
break;
case EXPRESSION:
Construct exp = map.get(key);
Mixed exp = map.get(key);
if(!exp.val().isEmpty()
&& exp.val().charAt(0) == '(' && exp.val().charAt(exp.val().length() - 1) == ')') {
ExpressionMatch(exp, key, actualValue);
@@ -143,21 +143,21 @@ public static void match(Map<String, Construct> map, String key,
}
}
private static void ItemMatch(Construct item1, Construct item2) throws PrefilterNonMatchException {
private static void ItemMatch(Mixed item1, Mixed item2) throws PrefilterNonMatchException {
String i1 = item1.val().split(":")[0];
String i2 = item2.val().split(":")[0];
if(!i1.trim().equals(i2)) {
throw new PrefilterNonMatchException();
}
}
private static void BooleanMatch(Construct bool1, Construct bool2) throws PrefilterNonMatchException {
private static void BooleanMatch(Mixed bool1, Mixed bool2) throws PrefilterNonMatchException {
if(Static.getBoolean(bool1, Target.UNKNOWN) != Static.getBoolean(bool2, Target.UNKNOWN)) {
throw new PrefilterNonMatchException();
}
}
private static void LocationMatch(Construct location1, Construct location2) throws PrefilterNonMatchException {
private static void LocationMatch(Mixed location1, Mixed location2) throws PrefilterNonMatchException {
MCLocation l1 = ObjectGenerator.GetGenerator().location(location1, null, location1.getTarget());
MCLocation l2 = ObjectGenerator.GetGenerator().location(location2, null, Target.UNKNOWN);
if((!l1.getWorld().equals(l2.getWorld())) || (l1.getBlockX() != l2.getBlockX()) || (l1.getBlockY() != l2.getBlockY()) || (l1.getBlockZ() != l2.getBlockZ())) {
@@ -171,7 +171,7 @@ private static void StringMatch(String string1, String string2) throws Prefilter
}
}
private static void MathMatch(Construct one, Construct two) throws PrefilterNonMatchException {
private static void MathMatch(Mixed one, Mixed two) throws PrefilterNonMatchException {
try {
double dOne = Static.getNumber(one, Target.UNKNOWN);
double dTwo = Static.getNumber(two, Target.UNKNOWN);
@@ -183,7 +183,7 @@ private static void MathMatch(Construct one, Construct two) throws PrefilterNonM
}
}
private static void ExpressionMatch(Construct expression, String key, Construct dvalue) throws PrefilterNonMatchException {
private static void ExpressionMatch(Mixed expression, String key, Mixed dvalue) throws PrefilterNonMatchException {
String exp = expression.val().substring(1, expression.val().length() - 1);
boolean inequalityMode = false;
if(exp.contains("<") || exp.contains(">") || exp.contains("==")) {
@@ -224,14 +224,14 @@ private static void ExpressionMatch(Construct expression, String key, Construct
}
}
private static void RegexMatch(String regex, Construct value) throws PrefilterNonMatchException {
private static void RegexMatch(String regex, Mixed value) throws PrefilterNonMatchException {
regex = regex.substring(1, regex.length() - 1);
if(!value.val().matches(regex)) {
throw new PrefilterNonMatchException();
}
}
private static void MacroMatch(String key, Construct expression, Construct value) throws PrefilterNonMatchException {
private static void MacroMatch(String key, Mixed expression, Mixed value) throws PrefilterNonMatchException {
if(expression.val().isEmpty()) {
throw new PrefilterNonMatchException();
} else if(expression.val().charAt(0) == '(' && expression.val().charAt(expression.val().length() - 1) == ')') {
Oops, something went wrong.

0 comments on commit 370cda3

Please sign in to comment.