commit
06bcb0fb15
4 changed files with 11 additions and 9 deletions
|
@ -34,10 +34,7 @@ public final class ShowControlPlugin extends JavaPlugin {
|
||||||
getLogger().info("Loading default triggers...");
|
getLogger().info("Loading default triggers...");
|
||||||
ShowAPI.index(ShowControlPlugin.class, "nl.sbdeveloper.showcontrol.api.triggers.impl");
|
ShowAPI.index(ShowControlPlugin.class, "nl.sbdeveloper.showcontrol.api.triggers.impl");
|
||||||
|
|
||||||
Bukkit.getScheduler().runTaskLater(this, () -> {
|
Bukkit.getScheduler().runTaskLater(this, DataStorage::load, 1L); //Load 1 tick later, because of multi world
|
||||||
getLogger().info("Loading data...");
|
|
||||||
DataStorage.load();
|
|
||||||
}, 1L); //Load 1 tick later, because of multi world
|
|
||||||
|
|
||||||
getLogger().info("Plugin enabled!");
|
getLogger().info("Plugin enabled!");
|
||||||
getLogger().info("-------------------------------");
|
getLogger().info("-------------------------------");
|
||||||
|
|
|
@ -42,7 +42,7 @@ public class ShowAPI {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T extends Trigger> T getTrigger(String data) throws ReflectiveOperationException, InvalidTriggerException, TooFewArgumentsException {
|
public static <T extends Trigger> T getTrigger(String data) throws ReflectiveOperationException, InvalidTriggerException, TooFewArgumentsException, IllegalArgumentException {
|
||||||
String[] dataSplitter = data.split(" ");
|
String[] dataSplitter = data.split(" ");
|
||||||
String[] dataSplitterNew = Arrays.copyOfRange(dataSplitter, 1, dataSplitter.length);
|
String[] dataSplitterNew = Arrays.copyOfRange(dataSplitter, 1, dataSplitter.length);
|
||||||
|
|
||||||
|
@ -52,6 +52,6 @@ public class ShowAPI {
|
||||||
|
|
||||||
Constructor<T> ctor = (Constructor<T>) triggers.get(triggerType).getConstructor(String[].class);
|
Constructor<T> ctor = (Constructor<T>) triggers.get(triggerType).getConstructor(String[].class);
|
||||||
if (dataSplitter.length < triggers.get(triggerType).getAnnotation(TriggerIdentifier.class).minArgs() + 1) throw new TooFewArgumentsException("Provided triggerdata " + data + " has too few arguments!");
|
if (dataSplitter.length < triggers.get(triggerType).getAnnotation(TriggerIdentifier.class).minArgs() + 1) throw new TooFewArgumentsException("Provided triggerdata " + data + " has too few arguments!");
|
||||||
return ctor.newInstance(dataSplitterNew);
|
return ctor.newInstance(new Object[] { dataSplitterNew });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ public class ShowCMD extends BaseCommand {
|
||||||
|
|
||||||
@Subcommand("add")
|
@Subcommand("add")
|
||||||
@Description("")
|
@Description("")
|
||||||
@CommandCompletion("@showname @empty @showtype")
|
@CommandCompletion("@showname @empty @showtype @empty")
|
||||||
public void onAdd(CommandSender sender, String name, String time, String args) {
|
public void onAdd(CommandSender sender, String name, String time, String args) {
|
||||||
if (!Shows.exists(name)) {
|
if (!Shows.exists(name)) {
|
||||||
sender.sendMessage(ChatColor.RED + "That show doesn't exists.");
|
sender.sendMessage(ChatColor.RED + "That show doesn't exists.");
|
||||||
|
@ -73,6 +73,9 @@ public class ShowCMD extends BaseCommand {
|
||||||
} catch (TooFewArgumentsException e) {
|
} catch (TooFewArgumentsException e) {
|
||||||
sender.sendMessage(ChatColor.RED + "You did not provide enough information for the chosen trigger.");
|
sender.sendMessage(ChatColor.RED + "You did not provide enough information for the chosen trigger.");
|
||||||
return;
|
return;
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "Couldn't create the trigger: " + e.getMessage());
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Shows.addPoint(name, timeMilli, data);
|
Shows.addPoint(name, timeMilli, data);
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package nl.sbdeveloper.showcontrol.utils;
|
package nl.sbdeveloper.showcontrol.utils;
|
||||||
|
|
||||||
import nl.sbdeveloper.showcontrol.api.ShowCuePoint;
|
import nl.sbdeveloper.showcontrol.api.ShowCuePoint;
|
||||||
|
import nl.sbdeveloper.showcontrol.api.triggers.TriggerIdentifier;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.util.ChatPaginator;
|
import org.bukkit.util.ChatPaginator;
|
||||||
|
|
||||||
|
@ -15,7 +15,9 @@ public class MainUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ItemStack pointToItem(ShowCuePoint point) {
|
public static ItemStack pointToItem(ShowCuePoint point) {
|
||||||
ItemBuilder builder = new ItemBuilder(Material.NOTE_BLOCK);
|
TriggerIdentifier identifier = point.getTask().getClass().getAnnotation(TriggerIdentifier.class);
|
||||||
|
|
||||||
|
ItemBuilder builder = new ItemBuilder(identifier.item());
|
||||||
builder.setName(ChatColor.ITALIC + "TimeCode: " + TimeUtil.makeReadable(point.getTime()));
|
builder.setName(ChatColor.ITALIC + "TimeCode: " + TimeUtil.makeReadable(point.getTime()));
|
||||||
|
|
||||||
List<String> lores = new ArrayList<>();
|
List<String> lores = new ArrayList<>();
|
||||||
|
|
Loading…
Add table
Reference in a new issue