Archiviert
1
0

Allow HH:mm on /ban and /mute

Dieser Commit ist enthalten in:
Chaoscaot 2020-10-18 00:50:18 +02:00
Ursprung 131134b8b8
Commit 38f90d025a
3 geänderte Dateien mit 18 neuen und 12 gelöschten Zeilen

Datei anzeigen

@ -36,7 +36,7 @@
</configuration> </configuration>
</plugin> </plugin>
</plugins> </plugins>
<finalName>bungeecore</finalName> <finalName>BungeeCore</finalName>
</build> </build>
<dependencies> <dependencies>

Datei anzeigen

@ -37,8 +37,8 @@ public class BanCommand extends BasicCommand {
@Override @Override
public void execute(CommandSender sender, String[] args) { public void execute(CommandSender sender, String[] args) {
if(args.length < 3){ if(args.length < 4){
BungeeCore.send(sender, BungeeCore.CHAT_PREFIX + "/ban [Spieler] [dd.mm.yyyy oder perma] [Grund]"); BungeeCore.send(sender, BungeeCore.CHAT_PREFIX + "/ban [Spieler] [dd.mm.yyyy oder perma] [hh:mm] [Grund]");
return; return;
} }
@ -46,12 +46,12 @@ public class BanCommand extends BasicCommand {
if(target == null) if(target == null)
return; return;
Timestamp banTime = parseTime(sender, args[1]); Timestamp banTime = parseTime(sender, String.join(args[1], args[2]));
if(banTime == null) if(banTime == null)
return; return;
StringBuilder banReason = new StringBuilder(); StringBuilder banReason = new StringBuilder();
for (int i = 2; i < args.length; i++){ for (int i = 3; i < args.length; i++){
banReason.append(args[i]).append(" "); banReason.append(args[i]).append(" ");
} }
String msg = banReason.toString(); String msg = banReason.toString();
@ -63,13 +63,19 @@ public class BanCommand extends BasicCommand {
if(arg.equalsIgnoreCase("perma")) { if(arg.equalsIgnoreCase("perma")) {
return Timestamp.from(Instant.ofEpochSecond(946674800)); return Timestamp.from(Instant.ofEpochSecond(946674800));
}else{ }else{
SimpleDateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy"); SimpleDateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy HH:mm");
try{ try{
Date parsedDate = dateFormat.parse(arg); Date parsedDate = dateFormat.parse(arg);
return new java.sql.Timestamp(parsedDate.getTime()); return new java.sql.Timestamp(parsedDate.getTime());
}catch(ParseException e){ }catch(ParseException e){
BungeeCore.send(sender, BungeeCore.CHAT_PREFIX + "§cUngültige Zeitangabe."); dateFormat = new SimpleDateFormat("dd.MM.yyyy");
return null; try{
Date parsedDate = dateFormat.parse(arg.split(" ")[0]);
return new java.sql.Timestamp(parsedDate.getTime());
}catch(ParseException exception){
BungeeCore.send(sender, BungeeCore.CHAT_PREFIX + "§cUngültige Zeitangabe.");
return null;
}
} }
} }
} }

Datei anzeigen

@ -33,8 +33,8 @@ public class MuteCommand extends BasicCommand {
@Override @Override
public void execute(CommandSender sender, String[] args) { public void execute(CommandSender sender, String[] args) {
if(args.length < 3){ if(args.length < 4){
BungeeCore.send(sender, BungeeCore.CHAT_PREFIX + "/mute [Spieler] [dd.mm.yyyy oder perma] [Grund]"); BungeeCore.send(sender, BungeeCore.CHAT_PREFIX + "/mute [Spieler] [dd.mm.yyyy oder perma] [hh:mm] [Grund]");
return; return;
} }
@ -42,12 +42,12 @@ public class MuteCommand extends BasicCommand {
if(target == null) if(target == null)
return; return;
Timestamp muteTime = BanCommand.parseTime(sender, args[1]); Timestamp muteTime = BanCommand.parseTime(sender, String.join(args[1], args[2]));
if(muteTime == null) if(muteTime == null)
return; return;
StringBuilder muteReason = new StringBuilder(); StringBuilder muteReason = new StringBuilder();
for (int i = 2; i < args.length; i++){ for (int i = 3; i < args.length; i++){
muteReason.append(args[i]).append(" "); muteReason.append(args[i]).append(" ");
} }
String msg = muteReason.toString(); String msg = muteReason.toString();