Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package de.mario52.atomiccraft.explosioncontrol;
- import java.util.ArrayList;
- import java.util.Arrays;
- import java.util.List;
- import org.bukkit.Bukkit;
- import org.bukkit.Effect;
- import org.bukkit.Location;
- import org.bukkit.Particle;
- import org.bukkit.entity.Player;
- import org.bukkit.plugin.Plugin;
- import org.bukkit.potion.PotionEffect;
- import org.bukkit.potion.PotionEffectType;
- import project.particle.handle.ParticleHandler;
- public class BombExplosion
- {
- Location loc;
- int time;
- String sender;
- int countdown_id;
- int shockwave;
- Plugin pl;
- double shockw_radius = 0;
- public BombExplosion(Location loc, int time, String sender, Plugin pl)
- {
- this.loc = loc;
- this.time = time;
- this.sender = sender;
- this.pl = pl;
- }
- @SuppressWarnings("deprecation")
- public void launch()
- {
- Bukkit.broadcastMessage("§4§l" + sender + " placed a NUKE at X" + loc.getBlockX() + ", Y" + loc.getBlockY() + ", Z" + loc.getBlockZ());
- countdown_id = Bukkit.getScheduler().scheduleSyncRepeatingTask(pl, new Runnable() {
- @Override
- public void run() {
- Bukkit.broadcastMessage("§4" + time + " seconds left");
- time--;
- if(time == 9)
- {
- Bukkit.getScheduler().cancelTask(countdown_id);
- detonate();
- }
- }
- }, 20, 20);
- }
- @SuppressWarnings("deprecation")
- private void detonate()
- {
- for(Player p :Bukkit.getOnlinePlayers())
- {
- p.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 10, 10));
- }
- shockwave = Bukkit.getScheduler().scheduleSyncRepeatingTask(pl, new Runnable() {
- @Override
- public void run() {
- if(shockw_radius <= 35)
- {
- spawnShockwaveCircles(Bukkit.getOnlinePlayers().iterator().next(),loc, shockw_radius);
- shockw_radius = shockw_radius + 0.5;
- }else
- {
- Bukkit.getScheduler().cancelTask(shockwave);
- }
- }
- }, 0, 1);
- }
- private List<Double> t = Arrays.asList(-0.2,0.0,0.2,0.4);
- @SuppressWarnings("deprecation")
- private void spawnShockwaveCircles(Player p, Location location, double radius)
- {
- for (double radians = 0;radians < (2*Math.PI); radians+=(Math.PI/180))
- {
- final double radians2 = radians;
- t.parallelStream().forEach((Double t) -> {
- double x = Math.cos(radians2) * (radius - t);
- double z = Math.sin(radians2)* (radius - t);
- location.add(x,0,z);
- ParticleHandler.send(ParticleHandler.getParameter(Particle.SMOKE_NORMAL, 1, 0, 0, 0),p,(float) location.getX(),(float)location.getY(),(float) location.getZ());
- location.subtract(x,0,z);
- });
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement