Advertisement
Guest User

RadiatedAreaRadsuit

a guest
Dec 9th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.15 KB | None | 0 0
  1. package me.zoutepopcorn.plugin.radiation.Tasks;
  2.  
  3. import java.util.HashMap;
  4. import java.util.Map;
  5. import java.util.UUID;
  6.  
  7. import org.bukkit.*;
  8. import org.bukkit.block.Block;
  9. import org.bukkit.entity.Player;
  10. import org.bukkit.inventory.ItemStack;
  11. import org.bukkit.inventory.meta.LeatherArmorMeta;
  12. import org.bukkit.potion.PotionEffect;
  13. import org.bukkit.potion.PotionEffectType;
  14.  
  15. import me.zoutepopcorn.plugin.radiation.Radiation;
  16. import me.zoutepopcorn.plugin.radiation.API.SettingsManager;
  17.  
  18. public class RadiatedAreaRadsuit {
  19.  
  20. public Radiation plugin;
  21.  
  22. public RadiatedAreaRadsuit(Radiation Radiation)
  23. {
  24. plugin = Radiation;
  25. }
  26.  
  27. SettingsManager settings = SettingsManager.getInstance();
  28.  
  29. public Map<UUID, Integer> taskID = new HashMap<UUID, Integer>();
  30.  
  31. public void areaOne() {
  32. Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
  33. @SuppressWarnings("deprecation")
  34. @Override
  35. public void run() {
  36. for (Player player : Bukkit.getOnlinePlayers()) {
  37. Location loc = new Location(player.getWorld(), player.getLocation().getX(), 0, player.getLocation().getZ());
  38. Block block = loc.getBlock();
  39. if ((block.getType() == Material.WOOL) && (block.getData() == 3)) {
  40. double time = settings.getPlayers().getDouble("Players." + player.getUniqueId() + ".Timer");
  41. if (time <= 0) {
  42. plugin.Health.Damage(player, 5);
  43. }
  44. }
  45. }
  46. }
  47. }, 0L, 10L);
  48. }
  49. public void areaTwo() {
  50. Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
  51. @SuppressWarnings("deprecation")
  52. @Override
  53. public void run() {
  54. for (Player player : Bukkit.getOnlinePlayers()) {
  55. Location loc = new Location(player.getWorld(), player.getLocation().getX(), 0, player.getLocation().getZ());
  56. Block block = loc.getBlock();
  57. if ((block.getType() == Material.WOOL) && (block.getData() == 4)) {
  58. double time = settings.getPlayers().getDouble("Players." + player.getUniqueId() + ".Timer");
  59. if (time <= 0) {
  60. plugin.Health.Damage(player, 1);
  61. }
  62. }
  63. }
  64. }
  65. }, 0L, 20L);
  66. }
  67.  
  68. public void areaThree() {
  69. Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
  70. @SuppressWarnings("deprecation")
  71. @Override
  72. public void run() {
  73. for (Player player : Bukkit.getOnlinePlayers()) {
  74. Location loc = new Location(player.getWorld(), player.getLocation().getX(), 0, player.getLocation().getZ());
  75. Block block = loc.getBlock();
  76. if ((block.getType() == Material.WOOL) && (block.getData() == 14)) {
  77. double time = settings.getPlayers().getDouble("Players." + player.getUniqueId() + ".Timer");
  78. if (time <= 0) {
  79. if (player.getInventory().getChestplate() != null) {
  80. if (player.getInventory().getChestplate().getType() == Material.DIAMOND_CHESTPLATE) {
  81. plugin.Health.Damage(player, 10/4);
  82. }
  83. } else {
  84. plugin.Health.Damage(player, 10);
  85. }
  86. }
  87. }
  88. }
  89. }
  90. }, 0L, 5L);
  91. }
  92.  
  93. public static ItemStack Radhelm()
  94. {
  95. ItemStack i = new ItemStack(Material.LEATHER_HELMET);
  96. LeatherArmorMeta lam = (LeatherArmorMeta)i.getItemMeta();
  97. lam.setDisplayName(ChatColor.RED + "" + ChatColor.BOLD + "Radiation Suit Helm");
  98. lam.setColor(Color.fromRGB(0, 170, 0));
  99. i.setItemMeta(lam);
  100. return i;
  101. }
  102. public static ItemStack Radshirt()
  103. {
  104. ItemStack i = new ItemStack(Material.LEATHER_CHESTPLATE);
  105. LeatherArmorMeta lam = (LeatherArmorMeta)i.getItemMeta();
  106. lam.setDisplayName(ChatColor.RED + "" + ChatColor.BOLD + "Radiation Suit Chestplate");
  107. lam.setColor(Color.fromRGB(0, 170, 0));
  108. i.setItemMeta(lam);
  109. return i;
  110. }
  111. public static ItemStack Radpants()
  112. {
  113. ItemStack i = new ItemStack(Material.LEATHER_LEGGINGS);
  114. LeatherArmorMeta lam = (LeatherArmorMeta)i.getItemMeta();
  115. lam.setDisplayName(ChatColor.RED + "" + ChatColor.BOLD + "Radiation Suit Chestplate");
  116. lam.setColor(Color.fromRGB(0, 170, 0));
  117. i.setItemMeta(lam);
  118. return i;
  119. }
  120. public static ItemStack Radshoes()
  121. {
  122. ItemStack i = new ItemStack(Material.LEATHER_BOOTS);
  123. LeatherArmorMeta lam = (LeatherArmorMeta)i.getItemMeta();
  124. lam.setDisplayName(ChatColor.RED + "" + ChatColor.BOLD + "Radiation Suit Chestplate");
  125. lam.setColor(Color.fromRGB(0, 170, 0));
  126. i.setItemMeta(lam);
  127. return i;
  128. }
  129. // Gele Gebied // Lage Rad
  130. // Ongeveer 45 tot 50 seconden om van 0 naar 100 te gaan. Ongeveer 2:57 min om van 100 naar 0 te gaan.
  131. public void radiatedTimer(final Player player, long ticks){
  132. final int tid = plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable(){
  133. @SuppressWarnings("deprecation")
  134. public void run(){
  135. Location loc = new Location(player.getWorld(), player.getLocation().getX(), 0, player.getLocation().getZ());
  136. Block block = loc.getBlock();
  137. if ((block.getType() == Material.WOOL) && (block.getData() == 4)) {
  138. if (player.getInventory().getHelmet().getData().getItemType().equals(Radhelm())
  139. && (player.getInventory().getChestplate().getData().getItemType().equals(Radshirt())
  140. && (player.getInventory().getLeggings().getData().getItemType().equals(Radpants())
  141. && (player.getInventory().getBoots().getData().getItemType().equals(Radshoes()))))) {
  142. double time = settings.getPlayers().getDouble("Players." + player.getUniqueId() + ".Timer");
  143. if (time > 0) {
  144. settings.getPlayers().set("Players." + player.getUniqueId() + ".Timer", time - (plugin.RadiationScoreboard.maxTime / 20));
  145. settings.savePlayers();
  146. if (time > plugin.RadiationScoreboard.maxTime / 20 * 3 && time <= plugin.RadiationScoreboard.maxTime / 20 * 4) {
  147. player.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 400, 1));
  148. }
  149. plugin.RadiationScoreboard.setupScoreboard(player);
  150. }
  151. }
  152. }
  153. }
  154. }, 0L, ticks);
  155. // Blauw Gebied // Middel Rad
  156. final int tid2 = plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable(){
  157. @SuppressWarnings("deprecation")
  158. public void run(){
  159. Location loc = new Location(player.getWorld(), player.getLocation().getX(), 0, player.getLocation().getZ());
  160. Block block = loc.getBlock();
  161. if ((block.getType() == Material.WOOL) && (block.getData() == 3)) {
  162. if (player.getInventory().getHelmet().getData().getItemType().equals(Radhelm())
  163. && (player.getInventory().getChestplate().getData().getItemType().equals(Radshirt())
  164. && (player.getInventory().getLeggings().getData().getItemType().equals(Radpants())
  165. && (player.getInventory().getBoots().getData().getItemType().equals(Radshoes()))))) {
  166. double time = settings.getPlayers().getDouble("Players." + player.getUniqueId() + ".Timer");
  167. if (time > 0) {
  168. settings.getPlayers().set("Players." + player.getUniqueId() + ".Timer", time-(plugin.RadiationScoreboard.maxTime/20));
  169. settings.savePlayers();
  170. if (time > plugin.RadiationScoreboard.maxTime/20*3 && time <= plugin.RadiationScoreboard.maxTime/20*4) {
  171. player.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 400, 1));
  172. }
  173. plugin.RadiationScoreboard.setupScoreboard(player);
  174. }
  175. }
  176. }}
  177. }, 0L, ticks/2);
  178.  
  179. // Rood Gebied // Hevige Rad
  180. final int tid3 = plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable(){
  181. @SuppressWarnings("deprecation")
  182. public void run(){
  183. Location loc = new Location(player.getWorld(), player.getLocation().getX(), 0, player.getLocation().getZ());
  184. Block block = loc.getBlock();
  185. if ((block.getType() == Material.WOOL) && (block.getData() == 14)) {
  186. if (player.getInventory().getHelmet().getData().getItemType().equals(Radhelm())
  187. && (player.getInventory().getChestplate().getData().getItemType().equals(Radshirt())
  188. && (player.getInventory().getLeggings().getData().getItemType().equals(Radpants())
  189. && (player.getInventory().getBoots().getData().getItemType().equals(Radshoes()))))) {
  190. double time = settings.getPlayers().getDouble("Players." + player.getUniqueId() + ".Timer");
  191. if (time > 0) {
  192. settings.getPlayers().set("Players." + player.getUniqueId() + ".Timer", time-(plugin.RadiationScoreboard.maxTime/20));
  193. settings.savePlayers();
  194. if (time > plugin.RadiationScoreboard.maxTime/20*3 && time <= plugin.RadiationScoreboard.maxTime/20*4) {
  195. player.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 400, 1));
  196. }
  197. plugin.RadiationScoreboard.setupScoreboard(player);
  198. }
  199. }}
  200. }
  201. }, 0L, (ticks/6)+(ticks/4));
  202.  
  203.  
  204. final int tid4 = plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable(){
  205. @SuppressWarnings("deprecation")
  206. public void run(){
  207. Location loc = new Location(player.getWorld(), player.getLocation().getX(), 0, player.getLocation().getZ());
  208. Block block = loc.getBlock();
  209. if ((block.getType() == Material.WOOL) && (block.getData() == 4) || (block.getType() == Material.WOOL) && (block.getData() == 3)) {
  210. } else {
  211. int time = settings.getPlayers().getInt("Players." + player.getUniqueId() + ".Timer");
  212. if (time < 45) {
  213. settings.getPlayers().set("Players." + player.getUniqueId() + ".Timer", time+(plugin.RadiationScoreboard.maxTime/20));
  214. settings.savePlayers();
  215. plugin.RadiationScoreboard.setupScoreboard(player);
  216. }
  217. }
  218. }
  219. }, 0L, ticks*4);
  220.  
  221. taskID.put(player.getUniqueId(), tid);
  222. taskID.put(player.getUniqueId(), tid2);
  223. taskID.put(player.getUniqueId(), tid3);
  224. taskID.put(player.getUniqueId(), tid4);
  225. }
  226.  
  227.  
  228.  
  229. public void endTask(Player player){
  230. if(taskID.containsKey(player.getUniqueId())){
  231. int tid = taskID.get(player.getUniqueId()); //get the ID from the hashmap
  232. plugin.getServer().getScheduler().cancelTask(tid); //cancel the task
  233. taskID.remove(player.getUniqueId()); //remove the player from the hashmap
  234. }
  235. }
  236. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement