Skip to content

Commit

Permalink
'matched to multiple scriptevents': show events matched
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Dec 8, 2019
1 parent f64275b commit c392128
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public static class ScriptPath {
public String[] eventArgs;
public String[] eventArgsLower;
public String[] rawEventArgs;
public int matches = 0;
public List<ScriptEvent> matches = new ArrayList<>();

public String rawEventArgAt(int index) {
return index < rawEventArgs.length ? rawEventArgs[index] : "";
Expand Down Expand Up @@ -199,7 +199,7 @@ else if (evt.str.contains("@")) {
for (ScriptPath path : paths) {
if (event.couldMatch(path)) {
event.eventPaths.add(path);
path.matches++;
path.matches.add(event);
if (Debug.showLoading) {
Debug.log("Event match, " + event.getName() + " matched for '" + path + "'!");
}
Expand All @@ -217,10 +217,10 @@ else if (evt.str.contains("@")) {
}
}
for (ScriptPath path : paths) {
if (path.matches > 1) {
Debug.log("Event " + path + " is matched to multiple ScriptEvents.");
if (path.matches.size() > 1) {
Debug.log("Event " + path + " is matched to multiple ScriptEvents: " + CoreUtilities.join(", ", path.matches));
}
else if (path.matches == 0) {
else if (path.matches.isEmpty()) {
Debug.log("Event " + path + " is not matched to any ScriptEvents.");
}
}
Expand Down Expand Up @@ -484,6 +484,11 @@ else if (name.equals("event_name")) {
return null;
}

@Override
public String toString() {
return getName();
}

// <--[language]
// @name Advanced Script Event Matching
// @group Script Events
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@ public class CoreUtilities {

public static TagContext noDebugContext;

public static String join(String delim, List objects) {
StringBuilder output = new StringBuilder(objects.size() * 5);
for (int i = 0; i < objects.size(); i++) {
output.append(objects.get(i));
if (i + 1 < objects.size()) {
output.append(delim);
}
}
return output.toString();
}

public static String stringifyNullPass(Object obj) {
return obj == null ? null : obj.toString();
}
Expand Down

0 comments on commit c392128

Please sign in to comment.