diff --git a/src/main/java/com/iridium/iridiumskyblock/commands/RegenCommand.java b/src/main/java/com/iridium/iridiumskyblock/commands/RegenCommand.java index efdd82db8..d889bd84b 100644 --- a/src/main/java/com/iridium/iridiumskyblock/commands/RegenCommand.java +++ b/src/main/java/com/iridium/iridiumskyblock/commands/RegenCommand.java @@ -23,7 +23,7 @@ public RegenCommand() { @Override public boolean execute(User user, Island island, String[] args, IridiumTeams iridiumTeams) { Player player = user.getPlayer(); - if (args.length == 0) { + if (args.length == 0 && IridiumSkyblock.getInstance().getSchematics().schematics.entrySet().size() > 1) { if (!IridiumSkyblock.getInstance().getIslandManager().getTeamPermission(island, IridiumSkyblock.getInstance().getUserManager().getUser(player), "regen")) { player.sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().cannotRegenIsland .replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix) @@ -36,7 +36,7 @@ public boolean execute(User user, Island island, String[] args, IridiumTeams schematic = IridiumSkyblock.getInstance().getSchematics().schematics.keySet().stream() - .filter(config -> config.equalsIgnoreCase(args[0])) + .filter(config -> IridiumSkyblock.getInstance().getSchematics().schematics.entrySet().size() == 1 || config.equalsIgnoreCase(args[0])) .findFirst(); if (!schematic.isPresent()) { player.sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().unknownSchematic diff --git a/src/main/java/com/iridium/iridiumskyblock/managers/IslandManager.java b/src/main/java/com/iridium/iridiumskyblock/managers/IslandManager.java index 381d16b3f..15b4e7a32 100644 --- a/src/main/java/com/iridium/iridiumskyblock/managers/IslandManager.java +++ b/src/main/java/com/iridium/iridiumskyblock/managers/IslandManager.java @@ -134,12 +134,23 @@ public List getTeams() { return IridiumSkyblock.getInstance().getDatabaseManager().getIslandTableManager().getEntries(); } + private CompletableFuture getSchematic(Player player) { + CompletableFuture schematicNameCompletableFuture = new CompletableFuture<>(); + if (IridiumSkyblock.getInstance().getSchematics().schematics.entrySet().size() == 1) { + for (Map.Entry entry : IridiumSkyblock.getInstance().getSchematics().schematics.entrySet()) { + schematicNameCompletableFuture.complete(entry.getKey()); + return schematicNameCompletableFuture; + } + } + + Bukkit.getScheduler().runTask(IridiumSkyblock.getInstance(), () -> player.openInventory(new CreateGUI(player.getOpenInventory().getTopInventory(), schematicNameCompletableFuture).getInventory())); + return schematicNameCompletableFuture; + } + @Override public CompletableFuture createTeam(@NotNull Player owner, String name) { - CompletableFuture schematicNameCompletableFuture = new CompletableFuture<>(); - owner.openInventory(new CreateGUI(owner.getOpenInventory().getTopInventory(), schematicNameCompletableFuture).getInventory()); return CompletableFuture.supplyAsync(() -> { - String schematic = schematicNameCompletableFuture.join(); + String schematic = getSchematic(owner).join(); if (schematic == null) return null; User user = IridiumSkyblock.getInstance().getUserManager().getUser(owner);