Skip to content

Commit 12dd1fb

Browse files
committed
Fix build
1 parent 90b2c2e commit 12dd1fb

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

enigma-swing/src/main/java/org/quiltmc/enigma/gui/search/SearchEntry.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package org.quiltmc.enigma.gui.search;
22

3-
import org.quiltmc.enigma.gui.dialog.SearchDialog;
4-
53
import java.util.List;
64

75
public interface SearchEntry {
@@ -15,5 +13,9 @@ public interface SearchEntry {
1513
*/
1614
String getIdentifier();
1715

18-
SearchDialog.Type getType();
16+
/**
17+
* Returns the priority of the type of this entry. Entries with higher
18+
* priorities show up higher in the result list. Should be greater than zero.
19+
*/
20+
int getTypePriority();
1921
}

enigma-swing/src/main/java/org/quiltmc/enigma/gui/search/SearchUtil.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package org.quiltmc.enigma.gui.search;
22

3-
import org.quiltmc.enigma.gui.dialog.SearchDialog;
43
import org.quiltmc.enigma.util.Pair;
54

65
import java.util.ArrayList;
@@ -160,8 +159,7 @@ public float getScore(String term, int hits) {
160159
}
161160

162161
// modify by type
163-
int typeModifier = SearchDialog.Type.values().length - this.searchEntry.getType().ordinal() + 1;
164-
return maxScore * (hits + 1) * typeModifier;
162+
return maxScore * (hits + 1) * this.searchEntry.getTypePriority();
165163
}
166164

167165
/**
@@ -211,7 +209,11 @@ private static float getScoreFor(String term, String[] name) {
211209
}
212210

213211
private static <K, V> void merge(Map<K, V> self, Map<K, V> source, BiFunction<V, V, V> combiner) {
214-
source.forEach((k, v) -> self.compute(k, (_k, v1) -> v1 == null ? v : v == null ? v1 : combiner.apply(v, v1)));
212+
source.forEach((k, v) -> {
213+
if (v != null) {
214+
self.merge(k, v, combiner);
215+
}
216+
});
215217
}
216218

217219
public static <T extends SearchEntry> Entry<T> from(T e) {

0 commit comments

Comments
 (0)