36 Zeilen
1.5 KiB
Java
36 Zeilen
1.5 KiB
Java
package me.yaruma.fightsystem.utils;
|
|
|
|
import org.bukkit.Location;
|
|
import org.bukkit.entity.Player;
|
|
|
|
public class Region {
|
|
|
|
public static boolean isInRange(Location location, int minX, int minY, int minZ, int xRange, int yRange, int zRange, int margin) {
|
|
return isInRegion(location, minX, minY, minZ, minX + xRange, minY + yRange, minZ + zRange, margin);
|
|
}
|
|
|
|
public static boolean isInRegion(Location location, int minX, int minY, int minZ, int maxX, int maxY, int maxZ, int margin) {
|
|
return isIn2DRegion(location, minX, minZ, maxX, maxZ, margin) && inRange(location.getBlockY(), minY, maxY, margin);
|
|
}
|
|
|
|
public static boolean isIn2DRange(Location location, int minX, int minZ, int xRange, int zRange, int margin){
|
|
return isIn2DRegion(location, minX, minZ, minX + xRange, minZ + zRange, margin);
|
|
}
|
|
|
|
public static boolean isIn2DRegion(Location location, int minX, int minZ, int maxX, int maxZ, int margin){
|
|
return inRange(location.getBlockX(), minX, maxX, margin) && inRange(location.getBlockZ(), minZ, maxZ, margin);
|
|
}
|
|
|
|
public static boolean isIn2DRegion(Location location, int minX, int minZ, int maxX, int maxZ){
|
|
return inRange(location.getBlockX(), minX, maxX) && inRange(location.getBlockZ(), minZ, maxZ);
|
|
}
|
|
|
|
public static boolean inRange(double value, int min, int max, int margin){
|
|
return inRange(value, min-margin, max+margin);
|
|
}
|
|
|
|
public static boolean inRange(double value, int min, int max){
|
|
return min <= value && value <= max;
|
|
}
|
|
}
|