geforkt von Mirrors/FastAsyncWorldEdit
Remove old Bukkit entity adapter classes. (reverted from commit b461f44db8
)
CraftBook uses some of these classes.
Dieser Commit ist enthalten in:
Ursprung
e7f65e27db
Commit
15b173dca6
@ -19,14 +19,10 @@
|
||||
|
||||
package com.sk89q.worldedit.bukkit;
|
||||
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.BlockWorldVector;
|
||||
import com.sk89q.worldedit.LocalWorld;
|
||||
import com.sk89q.worldedit.Location;
|
||||
import java.util.List;
|
||||
|
||||
import com.sk89q.worldedit.NotABlockException;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.WorldVector;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.blocks.BlockID;
|
||||
import com.sk89q.worldedit.blocks.BlockType;
|
||||
@ -37,12 +33,25 @@ import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.ExperienceOrb;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.Painting;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.BlockWorldVector;
|
||||
import com.sk89q.worldedit.LocalWorld;
|
||||
import com.sk89q.worldedit.Location;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldVector;
|
||||
import com.sk89q.worldedit.bukkit.entity.BukkitEntity;
|
||||
import com.sk89q.worldedit.bukkit.entity.BukkitExpOrb;
|
||||
import com.sk89q.worldedit.bukkit.entity.BukkitItem;
|
||||
import com.sk89q.worldedit.bukkit.entity.BukkitPainting;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.material.Dye;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public final class BukkitUtil {
|
||||
|
||||
private BukkitUtil() {
|
||||
@ -142,6 +151,20 @@ public final class BukkitUtil {
|
||||
return ((BukkitWorld) world).getWorld();
|
||||
}
|
||||
|
||||
public static BukkitEntity toLocalEntity(Entity e) {
|
||||
switch (e.getType()) {
|
||||
case EXPERIENCE_ORB:
|
||||
return new BukkitExpOrb(toLocation(e.getLocation()), e.getUniqueId(), ((ExperienceOrb)e).getExperience());
|
||||
case PAINTING:
|
||||
Painting paint = (Painting) e;
|
||||
return new BukkitPainting(toLocation(e.getLocation()), paint.getArt(), paint.getFacing(), e.getUniqueId());
|
||||
case DROPPED_ITEM:
|
||||
return new BukkitItem(toLocation(e.getLocation()), ((Item)e).getItemStack(), e.getUniqueId());
|
||||
default:
|
||||
return new BukkitEntity(toLocation(e.getLocation()), e.getType(), e.getUniqueId());
|
||||
}
|
||||
}
|
||||
|
||||
public static BaseBlock toBlock(LocalWorld world, ItemStack itemStack) throws WorldEditException {
|
||||
final int typeId = itemStack.getTypeId();
|
||||
|
||||
|
51
src/bukkit/java/com/sk89q/worldedit/bukkit/entity/BukkitEntity.java
Normale Datei
51
src/bukkit/java/com/sk89q/worldedit/bukkit/entity/BukkitEntity.java
Normale Datei
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.bukkit.entity;
|
||||
|
||||
import com.sk89q.worldedit.LocalEntity;
|
||||
import com.sk89q.worldedit.Location;
|
||||
import com.sk89q.worldedit.bukkit.BukkitUtil;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author zml2008
|
||||
*/
|
||||
public class BukkitEntity extends LocalEntity {
|
||||
private final EntityType type;
|
||||
private final UUID entityId;
|
||||
|
||||
public BukkitEntity(Location loc, EntityType type, UUID entityId) {
|
||||
super(loc);
|
||||
this.type = type;
|
||||
this.entityId = entityId;
|
||||
}
|
||||
|
||||
public UUID getEntityId() {
|
||||
return entityId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean spawn(Location weLoc) {
|
||||
org.bukkit.Location loc = BukkitUtil.toLocation(weLoc);
|
||||
return loc.getWorld().spawn(loc, type.getEntityClass()) != null;
|
||||
}
|
||||
}
|
50
src/bukkit/java/com/sk89q/worldedit/bukkit/entity/BukkitExpOrb.java
Normale Datei
50
src/bukkit/java/com/sk89q/worldedit/bukkit/entity/BukkitExpOrb.java
Normale Datei
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.bukkit.entity;
|
||||
|
||||
import com.sk89q.worldedit.Location;
|
||||
import com.sk89q.worldedit.bukkit.BukkitUtil;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.ExperienceOrb;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author zml2008
|
||||
*/
|
||||
public class BukkitExpOrb extends BukkitEntity {
|
||||
private final int amount;
|
||||
|
||||
public BukkitExpOrb(Location loc, UUID entityId, int amount) {
|
||||
super(loc, EntityType.EXPERIENCE_ORB, entityId);
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean spawn(Location weLoc) {
|
||||
org.bukkit.Location loc = BukkitUtil.toLocation(weLoc);
|
||||
ExperienceOrb orb = loc.getWorld().spawn(loc, ExperienceOrb.class);
|
||||
if (orb != null) {
|
||||
orb.setExperience(amount);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
44
src/bukkit/java/com/sk89q/worldedit/bukkit/entity/BukkitItem.java
Normale Datei
44
src/bukkit/java/com/sk89q/worldedit/bukkit/entity/BukkitItem.java
Normale Datei
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.bukkit.entity;
|
||||
|
||||
import com.sk89q.worldedit.Location;
|
||||
import com.sk89q.worldedit.bukkit.BukkitUtil;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author zml2008
|
||||
*/
|
||||
public class BukkitItem extends BukkitEntity {
|
||||
private final ItemStack stack;
|
||||
public BukkitItem(Location loc, ItemStack stack, UUID entityId) {
|
||||
super(loc, EntityType.DROPPED_ITEM, entityId);
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean spawn(Location weLoc) {
|
||||
org.bukkit.Location loc = BukkitUtil.toLocation(weLoc);
|
||||
return loc.getWorld().dropItem(loc, stack) != null;
|
||||
}
|
||||
}
|
105
src/bukkit/java/com/sk89q/worldedit/bukkit/entity/BukkitPainting.java
Normale Datei
105
src/bukkit/java/com/sk89q/worldedit/bukkit/entity/BukkitPainting.java
Normale Datei
@ -0,0 +1,105 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.bukkit.entity;
|
||||
|
||||
import com.sk89q.worldedit.Location;
|
||||
import com.sk89q.worldedit.bukkit.BukkitUtil;
|
||||
import org.bukkit.Art;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Painting;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Deque;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author zml2008
|
||||
*/
|
||||
public class BukkitPainting extends BukkitEntity {
|
||||
private static int spawnTask = -1;
|
||||
private static final Deque<QueuedPaintingSpawn> spawnQueue = new ArrayDeque<QueuedPaintingSpawn>();
|
||||
|
||||
private class QueuedPaintingSpawn {
|
||||
private final Location weLoc;
|
||||
|
||||
public QueuedPaintingSpawn(Location weLoc) {
|
||||
this.weLoc = weLoc;
|
||||
}
|
||||
|
||||
public void spawn() {
|
||||
spawnRaw(weLoc);
|
||||
}
|
||||
}
|
||||
private static class PaintingSpawnRunnable implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
synchronized (spawnQueue) {
|
||||
QueuedPaintingSpawn spawn;
|
||||
while ((spawn = spawnQueue.poll()) != null) {
|
||||
try {
|
||||
spawn.spawn();
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
spawnTask = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private final Art art;
|
||||
private final BlockFace facingDirection;
|
||||
public BukkitPainting(Location loc, Art art, BlockFace facingDirection, UUID entityId) {
|
||||
super(loc, EntityType.PAINTING, entityId);
|
||||
this.art = art;
|
||||
this.facingDirection = facingDirection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Queue the painting to be spawned at the specified location.
|
||||
* This operation is delayed so that the block changes that may be applied can be applied before the painting spawn is attempted.
|
||||
*
|
||||
* @param weLoc The WorldEdit location
|
||||
* @return Whether the spawn as successful
|
||||
*/
|
||||
public boolean spawn(Location weLoc) {
|
||||
synchronized (spawnQueue) {
|
||||
spawnQueue.add(new QueuedPaintingSpawn(weLoc));
|
||||
if (spawnTask == -1) {
|
||||
spawnTask = Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Bukkit.getServer().getPluginManager().getPlugin("WorldEdit"), new PaintingSpawnRunnable(), 1L);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean spawnRaw(Location weLoc) {
|
||||
org.bukkit.Location loc = BukkitUtil.toLocation(weLoc);
|
||||
Painting paint = loc.getWorld().spawn(loc, Painting.class);
|
||||
if (paint != null) {
|
||||
paint.setFacingDirection(facingDirection, true);
|
||||
paint.setArt(art, true);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren