mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-06-29 12:14:43 +02:00
Current progress on data accessors
Pushing because I started on stuff and don't wanna lose it...
This commit is contained in:
@ -0,0 +1,4 @@
|
||||
package com.gmail.nossr50.mcmmo.api.data;
|
||||
|
||||
public interface MMOEntity {
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
package com.gmail.nossr50.mcmmo.api.data;
|
||||
|
||||
public interface MMOPlayer<N> {
|
||||
public interface MMOPlayer<N> extends MMOEntity {
|
||||
|
||||
|
||||
N getPlayer();
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -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);
|
||||
|
||||
}
|
Reference in New Issue
Block a user