2022-06-09 21:27:04 +00:00
|
|
|
package me.unurled.raxen.utils;
|
2022-04-05 20:11:30 +00:00
|
|
|
|
2022-06-09 21:27:04 +00:00
|
|
|
import me.unurled.raxen.Raxen;
|
|
|
|
import me.unurled.raxen.components.dungeons.Gate;
|
|
|
|
import me.unurled.raxen.components.dungeons.Rank;
|
|
|
|
import me.unurled.raxen.components.dungeons.Types;
|
2022-05-24 09:25:35 +00:00
|
|
|
import org.bukkit.Bukkit;
|
|
|
|
import org.bukkit.Location;
|
2022-04-07 20:35:01 +00:00
|
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
|
|
2022-05-24 09:25:35 +00:00
|
|
|
import java.util.HashMap;
|
2022-04-07 20:35:01 +00:00
|
|
|
import java.util.Random;
|
2022-04-05 20:11:30 +00:00
|
|
|
|
|
|
|
public class DungeonUtils {
|
|
|
|
|
2022-04-14 20:35:27 +00:00
|
|
|
/**
|
|
|
|
* get the radius from the rank of a dungeon
|
|
|
|
*/
|
2022-04-07 20:35:01 +00:00
|
|
|
public static Integer getRadiusFromRank(@NotNull Rank rank) {
|
2022-04-05 20:11:30 +00:00
|
|
|
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;
|
|
|
|
}
|
2022-04-07 20:35:01 +00:00
|
|
|
|
2022-04-14 20:35:27 +00:00
|
|
|
/**
|
|
|
|
* used to spawn monster based on random
|
|
|
|
*/
|
2022-04-07 20:35:01 +00:00
|
|
|
public static void fromTypeToMonster(Types types, Rank rank) {
|
|
|
|
Random r = new Random();
|
|
|
|
r.nextInt();
|
|
|
|
}
|
2022-05-24 09:25:35 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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<Gate, Location> 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<Gate, Location> 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;
|
|
|
|
}
|
2022-04-05 20:11:30 +00:00
|
|
|
}
|