Fix Flag.Value to have enum methods for save/load
This commit is contained in:
@ -22,6 +22,8 @@ package de.steamwar.bausystem.region;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import lombok.NonNull;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface FlagStorage {
|
||||
|
||||
@NonNull
|
||||
@ -33,4 +35,6 @@ public interface FlagStorage {
|
||||
<T extends Enum<T> & Flag.Value<T>> FlagOptional<T> get(@NonNull Flag<T> flag);
|
||||
|
||||
void clear();
|
||||
|
||||
Map<Flag<?>, Flag.Value<?>> getBackedMap();
|
||||
}
|
||||
|
||||
@ -89,6 +89,10 @@ public final class Flag<T extends Enum<T> & Flag.Value<T>> implements EnumDispla
|
||||
|
||||
public interface Value<T extends Enum<T> & Value<T>> extends EnumDisplay {
|
||||
|
||||
String name();
|
||||
|
||||
int ordinal();
|
||||
|
||||
T getValue();
|
||||
|
||||
T getValueOf(final String name);
|
||||
|
||||
@ -74,4 +74,9 @@ public class FixedFlagStorage implements FlagStorage {
|
||||
public void clear() {
|
||||
flagMap.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Flag<?>, Flag.Value<?>> getBackedMap() {
|
||||
return flagMap;
|
||||
}
|
||||
}
|
||||
|
||||
@ -78,4 +78,9 @@ public class FixedGlobalFlagStorage implements FlagStorage {
|
||||
public void clear() {
|
||||
flagMap.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Flag<?>, Flag.Value<?>> getBackedMap() {
|
||||
return flagMap;
|
||||
}
|
||||
}
|
||||
|
||||
@ -28,9 +28,13 @@ import java.util.UUID;
|
||||
public class FixedRegion implements Region {
|
||||
|
||||
private UUID uuid;
|
||||
private FixedFlagStorage flagStorage;
|
||||
private Prototype prototype;
|
||||
|
||||
public FixedRegion(String name) {
|
||||
public FixedRegion(String name, FixedFlagStorage flagStorage, Prototype prototype) {
|
||||
uuid = UUID.nameUUIDFromBytes(name.getBytes(StandardCharsets.UTF_8));
|
||||
this.flagStorage = flagStorage;
|
||||
this.prototype = prototype;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -45,7 +49,7 @@ public class FixedRegion implements Region {
|
||||
|
||||
@Override
|
||||
public @NonNull FlagStorage getFlags() {
|
||||
return null;
|
||||
return flagStorage;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user