From c664e08fa6d493439744a650bc31c4f0d0fd94de Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sat, 1 Apr 2023 14:19:17 +0200 Subject: [PATCH] Fix AI --- .../schematiccommand/parts/AprilPart.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/AprilPart.java b/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/AprilPart.java index 04d72f9..e0dbb80 100644 --- a/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/AprilPart.java +++ b/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/AprilPart.java @@ -26,9 +26,9 @@ import de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommand; import de.steamwar.sql.SchematicData; import de.steamwar.sql.SchematicNode; import de.steamwar.sql.SteamwarUser; -import lombok.SneakyThrows; import org.bukkit.entity.Player; +import java.io.IOException; import java.util.List; import java.util.Random; @@ -40,17 +40,24 @@ public class AprilPart extends SWCommand { super(null); } - @SneakyThrows @Register("prompt") public void prompt(Player player, String... prompt) { SteamwarUser user = SteamwarUser.get(player.getName()); String message = String.join(" ", prompt); SchematicSystem.MESSAGE.send("AI_START", player, message); - Thread.sleep(random.nextInt(3000)); + try { + Thread.sleep(random.nextInt(3000)); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } int randomInt = random.nextInt(100); if (randomInt < 33) { List nodes = SchematicNode.getAll(user); - new SchematicData(nodes.get(random.nextInt(nodes.size()))).loadToPlayer(player); + try { + new SchematicData(nodes.get(random.nextInt(nodes.size()))).loadToPlayer(player); + } catch (IOException e) { + throw new RuntimeException(e); + } SchematicSystem.MESSAGE.send("AI_FINISH", player); } else if (randomInt < 66) { SchematicSystem.MESSAGE.send("AI_NO_STEAMIES", player);