Skip to content

Commit 40f29ea

Browse files
author
Slikey
committed
Still unfinished.. TODO
1 parent 449afb8 commit 40f29ea

1 file changed

Lines changed: 32 additions & 14 deletions

File tree

src/de/slikey/effectlib/effect/BigBangLocationEffect.java

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,40 +4,58 @@
44
import org.bukkit.FireworkEffect;
55
import org.bukkit.FireworkEffect.Builder;
66
import org.bukkit.Location;
7+
import org.bukkit.Sound;
78
import org.bukkit.entity.EntityType;
89
import org.bukkit.entity.Firework;
9-
import org.bukkit.event.Cancellable;
10-
import org.bukkit.event.Event;
1110
import org.bukkit.inventory.meta.FireworkMeta;
11+
import org.bukkit.util.Vector;
1212

1313
import de.slikey.effectlib.EffectManager;
1414
import de.slikey.effectlib.EffectType;
15+
import de.slikey.effectlib.util.RandomUtils;
1516

1617
public class BigBangLocationEffect extends LocationEffect {
1718

19+
public FireworkEffect firework;
20+
public int intensity = 2;
21+
public float radius = 2;
22+
public int explosions = 10;
23+
public int soundInterval = 5;
24+
protected int step = 0;
25+
1826
public BigBangLocationEffect(EffectManager effectManager, Location location) {
1927
super(effectManager, location);
2028
type = EffectType.REPEATING;
21-
period = 40;
22-
iterations = 20;
23-
}
29+
period = 2;
30+
iterations = 400;
2431

25-
@Override
26-
public void onRun() {
2732
Builder b = FireworkEffect.builder();
2833
b.withColor(Color.RED).withColor(Color.ORANGE).withColor(Color.BLACK);
2934
b.withFade(Color.BLACK);
3035
b.trail(true);
31-
FireworkEffect fe = b.build();
36+
firework = b.build();
37+
}
3238

33-
final Firework fw = (Firework) location.getWorld().spawnEntity(location, EntityType.FIREWORK);
34-
fw.playEffect(org.bukkit.EntityEffect.WOLF_HEARTS);
39+
@Override
40+
public void onRun() {
41+
for (int i = 0; i < explosions; i++) {
42+
Vector v = RandomUtils.getRandomVector().multiply(radius);
43+
detonate(v);
44+
if (step % soundInterval == 0)
45+
location.getWorld().playSound(location, Sound.EXPLODE, 100, 1);
46+
}
47+
step++;
48+
}
49+
50+
protected void detonate(Vector v) {
51+
final Firework fw = (Firework) location.getWorld().spawnEntity(location.add(v), EntityType.FIREWORK);
52+
location.subtract(v);
3553
FireworkMeta meta = fw.getFireworkMeta();
36-
meta.setPower(10);
37-
meta.addEffect(fe);
54+
meta.setPower(0);
55+
for (int i = 0; i < intensity; i++) {
56+
meta.addEffect(firework);
57+
}
3858
fw.setFireworkMeta(meta);
39-
4059
fw.detonate();
4160
}
42-
4361
}

0 commit comments

Comments
 (0)