commands return integer value if possible, fixes #408

handle infinite values as infinities.
This commit is contained in:
gnembon committed 2020-09-05 02:06:59 -03:00
1 parent ddcf3367f5
commit 1006e0ac40
7 files changed
+63 -34

No files matched your search

@@ -221,10 +221,10 @@ public class CarpetScriptServer
requires((player) -> modules.containsKey(hostName)).
executes( (c) ->
{
String response = modules.get(hostName).retrieveForExecution(c.getSource()).
Value response = modules.get(hostName).retrieveForExecution(c.getSource()).
handleCommand(c.getSource(),"__command", null, "");
if (!response.isEmpty()) Messenger.m(c.getSource(), "gi "+response);
return 1;
if (!response.isNull()) Messenger.m(c.getSource(), "gi "+response.getString());
return (int)response.readInteger();
});
for (String function : host.globaFunctionNames(host.main, s -> !s.startsWith("_")).sorted().collect(Collectors.toList()))
@@ -233,17 +233,17 @@ public class CarpetScriptServer
then(literal(function).
requires((player) -> modules.containsKey(hostName) && modules.get(hostName).getFunction(function) != null).
executes( (c) -> {
String response = modules.get(hostName).retrieveForExecution(c.getSource()).
Value response = modules.get(hostName).retrieveForExecution(c.getSource()).
handleCommand(c.getSource(), function,null,"");
if (!response.isEmpty()) Messenger.m(c.getSource(),"gi "+response);
return 1;
if (!response.isNull()) Messenger.m(c.getSource(),"gi "+response.getString());
return (int)response.readInteger();
}).
then(argument("args...", StringArgumentType.greedyString()).
executes( (c) -> {
String response = modules.get(hostName).retrieveForExecution(c.getSource()).
Value response = modules.get(hostName).retrieveForExecution(c.getSource()).
handleCommand(c.getSource(), function,null, StringArgumentType.getString(c, "args..."));
if (!response.isEmpty()) Messenger.m(c.getSource(), "gi "+response);
return 1;
if (!response.isNull()) Messenger.m(c.getSource(), "gi "+response.getString());
return (int)response.readInteger();
})));
}
Messenger.m(source, "gi "+hostName+" app "+loaded+" with /"+hostName+" command");