Skip to content

Commit

Permalink
Code health
Browse files Browse the repository at this point in the history
  • Loading branch information
Jikoo committed Dec 21, 2023
1 parent c9a7d04 commit c08891c
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 17 deletions.
19 changes: 10 additions & 9 deletions src/main/java/com/github/jikoo/regionerator/ChunkFlagger.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@
import com.github.jikoo.regionerator.database.DatabaseAdapter;
import com.github.jikoo.regionerator.util.BatchExpirationLoadingCache;
import com.github.jikoo.regionerator.util.yaml.Config;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.io.File;
import java.util.Collection;
import java.util.Map;
Expand All @@ -22,13 +30,6 @@
import java.util.concurrent.atomic.AtomicLong;
import java.util.logging.Level;
import java.util.regex.Pattern;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

/**
* Utility for storing and loading chunk visit timestamps.
Expand Down Expand Up @@ -406,7 +407,7 @@ private void importOldValue(long oldValue) {
}

/**
* Gets whether or not the chunk data needs to be saved to the database.
* Gets whether the chunk data needs to be saved to the database.
*
* @return true if the chunk data has not been saved
*/
Expand All @@ -431,7 +432,7 @@ public boolean equals(@Nullable Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
FlagData other = (FlagData) obj;
return lastVisit.equals(other.lastVisit) && dirty.equals(other.dirty) && chunkId.equals(other.chunkId);
return lastVisit.get() == other.lastVisit.get() && dirty.get() == other.dirty.get() && chunkId.equals(other.chunkId);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,11 @@ public boolean isChunkProtected(@NotNull World chunkWorld, int chunkX, int chunk
return false;
}
ClaimManager claimManager = GriefDefender.getCore().getClaimManager(chunkWorld.getUID());
if (claimManager == null) {
return false;
}
Set<Claim> claims = claimManager.getChunksToClaimsMap().get(getChunkKey(chunkX, chunkZ));
return claims != null && claims.size() > 0;
return claims != null && !claims.isEmpty();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public boolean isChunkProtected(@NotNull World chunkWorld, int chunkX, int chunk
PlotArea[] plotAreas = PlotSquared.platform().plotAreaManager().getPlotAreas(chunkWorld.getName(), region);

for (PlotArea plotArea : plotAreas) {
if (plotArea.getPlots().size() > 0) {
if (!plotArea.getPlots().isEmpty()) {
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public PreciousStonesHook() {

@Override
public boolean isChunkProtected(@NotNull World chunkWorld, int chunkX, int chunkZ) {
return PreciousStones.API().getChunkFields(new DummyChunk(chunkWorld, chunkX, chunkZ), FieldFlag.ALL).size() > 0;
return !PreciousStones.API().getChunkFields(new DummyChunk(chunkWorld, chunkX, chunkZ), FieldFlag.ALL).isEmpty();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public boolean isChunkProtected(@NotNull World chunkWorld, int chunkX, int chunk
*/

if (needAPI) {
return RedProtect.get().getAPI().getChunkRegions(new DummyChunk(chunkWorld, chunkX, chunkZ)).size() > 0;
return !RedProtect.get().getAPI().getChunkRegions(new DummyChunk(chunkWorld, chunkX, chunkZ)).isEmpty();
}

for (Region region : RedProtect.get().getRegionManager().getRegionsByWorld(chunkWorld.getName())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ public int getLocalChunkZ() {
}

/**
* Gets whether or not the chunk is orphaned, or deleted.
* Gets whether the chunk is either orphaned or deleted.
*
* @return true if the chunk is orphaned
* @return true if the chunk is orphaned or deleted
*/
public abstract boolean isOrphaned();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ public void deleteChunk(int index) throws IOException {
boolean isLargeChunk = false;
if ((encoding & FLAG_CHUNK_TOO_LARGE) != 0) {
isLargeChunk = true;
encoding &= ~FLAG_CHUNK_TOO_LARGE;
encoding = (byte) (encoding & ~FLAG_CHUNK_TOO_LARGE);
}

RegionCompression compression;
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ deletion:
expensive-checks-between-recovery: 128
# Hours between deletion cycles
hours-between-cycles: 12
# Whether or not to remember time for next cycle on plugin load
# Whether to remember time for next cycle on plugin load
remember-next-cycle-time: false

# Worlds the plugin is able to delete regions in
Expand Down

0 comments on commit c08891c

Please sign in to comment.