diff --git a/pom.xml b/pom.xml
index 96a8517..460dc8a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
nl.SBDeveloper
ShowAPI
- 1.0
+ 1.1
jar
ShowAPI
https://sbdplugins.nl
diff --git a/src/main/java/nl/sbdeveloper/showapi/ShowAPI.java b/src/main/java/nl/sbdeveloper/showapi/ShowAPI.java
index e11074a..af1b05b 100644
--- a/src/main/java/nl/sbdeveloper/showapi/ShowAPI.java
+++ b/src/main/java/nl/sbdeveloper/showapi/ShowAPI.java
@@ -2,12 +2,19 @@ package nl.sbdeveloper.showapi;
import nl.sbdeveloper.showapi.utils.Laser;
import nl.sbdeveloper.showapi.utils.VersionUtil;
+import org.bukkit.Color;
+import org.bukkit.FireworkEffect;
import org.bukkit.Location;
+import org.bukkit.entity.EnderCrystal;
+import org.bukkit.entity.EntityType;
+import org.bukkit.entity.Firework;
import org.bukkit.event.Listener;
+import org.bukkit.inventory.meta.FireworkMeta;
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitRunnable;
import org.inventivetalent.apihelper.API;
import org.inventivetalent.apihelper.APIManager;
+import org.jetbrains.annotations.NotNull;
import java.util.HashMap;
import java.util.Map;
@@ -40,11 +47,135 @@ public class ShowAPI implements API, Listener {
}
- //LASERS
+ public static class Fireworks {
+ public static void spawn(@NotNull Firework fw, Location baseLoc) {
+ fw.spawn(baseLoc);
+ }
+
+ public static class Firework {
+ private FireworkEffect.Builder effectBuilder;
+ private int power;
+
+ public Firework() {
+ effectBuilder = FireworkEffect.builder();
+ }
+
+ public Firework addFlicker() {
+ effectBuilder.flicker(true);
+ return this;
+ }
+
+ public Firework addTrail() {
+ effectBuilder.trail(true);
+ return this;
+ }
+
+ public Firework addColor(Color color) {
+ effectBuilder.withColor(color);
+ return this;
+ }
+
+ public Firework addFade(Color color) {
+ effectBuilder.withFade(color);
+ return this;
+ }
+
+ public Firework setType(FireworkEffect.Type type) {
+ effectBuilder.with(type);
+ return this;
+ }
+
+ public Firework setPower(int power) {
+ this.power = power;
+ return this;
+ }
+
+ private void spawn(@NotNull Location loc) {
+ org.bukkit.entity.Firework fw = (org.bukkit.entity.Firework) loc.getWorld().spawnEntity(loc, EntityType.FIREWORK);
+ FireworkMeta fwm = fw.getFireworkMeta();
+ fwm.addEffect(effectBuilder.build());
+ fwm.setPower(power);
+ fw.setFireworkMeta(fwm);
+ }
+ }
+ }
+
+ //SPOTS -> End Crystals
+ public static class Spots {
+ private static Map spots = new HashMap<>();
+
+ /**
+ * Spawn a new spot, and start it
+ *
+ * @param name The name of the spot
+ * @param baseLoc The start location
+ */
+ public static void start(String name, Location baseLoc) {
+ spots.put(name, new SpotRunnable(name, baseLoc));
+ spots.get(name).runTaskTimer(ShowAPIPlugin.getInstance(), 0, 1);
+ }
+
+ /**
+ * Move a spot to a location
+ *
+ * @param name The name of the spot
+ * @param posLoc The new location
+ *
+ * @return true if done, false if it doesn't exists
+ */
+ public static boolean move(String name, Location posLoc) {
+ if (!spots.containsKey(name)) return false;
+
+ spots.get(name).changePositionLocation(posLoc);
+ return true;
+ }
+
+ private static class SpotRunnable extends BukkitRunnable {
+ private final EnderCrystal crystal;
+ private final String name;
+
+ private Location posLoc;
+
+ public SpotRunnable(String name, Location baseLoc) {
+ this.name = name;
+
+ this.crystal = (EnderCrystal) baseLoc.getWorld().spawnEntity(baseLoc, EntityType.ENDER_CRYSTAL);
+ this.crystal.setCustomName(name);
+ this.crystal.setShowingBottom(false);
+ this.crystal.setCustomNameVisible(false);
+ this.crystal.setBeamTarget(baseLoc.clone().add(0, 5, 0));
+ }
+
+ @Override
+ public void run() {
+ if (posLoc == null) return;
+ this.crystal.setBeamTarget(posLoc);
+ }
+
+ public void changePositionLocation(Location posLoc) {
+ this.posLoc = posLoc;
+ }
+
+ public synchronized void cancel() throws IllegalStateException {
+ spots.remove(name);
+ super.cancel();
+ }
+ }
+ }
+
+ //LASERS -> Guardian beams
public static class Lasers {
private static Map lasers = new HashMap<>();
- public static boolean startLaser(String name, Location baseLoc) {
+ /**
+ * Spawn a new laser, and start it
+ *
+ * @param name The name of the laser
+ * @param baseLoc The start location
+ *
+ * @return true if done, false if an exception
+ */
+ public static boolean start(String name, Location baseLoc) {
try {
lasers.put(name, new LaserRunnable(name, baseLoc));
lasers.get(name).runTaskTimer(ShowAPIPlugin.getInstance(), 0, 1);
@@ -55,7 +186,14 @@ public class ShowAPI implements API, Listener {
return false;
}
- public static boolean moveLaser(String name, Location posLoc) {
+ /**
+ * Move a laser to a location
+ * @param name The name of the laser
+ * @param posLoc The new location
+ *
+ * @return true if done, false if it doesn't exists
+ */
+ public static boolean move(String name, Location posLoc) {
if (!lasers.containsKey(name)) return false;
lasers.get(name).changePositionLocation(posLoc);
@@ -76,7 +214,10 @@ public class ShowAPI implements API, Listener {
this.laser.start(ShowAPIPlugin.getInstance());
}
+ @Override
public void run() {
+ if (posLoc == null) return;
+
try {
laser.moveStart(baseLoc);
laser.moveEnd(posLoc);