Skip to content

Commit

Permalink
fix(tsl): BOTH action crashing on empty actions
Browse files Browse the repository at this point in the history
  • Loading branch information
iGoodie committed Jan 2, 2020
1 parent 7c2c660 commit 3252fef
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Expand Up @@ -5,7 +5,7 @@ org.gradle.daemon=false

mod_id=twitchspawn
mod_group=net.programmer.igoodie
mod_version=1.4.13
mod_version=1.4.14

minecraft_version=1.14.4
forge_version=28.0.83
Expand Down
Expand Up @@ -82,12 +82,24 @@ private TSLAction parseSingleAction(List<String> actionWords) throws TSLSyntaxEr
return TSLParser.parseAction(actionName, actionArgs);
}

private List<List<String>> splitActions(List<String> words) {
private List<List<String>> splitActions(List<String> words) throws TSLSyntaxError {
List<List<String>> actionsRaw = new LinkedList<>();
List<String> actionRaw = new LinkedList<>();

for (String word : words) {
if (word.equalsIgnoreCase(DELIMITER)) {
for (int i = 0; i < words.size(); i++) {
boolean lastWord = (i == words.size() - 1);
String word = words.get(i);

if (lastWord) {
if (word.equalsIgnoreCase(DELIMITER))
throw new TSLSyntaxError("Unexpected %s word at the end.", DELIMITER);
actionRaw.add(word);
}

if (word.equalsIgnoreCase(DELIMITER) || lastWord) {
if (actionRaw.isEmpty())
throw new TSLSyntaxError("Expected an action after %s word.", DELIMITER);

actionsRaw.add(actionRaw);
actionRaw = new LinkedList<>();
continue;
Expand All @@ -96,8 +108,6 @@ private List<List<String>> splitActions(List<String> words) {
actionRaw.add(word);
}

actionsRaw.add(actionRaw);

return actionsRaw;
}

Expand Down

0 comments on commit 3252fef

Please sign in to comment.