package gq.unurled.raxen.utils; import gq.unurled.raxen.Raxen; import gq.unurled.raxen.components.dungeons.Gate; import gq.unurled.raxen.components.dungeons.Rank; import gq.unurled.raxen.components.dungeons.Types; import org.bukkit.Bukkit; import org.bukkit.Location; import org.jetbrains.annotations.NotNull; import java.util.HashMap; import java.util.Random; public class DungeonUtils { /** * get the radius from the rank of a dungeon */ public static Integer getRadiusFromRank(@NotNull Rank rank) { Integer radius = 1; switch (rank) { case F: radius = 4; case E: radius = 5; case D: radius = 8; case C: radius = 10; case B: radius = 15; case A: radius = 20; case S: radius = 30; case SS: radius = 40; case SSS: radius = 50; case WORLD: radius = 100; case UNBEATABLE: radius = 200; case NOT_DEFINED: radius = 1000; } return radius; } /** * used to spawn monster based on random */ public static void fromTypeToMonster(Types types, Rank rank) { Random r = new Random(); r.nextInt(); } /** * if a gate is in range of the player * @return boolean */ public static Boolean isInRange(Location loc) { Raxen main = (Raxen) Bukkit.getServer().getPluginManager().getPlugin("Raxen"); HashMap gats = main.getManager().getDungeonsManager().getGates(); for (Gate g : gats.keySet()) { Double x = g.getLoc().getX(); Double y = g.getLoc().getY(); Double z = g.getLoc().getZ(); Double radius = Double.valueOf(g.getPortalRadius()); if (loc.getX() < x+radius && loc.getX() > x-radius) { if (loc.getY() < y+radius && loc.getY() > y-radius) { if (loc.getZ() < z+radius && loc.getZ() > z-radius) { return true; } } } } return false; } /** * if a gate is in range of the player * @return the gates which is in range */ public static Gate whichIsInRange(Location loc) { Raxen main = (Raxen) Bukkit.getServer().getPluginManager().getPlugin("Raxen"); HashMap gats = main.getManager().getDungeonsManager().getGates(); for (Gate g : gats.keySet()) { Double x = g.getLoc().getX(); Double y = g.getLoc().getY(); Double z = g.getLoc().getZ(); Double radius = Double.valueOf(g.getPortalRadius()); if (loc.getX() < x+radius && loc.getX() > x-radius) { if (loc.getY() < y+radius && loc.getY() > y-radius) { if (loc.getZ() < z+radius && loc.getZ() > z-radius) { return g; } } } } return null; } }