Merging upstream changes

This commit is contained in:
matt 2019-03-26 13:27:09 -04:00
parent 85bfd16d7c
commit 0d88a6bce2
23 changed files with 1708 additions and 1768 deletions

View File

@ -225,7 +225,7 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit
if (te != null) { if (te != null) {
NBTTagCompound tag = new NBTTagCompound(); NBTTagCompound tag = new NBTTagCompound();
readTileEntityIntoTag(te, tag); // Load data 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); return new CompoundTag(values);
} else if (foreign instanceof NBTTagByte) { } else if (foreign instanceof NBTTagByte) {
return new ByteTag(((NBTTagByte) foreign).asByte()); // getByte return new ByteTag(((NBTTagByte) foreign).asByte());
} else if (foreign instanceof NBTTagByteArray) { } else if (foreign instanceof NBTTagByteArray) {
return new ByteArrayTag(((NBTTagByteArray) foreign).c()); // data return new ByteArrayTag(((NBTTagByteArray) foreign).c()); // data
} else if (foreign instanceof NBTTagDouble) { } else if (foreign instanceof NBTTagDouble) {
return new DoubleTag(((NBTTagDouble) foreign).asDouble()); // getDouble return new DoubleTag(((NBTTagDouble) foreign).asDouble()); // getDouble
} else if (foreign instanceof NBTTagFloat) { } else if (foreign instanceof NBTTagFloat) {
return new FloatTag(((NBTTagFloat) foreign).asFloat()); // getFloat return new FloatTag(((NBTTagFloat) foreign).asFloat());
} else if (foreign instanceof NBTTagInt) { } else if (foreign instanceof NBTTagInt) {
return new IntTag(((NBTTagInt) foreign).asInt()); // getInt return new IntTag(((NBTTagInt) foreign).asInt());
} else if (foreign instanceof NBTTagIntArray) { } else if (foreign instanceof NBTTagIntArray) {
return new IntArrayTag(((NBTTagIntArray) foreign).d()); // data return new IntArrayTag(((NBTTagIntArray) foreign).d()); // data
} else if (foreign instanceof NBTTagLongArray) {
return new LongArrayTag(((NBTTagLongArray) foreign).d()); // data
} else if (foreign instanceof NBTTagList) { } else if (foreign instanceof NBTTagList) {
try { try {
return toNativeList((NBTTagList) foreign); 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>()); return new ListTag(ByteTag.class, new ArrayList<ByteTag>());
} }
} else if (foreign instanceof NBTTagLong) { } else if (foreign instanceof NBTTagLong) {
return new LongTag(((NBTTagLong) foreign).asLong()); // getLong return new LongTag(((NBTTagLong) foreign).asLong());
} else if (foreign instanceof NBTTagShort) { } else if (foreign instanceof NBTTagShort) {
return new ShortTag(((NBTTagShort) foreign).asShort()); // getShort return new ShortTag(((NBTTagShort) foreign).asShort());
} else if (foreign instanceof NBTTagString) { } else if (foreign instanceof NBTTagString) {
return new StringTag(foreign.asString()); // data return new StringTag(foreign.asString());
} else if (foreign instanceof NBTTagEnd) { } else if (foreign instanceof NBTTagEnd) {
return new EndTag(); return new EndTag();
} else { } 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 { public ListTag toNativeList(NBTTagList foreign) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
List<Tag> values = new ArrayList<>(); List<Tag> values = new ArrayList<>();
int type = foreign.getTypeId(); int type = foreign.d();
List foreignList; List foreignList;
foreignList = (List) nbtListTagListField.get(foreign); 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()); return new NBTTagInt(((IntTag) foreign).getValue());
} else if (foreign instanceof IntArrayTag) { } else if (foreign instanceof IntArrayTag) {
return new NBTTagIntArray(((IntArrayTag) foreign).getValue()); return new NBTTagIntArray(((IntArrayTag) foreign).getValue());
} else if (foreign instanceof LongArrayTag) {
return new NBTTagLongArray(((LongArrayTag) foreign).getValue());
} else if (foreign instanceof ListTag) { } else if (foreign instanceof ListTag) {
NBTTagList tag = new NBTTagList(); NBTTagList tag = new NBTTagList();
ListTag<?> foreignList = (ListTag) foreign; ListTag foreignList = (ListTag) foreign;
for (Tag t : foreignList.getValue()) { for (Tag t : foreignList.getValue()) {
tag.add(fromNative(t)); tag.add(fromNative(t));
} }
@ -552,4 +556,4 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
} }

View File

