From 15570cab7c6e98987a55edc3d3829e1a0c8529bf Mon Sep 17 00:00:00 2001 From: jojo Date: Wed, 16 Dec 2020 09:08:27 +0100 Subject: [PATCH] Make Sleep 'CaSeInDePeNdEnCe' Make Sleep Command like Bukkit Command (String.split(" ")) --- .../bausystem/world/ScriptListener.java | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/ScriptListener.java b/BauSystem_Main/src/de/steamwar/bausystem/world/ScriptListener.java index f490d35..552e068 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/ScriptListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/ScriptListener.java @@ -67,16 +67,20 @@ public class ScriptListener implements Listener { while (index < commands.size()) { String command = commands.get(index++); - if (command.startsWith("sleep")) { - String sleepTimeString = command.substring(5).trim(); - int sleepTime = 1; - try { - sleepTime = Integer.parseInt(sleepTimeString); - } catch (NumberFormatException e) { - // Ignored + String[] strings = command.split(" "); + if (strings.length > 0) { + if (strings[0].equalsIgnoreCase("sleep")) { + int sleepTime = 1; + if (strings.length > 1) { + try { + sleepTime = Integer.parseInt(strings[1]); + } catch (NumberFormatException e) { + // Ignored + } + } + Bukkit.getScheduler().runTaskLater(BauSystem.getPlugin(), this::resume, sleepTime); + break; } - Bukkit.getScheduler().runTaskLater(BauSystem.getPlugin(), this::resume, sleepTime); - break; } PlayerCommandPreprocessEvent preprocessEvent = new PlayerCommandPreprocessEvent(player, "/" + command);