Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@
@Override
public @Nullable String onRequest(OfflinePlayer offlinePlayer, @NotNull String params) {
// Split string in to an Array with underscores
List<String> paramsArray = Lists.newArrayList(REPatterns.UNDERSCORE.split(params));
List<String> paramsArray = Lists.newArrayList(
StringFormatter.parseQuotesInArgs(REPatterns.UNDERSCORE.split(params), "_"));

Check warning on line 91 in src/main/java/org/mvplugins/multiverse/core/PlaceholderExpansionHook.java

View workflow job for this annotation

GitHub Actions / checkstyle / checkstyle

[checkstyle] reported by reviewdog 🐶 The String "_" appears 2 times in the file. Raw Output: /github/workspace/src/main/java/org/mvplugins/multiverse/core/PlaceholderExpansionHook.java:91:88: warning: The String "_" appears 2 times in the file. (com.puppycrawl.tools.checkstyle.checks.coding.MultipleStringLiteralsCheck)

// No placeholder defined
if (paramsArray.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,20 @@
* @return The parsed args
*/
public static @NotNull Collection<String> parseQuotesInArgs(@NotNull String[] args) {
return parseQuotesInArgs(args, " ");

Check warning on line 121 in src/main/java/org/mvplugins/multiverse/core/utils/StringFormatter.java

View workflow job for this annotation

GitHub Actions / checkstyle / checkstyle

[checkstyle] reported by reviewdog 🐶 The String " " appears 2 times in the file. Raw Output: /github/workspace/src/main/java/org/mvplugins/multiverse/core/utils/StringFormatter.java:121:40: warning: The String " " appears 2 times in the file. (com.puppycrawl.tools.checkstyle.checks.coding.MultipleStringLiteralsCheck)
}

/**
* Parse quotes in args into a single string. E.g. ["\"my", "string\""] -> ["my string"]
*
* @param args The args to parse
* @param separator The separator to use between args when joining them
* @return The parsed args
*
* @since 5.8
*/
@ApiStatus.AvailableSince("5.8")

Check warning on line 133 in src/main/java/org/mvplugins/multiverse/core/utils/StringFormatter.java

View workflow job for this annotation

GitHub Actions / checkstyle / checkstyle

[checkstyle] reported by reviewdog 🐶 Cyclomatic Complexity is 12 (max allowed is 7). Raw Output: /github/workspace/src/main/java/org/mvplugins/multiverse/core/utils/StringFormatter.java:133:5: warning: Cyclomatic Complexity is 12 (max allowed is 7). (com.puppycrawl.tools.checkstyle.checks.metrics.CyclomaticComplexityCheck)
public static @NotNull Collection<String> parseQuotesInArgs(@NotNull String[] args, @NotNull String separator) {
List<String> result = new ArrayList<>(args.length);
StringBuilder current = new StringBuilder();
boolean inQuotes = false;
Expand All @@ -131,13 +145,13 @@
quoteStartIndex = i;
current.append(arg.substring(1));
} else if (inQuotes && arg.endsWith("\"")) {
current.append(" ").append(arg, 0, arg.length() - 1);
current.append(separator).append(arg, 0, arg.length() - 1);
result.add(current.toString());
current.setLength(0);
inQuotes = false;
quoteStartIndex = -1;
} else if (inQuotes) {
current.append(" ").append(arg);
current.append(separator).append(arg);
} else if (arg.startsWith("\"") && arg.endsWith("\"") && arg.length() > 1) {
// Fully quoted in one token
result.add(arg.substring(1, arg.length() - 1));
Expand Down
Loading