diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/NewJREUtil.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/NewJREUtil.java index a0df3f7c5..3b7f7c758 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/NewJREUtil.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/NewJREUtil.java @@ -93,13 +93,11 @@ public class NewJREUtil { // If the runtime version selected by the user is not appropriate for this version (which means the game won't run at all) // automatically pick from either an already installed runtime, or a runtime packed with the launcher - MathUtils.RankedValue nearestInstalledRuntime = getNearestInstalledRuntime(gameRequiredVersion); - MathUtils.RankedValue nearestInternalRuntime = getNearestInternalRuntime(gameRequiredVersion); + MathUtils.RankedValue nearestInstalledRuntime = getNearestInstalledRuntime(gameRequiredVersion); + MathUtils.RankedValue nearestInternalRuntime = getNearestInternalRuntime(gameRequiredVersion); - MathUtils.RankedValue selectedRankedRuntime = (MathUtils.RankedValue) MathUtils.multiTypeObjectMin( - nearestInternalRuntime, nearestInstalledRuntime, - (v1)->v1.rank, - (v2)->v2.rank + MathUtils.RankedValue selectedRankedRuntime = MathUtils.objectMin( + nearestInternalRuntime, nearestInstalledRuntime, (value)->value.rank ); // No possible selections diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/utils/MathUtils.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/utils/MathUtils.java index b00b49257..f3a49f64a 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/utils/MathUtils.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/utils/MathUtils.java @@ -57,21 +57,19 @@ public class MathUtils { } /** - * Out of two objects with different types, select one with the lowest value. + * Out of two objects, select one with the lowest value. * @param object1 Object 1 for comparsion * @param object2 Object 2 for comparsion - * @param valueProvider1 Value provider for object 1 - * @param valueProvider2 Value provider for object 2 + * @param valueProvider Value provider for the objects * @return If value of object 1 is lower than or equal to object 2, returns object 1 * Otherwise, returns object 2 - * @param Type of object 1 - * @param Type of object 2 + * @param Type of objects */ - public static Object multiTypeObjectMin(T object1, Y object2, ValueProvider valueProvider1, ValueProvider valueProvider2) { + public static T objectMin(T object1, T object2, ValueProvider valueProvider) { if(object1 == null) return object2; if(object2 == null) return object1; - int value1 = valueProvider1.getValue(object1); - int value2 = valueProvider2.getValue(object2); + int value1 = valueProvider.getValue(object1); + int value2 = valueProvider.getValue(object2); if(value1 <= value2) { return object1; } else {