From b461f44db809674123639378355f245d5d9c9344 Mon Sep 17 00:00:00 2001 From: sk89q Date: Fri, 18 Jul 2014 11:32:19 -0700 Subject: [PATCH] Remove old Bukkit entity adapter classes. --- .../sk89q/worldedit/bukkit/BukkitUtil.java | 40 ++----- .../worldedit/bukkit/entity/BukkitEntity.java | 51 --------- .../worldedit/bukkit/entity/BukkitExpOrb.java | 50 --------- .../worldedit/bukkit/entity/BukkitItem.java | 44 -------- .../bukkit/entity/BukkitPainting.java | 105 ------------------ 5 files changed, 9 insertions(+), 281 deletions(-) delete mode 100644 src/bukkit/java/com/sk89q/worldedit/bukkit/entity/BukkitEntity.java delete mode 100644 src/bukkit/java/com/sk89q/worldedit/bukkit/entity/BukkitExpOrb.java delete mode 100644 src/bukkit/java/com/sk89q/worldedit/bukkit/entity/BukkitItem.java delete mode 100644 src/bukkit/java/com/sk89q/worldedit/bukkit/entity/BukkitPainting.java diff --git a/src/bukkit/java/com/sk89q/worldedit/bukkit/BukkitUtil.java b/src/bukkit/java/com/sk89q/worldedit/bukkit/BukkitUtil.java index 608b84f9e..947347249 100644 --- a/src/bukkit/java/com/sk89q/worldedit/bukkit/BukkitUtil.java +++ b/src/bukkit/java/com/sk89q/worldedit/bukkit/BukkitUtil.java @@ -19,10 +19,14 @@ package com.sk89q.worldedit.bukkit; -import java.util.List; - +import com.sk89q.worldedit.BlockVector; +import com.sk89q.worldedit.BlockWorldVector; +import com.sk89q.worldedit.LocalWorld; +import com.sk89q.worldedit.Location; 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; @@ -33,26 +37,14 @@ 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 class BukkitUtil { + private BukkitUtil() { } @@ -150,20 +142,6 @@ public 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(); diff --git a/src/bukkit/java/com/sk89q/worldedit/bukkit/entity/BukkitEntity.java b/src/bukkit/java/com/sk89q/worldedit/bukkit/entity/BukkitEntity.java deleted file mode 100644 index dd0adfb83..000000000 --- a/src/bukkit/java/com/sk89q/worldedit/bukkit/entity/BukkitEntity.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * WorldEdit, a Minecraft world manipulation toolkit - * Copyright (C) sk89q - * 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 . - */ - -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; - } -} diff --git a/src/bukkit/java/com/sk89q/worldedit/bukkit/entity/BukkitExpOrb.java b/src/bukkit/java/com/sk89q/worldedit/bukkit/entity/BukkitExpOrb.java deleted file mode 100644 index 8c2d1be3f..000000000 --- a/src/bukkit/java/com/sk89q/worldedit/bukkit/entity/BukkitExpOrb.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * WorldEdit, a Minecraft world manipulation toolkit - * Copyright (C) sk89q - * 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 . - */ - -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; - } -} diff --git a/src/bukkit/java/com/sk89q/worldedit/bukkit/entity/BukkitItem.java b/src/bukkit/java/com/sk89q/worldedit/bukkit/entity/BukkitItem.java deleted file mode 100644 index 208db6933..000000000 --- a/src/bukkit/java/com/sk89q/worldedit/bukkit/entity/BukkitItem.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * WorldEdit, a Minecraft world manipulation toolkit - * Copyright (C) sk89q - * 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 . - */ - -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; - } -} diff --git a/src/bukkit/java/com/sk89q/worldedit/bukkit/entity/BukkitPainting.java b/src/bukkit/java/com/sk89q/worldedit/bukkit/entity/BukkitPainting.java deleted file mode 100644 index 0db7c8304..000000000 --- a/src/bukkit/java/com/sk89q/worldedit/bukkit/entity/BukkitPainting.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * WorldEdit, a Minecraft world manipulation toolkit - * Copyright (C) sk89q - * 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 . - */ - -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 spawnQueue = new ArrayDeque(); - - 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; - } -}