Added javadoc / API info
This commit is contained in:
parent
b25cd1323f
commit
2d194af704
15 changed files with 269 additions and 2 deletions
32
.run/ShowControl build.run.xml
Normal file
32
.run/ShowControl build.run.xml
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
<component name="ProjectRunConfigurationManager">
|
||||||
|
<configuration default="false" name="ShowControl build" type="MavenRunConfiguration" factoryName="Maven">
|
||||||
|
<MavenSettings>
|
||||||
|
<option name="myGeneralSettings" />
|
||||||
|
<option name="myRunnerSettings" />
|
||||||
|
<option name="myRunnerParameters">
|
||||||
|
<MavenRunnerParameters>
|
||||||
|
<option name="cmdOptions" />
|
||||||
|
<option name="profiles">
|
||||||
|
<set />
|
||||||
|
</option>
|
||||||
|
<option name="goals">
|
||||||
|
<list>
|
||||||
|
<option value="clean" />
|
||||||
|
<option value="package" />
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
<option name="pomFileName" />
|
||||||
|
<option name="profilesMap">
|
||||||
|
<map />
|
||||||
|
</option>
|
||||||
|
<option name="projectsCmdOptionValues">
|
||||||
|
<list />
|
||||||
|
</option>
|
||||||
|
<option name="resolveToWorkspace" value="false" />
|
||||||
|
<option name="workingDirPath" value="$PROJECT_DIR$" />
|
||||||
|
</MavenRunnerParameters>
|
||||||
|
</option>
|
||||||
|
</MavenSettings>
|
||||||
|
<method v="2" />
|
||||||
|
</configuration>
|
||||||
|
</component>
|
32
.run/ShowControl deploy.run.xml
Normal file
32
.run/ShowControl deploy.run.xml
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
<component name="ProjectRunConfigurationManager">
|
||||||
|
<configuration default="false" name="ShowControl deploy" type="MavenRunConfiguration" factoryName="Maven">
|
||||||
|
<MavenSettings>
|
||||||
|
<option name="myGeneralSettings" />
|
||||||
|
<option name="myRunnerSettings" />
|
||||||
|
<option name="myRunnerParameters">
|
||||||
|
<MavenRunnerParameters>
|
||||||
|
<option name="cmdOptions" />
|
||||||
|
<option name="profiles">
|
||||||
|
<set />
|
||||||
|
</option>
|
||||||
|
<option name="goals">
|
||||||
|
<list>
|
||||||
|
<option value="clean" />
|
||||||
|
<option value="deploy" />
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
<option name="pomFileName" />
|
||||||
|
<option name="profilesMap">
|
||||||
|
<map />
|
||||||
|
</option>
|
||||||
|
<option name="projectsCmdOptionValues">
|
||||||
|
<list />
|
||||||
|
</option>
|
||||||
|
<option name="resolveToWorkspace" value="false" />
|
||||||
|
<option name="workingDirPath" value="$PROJECT_DIR$" />
|
||||||
|
</MavenRunnerParameters>
|
||||||
|
</option>
|
||||||
|
</MavenSettings>
|
||||||
|
<method v="2" />
|
||||||
|
</configuration>
|
||||||
|
</component>
|
32
.run/ShowControl javadoc.run.xml
Normal file
32
.run/ShowControl javadoc.run.xml
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
<component name="ProjectRunConfigurationManager">
|
||||||
|
<configuration default="false" name="ShowControl javadoc" type="MavenRunConfiguration" factoryName="Maven">
|
||||||
|
<MavenSettings>
|
||||||
|
<option name="myGeneralSettings" />
|
||||||
|
<option name="myRunnerSettings" />
|
||||||
|
<option name="myRunnerParameters">
|
||||||
|
<MavenRunnerParameters>
|
||||||
|
<option name="cmdOptions" />
|
||||||
|
<option name="profiles">
|
||||||
|
<set />
|
||||||
|
</option>
|
||||||
|
<option name="goals">
|
||||||
|
<list>
|
||||||
|
<option value="clean" />
|
||||||
|
<option value="javadoc:javadoc" />
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
<option name="pomFileName" />
|
||||||
|
<option name="profilesMap">
|
||||||
|
<map />
|
||||||
|
</option>
|
||||||
|
<option name="projectsCmdOptionValues">
|
||||||
|
<list />
|
||||||
|
</option>
|
||||||
|
<option name="resolveToWorkspace" value="false" />
|
||||||
|
<option name="workingDirPath" value="$PROJECT_DIR$" />
|
||||||
|
</MavenRunnerParameters>
|
||||||
|
</option>
|
||||||
|
</MavenSettings>
|
||||||
|
<method v="2" />
|
||||||
|
</configuration>
|
||||||
|
</component>
|
19
pom.xml
19
pom.xml
|
@ -23,6 +23,13 @@
|
||||||
</pluginRepository>
|
</pluginRepository>
|
||||||
</pluginRepositories>
|
</pluginRepositories>
|
||||||
|
|
||||||
|
<distributionManagement>
|
||||||
|
<repository>
|
||||||
|
<id>sbdevelopment-repo</id>
|
||||||
|
<url>https://repo.sbdevelopment.tech/releases</url>
|
||||||
|
</repository>
|
||||||
|
</distributionManagement>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<defaultGoal>clean package</defaultGoal>
|
<defaultGoal>clean package</defaultGoal>
|
||||||
<finalName>${project.name} v${project.version}</finalName>
|
<finalName>${project.name} v${project.version}</finalName>
|
||||||
|
@ -85,6 +92,18 @@
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-javadoc-plugin</artifactId>
|
||||||
|
<version>3.6.0</version>
|
||||||
|
<configuration>
|
||||||
|
<release>11</release>
|
||||||
|
<additionalJOption>--no-module-directories</additionalJOption> <!-- Fix for undefined in search -->
|
||||||
|
<sourceFileIncludes>
|
||||||
|
<sourceFileInclude>**/tech/sbdevelopment/showcontrol/api/**</sourceFileInclude>
|
||||||
|
</sourceFileIncludes>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
<resources>
|
<resources>
|
||||||
<resource>
|
<resource>
|
||||||
|
|
|
@ -17,6 +17,7 @@ import tech.sbdevelopment.showcontrol.api.triggers.TriggerIdentifier;
|
||||||
import tech.sbdevelopment.showcontrol.data.DataStorage;
|
import tech.sbdevelopment.showcontrol.data.DataStorage;
|
||||||
import tech.sbdevelopment.showcontrol.utils.YamlFile;
|
import tech.sbdevelopment.showcontrol.utils.YamlFile;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
@ -25,15 +26,36 @@ import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class is the main class of the API.
|
||||||
|
*/
|
||||||
public class SCAPI {
|
public class SCAPI {
|
||||||
|
/**
|
||||||
|
* A map of all default trigger, only used for tab complete.
|
||||||
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
private static final Map<String, Trigger> defaultTriggers = new HashMap<>(); //DO NOT USE, just for tab complete!
|
private static final Map<String, Trigger> defaultTriggers = new HashMap<>();
|
||||||
|
/**
|
||||||
|
* A map of all triggers, used for creating new triggers.
|
||||||
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
private static final Map<String, Class<? extends Trigger>> triggers = new HashMap<>();
|
private static final Map<String, Class<? extends Trigger>> triggers = new HashMap<>();
|
||||||
|
/**
|
||||||
|
* A map of all shows with their cue points.
|
||||||
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
private static final HashMap<String, List<ShowCuePoint>> showsMap = new HashMap<>();
|
private static final HashMap<String, List<ShowCuePoint>> showsMap = new HashMap<>();
|
||||||
|
/**
|
||||||
|
* A map of all show timers.
|
||||||
|
*/
|
||||||
private static final HashMap<String, ScheduledExecutorService> showTimers = new HashMap<>();
|
private static final HashMap<String, ScheduledExecutorService> showTimers = new HashMap<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Index all triggers in a package. Call this method in your onEnable method.
|
||||||
|
*
|
||||||
|
* @param clazz The class to use as starting point, usually your main class.
|
||||||
|
* @param packages The packages to index.
|
||||||
|
*/
|
||||||
public static void index(Class<?> clazz, String... packages) {
|
public static void index(Class<?> clazz, String... packages) {
|
||||||
ShowControlPlugin.getInstance().getLogger().info("Indexing triggers for starting point " + clazz.getSimpleName() + "...");
|
ShowControlPlugin.getInstance().getLogger().info("Indexing triggers for starting point " + clazz.getSimpleName() + "...");
|
||||||
|
|
||||||
|
@ -62,11 +84,31 @@ public class SCAPI {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<String> getTabComplete(String triggerType, Player player, int index, String arg) {
|
/**
|
||||||
|
* Get the tab complete for a trigger.
|
||||||
|
*
|
||||||
|
* @param triggerType The trigger type.
|
||||||
|
* @param player The player that wants to add the cue, will be null if it's not a player.
|
||||||
|
* @param index The current argument index.
|
||||||
|
* @param arg The current argument.
|
||||||
|
* @return The tab complete value based on the index and argument.
|
||||||
|
*/
|
||||||
|
public static List<String> getTabComplete(String triggerType, @Nullable Player player, int index, String arg) {
|
||||||
if (!defaultTriggers.containsKey(triggerType)) return new ArrayList<>();
|
if (!defaultTriggers.containsKey(triggerType)) return new ArrayList<>();
|
||||||
return defaultTriggers.get(triggerType).getArgumentTabComplete(player, index, arg);
|
return defaultTriggers.get(triggerType).getArgumentTabComplete(player, index, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a trigger from a data string.
|
||||||
|
*
|
||||||
|
* @param data The data string.
|
||||||
|
* @return The trigger.
|
||||||
|
* @param <T> The trigger type.
|
||||||
|
* @throws ReflectiveOperationException When the trigger could not be created.
|
||||||
|
* @throws InvalidTriggerException When the trigger does not exist.
|
||||||
|
* @throws TooFewArgumentsException When the trigger data does not have enough arguments.
|
||||||
|
* @throws IllegalArgumentException When the trigger data is invalid.
|
||||||
|
*/
|
||||||
public static <T extends Trigger> T getTrigger(String data) throws ReflectiveOperationException, InvalidTriggerException, TooFewArgumentsException, IllegalArgumentException {
|
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);
|
||||||
|
@ -83,11 +125,21 @@ public class SCAPI {
|
||||||
return ctor.newInstance(new Object[]{dataSplitterNew});
|
return ctor.newInstance(new Object[]{dataSplitterNew});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new show.
|
||||||
|
*
|
||||||
|
* @param name The name of the show.
|
||||||
|
*/
|
||||||
public static void create(String name) {
|
public static void create(String name) {
|
||||||
showsMap.put(name, new ArrayList<>());
|
showsMap.put(name, new ArrayList<>());
|
||||||
DataStorage.save();
|
DataStorage.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete a show.
|
||||||
|
*
|
||||||
|
* @param name The name of the show.
|
||||||
|
*/
|
||||||
public static void delete(String name) {
|
public static void delete(String name) {
|
||||||
showsMap.remove(name);
|
showsMap.remove(name);
|
||||||
|
|
||||||
|
@ -95,21 +147,46 @@ public class SCAPI {
|
||||||
data.delete();
|
data.delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a show exists.
|
||||||
|
*
|
||||||
|
* @param name The name of the show.
|
||||||
|
* @return If the show exists.
|
||||||
|
*/
|
||||||
public static boolean exists(String name) {
|
public static boolean exists(String name) {
|
||||||
return showsMap.containsKey(name);
|
return showsMap.containsKey(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the points of a show.
|
||||||
|
*
|
||||||
|
* @param name The name of the show.
|
||||||
|
* @return The points of the show.
|
||||||
|
*/
|
||||||
public static List<ShowCuePoint> getPoints(String name) {
|
public static List<ShowCuePoint> getPoints(String name) {
|
||||||
if (!exists(name)) return new ArrayList<>();
|
if (!exists(name)) return new ArrayList<>();
|
||||||
return showsMap.get(name);
|
return showsMap.get(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a point to a show.
|
||||||
|
*
|
||||||
|
* @param name The name of the show.
|
||||||
|
* @param time The time of the point.
|
||||||
|
* @param data The data of the point.
|
||||||
|
*/
|
||||||
public static void addPoint(String name, Long time, Trigger data) {
|
public static void addPoint(String name, Long time, Trigger data) {
|
||||||
if (!exists(name)) return;
|
if (!exists(name)) return;
|
||||||
getPoints(name).add(new ShowCuePoint(time, data));
|
getPoints(name).add(new ShowCuePoint(time, data));
|
||||||
DataStorage.save();
|
DataStorage.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a point from a show.
|
||||||
|
*
|
||||||
|
* @param name The name of the show.
|
||||||
|
* @param point The point to remove.
|
||||||
|
*/
|
||||||
public static void removePoint(String name, ShowCuePoint point) {
|
public static void removePoint(String name, ShowCuePoint point) {
|
||||||
if (!exists(name)) return;
|
if (!exists(name)) return;
|
||||||
|
|
||||||
|
@ -122,6 +199,11 @@ public class SCAPI {
|
||||||
data.saveFile();
|
data.saveFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start a show.
|
||||||
|
*
|
||||||
|
* @param name The name of the show.
|
||||||
|
*/
|
||||||
public static void startShow(String name) {
|
public static void startShow(String name) {
|
||||||
if (!exists(name)) return;
|
if (!exists(name)) return;
|
||||||
ScheduledExecutorService showTimer = Executors.newSingleThreadScheduledExecutor();
|
ScheduledExecutorService showTimer = Executors.newSingleThreadScheduledExecutor();
|
||||||
|
@ -131,6 +213,11 @@ public class SCAPI {
|
||||||
showTimers.put(name, showTimer);
|
showTimers.put(name, showTimer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cancel a show.
|
||||||
|
*
|
||||||
|
* @param name The name of the show.
|
||||||
|
*/
|
||||||
public static void cancelShow(String name) {
|
public static void cancelShow(String name) {
|
||||||
if (!exists(name)) return;
|
if (!exists(name)) return;
|
||||||
if (!showTimers.containsKey(name)) return;
|
if (!showTimers.containsKey(name)) return;
|
||||||
|
|
|
@ -2,6 +2,9 @@ package tech.sbdevelopment.showcontrol.api.exceptions;
|
||||||
|
|
||||||
import lombok.experimental.StandardException;
|
import lombok.experimental.StandardException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Thrown when an argument is invalid
|
||||||
|
*/
|
||||||
@StandardException
|
@StandardException
|
||||||
public class InvalidArgumentException extends Exception {
|
public class InvalidArgumentException extends Exception {
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,9 @@ package tech.sbdevelopment.showcontrol.api.exceptions;
|
||||||
|
|
||||||
import lombok.experimental.StandardException;
|
import lombok.experimental.StandardException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Thrown when a trigger is invalid
|
||||||
|
*/
|
||||||
@StandardException
|
@StandardException
|
||||||
public class InvalidTriggerException extends Exception {
|
public class InvalidTriggerException extends Exception {
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,9 @@ package tech.sbdevelopment.showcontrol.api.exceptions;
|
||||||
|
|
||||||
import lombok.experimental.StandardException;
|
import lombok.experimental.StandardException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Thrown when a trigger has too few arguments
|
||||||
|
*/
|
||||||
@StandardException
|
@StandardException
|
||||||
public class TooFewArgumentsException extends Exception {
|
public class TooFewArgumentsException extends Exception {
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
/**
|
||||||
|
* This package contains the exceptions thrown by the plugin.
|
||||||
|
*/
|
||||||
|
package tech.sbdevelopment.showcontrol.api.exceptions;
|
|
@ -0,0 +1,4 @@
|
||||||
|
/**
|
||||||
|
* This package contains the API of the ShowControl plugin.
|
||||||
|
*/
|
||||||
|
package tech.sbdevelopment.showcontrol.api;
|
|
@ -12,8 +12,19 @@ import java.util.UUID;
|
||||||
@Getter
|
@Getter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class ShowCuePoint {
|
public class ShowCuePoint {
|
||||||
|
/**
|
||||||
|
* The ID of the cue point
|
||||||
|
*/
|
||||||
private final UUID cueID;
|
private final UUID cueID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The start-time (milliseconds)
|
||||||
|
*/
|
||||||
private final Long time;
|
private final Long time;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The data
|
||||||
|
*/
|
||||||
private final Trigger data;
|
private final Trigger data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
/**
|
||||||
|
* This package contains the point API.
|
||||||
|
*/
|
||||||
|
package tech.sbdevelopment.showcontrol.api.points;
|
|
@ -8,10 +8,16 @@ import org.bukkit.entity.Player;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class is the base class for all triggers
|
||||||
|
*/
|
||||||
@NoArgsConstructor(force = true)
|
@NoArgsConstructor(force = true)
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@Getter
|
@Getter
|
||||||
public abstract class Trigger {
|
public abstract class Trigger {
|
||||||
|
/**
|
||||||
|
* The datastring of the trigger
|
||||||
|
*/
|
||||||
private final String[] dataString;
|
private final String[] dataString;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -7,14 +7,37 @@ import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This annotation is used to identify a trigger.
|
||||||
|
*/
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Target(ElementType.TYPE)
|
@Target(ElementType.TYPE)
|
||||||
public @interface TriggerIdentifier {
|
public @interface TriggerIdentifier {
|
||||||
|
/**
|
||||||
|
* The identifier of the trigger, used in the add command.
|
||||||
|
*
|
||||||
|
* @return The identifier of the trigger.
|
||||||
|
*/
|
||||||
String value();
|
String value();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The minimum amount of arguments the trigger needs.
|
||||||
|
*
|
||||||
|
* @return The minimum amount of arguments the trigger needs.
|
||||||
|
*/
|
||||||
int minArgs() default 0;
|
int minArgs() default 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The description of the arguments the trigger needs.
|
||||||
|
*
|
||||||
|
* @return The description of the arguments the trigger needs.
|
||||||
|
*/
|
||||||
String argDesc() default "";
|
String argDesc() default "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The item shown in the GUI for a show.
|
||||||
|
*
|
||||||
|
* @return The item shown in the GUI for a show.
|
||||||
|
*/
|
||||||
Material item() default Material.NOTE_BLOCK;
|
Material item() default Material.NOTE_BLOCK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
/**
|
||||||
|
* This package contains the trigger API.
|
||||||
|
*/
|
||||||
|
package tech.sbdevelopment.showcontrol.api.triggers;
|
Loading…
Add table
Reference in a new issue