Allow HH:mm on /ban and /mute #132
@ -37,8 +37,8 @@ public class BanCommand extends BasicCommand {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if(args.length < 4){
|
||||
BungeeCore.send(sender, BungeeCore.CHAT_PREFIX + "/ban [Spieler] [dd.mm.yyyy oder perma] {hh:mm} [Grund]");
|
||||
if(args.length < 3){
|
||||
BungeeCore.send(sender, BungeeCore.CHAT_PREFIX + "/ban [Spieler] [dd.mm.yyyy oder dd.mm.yyyy_hh:mm oder perma] [Grund]");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -46,13 +46,12 @@ public class BanCommand extends BasicCommand {
|
||||
if(target == null)
|
||||
return;
|
||||
|
||||
Timestamp banTime = parseTime(sender, String.join(args[1], args[2]));
|
||||
Timestamp banTime = parseTime(sender, args[1]);
|
||||
if(banTime == null)
|
||||
return;
|
||||
|
||||
StringBuilder banReason = new StringBuilder();
|
||||
int start = hasTimestamp(args[2])?2:3;
|
||||
for (int i = start; i < args.length; i++){
|
||||
for (int i = 2; i < args.length; i++){
|
||||
banReason.append(args[i]).append(" ");
|
||||
}
|
||||
String msg = banReason.toString();
|
||||
@ -64,14 +63,14 @@ public class BanCommand extends BasicCommand {
|
||||
if(arg.equalsIgnoreCase("perma")) {
|
||||
return Timestamp.from(Instant.ofEpochSecond(946674800));
|
||||
}else{
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy HH:mm");
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy_HH:mm");
|
||||
try{
|
||||
Date parsedDate = dateFormat.parse(arg);
|
||||
return new java.sql.Timestamp(parsedDate.getTime());
|
||||
}catch(ParseException e){
|
||||
dateFormat = new SimpleDateFormat("dd.MM.yyyy");
|
||||
try{
|
||||
Date parsedDate = dateFormat.parse(arg.split(" ")[0]);
|
||||
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.");
|
||||
@ -80,14 +79,4 @@ public class BanCommand extends BasicCommand {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean hasTimestamp(String time) {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm");
|
||||
try{
|
||||
dateFormat.parse(time);
|
||||
return true;
|
||||
}catch(ParseException exception){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -33,8 +33,8 @@ public class MuteCommand extends BasicCommand {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if(args.length < 4){
|
||||
BungeeCore.send(sender, BungeeCore.CHAT_PREFIX + "/mute [Spieler] [dd.mm.yyyy oder perma] {hh:mm} [Grund]");
|
||||
if(args.length < 3){
|
||||
BungeeCore.send(sender, BungeeCore.CHAT_PREFIX + "/mute [Spieler] [dd.mm.yyyy oder dd.mm.yyyy_hh:mm oder perma] [Grund]");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -42,13 +42,12 @@ public class MuteCommand extends BasicCommand {
|
||||
if(target == null)
|
||||
return;
|
||||
|
||||
Timestamp muteTime = BanCommand.parseTime(sender, String.join(args[1], args[2]));
|
||||
Timestamp muteTime = BanCommand.parseTime(sender, args[1]);
|
||||
if(muteTime == null)
|
||||
return;
|
||||
|
||||
StringBuilder muteReason = new StringBuilder();
|
||||
int start = BanCommand.hasTimestamp(args[2])?2:3;
|
||||
for (int i = start; i < args.length; i++){
|
||||
for (int i = 2; i < args.length; i++){
|
||||
muteReason.append(args[i]).append(" ");
|
||||
}
|
||||
String msg = muteReason.toString();
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren
Es ist schlecht, wenn das immer mit angegeben werden muss, denn dann macht das den Befehlsaufruf immer komplexer, und er ist den meisten bereits jetzt zu komplex.
Die alte Variante ist immer noch zur verfügung, wird halt nur nicht angezeigt. Siehe Zeile 73
Öh, nein? wie die genau markierte Codezeile zeigt :)
Jetzt aber.