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
Yaruma3341 d2d126f02f Not stable version
Signed-off-by: Yaruma3341 <yaruma3341@gmail.com>
2019-02-23 17:53:31 +01:00

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;
}
}