From c9434b916e5a40226c26abe3c0deabbf962ebe77 Mon Sep 17 00:00:00 2001 From: Joey Hines Date: Fri, 2 Oct 2020 17:24:09 -0500 Subject: [PATCH] Updated Plugin-Api --- pom.xml | 6 +- .../qol/commands/ShadowMuteCommand.java | 14 ++- .../listeners/CommandPreprocessListener.java | 4 +- .../xyz/etztech/qol/other/ShadowMuteTime.java | 112 ------------------ .../xyz/etztech/qol/other/TPSRunnable.java | 4 +- 5 files changed, 15 insertions(+), 125 deletions(-) delete mode 100644 src/main/java/xyz/etztech/qol/other/ShadowMuteTime.java diff --git a/pom.xml b/pom.xml index c2b5d99..8d0d2af 100644 --- a/pom.xml +++ b/pom.xml @@ -36,13 +36,13 @@ xyz.etztech - EtzCore - 1.0.5 + plugin-api + 1.0.8 net.ess3 EssentialsX - 2.17.2 + 2.18.1 us.dynmap diff --git a/src/main/java/xyz/etztech/qol/commands/ShadowMuteCommand.java b/src/main/java/xyz/etztech/qol/commands/ShadowMuteCommand.java index b201e40..0be8bda 100644 --- a/src/main/java/xyz/etztech/qol/commands/ShadowMuteCommand.java +++ b/src/main/java/xyz/etztech/qol/commands/ShadowMuteCommand.java @@ -9,7 +9,9 @@ import org.bukkit.entity.Player; import xyz.etztech.qol.EtzTechUtil; import xyz.etztech.qol.Lang; import xyz.etztech.qol.QoL; -import xyz.etztech.qol.other.ShadowMuteTime; +import xyz.etztech.core.command.TickDuration; + +import java.time.Duration; public class ShadowMuteCommand implements CommandExecutor { @@ -43,16 +45,16 @@ public class ShadowMuteCommand implements CommandExecutor { final Player player = argPlayer; - ShadowMuteTime smt; + TickDuration duration; try { - smt = ShadowMuteTime.parse(args[1]); + duration = TickDuration.parse(args[1]); } catch (Exception ex) { - smt = new ShadowMuteTime(); + duration = new TickDuration(Duration.ofMinutes(5)); commandSender.sendMessage(ChatColor.RED + ex.getMessage()); } EtzTechUtil.sms(commandSender, ChatColor.GREEN + "Shadow Muting " + ChatColor.YELLOW + - player.getName() + ChatColor.GREEN + " for " + ChatColor.YELLOW + smt.toString()); + player.getName() + ChatColor.GREEN + " for " + ChatColor.YELLOW + duration.toString()); QoL.addSM(player); Bukkit.getScheduler().runTaskLater(plugin, new Runnable() { @@ -61,7 +63,7 @@ public class ShadowMuteCommand implements CommandExecutor { Bukkit.getConsoleSender().sendMessage(ChatColor.GREEN + "Removing Shadow Mute for " + ChatColor.YELLOW + player.getName()); QoL.removeSM(player); } - }, smt.toTicks()); + }, duration.toTicks()); return true; diff --git a/src/main/java/xyz/etztech/qol/listeners/CommandPreprocessListener.java b/src/main/java/xyz/etztech/qol/listeners/CommandPreprocessListener.java index a5bbeb7..9e6db8c 100644 --- a/src/main/java/xyz/etztech/qol/listeners/CommandPreprocessListener.java +++ b/src/main/java/xyz/etztech/qol/listeners/CommandPreprocessListener.java @@ -11,7 +11,7 @@ import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.server.ServerCommandEvent; import org.dynmap.DynmapAPI; -import xyz.etztech.core.web.CoreWeb; +import xyz.etztech.core.web.Http; import xyz.etztech.qol.QoL; import xyz.etztech.qol.other.LinkCommand; @@ -163,7 +163,7 @@ public class CommandPreprocessListener implements Listener { Map post = new HashMap<>(); post.put("username", username); post.put("content", content); - CoreWeb.asyncPost(plugin, webhook, post); + Http.asyncPost(plugin, webhook, post); } } diff --git a/src/main/java/xyz/etztech/qol/other/ShadowMuteTime.java b/src/main/java/xyz/etztech/qol/other/ShadowMuteTime.java deleted file mode 100644 index e31789c..0000000 --- a/src/main/java/xyz/etztech/qol/other/ShadowMuteTime.java +++ /dev/null @@ -1,112 +0,0 @@ -package xyz.etztech.qol.other; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -public class ShadowMuteTime { - - private int hours; - private int minutes; - private int seconds; - - public ShadowMuteTime() { - hours = 1; - minutes = 0; - seconds = 0; - } - - public int getHours() { - return hours; - } - - public void setHours(int hours) { - this.hours = hours; - } - - public void addHours(int hours) { - this.hours += hours; - } - - public int getMinutes() { - return minutes; - } - - public void setMinutes(int minutes) { - this.minutes = minutes; - } - - public void addMinutes(int minutes) { - this.minutes += minutes; - } - - public int getSeconds() { - return seconds; - } - - public void setSeconds(int seconds) { - this.seconds = seconds; - } - - public void addSeconds(int seconds) { - this.seconds += seconds; - } - - public String toString() { - return getHours() + " hours, " + getMinutes() + " minutes, and " + getSeconds() + " seconds"; - } - - public long toTicks() { - int seconds = getSeconds(); - seconds += getMinutes()*60; - seconds += getHours()*60*60; - return seconds*20; - } - - public static ShadowMuteTime parse(String time) throws Exception { - ShadowMuteTime smt = new ShadowMuteTime(); - smt.setHours(0); // Defaults to 1 hour - String timePattern = "(?:(?\\d+)h)?(?:(?\\d+)m)?(?:(?\\d+)s)?"; - Pattern pattern = Pattern.compile(timePattern); - Matcher match = pattern.matcher(time); - - if (!match.matches()) { - throw new Exception("Time format does not match, defaulting to 1 hour."); - } - - String hourString = match.group("hours"); - if (hourString != null) { - int hours = Integer.parseInt(hourString); - smt.addHours(hours); - } - - String minuteString = match.group("minutes"); - if (minuteString != null) { - int minutes = Integer.parseInt(minuteString); - if (minutes >= 60) { - int toHours = minutes / 60; - minutes %= 60; - smt.addHours(toHours); - } - smt.addMinutes(minutes); - } - - String secondString = match.group("seconds"); - if (secondString != null) { - int seconds = Integer.parseInt(secondString); - if (seconds >= 60) { - int toMinutes = seconds / 60; - seconds %= 60; - int minutes = smt.getMinutes() + toMinutes; - if (minutes >= 60) { - int toHours = minutes / 60; - minutes %= 60; - smt.addHours(toHours); - } - smt.addMinutes(minutes); - } - smt.addSeconds(seconds); - } - - return smt; - } -} diff --git a/src/main/java/xyz/etztech/qol/other/TPSRunnable.java b/src/main/java/xyz/etztech/qol/other/TPSRunnable.java index e25e3fa..57cf0a4 100644 --- a/src/main/java/xyz/etztech/qol/other/TPSRunnable.java +++ b/src/main/java/xyz/etztech/qol/other/TPSRunnable.java @@ -2,7 +2,7 @@ package xyz.etztech.qol.other; import net.ess3.api.IEssentials; import org.apache.commons.lang.StringUtils; -import xyz.etztech.core.web.CoreWeb; +import xyz.etztech.core.web.Http; import xyz.etztech.qol.QoL; import java.util.HashMap; @@ -30,7 +30,7 @@ public class TPSRunnable implements Runnable { Map data = new HashMap<>(); data.put("username", "TPS Alert"); data.put("content", message); - CoreWeb.asyncPost(plugin, webhook, data); + Http.asyncPost(plugin, webhook, data); } } }