Bumped GuardianBeam to 2.3.5 (fixes Spot), fixed time combinations
This commit is contained in:
parent
a4dbdab581
commit
47f496133c
3 changed files with 30 additions and 37 deletions
10
pom.xml
10
pom.xml
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
<groupId>tech.sbdevelopment</groupId>
|
<groupId>tech.sbdevelopment</groupId>
|
||||||
<artifactId>ShowControl</artifactId>
|
<artifactId>ShowControl</artifactId>
|
||||||
<version>1.6</version>
|
<version>1.6.1</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<name>ShowControl</name>
|
<name>ShowControl</name>
|
||||||
<url>https://sbdevelopment.tech</url>
|
<url>https://sbdevelopment.tech</url>
|
||||||
|
@ -157,7 +157,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot-api</artifactId>
|
<artifactId>spigot-api</artifactId>
|
||||||
<version>1.20.1-R0.1-SNAPSHOT</version>
|
<version>1.20.2-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -177,9 +177,9 @@
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.github.skytasul</groupId>
|
<groupId>com.github.SkytAsul</groupId>
|
||||||
<artifactId>guardianbeam</artifactId>
|
<artifactId>GuardianBeam</artifactId>
|
||||||
<version>2.3.4</version>
|
<version>97b0078aba</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -61,7 +61,7 @@ public class ShowCMD extends BaseCommand {
|
||||||
|
|
||||||
Long timeMilli;
|
Long timeMilli;
|
||||||
try {
|
try {
|
||||||
timeMilli = TimeUtil.toMilis(time);
|
timeMilli = TimeUtil.toMillis(time);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
sender.sendMessage(ChatColor.RED + "Provide a valid time, for example 5s (5 seconds) or 10m (10 minutes).");
|
sender.sendMessage(ChatColor.RED + "Provide a valid time, for example 5s (5 seconds) or 10m (10 minutes).");
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -3,54 +3,47 @@ package tech.sbdevelopment.showcontrol.utils;
|
||||||
import java.time.LocalTime;
|
import java.time.LocalTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
/*
|
|
||||||
* Source from:
|
|
||||||
* https://github.com/Mindgamesnl/OpenAudioMc/blob/master/plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/show/util/TimeParser.java
|
|
||||||
*/
|
|
||||||
public class TimeUtil {
|
public class TimeUtil {
|
||||||
|
public static Long toMillis(String input) {
|
||||||
public static Long toMilis(String input) {
|
|
||||||
long time = 0L;
|
long time = 0L;
|
||||||
|
|
||||||
// ITS A TIMECODE
|
|
||||||
if (input.contains(":")) {
|
if (input.contains(":")) {
|
||||||
return LocalTime.parse(input, DateTimeFormatter.ofPattern("HH:mm:ss")).toSecondOfDay() * 1000L;
|
return LocalTime.parse(input, DateTimeFormatter.ofPattern("HH:mm:ss")).toSecondOfDay() * 1000L;
|
||||||
}
|
}
|
||||||
|
|
||||||
input = input.toLowerCase() + "-";
|
input = input.toLowerCase() + "-";
|
||||||
|
|
||||||
String[] milisSplit = input.split("ms");
|
Pattern pattern = Pattern.compile("(\\d+)([a-z]+)");
|
||||||
if (isValid(milisSplit)) {
|
Matcher matcher = pattern.matcher(input);
|
||||||
time += Long.parseLong(milisSplit[0]);
|
|
||||||
return time;
|
|
||||||
}
|
|
||||||
|
|
||||||
String[] secondsSplit = input.split("s");
|
while (matcher.find()) {
|
||||||
if (isValid(secondsSplit)) {
|
String value = matcher.group(1);
|
||||||
time += Math.round(Double.parseDouble(secondsSplit[0]) * 1000);
|
String unit = matcher.group(2);
|
||||||
return time;
|
|
||||||
}
|
|
||||||
|
|
||||||
String[] minutesSplit = input.split("m");
|
switch (unit) {
|
||||||
if (isValid(minutesSplit)) {
|
case "ms":
|
||||||
time += Math.round(Double.parseDouble(minutesSplit[0]) * 60000);
|
time += Long.parseLong(value);
|
||||||
return time;
|
break;
|
||||||
|
case "s":
|
||||||
|
time += Math.round(Double.parseDouble(value) * 1000);
|
||||||
|
break;
|
||||||
|
case "m":
|
||||||
|
time += Math.round(Double.parseDouble(value) * 60000);
|
||||||
|
break;
|
||||||
|
case "t":
|
||||||
|
time += Integer.parseInt(value) * 50L;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException("Unknown time unit: " + unit);
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] tickSplit = input.split("t");
|
|
||||||
if (isValid(tickSplit)) {
|
|
||||||
time += Integer.parseInt(tickSplit[0]) * 50L;
|
|
||||||
return time;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return time;
|
return time;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isValid(String[] array) {
|
|
||||||
return array.length > 1 && !array[0].isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String makeReadable(Long time) {
|
public static String makeReadable(Long time) {
|
||||||
return String.format("%02d:%02d:%02d", TimeUnit.MILLISECONDS.toHours(time),
|
return String.format("%02d:%02d:%02d", TimeUnit.MILLISECONDS.toHours(time),
|
||||||
TimeUnit.MILLISECONDS.toMinutes(time) - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(time)),
|
TimeUnit.MILLISECONDS.toMinutes(time) - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(time)),
|
||||||
|
|
Loading…
Add table
Reference in a new issue