Skip to content

Commit

Permalink
Sorting - Fix startup error caused by misconfiguration (#664)
Browse files Browse the repository at this point in the history
  • Loading branch information
NEZNAMY committed Jul 28, 2022
1 parent 6a2d509 commit 86b3cc4
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package me.neznamy.tab.shared.features.sorting.types;

import java.util.LinkedHashMap;
import java.util.Locale;

import me.neznamy.tab.api.chat.EnumChatFormat;
import me.neznamy.tab.shared.ITabPlayer;
import me.neznamy.tab.shared.features.sorting.Sorting;

import java.util.LinkedHashMap;
import java.util.Locale;

/**
* Sorting by a placeholder by values defined in list
*/
Expand All @@ -26,7 +26,11 @@ public class Placeholder extends SortingType {
public Placeholder(Sorting sorting, String options) {
super(sorting, getPlaceholder(options));
String[] args = options.split(":");
sortingMap = convertSortingElements(args[args.length-1].split(","));
if (args.length > 1)
sortingMap = convertSortingElements(args[args.length-1].split(","));
else
// Invalid configuration
sortingMap = new LinkedHashMap<>();
}

/**
Expand All @@ -39,6 +43,7 @@ public Placeholder(Sorting sorting, String options) {
*/
private static String getPlaceholder(String options) {
String[] args = options.split(":");
if (args.length == 1) return args[0]; // Missing predefined values
return options.substring(0, options.length()-args[args.length-1].length()-1);
}

Expand Down

0 comments on commit 86b3cc4

Please sign in to comment.