Skip to content

Commit

Permalink
Fixes bugs introduced by code smell fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
tastybento committed Jun 26, 2020
1 parent 73fad8a commit a6be22b
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 45 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@
<!-- Non-minecraft related dependencies -->
<powermock.version>2.0.2</powermock.version>
<!-- More visible way how to change dependency versions -->
<spigot.version>1.15.2-R0.1-SNAPSHOT</spigot.version>
<spigot.version>1.16.1-R0.1-SNAPSHOT</spigot.version>
<bentobox.version>1.14.0-SNAPSHOT</bentobox.version>
<!-- Revision variable removes warning about dynamic version -->
<revision>${build.version}-SNAPSHOT</revision>
<!-- Do not change unless you want different name for local builds. -->
<build.number>-LOCAL</build.number>
<!-- This allows to change between versions. -->
<build.version>2.2.0</build.version>
<build.version>2.3.0</build.version>
</properties>

<!-- Profiles will allow to automatically change build version. -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;

import com.bgsoftware.wildstacker.api.WildStackerAPI;
import com.bgsoftware.wildstacker.api.objects.StackedBarrel;
Expand Down Expand Up @@ -429,12 +430,13 @@ private void scanChests(Chunk chunk) {
* @param chunk - the chunk to scan
* @return future that completes when the scan is done and supplies a boolean that will be true if the scan was successful, false if not
*/
private CompletableFuture<Boolean> scanChunk(@NonNull Chunk chunk) {
private CompletableFuture<Boolean> scanChunk(@Nullable Chunk chunk) {
// If the chunk hasn't been generated, return
if (chunk == null) return CompletableFuture.completedFuture(false);
// Scan chests
if (addon.getSettings().isIncludeChests()) {
scanChests(chunk);
}

// Count blocks in chunk
CompletableFuture<Boolean> result = new CompletableFuture<>();
Bukkit.getScheduler().runTaskAsynchronously(BentoBox.getInstance(), () -> scanAsync(result, chunk));
Expand All @@ -447,6 +449,7 @@ private CompletableFuture<Boolean> scanChunk(@NonNull Chunk chunk) {
*/
public CompletableFuture<Boolean> scanNextChunk() {
if (chunksToCheck.isEmpty()) {
addon.logError("Unexpected: no chunks to scan!");
// This should not be needed, but just in case
return CompletableFuture.completedFuture(false);
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/world/bentobox/level/calculators/Pipeliner.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public Pipeliner(Level addon) {
}
// One island at a time
if (inProcess || processQueue.isEmpty()) return;

IslandLevelCalculator iD = processQueue.poll();
// Ignore deleted or unonwed islands
if (iD.getIsland().isDeleted() || iD.getIsland().isUnowned()) return;
Expand All @@ -63,6 +64,7 @@ public int getIslandsInQueue() {
private void scanChunk(IslandLevelCalculator iD) {
if (iD.getIsland().isDeleted() || iD.getIsland().isUnowned()) {
// Island is deleted, so finish early with nothing
addon.log("Canceling island level calculation - island has been deleted, or has become unowned.");
inProcess = false;
iD.getR().complete(null);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public void setup() {

@Override
public boolean execute(User user, String label, List<String> args) {
user.sendMessage("islands-in-queue", TextVariables.NUMBER, String.valueOf(addon.getPipeliner().getIslandsInQueue()));
user.sendMessage("admin.levelstatus.islands-in-queue", TextVariables.NUMBER, String.valueOf(addon.getPipeliner().getIslandsInQueue()));
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ public boolean execute(User user, String label, List<String> args) {
return true;
}
}
if (!user.isPlayer()) {
user.sendMessage("general.errors.use-in-game");
return false;
}
// Self request
// Check player cooldown
int coolDown = this.addon.getSettings().getLevelWait();
Expand Down

0 comments on commit a6be22b

Please sign in to comment.