Skip to content

Commit

Permalink
Fixed errors when creating new islands
Browse files Browse the repository at this point in the history
  • Loading branch information
OmerBenGera committed Oct 1, 2022
1 parent 2cfa85e commit ac21454
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
Expand Up @@ -172,10 +172,17 @@ public void createIsland(Island.Builder builderParam, Biome biome, boolean offse

Preconditions.checkArgument(schematic != null, "Cannot create an island with an invalid schematic.");

if (!Bukkit.isPrimaryThread()) {
BukkitExecutor.sync(() -> createIslandInternalAsync(builder, biome, offset, schematic));
} else {
createIslandInternalAsync(builder, biome, offset, schematic);
try {
if (!Bukkit.isPrimaryThread()) {
BukkitExecutor.sync(() -> createIslandInternalAsync(builder, biome, offset, schematic));
} else {
createIslandInternalAsync(builder, biome, offset, schematic);
}
} catch (Throwable error) {
error.printStackTrace();
PluginDebugger.debug(error);
builder.owner.setIsland(null);
Message.CREATE_ISLAND_FAILURE.send(builder.owner);
}
}

Expand All @@ -192,7 +199,7 @@ private void createIslandInternalAsync(IslandBuilderImpl builder, Biome biome, b
if (!plugin.getEventsBus().callPreIslandCreateEvent(builder.owner, builder.islandName))
return;

UUID islandUUID = generateIslandUUID();
builder.setUniqueId(generateIslandUUID());

long startTime = System.currentTimeMillis();

Expand Down
Expand Up @@ -313,12 +313,6 @@ public SIsland(IslandBuilderImpl builder) {
islandWarp.setIcon(warpRecord.icon);
});

updateDatesFormatter();
startBankInterest();
checkMembersDuplication();
updateOldUpgradeValues();
updateUpgrades();
updateIslandChests();

// We want to save all the limits to the custom block keys
plugin.getBlockValues().addCustomBlockKeys(builder.blockLimits.keySet());
Expand All @@ -329,6 +323,13 @@ public SIsland(IslandBuilderImpl builder) {
this.blocksTracker = plugin.getFactory().createIslandBlocksTrackerAlgorithm(this);
this.entitiesTracker = plugin.getFactory().createIslandEntitiesTrackerAlgorithm(this);

updateDatesFormatter();
startBankInterest();
checkMembersDuplication();
updateOldUpgradeValues();
updateUpgrades();
updateIslandChests();

this.islandBank.setBalance(builder.balance);
builder.bankTransactions.forEach(this.islandBank::loadTransaction);
if (builder.persistentData.length > 0)
Expand Down

0 comments on commit ac21454

Please sign in to comment.