Current progress on data accessors

Pushing because I started on stuff and don't wanna lose it...
This commit is contained in:
Shane Freeder
2020-01-20 21:52:50 +00:00
parent ec58a0e81f
commit 21a0a05683
10 changed files with 114 additions and 32 deletions

View File

@ -0,0 +1,4 @@
package com.gmail.nossr50.mcmmo.api.data;
public interface MMOEntity {
}

View File

@ -1,6 +1,6 @@
package com.gmail.nossr50.mcmmo.api.data;
public interface MMOPlayer<N> {
public interface MMOPlayer<N> extends MMOEntity {
N getPlayer();

View File

@ -1,5 +1,9 @@
package com.gmail.nossr50.mcmmo.api.platform;
import com.gmail.nossr50.mcmmo.api.data.MMOPlayer;
import com.gmail.nossr50.mcmmo.api.platform.util.MetadataStore;
import java.io.File;
import java.util.logging.Logger;
public interface PlatformProvider {
@ -7,4 +11,10 @@ public interface PlatformProvider {
Logger getLogger();
void tearDown();
MetadataStore getMetadataStore();
File getDataFolder();
void getVersion();
}

View File

@ -0,0 +1,17 @@
package com.gmail.nossr50.mcmmo.api.platform.util;
import org.jetbrains.annotations.NotNull;
public class MetadataKey<V> {
private final String key;
public MetadataKey(@NotNull String key) {
this.key = key;
}
@NotNull
public String getKey() {
return key;
}
}

View File

@ -0,0 +1,39 @@
package com.gmail.nossr50.mcmmo.api.platform.util;
import com.gmail.nossr50.mcmmo.api.data.MMOEntity;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public interface MetadataStore {
/**
* @param holder holder of the metadata
* @param key key for the metdata
* @param <V> value type
* @return the metadata value or null
*/
@Nullable
<V> V getMetadata(@NotNull MMOEntity holder, @NotNull MetadataKey<V> key);
/**
* @param holder holder of the metdata
* @param key metadata key
* @param value metadata value
* @param <V> value type
* @return the existing metadata value if set, or null
*/
@Nullable
<V> V setMetadata(@NotNull MMOEntity holder, @NotNull MetadataKey<V> key, @Nullable V value);
/**
* @param holder holder of the metadata
* @param key metadata key
* @param <V> value type
* @return the removed metadata key
*/
@Nullable
<V> V removeMetadata(@NotNull MMOEntity holder, @NotNull MetadataKey<V> key);
}