Fixed extension column appearing multiple times

This commit is contained in:
Rsl1122 2019-05-12 13:23:40 +03:00
parent ad48a016a3
commit ef35312844

View File

@ -34,7 +34,6 @@ import com.djrapitops.plan.utilities.html.icon.Family;
import com.djrapitops.plan.utilities.html.icon.Icon;
import java.util.*;
import java.util.stream.Collectors;
/**
* Parsing utility for creating jQuery Datatables JSON for a Players Table.
@ -70,11 +69,11 @@ public class PlayersTableJSONParser {
// Data
this.players = players;
this.extensionData = extensionData;
extensionDescriptives = extensionData.values().stream()
.map(ExtensionTabData::getDescriptives)
.flatMap(Collection::stream)
.distinct().sorted((one, two) -> String.CASE_INSENSITIVE_ORDER.compare(one.getName(), two.getName()))
.collect(Collectors.toList());
extensionDescriptives = new ArrayList<>();
addExtensionDescriptives(extensionData);
extensionDescriptives.sort((one, two) -> String.CASE_INSENSITIVE_ORDER.compare(one.getName(), two.getName()));
// Settings
this.maxPlayers = maxPlayers;
this.activeMsThreshold = activeMsThreshold;
@ -90,6 +89,18 @@ public class PlayersTableJSONParser {
this.decimalFormatter = formatters.decimals();
}
private void addExtensionDescriptives(Map<UUID, ExtensionTabData> extensionData) {
Set<String> foundDescriptives = new HashSet<>();
for (ExtensionTabData tabData : extensionData.values()) {
for (ExtensionDescriptive descriptive : tabData.getDescriptives()) {
if (!foundDescriptives.contains(descriptive.getName())) {
extensionDescriptives.add(descriptive);
foundDescriptives.add(descriptive.getName());
}
}
}
}
public String toJSONString() {
String data = parseData();
String columnHeaders = parseColumnHeaders();