v1.2 - Added Particle trigger, and a lot of fixes
This commit is contained in:
parent
7dffb45132
commit
ac496b7184
13 changed files with 200 additions and 60 deletions
2
pom.xml
2
pom.xml
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
<groupId>nl.SBDeveloper</groupId>
|
<groupId>nl.SBDeveloper</groupId>
|
||||||
<artifactId>ShowAPI</artifactId>
|
<artifactId>ShowAPI</artifactId>
|
||||||
<version>1.1</version>
|
<version>1.2</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<name>ShowAPI</name>
|
<name>ShowAPI</name>
|
||||||
<url>https://sbdplugins.nl</url>
|
<url>https://sbdplugins.nl</url>
|
||||||
|
|
|
@ -139,6 +139,12 @@ public class ShowAPI implements API, Listener {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void remove(String name) {
|
||||||
|
if (!spots.containsKey(name)) return;
|
||||||
|
|
||||||
|
spots.get(name).cancel();
|
||||||
|
}
|
||||||
|
|
||||||
private static class SpotRunnable extends BukkitRunnable {
|
private static class SpotRunnable extends BukkitRunnable {
|
||||||
private final EnderCrystal crystal;
|
private final EnderCrystal crystal;
|
||||||
private final String name;
|
private final String name;
|
||||||
|
@ -166,6 +172,7 @@ public class ShowAPI implements API, Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void cancel() throws IllegalStateException {
|
public synchronized void cancel() throws IllegalStateException {
|
||||||
|
crystal.remove();
|
||||||
spots.remove(name);
|
spots.remove(name);
|
||||||
super.cancel();
|
super.cancel();
|
||||||
}
|
}
|
||||||
|
@ -219,6 +226,13 @@ public class ShowAPI implements API, Listener {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void remove(String name) {
|
||||||
|
if (!lasers.containsKey(name)) return;
|
||||||
|
|
||||||
|
lasers.get(name).cancel();
|
||||||
|
lasers.remove(name);
|
||||||
|
}
|
||||||
|
|
||||||
private static class LaserRunnable extends BukkitRunnable {
|
private static class LaserRunnable extends BukkitRunnable {
|
||||||
private final Laser laser;
|
private final Laser laser;
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
|
@ -30,6 +30,7 @@ public final class ShowAPIPlugin extends JavaPlugin {
|
||||||
APIManager.initAPI(ShowAPI.class);
|
APIManager.initAPI(ShowAPI.class);
|
||||||
|
|
||||||
spiGUI = new SpiGUI(this);
|
spiGUI = new SpiGUI(this);
|
||||||
|
spiGUI.setEnableAutomaticPagination(true);
|
||||||
|
|
||||||
getCommand("mctpshow").setExecutor(new ShowCMD());
|
getCommand("mctpshow").setExecutor(new ShowCMD());
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,34 +14,66 @@ public class ShowCue {
|
||||||
private final TriggerData data;
|
private final TriggerData data;
|
||||||
private int taskID;
|
private int taskID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new cue point
|
||||||
|
*
|
||||||
|
* @param timeSeconds The starttime in seconds
|
||||||
|
* @param data The data
|
||||||
|
*/
|
||||||
public ShowCue(int timeSeconds, TriggerData data) {
|
public ShowCue(int timeSeconds, TriggerData data) {
|
||||||
this.cueID = UUID.randomUUID();
|
this(UUID.randomUUID(), timeSeconds, data);
|
||||||
this.timeSeconds = timeSeconds;
|
|
||||||
this.data = data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load an exisiting cue point
|
||||||
|
*
|
||||||
|
* @param uuid The UUID
|
||||||
|
* @param timeSeconds The starttime in seconds
|
||||||
|
* @param data The data
|
||||||
|
*/
|
||||||
public ShowCue(UUID uuid, int timeSeconds, TriggerData data) {
|
public ShowCue(UUID uuid, int timeSeconds, TriggerData data) {
|
||||||
this.cueID = uuid;
|
this.cueID = uuid;
|
||||||
this.timeSeconds = timeSeconds;
|
this.timeSeconds = timeSeconds;
|
||||||
this.data = data;
|
this.data = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the ID of the cue point
|
||||||
|
*
|
||||||
|
* @return The UUID
|
||||||
|
*/
|
||||||
public UUID getCueID() {
|
public UUID getCueID() {
|
||||||
return cueID;
|
return cueID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the time in seconds
|
||||||
|
*
|
||||||
|
* @return The time in seconds
|
||||||
|
*/
|
||||||
public int getTimeSeconds() {
|
public int getTimeSeconds() {
|
||||||
return timeSeconds;
|
return timeSeconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the data of this cue
|
||||||
|
*
|
||||||
|
* @return The data
|
||||||
|
*/
|
||||||
public TriggerData getData() {
|
public TriggerData getData() {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start this cue point
|
||||||
|
*/
|
||||||
public void runAtTime() {
|
public void runAtTime() {
|
||||||
this.taskID = Bukkit.getScheduler().runTaskLater(ShowAPIPlugin.getInstance(), data::trigger, 20 * timeSeconds).getTaskId();
|
this.taskID = Bukkit.getScheduler().runTaskLater(ShowAPIPlugin.getInstance(), data::trigger, 20 * timeSeconds).getTaskId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cancel this cue point
|
||||||
|
*/
|
||||||
public void cancel() {
|
public void cancel() {
|
||||||
Bukkit.getScheduler().cancelTask(taskID);
|
Bukkit.getScheduler().cancelTask(taskID);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,11 @@ public abstract class TriggerData {
|
||||||
*/
|
*/
|
||||||
public void trigger() {}
|
public void trigger() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method gets fired when the cue gets removed
|
||||||
|
*/
|
||||||
|
public void remove() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the trigger type
|
* Get the trigger type
|
||||||
*
|
*
|
||||||
|
@ -26,6 +31,11 @@ public abstract class TriggerData {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the datastring from this cue
|
||||||
|
*
|
||||||
|
* @return The datastring
|
||||||
|
*/
|
||||||
public String getDataString() {
|
public String getDataString() {
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
for (String s : dataString) {
|
for (String s : dataString) {
|
||||||
|
|
|
@ -1,5 +1,28 @@
|
||||||
package nl.sbdeveloper.showapi.api;
|
package nl.sbdeveloper.showapi.api;
|
||||||
|
|
||||||
|
import nl.sbdeveloper.showapi.api.triggers.*;
|
||||||
|
|
||||||
public enum TriggerType {
|
public enum TriggerType {
|
||||||
COMMAND, FIREWORK, SPOT, LASER, ANIMA
|
COMMAND(CommandTrigger.class, 2),
|
||||||
|
FIREWORK(FireworkTrigger.class, 6),
|
||||||
|
SPOT(SpotTrigger.class, 6),
|
||||||
|
LASER(LaserTrigger.class, 6),
|
||||||
|
ANIMA(AnimaTrigger.class, 2),
|
||||||
|
PARTICLE(ParticleTrigger.class, 7);
|
||||||
|
|
||||||
|
private final Class<? extends TriggerData> trigger;
|
||||||
|
private final int minArgs;
|
||||||
|
|
||||||
|
TriggerType(Class<? extends TriggerData> trigger, int minArgs) {
|
||||||
|
this.trigger = trigger;
|
||||||
|
this.minArgs = minArgs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Class<? extends TriggerData> getTrigger() {
|
||||||
|
return trigger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMinArgs() {
|
||||||
|
return minArgs;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,13 +8,15 @@ import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
|
||||||
public class LaserTrigger extends TriggerData {
|
public class LaserTrigger extends TriggerData {
|
||||||
private String name;
|
private final String name;
|
||||||
private Location newLocation;
|
private Location newLocation;
|
||||||
|
|
||||||
public LaserTrigger(String[] data) {
|
public LaserTrigger(String[] data) {
|
||||||
super(TriggerType.LASER, data);
|
super(TriggerType.LASER, data);
|
||||||
|
|
||||||
World w = Bukkit.getWorld(data[0]);
|
this.name = data[0];
|
||||||
|
|
||||||
|
World w = Bukkit.getWorld(data[1]);
|
||||||
if (w == null) {
|
if (w == null) {
|
||||||
Bukkit.getLogger().info("De wereld is null!");
|
Bukkit.getLogger().info("De wereld is null!");
|
||||||
return;
|
return;
|
||||||
|
@ -24,9 +26,9 @@ public class LaserTrigger extends TriggerData {
|
||||||
int y;
|
int y;
|
||||||
int z;
|
int z;
|
||||||
try {
|
try {
|
||||||
x = Integer.parseInt(data[1]);
|
x = Integer.parseInt(data[2]);
|
||||||
y = Integer.parseInt(data[2]);
|
y = Integer.parseInt(data[3]);
|
||||||
z = Integer.parseInt(data[3]);
|
z = Integer.parseInt(data[4]);
|
||||||
} catch (NumberFormatException ex) {
|
} catch (NumberFormatException ex) {
|
||||||
Bukkit.getLogger().info("De positie is null!");
|
Bukkit.getLogger().info("De positie is null!");
|
||||||
return;
|
return;
|
||||||
|
@ -34,8 +36,6 @@ public class LaserTrigger extends TriggerData {
|
||||||
|
|
||||||
this.newLocation = new Location(w, x, y, z);
|
this.newLocation = new Location(w, x, y, z);
|
||||||
|
|
||||||
this.name = data[4];
|
|
||||||
|
|
||||||
if (!ShowAPI.Lasers.exists(name)) {
|
if (!ShowAPI.Lasers.exists(name)) {
|
||||||
ShowAPI.Lasers.start(name, newLocation);
|
ShowAPI.Lasers.start(name, newLocation);
|
||||||
}
|
}
|
||||||
|
@ -45,4 +45,9 @@ public class LaserTrigger extends TriggerData {
|
||||||
public void trigger() {
|
public void trigger() {
|
||||||
ShowAPI.Lasers.move(name, newLocation);
|
ShowAPI.Lasers.move(name, newLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void remove() {
|
||||||
|
ShowAPI.Lasers.remove(name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,56 @@
|
||||||
|
package nl.sbdeveloper.showapi.api.triggers;
|
||||||
|
|
||||||
|
import nl.sbdeveloper.showapi.api.TriggerData;
|
||||||
|
import nl.sbdeveloper.showapi.api.TriggerType;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Particle;
|
||||||
|
import org.bukkit.World;
|
||||||
|
|
||||||
|
public class ParticleTrigger extends TriggerData {
|
||||||
|
private Particle type;
|
||||||
|
private Location spawnLoc;
|
||||||
|
private int count;
|
||||||
|
|
||||||
|
public ParticleTrigger(String[] data) {
|
||||||
|
super(TriggerType.PARTICLE, data);
|
||||||
|
|
||||||
|
World w = Bukkit.getWorld(data[0]);
|
||||||
|
if (w == null) {
|
||||||
|
Bukkit.getLogger().info("De wereld is null!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
|
int z;
|
||||||
|
try {
|
||||||
|
x = Integer.parseInt(data[1]);
|
||||||
|
y = Integer.parseInt(data[2]);
|
||||||
|
z = Integer.parseInt(data[3]);
|
||||||
|
} catch (NumberFormatException ex) {
|
||||||
|
Bukkit.getLogger().info("De positie is incorrect!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.spawnLoc = new Location(w, x, y, z);
|
||||||
|
|
||||||
|
try {
|
||||||
|
this.type = Particle.valueOf(data[4]);
|
||||||
|
} catch (IllegalArgumentException ex) {
|
||||||
|
Bukkit.getLogger().info("De particle " + data[4] + " bestaat niet!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
this.count = Integer.parseInt(data[5]);
|
||||||
|
} catch (NumberFormatException ex) {
|
||||||
|
Bukkit.getLogger().info("Het aantal " + data[4] + " is incorrect!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void trigger() {
|
||||||
|
spawnLoc.getWorld().spawnParticle(type, spawnLoc, count);
|
||||||
|
}
|
||||||
|
}
|
|
@ -8,13 +8,15 @@ import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
|
||||||
public class SpotTrigger extends TriggerData {
|
public class SpotTrigger extends TriggerData {
|
||||||
private String name;
|
private final String name;
|
||||||
private Location newLocation;
|
private Location newLocation;
|
||||||
|
|
||||||
public SpotTrigger(String[] data) {
|
public SpotTrigger(String[] data) {
|
||||||
super(TriggerType.SPOT, data);
|
super(TriggerType.SPOT, data);
|
||||||
|
|
||||||
World w = Bukkit.getWorld(data[0]);
|
this.name = data[0];
|
||||||
|
|
||||||
|
World w = Bukkit.getWorld(data[1]);
|
||||||
if (w == null) {
|
if (w == null) {
|
||||||
Bukkit.getLogger().info("De wereld is null!");
|
Bukkit.getLogger().info("De wereld is null!");
|
||||||
return;
|
return;
|
||||||
|
@ -24,9 +26,9 @@ public class SpotTrigger extends TriggerData {
|
||||||
int y;
|
int y;
|
||||||
int z;
|
int z;
|
||||||
try {
|
try {
|
||||||
x = Integer.parseInt(data[1]);
|
x = Integer.parseInt(data[2]);
|
||||||
y = Integer.parseInt(data[2]);
|
y = Integer.parseInt(data[3]);
|
||||||
z = Integer.parseInt(data[3]);
|
z = Integer.parseInt(data[4]);
|
||||||
} catch (NumberFormatException ex) {
|
} catch (NumberFormatException ex) {
|
||||||
Bukkit.getLogger().info("De positie is null!");
|
Bukkit.getLogger().info("De positie is null!");
|
||||||
return;
|
return;
|
||||||
|
@ -34,10 +36,8 @@ public class SpotTrigger extends TriggerData {
|
||||||
|
|
||||||
this.newLocation = new Location(w, x, y, z);
|
this.newLocation = new Location(w, x, y, z);
|
||||||
|
|
||||||
this.name = data[4];
|
if (!ShowAPI.Spots.exists(name)) {
|
||||||
|
ShowAPI.Spots.start(name, newLocation);
|
||||||
if (!ShowAPI.Lasers.exists(name)) {
|
|
||||||
ShowAPI.Lasers.start(name, newLocation);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,4 +45,9 @@ public class SpotTrigger extends TriggerData {
|
||||||
public void trigger() {
|
public void trigger() {
|
||||||
ShowAPI.Spots.move(name, newLocation);
|
ShowAPI.Spots.move(name, newLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void remove() {
|
||||||
|
ShowAPI.Spots.remove(name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,21 +33,22 @@ public class Shows {
|
||||||
return showsMap.get(name);
|
return showsMap.get(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void removePoint(String name, ShowCue point) {
|
|
||||||
if (!exists(name)) return;
|
|
||||||
|
|
||||||
showsMap.get(name).remove(point);
|
|
||||||
|
|
||||||
ShowAPIPlugin.getData().getFile().set("Shows." + name + "." + point.getCueID(), null);
|
|
||||||
ShowAPIPlugin.getData().saveFile();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void addPoint(String name, int sec, TriggerData data) {
|
public static void addPoint(String name, int sec, TriggerData data) {
|
||||||
if (!exists(name)) return;
|
if (!exists(name)) return;
|
||||||
getPoints(name).add(new ShowCue(sec, data));
|
getPoints(name).add(new ShowCue(sec, data));
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(ShowAPIPlugin.getInstance(), DataSaving::save);
|
Bukkit.getScheduler().runTaskAsynchronously(ShowAPIPlugin.getInstance(), DataSaving::save);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void removePoint(String name, ShowCue point) {
|
||||||
|
if (!exists(name)) return;
|
||||||
|
|
||||||
|
point.getData().remove();
|
||||||
|
showsMap.get(name).remove(point);
|
||||||
|
|
||||||
|
ShowAPIPlugin.getData().getFile().set("Shows." + name + "." + point.getCueID(), null);
|
||||||
|
ShowAPIPlugin.getData().saveFile();
|
||||||
|
}
|
||||||
|
|
||||||
public static void startShow(String name) {
|
public static void startShow(String name) {
|
||||||
if (!exists(name)) return;
|
if (!exists(name)) return;
|
||||||
getPoints(name).forEach(ShowCue::runAtTime);
|
getPoints(name).forEach(ShowCue::runAtTime);
|
||||||
|
|
|
@ -12,14 +12,13 @@ import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
|
|
||||||
public class ShowCueGUI {
|
public class ShowCueGUI {
|
||||||
public static void openGUI(String name, Player p) {
|
public static void openGUI(String name, Player p) {
|
||||||
SGMenu menu = ShowAPIPlugin.getSpiGUI().create(ChatColor.DARK_AQUA + "Show Cue Manager:", MainUtil.pointsToRow(Shows.getPoints(name).size()));
|
SGMenu menu = ShowAPIPlugin.getSpiGUI().create(ChatColor.DARK_AQUA + "Show Cue Manager:", 5);
|
||||||
menu.setAutomaticPaginationEnabled(true);
|
menu.setAutomaticPaginationEnabled(true);
|
||||||
|
|
||||||
for (ShowCue cue : Shows.getPoints(name)) {
|
for (ShowCue cue : Shows.getPoints(name)) {
|
||||||
SGButton button = new SGButton(MainUtil.pointToItem(cue))
|
SGButton button = new SGButton(MainUtil.pointToItem(cue))
|
||||||
.withListener((InventoryClickEvent e) -> {
|
.withListener((InventoryClickEvent e) -> {
|
||||||
Shows.removePoint(name, cue);
|
Shows.removePoint(name, cue); //Remove the point
|
||||||
|
|
||||||
openGUI(name, p); //Refresh
|
openGUI(name, p); //Refresh
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -158,6 +158,7 @@ public class Laser {
|
||||||
static int generateEID() {
|
static int generateEID() {
|
||||||
return lastIssuedEID++;
|
return lastIssuedEID++;
|
||||||
}
|
}
|
||||||
|
private static String nmsVersion = Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];
|
||||||
private static int version = Integer.parseInt(Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3].substring(1).split("_")[1]);
|
private static int version = Integer.parseInt(Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3].substring(1).split("_")[1]);
|
||||||
private static String npack = "net.minecraft.server." + Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3] + ".";
|
private static String npack = "net.minecraft.server." + Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3] + ".";
|
||||||
private static String cpack = Bukkit.getServer().getClass().getPackage().getName() + ".";
|
private static String cpack = Bukkit.getServer().getClass().getPackage().getName() + ".";
|
||||||
|
@ -205,8 +206,13 @@ public class Laser {
|
||||||
watcherName3 = "bA";
|
watcherName3 = "bA";
|
||||||
squidID = 74;
|
squidID = 74;
|
||||||
guardianID = 31;
|
guardianID = 31;
|
||||||
}else if (version >= 16) {
|
}else if (version == 16) {
|
||||||
|
if (nmsVersion.equals("v1_16_R3")) {
|
||||||
|
watcherName1 = "S";
|
||||||
|
} else {
|
||||||
watcherName1 = "T";
|
watcherName1 = "T";
|
||||||
|
}
|
||||||
|
|
||||||
watcherName2 = "b";
|
watcherName2 = "b";
|
||||||
watcherName3 = "d";
|
watcherName3 = "d";
|
||||||
squidID = 74;
|
squidID = 74;
|
||||||
|
|
|
@ -1,27 +1,22 @@
|
||||||
package nl.sbdeveloper.showapi.utils;
|
package nl.sbdeveloper.showapi.utils;
|
||||||
|
|
||||||
import com.samjakob.spigui.item.ItemBuilder;
|
import com.samjakob.spigui.item.ItemBuilder;
|
||||||
import nl.sbdeveloper.showapi.ShowAPI;
|
|
||||||
import nl.sbdeveloper.showapi.api.ShowCue;
|
import nl.sbdeveloper.showapi.api.ShowCue;
|
||||||
import nl.sbdeveloper.showapi.api.TriggerData;
|
import nl.sbdeveloper.showapi.api.TriggerData;
|
||||||
import nl.sbdeveloper.showapi.api.TriggerType;
|
import nl.sbdeveloper.showapi.api.TriggerType;
|
||||||
import nl.sbdeveloper.showapi.api.triggers.*;
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.*;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.craftbukkit.libs.org.apache.commons.lang3.ArrayUtils;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.util.ChatPaginator;
|
import org.bukkit.util.ChatPaginator;
|
||||||
|
|
||||||
import java.lang.reflect.Array;
|
import java.lang.reflect.Constructor;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class MainUtil {
|
public class MainUtil {
|
||||||
public static int pointsToRow(int points) {
|
|
||||||
return (int) Math.ceil((double) points / 9);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ItemStack pointToItem(ShowCue point) {
|
public static ItemStack pointToItem(ShowCue point) {
|
||||||
ItemBuilder builder = new ItemBuilder(Material.NOTE_BLOCK);
|
ItemBuilder builder = new ItemBuilder(Material.NOTE_BLOCK);
|
||||||
builder.name(ChatColor.ITALIC + "TimeCode: " + TimeUtil.showTime(point.getTimeSeconds()));
|
builder.name(ChatColor.ITALIC + "TimeCode: " + TimeUtil.showTime(point.getTimeSeconds()));
|
||||||
|
@ -50,19 +45,12 @@ public class MainUtil {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == TriggerType.COMMAND && dataSplitter.length >= 2) {
|
try {
|
||||||
return new CommandTrigger(dataSplitterNew);
|
Constructor<? extends TriggerData> ctor = type.getTrigger().getConstructor(String[].class);
|
||||||
} else if (type == TriggerType.FIREWORK && dataSplitter.length >= 6) {
|
if (dataSplitter.length < type.getMinArgs()) return null;
|
||||||
return new FireworkTrigger(dataSplitterNew);
|
return ctor.newInstance(new Object[] { dataSplitterNew });
|
||||||
} else if (type == TriggerType.LASER && dataSplitter.length == 6) {
|
} catch (NoSuchMethodException | IllegalAccessException | InstantiationException | InvocationTargetException e) {
|
||||||
return new LaserTrigger(dataSplitterNew);
|
|
||||||
} else if (type == TriggerType.SPOT && dataSplitter.length == 6) {
|
|
||||||
return new SpotTrigger(dataSplitterNew);
|
|
||||||
} else if (type == TriggerType.ANIMA && dataSplitter.length == 2) {
|
|
||||||
return new AnimaTrigger(dataSplitterNew);
|
|
||||||
}
|
|
||||||
|
|
||||||
Bukkit.getLogger().info("Aan het einde. Incorrecte type of te weinig data!");
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue