geforkt von Mirrors/FastAsyncWorldEdit
Merging upstream changes
Dieser Commit ist enthalten in:
Ursprung
85bfd16d7c
Commit
0d88a6bce2
@ -225,7 +225,7 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit
|
||||
if (te != null) {
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
readTileEntityIntoTag(te, tag); // Load data
|
||||
return new BaseBlock(state, (CompoundTag) toNative(tag));
|
||||
return state.toBaseBlock((CompoundTag) toNative(tag));
|
||||
}
|
||||
}
|
||||
|
||||
@ -402,17 +402,19 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit
|
||||
}
|
||||
return new CompoundTag(values);
|
||||
} else if (foreign instanceof NBTTagByte) {
|
||||
return new ByteTag(((NBTTagByte) foreign).asByte()); // getByte
|
||||
return new ByteTag(((NBTTagByte) foreign).asByte());
|
||||
} else if (foreign instanceof NBTTagByteArray) {
|
||||
return new ByteArrayTag(((NBTTagByteArray) foreign).c()); // data
|
||||
} else if (foreign instanceof NBTTagDouble) {
|
||||
return new DoubleTag(((NBTTagDouble) foreign).asDouble()); // getDouble
|
||||
} else if (foreign instanceof NBTTagFloat) {
|
||||
return new FloatTag(((NBTTagFloat) foreign).asFloat()); // getFloat
|
||||
return new FloatTag(((NBTTagFloat) foreign).asFloat());
|
||||
} else if (foreign instanceof NBTTagInt) {
|
||||
return new IntTag(((NBTTagInt) foreign).asInt()); // getInt
|
||||
return new IntTag(((NBTTagInt) foreign).asInt());
|
||||
} else if (foreign instanceof NBTTagIntArray) {
|
||||
return new IntArrayTag(((NBTTagIntArray) foreign).d()); // data
|
||||
} else if (foreign instanceof NBTTagLongArray) {
|
||||
return new LongArrayTag(((NBTTagLongArray) foreign).d()); // data
|
||||
} else if (foreign instanceof NBTTagList) {
|
||||
try {
|
||||
return toNativeList((NBTTagList) foreign);
|
||||
@ -421,11 +423,11 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit
|
||||
return new ListTag(ByteTag.class, new ArrayList<ByteTag>());
|
||||
}
|
||||
} else if (foreign instanceof NBTTagLong) {
|
||||
return new LongTag(((NBTTagLong) foreign).asLong()); // getLong
|
||||
return new LongTag(((NBTTagLong) foreign).asLong());
|
||||
} else if (foreign instanceof NBTTagShort) {
|
||||
return new ShortTag(((NBTTagShort) foreign).asShort()); // getShort
|
||||
return new ShortTag(((NBTTagShort) foreign).asShort());
|
||||
} else if (foreign instanceof NBTTagString) {
|
||||
return new StringTag(foreign.asString()); // data
|
||||
return new StringTag(foreign.asString());
|
||||
} else if (foreign instanceof NBTTagEnd) {
|
||||
return new EndTag();
|
||||
} else {
|
||||
@ -445,7 +447,7 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit
|
||||
*/
|
||||
public ListTag toNativeList(NBTTagList foreign) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
|
||||
List<Tag> values = new ArrayList<>();
|
||||
int type = foreign.getTypeId();
|
||||
int type = foreign.d();
|
||||
|
||||
List foreignList;
|
||||
foreignList = (List) nbtListTagListField.get(foreign);
|
||||
@ -488,9 +490,11 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit
|
||||
return new NBTTagInt(((IntTag) foreign).getValue());
|
||||
} else if (foreign instanceof IntArrayTag) {
|
||||
return new NBTTagIntArray(((IntArrayTag) foreign).getValue());
|
||||
} else if (foreign instanceof LongArrayTag) {
|
||||
return new NBTTagLongArray(((LongArrayTag) foreign).getValue());
|
||||
} else if (foreign instanceof ListTag) {
|
||||
NBTTagList tag = new NBTTagList();
|
||||
ListTag<?> foreignList = (ListTag) foreign;
|
||||
ListTag foreignList = (ListTag) foreign;
|
||||
for (Tag t : foreignList.getValue()) {
|
||||
tag.add(fromNative(t));
|
||||
}
|
||||
@ -552,4 +556,4 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,24 +19,22 @@
|
||||
|
||||
package com.sk89q.worldedit.bukkit;
|
||||
|
||||
import com.sk89q.worldedit.entity.metadata.Metadatable;
|
||||
import com.sk89q.worldedit.session.SessionKey;
|
||||
import com.sk89q.worldedit.util.auth.AuthorizationException;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.internal.cui.CUIEvent;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
public class BukkitCommandSender implements Actor, Metadatable {
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.internal.cui.CUIEvent;
|
||||
import com.sk89q.worldedit.session.SessionKey;
|
||||
import com.sk89q.worldedit.util.auth.AuthorizationException;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class BukkitCommandSender implements Actor {
|
||||
|
||||
/**
|
||||
* One time generated ID.
|
||||
@ -45,7 +43,6 @@ public class BukkitCommandSender implements Actor, Metadatable {
|
||||
|
||||
private CommandSender sender;
|
||||
private WorldEditPlugin plugin;
|
||||
private ConcurrentHashMap<String, Object> meta;
|
||||
|
||||
public BukkitCommandSender(WorldEditPlugin plugin, CommandSender sender) {
|
||||
checkNotNull(plugin);
|
||||
@ -56,12 +53,6 @@ public class BukkitCommandSender implements Actor, Metadatable {
|
||||
this.sender = sender;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized Map<String, Object> getMetaMap() {
|
||||
if (meta == null) meta = new ConcurrentHashMap<>();
|
||||
return meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUniqueId() {
|
||||
return DEFAULT_ID;
|
||||
|
@ -37,7 +37,7 @@ import javax.annotation.Nullable;
|
||||
/**
|
||||
* An adapter to adapt a Bukkit entity into a WorldEdit one.
|
||||
*/
|
||||
public class BukkitEntity implements Entity {
|
||||
class BukkitEntity implements Entity {
|
||||
|
||||
private final WeakReference<org.bukkit.entity.Entity> entityRef;
|
||||
|
||||
@ -46,7 +46,7 @@ public class BukkitEntity implements Entity {
|
||||
*
|
||||
* @param entity the entity
|
||||
*/
|
||||
public BukkitEntity(org.bukkit.entity.Entity entity) {
|
||||
BukkitEntity(org.bukkit.entity.Entity entity) {
|
||||
checkNotNull(entity);
|
||||
this.entityRef = new WeakReference<>(entity);
|
||||
}
|
||||
|
@ -18,16 +18,12 @@
|
||||
|
||||
package com.sk89q.worldedit.bukkit;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.sk89q.worldedit.*;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
import com.sk89q.worldedit.blocks.LazyBlock;
|
||||
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.history.change.BlockChange;
|
||||
@ -50,15 +46,19 @@ import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.Chest;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.DoubleChestInventory;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
public class BukkitWorld extends AbstractWorld {
|
||||
|
||||
@ -90,7 +90,7 @@ public class BukkitWorld extends AbstractWorld {
|
||||
List<com.sk89q.worldedit.entity.Entity> entities = new ArrayList<>();
|
||||
for (Entity ent : ents) {
|
||||
if (region.contains(BukkitAdapter.asBlockVector(ent.getLocation()))) {
|
||||
addEntities(ent, entities);
|
||||
entities.add(BukkitAdapter.adapt(ent));
|
||||
}
|
||||
}
|
||||
return entities;
|
||||
@ -100,43 +100,11 @@ public class BukkitWorld extends AbstractWorld {
|
||||
public List<com.sk89q.worldedit.entity.Entity> getEntities() {
|
||||
List<com.sk89q.worldedit.entity.Entity> list = new ArrayList<>();
|
||||
for (Entity entity : getWorld().getEntities()) {
|
||||
addEntities(entity, list);
|
||||
list.add(BukkitAdapter.adapt(entity));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private static com.sk89q.worldedit.entity.Entity adapt(Entity ent) {
|
||||
if (ent == null) return null;
|
||||
return BukkitAdapter.adapt(ent);
|
||||
}
|
||||
|
||||
private void addEntities(Entity ent, Collection<com.sk89q.worldedit.entity.Entity> ents) {
|
||||
ents.add(BukkitAdapter.adapt(ent));
|
||||
if (ent instanceof Player) {
|
||||
final Player plr = (Player) ent;
|
||||
com.sk89q.worldedit.entity.Entity left = adapt(((Player) ent).getShoulderEntityLeft());
|
||||
com.sk89q.worldedit.entity.Entity right = adapt(((Player) ent).getShoulderEntityRight());
|
||||
if (left != null) {
|
||||
ents.add(new DelegateEntity(left) {
|
||||
@Override
|
||||
public boolean remove() {
|
||||
plr.setShoulderEntityLeft(null);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
if (right != null) {
|
||||
ents.add(new DelegateEntity(right) {
|
||||
@Override
|
||||
public boolean remove() {
|
||||
plr.setShoulderEntityRight(null);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public com.sk89q.worldedit.entity.Entity createEntity(com.sk89q.worldedit.util.Location location, BaseEntity entity) {
|
||||
@ -196,7 +164,7 @@ public class BukkitWorld extends AbstractWorld {
|
||||
|
||||
@Override
|
||||
public boolean regenerate(Region region, EditSession editSession) {
|
||||
com.sk89q.worldedit.world.block.BlockStateHolder[] history = new com.sk89q.worldedit.world.block.BlockState[16 * 16 * (getMaxY() + 1)];
|
||||
BaseBlock[] history = new BaseBlock[16 * 16 * (getMaxY() + 1)];
|
||||
|
||||
for (BlockVector2 chunk : region.getChunks()) {
|
||||
BlockVector3 min = BlockVector3.at(chunk.getBlockX() * 16, 0, chunk.getBlockZ() * 16);
|
||||
@ -455,10 +423,7 @@ public class BukkitWorld extends AbstractWorld {
|
||||
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
||||
if (adapter != null) {
|
||||
try {
|
||||
int x = position.getBlockX();
|
||||
int y = position.getBlockY();
|
||||
int z = position.getBlockZ();
|
||||
return adapter.setBlock(getWorld().getChunkAt(x >> 4, z >> 4), x, y, z, block, true);
|
||||
return adapter.setBlock(BukkitAdapter.adapt(getWorld(), position), block, notifyAndLight);
|
||||
} catch (Exception e) {
|
||||
if (block instanceof BaseBlock && ((BaseBlock)block).getNbtData() != null) {
|
||||
logger.warning("Tried to set a corrupt tile entity at " + position.toString());
|
||||
|
@ -300,7 +300,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
for (int cx = scx; cx <= ecx; cx++) {
|
||||
final int finalCX = cx;
|
||||
final int finalCZ = cz;
|
||||
TaskManager.IMP.getPublicForkJoinPool().submit((Runnable) () -> {
|
||||
TaskManager.IMP.getPublicForkJoinPool().submit(() -> {
|
||||
try {
|
||||
FaweChunk toSend = getSnapshot(finalCX, finalCZ);
|
||||
toSend.setLoc(HeightMapMCAGenerator.this, finalCX + OX, finalCZ + OZ);
|
||||
|
@ -1,423 +1,430 @@
|
||||
package com.sk89q.jnbt;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* The {@code TAG_List} tag.
|
||||
*/
|
||||
public final class ListTag<T extends Tag> extends Tag {
|
||||
|
||||
private final Class<T> type;
|
||||
private final List<T> value;
|
||||
|
||||
/**
|
||||
* Creates the tag with an empty name.
|
||||
*
|
||||
* @param type the type of tag
|
||||
* @param value the value of the tag
|
||||
*/
|
||||
public ListTag(Class<T> type, List<T> value) {
|
||||
super();
|
||||
checkNotNull(value);
|
||||
this.type = type;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Object> getRaw() {
|
||||
ArrayList<Object> raw = new ArrayList<>();
|
||||
for (Tag t : value) {
|
||||
raw.add(t.getRaw());
|
||||
}
|
||||
return raw;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type of item in this list.
|
||||
*
|
||||
* @return The type of item in this list.
|
||||
*/
|
||||
public Class<T> getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<T> getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new list tag with this tag's name and type.
|
||||
*
|
||||
* @param list the new list
|
||||
* @return a new list tag
|
||||
*/
|
||||
public ListTag setValue(List<Tag> list) {
|
||||
return new ListTag(getType(), list);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the tag if it exists at the given index.
|
||||
*
|
||||
* @param index the index
|
||||
* @return the tag or null
|
||||
*/
|
||||
@Nullable
|
||||
public Tag getIfExists(int index) {
|
||||
try {
|
||||
return value.get(index);
|
||||
} catch (NoSuchElementException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a byte array named with the given index.
|
||||
*
|
||||
* <p>If the index does not exist or its value is not a byte array tag,
|
||||
* then an empty byte array will be returned.</p>
|
||||
*
|
||||
* @param index the index
|
||||
* @return a byte array
|
||||
*/
|
||||
public byte[] getByteArray(int index) {
|
||||
Tag tag = getIfExists(index);
|
||||
if (tag instanceof ByteArrayTag) {
|
||||
return ((ByteArrayTag) tag).getValue();
|
||||
} else {
|
||||
return new byte[0];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a byte named with the given index.
|
||||
*
|
||||
* <p>If the index does not exist or its value is not a byte tag,
|
||||
* then {@code 0} will be returned.</p>
|
||||
*
|
||||
* @param index the index
|
||||
* @return a byte
|
||||
*/
|
||||
public byte getByte(int index) {
|
||||
Tag tag = getIfExists(index);
|
||||
if (tag instanceof ByteTag) {
|
||||
return ((ByteTag) tag).getValue();
|
||||
} else {
|
||||
return (byte) 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a double named with the given index.
|
||||
*
|
||||
* <p>If the index does not exist or its value is not a double tag,
|
||||
* then {@code 0} will be returned.</p>
|
||||
*
|
||||
* @param index the index
|
||||
* @return a double
|
||||
*/
|
||||
public double getDouble(int index) {
|
||||
Tag tag = getIfExists(index);
|
||||
if (tag instanceof DoubleTag) {
|
||||
return ((DoubleTag) tag).getValue();
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a double named with the given index, even if it's another
|
||||
* type of number.
|
||||
*
|
||||
* <p>If the index does not exist or its value is not a number,
|
||||
* then {@code 0} will be returned.</p>
|
||||
*
|
||||
* @param index the index
|
||||
* @return a double
|
||||
*/
|
||||
public double asDouble(int index) {
|
||||
Tag tag = getIfExists(index);
|
||||
if (tag instanceof ByteTag) {
|
||||
return ((ByteTag) tag).getValue();
|
||||
|
||||
} else if (tag instanceof ShortTag) {
|
||||
return ((ShortTag) tag).getValue();
|
||||
|
||||
} else if (tag instanceof IntTag) {
|
||||
return ((IntTag) tag).getValue();
|
||||
|
||||
} else if (tag instanceof LongTag) {
|
||||
return ((LongTag) tag).getValue();
|
||||
|
||||
} else if (tag instanceof FloatTag) {
|
||||
return ((FloatTag) tag).getValue();
|
||||
|
||||
} else if (tag instanceof DoubleTag) {
|
||||
return ((DoubleTag) tag).getValue();
|
||||
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a float named with the given index.
|
||||
*
|
||||
* <p>If the index does not exist or its value is not a float tag,
|
||||
* then {@code 0} will be returned.</p>
|
||||
*
|
||||
* @param index the index
|
||||
* @return a float
|
||||
*/
|
||||
public float getFloat(int index) {
|
||||
Tag tag = getIfExists(index);
|
||||
if (tag instanceof FloatTag) {
|
||||
return ((FloatTag) tag).getValue();
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a {@code int[]} named with the given index.
|
||||
*
|
||||
* <p>If the index does not exist or its value is not an int array tag,
|
||||
* then an empty array will be returned.</p>
|
||||
*
|
||||
* @param index the index
|
||||
* @return an int array
|
||||
*/
|
||||
public int[] getIntArray(int index) {
|
||||
Tag tag = getIfExists(index);
|
||||
if (tag instanceof IntArrayTag) {
|
||||
return ((IntArrayTag) tag).getValue();
|
||||
} else {
|
||||
return new int[0];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an int named with the given index.
|
||||
*
|
||||
* <p>If the index does not exist or its value is not an int tag,
|
||||
* then {@code 0} will be returned.</p>
|
||||
*
|
||||
* @param index the index
|
||||
* @return an int
|
||||
*/
|
||||
public int getInt(int index) {
|
||||
Tag tag = getIfExists(index);
|
||||
if (tag instanceof IntTag) {
|
||||
return ((IntTag) tag).getValue();
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an int named with the given index, even if it's another
|
||||
* type of number.
|
||||
*
|
||||
* <p>If the index does not exist or its value is not a number,
|
||||
* then {@code 0} will be returned.</p>
|
||||
*
|
||||
* @param index the index
|
||||
* @return an int
|
||||
*/
|
||||
public int asInt(int index) {
|
||||
Tag tag = getIfExists(index);
|
||||
if (tag instanceof ByteTag) {
|
||||
return ((ByteTag) tag).getValue();
|
||||
|
||||
} else if (tag instanceof ShortTag) {
|
||||
return ((ShortTag) tag).getValue();
|
||||
|
||||
} else if (tag instanceof IntTag) {
|
||||
return ((IntTag) tag).getValue();
|
||||
|
||||
} else if (tag instanceof LongTag) {
|
||||
return ((LongTag) tag).getValue().intValue();
|
||||
|
||||
} else if (tag instanceof FloatTag) {
|
||||
return ((FloatTag) tag).getValue().intValue();
|
||||
|
||||
} else if (tag instanceof DoubleTag) {
|
||||
return ((DoubleTag) tag).getValue().intValue();
|
||||
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of tags named with the given index.
|
||||
*
|
||||
* <p>If the index does not exist or its value is not a list tag,
|
||||
* then an empty list will be returned.</p>
|
||||
*
|
||||
* @param index the index
|
||||
* @return a list of tags
|
||||
*/
|
||||
public List<Tag> getList(int index) {
|
||||
Tag tag = getIfExists(index);
|
||||
if (tag instanceof ListTag) {
|
||||
return ((ListTag) tag).getValue();
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a {@code TagList} named with the given index.
|
||||
*
|
||||
* <p>If the index does not exist or its value is not a list tag,
|
||||
* then an empty tag list will be returned.</p>
|
||||
*
|
||||
* @param index the index
|
||||
* @return a tag list instance
|
||||
*/
|
||||
public ListTag getListTag(int index) {
|
||||
Tag tag = getIfExists(index);
|
||||
if (tag instanceof ListTag) {
|
||||
return (ListTag) tag;
|
||||
} else {
|
||||
return new ListTag(StringTag.class, Collections.<Tag>emptyList());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of tags named with the given index.
|
||||
*
|
||||
* <p>If the index does not exist or its value is not a list tag,
|
||||
* then an empty list will be returned. If the given index references
|
||||
* a list but the list of of a different type, then an empty
|
||||
* list will also be returned.</p>
|
||||
*
|
||||
* @param index the index
|
||||
* @param listType the class of the contained type
|
||||
* @return a list of tags
|
||||
* @param <T> the NBT type
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends Tag> List<T> getList(int index, Class<T> listType) {
|
||||
Tag tag = getIfExists(index);
|
||||
if (tag instanceof ListTag) {
|
||||
ListTag listTag = (ListTag) tag;
|
||||
if (listTag.getType().equals(listType)) {
|
||||
return (List<T>) listTag.getValue();
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a long named with the given index.
|
||||
*
|
||||
* <p>If the index does not exist or its value is not a long tag,
|
||||
* then {@code 0} will be returned.</p>
|
||||
*
|
||||
* @param index the index
|
||||
* @return a long
|
||||
*/
|
||||
public long getLong(int index) {
|
||||
Tag tag = getIfExists(index);
|
||||
if (tag instanceof LongTag) {
|
||||
return ((LongTag) tag).getValue();
|
||||
} else {
|
||||
return 0L;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a long named with the given index, even if it's another
|
||||
* type of number.
|
||||
*
|
||||
* <p>If the index does not exist or its value is not a number,
|
||||
* then {@code 0} will be returned.</p>
|
||||
*
|
||||
* @param index the index
|
||||
* @return a long
|
||||
*/
|
||||
public long asLong(int index) {
|
||||
Tag tag = getIfExists(index);
|
||||
if (tag instanceof ByteTag) {
|
||||
return ((ByteTag) tag).getValue();
|
||||
|
||||
} else if (tag instanceof ShortTag) {
|
||||
return ((ShortTag) tag).getValue();
|
||||
|
||||
} else if (tag instanceof IntTag) {
|
||||
return ((IntTag) tag).getValue();
|
||||
|
||||
} else if (tag instanceof LongTag) {
|
||||
return ((LongTag) tag).getValue();
|
||||
|
||||
} else if (tag instanceof FloatTag) {
|
||||
return ((FloatTag) tag).getValue().longValue();
|
||||
|
||||
} else if (tag instanceof DoubleTag) {
|
||||
return ((DoubleTag) tag).getValue().longValue();
|
||||
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a short named with the given index.
|
||||
*
|
||||
* <p>If the index does not exist or its value is not a short tag,
|
||||
* then {@code 0} will be returned.</p>
|
||||
*
|
||||
* @param index the index
|
||||
* @return a short
|
||||
*/
|
||||
public short getShort(int index) {
|
||||
Tag tag = getIfExists(index);
|
||||
if (tag instanceof ShortTag) {
|
||||
return ((ShortTag) tag).getValue();
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a string named with the given index.
|
||||
*
|
||||
* <p>If the index does not exist or its value is not a string tag,
|
||||
* then {@code ""} will be returned.</p>
|
||||
*
|
||||
* @param index the index
|
||||
* @return a string
|
||||
*/
|
||||
public String getString(int index) {
|
||||
Tag tag = getIfExists(index);
|
||||
if (tag instanceof StringTag) {
|
||||
return ((StringTag) tag).getValue();
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder bldr = new StringBuilder();
|
||||
bldr.append("TAG_List").append(": ").append(value.size()).append(" entries of type ").append(NBTUtils.getTypeName(type)).append("\r\n{\r\n");
|
||||
for (Tag t : value) {
|
||||
bldr.append(" ").append(t.toString().replaceAll("\r\n", "\r\n ")).append("\r\n");
|
||||
}
|
||||
bldr.append("}");
|
||||
return bldr.toString();
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.jnbt;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* The {@code TAG_List} tag.
|
||||
*/
|
||||
public final class ListTag extends Tag {
|
||||
|
||||
private final Class<? extends Tag> type;
|
||||
private final List<Tag> value;
|
||||
|
||||
/**
|
||||
* Creates the tag with an empty name.
|
||||
*
|
||||
* @param type the type of tag
|
||||
* @param value the value of the tag
|
||||
*/
|
||||
public ListTag(Class<? extends Tag> type, List<? extends Tag> value) {
|
||||
super();
|
||||
checkNotNull(value);
|
||||
this.type = type;
|
||||
this.value = Collections.unmodifiableList(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type of item in this list.
|
||||
*
|
||||
* @return The type of item in this list.
|
||||
*/
|
||||
public Class<? extends Tag> getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Tag> getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new list tag with this tag's name and type.
|
||||
*
|
||||
* @param list the new list
|
||||
* @return a new list tag
|
||||
*/
|
||||
public ListTag setValue(List<Tag> list) {
|
||||
return new ListTag(getType(), list);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the tag if it exists at the given index.
|
||||
*
|
||||
* @param index the index
|
||||
* @return the tag or null
|
||||
*/
|
||||
@Nullable
|
||||
public Tag getIfExists(int index) {
|
||||
if (index >= value.size()) {
|
||||
return null;
|
||||
}
|
||||
return value.get(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a byte array named with the given index.
|
||||
*
|
||||
* <p>If the index does not exist or its value is not a byte array tag,
|
||||
* then an empty byte array will be returned.</p>
|
||||
*
|
||||
* @param index the index
|
||||
* @return a byte array
|
||||
*/
|
||||
public byte[] getByteArray(int index) {
|
||||
Tag tag = getIfExists(index);
|
||||
if (tag instanceof ByteArrayTag) {
|
||||
return ((ByteArrayTag) tag).getValue();
|
||||
} else {
|
||||
return new byte[0];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a byte named with the given index.
|
||||
*
|
||||
* <p>If the index does not exist or its value is not a byte tag,
|
||||
* then {@code 0} will be returned.</p>
|
||||
*
|
||||
* @param index the index
|
||||
* @return a byte
|
||||
*/
|
||||
public byte getByte(int index) {
|
||||
Tag tag = getIfExists(index);
|
||||
if (tag instanceof ByteTag) {
|
||||
return ((ByteTag) tag).getValue();
|
||||
} else {
|
||||
return (byte) 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a double named with the given index.
|
||||
*
|
||||
* <p>If the index does not exist or its value is not a double tag,
|
||||
* then {@code 0} will be returned.</p>
|
||||
*
|
||||
* @param index the index
|
||||
* @return a double
|
||||
*/
|
||||
public double getDouble(int index) {
|
||||
Tag tag = getIfExists(index);
|
||||
if (tag instanceof DoubleTag) {
|
||||
return ((DoubleTag) tag).getValue();
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a double named with the given index, even if it's another
|
||||
* type of number.
|
||||
*
|
||||
* <p>If the index does not exist or its value is not a number,
|
||||
* then {@code 0} will be returned.</p>
|
||||
*
|
||||
* @param index the index
|
||||
* @return a double
|
||||
*/
|
||||
public double asDouble(int index) {
|
||||
Tag tag = getIfExists(index);
|
||||
if (tag instanceof ByteTag) {
|
||||
return ((ByteTag) tag).getValue();
|
||||
|
||||
} else if (tag instanceof ShortTag) {
|
||||
return ((ShortTag) tag).getValue();
|
||||
|
||||
} else if (tag instanceof IntTag) {
|
||||
return ((IntTag) tag).getValue();
|
||||
|
||||
} else if (tag instanceof LongTag) {
|
||||
return ((LongTag) tag).getValue();
|
||||
|
||||
} else if (tag instanceof FloatTag) {
|
||||
return ((FloatTag) tag).getValue();
|
||||
|
||||
} else if (tag instanceof DoubleTag) {
|
||||
return ((DoubleTag) tag).getValue();
|
||||
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a float named with the given index.
|
||||
*
|
||||
* <p>If the index does not exist or its value is not a float tag,
|
||||
* then {@code 0} will be returned.</p>
|
||||
*
|
||||
* @param index the index
|
||||
* @return a float
|
||||
*/
|
||||
public float getFloat(int index) {
|
||||
Tag tag = getIfExists(index);
|
||||
if (tag instanceof FloatTag) {
|
||||
return ((FloatTag) tag).getValue();
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a {@code int[]} named with the given index.
|
||||
*
|
||||
* <p>If the index does not exist or its value is not an int array tag,
|
||||
* then an empty array will be returned.</p>
|
||||
*
|
||||
* @param index the index
|
||||
* @return an int array
|
||||
*/
|
||||
public int[] getIntArray(int index) {
|
||||
Tag tag = getIfExists(index);
|
||||
if (tag instanceof IntArrayTag) {
|
||||
return ((IntArrayTag) tag).getValue();
|
||||
} else {
|
||||
return new int[0];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an int named with the given index.
|
||||
*
|
||||
* <p>If the index does not exist or its value is not an int tag,
|
||||
* then {@code 0} will be returned.</p>
|
||||
*
|
||||
* @param index the index
|
||||
* @return an int
|
||||
*/
|
||||
public int getInt(int index) {
|
||||
Tag tag = getIfExists(index);
|
||||
if (tag instanceof IntTag) {
|
||||
return ((IntTag) tag).getValue();
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an int named with the given index, even if it's another
|
||||
* type of number.
|
||||
*
|
||||
* <p>If the index does not exist or its value is not a number,
|
||||
* then {@code 0} will be returned.</p>
|
||||
*
|
||||
* @param index the index
|
||||
* @return an int
|
||||
*/
|
||||
public int asInt(int index) {
|
||||
Tag tag = getIfExists(index);
|
||||
if (tag instanceof ByteTag) {
|
||||
return ((ByteTag) tag).getValue();
|
||||
|
||||
} else if (tag instanceof ShortTag) {
|
||||
return ((ShortTag) tag).getValue();
|
||||
|
||||
} else if (tag instanceof IntTag) {
|
||||
return ((IntTag) tag).getValue();
|
||||
|
||||
} else if (tag instanceof LongTag) {
|
||||
return ((LongTag) tag).getValue().intValue();
|
||||
|
||||
} else if (tag instanceof FloatTag) {
|
||||
return ((FloatTag) tag).getValue().intValue();
|
||||
|
||||
} else if (tag instanceof DoubleTag) {
|
||||
return ((DoubleTag) tag).getValue().intValue();
|
||||
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of tags named with the given index.
|
||||
*
|
||||
* <p>If the index does not exist or its value is not a list tag,
|
||||
* then an empty list will be returned.</p>
|
||||
*
|
||||
* @param index the index
|
||||
* @return a list of tags
|
||||
*/
|
||||
public List<Tag> getList(int index) {
|
||||
Tag tag = getIfExists(index);
|
||||
if (tag instanceof ListTag) {
|
||||
return ((ListTag) tag).getValue();
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a {@code TagList} named with the given index.
|
||||
*
|
||||
* <p>If the index does not exist or its value is not a list tag,
|
||||
* then an empty tag list will be returned.</p>
|
||||
*
|
||||
* @param index the index
|
||||
* @return a tag list instance
|
||||
*/
|
||||
public ListTag getListTag(int index) {
|
||||
Tag tag = getIfExists(index);
|
||||
if (tag instanceof ListTag) {
|
||||
return (ListTag) tag;
|
||||
} else {
|
||||
return new ListTag(StringTag.class, Collections.<Tag>emptyList());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of tags named with the given index.
|
||||
*
|
||||
* <p>If the index does not exist or its value is not a list tag,
|
||||
* then an empty list will be returned. If the given index references
|
||||
* a list but the list of of a different type, then an empty
|
||||
* list will also be returned.</p>
|
||||
*
|
||||
* @param index the index
|
||||
* @param listType the class of the contained type
|
||||
* @return a list of tags
|
||||
* @param <T> the NBT type
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends Tag> List<T> getList(int index, Class<T> listType) {
|
||||
Tag tag = getIfExists(index);
|
||||
if (tag instanceof ListTag) {
|
||||
ListTag listTag = (ListTag) tag;
|
||||
if (listTag.getType().equals(listType)) {
|
||||
return (List<T>) listTag.getValue();
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a long named with the given index.
|
||||
*
|
||||
* <p>If the index does not exist or its value is not a long tag,
|
||||
* then {@code 0} will be returned.</p>
|
||||
*
|
||||
* @param index the index
|
||||
* @return a long
|
||||
*/
|
||||
public long getLong(int index) {
|
||||
Tag tag = getIfExists(index);
|
||||
if (tag instanceof LongTag) {
|
||||
return ((LongTag) tag).getValue();
|
||||
} else {
|
||||
return 0L;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a long named with the given index, even if it's another
|
||||
* type of number.
|
||||
*
|
||||
* <p>If the index does not exist or its value is not a number,
|
||||
* then {@code 0} will be returned.</p>
|
||||
*
|
||||
* @param index the index
|
||||
* @return a long
|
||||
*/
|
||||
public long asLong(int index) {
|
||||
Tag tag = getIfExists(index);
|
||||
if (tag instanceof ByteTag) {
|
||||
return ((ByteTag) tag).getValue();
|
||||
|
||||
} else if (tag instanceof ShortTag) {
|
||||
return ((ShortTag) tag).getValue();
|
||||
|
||||
} else if (tag instanceof IntTag) {
|
||||
return ((IntTag) tag).getValue();
|
||||
|
||||
} else if (tag instanceof LongTag) {
|
||||
return ((LongTag) tag).getValue();
|
||||
|
||||
} else if (tag instanceof FloatTag) {
|
||||
return ((FloatTag) tag).getValue().longValue();
|
||||
|
||||
} else if (tag instanceof DoubleTag) {
|
||||
return ((DoubleTag) tag).getValue().longValue();
|
||||
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a short named with the given index.
|
||||
*
|
||||
* <p>If the index does not exist or its value is not a short tag,
|
||||
* then {@code 0} will be returned.</p>
|
||||
*
|
||||
* @param index the index
|
||||
* @return a short
|
||||
*/
|
||||
public short getShort(int index) {
|
||||
Tag tag = getIfExists(index);
|
||||
if (tag instanceof ShortTag) {
|
||||
return ((ShortTag) tag).getValue();
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a string named with the given index.
|
||||
*
|
||||
* <p>If the index does not exist or its value is not a string tag,
|
||||
* then {@code ""} will be returned.</p>
|
||||
*
|
||||
* @param index the index
|
||||
* @return a string
|
||||
*/
|
||||
public String getString(int index) {
|
||||
Tag tag = getIfExists(index);
|
||||
if (tag instanceof StringTag) {
|
||||
return ((StringTag) tag).getValue();
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder bldr = new StringBuilder();
|
||||
bldr.append("TAG_List").append(": ").append(value.size()).append(" entries of type ").append(NBTUtils.getTypeName(type)).append("\r\n{\r\n");
|
||||
for (Tag t : value) {
|
||||
bldr.append(" ").append(t.toString().replaceAll("\r\n", "\r\n ")).append("\r\n");
|
||||
}
|
||||
bldr.append("}");
|
||||
return bldr.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,90 +1,177 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit;
|
||||
|
||||
import com.sk89q.worldedit.util.logging.LogFormat;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldedit.world.item.ItemType;
|
||||
import com.sk89q.worldedit.world.item.ItemTypes;
|
||||
import com.sk89q.worldedit.world.registry.LegacyMapper;
|
||||
import com.sk89q.worldedit.world.snapshot.SnapshotRepository;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Represents WorldEdit's configuration.
|
||||
*/
|
||||
public abstract class LocalConfiguration {
|
||||
protected static final String[] defaultDisallowedBlocks = new String[] {};
|
||||
|
||||
public boolean profile = false;
|
||||
public Set<String> disallowedBlocks = new HashSet<>();
|
||||
public int defaultChangeLimit = -1;
|
||||
public int maxChangeLimit = -1;
|
||||
public int defaultMaxPolygonalPoints = -1;
|
||||
public int maxPolygonalPoints = 20;
|
||||
public int defaultMaxPolyhedronPoints = -1;
|
||||
public int maxPolyhedronPoints = 20;
|
||||
public String shellSaveType = "";
|
||||
public SnapshotRepository snapshotRepo = null;
|
||||
public int maxRadius = -1;
|
||||
public int maxSuperPickaxeSize = 5;
|
||||
public int maxBrushRadius = 100;
|
||||
public boolean logCommands = false;
|
||||
public String logFile = "";
|
||||
public String logFormat = LogFormat.DEFAULT_FORMAT;
|
||||
public boolean registerHelp = true; // what is the point of this, it's not even used
|
||||
public String wandItem = ItemTypes.WOODEN_AXE.getId();
|
||||
public boolean superPickaxeDrop = true;
|
||||
public boolean superPickaxeManyDrop = true;
|
||||
public boolean noDoubleSlash = false;
|
||||
public boolean useInventory = false;
|
||||
public boolean useInventoryOverride = false;
|
||||
public boolean useInventoryCreativeOverride = false;
|
||||
public boolean navigationUseGlass = true;
|
||||
public String navigationWand = ItemTypes.COMPASS.getId();
|
||||
public int navigationWandMaxDistance = 50;
|
||||
public int scriptTimeout = 3000;
|
||||
public Set<String> allowedDataCycleBlocks = new HashSet<>();
|
||||
public String saveDir = "schematics";
|
||||
public String scriptsDir = "craftscripts";
|
||||
public boolean showHelpInfo = true;
|
||||
public int butcherDefaultRadius = -1;
|
||||
public int butcherMaxRadius = -1;
|
||||
public boolean allowSymlinks = false;
|
||||
public boolean serverSideCUI = true;
|
||||
|
||||
/**
|
||||
* Load the configuration.
|
||||
*/
|
||||
public abstract void load();
|
||||
|
||||
/**
|
||||
* Get the working directory to work from.
|
||||
*
|
||||
* @return a working directory
|
||||
*/
|
||||
public File getWorkingDirectory() {
|
||||
return new File(".");
|
||||
}
|
||||
}
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.sk89q.worldedit.util.logging.LogFormat;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldedit.world.registry.LegacyMapper;
|
||||
import com.sk89q.worldedit.world.snapshot.SnapshotRepository;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Represents WorldEdit's configuration.
|
||||
*/
|
||||
public abstract class LocalConfiguration {
|
||||
|
||||
public boolean profile = false;
|
||||
public Set<String> disallowedBlocks = new HashSet<>();
|
||||
public int defaultChangeLimit = -1;
|
||||
public int maxChangeLimit = -1;
|
||||
public int defaultMaxPolygonalPoints = -1;
|
||||
public int maxPolygonalPoints = 20;
|
||||
public int defaultMaxPolyhedronPoints = -1;
|
||||
public int maxPolyhedronPoints = 20;
|
||||
public String shellSaveType = "";
|
||||
public SnapshotRepository snapshotRepo = null;
|
||||
public int maxRadius = -1;
|
||||
public int maxSuperPickaxeSize = 5;
|
||||
public int maxBrushRadius = 6;
|
||||
public boolean logCommands = false;
|
||||
public String logFile = "";
|
||||
public String logFormat = LogFormat.DEFAULT_FORMAT;
|
||||
public boolean registerHelp = true; // what is the point of this, it's not even used
|
||||
public String wandItem = "minecraft:wooden_axe";
|
||||
public boolean superPickaxeDrop = true;
|
||||
public boolean superPickaxeManyDrop = true;
|
||||
public boolean noDoubleSlash = false;
|
||||
public boolean useInventory = false;
|
||||
public boolean useInventoryOverride = false;
|
||||
public boolean useInventoryCreativeOverride = false;
|
||||
public boolean navigationUseGlass = true;
|
||||
public String navigationWand = "minecraft:compass";
|
||||
public int navigationWandMaxDistance = 50;
|
||||
public int scriptTimeout = 3000;
|
||||
public Set<String> allowedDataCycleBlocks = new HashSet<>();
|
||||
public String saveDir = "schematics";
|
||||
public String scriptsDir = "craftscripts";
|
||||
public boolean showHelpInfo = true;
|
||||
public int butcherDefaultRadius = -1;
|
||||
public int butcherMaxRadius = -1;
|
||||
public boolean allowSymlinks = false;
|
||||
public boolean serverSideCUI = true;
|
||||
|
||||
protected String[] getDefaultDisallowedBlocks() {
|
||||
List<BlockType> blockTypes = Lists.newArrayList(
|
||||
BlockTypes.OAK_SAPLING,
|
||||
BlockTypes.JUNGLE_SAPLING,
|
||||
BlockTypes.DARK_OAK_SAPLING,
|
||||
BlockTypes.SPRUCE_SAPLING,
|
||||
BlockTypes.BIRCH_SAPLING,
|
||||
BlockTypes.ACACIA_SAPLING,
|
||||
BlockTypes.BLACK_BED,
|
||||
BlockTypes.BLUE_BED,
|
||||
BlockTypes.BROWN_BED,
|
||||
BlockTypes.CYAN_BED,
|
||||
BlockTypes.GRAY_BED,
|
||||
BlockTypes.GREEN_BED,
|
||||
BlockTypes.LIGHT_BLUE_BED,
|
||||
BlockTypes.LIGHT_GRAY_BED,
|
||||
BlockTypes.LIME_BED,
|
||||
BlockTypes.MAGENTA_BED,
|
||||
BlockTypes.ORANGE_BED,
|
||||
BlockTypes.PINK_BED,
|
||||
BlockTypes.PURPLE_BED,
|
||||
BlockTypes.RED_BED,
|
||||
BlockTypes.WHITE_BED,
|
||||
BlockTypes.YELLOW_BED,
|
||||
BlockTypes.POWERED_RAIL,
|
||||
BlockTypes.DETECTOR_RAIL,
|
||||
BlockTypes.GRASS,
|
||||
BlockTypes.DEAD_BUSH,
|
||||
BlockTypes.MOVING_PISTON,
|
||||
BlockTypes.PISTON_HEAD,
|
||||
BlockTypes.SUNFLOWER,
|
||||
BlockTypes.ROSE_BUSH,
|
||||
BlockTypes.DANDELION,
|
||||
BlockTypes.POPPY,
|
||||
BlockTypes.BROWN_MUSHROOM,
|
||||
BlockTypes.RED_MUSHROOM,
|
||||
BlockTypes.TNT,
|
||||
BlockTypes.TORCH,
|
||||
BlockTypes.FIRE,
|
||||
BlockTypes.REDSTONE_WIRE,
|
||||
BlockTypes.WHEAT,
|
||||
BlockTypes.POTATOES,
|
||||
BlockTypes.CARROTS,
|
||||
BlockTypes.MELON_STEM,
|
||||
BlockTypes.PUMPKIN_STEM,
|
||||
BlockTypes.BEETROOTS,
|
||||
BlockTypes.RAIL,
|
||||
BlockTypes.LEVER,
|
||||
BlockTypes.REDSTONE_TORCH,
|
||||
BlockTypes.REDSTONE_WALL_TORCH,
|
||||
BlockTypes.REPEATER,
|
||||
BlockTypes.COMPARATOR,
|
||||
BlockTypes.STONE_BUTTON,
|
||||
BlockTypes.BIRCH_BUTTON,
|
||||
BlockTypes.ACACIA_BUTTON,
|
||||
BlockTypes.DARK_OAK_BUTTON,
|
||||
BlockTypes.JUNGLE_BUTTON,
|
||||
BlockTypes.OAK_BUTTON,
|
||||
BlockTypes.SPRUCE_BUTTON,
|
||||
BlockTypes.CACTUS,
|
||||
BlockTypes.SUGAR_CANE,
|
||||
// ores and stuff
|
||||
BlockTypes.BEDROCK
|
||||
);
|
||||
return blockTypes.stream().filter(Objects::nonNull).map(BlockType::getId).toArray(String[]::new);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the configuration.
|
||||
*/
|
||||
public abstract void load();
|
||||
|
||||
/**
|
||||
* Get the working directory to work from.
|
||||
*
|
||||
* @return a working directory
|
||||
*/
|
||||
public File getWorkingDirectory() {
|
||||
return new File(".");
|
||||
}
|
||||
|
||||
public String convertLegacyItem(String legacy) {
|
||||
String item = legacy;
|
||||
try {
|
||||
String[] splitter = item.split(":", 2);
|
||||
int id = 0;
|
||||
byte data = 0;
|
||||
if (splitter.length == 1) {
|
||||
id = Integer.parseInt(item);
|
||||
} else {
|
||||
id = Integer.parseInt(splitter[0]);
|
||||
data = Byte.parseByte(splitter[1]);
|
||||
}
|
||||
item = LegacyMapper.getInstance().getItemFromLegacy(id, data).getId();
|
||||
} catch (Throwable e) {
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -53,9 +53,9 @@ public class GeneralCommands {
|
||||
|
||||
@Command(
|
||||
aliases = { "/limit" },
|
||||
usage = "<limit>",
|
||||
usage = "[limit]",
|
||||
desc = "Modify block change limit",
|
||||
min = 1,
|
||||
min = 0,
|
||||
max = 1
|
||||
)
|
||||
@CommandPermissions("worldedit.limit")
|
||||
@ -64,7 +64,7 @@ public class GeneralCommands {
|
||||
LocalConfiguration config = worldEdit.getConfiguration();
|
||||
boolean mayDisable = player.hasPermission("worldedit.limit.unrestricted");
|
||||
|
||||
int limit = Math.max(-1, args.getInteger(0));
|
||||
int limit = args.argsLength() == 0 ? config.defaultChangeLimit : Math.max(-1, args.getInteger(0));
|
||||
if (!mayDisable && config.maxChangeLimit > -1) {
|
||||
if (limit > config.maxChangeLimit) {
|
||||
player.printError("Your maximum allowable limit is " + config.maxChangeLimit + ".");
|
||||
@ -164,7 +164,7 @@ public class GeneralCommands {
|
||||
boolean blocksOnly = args.hasFlag('b');
|
||||
boolean itemsOnly = args.hasFlag('i');
|
||||
|
||||
ItemType type = ItemTypes.parse(query);
|
||||
ItemType type = ItemTypes.get(query);
|
||||
|
||||
if (type != null) {
|
||||
actor.print(type.getId() + " (" + type.getName() + ")");
|
||||
|
@ -19,10 +19,7 @@
|
||||
|
||||
package com.sk89q.worldedit.entity;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||
@ -32,9 +29,12 @@ import com.sk89q.worldedit.util.Direction;
|
||||
import com.sk89q.worldedit.util.HandSide;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.gamemode.GameMode;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Represents a player
|
||||
*/
|
||||
|
@ -1,67 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
@ -19,12 +19,10 @@
|
||||
|
||||
package com.sk89q.worldedit.extension.factory.parser;
|
||||
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.blocks.BaseItem;
|
||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.extension.platform.Capability;
|
||||
import com.sk89q.worldedit.internal.registry.InputParser;
|
||||
import com.sk89q.worldedit.world.item.ItemType;
|
||||
import com.sk89q.worldedit.world.item.ItemTypes;
|
||||
@ -46,17 +44,8 @@ public class DefaultItemParser extends InputParser<BaseItem> {
|
||||
ItemType type;
|
||||
if (split.length == 1) {
|
||||
type = LegacyMapper.getInstance().getItemFromLegacy(Integer.parseInt(split[0]));
|
||||
} else if (MathMan.isInteger(split[0])) {
|
||||
type = LegacyMapper.getInstance().getItemFromLegacy(Integer.parseInt(split[0]), Integer.parseInt(split[1]));
|
||||
} else {
|
||||
type = ItemTypes.parse(input);
|
||||
if (type != null) {
|
||||
Integer legacy = LegacyMapper.getInstance().getLegacyCombined(type);
|
||||
if (legacy != null) {
|
||||
ItemType newType = LegacyMapper.getInstance().getItemFromLegacy(legacy >> 4, Integer.parseInt(split[1]));
|
||||
if (newType != null) type = newType;
|
||||
}
|
||||
}
|
||||
type = LegacyMapper.getInstance().getItemFromLegacy(Integer.parseInt(split[0]), Integer.parseInt(split[1]));
|
||||
}
|
||||
item = new BaseItem(type);
|
||||
} catch (NumberFormatException e) {
|
||||
|
@ -30,11 +30,13 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
|
||||
public class AbstractProperty<T> implements Property<T> {
|
||||
|
||||
private final PropertyKey key;
|
||||
private final String name;
|
||||
private final List<T> values;
|
||||
private String name;
|
||||
private List<T> values;
|
||||
|
||||
private final int bitMask;
|
||||
private final int bitMaskInverse;
|
||||
@ -75,6 +77,7 @@ public class AbstractProperty<T> implements Property<T> {
|
||||
return bitMask;
|
||||
}
|
||||
|
||||
//todo remove the following to allow for upstream compatibility.
|
||||
public <C extends AbstractProperty<T>> C withOffset(int bitOffset) {
|
||||
return (C) new AbstractProperty<>(name, values, bitOffset);
|
||||
}
|
||||
@ -116,6 +119,14 @@ public class AbstractProperty<T> implements Property<T> {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal method for name setting post-deserialise. Do not use.
|
||||
*/
|
||||
public void setName(final String name) {
|
||||
checkState(this.name == null, "name already set");
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass().getSimpleName() + "{name=" + name + "}";
|
||||
|
@ -19,6 +19,8 @@
|
||||
|
||||
package com.sk89q.worldedit.session;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
@ -27,9 +29,6 @@ import com.sk89q.worldedit.math.transform.Transform;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* Holds the clipboard and the current transform on the clipboard.
|
||||
*/
|
||||
@ -47,8 +46,6 @@ public class ClipboardHolder {
|
||||
this.clipboard = clipboard;
|
||||
}
|
||||
|
||||
protected ClipboardHolder() {}
|
||||
|
||||
/**
|
||||
* Get the clipboard.
|
||||
* <p>
|
||||
|
@ -1,135 +1,131 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.util;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.sk89q.util.yaml.YAMLProcessor;
|
||||
import com.sk89q.worldedit.LocalConfiguration;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.session.SessionManager;
|
||||
import com.sk89q.worldedit.util.report.Unreported;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldedit.world.item.ItemTypes;
|
||||
import com.sk89q.worldedit.world.snapshot.SnapshotRepository;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* A less simple implementation of {@link LocalConfiguration}
|
||||
* using YAML configuration files.
|
||||
*/
|
||||
public class YAMLConfiguration extends LocalConfiguration {
|
||||
|
||||
@Unreported protected final YAMLProcessor config;
|
||||
@Unreported protected final Logger logger;
|
||||
|
||||
public YAMLConfiguration(YAMLProcessor config, Logger logger) {
|
||||
this.config = config;
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
try {
|
||||
config.load();
|
||||
} catch (Throwable e) {
|
||||
logger.log(Level.WARNING, "Error loading WorldEdit configuration", e);
|
||||
}
|
||||
|
||||
profile = config.getBoolean("debug", profile);
|
||||
wandItem = ItemTypes.parse(config.getString("wand-item", wandItem)).getId();
|
||||
|
||||
defaultChangeLimit = Math.max(-1, config.getInt(
|
||||
"limits.max-blocks-changed.default", defaultChangeLimit));
|
||||
maxChangeLimit = Math.max(-1,
|
||||
config.getInt("limits.max-blocks-changed.maximum", maxChangeLimit));
|
||||
|
||||
defaultMaxPolygonalPoints = Math.max(-1,
|
||||
config.getInt("limits.max-polygonal-points.default", defaultMaxPolygonalPoints));
|
||||
maxPolygonalPoints = Math.max(-1,
|
||||
config.getInt("limits.max-polygonal-points.maximum", maxPolygonalPoints));
|
||||
|
||||
defaultMaxPolyhedronPoints = Math.max(-1, config.getInt("limits.max-polyhedron-points.default", defaultMaxPolyhedronPoints));
|
||||
maxPolyhedronPoints = Math.max(-1, config.getInt("limits.max-polyhedron-points.maximum", maxPolyhedronPoints));
|
||||
|
||||
maxRadius = Math.max(-1, config.getInt("limits.max-radius", maxRadius));
|
||||
maxBrushRadius = config.getInt("limits.max-brush-radius", maxBrushRadius);
|
||||
maxSuperPickaxeSize = Math.max(1, config.getInt(
|
||||
"limits.max-super-pickaxe-size", maxSuperPickaxeSize));
|
||||
|
||||
butcherDefaultRadius = Math.max(-1, config.getInt("limits.butcher-radius.default", butcherDefaultRadius));
|
||||
butcherMaxRadius = Math.max(-1, config.getInt("limits.butcher-radius.maximum", butcherMaxRadius));
|
||||
|
||||
disallowedBlocks =
|
||||
new HashSet<>(config.getStringList("limits.disallowed-blocks", Lists.newArrayList(defaultDisallowedBlocks)));
|
||||
allowedDataCycleBlocks =
|
||||
new HashSet<>(config.getStringList("limits.allowed-data-cycle-blocks", null));
|
||||
|
||||
registerHelp = config.getBoolean("register-help", true);
|
||||
logCommands = config.getBoolean("logging.log-commands", logCommands);
|
||||
logFile = config.getString("logging.file", logFile);
|
||||
logFormat = config.getString("logging.format", logFormat);
|
||||
|
||||
superPickaxeDrop = config.getBoolean("super-pickaxe.drop-items",
|
||||
superPickaxeDrop);
|
||||
superPickaxeManyDrop = config.getBoolean(
|
||||
"super-pickaxe.many-drop-items", superPickaxeManyDrop);
|
||||
|
||||
noDoubleSlash = config.getBoolean("no-double-slash", noDoubleSlash);
|
||||
|
||||
useInventory = config.getBoolean("use-inventory.enable", useInventory);
|
||||
useInventoryOverride = config.getBoolean("use-inventory.allow-override",
|
||||
useInventoryOverride);
|
||||
useInventoryCreativeOverride = config.getBoolean("use-inventory.creative-mode-overrides",
|
||||
useInventoryCreativeOverride);
|
||||
|
||||
navigationWand = ItemTypes.parse(config.getString("navigation-wand.item", navigationWand)).getId();
|
||||
navigationWandMaxDistance = config.getInt("navigation-wand.max-distance", navigationWandMaxDistance);
|
||||
navigationUseGlass = config.getBoolean("navigation.use-glass", navigationUseGlass);
|
||||
|
||||
scriptTimeout = config.getInt("scripting.timeout", scriptTimeout);
|
||||
scriptsDir = config.getString("scripting.dir", scriptsDir);
|
||||
|
||||
saveDir = config.getString("saving.dir", saveDir);
|
||||
|
||||
allowSymlinks = config.getBoolean("files.allow-symbolic-links", false);
|
||||
LocalSession.MAX_HISTORY_SIZE = Math.max(0, config.getInt("history.size", 15));
|
||||
SessionManager.EXPIRATION_GRACE = config.getInt("history.expiration", 10) * 60 * 1000;
|
||||
|
||||
showHelpInfo = config.getBoolean("show-help-on-first-use", true);
|
||||
|
||||
String snapshotsDir = config.getString("snapshots.directory", "");
|
||||
if (!snapshotsDir.isEmpty()) {
|
||||
snapshotRepo = new SnapshotRepository(snapshotsDir);
|
||||
}
|
||||
|
||||
String type = config.getString("shell-save-type", "").trim();
|
||||
shellSaveType = type.isEmpty() ? null : type;
|
||||
|
||||
}
|
||||
|
||||
public void unload() {
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.util;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.sk89q.util.yaml.YAMLProcessor;
|
||||
import com.sk89q.worldedit.LocalConfiguration;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.session.SessionManager;
|
||||
import com.sk89q.worldedit.util.report.Unreported;
|
||||
import com.sk89q.worldedit.world.snapshot.SnapshotRepository;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* A less simple implementation of {@link LocalConfiguration}
|
||||
* using YAML configuration files.
|
||||
*/
|
||||
public class YAMLConfiguration extends LocalConfiguration {
|
||||
|
||||
@Unreported protected final YAMLProcessor config;
|
||||
@Unreported protected final Logger logger;
|
||||
|
||||
public YAMLConfiguration(YAMLProcessor config, Logger logger) {
|
||||
this.config = config;
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
try {
|
||||
config.load();
|
||||
} catch (IOException e) {
|
||||
logger.log(Level.WARNING, "Error loading WorldEdit configuration", e);
|
||||
}
|
||||
|
||||
profile = config.getBoolean("debug", profile);
|
||||
wandItem = convertLegacyItem(config.getString("wand-item", wandItem));
|
||||
|
||||
defaultChangeLimit = Math.max(-1, config.getInt(
|
||||
"limits.max-blocks-changed.default", defaultChangeLimit));
|
||||
maxChangeLimit = Math.max(-1,
|
||||
config.getInt("limits.max-blocks-changed.maximum", maxChangeLimit));
|
||||
|
||||
defaultMaxPolygonalPoints = Math.max(-1,
|
||||
config.getInt("limits.max-polygonal-points.default", defaultMaxPolygonalPoints));
|
||||
maxPolygonalPoints = Math.max(-1,
|
||||
config.getInt("limits.max-polygonal-points.maximum", maxPolygonalPoints));
|
||||
|
||||
defaultMaxPolyhedronPoints = Math.max(-1, config.getInt("limits.max-polyhedron-points.default", defaultMaxPolyhedronPoints));
|
||||
maxPolyhedronPoints = Math.max(-1, config.getInt("limits.max-polyhedron-points.maximum", maxPolyhedronPoints));
|
||||
|
||||
maxRadius = Math.max(-1, config.getInt("limits.max-radius", maxRadius));
|
||||
maxBrushRadius = config.getInt("limits.max-brush-radius", maxBrushRadius);
|
||||
maxSuperPickaxeSize = Math.max(1, config.getInt(
|
||||
"limits.max-super-pickaxe-size", maxSuperPickaxeSize));
|
||||
|
||||
butcherDefaultRadius = Math.max(-1, config.getInt("limits.butcher-radius.default", butcherDefaultRadius));
|
||||
butcherMaxRadius = Math.max(-1, config.getInt("limits.butcher-radius.maximum", butcherMaxRadius));
|
||||
|
||||
disallowedBlocks = new HashSet<>(config.getStringList("limits.disallowed-blocks", Lists.newArrayList(getDefaultDisallowedBlocks())));
|
||||
allowedDataCycleBlocks =
|
||||
new HashSet<>(config.getStringList("limits.allowed-data-cycle-blocks", null));
|
||||
|
||||
registerHelp = config.getBoolean("register-help", true);
|
||||
logCommands = config.getBoolean("logging.log-commands", logCommands);
|
||||
logFile = config.getString("logging.file", logFile);
|
||||
logFormat = config.getString("logging.format", logFormat);
|
||||
|
||||
superPickaxeDrop = config.getBoolean("super-pickaxe.drop-items",
|
||||
superPickaxeDrop);
|
||||
superPickaxeManyDrop = config.getBoolean(
|
||||
"super-pickaxe.many-drop-items", superPickaxeManyDrop);
|
||||
|
||||
noDoubleSlash = config.getBoolean("no-double-slash", noDoubleSlash);
|
||||
|
||||
useInventory = config.getBoolean("use-inventory.enable", useInventory);
|
||||
useInventoryOverride = config.getBoolean("use-inventory.allow-override",
|
||||
useInventoryOverride);
|
||||
useInventoryCreativeOverride = config.getBoolean("use-inventory.creative-mode-overrides",
|
||||
useInventoryCreativeOverride);
|
||||
|
||||
navigationWand = convertLegacyItem(config.getString("navigation-wand.item", navigationWand));
|
||||
navigationWandMaxDistance = config.getInt("navigation-wand.max-distance", navigationWandMaxDistance);
|
||||
navigationUseGlass = config.getBoolean("navigation.use-glass", navigationUseGlass);
|
||||
|
||||
scriptTimeout = config.getInt("scripting.timeout", scriptTimeout);
|
||||
scriptsDir = config.getString("scripting.dir", scriptsDir);
|
||||
|
||||
saveDir = config.getString("saving.dir", saveDir);
|
||||
|
||||
allowSymlinks = config.getBoolean("files.allow-symbolic-links", false);
|
||||
LocalSession.MAX_HISTORY_SIZE = Math.max(0, config.getInt("history.size", 15));
|
||||
SessionManager.EXPIRATION_GRACE = config.getInt("history.expiration", 10) * 60 * 1000;
|
||||
|
||||
showHelpInfo = config.getBoolean("show-help-on-first-use", true);
|
||||
|
||||
String snapshotsDir = config.getString("snapshots.directory", "");
|
||||
if (!snapshotsDir.isEmpty()) {
|
||||
snapshotRepo = new SnapshotRepository(snapshotsDir);
|
||||
}
|
||||
|
||||
String type = config.getString("shell-save-type", "").trim();
|
||||
shellSaveType = type.isEmpty() ? null : type;
|
||||
|
||||
}
|
||||
|
||||
public void unload() {
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -230,7 +230,11 @@ public class BaseBlock implements BlockStateHolder<BaseBlock>, TileEntityBlock {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return getOrdinal();
|
||||
int ret = toImmutableState().hashCode() << 3;
|
||||
if (hasNbtData()) {
|
||||
ret += getNbtData().hashCode();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -116,7 +116,8 @@ public interface BlockStateHolder<T extends BlockStateHolder<T>> extends FawePat
|
||||
Map<Property<?>, Object> getStates();
|
||||
|
||||
/**
|
||||
* @deprecated use masks - not try to this fuzzy/non fuzzy state nonsense
|
||||
* Checks if the type is the same, and if the matched states are the same.
|
||||
*
|
||||
* @param o other block
|
||||
* @return true if equal
|
||||
*/
|
||||
@ -148,7 +149,9 @@ public interface BlockStateHolder<T extends BlockStateHolder<T>> extends FawePat
|
||||
if (getStates().isEmpty()) {
|
||||
return this.getBlockType().getId();
|
||||
} else {
|
||||
String properties = getStates().entrySet().stream().map(entry -> entry.getKey().getName() + "=" + entry.getValue().toString().toLowerCase()).collect(Collectors.joining(","));
|
||||
String properties =
|
||||
getStates().entrySet().stream().map(entry -> entry.getKey().getName() + "=" + entry.getValue().toString().toLowerCase()).collect(Collectors.joining(
|
||||
","));
|
||||
return this.getBlockType().getId() + "[" + properties + "]";
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +0,0 @@
|
||||
package com.sk89q.worldedit.world.block;
|
||||
|
||||
public class BlockStateRegistry {
|
||||
|
||||
}
|
@ -665,15 +665,15 @@ public class BlockTypes{
|
||||
public static final BlockType ZOMBIE_HEAD = register("minecraft:zombie_head", state -> state.with(state.getBlockType().getProperty("rotation"), 0));
|
||||
public static final BlockType ZOMBIE_WALL_HEAD = register("minecraft:zombie_wall_head", state -> state.with(state.getBlockType().getProperty("facing"), Direction.NORTH));
|
||||
|
||||
|
||||
|
||||
private static BlockType register(String id) {
|
||||
return register(new BlockType(id));
|
||||
}
|
||||
|
||||
|
||||
private static BlockType register(String id, Function<BlockState, BlockState> values) {
|
||||
return register(new BlockType(id, values));
|
||||
}
|
||||
|
||||
|
||||
public static BlockType register(BlockType type) {
|
||||
if(sortedRegistry == null) {
|
||||
sortedRegistry = new ArrayList<>();
|
||||
@ -685,7 +685,7 @@ public class BlockTypes{
|
||||
if(!sortedRegistry.contains(type))sortedRegistry.add(type);
|
||||
return internalRegister(type, sortedRegistry.indexOf(type));
|
||||
}
|
||||
|
||||
|
||||
private static ArrayList<BlockType> sortedRegistry;
|
||||
private static ArrayList<BlockState> stateList;
|
||||
public static BlockType[] values;
|
||||
@ -693,7 +693,7 @@ public class BlockTypes{
|
||||
private static Set<String> $NAMESPACES;
|
||||
@Deprecated public static int BIT_OFFSET; // Used internally
|
||||
@Deprecated public static int BIT_MASK; // Used internally
|
||||
|
||||
|
||||
private static BlockType internalRegister(BlockType blockType, final int internalId) {
|
||||
init(blockType, blockType.getId(), internalId, stateList);
|
||||
if(BlockType.REGISTRY.get(blockType.getId()) == null) BlockType.REGISTRY.register(blockType.getId(), blockType);
|
||||
@ -703,10 +703,6 @@ public class BlockTypes{
|
||||
return blockType;
|
||||
}
|
||||
|
||||
private static BlockType[] values() {
|
||||
return sortedRegistry.toArray(new BlockType[sortedRegistry.size()]);
|
||||
}
|
||||
|
||||
private static void init(BlockType type, String id, int internalId, ArrayList<BlockState> states) {
|
||||
try {
|
||||
type.setSettings(new Settings(type, id, internalId, states));
|
||||
@ -856,7 +852,7 @@ public class BlockTypes{
|
||||
public static final @Nullable BlockType get(final String id) {
|
||||
return BlockType.REGISTRY.get(id.toLowerCase());
|
||||
}
|
||||
|
||||
|
||||
public static final @Nullable BlockType get(final CharSequence id) {
|
||||
return BlockType.REGISTRY.get(id.toString().toLowerCase());
|
||||
}
|
||||
|
@ -266,10 +266,9 @@ public class AnvilChunk implements Chunk {
|
||||
if (state.getMaterial().hasContainer()) {
|
||||
CompoundTag tileEntity = getBlockTileEntity(position);
|
||||
if (tileEntity != null) {
|
||||
return new BaseBlock(state, tileEntity);
|
||||
return state.toBaseBlock(tileEntity);
|
||||
}
|
||||
}
|
||||
|
||||
return state.toBaseBlock();
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,6 @@ import com.sk89q.jnbt.NBTUtils;
|
||||
import com.sk89q.jnbt.Tag;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.DataException;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
@ -189,7 +188,9 @@ public class OldChunk implements Chunk {
|
||||
}
|
||||
if (state.getBlockType().getMaterial().hasContainer()) {
|
||||
CompoundTag tileEntity = getBlockTileEntity(position);
|
||||
if (tileEntity != null) return new BaseBlock(state, tileEntity);
|
||||
if (tileEntity != null) {
|
||||
return state.toBaseBlock(tileEntity);
|
||||
}
|
||||
}
|
||||
return state.toBaseBlock();
|
||||
}
|
||||
|
@ -63,4 +63,4 @@ public class EntityType {
|
||||
return obj instanceof EntityType && this.id.equals(((EntityType) obj).id);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -23,113 +23,105 @@ import javax.annotation.Nullable;
|
||||
|
||||
public class EntityTypes {
|
||||
|
||||
public static final EntityType AREA_EFFECT_CLOUD = register("minecraft:area_effect_cloud");
|
||||
public static final EntityType ARMOR_STAND = register("minecraft:armor_stand");
|
||||
public static final EntityType ARROW = register("minecraft:arrow");
|
||||
public static final EntityType BAT = register("minecraft:bat");
|
||||
public static final EntityType BLAZE = register("minecraft:blaze");
|
||||
public static final EntityType BOAT = register("minecraft:boat");
|
||||
public static final EntityType CAVE_SPIDER = register("minecraft:cave_spider");
|
||||
public static final EntityType CHEST_MINECART = register("minecraft:chest_minecart");
|
||||
public static final EntityType CHICKEN = register("minecraft:chicken");
|
||||
public static final EntityType COD = register("minecraft:cod");
|
||||
public static final EntityType COMMAND_BLOCK_MINECART = register("minecraft:command_block_minecart");
|
||||
public static final EntityType COW = register("minecraft:cow");
|
||||
public static final EntityType CREEPER = register("minecraft:creeper");
|
||||
public static final EntityType DOLPHIN = register("minecraft:dolphin");
|
||||
public static final EntityType DONKEY = register("minecraft:donkey");
|
||||
public static final EntityType DRAGON_FIREBALL = register("minecraft:dragon_fireball");
|
||||
public static final EntityType DROWNED = register("minecraft:drowned");
|
||||
public static final EntityType EGG = register("minecraft:egg");
|
||||
public static final EntityType ELDER_GUARDIAN = register("minecraft:elder_guardian");
|
||||
public static final EntityType END_CRYSTAL = register("minecraft:end_crystal");
|
||||
public static final EntityType ENDER_DRAGON = register("minecraft:ender_dragon");
|
||||
public static final EntityType ENDER_PEARL = register("minecraft:ender_pearl");
|
||||
public static final EntityType ENDERMAN = register("minecraft:enderman");
|
||||
public static final EntityType ENDERMITE = register("minecraft:endermite");
|
||||
public static final EntityType EVOKER = register("minecraft:evoker");
|
||||
public static final EntityType EVOKER_FANGS = register("minecraft:evoker_fangs");
|
||||
public static final EntityType EXPERIENCE_BOTTLE = register("minecraft:experience_bottle");
|
||||
public static final EntityType EXPERIENCE_ORB = register("minecraft:experience_orb");
|
||||
public static final EntityType EYE_OF_ENDER = register("minecraft:eye_of_ender");
|
||||
public static final EntityType FALLING_BLOCK = register("minecraft:falling_block");
|
||||
public static final EntityType FIREBALL = register("minecraft:fireball");
|
||||
public static final EntityType FIREWORK_ROCKET = register("minecraft:firework_rocket");
|
||||
public static final EntityType FISHING_BOBBER = register("minecraft:fishing_bobber");
|
||||
public static final EntityType FURNACE_MINECART = register("minecraft:furnace_minecart");
|
||||
public static final EntityType GHAST = register("minecraft:ghast");
|
||||
public static final EntityType GIANT = register("minecraft:giant");
|
||||
public static final EntityType GUARDIAN = register("minecraft:guardian");
|
||||
public static final EntityType HOPPER_MINECART = register("minecraft:hopper_minecart");
|
||||
public static final EntityType HORSE = register("minecraft:horse");
|
||||
public static final EntityType HUSK = register("minecraft:husk");
|
||||
public static final EntityType ILLUSIONER = register("minecraft:illusioner");
|
||||
public static final EntityType IRON_GOLEM = register("minecraft:iron_golem");
|
||||
public static final EntityType ITEM = register("minecraft:item");
|
||||
public static final EntityType ITEM_FRAME = register("minecraft:item_frame");
|
||||
public static final EntityType LEASH_KNOT = register("minecraft:leash_knot");
|
||||
public static final EntityType LIGHTNING_BOLT = register("minecraft:lightning_bolt");
|
||||
public static final EntityType LLAMA = register("minecraft:llama");
|
||||
public static final EntityType LLAMA_SPIT = register("minecraft:llama_spit");
|
||||
public static final EntityType MAGMA_CUBE = register("minecraft:magma_cube");
|
||||
public static final EntityType MINECART = register("minecraft:minecart");
|
||||
public static final EntityType MOOSHROOM = register("minecraft:mooshroom");
|
||||
public static final EntityType MULE = register("minecraft:mule");
|
||||
public static final EntityType OCELOT = register("minecraft:ocelot");
|
||||
public static final EntityType PAINTING = register("minecraft:painting");
|
||||
public static final EntityType PARROT = register("minecraft:parrot");
|
||||
public static final EntityType PHANTOM = register("minecraft:phantom");
|
||||
public static final EntityType PIG = register("minecraft:pig");
|
||||
public static final EntityType PLAYER = register("minecraft:player");
|
||||
public static final EntityType POLAR_BEAR = register("minecraft:polar_bear");
|
||||
public static final EntityType POTION = register("minecraft:potion");
|
||||
public static final EntityType PUFFERFISH = register("minecraft:pufferfish");
|
||||
public static final EntityType RABBIT = register("minecraft:rabbit");
|
||||
public static final EntityType SALMON = register("minecraft:salmon");
|
||||
public static final EntityType SHEEP = register("minecraft:sheep");
|
||||
public static final EntityType SHULKER = register("minecraft:shulker");
|
||||
public static final EntityType SHULKER_BULLET = register("minecraft:shulker_bullet");
|
||||
public static final EntityType SILVERFISH = register("minecraft:silverfish");
|
||||
public static final EntityType SKELETON = register("minecraft:skeleton");
|
||||
public static final EntityType SKELETON_HORSE = register("minecraft:skeleton_horse");
|
||||
public static final EntityType SLIME = register("minecraft:slime");
|
||||
public static final EntityType SMALL_FIREBALL = register("minecraft:small_fireball");
|
||||
public static final EntityType SNOW_GOLEM = register("minecraft:snow_golem");
|
||||
public static final EntityType SNOWBALL = register("minecraft:snowball");
|
||||
public static final EntityType SPAWNER_MINECART = register("minecraft:spawner_minecart");
|
||||
public static final EntityType SPECTRAL_ARROW = register("minecraft:spectral_arrow");
|
||||
public static final EntityType SPIDER = register("minecraft:spider");
|
||||
public static final EntityType SQUID = register("minecraft:squid");
|
||||
public static final EntityType STRAY = register("minecraft:stray");
|
||||
public static final EntityType TNT = register("minecraft:tnt");
|
||||
public static final EntityType TNT_MINECART = register("minecraft:tnt_minecart");
|
||||
public static final EntityType TRIDENT = register("minecraft:trident");
|
||||
public static final EntityType TROPICAL_FISH = register("minecraft:tropical_fish");
|
||||
public static final EntityType TURTLE = register("minecraft:turtle");
|
||||
public static final EntityType VEX = register("minecraft:vex");
|
||||
public static final EntityType VILLAGER = register("minecraft:villager");
|
||||
public static final EntityType VINDICATOR = register("minecraft:vindicator");
|
||||
public static final EntityType WITCH = register("minecraft:witch");
|
||||
public static final EntityType WITHER = register("minecraft:wither");
|
||||
public static final EntityType WITHER_SKELETON = register("minecraft:wither_skeleton");
|
||||
public static final EntityType WITHER_SKULL = register("minecraft:wither_skull");
|
||||
public static final EntityType WOLF = register("minecraft:wolf");
|
||||
public static final EntityType ZOMBIE = register("minecraft:zombie");
|
||||
public static final EntityType ZOMBIE_HORSE = register("minecraft:zombie_horse");
|
||||
public static final EntityType ZOMBIE_PIGMAN = register("minecraft:zombie_pigman");
|
||||
public static final EntityType ZOMBIE_VILLAGER = register("minecraft:zombie_villager");
|
||||
@Nullable public static final EntityType AREA_EFFECT_CLOUD = get("minecraft:area_effect_cloud");
|
||||
@Nullable public static final EntityType ARMOR_STAND = get("minecraft:armor_stand");
|
||||
@Nullable public static final EntityType ARROW = get("minecraft:arrow");
|
||||
@Nullable public static final EntityType BAT = get("minecraft:bat");
|
||||
@Nullable public static final EntityType BLAZE = get("minecraft:blaze");
|
||||
@Nullable public static final EntityType BOAT = get("minecraft:boat");
|
||||
@Nullable public static final EntityType CAVE_SPIDER = get("minecraft:cave_spider");
|
||||
@Nullable public static final EntityType CHEST_MINECART = get("minecraft:chest_minecart");
|
||||
@Nullable public static final EntityType CHICKEN = get("minecraft:chicken");
|
||||
@Nullable public static final EntityType COD = get("minecraft:cod");
|
||||
@Nullable public static final EntityType COMMAND_BLOCK_MINECART = get("minecraft:command_block_minecart");
|
||||
@Nullable public static final EntityType COW = get("minecraft:cow");
|
||||
@Nullable public static final EntityType CREEPER = get("minecraft:creeper");
|
||||
@Nullable public static final EntityType DOLPHIN = get("minecraft:dolphin");
|
||||
@Nullable public static final EntityType DONKEY = get("minecraft:donkey");
|
||||
@Nullable public static final EntityType DRAGON_FIREBALL = get("minecraft:dragon_fireball");
|
||||
@Nullable public static final EntityType DROWNED = get("minecraft:drowned");
|
||||
@Nullable public static final EntityType EGG = get("minecraft:egg");
|
||||
@Nullable public static final EntityType ELDER_GUARDIAN = get("minecraft:elder_guardian");
|
||||
@Nullable public static final EntityType END_CRYSTAL = get("minecraft:end_crystal");
|
||||
@Nullable public static final EntityType ENDER_DRAGON = get("minecraft:ender_dragon");
|
||||
@Nullable public static final EntityType ENDER_PEARL = get("minecraft:ender_pearl");
|
||||
@Nullable public static final EntityType ENDERMAN = get("minecraft:enderman");
|
||||
@Nullable public static final EntityType ENDERMITE = get("minecraft:endermite");
|
||||
@Nullable public static final EntityType EVOKER = get("minecraft:evoker");
|
||||
@Nullable public static final EntityType EVOKER_FANGS = get("minecraft:evoker_fangs");
|
||||
@Nullable public static final EntityType EXPERIENCE_BOTTLE = get("minecraft:experience_bottle");
|
||||
@Nullable public static final EntityType EXPERIENCE_ORB = get("minecraft:experience_orb");
|
||||
@Nullable public static final EntityType EYE_OF_ENDER = get("minecraft:eye_of_ender");
|
||||
@Nullable public static final EntityType FALLING_BLOCK = get("minecraft:falling_block");
|
||||
@Nullable public static final EntityType FIREBALL = get("minecraft:fireball");
|
||||
@Nullable public static final EntityType FIREWORK_ROCKET = get("minecraft:firework_rocket");
|
||||
@Nullable public static final EntityType FISHING_BOBBER = get("minecraft:fishing_bobber");
|
||||
@Nullable public static final EntityType FURNACE_MINECART = get("minecraft:furnace_minecart");
|
||||
@Nullable public static final EntityType GHAST = get("minecraft:ghast");
|
||||
@Nullable public static final EntityType GIANT = get("minecraft:giant");
|
||||
@Nullable public static final EntityType GUARDIAN = get("minecraft:guardian");
|
||||
@Nullable public static final EntityType HOPPER_MINECART = get("minecraft:hopper_minecart");
|
||||
@Nullable public static final EntityType HORSE = get("minecraft:horse");
|
||||
@Nullable public static final EntityType HUSK = get("minecraft:husk");
|
||||
@Nullable public static final EntityType ILLUSIONER = get("minecraft:illusioner");
|
||||
@Nullable public static final EntityType IRON_GOLEM = get("minecraft:iron_golem");
|
||||
@Nullable public static final EntityType ITEM = get("minecraft:item");
|
||||
@Nullable public static final EntityType ITEM_FRAME = get("minecraft:item_frame");
|
||||
@Nullable public static final EntityType LEASH_KNOT = get("minecraft:leash_knot");
|
||||
@Nullable public static final EntityType LIGHTNING_BOLT = get("minecraft:lightning_bolt");
|
||||
@Nullable public static final EntityType LLAMA = get("minecraft:llama");
|
||||
@Nullable public static final EntityType LLAMA_SPIT = get("minecraft:llama_spit");
|
||||
@Nullable public static final EntityType MAGMA_CUBE = get("minecraft:magma_cube");
|
||||
@Nullable public static final EntityType MINECART = get("minecraft:minecart");
|
||||
@Nullable public static final EntityType MOOSHROOM = get("minecraft:mooshroom");
|
||||
@Nullable public static final EntityType MULE = get("minecraft:mule");
|
||||
@Nullable public static final EntityType OCELOT = get("minecraft:ocelot");
|
||||
@Nullable public static final EntityType PAINTING = get("minecraft:painting");
|
||||
@Nullable public static final EntityType PARROT = get("minecraft:parrot");
|
||||
@Nullable public static final EntityType PHANTOM = get("minecraft:phantom");
|
||||
@Nullable public static final EntityType PIG = get("minecraft:pig");
|
||||
@Nullable public static final EntityType PLAYER = get("minecraft:player");
|
||||
@Nullable public static final EntityType POLAR_BEAR = get("minecraft:polar_bear");
|
||||
@Nullable public static final EntityType POTION = get("minecraft:potion");
|
||||
@Nullable public static final EntityType PUFFERFISH = get("minecraft:pufferfish");
|
||||
@Nullable public static final EntityType RABBIT = get("minecraft:rabbit");
|
||||
@Nullable public static final EntityType SALMON = get("minecraft:salmon");
|
||||
@Nullable public static final EntityType SHEEP = get("minecraft:sheep");
|
||||
@Nullable public static final EntityType SHULKER = get("minecraft:shulker");
|
||||
@Nullable public static final EntityType SHULKER_BULLET = get("minecraft:shulker_bullet");
|
||||
@Nullable public static final EntityType SILVERFISH = get("minecraft:silverfish");
|
||||
@Nullable public static final EntityType SKELETON = get("minecraft:skeleton");
|
||||
@Nullable public static final EntityType SKELETON_HORSE = get("minecraft:skeleton_horse");
|
||||
@Nullable public static final EntityType SLIME = get("minecraft:slime");
|
||||
@Nullable public static final EntityType SMALL_FIREBALL = get("minecraft:small_fireball");
|
||||
@Nullable public static final EntityType SNOW_GOLEM = get("minecraft:snow_golem");
|
||||
@Nullable public static final EntityType SNOWBALL = get("minecraft:snowball");
|
||||
@Nullable public static final EntityType SPAWNER_MINECART = get("minecraft:spawner_minecart");
|
||||
@Nullable public static final EntityType SPECTRAL_ARROW = get("minecraft:spectral_arrow");
|
||||
@Nullable public static final EntityType SPIDER = get("minecraft:spider");
|
||||
@Nullable public static final EntityType SQUID = get("minecraft:squid");
|
||||
@Nullable public static final EntityType STRAY = get("minecraft:stray");
|
||||
@Nullable public static final EntityType TNT = get("minecraft:tnt");
|
||||
@Nullable public static final EntityType TNT_MINECART = get("minecraft:tnt_minecart");
|
||||
@Nullable public static final EntityType TRIDENT = get("minecraft:trident");
|
||||
@Nullable public static final EntityType TROPICAL_FISH = get("minecraft:tropical_fish");
|
||||
@Nullable public static final EntityType TURTLE = get("minecraft:turtle");
|
||||
@Nullable public static final EntityType VEX = get("minecraft:vex");
|
||||
@Nullable public static final EntityType VILLAGER = get("minecraft:villager");
|
||||
@Nullable public static final EntityType VINDICATOR = get("minecraft:vindicator");
|
||||
@Nullable public static final EntityType WITCH = get("minecraft:witch");
|
||||
@Nullable public static final EntityType WITHER = get("minecraft:wither");
|
||||
@Nullable public static final EntityType WITHER_SKELETON = get("minecraft:wither_skeleton");
|
||||
@Nullable public static final EntityType WITHER_SKULL = get("minecraft:wither_skull");
|
||||
@Nullable public static final EntityType WOLF = get("minecraft:wolf");
|
||||
@Nullable public static final EntityType ZOMBIE = get("minecraft:zombie");
|
||||
@Nullable public static final EntityType ZOMBIE_HORSE = get("minecraft:zombie_horse");
|
||||
@Nullable public static final EntityType ZOMBIE_PIGMAN = get("minecraft:zombie_pigman");
|
||||
@Nullable public static final EntityType ZOMBIE_VILLAGER = get("minecraft:zombie_villager");
|
||||
|
||||
private EntityTypes() {
|
||||
}
|
||||
|
||||
private static EntityType register(final String id) {
|
||||
return register(new EntityType(id));
|
||||
}
|
||||
|
||||
public static EntityType register(final EntityType entityType) {
|
||||
return EntityType.REGISTRY.register(entityType.getId(), entityType);
|
||||
}
|
||||
|
||||
public static @Nullable EntityType get(final String id) {
|
||||
return EntityType.REGISTRY.get(id);
|
||||
}
|
||||
@ -201,4 +193,4 @@ public class EntityTypes {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Datei-Diff unterdrückt, da er zu groß ist
Diff laden
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren