From a959b20370251bfd370c4b07e737cf3929616e91 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Tue, 20 Oct 2020 22:10:57 +0200 Subject: [PATCH] Fixing... --- src/de/steamwar/bungeecore/commands/BanCommand.java | 13 ++++++++++++- .../steamwar/bungeecore/commands/MuteCommand.java | 3 ++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/BanCommand.java b/src/de/steamwar/bungeecore/commands/BanCommand.java index 0368256..9ab6cad 100644 --- a/src/de/steamwar/bungeecore/commands/BanCommand.java +++ b/src/de/steamwar/bungeecore/commands/BanCommand.java @@ -51,7 +51,8 @@ public class BanCommand extends BasicCommand { return; StringBuilder banReason = new StringBuilder(); - for (int i = 3; i < args.length; i++){ + int start = hasTimestamp(args[2])?2:3; + for (int i = start; i < args.length; i++){ banReason.append(args[i]).append(" "); } String msg = banReason.toString(); @@ -79,4 +80,14 @@ 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; + } + } } diff --git a/src/de/steamwar/bungeecore/commands/MuteCommand.java b/src/de/steamwar/bungeecore/commands/MuteCommand.java index 57e6aff..9cc0ca9 100644 --- a/src/de/steamwar/bungeecore/commands/MuteCommand.java +++ b/src/de/steamwar/bungeecore/commands/MuteCommand.java @@ -47,7 +47,8 @@ public class MuteCommand extends BasicCommand { return; StringBuilder muteReason = new StringBuilder(); - for (int i = 3; i < args.length; i++){ + int start = BanCommand.hasTimestamp(args[2])?2:3; + for (int i = start; i < args.length; i++){ muteReason.append(args[i]).append(" "); } String msg = muteReason.toString();