SteamWar/FightSystem
Archiviert
13
1
Dieses Repository wurde am 2024-08-05 archiviert. Du kannst Dateien ansehen und es klonen, aber nicht pushen oder Issues/Pull-Requests öffnen.
FightSystem/src/me/yaruma/fightsystem/utils/Region.java

36 Zeilen
1.5 KiB
Java

package me.yaruma.fightsystem.utils;
import org.bukkit.Location;
import org.bukkit.entity.Player;
public class Region {
2019-02-23 16:59:25 +01:00
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);
}
2019-02-23 16:59:25 +01:00
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);
}
2019-02-23 16:59:25 +01:00
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);
}
2019-02-23 16:59:25 +01:00
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, margin) && inRange(location.getBlockZ(), minZ, maxZ, margin);
}
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;
}
}