mirror of
https://github.com/Xiao-MoMi/Custom-Crops.git
synced 2025-12-28 03:19:15 +00:00
migration system
This commit is contained in:
@@ -116,6 +116,12 @@ public abstract class ConfigManager implements Reloadable {
|
||||
return instance.getScarecrowID();
|
||||
}
|
||||
|
||||
public static boolean convertWorldOnLoad() {
|
||||
return instance.isConvertWorldOnLoad();
|
||||
}
|
||||
|
||||
protected abstract boolean isConvertWorldOnLoad();
|
||||
|
||||
protected abstract double[] getDefaultQualityRatio();
|
||||
|
||||
protected abstract String getLang();
|
||||
|
||||
@@ -42,6 +42,8 @@ public interface ItemManager extends Reloadable {
|
||||
|
||||
void placeItem(Location location, ItemCarrier carrier, String id);
|
||||
|
||||
void placeItem(Location location, ItemCarrier carrier, String id, boolean rotate);
|
||||
|
||||
void removeAnythingAt(Location location);
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -19,6 +19,7 @@ package net.momirealms.customcrops.api.manager;
|
||||
|
||||
import net.momirealms.customcrops.api.common.Reloadable;
|
||||
import net.momirealms.customcrops.api.mechanic.item.*;
|
||||
import net.momirealms.customcrops.api.mechanic.world.AbstractWorldAdaptor;
|
||||
import net.momirealms.customcrops.api.mechanic.world.CustomCropsBlock;
|
||||
import net.momirealms.customcrops.api.mechanic.world.SimpleLocation;
|
||||
import net.momirealms.customcrops.api.mechanic.world.level.*;
|
||||
@@ -139,4 +140,6 @@ public interface WorldManager extends Reloadable {
|
||||
void removeScarecrowAt(@NotNull SimpleLocation location);
|
||||
|
||||
CustomCropsBlock removeAnythingAt(SimpleLocation location);
|
||||
|
||||
AbstractWorldAdaptor getWorldAdaptor();
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ public interface Crop extends KeyItem {
|
||||
|
||||
BoneMeal[] getBoneMeals();
|
||||
|
||||
boolean isRotation();
|
||||
boolean hasRotation();
|
||||
|
||||
void trigger(ActionTrigger trigger, State state);
|
||||
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (C) <2022> <XiaoMoMi>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customcrops.api.mechanic.world;
|
||||
|
||||
import net.momirealms.customcrops.api.manager.WorldManager;
|
||||
import net.momirealms.customcrops.api.mechanic.world.level.CustomCropsChunk;
|
||||
import net.momirealms.customcrops.api.mechanic.world.level.CustomCropsWorld;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
public abstract class AbstractWorldAdaptor implements Listener {
|
||||
|
||||
public static final int version = 1;
|
||||
protected WorldManager worldManager;
|
||||
|
||||
public AbstractWorldAdaptor(WorldManager worldManager) {
|
||||
this.worldManager = worldManager;
|
||||
}
|
||||
|
||||
public abstract void unload(CustomCropsWorld customCropsWorld);
|
||||
|
||||
public abstract void init(CustomCropsWorld customCropsWorld);
|
||||
|
||||
public abstract void loadDynamicData(CustomCropsWorld customCropsWorld, ChunkCoordinate chunkCoordinate);
|
||||
|
||||
public abstract void unloadDynamicData(CustomCropsWorld customCropsWorld, ChunkCoordinate chunkCoordinate);
|
||||
|
||||
public abstract void saveDynamicData(CustomCropsWorld ccWorld, CustomCropsChunk chunk);
|
||||
}
|
||||
@@ -28,6 +28,19 @@ public record ChunkCoordinate(int x, int z) {
|
||||
return new ChunkCoordinate(x, z);
|
||||
}
|
||||
|
||||
public static ChunkCoordinate getByString(String coordinate) {
|
||||
String[] split = coordinate.split(",", 2);
|
||||
try {
|
||||
int x = Integer.parseInt(split[0]);
|
||||
int z = Integer.parseInt(split[1]);
|
||||
return new ChunkCoordinate(x, z);
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
long combined = (long) x << 32 | z;
|
||||
|
||||
Reference in New Issue
Block a user