Skip to content

Commit 1a3a6c2

Browse files
committed
Fix sorting by value in details panel
1 parent 8e02cf4 commit 1a3a6c2

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

src/main/java/world/bentobox/level/config/BlockConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public BlockConfig(Level addon, YamlConfiguration blockValuesConfig, File file)
6464
// Validate
6565
if (isMaterial(key) || isSpawner(key) || isOther(key)) {
6666
// Store for lookup
67-
this.blockValues.put(key, blocks.getInt(key));
67+
this.blockValues.put(key.toLowerCase(Locale.ENGLISH), blocks.getInt(key));
6868
} else {
6969
addon.logError("Unknown listing in blocks section: " + key);
7070
}

src/main/java/world/bentobox/level/panels/DetailsPanel.java

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
11
package world.bentobox.level.panels;
22

33
import java.io.File;
4-
import java.util.ArrayList;
5-
import java.util.Comparator;
6-
import java.util.EnumMap;
7-
import java.util.HashMap;
8-
import java.util.List;
9-
import java.util.Map;
10-
import java.util.Objects;
11-
import java.util.Optional;
4+
import java.util.*;
125
import java.util.stream.Collectors;
136

147
import org.bukkit.Material;
@@ -263,6 +256,7 @@ private void updateFilters() {
263256
}
264257
// Sort and filter
265258
Comparator<BlockRec> sorter;
259+
System.out.println("activeFilter: " + activeFilter);
266260

267261
switch (this.activeFilter) {
268262
case COUNT -> {
@@ -285,17 +279,26 @@ private void updateFilters() {
285279
blockLimit = Objects.requireNonNullElse(this.addon.getBlockConfig().getLimit(o2.key()), 0);
286280
int o2Count = blockLimit > 0 ? Math.min(o2.value(), blockLimit) : o2.value();
287281

282+
System.out.println("o1.key(): " + o1.key());
283+
System.out.println("o1.key() class: " + o1.key().getClass());
284+
System.out.println("o2.key(): " + o2.key());
285+
288286
long o1Value = (long) o1Count
289-
* this.addon.getBlockConfig().getBlockValues().getOrDefault(o1.key(), 0);
287+
* this.addon.getBlockConfig().getBlockValues().getOrDefault(o1.key().toString().toLowerCase(Locale.ENGLISH), 0);
290288
long o2Value = (long) o2Count
291-
* this.addon.getBlockConfig().getBlockValues().getOrDefault(o2.key(), 0);
289+
* this.addon.getBlockConfig().getBlockValues().getOrDefault(o2.key().toString().toLowerCase(Locale.ENGLISH), 0);
290+
291+
System.out.println("o1Value: " + o1Value);
292+
System.out.println("o2Value: " + o2Value);
292293

293294
if (o1Value == o2Value) {
295+
System.out.println("has same value");
294296
String o1Name = Utils.prettifyObject(o1.key(), this.user);
295297
String o2Name = Utils.prettifyObject(o2.key(), this.user);
296298

297299
return String.CASE_INSENSITIVE_ORDER.compare(o1Name, o2Name);
298300
} else {
301+
System.out.println("compare long");
299302
return Long.compare(o2Value, o1Value);
300303
}
301304
};

0 commit comments

Comments
 (0)