Small API changes
This commit is contained in:
parent
f6bfb40a81
commit
3f5d0de26e
22 changed files with 86 additions and 142 deletions
10
pom.xml
10
pom.xml
|
@ -62,23 +62,23 @@
|
||||||
<relocations>
|
<relocations>
|
||||||
<relocation>
|
<relocation>
|
||||||
<pattern>fr.minuskube.inv</pattern>
|
<pattern>fr.minuskube.inv</pattern>
|
||||||
<shadedPattern>nl.sbdeveloper.showcontrol.libs.inv</shadedPattern>
|
<shadedPattern>tech.sbdevelopment.showcontrol.libs.inv</shadedPattern>
|
||||||
</relocation>
|
</relocation>
|
||||||
<relocation>
|
<relocation>
|
||||||
<pattern>fr.skytasul.guardianbeam</pattern>
|
<pattern>fr.skytasul.guardianbeam</pattern>
|
||||||
<shadedPattern>nl.sbdeveloper.showcontrol.libs.guardianbeam</shadedPattern>
|
<shadedPattern>tech.sbdevelopment.showcontrol.libs.guardianbeam</shadedPattern>
|
||||||
</relocation>
|
</relocation>
|
||||||
<relocation>
|
<relocation>
|
||||||
<pattern>co.aikar.commands</pattern>
|
<pattern>co.aikar.commands</pattern>
|
||||||
<shadedPattern>nl.sbdeveloper.showcontrol.libs.commands</shadedPattern>
|
<shadedPattern>tech.sbdevelopment.showcontrol.libs.commands</shadedPattern>
|
||||||
</relocation>
|
</relocation>
|
||||||
<relocation>
|
<relocation>
|
||||||
<pattern>co.aikar.locales</pattern>
|
<pattern>co.aikar.locales</pattern>
|
||||||
<shadedPattern>nl.sbdeveloper.showcontrol.libs.locales</shadedPattern>
|
<shadedPattern>tech.sbdevelopment.showcontrol.libs.locales</shadedPattern>
|
||||||
</relocation>
|
</relocation>
|
||||||
<relocation>
|
<relocation>
|
||||||
<pattern>org.reflections</pattern>
|
<pattern>org.reflections</pattern>
|
||||||
<shadedPattern>nl.sbdeveloper.showcontrol.libs.reflections</shadedPattern>
|
<shadedPattern>tech.sbdevelopment.showcontrol.libs.reflections</shadedPattern>
|
||||||
</relocation>
|
</relocation>
|
||||||
</relocations>
|
</relocations>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|
|
@ -44,7 +44,7 @@ public final class ShowControlPlugin extends JavaPlugin {
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
getLogger().info("Saving data...");
|
getLogger().info("Saving data...");
|
||||||
DataStorage.save();
|
DataStorage.save();
|
||||||
Shows.getShowsMap().values().forEach(show -> show.forEach(showCue -> showCue.getTask().remove()));
|
Shows.getShowsMap().values().forEach(show -> show.forEach(showCue -> showCue.getData().remove()));
|
||||||
|
|
||||||
getLogger().info("Plugin disabled!");
|
getLogger().info("Plugin disabled!");
|
||||||
instance = null;
|
instance = null;
|
||||||
|
|
|
@ -2,6 +2,8 @@ package tech.sbdevelopment.showcontrol.api;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import tech.sbdevelopment.showcontrol.ShowControlPlugin;
|
import tech.sbdevelopment.showcontrol.ShowControlPlugin;
|
||||||
|
import tech.sbdevelopment.showcontrol.api.exceptions.InvalidTriggerException;
|
||||||
|
import tech.sbdevelopment.showcontrol.api.exceptions.TooFewArgumentsException;
|
||||||
import tech.sbdevelopment.showcontrol.api.triggers.Trigger;
|
import tech.sbdevelopment.showcontrol.api.triggers.Trigger;
|
||||||
import tech.sbdevelopment.showcontrol.api.triggers.TriggerIdentifier;
|
import tech.sbdevelopment.showcontrol.api.triggers.TriggerIdentifier;
|
||||||
import org.reflections.Reflections;
|
import org.reflections.Reflections;
|
||||||
|
|
|
@ -1,64 +0,0 @@
|
||||||
package tech.sbdevelopment.showcontrol.api;
|
|
||||||
|
|
||||||
import tech.sbdevelopment.showcontrol.api.triggers.Trigger;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A cue point of a show
|
|
||||||
*/
|
|
||||||
public class ShowCuePoint {
|
|
||||||
private final UUID cueID;
|
|
||||||
private final Long time;
|
|
||||||
private final Trigger data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new cue point
|
|
||||||
*
|
|
||||||
* @param time The starttime (milli)
|
|
||||||
* @param data The data
|
|
||||||
*/
|
|
||||||
public ShowCuePoint(Long time, Trigger data) {
|
|
||||||
this(UUID.randomUUID(), time, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Load an exisiting cue point
|
|
||||||
*
|
|
||||||
* @param uuid The UUID
|
|
||||||
* @param time The starttime (milli)
|
|
||||||
* @param data The data
|
|
||||||
*/
|
|
||||||
public ShowCuePoint(UUID uuid, Long time, Trigger data) {
|
|
||||||
this.cueID = uuid;
|
|
||||||
this.time = time;
|
|
||||||
this.data = data;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the ID of the cue point
|
|
||||||
*
|
|
||||||
* @return The UUID
|
|
||||||
*/
|
|
||||||
public UUID getCueID() {
|
|
||||||
return cueID;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the time (milli)
|
|
||||||
*
|
|
||||||
* @return The time (milli)
|
|
||||||
*/
|
|
||||||
public Long getTime() {
|
|
||||||
return time;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the data of this cue
|
|
||||||
*
|
|
||||||
* @return The data
|
|
||||||
*/
|
|
||||||
public Trigger getTask() {
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,4 +1,4 @@
|
||||||
package tech.sbdevelopment.showcontrol.api;
|
package tech.sbdevelopment.showcontrol.api.exceptions;
|
||||||
|
|
||||||
import lombok.experimental.StandardException;
|
import lombok.experimental.StandardException;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package tech.sbdevelopment.showcontrol.api;
|
package tech.sbdevelopment.showcontrol.api.exceptions;
|
||||||
|
|
||||||
import lombok.experimental.StandardException;
|
import lombok.experimental.StandardException;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package tech.sbdevelopment.showcontrol.api;
|
package tech.sbdevelopment.showcontrol.api.exceptions;
|
||||||
|
|
||||||
import lombok.experimental.StandardException;
|
import lombok.experimental.StandardException;
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
package tech.sbdevelopment.showcontrol.api.points;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import tech.sbdevelopment.showcontrol.api.triggers.Trigger;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A cue point of a show
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class ShowCuePoint {
|
||||||
|
private final UUID cueID;
|
||||||
|
private final Long time;
|
||||||
|
private final Trigger data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new cue point
|
||||||
|
*
|
||||||
|
* @param time The start-time (milliseconds)
|
||||||
|
* @param data The data
|
||||||
|
*/
|
||||||
|
public ShowCuePoint(Long time, Trigger data) {
|
||||||
|
this(UUID.randomUUID(), time, data);
|
||||||
|
}
|
||||||
|
}
|
|
@ -33,6 +33,11 @@ public abstract class Trigger {
|
||||||
return builder.toString().trim();
|
return builder.toString().trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the ID of the trigger
|
||||||
|
*
|
||||||
|
* @return The ID
|
||||||
|
*/
|
||||||
public String getTriggerId() {
|
public String getTriggerId() {
|
||||||
return getClass().getAnnotation(TriggerIdentifier.class).value();
|
return getClass().getAnnotation(TriggerIdentifier.class).value();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package tech.sbdevelopment.showcontrol.api.triggers.impl;
|
package tech.sbdevelopment.showcontrol.api.triggers.impl;
|
||||||
|
|
||||||
import tech.sbdevelopment.showcontrol.api.InvalidArgumentException;
|
import tech.sbdevelopment.showcontrol.api.exceptions.InvalidArgumentException;
|
||||||
import tech.sbdevelopment.showcontrol.api.triggers.Trigger;
|
import tech.sbdevelopment.showcontrol.api.triggers.Trigger;
|
||||||
import tech.sbdevelopment.showcontrol.api.triggers.TriggerIdentifier;
|
import tech.sbdevelopment.showcontrol.api.triggers.TriggerIdentifier;
|
||||||
import tech.sbdevelopment.showcontrol.elements.Fireworks;
|
import tech.sbdevelopment.showcontrol.elements.Fireworks;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package tech.sbdevelopment.showcontrol.api.triggers.impl;
|
package tech.sbdevelopment.showcontrol.api.triggers.impl;
|
||||||
|
|
||||||
import tech.sbdevelopment.showcontrol.api.InvalidArgumentException;
|
import tech.sbdevelopment.showcontrol.api.exceptions.InvalidArgumentException;
|
||||||
import tech.sbdevelopment.showcontrol.api.triggers.Trigger;
|
import tech.sbdevelopment.showcontrol.api.triggers.Trigger;
|
||||||
import tech.sbdevelopment.showcontrol.api.triggers.TriggerIdentifier;
|
import tech.sbdevelopment.showcontrol.api.triggers.TriggerIdentifier;
|
||||||
import tech.sbdevelopment.showcontrol.elements.Lasers;
|
import tech.sbdevelopment.showcontrol.elements.Lasers;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package tech.sbdevelopment.showcontrol.api.triggers.impl;
|
package tech.sbdevelopment.showcontrol.api.triggers.impl;
|
||||||
|
|
||||||
import tech.sbdevelopment.showcontrol.api.InvalidArgumentException;
|
import tech.sbdevelopment.showcontrol.api.exceptions.InvalidArgumentException;
|
||||||
import tech.sbdevelopment.showcontrol.api.triggers.Trigger;
|
import tech.sbdevelopment.showcontrol.api.triggers.Trigger;
|
||||||
import tech.sbdevelopment.showcontrol.api.triggers.TriggerIdentifier;
|
import tech.sbdevelopment.showcontrol.api.triggers.TriggerIdentifier;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package tech.sbdevelopment.showcontrol.api.triggers.impl;
|
package tech.sbdevelopment.showcontrol.api.triggers.impl;
|
||||||
|
|
||||||
import tech.sbdevelopment.showcontrol.api.InvalidArgumentException;
|
import tech.sbdevelopment.showcontrol.api.exceptions.InvalidArgumentException;
|
||||||
import tech.sbdevelopment.showcontrol.api.triggers.Trigger;
|
import tech.sbdevelopment.showcontrol.api.triggers.Trigger;
|
||||||
import tech.sbdevelopment.showcontrol.api.triggers.TriggerIdentifier;
|
import tech.sbdevelopment.showcontrol.api.triggers.TriggerIdentifier;
|
||||||
import tech.sbdevelopment.showcontrol.elements.Spots;
|
import tech.sbdevelopment.showcontrol.elements.Spots;
|
||||||
|
|
|
@ -2,9 +2,9 @@ package tech.sbdevelopment.showcontrol.commands;
|
||||||
|
|
||||||
import co.aikar.commands.BaseCommand;
|
import co.aikar.commands.BaseCommand;
|
||||||
import co.aikar.commands.annotation.*;
|
import co.aikar.commands.annotation.*;
|
||||||
import tech.sbdevelopment.showcontrol.api.InvalidTriggerException;
|
import tech.sbdevelopment.showcontrol.api.exceptions.InvalidTriggerException;
|
||||||
import tech.sbdevelopment.showcontrol.api.ShowAPI;
|
import tech.sbdevelopment.showcontrol.api.ShowAPI;
|
||||||
import tech.sbdevelopment.showcontrol.api.TooFewArgumentsException;
|
import tech.sbdevelopment.showcontrol.api.exceptions.TooFewArgumentsException;
|
||||||
import tech.sbdevelopment.showcontrol.api.triggers.Trigger;
|
import tech.sbdevelopment.showcontrol.api.triggers.Trigger;
|
||||||
import tech.sbdevelopment.showcontrol.data.Shows;
|
import tech.sbdevelopment.showcontrol.data.Shows;
|
||||||
import tech.sbdevelopment.showcontrol.gui.ShowCueGUI;
|
import tech.sbdevelopment.showcontrol.gui.ShowCueGUI;
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package tech.sbdevelopment.showcontrol.data;
|
package tech.sbdevelopment.showcontrol.data;
|
||||||
|
|
||||||
import tech.sbdevelopment.showcontrol.ShowControlPlugin;
|
import tech.sbdevelopment.showcontrol.ShowControlPlugin;
|
||||||
import tech.sbdevelopment.showcontrol.api.InvalidTriggerException;
|
import tech.sbdevelopment.showcontrol.api.exceptions.InvalidTriggerException;
|
||||||
import tech.sbdevelopment.showcontrol.api.ShowAPI;
|
import tech.sbdevelopment.showcontrol.api.ShowAPI;
|
||||||
import tech.sbdevelopment.showcontrol.api.ShowCuePoint;
|
import tech.sbdevelopment.showcontrol.api.points.ShowCuePoint;
|
||||||
import tech.sbdevelopment.showcontrol.api.TooFewArgumentsException;
|
import tech.sbdevelopment.showcontrol.api.exceptions.TooFewArgumentsException;
|
||||||
import tech.sbdevelopment.showcontrol.api.triggers.Trigger;
|
import tech.sbdevelopment.showcontrol.api.triggers.Trigger;
|
||||||
import tech.sbdevelopment.showcontrol.utils.YamlFile;
|
import tech.sbdevelopment.showcontrol.utils.YamlFile;
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ public class DataStorage {
|
||||||
File showsFolder = new File(ShowControlPlugin.getInstance().getDataFolder(), "data");
|
File showsFolder = new File(ShowControlPlugin.getInstance().getDataFolder(), "data");
|
||||||
for (File showFile : showsFolder.listFiles()) {
|
for (File showFile : showsFolder.listFiles()) {
|
||||||
String showID = removeExtension(showFile.getName());
|
String showID = removeExtension(showFile.getName());
|
||||||
YamlFile showConfig = new YamlFile("data/" + showID);
|
YamlFile showConfig = new YamlFile(ShowControlPlugin.getInstance(), "data/" + showID);
|
||||||
files.put(showID, showConfig);
|
files.put(showID, showConfig);
|
||||||
|
|
||||||
List<ShowCuePoint> cues = new ArrayList<>();
|
List<ShowCuePoint> cues = new ArrayList<>();
|
||||||
|
@ -51,11 +51,11 @@ public class DataStorage {
|
||||||
|
|
||||||
public static void save() {
|
public static void save() {
|
||||||
for (Map.Entry<String, List<ShowCuePoint>> entry : Shows.getShowsMap().entrySet()) {
|
for (Map.Entry<String, List<ShowCuePoint>> entry : Shows.getShowsMap().entrySet()) {
|
||||||
YamlFile file = files.containsKey(entry.getKey()) ? files.get(entry.getKey()) : new YamlFile("data/" + entry.getKey());
|
YamlFile file = files.containsKey(entry.getKey()) ? files.get(entry.getKey()) : new YamlFile(ShowControlPlugin.getInstance(), "data/" + entry.getKey());
|
||||||
for (ShowCuePoint cue : entry.getValue()) {
|
for (ShowCuePoint cue : entry.getValue()) {
|
||||||
file.getFile().set(cue.getCueID().toString() + ".Time", cue.getTime());
|
file.getFile().set(cue.getCueID().toString() + ".Time", cue.getTime());
|
||||||
file.getFile().set(cue.getCueID().toString() + ".Type", cue.getTask().getTriggerId());
|
file.getFile().set(cue.getCueID().toString() + ".Type", cue.getData().getTriggerId());
|
||||||
file.getFile().set(cue.getCueID().toString() + ".Data", cue.getTask().getDataString());
|
file.getFile().set(cue.getCueID().toString() + ".Data", cue.getData().getDataString());
|
||||||
}
|
}
|
||||||
file.saveFile();
|
file.saveFile();
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ package tech.sbdevelopment.showcontrol.data;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import tech.sbdevelopment.showcontrol.ShowControlPlugin;
|
import tech.sbdevelopment.showcontrol.ShowControlPlugin;
|
||||||
import tech.sbdevelopment.showcontrol.api.ShowCuePoint;
|
import tech.sbdevelopment.showcontrol.api.points.ShowCuePoint;
|
||||||
import tech.sbdevelopment.showcontrol.api.triggers.Trigger;
|
import tech.sbdevelopment.showcontrol.api.triggers.Trigger;
|
||||||
import tech.sbdevelopment.showcontrol.utils.YamlFile;
|
import tech.sbdevelopment.showcontrol.utils.YamlFile;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
@ -50,7 +50,7 @@ public class Shows {
|
||||||
public static void removePoint(String name, ShowCuePoint point) {
|
public static void removePoint(String name, ShowCuePoint point) {
|
||||||
if (!exists(name)) return;
|
if (!exists(name)) return;
|
||||||
|
|
||||||
point.getTask().remove();
|
point.getData().remove();
|
||||||
showsMap.get(name).remove(point);
|
showsMap.get(name).remove(point);
|
||||||
|
|
||||||
YamlFile data = DataStorage.getFiles().get(name);
|
YamlFile data = DataStorage.getFiles().get(name);
|
||||||
|
@ -63,7 +63,7 @@ public class Shows {
|
||||||
if (!exists(name)) return;
|
if (!exists(name)) return;
|
||||||
ScheduledExecutorService showTimer = Executors.newSingleThreadScheduledExecutor();
|
ScheduledExecutorService showTimer = Executors.newSingleThreadScheduledExecutor();
|
||||||
for (ShowCuePoint point : getPoints(name)) {
|
for (ShowCuePoint point : getPoints(name)) {
|
||||||
showTimer.schedule(() -> Bukkit.getScheduler().runTask(ShowControlPlugin.getInstance(), () -> point.getTask().trigger()), point.getTime(), TimeUnit.MILLISECONDS);
|
showTimer.schedule(() -> Bukkit.getScheduler().runTask(ShowControlPlugin.getInstance(), () -> point.getData().trigger()), point.getTime(), TimeUnit.MILLISECONDS);
|
||||||
}
|
}
|
||||||
showTimers.put(name, showTimer);
|
showTimers.put(name, showTimer);
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@ public class Lasers {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (oldLoc.getBlockX() != posLoc.getBlockX()) {
|
if (oldLoc.getBlockX() != posLoc.getBlockX()) {
|
||||||
if (oldLoc.getX() > posLoc.getX()) { //De x gaat omhoog
|
if (oldLoc.getX() > posLoc.getX()) { //Increase of X
|
||||||
oldLoc = oldLoc.add(0.01, 0, 0);
|
oldLoc = oldLoc.add(0.01, 0, 0);
|
||||||
} else {
|
} else {
|
||||||
oldLoc = oldLoc.add(-0.01, 0, 0);
|
oldLoc = oldLoc.add(-0.01, 0, 0);
|
||||||
|
@ -68,7 +68,7 @@ public class Lasers {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oldLoc.getBlockY() != posLoc.getBlockY()) {
|
if (oldLoc.getBlockY() != posLoc.getBlockY()) {
|
||||||
if (oldLoc.getY() > posLoc.getY()) { //De y gaat omhoog
|
if (oldLoc.getY() > posLoc.getY()) { //Increase of Y
|
||||||
oldLoc = oldLoc.add(0, 0.01, 0);
|
oldLoc = oldLoc.add(0, 0.01, 0);
|
||||||
} else {
|
} else {
|
||||||
oldLoc = oldLoc.add(0, -0.01, 0);
|
oldLoc = oldLoc.add(0, -0.01, 0);
|
||||||
|
@ -79,7 +79,7 @@ public class Lasers {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oldLoc.getBlockZ() != posLoc.getBlockZ()) {
|
if (oldLoc.getBlockZ() != posLoc.getBlockZ()) {
|
||||||
if (oldLoc.getZ() > posLoc.getZ()) { //De z gaat omhoog
|
if (oldLoc.getZ() > posLoc.getZ()) { //Increase of Z
|
||||||
oldLoc = oldLoc.add(0, 0, 0.01);
|
oldLoc = oldLoc.add(0, 0, 0.01);
|
||||||
} else {
|
} else {
|
||||||
oldLoc = oldLoc.add(0, 0, -0.01);
|
oldLoc = oldLoc.add(0, 0, -0.01);
|
||||||
|
|
|
@ -57,7 +57,7 @@ public class Spots {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (oldLoc.getBlockX() != posLoc.getBlockX()) {
|
if (oldLoc.getBlockX() != posLoc.getBlockX()) {
|
||||||
if (oldLoc.getX() > posLoc.getX()) { //De x gaat omhoog
|
if (oldLoc.getX() > posLoc.getX()) { //Increase of X
|
||||||
oldLoc = oldLoc.add(0.01, 0, 0);
|
oldLoc = oldLoc.add(0.01, 0, 0);
|
||||||
} else {
|
} else {
|
||||||
oldLoc = oldLoc.add(-0.01, 0, 0);
|
oldLoc = oldLoc.add(-0.01, 0, 0);
|
||||||
|
@ -68,7 +68,7 @@ public class Spots {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oldLoc.getBlockY() != posLoc.getBlockY()) {
|
if (oldLoc.getBlockY() != posLoc.getBlockY()) {
|
||||||
if (oldLoc.getY() > posLoc.getY()) { //De y gaat omhoog
|
if (oldLoc.getY() > posLoc.getY()) { //Increase of Y
|
||||||
oldLoc = oldLoc.add(0, 0.01, 0);
|
oldLoc = oldLoc.add(0, 0.01, 0);
|
||||||
} else {
|
} else {
|
||||||
oldLoc = oldLoc.add(0, -0.01, 0);
|
oldLoc = oldLoc.add(0, -0.01, 0);
|
||||||
|
@ -79,7 +79,7 @@ public class Spots {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oldLoc.getBlockZ() != posLoc.getBlockZ()) {
|
if (oldLoc.getBlockZ() != posLoc.getBlockZ()) {
|
||||||
if (oldLoc.getZ() > posLoc.getZ()) { //De z gaat omhoog
|
if (oldLoc.getZ() > posLoc.getZ()) { //Increase of Z
|
||||||
oldLoc = oldLoc.add(0, 0, 0.01);
|
oldLoc = oldLoc.add(0, 0, 0.01);
|
||||||
} else {
|
} else {
|
||||||
oldLoc = oldLoc.add(0, 0, -0.01);
|
oldLoc = oldLoc.add(0, 0, -0.01);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package tech.sbdevelopment.showcontrol.gui;
|
package tech.sbdevelopment.showcontrol.gui;
|
||||||
|
|
||||||
import fr.minuskube.inv.ClickableItem;
|
import fr.minuskube.inv.ClickableItem;
|
||||||
import tech.sbdevelopment.showcontrol.api.ShowCuePoint;
|
import tech.sbdevelopment.showcontrol.api.points.ShowCuePoint;
|
||||||
import tech.sbdevelopment.showcontrol.data.Shows;
|
import tech.sbdevelopment.showcontrol.data.Shows;
|
||||||
import tech.sbdevelopment.showcontrol.utils.MainUtil;
|
import tech.sbdevelopment.showcontrol.utils.MainUtil;
|
||||||
import tech.sbdevelopment.showcontrol.utils.inventories.PaginationInventory;
|
import tech.sbdevelopment.showcontrol.utils.inventories.PaginationInventory;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package tech.sbdevelopment.showcontrol.utils;
|
package tech.sbdevelopment.showcontrol.utils;
|
||||||
|
|
||||||
import tech.sbdevelopment.showcontrol.api.ShowCuePoint;
|
import tech.sbdevelopment.showcontrol.api.points.ShowCuePoint;
|
||||||
import tech.sbdevelopment.showcontrol.api.triggers.TriggerIdentifier;
|
import tech.sbdevelopment.showcontrol.api.triggers.TriggerIdentifier;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
@ -15,19 +15,19 @@ public class MainUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ItemStack pointToItem(ShowCuePoint point) {
|
public static ItemStack pointToItem(ShowCuePoint point) {
|
||||||
TriggerIdentifier identifier = point.getTask().getClass().getAnnotation(TriggerIdentifier.class);
|
TriggerIdentifier identifier = point.getData().getClass().getAnnotation(TriggerIdentifier.class);
|
||||||
|
|
||||||
List<String> lores = new ArrayList<>();
|
List<String> lores = new ArrayList<>();
|
||||||
lores.add(ChatColor.GREEN + "Type: " + ChatColor.AQUA + capitalize(point.getTask().getTriggerId()));
|
lores.add(ChatColor.GREEN + "Type: " + ChatColor.AQUA + capitalize(point.getData().getTriggerId()));
|
||||||
lores.add(ChatColor.GREEN + "Data:");
|
lores.add(ChatColor.GREEN + "Data:");
|
||||||
for (String str : ChatPaginator.paginate(point.getTask().getDataString(), 20).getLines()) {
|
for (String str : ChatPaginator.paginate(point.getData().getDataString(), 20).getLines()) {
|
||||||
lores.add(ChatColor.AQUA + ChatColor.stripColor(str));
|
lores.add(ChatColor.AQUA + ChatColor.stripColor(str));
|
||||||
}
|
}
|
||||||
lores.add("");
|
lores.add("");
|
||||||
lores.add(ChatColor.RED + ChatColor.BOLD.toString() + "Click to remove!");
|
lores.add(ChatColor.RED + ChatColor.BOLD.toString() + "Click to remove!");
|
||||||
|
|
||||||
return new ItemBuilder(identifier.item())
|
return new ItemBuilder(identifier.item())
|
||||||
.displayname(ChatColor.ITALIC + "TimeCode: " + TimeUtil.makeReadable(point.getTime()))
|
.displayname(ChatColor.LIGHT_PURPLE + ChatColor.ITALIC.toString() + "TimeCode: " + TimeUtil.makeReadable(point.getTime()))
|
||||||
.lore(lores).getItemStack();
|
.lore(lores).getItemStack();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,29 +0,0 @@
|
||||||
package tech.sbdevelopment.showcontrol.utils;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
|
|
||||||
public class VersionUtil {
|
|
||||||
private static final int VERSION = Integer.parseInt(getMajorVersion(Bukkit.getVersion()).substring(2));
|
|
||||||
|
|
||||||
private static String getMajorVersion(String version) {
|
|
||||||
// getVersion()
|
|
||||||
int index = version.lastIndexOf("MC:");
|
|
||||||
if (index != -1) {
|
|
||||||
version = version.substring(index + 4, version.length() - 1);
|
|
||||||
} else if (version.endsWith("SNAPSHOT")) {
|
|
||||||
// getBukkitVersion()
|
|
||||||
index = version.indexOf('-');
|
|
||||||
version = version.substring(0, index);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 1.13.2, 1.14.4, etc...
|
|
||||||
int lastDot = version.lastIndexOf('.');
|
|
||||||
if (version.indexOf('.') != lastDot) version = version.substring(0, lastDot);
|
|
||||||
|
|
||||||
return version;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getVersion() {
|
|
||||||
return VERSION;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,9 +1,9 @@
|
||||||
package tech.sbdevelopment.showcontrol.utils;
|
package tech.sbdevelopment.showcontrol.utils;
|
||||||
|
|
||||||
import tech.sbdevelopment.showcontrol.ShowControlPlugin;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -13,30 +13,32 @@ import java.nio.charset.StandardCharsets;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class YamlFile {
|
public class YamlFile {
|
||||||
|
private final JavaPlugin plugin;
|
||||||
|
private final String name;
|
||||||
private FileConfiguration fileConfiguration;
|
private FileConfiguration fileConfiguration;
|
||||||
private File file;
|
private File file;
|
||||||
private final String name;
|
|
||||||
|
|
||||||
public YamlFile(String name) {
|
public YamlFile(JavaPlugin plugin, String name) {
|
||||||
|
this.plugin = plugin;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
|
||||||
if (!ShowControlPlugin.getInstance().getDataFolder().exists()) {
|
if (!plugin.getDataFolder().exists()) {
|
||||||
if (!ShowControlPlugin.getInstance().getDataFolder().mkdir()) {
|
if (!plugin.getDataFolder().mkdir()) {
|
||||||
Bukkit.getLogger().severe("[ShowAPI] Couldn't generate the pluginfolder!");
|
Bukkit.getLogger().severe("[" + this.plugin.getName() + "] Couldn't generate the pluginfolder!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.file = new File(ShowControlPlugin.getInstance().getDataFolder(), name + ".yml");
|
this.file = new File(plugin.getDataFolder(), name + ".yml");
|
||||||
if (!this.file.exists()) {
|
if (!this.file.exists()) {
|
||||||
try {
|
try {
|
||||||
if (!this.file.createNewFile()) {
|
if (!this.file.createNewFile()) {
|
||||||
Bukkit.getLogger().severe("[ShowAPI] Couldn't generate the " + name + ".yml!");
|
Bukkit.getLogger().severe("[" + this.plugin.getName() + "] Couldn't generate the " + name + ".yml!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Bukkit.getLogger().info("[ShowAPI] Generating the " + name + ".yml!");
|
Bukkit.getLogger().info("[" + this.plugin.getName() + "] Generating the " + name + ".yml!");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Bukkit.getLogger().severe("[ShowAPI] Couldn't generate the " + name + ".yml!");
|
Bukkit.getLogger().severe("[" + this.plugin.getName() + "] Couldn't generate the " + name + ".yml!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,7 +46,7 @@ public class YamlFile {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadDefaults() {
|
public void loadDefaults() {
|
||||||
Reader defConfigStream1 = new InputStreamReader(Objects.requireNonNull(ShowControlPlugin.getInstance().getResource(name + ".yml"), "Resource is null"), StandardCharsets.UTF_8);
|
Reader defConfigStream1 = new InputStreamReader(Objects.requireNonNull(plugin.getResource(name + ".yml"), "Resource is null"), StandardCharsets.UTF_8);
|
||||||
YamlConfiguration defConfig1 = YamlConfiguration.loadConfiguration(defConfigStream1);
|
YamlConfiguration defConfig1 = YamlConfiguration.loadConfiguration(defConfigStream1);
|
||||||
getFile().setDefaults(defConfig1);
|
getFile().setDefaults(defConfig1);
|
||||||
getFile().options().copyDefaults(true);
|
getFile().options().copyDefaults(true);
|
||||||
|
@ -59,7 +61,7 @@ public class YamlFile {
|
||||||
try {
|
try {
|
||||||
this.fileConfiguration.save(this.file);
|
this.fileConfiguration.save(this.file);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Bukkit.getLogger().severe("[ShowAPI] Couldn't save the " + name + ".yml!");
|
Bukkit.getLogger().severe("[" + this.plugin.getName() + "] Couldn't save the " + name + ".yml!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue