Skip to content

Commit

Permalink
More splitters.
Browse files Browse the repository at this point in the history
  • Loading branch information
wizjany committed Feb 13, 2019
1 parent b225984 commit 9835816
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public Mask parseFromInput(String input, ParserContext context) throws InputPars
String states = input.substring(2, input.length() - 1);
try {
return new BlockStateMask(extent,
Splitter.on(',').omitEmptyStrings().withKeyValueSeparator('=').split(states));
Splitter.on(',').omitEmptyStrings().trimResults().withKeyValueSeparator('=').split(states));
} catch (Exception e) {
throw new InputParseException("Invalid states.", e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package com.sk89q.worldedit.extension.factory.parser.pattern;

import com.google.common.base.Splitter;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.sk89q.worldedit.WorldEdit;
Expand Down Expand Up @@ -60,14 +61,9 @@ public Pattern parseFromInput(String input, ParserContext context) throws InputP
} else {
// states given
if (!parts[1].endsWith("]")) throw new InputParseException("Invalid state format.");
String[] allStates = parts[1].substring(0, parts[1].length() - 1).split(",");

Map<String, String> statesToSet = Maps.newHashMap();
for (String state : allStates) {
String[] stateParts = state.split("=", 2);
if (stateParts.length != 2) throw new InputParseException("Invalid state format.");
statesToSet.put(stateParts[0], stateParts[1]);
}
Map<String, String> statesToSet = Splitter.on(',')
.omitEmptyStrings().trimResults().withKeyValueSeparator('=')
.split(parts[1].substring(0, parts[1].length() - 1));
if (type.isEmpty()) {
return new StateApplyingPattern(extent, statesToSet);
} else {
Expand Down

0 comments on commit 9835816

Please sign in to comment.