@ -19,24 +19,22 @@
package com.sk89q.worldedit.bukkit; 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.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull; 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. * One time generated ID.
@ -45,7 +43,6 @@ public class BukkitCommandSender implements Actor, Metadatable {
private CommandSender sender; private CommandSender sender;
private WorldEditPlugin plugin; private WorldEditPlugin plugin;
private ConcurrentHashMap<String, Object> meta;
public BukkitCommandSender(WorldEditPlugin plugin, CommandSender sender) { public BukkitCommandSender(WorldEditPlugin plugin, CommandSender sender) {
checkNotNull(plugin); checkNotNull(plugin);
@ -56,12 +53,6 @@ public class BukkitCommandSender implements Actor, Metadatable {
this.sender = sender; this.sender = sender;
} }
@Override
public synchronized Map<String, Object> getMetaMap() {
if (meta == null) meta = new ConcurrentHashMap<>();
return meta;
}
@Override @Override
public UUID getUniqueId() { public UUID getUniqueId() {
return DEFAULT_ID; return DEFAULT_ID;

View File

@ -37,7 +37,7 @@ import javax.annotation.Nullable;
/** /**
* An adapter to adapt a Bukkit entity into a WorldEdit one. * 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; private final WeakReference<org.bukkit.entity.Entity> entityRef;
@ -46,7 +46,7 @@ public class BukkitEntity implements Entity {
* *
* @param entity the entity * @param entity the entity
*/ */
public BukkitEntity(org.bukkit.entity.Entity entity) { BukkitEntity(org.bukkit.entity.Entity entity) {
checkNotNull(entity); checkNotNull(entity);
this.entityRef = new WeakReference<>(entity); this.entityRef = new WeakReference<>(entity);
} }

View File

@ -18,16 +18,12 @@
package com.sk89q.worldedit.bukkit; 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.EditSession;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.blocks.BaseItemStack; import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.blocks.LazyBlock;
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter; import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.history.change.BlockChange; 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.BlockState;
import org.bukkit.block.Chest; import org.bukkit.block.Chest;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.DoubleChestInventory; import org.bukkit.inventory.DoubleChestInventory;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.lang.ref.WeakReference; 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.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import static com.google.common.base.Preconditions.checkNotNull;
public class BukkitWorld extends AbstractWorld { public class BukkitWorld extends AbstractWorld {
@ -90,7 +90,7 @@ public class BukkitWorld extends AbstractWorld {
List<com.sk89q.worldedit.entity.Entity> entities = new ArrayList<>(); List<com.sk89q.worldedit.entity.Entity> entities = new ArrayList<>();
for (Entity ent : ents) { for (Entity ent : ents) {
if (region.contains(BukkitAdapter.asBlockVector(ent.getLocation()))) { if (region.contains(BukkitAdapter.asBlockVector(ent.getLocation()))) {
addEntities(ent, entities); entities.add(BukkitAdapter.adapt(ent));
} }
} }
return entities; return entities;
@ -100,43 +100,11 @@ public class BukkitWorld extends AbstractWorld {
public List<com.sk89q.worldedit.entity.Entity> getEntities() { public List<com.sk89q.worldedit.entity.Entity> getEntities() {
List<com.sk89q.worldedit.entity.Entity> list = new ArrayList<>(); List<com.sk89q.worldedit.entity.Entity> list = new ArrayList<>();
for (Entity entity : getWorld().getEntities()) { for (Entity entity : getWorld().getEntities()) {
addEntities(entity, list); list.add(BukkitAdapter.adapt(entity));
} }
return list; 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 @Nullable
@Override @Override
public com.sk89q.worldedit.entity.Entity createEntity(com.sk89q.worldedit.util.Location location, BaseEntity entity) { 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 @Override
public boolean regenerate(Region region, EditSession editSession) { 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()) { for (BlockVector2 chunk : region.getChunks()) {
BlockVector3 min = BlockVector3.at(chunk.getBlockX() * 16, 0, chunk.getBlockZ() * 16); 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(); BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
if (adapter != null) { if (adapter != null) {
try { try {
int x = position.getBlockX(); return adapter.setBlock(BukkitAdapter.adapt(getWorld(), position), block, notifyAndLight);
int y = position.getBlockY();
int z = position.getBlockZ();
return adapter.setBlock(getWorld().getChunkAt(x >> 4, z >> 4), x, y, z, block, true);
} catch (Exception e) { } catch (Exception e) {
if (block instanceof BaseBlock && ((BaseBlock)block).getNbtData() != null) { if (block instanceof BaseBlock && ((BaseBlock)block).getNbtData() != null) {
logger.warning("Tried to set a corrupt tile entity at " + position.toString()); logger.warning("Tried to set a corrupt tile entity at " + position.toString());

View File

@ -300,7 +300,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
for (int cx = scx; cx <= ecx; cx++) { for (int cx = scx; cx <= ecx; cx++) {
final int finalCX = cx; final int finalCX = cx;
final int finalCZ = cz; final int finalCZ = cz;
TaskManager.IMP.getPublicForkJoinPool().submit((Runnable) () -> { TaskManager.IMP.getPublicForkJoinPool().submit(() -> {
try { try {
FaweChunk toSend = getSnapshot(finalCX, finalCZ); FaweChunk toSend = getSnapshot(finalCX, finalCZ);
toSend.setLoc(HeightMapMCAGenerator.this, finalCX + OX, finalCZ + OZ); toSend.setLoc(HeightMapMCAGenerator.this, finalCX + OX, finalCZ + OZ);

View File

@ -1,423 +1,430 @@
package com.sk89q.jnbt; /*
* WorldEdit, a Minecraft world manipulation toolkit
import static com.google.common.base.Preconditions.checkNotNull; * Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
import java.util.ArrayList; *
import java.util.Collections; * This program is free software: you can redistribute it and/or modify it
import java.util.List; * under the terms of the GNU Lesser General Public License as published by the
import java.util.NoSuchElementException; * Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
import javax.annotation.Nullable; *
* This program is distributed in the hope that it will be useful, but WITHOUT
/** * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* The {@code TAG_List} tag. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
*/ * for more details.
public final class ListTag<T extends Tag> extends Tag { *
* You should have received a copy of the GNU Lesser General Public License
private final Class<T> type; * along with this program. If not, see <http://www.gnu.org/licenses/>.
private final List<T> value; */
/** package com.sk89q.jnbt;
* Creates the tag with an empty name.
* import static com.google.common.base.Preconditions.checkNotNull;
* @param type the type of tag
* @param value the value of the tag import java.util.Collections;
*/ import java.util.List;
public ListTag(Class<T> type, List<T> value) {
super(); import javax.annotation.Nullable;
checkNotNull(value);
this.type = type; /**
this.value = value; * The {@code TAG_List} tag.
} */
public final class ListTag extends Tag {
@Override
public List<Object> getRaw() { private final Class<? extends Tag> type;
ArrayList<Object> raw = new ArrayList<>(); private final List<Tag> value;
for (Tag t : value) {
raw.add(t.getRaw()); /**
} * Creates the tag with an empty name.
return raw; *
} * @param type the type of tag
* @param value the value of the tag
/** */
* Gets the type of item in this list. public ListTag(Class<? extends Tag> type, List<? extends Tag> value) {
* super();
* @return The type of item in this list. checkNotNull(value);
*/ this.type = type;
public Class<T> getType() { this.value = Collections.unmodifiableList(value);
return type; }
}
/**
@Override * Gets the type of item in this list.
public List<T> getValue() { *
return value; * @return The type of item in this list.
} */
public Class<? extends Tag> getType() {
/** return type;
* Create a new list tag with this tag's name and type. }
*
* @param list the new list @Override
* @return a new list tag public List<Tag> getValue() {
*/ return value;
public ListTag setValue(List<Tag> list) { }
return new ListTag(getType(), list);
} /**
* Create a new list tag with this tag's name and type.
/** *
* Get the tag if it exists at the given index. * @param list the new list
* * @return a new list tag
* @param index the index */
* @return the tag or null public ListTag setValue(List<Tag> list) {
*/ return new ListTag(getType(), list);
@Nullable }
public Tag getIfExists(int index) {
try { /**
return value.get(index); * Get the tag if it exists at the given index.
} catch (NoSuchElementException e) { *
return null; * @param index the index
} * @return the tag or null
} */
@Nullable
/** public Tag getIfExists(int index) {
* Get a byte array named with the given index. if (index >= value.size()) {
* return null;
* <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> return value.get(index);
* }
* @param index the index
* @return a byte array /**
*/ * Get a byte array named with the given index.
public byte[] getByteArray(int index) { *
Tag tag = getIfExists(index); * <p>If the index does not exist or its value is not a byte array tag,
if (tag instanceof ByteArrayTag) { * then an empty byte array will be returned.</p>
return ((ByteArrayTag) tag).getValue(); *
} else { * @param index the index
return new byte[0]; * @return a byte array
} */
} public byte[] getByteArray(int index) {
Tag tag = getIfExists(index);
/** if (tag instanceof ByteArrayTag) {
* Get a byte named with the given index. return ((ByteArrayTag) tag).getValue();
* } else {
* <p>If the index does not exist or its value is not a byte tag, return new byte[0];
* then {@code 0} will be returned.</p> }
* }
* @param index the index
* @return a byte /**
*/ * Get a byte named with the given index.
public byte getByte(int index) { *
Tag tag = getIfExists(index); * <p>If the index does not exist or its value is not a byte tag,
if (tag instanceof ByteTag) { * then {@code 0} will be returned.</p>
return ((ByteTag) tag).getValue(); *
} else { * @param index the index
return (byte) 0; * @return a byte
} */
} public byte getByte(int index) {
Tag tag = getIfExists(index);
/** if (tag instanceof ByteTag) {
* Get a double named with the given index. return ((ByteTag) tag).getValue();
* } else {
* <p>If the index does not exist or its value is not a double tag, return (byte) 0;
* then {@code 0} will be returned.</p> }
* }
* @param index the index
* @return a double /**
*/ * Get a double named with the given index.
public double getDouble(int index) { *
Tag tag = getIfExists(index); * <p>If the index does not exist or its value is not a double tag,
if (tag instanceof DoubleTag) { * then {@code 0} will be returned.</p>
return ((DoubleTag) tag).getValue(); *
} else { * @param index the index
return 0; * @return a double
} */
} public double getDouble(int index) {
Tag tag = getIfExists(index);
/** if (tag instanceof DoubleTag) {
* Get a double named with the given index, even if it's another return ((DoubleTag) tag).getValue();
* type of number. } else {
* return 0;
* <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 * Get a double named with the given index, even if it's another
*/ * type of number.
public double asDouble(int index) { *
Tag tag = getIfExists(index); * <p>If the index does not exist or its value is not a number,
if (tag instanceof ByteTag) { * then {@code 0} will be returned.</p>
return ((ByteTag) tag).getValue(); *
* @param index the index
} else if (tag instanceof ShortTag) { * @return a double
return ((ShortTag) tag).getValue(); */
public double asDouble(int index) {
} else if (tag instanceof IntTag) { Tag tag = getIfExists(index);
return ((IntTag) tag).getValue(); if (tag instanceof ByteTag) {
return ((ByteTag) tag).getValue();
} else if (tag instanceof LongTag) {
return ((LongTag) tag).getValue(); } else if (tag instanceof ShortTag) {
return ((ShortTag) tag).getValue();
} else if (tag instanceof FloatTag) {
return ((FloatTag) tag).getValue(); } else if (tag instanceof IntTag) {
return ((IntTag) tag).getValue();
} else if (tag instanceof DoubleTag) {
return ((DoubleTag) tag).getValue(); } else if (tag instanceof LongTag) {
return ((LongTag) tag).getValue();
} else {
return 0; } else if (tag instanceof FloatTag) {
} return ((FloatTag) tag).getValue();
}
} else if (tag instanceof DoubleTag) {
/** return ((DoubleTag) tag).getValue();
* Get a float named with the given index.
* } else {
* <p>If the index does not exist or its value is not a float tag, return 0;
* then {@code 0} will be returned.</p> }
* }
* @param index the index
* @return a float /**
*/ * Get a float named with the given index.
public float getFloat(int index) { *
Tag tag = getIfExists(index); * <p>If the index does not exist or its value is not a float tag,
if (tag instanceof FloatTag) { * then {@code 0} will be returned.</p>
return ((FloatTag) tag).getValue(); *
} else { * @param index the index
return 0; * @return a float
} */
} public float getFloat(int index) {
Tag tag = getIfExists(index);
/** if (tag instanceof FloatTag) {
* Get a {@code int[]} named with the given index. return ((FloatTag) tag).getValue();
* } else {
* <p>If the index does not exist or its value is not an int array tag, return 0;
* then an empty array will be returned.</p> }
* }
* @param index the index
* @return an int array /**
*/ * Get a {@code int[]} named with the given index.
public int[] getIntArray(int index) { *
Tag tag = getIfExists(index); * <p>If the index does not exist or its value is not an int array tag,
if (tag instanceof IntArrayTag) { * then an empty array will be returned.</p>
return ((IntArrayTag) tag).getValue(); *
} else { * @param index the index
return new int[0]; * @return an int array
} */
} public int[] getIntArray(int index) {
Tag tag = getIfExists(index);
/** if (tag instanceof IntArrayTag) {
* Get an int named with the given index. return ((IntArrayTag) tag).getValue();
* } else {
* <p>If the index does not exist or its value is not an int tag, return new int[0];
* then {@code 0} will be returned.</p> }
* }
* @param index the index
* @return an int /**
*/ * Get an int named with the given index.
public int getInt(int index) { *
Tag tag = getIfExists(index); * <p>If the index does not exist or its value is not an int tag,
if (tag instanceof IntTag) { * then {@code 0} will be returned.</p>
return ((IntTag) tag).getValue(); *
} else { * @param index the index
return 0; * @return an int
} */
} public int getInt(int index) {
Tag tag = getIfExists(index);
/** if (tag instanceof IntTag) {
* Get an int named with the given index, even if it's another return ((IntTag) tag).getValue();
* type of number. } else {
* return 0;
* <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 * Get an int named with the given index, even if it's another
*/ * type of number.
public int asInt(int index) { *
Tag tag = getIfExists(index); * <p>If the index does not exist or its value is not a number,
if (tag instanceof ByteTag) { * then {@code 0} will be returned.</p>
return ((ByteTag) tag).getValue(); *
* @param index the index
} else if (tag instanceof ShortTag) { * @return an int
return ((ShortTag) tag).getValue(); */
public int asInt(int index) {
} else if (tag instanceof IntTag) { Tag tag = getIfExists(index);
return ((IntTag) tag).getValue(); if (tag instanceof ByteTag) {
return ((ByteTag) tag).getValue();
} else if (tag instanceof LongTag) {
return ((LongTag) tag).getValue().intValue(); } else if (tag instanceof ShortTag) {
return ((ShortTag) tag).getValue();
} else if (tag instanceof FloatTag) {
return ((FloatTag) tag).getValue().intValue(); } else if (tag instanceof IntTag) {
return ((IntTag) tag).getValue();
} else if (tag instanceof DoubleTag) {
return ((DoubleTag) tag).getValue().intValue(); } else if (tag instanceof LongTag) {
return ((LongTag) tag).getValue().intValue();
} else {
return 0; } else if (tag instanceof FloatTag) {
} return ((FloatTag) tag).getValue().intValue();
}
} else if (tag instanceof DoubleTag) {
/** return ((DoubleTag) tag).getValue().intValue();
* Get a list of tags named with the given index.
* } else {
* <p>If the index does not exist or its value is not a list tag, return 0;
* then an empty list will be returned.</p> }
* }
* @param index the index
* @return a list of tags /**
*/ * Get a list of tags named with the given index.
public List<Tag> getList(int index) { *
Tag tag = getIfExists(index); * <p>If the index does not exist or its value is not a list tag,
if (tag instanceof ListTag) { * then an empty list will be returned.</p>
return ((ListTag) tag).getValue(); *
} else { * @param index the index
return Collections.emptyList(); * @return a list of tags
} */
} public List<Tag> getList(int index) {
Tag tag = getIfExists(index);
/** if (tag instanceof ListTag) {
* Get a {@code TagList} named with the given index. return ((ListTag) tag).getValue();
* } else {
* <p>If the index does not exist or its value is not a list tag, return Collections.emptyList();
* then an empty tag list will be returned.</p> }
* }
* @param index the index
* @return a tag list instance /**
*/ * Get a {@code TagList} named with the given index.
public ListTag getListTag(int index) { *
Tag tag = getIfExists(index); * <p>If the index does not exist or its value is not a list tag,
if (tag instanceof ListTag) { * then an empty tag list will be returned.</p>
return (ListTag) tag; *
} else { * @param index the index
return new ListTag(StringTag.class, Collections.<Tag>emptyList()); * @return a tag list instance
} */
} public ListTag getListTag(int index) {
Tag tag = getIfExists(index);
/** if (tag instanceof ListTag) {
* Get a list of tags named with the given index. return (ListTag) tag;
* } else {
* <p>If the index does not exist or its value is not a list tag, return new ListTag(StringTag.class, Collections.<Tag>emptyList());
* 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 * Get a list of tags named with the given index.
* @param listType the class of the contained type *
* @return a list of tags * <p>If the index does not exist or its value is not a list tag,
* @param <T> the NBT type * 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
@SuppressWarnings("unchecked") * list will also be returned.</p>
public <T extends Tag> List<T> getList(int index, Class<T> listType) { *
Tag tag = getIfExists(index); * @param index the index
if (tag instanceof ListTag) { * @param listType the class of the contained type
ListTag listTag = (ListTag) tag; * @return a list of tags
if (listTag.getType().equals(listType)) { * @param <T> the NBT type
return (List<T>) listTag.getValue(); */
} else { @SuppressWarnings("unchecked")
return Collections.emptyList(); public <T extends Tag> List<T> getList(int index, Class<T> listType) {
} Tag tag = getIfExists(index);
} else { if (tag instanceof ListTag) {
return Collections.emptyList(); ListTag listTag = (ListTag) tag;
} if (listTag.getType().equals(listType)) {
} return (List<T>) listTag.getValue();
} else {
/** return Collections.emptyList();
* Get a long named with the given index. }
* } else {
* <p>If the index does not exist or its value is not a long tag, return Collections.emptyList();
* then {@code 0} will be returned.</p> }
* }
* @param index the index
* @return a long /**
*/ * Get a long named with the given index.
public long getLong(int index) { *
Tag tag = getIfExists(index); * <p>If the index does not exist or its value is not a long tag,
if (tag instanceof LongTag) { * then {@code 0} will be returned.</p>
return ((LongTag) tag).getValue(); *
} else { * @param index the index
return 0L; * @return a long
} */
} public long getLong(int index) {
Tag tag = getIfExists(index);
/** if (tag instanceof LongTag) {
* Get a long named with the given index, even if it's another return ((LongTag) tag).getValue();
* type of number. } else {
* return 0L;
* <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 * Get a long named with the given index, even if it's another
*/ * type of number.
public long asLong(int index) { *
Tag tag = getIfExists(index); * <p>If the index does not exist or its value is not a number,
if (tag instanceof ByteTag) { * then {@code 0} will be returned.</p>
return ((ByteTag) tag).getValue(); *
* @param index the index
} else if (tag instanceof ShortTag) { * @return a long
return ((ShortTag) tag).getValue(); */
public long asLong(int index) {
} else if (tag instanceof IntTag) { Tag tag = getIfExists(index);
return ((IntTag) tag).getValue(); if (tag instanceof ByteTag) {
return ((ByteTag) tag).getValue();
} else if (tag instanceof LongTag) {
return ((LongTag) tag).getValue(); } else if (tag instanceof ShortTag) {
return ((ShortTag) tag).getValue();
} else if (tag instanceof FloatTag) {
return ((FloatTag) tag).getValue().longValue(); } else if (tag instanceof IntTag) {
return ((IntTag) tag).getValue();
} else if (tag instanceof DoubleTag) {
return ((DoubleTag) tag).getValue().longValue(); } else if (tag instanceof LongTag) {
return ((LongTag) tag).getValue();
} else {
return 0; } else if (tag instanceof FloatTag) {
} return ((FloatTag) tag).getValue().longValue();
}
} else if (tag instanceof DoubleTag) {
/** return ((DoubleTag) tag).getValue().longValue();
* Get a short named with the given index.
* } else {
* <p>If the index does not exist or its value is not a short tag, return 0;
* then {@code 0} will be returned.</p> }
* }
* @param index the index
* @return a short /**
*/ * Get a short named with the given index.
public short getShort(int index) { *
Tag tag = getIfExists(index); * <p>If the index does not exist or its value is not a short tag,
if (tag instanceof ShortTag) { * then {@code 0} will be returned.</p>
return ((ShortTag) tag).getValue(); *
} else { * @param index the index
return 0; * @return a short
} */
} public short getShort(int index) {
Tag tag = getIfExists(index);
/** if (tag instanceof ShortTag) {
* Get a string named with the given index. return ((ShortTag) tag).getValue();
* } else {
* <p>If the index does not exist or its value is not a string tag, return 0;
* then {@code ""} will be returned.</p> }
* }
* @param index the index
* @return a string /**
*/ * Get a string named with the given index.
public String getString(int index) { *
Tag tag = getIfExists(index); * <p>If the index does not exist or its value is not a string tag,
if (tag instanceof StringTag) { * then {@code ""} will be returned.</p>
return ((StringTag) tag).getValue(); *
} else { * @param index the index
return ""; * @return a string
} */
} public String getString(int index) {
Tag tag = getIfExists(index);
@Override if (tag instanceof StringTag) {
public String toString() { return ((StringTag) tag).getValue();
StringBuilder bldr = new StringBuilder(); } else {
bldr.append("TAG_List").append(": ").append(value.size()).append(" entries of type ").append(NBTUtils.getTypeName(type)).append("\r\n{\r\n"); return "";
for (Tag t : value) { }
bldr.append(" ").append(t.toString().replaceAll("\r\n", "\r\n ")).append("\r\n"); }
}
bldr.append("}"); @Override
return bldr.toString(); 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();
}
}

View File

@ -1,90 +1,177 @@
/* /*
* WorldEdit, a Minecraft world manipulation toolkit * WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com> * Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors * Copyright (C) WorldEdit team and contributors
* *
* This program is free software: you can redistribute it and/or modify it * 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 * under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or * Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT * This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details. * for more details.
* *
* You should have received a copy of the GNU Lesser General Public License * 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/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package com.sk89q.worldedit; package com.sk89q.worldedit;
import com.sk89q.worldedit.util.logging.LogFormat; import com.google.common.collect.Lists;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.util.logging.LogFormat;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.item.ItemType; import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.world.item.ItemTypes; import com.sk89q.worldedit.world.registry.LegacyMapper;
import com.sk89q.worldedit.world.registry.LegacyMapper; import com.sk89q.worldedit.world.snapshot.SnapshotRepository;
import com.sk89q.worldedit.world.snapshot.SnapshotRepository;
import java.io.File;
import java.io.File; import java.util.HashSet;
import java.util.HashSet; import java.util.List;
import java.util.Set; import java.util.Objects;
import java.util.Set;
/**
* Represents WorldEdit's configuration. /**
*/ * Represents WorldEdit's configuration.
public abstract class LocalConfiguration { */
protected static final String[] defaultDisallowedBlocks = new String[] {}; public abstract class LocalConfiguration {
public boolean profile = false; public boolean profile = false;
public Set<String> disallowedBlocks = new HashSet<>(); public Set<String> disallowedBlocks = new HashSet<>();
public int defaultChangeLimit = -1; public int defaultChangeLimit = -1;
public int maxChangeLimit = -1; public int maxChangeLimit = -1;
public int defaultMaxPolygonalPoints = -1; public int defaultMaxPolygonalPoints = -1;
public int maxPolygonalPoints = 20; public int maxPolygonalPoints = 20;
public int defaultMaxPolyhedronPoints = -1; public int defaultMaxPolyhedronPoints = -1;
public int maxPolyhedronPoints = 20; public int maxPolyhedronPoints = 20;
public String shellSaveType = ""; public String shellSaveType = "";
public SnapshotRepository snapshotRepo = null; public SnapshotRepository snapshotRepo = null;
public int maxRadius = -1; public int maxRadius = -1;
public int maxSuperPickaxeSize = 5; public int maxSuperPickaxeSize = 5;
public int maxBrushRadius = 100; public int maxBrushRadius = 6;
public boolean logCommands = false; public boolean logCommands = false;
public String logFile = ""; public String logFile = "";
public String logFormat = LogFormat.DEFAULT_FORMAT; public String logFormat = LogFormat.DEFAULT_FORMAT;
public boolean registerHelp = true; // what is the point of this, it's not even used public boolean registerHelp = true; // what is the point of this, it's not even used
public String wandItem = ItemTypes.WOODEN_AXE.getId(); public String wandItem = "minecraft:wooden_axe";
public boolean superPickaxeDrop = true; public boolean superPickaxeDrop = true;
public boolean superPickaxeManyDrop = true; public boolean superPickaxeManyDrop = true;
public boolean noDoubleSlash = false; public boolean noDoubleSlash = false;
public boolean useInventory = false; public boolean useInventory = false;
public boolean useInventoryOverride = false; public boolean useInventoryOverride = false;
public boolean useInventoryCreativeOverride = false; public boolean useInventoryCreativeOverride = false;
public boolean navigationUseGlass = true; public boolean navigationUseGlass = true;
public String navigationWand = ItemTypes.COMPASS.getId(); public String navigationWand = "minecraft:compass";
public int navigationWandMaxDistance = 50; public int navigationWandMaxDistance = 50;
public int scriptTimeout = 3000; public int scriptTimeout = 3000;
public Set<String> allowedDataCycleBlocks = new HashSet<>(); public Set<String> allowedDataCycleBlocks = new HashSet<>();
public String saveDir = "schematics"; public String saveDir = "schematics";
public String scriptsDir = "craftscripts"; public String scriptsDir = "craftscripts";
public boolean showHelpInfo = true; public boolean showHelpInfo = true;
public int butcherDefaultRadius = -1; public int butcherDefaultRadius = -1;
public int butcherMaxRadius = -1; public int butcherMaxRadius = -1;
public boolean allowSymlinks = false; public boolean allowSymlinks = false;
public boolean serverSideCUI = true; public boolean serverSideCUI = true;
/** protected String[] getDefaultDisallowedBlocks() {
* Load the configuration. List<BlockType> blockTypes = Lists.newArrayList(
*/ BlockTypes.OAK_SAPLING,
public abstract void load(); BlockTypes.JUNGLE_SAPLING,
BlockTypes.DARK_OAK_SAPLING,
/** BlockTypes.SPRUCE_SAPLING,
* Get the working directory to work from. BlockTypes.BIRCH_SAPLING,
* BlockTypes.ACACIA_SAPLING,
* @return a working directory BlockTypes.BLACK_BED,
*/ BlockTypes.BLUE_BED,
public File getWorkingDirectory() { BlockTypes.BROWN_BED,
return new File("."); 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;
}
}

View File

@ -53,9 +53,9 @@ public class GeneralCommands {
@Command( @Command(
aliases = { "/limit" }, aliases = { "/limit" },
usage = "<limit>", usage = "[limit]",
desc = "Modify block change limit", desc = "Modify block change limit",
min = 1, min = 0,
max = 1 max = 1
) )
@CommandPermissions("worldedit.limit") @CommandPermissions("worldedit.limit")
@ -64,7 +64,7 @@ public class GeneralCommands {
LocalConfiguration config = worldEdit.getConfiguration(); LocalConfiguration config = worldEdit.getConfiguration();
boolean mayDisable = player.hasPermission("worldedit.limit.unrestricted"); 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 (!mayDisable && config.maxChangeLimit > -1) {
if (limit > config.maxChangeLimit) { if (limit > config.maxChangeLimit) {
player.printError("Your maximum allowable limit is " + config.maxChangeLimit + "."); player.printError("Your maximum allowable limit is " + config.maxChangeLimit + ".");
@ -164,7 +164,7 @@ public class GeneralCommands {
boolean blocksOnly = args.hasFlag('b'); boolean blocksOnly = args.hasFlag('b');
boolean itemsOnly = args.hasFlag('i'); boolean itemsOnly = args.hasFlag('i');
ItemType type = ItemTypes.parse(query); ItemType type = ItemTypes.get(query);
if (type != null) { if (type != null) {
actor.print(type.getId() + " (" + type.getName() + ")"); actor.print(type.getId() + " (" + type.getName() + ")");

View File

@ -19,10 +19,7 @@
package com.sk89q.worldedit.entity; package com.sk89q.worldedit.entity;
import javax.annotation.Nullable;
import com.sk89q.worldedit.WorldEditException; 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.blocks.BaseItemStack;
import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extent.inventory.BlockBag; 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.HandSide;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.World; 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.block.BlockStateHolder;
import com.sk89q.worldedit.world.gamemode.GameMode; import com.sk89q.worldedit.world.gamemode.GameMode;
import javax.annotation.Nullable;
/** /**
* Represents a player * Represents a player
*/ */

View File

@ -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);
}
}

View File

@ -19,12 +19,10 @@
package com.sk89q.worldedit.extension.factory.parser; package com.sk89q.worldedit.extension.factory.parser;
import com.boydti.fawe.util.MathMan;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.blocks.BaseItem; import com.sk89q.worldedit.blocks.BaseItem;
import com.sk89q.worldedit.extension.input.InputParseException; import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.input.ParserContext; 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.internal.registry.InputParser;
import com.sk89q.worldedit.world.item.ItemType; import com.sk89q.worldedit.world.item.ItemType;
import com.sk89q.worldedit.world.item.ItemTypes; import com.sk89q.worldedit.world.item.ItemTypes;
@ -46,17 +44,8 @@ public class DefaultItemParser extends InputParser<BaseItem> {
ItemType type; ItemType type;
if (split.length == 1) { if (split.length == 1) {
type = LegacyMapper.getInstance().getItemFromLegacy(Integer.parseInt(split[0])); 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 { } else {
type = ItemTypes.parse(input); type = LegacyMapper.getInstance().getItemFromLegacy(Integer.parseInt(split[0]), Integer.parseInt(split[1]));
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;
}
}
} }
item = new BaseItem(type); item = new BaseItem(type);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {

View File

@ -30,11 +30,13 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.google.common.base.Preconditions.checkState;
public class AbstractProperty<T> implements Property<T> { public class AbstractProperty<T> implements Property<T> {
private final PropertyKey key; private final PropertyKey key;
private final String name; private String name;
private final List<T> values; private List<T> values;
private final int bitMask; private final int bitMask;
private final int bitMaskInverse; private final int bitMaskInverse;
@ -75,6 +77,7 @@ public class AbstractProperty<T> implements Property<T> {
return bitMask; return bitMask;
} }
//todo remove the following to allow for upstream compatibility.
public <C extends AbstractProperty<T>> C withOffset(int bitOffset) { public <C extends AbstractProperty<T>> C withOffset(int bitOffset) {
return (C) new AbstractProperty<>(name, values, bitOffset); return (C) new AbstractProperty<>(name, values, bitOffset);
} }
@ -116,6 +119,14 @@ public class AbstractProperty<T> implements Property<T> {
return this.name; 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 @Override
public String toString() { public String toString() {
return getClass().getSimpleName() + "{name=" + name + "}"; return getClass().getSimpleName() + "{name=" + name + "}";

View File

@ -19,6 +19,8 @@
package com.sk89q.worldedit.session; package com.sk89q.worldedit.session;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
import com.sk89q.worldedit.extent.clipboard.Clipboard; 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.Collections;
import java.util.List; import java.util.List;
import static com.google.common.base.Preconditions.checkNotNull;
/** /**
* Holds the clipboard and the current transform on the clipboard. * Holds the clipboard and the current transform on the clipboard.
*/ */
@ -47,8 +46,6 @@ public class ClipboardHolder {
this.clipboard = clipboard; this.clipboard = clipboard;
} }
protected ClipboardHolder() {}
/** /**
* Get the clipboard. * Get the clipboard.
* <p> * <p>

View File

@ -1,135 +1,131 @@
/* /*
* WorldEdit, a Minecraft world manipulation toolkit * WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com> * Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors * Copyright (C) WorldEdit team and contributors
* *
* This program is free software: you can redistribute it and/or modify it * 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 * under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or * Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT * This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details. * for more details.
* *
* You should have received a copy of the GNU Lesser General Public License * 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/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package com.sk89q.worldedit.util; package com.sk89q.worldedit.util;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.sk89q.util.yaml.YAMLProcessor; import com.sk89q.util.yaml.YAMLProcessor;
import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.session.SessionManager; import com.sk89q.worldedit.session.SessionManager;
import com.sk89q.worldedit.util.report.Unreported; import com.sk89q.worldedit.util.report.Unreported;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.snapshot.SnapshotRepository;
import com.sk89q.worldedit.world.item.ItemTypes;
import com.sk89q.worldedit.world.snapshot.SnapshotRepository; import java.io.IOException;
import java.util.HashSet;
import java.io.IOException; import java.util.logging.Level;
import java.util.HashSet; import java.util.logging.Logger;
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.
/** */
* A less simple implementation of {@link LocalConfiguration} public class YAMLConfiguration extends LocalConfiguration {
* using YAML configuration files.
*/ @Unreported protected final YAMLProcessor config;
public class YAMLConfiguration extends LocalConfiguration { @Unreported protected final Logger logger;
@Unreported protected final YAMLProcessor config; public YAMLConfiguration(YAMLProcessor config, Logger logger) {
@Unreported protected final Logger logger; this.config = config;
this.logger = logger;
public YAMLConfiguration(YAMLProcessor config, Logger logger) { }
this.config = config;
this.logger = logger; @Override
} public void load() {
try {
@Override config.load();
public void load() { } catch (IOException e) {
try { logger.log(Level.WARNING, "Error loading WorldEdit configuration", e);
config.load(); }
} catch (Throwable e) {
logger.log(Level.WARNING, "Error loading WorldEdit configuration", e); profile = config.getBoolean("debug", profile);
} wandItem = convertLegacyItem(config.getString("wand-item", wandItem));
profile = config.getBoolean("debug", profile); defaultChangeLimit = Math.max(-1, config.getInt(
wandItem = ItemTypes.parse(config.getString("wand-item", wandItem)).getId(); "limits.max-blocks-changed.default", defaultChangeLimit));
maxChangeLimit = Math.max(-1,
defaultChangeLimit = Math.max(-1, config.getInt( config.getInt("limits.max-blocks-changed.maximum", maxChangeLimit));
"limits.max-blocks-changed.default", defaultChangeLimit));
maxChangeLimit = Math.max(-1, defaultMaxPolygonalPoints = Math.max(-1,
config.getInt("limits.max-blocks-changed.maximum", maxChangeLimit)); config.getInt("limits.max-polygonal-points.default", defaultMaxPolygonalPoints));
maxPolygonalPoints = Math.max(-1,
defaultMaxPolygonalPoints = Math.max(-1, config.getInt("limits.max-polygonal-points.maximum", maxPolygonalPoints));
config.getInt("limits.max-polygonal-points.default", defaultMaxPolygonalPoints));
maxPolygonalPoints = Math.max(-1, defaultMaxPolyhedronPoints = Math.max(-1, config.getInt("limits.max-polyhedron-points.default", defaultMaxPolyhedronPoints));
config.getInt("limits.max-polygonal-points.maximum", maxPolygonalPoints)); maxPolyhedronPoints = Math.max(-1, config.getInt("limits.max-polyhedron-points.maximum", maxPolyhedronPoints));
defaultMaxPolyhedronPoints = Math.max(-1, config.getInt("limits.max-polyhedron-points.default", defaultMaxPolyhedronPoints)); maxRadius = Math.max(-1, config.getInt("limits.max-radius", maxRadius));
maxPolyhedronPoints = Math.max(-1, config.getInt("limits.max-polyhedron-points.maximum", maxPolyhedronPoints)); maxBrushRadius = config.getInt("limits.max-brush-radius", maxBrushRadius);
maxSuperPickaxeSize = Math.max(1, config.getInt(
maxRadius = Math.max(-1, config.getInt("limits.max-radius", maxRadius)); "limits.max-super-pickaxe-size", maxSuperPickaxeSize));
maxBrushRadius = config.getInt("limits.max-brush-radius", maxBrushRadius);
maxSuperPickaxeSize = Math.max(1, config.getInt( butcherDefaultRadius = Math.max(-1, config.getInt("limits.butcher-radius.default", butcherDefaultRadius));
"limits.max-super-pickaxe-size", maxSuperPickaxeSize)); butcherMaxRadius = Math.max(-1, config.getInt("limits.butcher-radius.maximum", butcherMaxRadius));
butcherDefaultRadius = Math.max(-1, config.getInt("limits.butcher-radius.default", butcherDefaultRadius)); disallowedBlocks = new HashSet<>(config.getStringList("limits.disallowed-blocks", Lists.newArrayList(getDefaultDisallowedBlocks())));
butcherMaxRadius = Math.max(-1, config.getInt("limits.butcher-radius.maximum", butcherMaxRadius)); allowedDataCycleBlocks =
new HashSet<>(config.getStringList("limits.allowed-data-cycle-blocks", null));
disallowedBlocks =
new HashSet<>(config.getStringList("limits.disallowed-blocks", Lists.newArrayList(defaultDisallowedBlocks))); registerHelp = config.getBoolean("register-help", true);
allowedDataCycleBlocks = logCommands = config.getBoolean("logging.log-commands", logCommands);
new HashSet<>(config.getStringList("limits.allowed-data-cycle-blocks", null)); logFile = config.getString("logging.file", logFile);
logFormat = config.getString("logging.format", logFormat);
registerHelp = config.getBoolean("register-help", true);
logCommands = config.getBoolean("logging.log-commands", logCommands); superPickaxeDrop = config.getBoolean("super-pickaxe.drop-items",
logFile = config.getString("logging.file", logFile); superPickaxeDrop);
logFormat = config.getString("logging.format", logFormat); superPickaxeManyDrop = config.getBoolean(
"super-pickaxe.many-drop-items", superPickaxeManyDrop);
superPickaxeDrop = config.getBoolean("super-pickaxe.drop-items",
superPickaxeDrop); noDoubleSlash = config.getBoolean("no-double-slash", noDoubleSlash);
superPickaxeManyDrop = config.getBoolean(
"super-pickaxe.many-drop-items", superPickaxeManyDrop); useInventory = config.getBoolean("use-inventory.enable", useInventory);
useInventoryOverride = config.getBoolean("use-inventory.allow-override",
noDoubleSlash = config.getBoolean("no-double-slash", noDoubleSlash); useInventoryOverride);
useInventoryCreativeOverride = config.getBoolean("use-inventory.creative-mode-overrides",
useInventory = config.getBoolean("use-inventory.enable", useInventory); useInventoryCreativeOverride);
useInventoryOverride = config.getBoolean("use-inventory.allow-override",
useInventoryOverride); navigationWand = convertLegacyItem(config.getString("navigation-wand.item", navigationWand));
useInventoryCreativeOverride = config.getBoolean("use-inventory.creative-mode-overrides", navigationWandMaxDistance = config.getInt("navigation-wand.max-distance", navigationWandMaxDistance);
useInventoryCreativeOverride); navigationUseGlass = config.getBoolean("navigation.use-glass", navigationUseGlass);
navigationWand = ItemTypes.parse(config.getString("navigation-wand.item", navigationWand)).getId(); scriptTimeout = config.getInt("scripting.timeout", scriptTimeout);
navigationWandMaxDistance = config.getInt("navigation-wand.max-distance", navigationWandMaxDistance); scriptsDir = config.getString("scripting.dir", scriptsDir);
navigationUseGlass = config.getBoolean("navigation.use-glass", navigationUseGlass);
saveDir = config.getString("saving.dir", saveDir);
scriptTimeout = config.getInt("scripting.timeout", scriptTimeout);
scriptsDir = config.getString("scripting.dir", scriptsDir); allowSymlinks = config.getBoolean("files.allow-symbolic-links", false);
LocalSession.MAX_HISTORY_SIZE = Math.max(0, config.getInt("history.size", 15));
saveDir = config.getString("saving.dir", saveDir); SessionManager.EXPIRATION_GRACE = config.getInt("history.expiration", 10) * 60 * 1000;
allowSymlinks = config.getBoolean("files.allow-symbolic-links", false); showHelpInfo = config.getBoolean("show-help-on-first-use", true);
LocalSession.MAX_HISTORY_SIZE = Math.max(0, config.getInt("history.size", 15));
SessionManager.EXPIRATION_GRACE = config.getInt("history.expiration", 10) * 60 * 1000; String snapshotsDir = config.getString("snapshots.directory", "");
if (!snapshotsDir.isEmpty()) {
showHelpInfo = config.getBoolean("show-help-on-first-use", true); snapshotRepo = new SnapshotRepository(snapshotsDir);
}
String snapshotsDir = config.getString("snapshots.directory", "");
if (!snapshotsDir.isEmpty()) { String type = config.getString("shell-save-type", "").trim();
snapshotRepo = new SnapshotRepository(snapshotsDir); shellSaveType = type.isEmpty() ? null : type;
}
}
String type = config.getString("shell-save-type", "").trim();
shellSaveType = type.isEmpty() ? null : type; public void unload() {
}
}
}
public void unload() {
}
}

View File

@ -230,7 +230,11 @@ public class BaseBlock implements BlockStateHolder<BaseBlock>, TileEntityBlock {
@Override @Override
public int hashCode() { public int hashCode() {
return getOrdinal(); int ret = toImmutableState().hashCode() << 3;
if (hasNbtData()) {
ret += getNbtData().hashCode();
}
return ret;
} }
@Override @Override

View File

@ -116,7 +116,8 @@ public interface BlockStateHolder<T extends BlockStateHolder<T>> extends FawePat
Map<Property<?>, Object> getStates(); 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 * @param o other block
* @return true if equal * @return true if equal
*/ */
@ -148,7 +149,9 @@ public interface BlockStateHolder<T extends BlockStateHolder<T>> extends FawePat
if (getStates().isEmpty()) { if (getStates().isEmpty()) {
return this.getBlockType().getId(); return this.getBlockType().getId();
} else { } 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 + "]"; return this.getBlockType().getId() + "[" + properties + "]";
} }
} }

View File

@ -1,5 +0,0 @@
package com.sk89q.worldedit.world.block;
public class BlockStateRegistry {
}

View File

@ -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_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)); 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) { private static BlockType register(String id) {
return register(new BlockType(id)); return register(new BlockType(id));
} }
private static BlockType register(String id, Function<BlockState, BlockState> values) { private static BlockType register(String id, Function<BlockState, BlockState> values) {
return register(new BlockType(id, values)); return register(new BlockType(id, values));
} }
public static BlockType register(BlockType type) { public static BlockType register(BlockType type) {
if(sortedRegistry == null) { if(sortedRegistry == null) {
sortedRegistry = new ArrayList<>(); sortedRegistry = new ArrayList<>();
@ -685,7 +685,7 @@ public class BlockTypes{
if(!sortedRegistry.contains(type))sortedRegistry.add(type); if(!sortedRegistry.contains(type))sortedRegistry.add(type);
return internalRegister(type, sortedRegistry.indexOf(type)); return internalRegister(type, sortedRegistry.indexOf(type));
} }
private static ArrayList<BlockType> sortedRegistry; private static ArrayList<BlockType> sortedRegistry;
private static ArrayList<BlockState> stateList; private static ArrayList<BlockState> stateList;
public static BlockType[] values; public static BlockType[] values;
@ -693,7 +693,7 @@ public class BlockTypes{
private static Set<String> $NAMESPACES; private static Set<String> $NAMESPACES;
@Deprecated public static int BIT_OFFSET; // Used internally @Deprecated public static int BIT_OFFSET; // Used internally
@Deprecated public static int BIT_MASK; // Used internally @Deprecated public static int BIT_MASK; // Used internally
private static BlockType internalRegister(BlockType blockType, final int internalId) { private static BlockType internalRegister(BlockType blockType, final int internalId) {
init(blockType, blockType.getId(), internalId, stateList); init(blockType, blockType.getId(), internalId, stateList);
if(BlockType.REGISTRY.get(blockType.getId()) == null) BlockType.REGISTRY.register(blockType.getId(), blockType); if(BlockType.REGISTRY.get(blockType.getId()) == null) BlockType.REGISTRY.register(blockType.getId(), blockType);
@ -703,10 +703,6 @@ public class BlockTypes{
return blockType; 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) { private static void init(BlockType type, String id, int internalId, ArrayList<BlockState> states) {
try { try {
type.setSettings(new Settings(type, id, internalId, states)); type.setSettings(new Settings(type, id, internalId, states));
@ -856,7 +852,7 @@ public class BlockTypes{
public static final @Nullable BlockType get(final String id) { public static final @Nullable BlockType get(final String id) {
return BlockType.REGISTRY.get(id.toLowerCase()); return BlockType.REGISTRY.get(id.toLowerCase());
} }
public static final @Nullable BlockType get(final CharSequence id) { public static final @Nullable BlockType get(final CharSequence id) {
return BlockType.REGISTRY.get(id.toString().toLowerCase()); return BlockType.REGISTRY.get(id.toString().toLowerCase());
} }

View File

@ -266,10 +266,9 @@ public class AnvilChunk implements Chunk {
if (state.getMaterial().hasContainer()) { if (state.getMaterial().hasContainer()) {
CompoundTag tileEntity = getBlockTileEntity(position); CompoundTag tileEntity = getBlockTileEntity(position);
if (tileEntity != null) { if (tileEntity != null) {
return new BaseBlock(state, tileEntity); return state.toBaseBlock(tileEntity);
} }
} }
return state.toBaseBlock(); return state.toBaseBlock();
} }

View File

@ -27,7 +27,6 @@ import com.sk89q.jnbt.NBTUtils;
import com.sk89q.jnbt.Tag; import com.sk89q.jnbt.Tag;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.DataException; import com.sk89q.worldedit.world.DataException;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BaseBlock;
@ -189,7 +188,9 @@ public class OldChunk implements Chunk {
} }
if (state.getBlockType().getMaterial().hasContainer()) { if (state.getBlockType().getMaterial().hasContainer()) {
CompoundTag tileEntity = getBlockTileEntity(position); CompoundTag tileEntity = getBlockTileEntity(position);
if (tileEntity != null) return new BaseBlock(state, tileEntity); if (tileEntity != null) {
return state.toBaseBlock(tileEntity);
}
} }
return state.toBaseBlock(); return state.toBaseBlock();
} }

View File

@ -63,4 +63,4 @@ public class EntityType {
return obj instanceof EntityType && this.id.equals(((EntityType) obj).id); return obj instanceof EntityType && this.id.equals(((EntityType) obj).id);
} }
} }

View File

@ -23,113 +23,105 @@ import javax.annotation.Nullable;
public class EntityTypes { public class EntityTypes {
public static final EntityType AREA_EFFECT_CLOUD = register("minecraft:area_effect_cloud"); @Nullable public static final EntityType AREA_EFFECT_CLOUD = get("minecraft:area_effect_cloud");
public static final EntityType ARMOR_STAND = register("minecraft:armor_stand"); @Nullable public static final EntityType ARMOR_STAND = get("minecraft:armor_stand");
public static final EntityType ARROW = register("minecraft:arrow"); @Nullable public static final EntityType ARROW = get("minecraft:arrow");
public static final EntityType BAT = register("minecraft:bat"); @Nullable public static final EntityType BAT = get("minecraft:bat");
public static final EntityType BLAZE = register("minecraft:blaze"); @Nullable public static final EntityType BLAZE = get("minecraft:blaze");
public static final EntityType BOAT = register("minecraft:boat"); @Nullable public static final EntityType BOAT = get("minecraft:boat");
public static final EntityType CAVE_SPIDER = register("minecraft:cave_spider"); @Nullable public static final EntityType CAVE_SPIDER = get("minecraft:cave_spider");
public static final EntityType CHEST_MINECART = register("minecraft:chest_minecart"); @Nullable public static final EntityType CHEST_MINECART = get("minecraft:chest_minecart");
public static final EntityType CHICKEN = register("minecraft:chicken"); @Nullable public static final EntityType CHICKEN = get("minecraft:chicken");
public static final EntityType COD = register("minecraft:cod"); @Nullable public static final EntityType COD = get("minecraft:cod");
public static final EntityType COMMAND_BLOCK_MINECART = register("minecraft:command_block_minecart"); @Nullable public static final EntityType COMMAND_BLOCK_MINECART = get("minecraft:command_block_minecart");
public static final EntityType COW = register("minecraft:cow"); @Nullable public static final EntityType COW = get("minecraft:cow");
public static final EntityType CREEPER = register("minecraft:creeper"); @Nullable public static final EntityType CREEPER = get("minecraft:creeper");
public static final EntityType DOLPHIN = register("minecraft:dolphin"); @Nullable public static final EntityType DOLPHIN = get("minecraft:dolphin");
public static final EntityType DONKEY = register("minecraft:donkey"); @Nullable public static final EntityType DONKEY = get("minecraft:donkey");
public static final EntityType DRAGON_FIREBALL = register("minecraft:dragon_fireball"); @Nullable public static final EntityType DRAGON_FIREBALL = get("minecraft:dragon_fireball");
public static final EntityType DROWNED = register("minecraft:drowned"); @Nullable public static final EntityType DROWNED = get("minecraft:drowned");
public static final EntityType EGG = register("minecraft:egg"); @Nullable public static final EntityType EGG = get("minecraft:egg");
public static final EntityType ELDER_GUARDIAN = register("minecraft:elder_guardian"); @Nullable public static final EntityType ELDER_GUARDIAN = get("minecraft:elder_guardian");
public static final EntityType END_CRYSTAL = register("minecraft:end_crystal"); @Nullable public static final EntityType END_CRYSTAL = get("minecraft:end_crystal");
public static final EntityType ENDER_DRAGON = register("minecraft:ender_dragon"); @Nullable public static final EntityType ENDER_DRAGON = get("minecraft:ender_dragon");
public static final EntityType ENDER_PEARL = register("minecraft:ender_pearl"); @Nullable public static final EntityType ENDER_PEARL = get("minecraft:ender_pearl");
public static final EntityType ENDERMAN = register("minecraft:enderman"); @Nullable public static final EntityType ENDERMAN = get("minecraft:enderman");
public static final EntityType ENDERMITE = register("minecraft:endermite"); @Nullable public static final EntityType ENDERMITE = get("minecraft:endermite");
public static final EntityType EVOKER = register("minecraft:evoker"); @Nullable public static final EntityType EVOKER = get("minecraft:evoker");
public static final EntityType EVOKER_FANGS = register("minecraft:evoker_fangs"); @Nullable public static final EntityType EVOKER_FANGS = get("minecraft:evoker_fangs");
public static final EntityType EXPERIENCE_BOTTLE = register("minecraft:experience_bottle"); @Nullable public static final EntityType EXPERIENCE_BOTTLE = get("minecraft:experience_bottle");
public static final EntityType EXPERIENCE_ORB = register("minecraft:experience_orb"); @Nullable public static final EntityType EXPERIENCE_ORB = get("minecraft:experience_orb");
public static final EntityType EYE_OF_ENDER = register("minecraft:eye_of_ender"); @Nullable public static final EntityType EYE_OF_ENDER = get("minecraft:eye_of_ender");
public static final EntityType FALLING_BLOCK = register("minecraft:falling_block"); @Nullable public static final EntityType FALLING_BLOCK = get("minecraft:falling_block");
public static final EntityType FIREBALL = register("minecraft:fireball"); @Nullable public static final EntityType FIREBALL = get("minecraft:fireball");
public static final EntityType FIREWORK_ROCKET = register("minecraft:firework_rocket"); @Nullable public static final EntityType FIREWORK_ROCKET = get("minecraft:firework_rocket");
public static final EntityType FISHING_BOBBER = register("minecraft:fishing_bobber"); @Nullable public static final EntityType FISHING_BOBBER = get("minecraft:fishing_bobber");
public static final EntityType FURNACE_MINECART = register("minecraft:furnace_minecart"); @Nullable public static final EntityType FURNACE_MINECART = get("minecraft:furnace_minecart");
public static final EntityType GHAST = register("minecraft:ghast"); @Nullable public static final EntityType GHAST = get("minecraft:ghast");
public static final EntityType GIANT = register("minecraft:giant"); @Nullable public static final EntityType GIANT = get("minecraft:giant");
public static final EntityType GUARDIAN = register("minecraft:guardian"); @Nullable public static final EntityType GUARDIAN = get("minecraft:guardian");
public static final EntityType HOPPER_MINECART = register("minecraft:hopper_minecart"); @Nullable public static final EntityType HOPPER_MINECART = get("minecraft:hopper_minecart");
public static final EntityType HORSE = register("minecraft:horse"); @Nullable public static final EntityType HORSE = get("minecraft:horse");
public static final EntityType HUSK = register("minecraft:husk"); @Nullable public static final EntityType HUSK = get("minecraft:husk");
public static final EntityType ILLUSIONER = register("minecraft:illusioner"); @Nullable public static final EntityType ILLUSIONER = get("minecraft:illusioner");
public static final EntityType IRON_GOLEM = register("minecraft:iron_golem"); @Nullable public static final EntityType IRON_GOLEM = get("minecraft:iron_golem");
public static final EntityType ITEM = register("minecraft:item"); @Nullable public static final EntityType ITEM = get("minecraft:item");
public static final EntityType ITEM_FRAME = register("minecraft:item_frame"); @Nullable public static final EntityType ITEM_FRAME = get("minecraft:item_frame");
public static final EntityType LEASH_KNOT = register("minecraft:leash_knot"); @Nullable public static final EntityType LEASH_KNOT = get("minecraft:leash_knot");
public static final EntityType LIGHTNING_BOLT = register("minecraft:lightning_bolt"); @Nullable public static final EntityType LIGHTNING_BOLT = get("minecraft:lightning_bolt");
public static final EntityType LLAMA = register("minecraft:llama"); @Nullable public static final EntityType LLAMA = get("minecraft:llama");
public static final EntityType LLAMA_SPIT = register("minecraft:llama_spit"); @Nullable public static final EntityType LLAMA_SPIT = get("minecraft:llama_spit");
public static final EntityType MAGMA_CUBE = register("minecraft:magma_cube"); @Nullable public static final EntityType MAGMA_CUBE = get("minecraft:magma_cube");
public static final EntityType MINECART = register("minecraft:minecart"); @Nullable public static final EntityType MINECART = get("minecraft:minecart");
public static final EntityType MOOSHROOM = register("minecraft:mooshroom"); @Nullable public static final EntityType MOOSHROOM = get("minecraft:mooshroom");
public static final EntityType MULE = register("minecraft:mule"); @Nullable public static final EntityType MULE = get("minecraft:mule");
public static final EntityType OCELOT = register("minecraft:ocelot"); @Nullable public static final EntityType OCELOT = get("minecraft:ocelot");
public static final EntityType PAINTING = register("minecraft:painting"); @Nullable public static final EntityType PAINTING = get("minecraft:painting");
public static final EntityType PARROT = register("minecraft:parrot"); @Nullable public static final EntityType PARROT = get("minecraft:parrot");
public static final EntityType PHANTOM = register("minecraft:phantom"); @Nullable public static final EntityType PHANTOM = get("minecraft:phantom");
public static final EntityType PIG = register("minecraft:pig"); @Nullable public static final EntityType PIG = get("minecraft:pig");
public static final EntityType PLAYER = register("minecraft:player"); @Nullable public static final EntityType PLAYER = get("minecraft:player");
public static final EntityType POLAR_BEAR = register("minecraft:polar_bear"); @Nullable public static final EntityType POLAR_BEAR = get("minecraft:polar_bear");
public static final EntityType POTION = register("minecraft:potion"); @Nullable public static final EntityType POTION = get("minecraft:potion");
public static final EntityType PUFFERFISH = register("minecraft:pufferfish"); @Nullable public static final EntityType PUFFERFISH = get("minecraft:pufferfish");
public static final EntityType RABBIT = register("minecraft:rabbit"); @Nullable public static final EntityType RABBIT = get("minecraft:rabbit");
public static final EntityType SALMON = register("minecraft:salmon"); @Nullable public static final EntityType SALMON = get("minecraft:salmon");
public static final EntityType SHEEP = register("minecraft:sheep"); @Nullable public static final EntityType SHEEP = get("minecraft:sheep");
public static final EntityType SHULKER = register("minecraft:shulker"); @Nullable public static final EntityType SHULKER = get("minecraft:shulker");
public static final EntityType SHULKER_BULLET = register("minecraft:shulker_bullet"); @Nullable public static final EntityType SHULKER_BULLET = get("minecraft:shulker_bullet");
public static final EntityType SILVERFISH = register("minecraft:silverfish"); @Nullable public static final EntityType SILVERFISH = get("minecraft:silverfish");
public static final EntityType SKELETON = register("minecraft:skeleton"); @Nullable public static final EntityType SKELETON = get("minecraft:skeleton");
public static final EntityType SKELETON_HORSE = register("minecraft:skeleton_horse"); @Nullable public static final EntityType SKELETON_HORSE = get("minecraft:skeleton_horse");
public static final EntityType SLIME = register("minecraft:slime"); @Nullable public static final EntityType SLIME = get("minecraft:slime");
public static final EntityType SMALL_FIREBALL = register("minecraft:small_fireball"); @Nullable public static final EntityType SMALL_FIREBALL = get("minecraft:small_fireball");
public static final EntityType SNOW_GOLEM = register("minecraft:snow_golem"); @Nullable public static final EntityType SNOW_GOLEM = get("minecraft:snow_golem");
public static final EntityType SNOWBALL = register("minecraft:snowball"); @Nullable public static final EntityType SNOWBALL = get("minecraft:snowball");
public static final EntityType SPAWNER_MINECART = register("minecraft:spawner_minecart"); @Nullable public static final EntityType SPAWNER_MINECART = get("minecraft:spawner_minecart");
public static final EntityType SPECTRAL_ARROW = register("minecraft:spectral_arrow"); @Nullable public static final EntityType SPECTRAL_ARROW = get("minecraft:spectral_arrow");
public static final EntityType SPIDER = register("minecraft:spider"); @Nullable public static final EntityType SPIDER = get("minecraft:spider");
public static final EntityType SQUID = register("minecraft:squid"); @Nullable public static final EntityType SQUID = get("minecraft:squid");
public static final EntityType STRAY = register("minecraft:stray"); @Nullable public static final EntityType STRAY = get("minecraft:stray");
public static final EntityType TNT = register("minecraft:tnt"); @Nullable public static final EntityType TNT = get("minecraft:tnt");
public static final EntityType TNT_MINECART = register("minecraft:tnt_minecart"); @Nullable public static final EntityType TNT_MINECART = get("minecraft:tnt_minecart");
public static final EntityType TRIDENT = register("minecraft:trident"); @Nullable public static final EntityType TRIDENT = get("minecraft:trident");
public static final EntityType TROPICAL_FISH = register("minecraft:tropical_fish"); @Nullable public static final EntityType TROPICAL_FISH = get("minecraft:tropical_fish");
public static final EntityType TURTLE = register("minecraft:turtle"); @Nullable public static final EntityType TURTLE = get("minecraft:turtle");
public static final EntityType VEX = register("minecraft:vex"); @Nullable public static final EntityType VEX = get("minecraft:vex");
public static final EntityType VILLAGER = register("minecraft:villager"); @Nullable public static final EntityType VILLAGER = get("minecraft:villager");
public static final EntityType VINDICATOR = register("minecraft:vindicator"); @Nullable public static final EntityType VINDICATOR = get("minecraft:vindicator");
public static final EntityType WITCH = register("minecraft:witch"); @Nullable public static final EntityType WITCH = get("minecraft:witch");
public static final EntityType WITHER = register("minecraft:wither"); @Nullable public static final EntityType WITHER = get("minecraft:wither");
public static final EntityType WITHER_SKELETON = register("minecraft:wither_skeleton"); @Nullable public static final EntityType WITHER_SKELETON = get("minecraft:wither_skeleton");
public static final EntityType WITHER_SKULL = register("minecraft:wither_skull"); @Nullable public static final EntityType WITHER_SKULL = get("minecraft:wither_skull");
public static final EntityType WOLF = register("minecraft:wolf"); @Nullable public static final EntityType WOLF = get("minecraft:wolf");
public static final EntityType ZOMBIE = register("minecraft:zombie"); @Nullable public static final EntityType ZOMBIE = get("minecraft:zombie");
public static final EntityType ZOMBIE_HORSE = register("minecraft:zombie_horse"); @Nullable public static final EntityType ZOMBIE_HORSE = get("minecraft:zombie_horse");
public static final EntityType ZOMBIE_PIGMAN = register("minecraft:zombie_pigman"); @Nullable public static final EntityType ZOMBIE_PIGMAN = get("minecraft:zombie_pigman");
public static final EntityType ZOMBIE_VILLAGER = register("minecraft:zombie_villager"); @Nullable public static final EntityType ZOMBIE_VILLAGER = get("minecraft:zombie_villager");
private EntityTypes() { 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) { public static @Nullable EntityType get(final String id) {
return EntityType.REGISTRY.get(id); return EntityType.REGISTRY.get(id);
} }
@ -201,4 +193,4 @@ public class EntityTypes {
} }
} }
} }