Advertisement
Lisenochek

Untitled

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