forked from SteamWar/SteamWar
Improve API of RegionDataStore, RegionBackups.Backup
This commit is contained in:
@@ -38,7 +38,6 @@ import de.steamwar.bausystem.utils.TickManager;
|
||||
import de.steamwar.bausystem.worlddata.WorldData;
|
||||
import de.steamwar.command.AbstractValidator;
|
||||
import de.steamwar.command.SWCommandUtils;
|
||||
import de.steamwar.core.CRIUSleepEvent;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.core.WorldEditRendererCUIEditor;
|
||||
import de.steamwar.core.WorldIdentifier;
|
||||
@@ -51,8 +50,6 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameRule;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
@@ -65,7 +62,7 @@ import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class BauSystem extends JavaPlugin implements Listener {
|
||||
public class BauSystem extends JavaPlugin {
|
||||
|
||||
// This should be treated as final!
|
||||
public static Message MESSAGE;
|
||||
@@ -137,10 +134,6 @@ public class BauSystem extends JavaPlugin implements Listener {
|
||||
WorldIdentifier.set("bau/" + Core.getVersion() + "/" + identifier);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onCRIUSleep(CRIUSleepEvent event) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
linker.unlink();
|
||||
|
||||
@@ -54,14 +54,16 @@ public interface RegionBackups {
|
||||
@CheckReturnValue
|
||||
public abstract boolean load();
|
||||
|
||||
public abstract void delete();
|
||||
|
||||
public abstract long getCreationTime();
|
||||
|
||||
@Override
|
||||
public int compareTo(Backup o) {
|
||||
return Long.compare(getCreationTime(), o.getCreationTime());
|
||||
}
|
||||
|
||||
@SuppressWarnings("java:S3038") // This forces everybody to implement 'deleteRegion' for Backups!
|
||||
@Override
|
||||
public abstract void deleteRegion();
|
||||
}
|
||||
|
||||
@CheckReturnValue
|
||||
|
||||
@@ -41,12 +41,12 @@ public abstract class RegionData {
|
||||
protected RegionData(RegionDataStore store) {
|
||||
this.store = store;
|
||||
initialize();
|
||||
store.loadRegionData(this);
|
||||
store.loadRegion();
|
||||
}
|
||||
|
||||
public final void setStore(RegionDataStore store) {
|
||||
this.store = store;
|
||||
store.saveRegionData(this);
|
||||
store.saveRegion();
|
||||
}
|
||||
|
||||
protected void initialize() {
|
||||
@@ -61,7 +61,7 @@ public abstract class RegionData {
|
||||
public final <T extends Enum<T> & Flag.Value<T>> boolean set(@NonNull Flag<T> flag, @NonNull T value) {
|
||||
if (has(flag).isWritable()) {
|
||||
if (flagMap.put(flag, value) != value) {
|
||||
store.saveRegionData(this);
|
||||
store.saveRegion();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -80,7 +80,7 @@ public abstract class RegionData {
|
||||
}
|
||||
}
|
||||
properties.forEach(property -> property.set(null));
|
||||
store.saveRegionData(this);
|
||||
store.saveRegion();
|
||||
}
|
||||
|
||||
public final Map<Flag<?>, Flag.Value<?>> getBackedMap() {
|
||||
@@ -97,7 +97,7 @@ public abstract class RegionData {
|
||||
|
||||
public final void setTestblockSchematic(SchematicNode schematic) {
|
||||
testblockSchematic.set(schematic);
|
||||
store.saveRegionData(this);
|
||||
store.saveRegion();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,9 +19,9 @@
|
||||
|
||||
package de.steamwar.bausystem.region;
|
||||
|
||||
import lombok.NonNull;
|
||||
|
||||
public interface RegionDataStore {
|
||||
void saveRegionData(@NonNull RegionData regionData);
|
||||
void loadRegionData(@NonNull RegionData regionData);
|
||||
void saveRegion();
|
||||
void loadRegion();
|
||||
default void deleteRegion() {
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user