Browse Source

comparing extended to comparable interface

Kajetan Johannes Hammerle 4 years ago
parent
commit
e4384894e9

+ 4 - 4
src/me/hammerle/snuviscript/code/FunctionRegistry.java

@@ -702,13 +702,13 @@ public class FunctionRegistry
         registerAlias("==", "equals");
         registerFunction("!=", (sc, in) -> !Objects.equals(in[0].get(sc), in[1].get(sc)));
         registerAlias("!=", "notequal");
-        registerFunction("<", (sc, in) -> in[0].getDouble(sc) < in[1].getDouble(sc));
+        registerFunction("<", (sc, in) -> ((Comparable) in[0].get(sc)).compareTo(in[1].get(sc)) < 0);
         registerAlias("<", "less");
-        registerFunction(">", (sc, in) -> in[0].getDouble(sc) > in[1].getDouble(sc));
+        registerFunction(">", (sc, in) -> ((Comparable) in[0].get(sc)).compareTo(in[1].get(sc)) > 0);
         registerAlias(">", "greater");
-        registerFunction("<=", (sc, in) -> in[0].getDouble(sc) <= in[1].getDouble(sc));
+        registerFunction("<=", (sc, in) -> ((Comparable) in[0].get(sc)).compareTo(in[1].get(sc)) <= 0);
         registerAlias("<=", "lessequal");
-        registerFunction(">=", (sc, in) -> in[0].getDouble(sc) >= in[1].getDouble(sc));
+        registerFunction(">=", (sc, in) -> ((Comparable) in[0].get(sc)).compareTo(in[1].get(sc)) >= 0);
         registerAlias(">=", "greaterequal");
         registerFunction("!", (sc, in) -> !in[0].getBoolean(sc));
         registerAlias("!", "invert");

+ 1 - 0
src/me/hammerle/snuviscript/code/ScriptManager.java

@@ -62,6 +62,7 @@ public class ScriptManager
     
     private void removeScriptUnsafe(Script sc)
     {
+        sc.term();
         sc.onTerm();
         scripts.remove(sc.getId());
         loadedEvents.values().forEach(list -> list.remove(sc));

+ 6 - 6
src/me/hammerle/snuviscript/test/Test.java

@@ -22,13 +22,13 @@ public class Test
     
     public static void test()
     {
-        //testTokenizer();
-        //testCompiler();
-        //testOutput();
+        testTokenizer();
+        testCompiler();
+        testOutput();
         
-        LOGGER.reset();
-        PARSER.startScript(true, "test", "./test/test.test");
-        LOGGER.printAll();
+        //LOGGER.reset();
+        //PARSER.startScript(true, "test", "./test/test.test");
+        //LOGGER.printAll();
     }
     
     private static void testOutput()

+ 2 - 0
uploadToServer.sh

@@ -0,0 +1,2 @@
+ant
+scp dist/SnuviScriptRecoded.jar alpaga:../minecraft/server/mods/libs