13
0

Fix AI
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
Chaoscaot 2023-04-01 14:19:17 +02:00
Ursprung ccdfb40d71
Commit c664e08fa6

Datei anzeigen

@ -26,9 +26,9 @@ import de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommand;
import de.steamwar.sql.SchematicData; import de.steamwar.sql.SchematicData;
import de.steamwar.sql.SchematicNode; import de.steamwar.sql.SchematicNode;
import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.SteamwarUser;
import lombok.SneakyThrows;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
@ -40,17 +40,24 @@ public class AprilPart extends SWCommand {
super(null); super(null);
} }
@SneakyThrows
@Register("prompt") @Register("prompt")
public void prompt(Player player, String... prompt) { public void prompt(Player player, String... prompt) {
SteamwarUser user = SteamwarUser.get(player.getName()); SteamwarUser user = SteamwarUser.get(player.getName());
String message = String.join(" ", prompt); String message = String.join(" ", prompt);
SchematicSystem.MESSAGE.send("AI_START", player, message); SchematicSystem.MESSAGE.send("AI_START", player, message);
try {
Thread.sleep(random.nextInt(3000)); Thread.sleep(random.nextInt(3000));
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
int randomInt = random.nextInt(100); int randomInt = random.nextInt(100);
if (randomInt < 33) { if (randomInt < 33) {
List<SchematicNode> nodes = SchematicNode.getAll(user); List<SchematicNode> nodes = SchematicNode.getAll(user);
try {
new SchematicData(nodes.get(random.nextInt(nodes.size()))).loadToPlayer(player); new SchematicData(nodes.get(random.nextInt(nodes.size()))).loadToPlayer(player);
} catch (IOException e) {
throw new RuntimeException(e);
}
SchematicSystem.MESSAGE.send("AI_FINISH", player); SchematicSystem.MESSAGE.send("AI_FINISH", player);
} else if (randomInt < 66) { } else if (randomInt < 66) {
SchematicSystem.MESSAGE.send("AI_NO_STEAMIES", player); SchematicSystem.MESSAGE.send("AI_NO_STEAMIES", player);