Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ru.lisenochek.mcrust.objects.misc;
- import org.bukkit.Location;
- import org.bukkit.entity.Player;
- import ru.lisenochek.mcrust.sql.SQLManager;
- import ru.lisenochek.mcrust.utils.Cuboid;
- import java.util.HashMap;
- public class Radtown {
- private static HashMap<String, Radtown> radtownsMap = new HashMap<>();
- private static HashMap<Location, Radtown> locationsMap = new HashMap<>();
- private String name;
- private Cuboid cuboid;
- private Radiation radiation;
- private Radtown(String name, Radiation radiation, Cuboid cuboid) {
- this.name = name;
- this.cuboid = cuboid;
- this.radiation = radiation;
- for (Location loc : cuboid.getBlocksList()) locationsMap.put(loc, this);
- radtownsMap.put(name, this);
- }
- public static Radtown create(String name, Radiation radiation, Cuboid cuboid) {
- return new Radtown(name, radiation, cuboid);
- }
- public static Radtown fromName(String name) {
- return radtownsMap.get(name);
- }
- public static Radtown fromLocation(Location location) {
- return locationsMap.get(location);
- }
- public static boolean checkBreak(Player player, Location location) {
- if (locationsMap.get(location) == null) return true;
- return player.hasPermission("mcrust.admin") || CustomBlock.getBlock(location.getBlock()).getType().isIgnoreBreakCupboard();
- }
- public static boolean checkPlace(Player player, Location location) {
- if (locationsMap.get(location) == null) return true;
- return player.hasPermission("mcrust.admin") || CustomBlock.getBlock(location.getBlock()).getType().isIgnoreBuildCupboard();
- }
- public String getName() {
- return name;
- }
- public Cuboid getCuboid() {
- return cuboid;
- }
- public Radiation getRadiation() {
- return radiation;
- }
- public void remove() {
- for (Location location : cuboid.getBlocksList()) locationsMap.remove(location);
- radtownsMap.remove(name);
- SQLManager.getManager().deleteRadtownData(this);
- }
- public enum Radiation {
- NONE(0, 0, 0),
- LOW(10, 60, 35),
- MEDIUM(45, 25, 50),
- HARD(75, 15, 80);
- private int minimumProtection;
- private int triggerTime;
- private int chance;
- Radiation(int minimumProtection, int triggerTime, int chance) {
- this.minimumProtection = minimumProtection;
- this.triggerTime = triggerTime;
- this.chance = chance;
- }
- public int getMinimumProtection() {
- return minimumProtection;
- }
- public int getTriggerTime() {
- return triggerTime;
- }
- public int getChance() {
- return chance;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement