mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-11 21:55:34 -04:00
Style[launcher]: simplify rank check
This commit is contained in:
parent
ed048fb4cb
commit
045018f8e0
@ -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)
|
// 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
|
// automatically pick from either an already installed runtime, or a runtime packed with the launcher
|
||||||
MathUtils.RankedValue<Runtime> nearestInstalledRuntime = getNearestInstalledRuntime(gameRequiredVersion);
|
MathUtils.RankedValue<?> nearestInstalledRuntime = getNearestInstalledRuntime(gameRequiredVersion);
|
||||||
MathUtils.RankedValue<InternalRuntime> nearestInternalRuntime = getNearestInternalRuntime(gameRequiredVersion);
|
MathUtils.RankedValue<?> nearestInternalRuntime = getNearestInternalRuntime(gameRequiredVersion);
|
||||||
|
|
||||||
MathUtils.RankedValue<?> selectedRankedRuntime = (MathUtils.RankedValue<?>) MathUtils.multiTypeObjectMin(
|
MathUtils.RankedValue<?> selectedRankedRuntime = MathUtils.objectMin(
|
||||||
nearestInternalRuntime, nearestInstalledRuntime,
|
nearestInternalRuntime, nearestInstalledRuntime, (value)->value.rank
|
||||||
(v1)->v1.rank,
|
|
||||||
(v2)->v2.rank
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// No possible selections
|
// No possible selections
|
||||||
|
@ -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 object1 Object 1 for comparsion
|
||||||
* @param object2 Object 2 for comparsion
|
* @param object2 Object 2 for comparsion
|
||||||
* @param valueProvider1 Value provider for object 1
|
* @param valueProvider Value provider for the objects
|
||||||
* @param valueProvider2 Value provider for object 2
|
|
||||||
* @return If value of object 1 is lower than or equal to object 2, returns object 1
|
* @return If value of object 1 is lower than or equal to object 2, returns object 1
|
||||||
* Otherwise, returns object 2
|
* Otherwise, returns object 2
|
||||||
* @param <T> Type of object 1
|
* @param <T> Type of objects
|
||||||
* @param <Y> Type of object 2
|
|
||||||
*/
|
*/
|
||||||
public static <T,Y> Object multiTypeObjectMin(T object1, Y object2, ValueProvider<T> valueProvider1, ValueProvider<Y> valueProvider2) {
|
public static <T> T objectMin(T object1, T object2, ValueProvider<T> valueProvider) {
|
||||||
if(object1 == null) return object2;
|
if(object1 == null) return object2;
|
||||||
if(object2 == null) return object1;
|
if(object2 == null) return object1;
|
||||||
int value1 = valueProvider1.getValue(object1);
|
int value1 = valueProvider.getValue(object1);
|
||||||
int value2 = valueProvider2.getValue(object2);
|
int value2 = valueProvider.getValue(object2);
|
||||||
if(value1 <= value2) {
|
if(value1 <= value2) {
|
||||||
return object1;
|
return object1;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user