diff --git a/src/main/java/com/iridium/iridiumskyblock/managers/IslandManager.java b/src/main/java/com/iridium/iridiumskyblock/managers/IslandManager.java index 94ade66bc..095e2ae97 100644 --- a/src/main/java/com/iridium/iridiumskyblock/managers/IslandManager.java +++ b/src/main/java/com/iridium/iridiumskyblock/managers/IslandManager.java @@ -115,8 +115,7 @@ public CompletableFuture createTeam(@NotNull Player owner, String name) User user = IridiumSkyblock.getInstance().getUserManager().getUser(owner); Schematics.SchematicConfig schematicConfig = IridiumSkyblock.getInstance().getSchematics().schematics.get(schematic); - IslandCreateEvent islandCreateEvent = new IslandCreateEvent(user, name, schematicConfig); - Bukkit.getPluginManager().callEvent(islandCreateEvent); + IslandCreateEvent islandCreateEvent = getIslandCreateEvent(user, name, schematicConfig).join(); if (islandCreateEvent.isCancelled()) return null; owner.sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().creatingIsland @@ -143,6 +142,17 @@ public CompletableFuture createTeam(@NotNull Player owner, String name) }); } + private CompletableFuture getIslandCreateEvent(@NotNull User user, @Nullable String islandName, Schematics.@NotNull SchematicConfig schematicConfig) { + CompletableFuture completableFuture = new CompletableFuture<>(); + Bukkit.getScheduler().runTask(IridiumSkyblock.getInstance(), () -> { + IslandCreateEvent islandCreateEvent = new IslandCreateEvent(user, islandName, schematicConfig); + Bukkit.getPluginManager().callEvent(islandCreateEvent); + completableFuture.complete(islandCreateEvent); + + }); + return completableFuture; + } + public CompletableFuture generateIsland(Island island, Schematics.SchematicConfig schematicConfig) { return CompletableFuture.runAsync(() -> { setHome(island, schematicConfig); @@ -596,12 +606,12 @@ public void handleBlockPlaceOutsideTerritory(BlockPlaceEvent blockEvent) { public void clearTeamInventory(Island island) { - if(IridiumSkyblock.getInstance().getConfiguration().clearInventoryOnRegen) { + if (IridiumSkyblock.getInstance().getConfiguration().clearInventoryOnRegen) { IridiumSkyblock.getInstance().getIslandManager().getMembersOnIsland(island).forEach(member -> member.getPlayer().getInventory().clear()); } - if(IridiumSkyblock.getInstance().getConfiguration().clearEnderChestOnRegen) { + if (IridiumSkyblock.getInstance().getConfiguration().clearEnderChestOnRegen) { IridiumSkyblock.getInstance().getIslandManager().getMembersOnIsland(island).forEach(member -> member.getPlayer().getEnderChest().clear()); }