mirror of
https://github.com/Xiao-MoMi/Custom-Crops.git
synced 2025-12-23 17:09:21 +00:00
Fix some warnings
This commit is contained in:
@@ -8,7 +8,7 @@ plugins {
|
||||
allprojects {
|
||||
|
||||
project.group = "net.momirealms"
|
||||
project.version = "3.4.4"
|
||||
project.version = "3.4.4.1"
|
||||
|
||||
apply<JavaPlugin>()
|
||||
apply(plugin = "java")
|
||||
|
||||
@@ -90,7 +90,7 @@ public class CChunk implements CustomCropsChunk {
|
||||
public void notifyOfflineUpdates() {
|
||||
long current = System.currentTimeMillis();
|
||||
int offlineTimeInSeconds = (int) (current - this.lastLoadedTime) / 1000;
|
||||
CustomCropsPlugin.get().debug("offlineSeconds: " + offlineTimeInSeconds + "s. " + chunkPos.toString());
|
||||
CustomCropsPlugin.get().debug(chunkPos.toString() + " Offline seconds: " + offlineTimeInSeconds + "s.");
|
||||
offlineTimeInSeconds = Math.min(offlineTimeInSeconds, cWorld.getWorldSetting().getMaxOfflineTime());
|
||||
this.lastLoadedTime = current;
|
||||
var setting = cWorld.getWorldSetting();
|
||||
|
||||
@@ -526,10 +526,7 @@ public class CWorld implements CustomCropsWorld {
|
||||
@Override
|
||||
public boolean isPotReachLimit(SimpleLocation location) {
|
||||
Optional<CustomCropsChunk> chunk = getLoadedChunkAt(location.getChunkPos());
|
||||
if (chunk.isEmpty()) {
|
||||
LogUtils.warn("Invalid operation: Querying pot amount from an unloaded chunk");
|
||||
return true;
|
||||
}
|
||||
if (chunk.isEmpty()) return false;
|
||||
if (setting.getPotPerChunk() < 0) return false;
|
||||
return chunk.get().getPotAmount() >= setting.getPotPerChunk();
|
||||
}
|
||||
@@ -537,10 +534,7 @@ public class CWorld implements CustomCropsWorld {
|
||||
@Override
|
||||
public boolean isCropReachLimit(SimpleLocation location) {
|
||||
Optional<CustomCropsChunk> chunk = getLoadedChunkAt(location.getChunkPos());
|
||||
if (chunk.isEmpty()) {
|
||||
LogUtils.warn("Invalid operation: Querying crop amount from an unloaded chunk");
|
||||
return true;
|
||||
}
|
||||
if (chunk.isEmpty()) return false;
|
||||
if (setting.getCropPerChunk() < 0) return false;
|
||||
return chunk.get().getCropAmount() >= setting.getCropPerChunk();
|
||||
}
|
||||
@@ -548,10 +542,7 @@ public class CWorld implements CustomCropsWorld {
|
||||
@Override
|
||||
public boolean isSprinklerReachLimit(SimpleLocation location) {
|
||||
Optional<CustomCropsChunk> chunk = getLoadedChunkAt(location.getChunkPos());
|
||||
if (chunk.isEmpty()) {
|
||||
LogUtils.warn("Invalid operation: Querying sprinkler amount from an unloaded chunk");
|
||||
return true;
|
||||
}
|
||||
if (chunk.isEmpty()) return false;
|
||||
if (setting.getSprinklerPerChunk() < 0) return false;
|
||||
return chunk.get().getSprinklerAmount() >= setting.getSprinklerPerChunk();
|
||||
}
|
||||
|
||||
@@ -191,7 +191,9 @@ public class BukkitWorldAdaptor extends AbstractWorldAdaptor {
|
||||
// if region file not exist, create one
|
||||
File data = getRegionDataFilePath(world, regionPos);
|
||||
if (!data.exists()) {
|
||||
cWorld.loadRegion(new CRegion(cWorld, regionPos));
|
||||
var region = new CRegion(cWorld, regionPos);
|
||||
saveRegion(region);
|
||||
cWorld.loadRegion(region);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -219,7 +221,7 @@ public class BukkitWorldAdaptor extends AbstractWorldAdaptor {
|
||||
long time2 = System.currentTimeMillis();
|
||||
CustomCropsPlugin.get().debug("Took " + (time2-time1) + "ms to load region " + regionPos);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
} catch (Exception e) {
|
||||
LogUtils.severe("Failed to load CustomCrops region data at " + chunkPos + ". Deleting corrupted region.");
|
||||
e.printStackTrace();
|
||||
data.delete();
|
||||
@@ -252,11 +254,6 @@ public class BukkitWorldAdaptor extends AbstractWorldAdaptor {
|
||||
@Override
|
||||
public void saveRegion(CustomCropsRegion customCropsRegion) {
|
||||
File file = getRegionDataFilePath(customCropsRegion.getCustomCropsWorld().getWorld(), customCropsRegion.getRegionPos());
|
||||
if (customCropsRegion.canPrune()) {
|
||||
file.delete();
|
||||
return;
|
||||
}
|
||||
|
||||
long time1 = System.currentTimeMillis();
|
||||
try (BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file))) {
|
||||
bos.write(serialize(customCropsRegion));
|
||||
|
||||
Reference in New Issue
Block a user