001 package org.bukkit; 002 003 import java.util.Map; 004 005 import com.google.common.collect.Maps; 006 007 import org.bukkit.block.BlockFace; 008 import org.bukkit.potion.Potion; 009 010 /** 011 * A list of effects that the server is able to send to players. 012 */ 013 public enum Effect { 014 /** 015 * An alternate click sound. 016 */ 017 CLICK2(1000, Type.SOUND), 018 /** 019 * A click sound. 020 */ 021 CLICK1(1001, Type.SOUND), 022 /** 023 * Sound of a bow firing. 024 */ 025 BOW_FIRE(1002, Type.SOUND), 026 /** 027 * Sound of a door opening/closing. 028 */ 029 DOOR_TOGGLE(1003, Type.SOUND), 030 /** 031 * Sound of fire being extinguished. 032 */ 033 EXTINGUISH(1004, Type.SOUND), 034 /** 035 * A song from a record. Needs the record item ID as additional info 036 */ 037 RECORD_PLAY(1005, Type.SOUND, Material.class), 038 /** 039 * Sound of ghast shrieking. 040 */ 041 GHAST_SHRIEK(1007, Type.SOUND), 042 /** 043 * Sound of ghast firing. 044 */ 045 GHAST_SHOOT(1008, Type.SOUND), 046 /** 047 * Sound of blaze firing. 048 */ 049 BLAZE_SHOOT(1009, Type.SOUND), 050 /** 051 * Sound of zombies chewing on wooden doors. 052 */ 053 ZOMBIE_CHEW_WOODEN_DOOR(1010, Type.SOUND), 054 /** 055 * Sound of zombies chewing on iron doors. 056 */ 057 ZOMBIE_CHEW_IRON_DOOR(1011, Type.SOUND), 058 /** 059 * Sound of zombies destroying a door. 060 */ 061 ZOMBIE_DESTROY_DOOR(1012, Type.SOUND), 062 /** 063 * A visual smoke effect. Needs direction as additional info. 064 */ 065 SMOKE(2000, Type.VISUAL, BlockFace.class), 066 /** 067 * Sound of a block breaking. Needs block ID as additional info. 068 */ 069 STEP_SOUND(2001, Type.SOUND, Material.class), 070 /** 071 * Visual effect of a splash potion breaking. Needs potion data value as 072 * additional info. 073 */ 074 POTION_BREAK(2002, Type.VISUAL, Potion.class), 075 /** 076 * An ender eye signal; a visual effect. 077 */ 078 ENDER_SIGNAL(2003, Type.VISUAL), 079 /** 080 * The flames seen on a mobspawner; a visual effect. 081 */ 082 MOBSPAWNER_FLAMES(2004, Type.VISUAL); 083 084 private final int id; 085 private final Type type; 086 private final Class<?> data; 087 private static final Map<Integer, Effect> BY_ID = Maps.newHashMap(); 088 089 Effect(int id, Type type) { 090 this(id,type,null); 091 } 092 093 Effect(int id, Type type, Class<?> data) { 094 this.id = id; 095 this.type = type; 096 this.data = data; 097 } 098 099 /** 100 * Gets the ID for this effect. 101 * 102 * @return ID of this effect 103 * @deprecated Magic value 104 */ 105 @Deprecated 106 public int getId() { 107 return this.id; 108 } 109 110 /** 111 * @return The type of the effect. 112 */ 113 public Type getType() { 114 return this.type; 115 } 116 117 /** 118 * @return The class which represents data for this effect, or null if 119 * none 120 */ 121 public Class<?> getData() { 122 return this.data; 123 } 124 125 /** 126 * Gets the Effect associated with the given ID. 127 * 128 * @param id ID of the Effect to return 129 * @return Effect with the given ID 130 * @deprecated Magic value 131 */ 132 @Deprecated 133 public static Effect getById(int id) { 134 return BY_ID.get(id); 135 } 136 137 static { 138 for (Effect effect : values()) { 139 BY_ID.put(effect.id, effect); 140 } 141 } 142 143 /** 144 * Represents the type of an effect. 145 */ 146 public enum Type {SOUND, VISUAL} 147 }