forked from Minecraft/QoL
Updated Plugin-Api
parent
2bc9733955
commit
c9434b916e
6
pom.xml
6
pom.xml
|
@ -36,13 +36,13 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>xyz.etztech</groupId>
|
<groupId>xyz.etztech</groupId>
|
||||||
<artifactId>EtzCore</artifactId>
|
<artifactId>plugin-api</artifactId>
|
||||||
<version>1.0.5</version>
|
<version>1.0.8</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.ess3</groupId>
|
<groupId>net.ess3</groupId>
|
||||||
<artifactId>EssentialsX</artifactId>
|
<artifactId>EssentialsX</artifactId>
|
||||||
<version>2.17.2</version>
|
<version>2.18.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>us.dynmap</groupId>
|
<groupId>us.dynmap</groupId>
|
||||||
|
|
|
@ -9,7 +9,9 @@ import org.bukkit.entity.Player;
|
||||||
import xyz.etztech.qol.EtzTechUtil;
|
import xyz.etztech.qol.EtzTechUtil;
|
||||||
import xyz.etztech.qol.Lang;
|
import xyz.etztech.qol.Lang;
|
||||||
import xyz.etztech.qol.QoL;
|
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 {
|
public class ShadowMuteCommand implements CommandExecutor {
|
||||||
|
|
||||||
|
@ -43,16 +45,16 @@ public class ShadowMuteCommand implements CommandExecutor {
|
||||||
|
|
||||||
final Player player = argPlayer;
|
final Player player = argPlayer;
|
||||||
|
|
||||||
ShadowMuteTime smt;
|
TickDuration duration;
|
||||||
try {
|
try {
|
||||||
smt = ShadowMuteTime.parse(args[1]);
|
duration = TickDuration.parse(args[1]);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
smt = new ShadowMuteTime();
|
duration = new TickDuration(Duration.ofMinutes(5));
|
||||||
commandSender.sendMessage(ChatColor.RED + ex.getMessage());
|
commandSender.sendMessage(ChatColor.RED + ex.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
EtzTechUtil.sms(commandSender, ChatColor.GREEN + "Shadow Muting " + ChatColor.YELLOW +
|
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);
|
QoL.addSM(player);
|
||||||
|
|
||||||
Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
|
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());
|
Bukkit.getConsoleSender().sendMessage(ChatColor.GREEN + "Removing Shadow Mute for " + ChatColor.YELLOW + player.getName());
|
||||||
QoL.removeSM(player);
|
QoL.removeSM(player);
|
||||||
}
|
}
|
||||||
}, smt.toTicks());
|
}, duration.toTicks());
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -11,7 +11,7 @@ import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
import org.bukkit.event.server.ServerCommandEvent;
|
import org.bukkit.event.server.ServerCommandEvent;
|
||||||
import org.dynmap.DynmapAPI;
|
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.QoL;
|
||||||
import xyz.etztech.qol.other.LinkCommand;
|
import xyz.etztech.qol.other.LinkCommand;
|
||||||
|
|
||||||
|
@ -163,7 +163,7 @@ public class CommandPreprocessListener implements Listener {
|
||||||
Map<String, String> post = new HashMap<>();
|
Map<String, String> post = new HashMap<>();
|
||||||
post.put("username", username);
|
post.put("username", username);
|
||||||
post.put("content", content);
|
post.put("content", content);
|
||||||
CoreWeb.asyncPost(plugin, webhook, post);
|
Http.asyncPost(plugin, webhook, post);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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 = "(?:(?<hours>\\d+)h)?(?:(?<minutes>\\d+)m)?(?:(?<seconds>\\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;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -2,7 +2,7 @@ package xyz.etztech.qol.other;
|
||||||
|
|
||||||
import net.ess3.api.IEssentials;
|
import net.ess3.api.IEssentials;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import xyz.etztech.core.web.CoreWeb;
|
import xyz.etztech.core.web.Http;
|
||||||
import xyz.etztech.qol.QoL;
|
import xyz.etztech.qol.QoL;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -30,7 +30,7 @@ public class TPSRunnable implements Runnable {
|
||||||
Map<String, String> data = new HashMap<>();
|
Map<String, String> data = new HashMap<>();
|
||||||
data.put("username", "TPS Alert");
|
data.put("username", "TPS Alert");
|
||||||
data.put("content", message);
|
data.put("content", message);
|
||||||
CoreWeb.asyncPost(plugin, webhook, data);
|
Http.asyncPost(plugin, webhook, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue