mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-06-11 20:13:55 +00:00
Merging upstream changes
This commit is contained in:
@ -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());
|
||||
|
Reference in New Issue
Block a user