Skip to content

Commit

Permalink
debug handling cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Nov 6, 2021
1 parent cf48b3f commit c3266f8
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,61 +153,40 @@ public static List<String> doEvents(List<String> eventNames, ScriptEntryData dat
}

public static List<String> doEvents(List<String> eventNames, ScriptEntryData data, Map<String, ObjectTag> context) {

try {
List<String> determinations = new ArrayList<>();

// Trim again to catch events that don't trim internally.
eventNames = trimEvents(eventNames);

for (String eventName : eventNames) {

if (events.containsKey("ON " + eventName.toUpperCase()))

{
if (events.containsKey("ON " + eventName.toUpperCase())) {
for (WorldScriptContainer script : events.get("ON " + eventName.toUpperCase())) {

if (script == null) {
continue;
}

// Fetch script from Event
List<ScriptEntry> entries = script.getEntries(data, "events.on " + eventName);

if (entries.isEmpty()) {
continue;
}

Debug.report(script, "Event",
ArgumentHelper.debugObj("Type", "on " + eventName)
+ script.getAsScriptArg().debug()
+ data.toString()
+ (context != null ? ArgumentHelper.debugObj("Context", context.toString()) : ""));

Debug.echoDebug(script, Debug.DebugElement.Header, "Building event 'ON " + eventName.toUpperCase()
+ "' for " + script.getName());

Debug.report(script, "Event", ArgumentHelper.debugObj("Type", "on " + eventName), script.getAsScriptArg(), data.toString(), (context != null ? ArgumentHelper.debugObj("Context", context.toString()) : ""));
Debug.echoDebug(script, Debug.DebugElement.Header, "Building event 'ON " + eventName.toUpperCase() + "' for " + script.getName());
// Add entries and context to the queue
ScriptQueue queue = new InstantQueue(script.getName());
queue.addEntries(entries);

if (context != null) {
OldEventContextSource oecs = new OldEventContextSource();
oecs.contexts = context;
queue.setContextSource(oecs);
}

// Start the queue!
queue.start();

// Check the determination
if (queue.determinations != null) {
determinations = queue.determinations;
}
}
}
}

return determinations;
}
catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ public static String db(String prefix, boolean value) {
}

public static String db(String prefix, Object value) {
if (value == null) {
return "";
}
return ArgumentHelper.debugObj(prefix, value);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ public class WebGetCommand extends AbstractCommand implements Holdable {

public WebGetCommand() {
setName("webget");
setSyntax("webget [<url>] (post:<data>) (headers:<header>/<value>|...) (timeout:<duration>/{10s}) (savefile:<path>) (hide_failure)");
setSyntax("webget [<url>] (post:<data>) (headers:<map>) (timeout:<duration>/{10s}) (savefile:<path>) (hide_failure)");
setRequiredArguments(1, 7);
isProcedural = false;
}

// <--[command]
// @Name Webget
// @Syntax webget [<url>] (data:<data>) (method:<method>) (headers:<header>/<value>|...) (timeout:<duration>/{10s}) (savefile:<path>) (hide_failure)
// @Syntax webget [<url>] (data:<data>) (method:<method>) (headers:<map>) (timeout:<duration>/{10s}) (savefile:<path>) (hide_failure)
// @Required 1
// @Maximum 7
// @Short Gets the contents of a web page or API response.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public ForeachCommand() {
// @Usage
// Use to iterate through a list of players and run commands automatically linked to each player in that list.
// - foreach <server.online_players> as:__player:
// - narrate "Thanks for coming to our server! Here's a bonus $50.00!"
// - narrate "Thanks for coming to our server, <player.name>! Here's a bonus $50.00!"
// - money give quantity:50
//
// -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public void execute(ScriptEntry scriptEntry) {
Deprecations.queueClear.warn(scriptEntry);
}
if (scriptEntry.dbCallShouldDebug()) {
Debug.report(scriptEntry, getName(), queue, db("Action", action.toString()), (action == Action.DELAY ? delay.debug() : null));
Debug.report(scriptEntry, getName(), queue, db("Action", action.toString()), delay);
}
switch (action) {
case CLEAR:
Expand Down

0 comments on commit c3266f8

Please sign in to comment.