Copy paste/merge FAWE classes to this WorldEdit fork

- so certain people can look at the diff and complain about my sloppy code :(

Signed-off-by: Jesse Boyd <jessepaleg@gmail.com>
This commit is contained in:
Jesse Boyd
2018-08-13 00:03:07 +10:00
parent a920c77cb8
commit a629d15c74
994 changed files with 117583 additions and 10745 deletions

View File

@ -19,14 +19,14 @@
package com.sk89q.worldedit.entity;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.world.NbtValued;
import com.sk89q.worldedit.world.entity.EntityType;
import javax.annotation.Nullable;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Represents a mutable "snapshot" of an entity.
*

View File

@ -22,7 +22,8 @@ package com.sk89q.worldedit.entity;
import com.sk89q.worldedit.PlayerDirection;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extent.inventory.BlockBag;

View File

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