SHARE
TWEET

Untitled

Lisenochek Oct 22nd, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package ru.lisenochek.mcrust.objects.misc;
  2.  
  3. import org.bukkit.Location;
  4. import org.bukkit.entity.Player;
  5. import ru.lisenochek.mcrust.sql.SQLManager;
  6. import ru.lisenochek.mcrust.utils.Cuboid;
  7.  
  8. import java.util.HashMap;
  9.  
  10. public class Radtown {
  11.  
  12.     private static HashMap<String, Radtown> radtownsMap = new HashMap<>();
  13.     private static HashMap<Location, Radtown> locationsMap = new HashMap<>();
  14.  
  15.     private String name;
  16.     private Cuboid cuboid;
  17.     private Radiation radiation;
  18.  
  19.     public Radtown(String name, Radiation radiation, Cuboid cuboid) {
  20.         this.name = name;
  21.         this.cuboid = cuboid;
  22.         this.radiation = radiation;
  23.         for (Location loc : cuboid.getBlocksList()) locationsMap.put(loc, this);
  24.         radtownsMap.put(name, this);
  25.     }
  26.  
  27.     public static Radtown fromName(String name) {
  28.         return radtownsMap.get(name);
  29.     }
  30.  
  31.     public static Radtown fromLocation(Location location) {
  32.         return locationsMap.get(location);
  33.     }
  34.  
  35.     public static boolean checkBreak(Player player, Location location) {
  36.         if (locationsMap.get(location) == null) return true;
  37.         return player.hasPermission("mcrust.admin") || CustomBlock.getBlock(location.getBlock()).getType().isIgnoreBreakCupboard();
  38.     }
  39.  
  40.     public static boolean checkPlace(Player player, Location location) {
  41.         if (locationsMap.get(location) == null) return true;
  42.         return player.hasPermission("mcrust.admin") || CustomBlock.getBlock(location.getBlock()).getType().isIgnoreBuildCupboard();
  43.     }
  44.  
  45.     public String getName() {
  46.         return name;
  47.     }
  48.  
  49.     public Cuboid getCuboid() {
  50.         return cuboid;
  51.     }
  52.  
  53.     public Radiation getRadiation() {
  54.         return radiation;
  55.     }
  56.  
  57.     public void remove() {
  58.         for (Location location : cuboid.getBlocksList()) locationsMap.remove(location);
  59.         radtownsMap.remove(name);
  60.         SQLManager.getManager().deleteRadtownData(this);
  61.     }
  62.  
  63.     public enum Radiation {
  64.  
  65.         NONE(0, 0, 0),
  66.         LOW(10, 60, 35),
  67.         MEDIUM(45, 25, 50),
  68.         HARD(75, 15, 80);
  69.  
  70.         private int minimumProtection;
  71.         private int triggerTime;
  72.         private int chance;
  73.  
  74.         Radiation(int minimumProtection, int triggerTime, int chance) {
  75.             this.minimumProtection = minimumProtection;
  76.             this.triggerTime = triggerTime;
  77.             this.chance = chance;
  78.         }
  79.  
  80.         public int getMinimumProtection() {
  81.             return minimumProtection;
  82.         }
  83.  
  84.         public int getTriggerTime() {
  85.             return triggerTime;
  86.         }
  87.  
  88.         public int getChance() {
  89.             return chance;
  90.         }
  91.     }
  92. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top