Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.zoutepopcorn.plugin.radiation.Tasks;
- import java.util.HashMap;
- import java.util.Map;
- import java.util.UUID;
- import org.bukkit.Bukkit;
- import org.bukkit.Location;
- import org.bukkit.Material;
- import org.bukkit.block.Block;
- import org.bukkit.entity.Player;
- import org.bukkit.potion.PotionEffect;
- import org.bukkit.potion.PotionEffectType;
- import me.zoutepopcorn.plugin.radiation.Radiation;
- import me.zoutepopcorn.plugin.radiation.API.SettingsManager;
- public class RadiatedAreaDia {
- public Radiation plugin;
- public RadiatedAreaDia(Radiation Radiation)
- {
- plugin = Radiation;
- }
- SettingsManager settings = SettingsManager.getInstance();
- public Map<UUID, Integer> taskID = new HashMap<UUID, Integer>();
- public void areaOne() {
- Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
- @SuppressWarnings("deprecation")
- @Override
- public void run() {
- for (Player player : Bukkit.getOnlinePlayers()) {
- Location loc = new Location(player.getWorld(), player.getLocation().getX(), 0, player.getLocation().getZ());
- Block block = loc.getBlock();
- if ((block.getType() == Material.WOOL) && (block.getData() == 3)) {
- double time = settings.getPlayers().getDouble("Players." + player.getUniqueId() + ".Timer");
- if (time <= 0) {
- plugin.Health.Damage(player, 5);
- }
- }
- }
- }
- }, 0L, 10L);
- }
- public void areaTwo() {
- Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
- @SuppressWarnings("deprecation")
- @Override
- public void run() {
- for (Player player : Bukkit.getOnlinePlayers()) {
- Location loc = new Location(player.getWorld(), player.getLocation().getX(), 0, player.getLocation().getZ());
- Block block = loc.getBlock();
- if ((block.getType() == Material.WOOL) && (block.getData() == 4)) {
- double time = settings.getPlayers().getDouble("Players." + player.getUniqueId() + ".Timer");
- if (time <= 0) {
- plugin.Health.Damage(player, 1);
- }
- }
- }
- }
- }, 0L, 20L);
- }
- public void areaThree() {
- Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
- @SuppressWarnings("deprecation")
- @Override
- public void run() {
- for (Player player : Bukkit.getOnlinePlayers()) {
- Location loc = new Location(player.getWorld(), player.getLocation().getX(), 0, player.getLocation().getZ());
- Block block = loc.getBlock();
- if ((block.getType() == Material.WOOL) && (block.getData() == 14)) {
- double time = settings.getPlayers().getDouble("Players." + player.getUniqueId() + ".Timer");
- if (time <= 0) {
- if (player.getInventory().getChestplate() != null) {
- if (player.getInventory().getChestplate().getType() == Material.DIAMOND_CHESTPLATE) {
- plugin.Health.Damage(player, 10/4);
- }
- } else {
- plugin.Health.Damage(player, 10);
- }
- }
- }
- }
- }
- }, 0L, 5L);
- }
- // Gele Gebied // Lage Rad
- // Ongeveer 45 tot 50 seconden om van 0 naar 100 te gaan. Ongeveer 2:57 min om van 100 naar 0 te gaan.
- public void radiatedTimer(final Player player, long ticks){
- final int tid = plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable(){
- @SuppressWarnings("deprecation")
- public void run(){
- Location loc = new Location(player.getWorld(), player.getLocation().getX(), 0, player.getLocation().getZ());
- Block block = loc.getBlock();
- if ((block.getType() == Material.WOOL) && (block.getData() == 4)) {
- if (player.getInventory().getHelmet().getData().getItemType().equals(Material.DIAMOND_HELMET)
- && (!player.getInventory().getChestplate().getData().getItemType().equals(Material.DIAMOND_CHESTPLATE)
- && (!player.getInventory().getLeggings().getData().getItemType().equals(Material.DIAMOND_LEGGINGS)
- && (!player.getInventory().getBoots().getData().getItemType().equals(Material.DIAMOND_BOOTS))))) {
- double time = settings.getPlayers().getDouble("Players." + player.getUniqueId() + ".Timer");
- if (time > 0) {
- settings.getPlayers().set("Players." + player.getUniqueId() + ".Timer", time - (plugin.RadiationScoreboard.maxTime / 20));
- settings.savePlayers();
- if (time > plugin.RadiationScoreboard.maxTime / 20 * 3 && time <= plugin.RadiationScoreboard.maxTime / 20 * 4) {
- player.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 400, 1));
- }
- plugin.RadiationScoreboard.setupScoreboard(player);
- }
- }
- }
- }
- }, 0L, ticks);
- // Blauw Gebied // Middel Rad
- final int tid2 = plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable(){
- @SuppressWarnings("deprecation")
- public void run(){
- Location loc = new Location(player.getWorld(), player.getLocation().getX(), 0, player.getLocation().getZ());
- Block block = loc.getBlock();
- if ((block.getType() == Material.WOOL) && (block.getData() == 3)) {
- if (player.getInventory().getHelmet().getData().getItemType().equals(Material.DIAMOND_HELMET)
- && (!player.getInventory().getChestplate().getData().getItemType().equals(Material.DIAMOND_CHESTPLATE)
- && (!player.getInventory().getLeggings().getData().getItemType().equals(Material.DIAMOND_LEGGINGS)
- && (!player.getInventory().getBoots().getData().getItemType().equals(Material.DIAMOND_BOOTS ))))){
- double time = settings.getPlayers().getDouble("Players." + player.getUniqueId() + ".Timer");
- if (time > 0) {
- settings.getPlayers().set("Players." + player.getUniqueId() + ".Timer", time-(plugin.RadiationScoreboard.maxTime/20));
- settings.savePlayers();
- if (time > plugin.RadiationScoreboard.maxTime/20*3 && time <= plugin.RadiationScoreboard.maxTime/20*4) {
- player.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 400, 1));
- }
- plugin.RadiationScoreboard.setupScoreboard(player);
- }
- }
- }}
- }, 0L, ticks/2);
- // Rood Gebied // Hevige Rad
- final int tid3 = plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable(){
- @SuppressWarnings("deprecation")
- public void run(){
- Location loc = new Location(player.getWorld(), player.getLocation().getX(), 0, player.getLocation().getZ());
- Block block = loc.getBlock();
- if ((block.getType() == Material.WOOL) && (block.getData() == 14)) {
- if (player.getInventory().getHelmet().getData().getItemType().equals(Material.DIAMOND_HELMET)
- && (!player.getInventory().getChestplate().getData().getItemType().equals(Material.DIAMOND_CHESTPLATE)
- && (!player.getInventory().getLeggings().getData().getItemType().equals(Material.DIAMOND_LEGGINGS)
- && (!player.getInventory().getBoots().getData().getItemType().equals(Material.DIAMOND_BOOTS ))))){
- double time = settings.getPlayers().getDouble("Players." + player.getUniqueId() + ".Timer");
- if (time > 0) {
- settings.getPlayers().set("Players." + player.getUniqueId() + ".Timer", time-(plugin.RadiationScoreboard.maxTime/20));
- settings.savePlayers();
- if (time > plugin.RadiationScoreboard.maxTime/20*3 && time <= plugin.RadiationScoreboard.maxTime/20*4) {
- player.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 400, 1));
- }
- plugin.RadiationScoreboard.setupScoreboard(player);
- }
- }}
- }
- }, 0L, (ticks/6)+(ticks/4));
- final int tid4 = plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable(){
- @SuppressWarnings("deprecation")
- public void run(){
- Location loc = new Location(player.getWorld(), player.getLocation().getX(), 0, player.getLocation().getZ());
- Block block = loc.getBlock();
- if ((block.getType() == Material.WOOL) && (block.getData() == 4) || (block.getType() == Material.WOOL) && (block.getData() == 3)) {
- } else {
- int time = settings.getPlayers().getInt("Players." + player.getUniqueId() + ".Timer");
- if (time < 45) {
- settings.getPlayers().set("Players." + player.getUniqueId() + ".Timer", time+(plugin.RadiationScoreboard.maxTime/20));
- settings.savePlayers();
- plugin.RadiationScoreboard.setupScoreboard(player);
- }
- }
- }
- }, 0L, ticks*4);
- taskID.put(player.getUniqueId(), tid);
- taskID.put(player.getUniqueId(), tid2);
- taskID.put(player.getUniqueId(), tid3);
- taskID.put(player.getUniqueId(), tid4);
- }
- public void endTask(Player player){
- if(taskID.containsKey(player.getUniqueId())){
- int tid = taskID.get(player.getUniqueId()); //get the ID from the hashmap
- plugin.getServer().getScheduler().cancelTask(tid); //cancel the task
- taskID.remove(player.getUniqueId()); //remove the player from the hashmap
- }
- }
- }
- ’
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement