-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
13b659b
commit 7eddb36
Showing
7 changed files
with
257 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
common/src/main/java/xyz/jpenilla/squaremap/common/config/DataStorageType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package xyz.jpenilla.squaremap.common.config; | ||
|
||
public enum DataStorageType { | ||
FLATFILE | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
common/src/main/java/xyz/jpenilla/squaremap/common/data/storage/AdditionalParameters.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package xyz.jpenilla.squaremap.common.data.storage; | ||
|
||
import java.util.Map; | ||
import java.util.Optional; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
import org.checkerframework.checker.nullness.qual.NonNull; | ||
import org.checkerframework.framework.qual.DefaultQualifier; | ||
|
||
@DefaultQualifier(NonNull.class) | ||
public final class AdditionalParameters { | ||
|
||
private final Map<String, Object> parameters = new ConcurrentHashMap<>(); | ||
|
||
public AdditionalParameters put(String key, Object value) { | ||
this.parameters.put(key, value); | ||
return this; | ||
} | ||
|
||
public Optional<Object> get(String key) { | ||
return Optional.ofNullable(parameters.get(key)); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
common/src/main/java/xyz/jpenilla/squaremap/common/data/storage/DataStorage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package xyz.jpenilla.squaremap.common.data.storage; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Set; | ||
import java.util.concurrent.CompletableFuture; | ||
import org.checkerframework.checker.nullness.qual.NonNull; | ||
import org.checkerframework.framework.qual.DefaultQualifier; | ||
import xyz.jpenilla.squaremap.api.WorldIdentifier; | ||
import xyz.jpenilla.squaremap.common.data.ChunkCoordinate; | ||
import xyz.jpenilla.squaremap.common.data.RegionCoordinate; | ||
|
||
@DefaultQualifier(NonNull.class) | ||
public interface DataStorage { | ||
|
||
void storeDirtyChunks(WorldIdentifier world, Set<ChunkCoordinate> dirtyChunkCoordinates, AdditionalParameters parameters); | ||
|
||
CompletableFuture<Set<ChunkCoordinate>> getDirtyChunks(WorldIdentifier world, AdditionalParameters parameters); | ||
|
||
void storeRenderProgress(WorldIdentifier world, Map<RegionCoordinate, Boolean> renderProgress, AdditionalParameters parameters); | ||
|
||
CompletableFuture<Map<RegionCoordinate, Boolean>> getRenderProgress(WorldIdentifier world, AdditionalParameters parameters); | ||
|
||
void deleteRenderProgress(WorldIdentifier world, AdditionalParameters parameters); | ||
|
||
void updateMarkers(WorldIdentifier world, List<Map<String, Object>> layers, AdditionalParameters parameters); | ||
|
||
void updateWorldSettings(WorldIdentifier world, Map<String, Object> settings, AdditionalParameters parameters); | ||
|
||
void updateGlobalSettings(WorldIdentifier world, Map<String, Object> settings, AdditionalParameters parameters); | ||
} |
18 changes: 18 additions & 0 deletions
18
common/src/main/java/xyz/jpenilla/squaremap/common/data/storage/DataStorageHolder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package xyz.jpenilla.squaremap.common.data.storage; | ||
|
||
import xyz.jpenilla.squaremap.common.config.Config; | ||
|
||
public class DataStorageHolder { | ||
|
||
private static DataStorage dataStorage; | ||
|
||
public static DataStorage getDataStorage() { | ||
if (dataStorage == null) { | ||
switch (Config.STORAGE_TYPE) { | ||
case FLATFILE -> dataStorage = new FlatfileDataStorage(); | ||
} | ||
} | ||
return dataStorage; | ||
} | ||
|
||
} |
Oops, something went wrong.