Message updates

This commit is contained in:
MattBDev
2019-11-02 15:53:25 -04:00
parent 678a99667d
commit f262271519
26 changed files with 221 additions and 236 deletions

View File

@ -1,59 +1,59 @@
package com.sk89q.worldedit.entity;
import java.util.Map;
import org.jetbrains.annotations.NotNull;
public interface MapMetadatable extends Metadatable {
Map<String, Object> getRawMeta();
/**
* Set some session only metadata for the player
*
* @param key
* @param value
* {@inheritDoc}
*/
@Override
default void setMeta(String key, Object value) {
getRawMeta().put(key, value);
}
/**
* {@inheritDoc}
*/
@Override
default <T> T getAndSetMeta(String key, T value) {
return (T) getRawMeta().put(key, value);
}
/**
* {@inheritDoc}
*/
@Override
default boolean hasMeta() {
return !getRawMeta().isEmpty();
}
/**
* Get the metadata for a key.
*
* @param <V>
* @param key
* @return
* {@inheritDoc}
*/
@Override
default <V> V getMeta(String key) {
return (V) getRawMeta().get(key);
}
/**
* Get the metadata for a specific key (or return the default provided)
*
* @param key
* @param def
* @param <V>
* @return
* {@inheritDoc}
*/
default <V> V getMeta(String key, V def) {
@NotNull
@Override
default <V> V getMeta(String key, @NotNull V def) {
V value = (V) getRawMeta().get(key);
return value == null ? def : value;
}
/**
* Delete the metadata for a key.
* - metadata is session only
* - deleting other plugin's metadata may cause issues
*
* @param key
* {@inheritDoc}
*/
@Override
default <V> V deleteMeta(String key) {
return (V) getRawMeta().remove(key);
}

View File

@ -42,7 +42,7 @@ public interface Metadatable {
*/
@NotNull
default <V> V getMeta(String key, @NotNull V defaultValue) {
V value = (V) getMeta(key);
V value = getMeta(key);
return value == null ? defaultValue : value; }
/**