9
0
mirror of https://github.com/Xiao-MoMi/Custom-Crops.git synced 2025-12-26 10:29:10 +00:00
This commit is contained in:
XiaoMoMi
2024-03-24 17:50:58 +08:00
parent b2843b6516
commit 5d2453a687
6 changed files with 54 additions and 8 deletions

View File

@@ -40,6 +40,7 @@ public class VersionManagerImpl extends VersionManager {
private final boolean isNewerThan1_20;
private final boolean isNewerThan1_20_R2;
private final boolean isNewerThan1_19;
private final boolean isNewerThan1_18;
private boolean isMojmap;
@SuppressWarnings("deprecation")
@@ -57,18 +58,28 @@ public class VersionManagerImpl extends VersionManager {
isNewerThan1_19_R3 = true;
isNewerThan1_20 = true;
isNewerThan1_19 = true;
isNewerThan1_18 = true;
} else if (main_ver == 19) {
isNewerThan1_19_R2 = Integer.parseInt(split[2].substring(1)) >= 2;
isNewerThan1_19_R3 = Integer.parseInt(split[2].substring(1)) >= 3;
isNewerThan1_20 = false;
isNewerThan1_20_R2 = false;
isNewerThan1_19 = true;
isNewerThan1_18 = true;
} else if (main_ver == 18) {
isNewerThan1_19_R2 = false;
isNewerThan1_19_R3 = false;
isNewerThan1_20_R2 = false;
isNewerThan1_20 = false;
isNewerThan1_19 = false;
isNewerThan1_18 = true;
} else {
isNewerThan1_19_R2 = false;
isNewerThan1_19_R3 = false;
isNewerThan1_20_R2 = false;
isNewerThan1_20 = false;
isNewerThan1_19 = false;
isNewerThan1_18 = false;
}
try {
@@ -132,6 +143,11 @@ public class VersionManagerImpl extends VersionManager {
return isNewerThan1_20;
}
@Override
public boolean isVersionNewerThan1_18() {
return isNewerThan1_18;
}
@Override
public boolean isMojmap() {
return isMojmap;

View File

@@ -27,6 +27,7 @@ import com.github.luben.zstd.Zstd;
import com.google.gson.Gson;
import net.momirealms.customcrops.api.CustomCropsPlugin;
import net.momirealms.customcrops.api.manager.ConfigManager;
import net.momirealms.customcrops.api.manager.VersionManager;
import net.momirealms.customcrops.api.manager.WorldManager;
import net.momirealms.customcrops.api.mechanic.world.*;
import net.momirealms.customcrops.api.mechanic.world.level.CustomCropsChunk;
@@ -89,11 +90,10 @@ public class BukkitWorldAdaptor extends AbstractWorldAdaptor {
return;
}
try {
if (VersionManager.isHigherThan1_18()) {
world.getPersistentDataContainer().set(key, PersistentDataType.STRING,
gson.toJson(cWorld.getInfoData()));
} catch (Exception e) {
// handle exceptions for those servers without pdc
} else {
try (FileWriter file = new FileWriter(new File(getWorldFolder(world), "cworld.dat"))) {
gson.toJson(cWorld.getInfoData(), file);
} catch (IOException ioException) {
@@ -120,12 +120,12 @@ public class BukkitWorldAdaptor extends AbstractWorldAdaptor {
return;
}
try {
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);
cWorld.setInfoData(data);
} catch (Exception e) {
} else {
File cWorldFile = new File(getWorldFolder(world), "cworld.dat");
if (cWorldFile.exists()) {
byte[] fileBytes = new byte[(int) cWorldFile.length()];

View File

@@ -24,4 +24,28 @@ softdepend:
- Jobs
- RealisticSeasons
- AdvancedSeasons
- SlimeWorldManager
- SlimeWorldManager
- HuskClaims
- HuskTowns
- Residence
- BentoBox
- FabledSkyBlock
- CrashClaim
- GriefDefender
- GriefPrevention
- BentoBox
- IridiumSkyBlock
- KingdomsX
- Landlord
- Lands
- PlotSquared
- ProtectionStones
- RedProtect
- Factions
- SuperiorSkyblock2
- Towny
- UltimateClaims
- UltimateClans
- uSkyBlock
- WorldGuard
- XClaim