summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorCeltic Minstrel <celtic.minstrel.ca@some.place>2012-02-26 12:53:31 -0500
committerEvilSeph <evilseph@gmail.com>2012-02-29 15:02:59 -0500
commit0db822f6090d08ad12b26fdf5133ae53b6b91eb7 (patch)
tree9bbe19ff05dd85578e9edf7ff20ca9469d6ca25e /src
parent925bf6498c5ebc15ce020a11fcd9678ff00debb9 (diff)
downloadbukkit-0db822f6090d08ad12b26fdf5133ae53b6b91eb7.tar
bukkit-0db822f6090d08ad12b26fdf5133ae53b6b91eb7.tar.gz
bukkit-0db822f6090d08ad12b26fdf5133ae53b6b91eb7.tar.lz
bukkit-0db822f6090d08ad12b26fdf5133ae53b6b91eb7.tar.xz
bukkit-0db822f6090d08ad12b26fdf5133ae53b6b91eb7.zip
Implementation of richer playEffect methods. Addresses BUKKIT-857
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/bukkit/Effect.java60
-rw-r--r--src/main/java/org/bukkit/Material.java7
-rw-r--r--src/main/java/org/bukkit/World.java23
-rw-r--r--src/main/java/org/bukkit/entity/Player.java11
-rw-r--r--src/test/java/org/bukkit/plugin/messaging/TestPlayer.java4
5 files changed, 87 insertions, 18 deletions
diff --git a/src/main/java/org/bukkit/Effect.java b/src/main/java/org/bukkit/Effect.java
index 14c197df..41ebf83b 100644
--- a/src/main/java/org/bukkit/Effect.java
+++ b/src/main/java/org/bukkit/Effect.java
@@ -4,30 +4,41 @@ import java.util.Map;
import com.google.common.collect.Maps;
+import org.bukkit.block.BlockFace;
+import org.bukkit.potion.Potion;
+
/**
* A list of effects that the server is able to send to players.
*/
public enum Effect {
- CLICK2(1000),
- CLICK1(1001),
- BOW_FIRE(1002),
- DOOR_TOGGLE(1003),
- EXTINGUISH(1004),
- RECORD_PLAY(1005),
- GHAST_SHRIEK(1007),
- GHAST_SHOOT(1008),
- BLAZE_SHOOT(1009),
- SMOKE(2000),
- STEP_SOUND(2001),
- POTION_BREAK(2002),
- ENDER_SIGNAL(2003),
- MOBSPAWNER_FLAMES(2004);
+ CLICK2(1000, Type.SOUND),
+ CLICK1(1001, Type.SOUND),
+ BOW_FIRE(1002, Type.SOUND),
+ DOOR_TOGGLE(1003, Type.SOUND),
+ EXTINGUISH(1004, Type.SOUND),
+ RECORD_PLAY(1005, Type.SOUND, Material.class),
+ GHAST_SHRIEK(1007, Type.SOUND),
+ GHAST_SHOOT(1008, Type.SOUND),
+ BLAZE_SHOOT(1009, Type.SOUND),
+ SMOKE(2000, Type.VISUAL, BlockFace.class),
+ STEP_SOUND(2001, Type.SOUND, Material.class),
+ POTION_BREAK(2002, Type.VISUAL, Potion.class),
+ ENDER_SIGNAL(2003, Type.VISUAL),
+ MOBSPAWNER_FLAMES(2004, Type.VISUAL);
private final int id;
+ private final Type type;
+ private final Class<?> data;
private static final Map<Integer, Effect> BY_ID = Maps.newHashMap();
- Effect(int id) {
+ Effect(int id, Type type) {
+ this(id,type,null);
+ }
+
+ Effect(int id, Type type, Class<?> data) {
this.id = id;
+ this.type = type;
+ this.data = data;
}
/**
@@ -40,6 +51,20 @@ public enum Effect {
}
/**
+ * @return The type of the effect.
+ */
+ public Type getType() {
+ return this.type;
+ }
+
+ /**
+ * @return The class which represents data for this effect, or null if none
+ */
+ public Class<?> getData() {
+ return this.data;
+ }
+
+ /**
* Gets the Effect associated with the given ID.
*
* @param id ID of the Effect to return
@@ -54,4 +79,9 @@ public enum Effect {
BY_ID.put(effect.id, effect);
}
}
+
+ /**
+ * Represents the type of an effect.
+ */
+ public enum Type {SOUND, VISUAL}
}
diff --git a/src/main/java/org/bukkit/Material.java b/src/main/java/org/bukkit/Material.java
index e9fadb05..69963a1c 100644
--- a/src/main/java/org/bukkit/Material.java
+++ b/src/main/java/org/bukkit/Material.java
@@ -476,4 +476,11 @@ public enum Material {
BY_NAME.put(material.name(), material);
}
}
+
+ /**
+ * @return True if this material represents a playable music disk.
+ */
+ public boolean isRecord() {
+ return id >= GOLD_RECORD.id && id <= RECORD_11.id;
+ }
}
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
index 1b326a55..080d4153 100644
--- a/src/main/java/org/bukkit/World.java
+++ b/src/main/java/org/bukkit/World.java
@@ -620,7 +620,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
*
* @param location the {@link Location} around which players must be to hear the sound
* @param effect the {@link Effect}
- * @param data a data bit needed for the RECORD_PLAY, SMOKE, and STEP_SOUND sounds
+ * @param data a data bit needed for some effects
*/
public void playEffect(Location location, Effect effect, int data);
@@ -629,12 +629,31 @@ public interface World extends PluginMessageRecipient, Metadatable {
*
* @param location the {@link Location} around which players must be to hear the effect
* @param effect the {@link Effect}
- * @param data a data bit needed for the RECORD_PLAY, SMOKE, and STEP effects
+ * @param data a data bit needed for some effects
* @param radius the radius around the location
*/
public void playEffect(Location location, Effect effect, int data, int radius);
/**
+ * Plays an effect to all players within a default radius around a given location.
+ *
+ * @param location the {@link Location} around which players must be to hear the sound
+ * @param effect the {@link Effect}
+ * @param data a data bit needed for some effects
+ */
+ public <T> void playEffect(Location location, Effect effect, T data);
+
+ /**
+ * Plays an effect to all players within a given radius around a location.
+ *
+ * @param location the {@link Location} around which players must be to hear the effect
+ * @param effect the {@link Effect}
+ * @param data a data bit needed for some effects
+ * @param radius the radius around the location
+ */
+ public <T> void playEffect(Location location, Effect effect, T data, int radius);
+
+ /**
* Get empty chunk snapshot (equivalent to all air blocks), optionally including valid biome
* data. Used for representing an ungenerated chunk, or for fetching only biome data without loading a chunk.
*
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
index dca7e432..60cad93b 100644
--- a/src/main/java/org/bukkit/entity/Player.java
+++ b/src/main/java/org/bukkit/entity/Player.java
@@ -201,11 +201,20 @@ public interface Player extends HumanEntity, CommandSender, OfflinePlayer, Plugi
*
* @param loc the location to play the effect at
* @param effect the {@link Effect}
- * @param data a data bit needed for the RECORD_PLAY, SMOKE, and STEP_SOUND sounds
+ * @param data a data bit needed for some effects
*/
public void playEffect(Location loc, Effect effect, int data);
/**
+ * Plays an effect to just this player.
+ *
+ * @param loc the location to play the effect at
+ * @param effect the {@link Effect}
+ * @param data a data bit needed for some effects
+ */
+ public <T> void playEffect(Location loc, Effect effect, T data);
+
+ /**
* Send a block change. This fakes a block change packet for a user at
* a certain location. This will not actually change the world in any way.
*
diff --git a/src/test/java/org/bukkit/plugin/messaging/TestPlayer.java b/src/test/java/org/bukkit/plugin/messaging/TestPlayer.java
index da6b7d81..e0ce019d 100644
--- a/src/test/java/org/bukkit/plugin/messaging/TestPlayer.java
+++ b/src/test/java/org/bukkit/plugin/messaging/TestPlayer.java
@@ -675,4 +675,8 @@ public class TestPlayer implements Player {
public void removeMetadata(String metadataKey, Plugin owningPlugin) {
throw new UnsupportedOperationException("Not supported yet.");
}
+
+ public <T> void playEffect(Location loc, Effect effect, T data) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
}