From 7091944d5761785f76a34303ee4bde01eb24cbc9 Mon Sep 17 00:00:00 2001 From: Shyanne Date: Thu, 5 Oct 2023 23:25:54 -0400 Subject: [PATCH] Update IslandManager.java updated the island manager to automagically skip the createGUI for the user if there is only 1 schematic to pick from --- .../managers/IslandManager.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/iridium/iridiumskyblock/managers/IslandManager.java b/src/main/java/com/iridium/iridiumskyblock/managers/IslandManager.java index 381d16b3f..db8d808cf 100644 --- a/src/main/java/com/iridium/iridiumskyblock/managers/IslandManager.java +++ b/src/main/java/com/iridium/iridiumskyblock/managers/IslandManager.java @@ -137,13 +137,24 @@ public List getTeams() { @Override public CompletableFuture createTeam(@NotNull Player owner, String name) { CompletableFuture schematicNameCompletableFuture = new CompletableFuture<>(); - owner.openInventory(new CreateGUI(owner.getOpenInventory().getTopInventory(), schematicNameCompletableFuture).getInventory()); + String schematic = null; + + if(IridiumSkyblock.getInstance().getSchematics().schematics.entrySet().size() > 1) { + owner.openInventory(new CreateGUI(owner.getOpenInventory().getTopInventory(), schematicNameCompletableFuture).getInventory()); + schematic = schematicNameCompletableFuture.join(); + } else { + for (Map.Entry entry : IridiumSkyblock.getInstance().getSchematics().schematics.entrySet()) { + schematic = (entry.getKey()); + } + } + + String finalSchematic = schematic; return CompletableFuture.supplyAsync(() -> { - String schematic = schematicNameCompletableFuture.join(); - if (schematic == null) return null; + + if (finalSchematic == null) return null; User user = IridiumSkyblock.getInstance().getUserManager().getUser(owner); - Schematics.SchematicConfig schematicConfig = IridiumSkyblock.getInstance().getSchematics().schematics.get(schematic); + Schematics.SchematicConfig schematicConfig = IridiumSkyblock.getInstance().getSchematics().schematics.get(finalSchematic); IslandCreateEvent islandCreateEvent = getIslandCreateEvent(user, name, schematicConfig).join(); if (islandCreateEvent.isCancelled()) return null;