Add logger to initialize + fix silent crash

This commit is contained in:
dginovker
2019-12-23 23:19:01 -05:00
parent 153ce9e255
commit 731c4cb08e
4 changed files with 15 additions and 7 deletions
@@ -19,10 +19,15 @@ public class ActionHandler {
private static String debugString = ""; private static String debugString = "";
public void handleInteractWith(Action a) public void handleInteractWithEntityByID(Action a)
{ {
if (a.getParamCount() == 0)
{
log("ERROR: " + a.getAction() + " does not have the required parameters!");
return;
}
int[] ids = new int[a.getParamCount() -1]; int[] ids = new int[a.getParamCount() -1];
for (int i = 0; i < a.getParamCount() - 1; i++) { for (int i = 0; i < ids.length; i++) {
ids[i] = a.getParam(i); ids[i] = a.getParam(i);
} }
interactWithEntity(ids, a.getParamAsString(a.getParamCount() - 1)); interactWithEntity(ids, a.getParamAsString(a.getParamCount() - 1));
+1 -1
View File
@@ -21,7 +21,7 @@ import static scriptfactory.VarsMethods.log;
* Welcome to AIO AIO - ScriptFactory. Make your own scripts! * Welcome to AIO AIO - ScriptFactory. Make your own scripts!
*/ */
@ScriptManifest(author = "Before", name = "Script Factory 1.15", category = Category.OTHER, version = 1.15, description = "Create your own scripts!", servers = "All") @ScriptManifest(author = "Before", name = "Script Factory 1.16", category = Category.OTHER, version = 1.16, description = "Create your own scripts!", servers = "All")
public class Core extends Script implements Paintable { public class Core extends Script implements Paintable {
private ArrayList<Action> actions = new ArrayList<>(); private ArrayList<Action> actions = new ArrayList<>();
@@ -79,7 +79,7 @@ public class ActionExecutor {
switch (action.getMethod().replace("-", " ").trim()) switch (action.getMethod().replace("-", " ").trim())
{ {
case "Interact with entity by ID": case "Interact with entity by ID":
actionHandler.handleInteractWith(action); actionHandler.handleInteractWithEntityByID(action);
break; break;
case "Interact with entity by location": case "Interact with entity by location":
actionHandler.handleInteractWithByLoc(action); actionHandler.handleInteractWithByLoc(action);
+6 -3
View File
@@ -1,6 +1,9 @@
package scriptfactory; package scriptfactory;
import org.parabot.core.Core;
import org.parabot.core.ui.BotUI;
import org.parabot.core.ui.Logger; import org.parabot.core.ui.Logger;
import org.rev317.min.accessors.Client;
import org.rev317.min.api.methods.*; import org.rev317.min.api.methods.*;
import scriptfactory.Actions.Action; import scriptfactory.Actions.Action;
import scriptfactory.Actions.Logic.Endif; import scriptfactory.Actions.Logic.Endif;
@@ -27,11 +30,11 @@ public class VarsMethods {
public static void log(String str) public static void log(String str)
{ {
if (str.toLowerCase().contains("error")) if (str.toLowerCase().contains("error") || str.toLowerCase().contains("warn"))
{ {
//TODO: Open the logger Logger.getInstance().setVisible(true);
//Put it in the paint as well //Put it in the paint as well
currentAction = "ERROR (See Logger)"; currentAction = "ERR/WARN (See log)";
} }
Logger.addMessage(str, false); Logger.addMessage(str, false);
System.out.println(str); System.out.println(str);