From 36fbfa409f9a0724e51429eb92669a2dd753b831 Mon Sep 17 00:00:00 2001 From: TomyLobo Date: Mon, 28 Nov 2011 07:13:19 +0100 Subject: [PATCH] Added LocalWorld.playEffect and an implementation for Bukkit. --- .../java/com/sk89q/worldedit/LocalWorld.java | 11 ++++++++++ .../sk89q/worldedit/bukkit/BukkitWorld.java | 22 +++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/src/main/java/com/sk89q/worldedit/LocalWorld.java b/src/main/java/com/sk89q/worldedit/LocalWorld.java index 6002d2377..27e587d0c 100644 --- a/src/main/java/com/sk89q/worldedit/LocalWorld.java +++ b/src/main/java/com/sk89q/worldedit/LocalWorld.java @@ -343,4 +343,15 @@ public abstract class LocalWorld { public void fixLighting(Iterable chunks) { } + + /** + * Plays the minecraft effect with the given type and data at the given position. + * + * @param position + * @param type + * @param data + */ + public boolean playEffect(Vector position, int type, int data) { + return false; + } } diff --git a/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java b/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java index dc7f3aa75..63272c9e4 100644 --- a/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java +++ b/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java @@ -23,6 +23,7 @@ import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -47,6 +48,7 @@ import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; import org.bukkit.Bukkit; import org.bukkit.Chunk; +import org.bukkit.Effect; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.TreeType; @@ -57,6 +59,7 @@ import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.LocalWorld; import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector2D; +import com.sk89q.worldedit.WorldVector; import com.sk89q.worldedit.blocks.*; import com.sk89q.worldedit.EntityType; import com.sk89q.worldedit.regions.Region; @@ -865,4 +868,23 @@ public class BukkitWorld extends LocalWorld { } } } + + private static final Map effects = new HashMap(); + static { + for (Effect effect : Effect.values()) { + effects.put(effect.getId(), effect); + } + } + + @Override + public boolean playEffect(Vector position, int type, int data) { + final Effect effect = effects.get(type); + if (effect == null) { + return false; + } + + world.playEffect(BukkitUtil.toLocation(world, position), effect, data); + + return true; + } }