Skip to content

Commit

Permalink
Update IslandManager.java
Browse files Browse the repository at this point in the history
updated the island manager to automagically skip the createGUI for the user if there is only 1 schematic to pick from
  • Loading branch information
sh0inx committed Oct 6, 2023
1 parent 3c5e593 commit 7091944
Showing 1 changed file with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,24 @@ public List<Island> getTeams() {
@Override
public CompletableFuture<Island> createTeam(@NotNull Player owner, String name) {
CompletableFuture<String> 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<String, Schematics.SchematicConfig> 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;
Expand Down

0 comments on commit 7091944

Please sign in to comment.