Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>17</java.version>
<java.version>21</java.version>
<powermock.version>2.0.2</powermock.version>
<!-- More visible way how to change dependency versions -->
<spigot.version>1.21.3-R0.1-SNAPSHOT</spigot.version>
<bentobox.version>2.7.1-SNAPSHOT</bentobox.version>
<spigot.version>1.21.5-R0.1-SNAPSHOT</spigot.version>
<bentobox.version>3.4.0</bentobox.version>
<bank.version>1.4.0</bank.version>
<level.version>2.5.0</level.version>
<greenhouses.version>1.4.0-SNAPSHOT</greenhouses.version>
Expand All @@ -52,7 +52,7 @@
<!-- Revision variable removes warning about dynamic version -->
<revision>${build.version}-SNAPSHOT</revision>
<!-- This allows to change between versions and snapshots. -->
<build.version>2.2.0</build.version>
<build.version>2.2.1</build.version>
<build.number>-LOCAL</build.number>
<!-- Sonar Cloud -->
<sonar.projectKey>BentoBoxWorld_Biomes</sonar.projectKey>
Expand Down
71 changes: 27 additions & 44 deletions src/main/java/world/bentobox/biomes/tasks/BiomeUpdateTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ public class BiomeUpdateTask
* @param biome BiomeObject that will changed.
*/
public BiomeUpdateTask(BiomesAddon addon,
User user,
BiomesObject biome)
User user, BiomesObject biome)
{
this.addon = addon;
this.user = user;
Expand Down Expand Up @@ -67,7 +66,7 @@ public void updateChunkQueue()
for (int x = this.minCoordinate.getBlockX() >> 4, maxX = this.maxCoordinate.getBlockX() >> 4; x <= maxX; x++)
{
for (int z = this.minCoordinate.getBlockZ() >> 4, maxZ = this.maxCoordinate.getBlockZ() >> 4; z <= maxZ;
z++)
z++)
{
this.chunksToUpdate.add(this.constructChunkData(x, z));
}
Expand Down Expand Up @@ -101,8 +100,8 @@ public void processBiomeChange(UpdateQueue updateQueue)
updateQueue.getProcessStartMap().remove(this);
this.result.complete(UpdateQueue.Result.TIMEOUT);
this.addon.logError(
"Biome change timed out after " + this.addon.getSettings().getChangeTimeout() + "m for user: " +
this.user.getName());
"Biome change timed out after " + this.addon.getSettings().getChangeTimeout() + "m for user: "
+ this.user.getName());
return;
}

Expand Down Expand Up @@ -155,7 +154,7 @@ private CompletableFuture<Boolean> scanNextChunk()
ChunkData chunkData = this.chunksToUpdate.poll();

chunkData.getChunk(this.world).thenAccept(chunk ->
this.scanChunk(chunkData, chunk).thenAccept(completed::complete));
this.scanChunk(chunkData, chunk).thenAccept(completed::complete));

return completed;
}
Expand All @@ -178,16 +177,7 @@ private CompletableFuture<Boolean> scanChunk(ChunkData chunkData, Chunk chunk)
return completed;
}

if (Util.isPaper())
{
Bukkit.getScheduler().runTaskAsynchronously(this.addon.getPlugin(),
() -> this.runBiomeChange(chunkData, chunk, completed));
}
else
{
Bukkit.getScheduler().runTask(this.addon.getPlugin(),
() -> this.runBiomeChange(chunkData, chunk, completed));
}
Bukkit.getScheduler().runTask(this.addon.getPlugin(), () -> this.runBiomeChange(chunkData, chunk, completed));

return completed;
}
Expand All @@ -200,20 +190,16 @@ private CompletableFuture<Boolean> scanChunk(ChunkData chunkData, Chunk chunk)
* @param chunk the chunk
* @param completed the completed
*/
@SuppressWarnings("deprecated")
private void runBiomeChange(ChunkData chunkData, Chunk chunk, CompletableFuture<Boolean> completed)
{
for (int x = chunkData.minX();
x <= chunkData.maxX();
x += 4)
x <= chunkData.maxX(); x += 4)
{
for (int z = chunkData.minZ();
z <= chunkData.maxZ();
z += 4)
z <= chunkData.maxZ(); z += 4)
{
for (int y = chunkData.minY();
y <= chunkData.maxY();
y += 4)
y <= chunkData.maxY(); y += 4)
{
// Biome should not be changed in Greenhouses.
if (!this.addon.getAddonManager().hasGreenhouseInLocation(this.world, x, y, z))
Expand Down Expand Up @@ -283,14 +269,13 @@ private ChunkData constructChunkData(int chunkX, int chunkZ)
}

return new ChunkData(chunkX, chunkZ,
minX, this.minCoordinate.getBlockY(), minZ,
maxX, this.maxCoordinate.getBlockY(), maxZ);
minX, this.minCoordinate.getBlockY(), minZ, maxX, this.maxCoordinate.getBlockY(), maxZ);
}


// ---------------------------------------------------------------------
// Section: Setters
// ---------------------------------------------------------------------
// ---------------------------------------------------------------------
// Section: Setters
// ---------------------------------------------------------------------


/**
Expand Down Expand Up @@ -337,9 +322,9 @@ public void setMaxCoordinate(BlockVector maxCoordinate)
}


// ---------------------------------------------------------------------
// Section: Getters
// ---------------------------------------------------------------------
// ---------------------------------------------------------------------
// Section: Getters
// ---------------------------------------------------------------------


/**
Expand Down Expand Up @@ -370,11 +355,9 @@ public int getNumberOfChunks()
public void notifyStarting()
{
Utils.sendMessage(this.user, this.user.getTranslation(
Constants.MESSAGES + "update-start",
"[biome]", this.biomesObject.getFriendlyName(),
"[number]", String.valueOf(this.getNumberOfChunks()),
"[time]", String.valueOf((int)
Math.max(1, this.getNumberOfChunks() * this.addon.getUpdateQueue().getChunkTime()))));
Constants.MESSAGES + "update-start", "[biome]", this.biomesObject.getFriendlyName(), "[number]",
String.valueOf(this.getNumberOfChunks()), "[time]", String.valueOf(
(int) Math.max(1, this.getNumberOfChunks() * this.addon.getUpdateQueue().getChunkTime()))));
}


Expand All @@ -384,14 +367,14 @@ public void notifyStarting()
public void notifyWaiting()
{
Utils.sendMessage(this.user,
this.user.getTranslation(Constants.MESSAGES + "waiting",
"[time]", String.valueOf(this.addon.getUpdateQueue().getQueueTime())));
this.user.getTranslation(Constants.MESSAGES + "waiting", "[time]",
String.valueOf(this.addon.getUpdateQueue().getQueueTime())));
}


// ---------------------------------------------------------------------
// Section: Classes
// ---------------------------------------------------------------------
// ---------------------------------------------------------------------
// Section: Classes
// ---------------------------------------------------------------------


/**
Expand All @@ -413,9 +396,9 @@ public CompletableFuture<Chunk> getChunk(World world)
}


// ---------------------------------------------------------------------
// Section: Variables
// ---------------------------------------------------------------------
// ---------------------------------------------------------------------
// Section: Variables
// ---------------------------------------------------------------------


/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/world/bentobox/biomes/utils/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ public static boolean hasUserUpdateModePermission(User user,
*/
public static String sanitizeInput(String input)
{
return ChatColor.stripColor(
return Util.stripColor(
Util.translateColorCodes(input.toLowerCase(Locale.ENGLISH).replace(" ", "_").replace("-", "_")));
}

Expand Down