wip: code cleanup
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package eu.mhsl.minecraft.pixelblocks.utils;
|
||||
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public enum Direction {
|
||||
north,
|
||||
east,
|
||||
south,
|
||||
west;
|
||||
|
||||
public static Direction vectorToDirection(Vector vector) {
|
||||
if(Math.abs(vector.getX()) > Math.abs(vector.getZ())) {
|
||||
if(vector.getX() >= 0) {
|
||||
return east;
|
||||
} else {
|
||||
return west;
|
||||
}
|
||||
} else {
|
||||
if(vector.getZ() >= 0) {
|
||||
return south;
|
||||
} else {
|
||||
return north;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,14 @@
|
||||
package eu.mhsl.minecraft.pixelblocks.utils;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class MinMaxUtil {
|
||||
public static <I, O extends Comparable<O>> O getMinProperty(List<I> list, Function<I, O> supplier) {
|
||||
return supplier.apply(list.stream().min(Comparator.comparing(supplier)).orElseThrow());
|
||||
}
|
||||
public static <I, O extends Comparable<O>> O getMaxProperty(List<I> list, Function<I, O> supplier) {
|
||||
return supplier.apply(list.stream().max(Comparator.comparing(supplier)).orElseThrow());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user