9
0
mirror of https://github.com/Xiao-MoMi/Custom-Crops.git synced 2025-12-25 18:09:28 +00:00

fix convert bugs

This commit is contained in:
XiaoMoMi
2024-03-27 02:09:53 +08:00
parent 64589c3503
commit 3e7633a4b0
3 changed files with 11 additions and 7 deletions

View File

@@ -195,7 +195,7 @@ public enum Dependency {
NBT_API(
"de{}tr7zw",
"item-nbt-api",
"2.12.2",
"2.12.3",
"codemc",
"item-nbt-api",
Relocation.of("changeme", "de{}tr7zw{}changeme")

View File

@@ -116,14 +116,16 @@ public class BukkitWorldAdaptor extends AbstractWorldAdaptor {
// try converting legacy worlds
if (ConfigManager.convertWorldOnLoad()) {
convertWorldFromV33toV34(cWorld, world);
return;
if (convertWorldFromV33toV34(cWorld, world)) {
return;
}
}
if (VersionManager.isHigherThan1_18()) {
// init world basic info
String json = world.getPersistentDataContainer().get(key, PersistentDataType.STRING);
WorldInfoData data = (json == null || json.equals("null")) ? WorldInfoData.empty() : gson.fromJson(json, WorldInfoData.class);
if (data == null) data = WorldInfoData.empty();
cWorld.setInfoData(data);
} else {
File cWorldFile = new File(getWorldFolder(world), "cworld.dat");
@@ -611,7 +613,7 @@ public class BukkitWorldAdaptor extends AbstractWorldAdaptor {
return outByteStream.toByteArray();
}
public void convertWorldFromV33toV34(@Nullable CWorld cWorld, World world) {
public boolean convertWorldFromV33toV34(@Nullable CWorld cWorld, World world) {
// handle legacy files
File leagcyFile = new File(world.getWorldFolder(), "customcrops" + File.separator + "data.yml");
if (leagcyFile.exists()) {
@@ -633,10 +635,10 @@ public class BukkitWorldAdaptor extends AbstractWorldAdaptor {
// read chunks
File folder = new File(world.getWorldFolder(), "customcrops" + File.separator + "chunks");
if (!folder.exists()) return;
if (!folder.exists()) return false;
LogUtils.warn("Converting chunks for world " + world.getName() + " from 3.3 to 3.4... This might take some time.");
File[] data_files = folder.listFiles();
if (data_files == null) return;
if (data_files == null) return false;
HashMap<RegionPos, CustomCropsRegion> regionHashMap = new HashMap<>();
@@ -685,7 +687,9 @@ public class BukkitWorldAdaptor extends AbstractWorldAdaptor {
saveRegion(region);
}
LogUtils.info("Successfully converted chunks for world: " + world.getName());
return true;
}
return false;
}
public void convertWorldFromV342toV343(@Nullable CWorld cWorld, World world) {