mirror of
https://github.com/dmulloy2/ProtocolLib.git
synced 2024-11-27 21:26:17 +01:00
Allow particles to be looked up using their name
This commit is contained in:
parent
3f5abe8719
commit
63babc4ca1
@ -168,63 +168,80 @@ public abstract class EnumWrappers {
|
||||
}
|
||||
|
||||
public enum Particle {
|
||||
EXPLOSION_NORMAL(0, true),
|
||||
EXPLOSION_LARGE(1, true),
|
||||
EXPLOSION_HUGE(2, true),
|
||||
FIREWORKS_SPARK(3, false),
|
||||
WATER_BUBBLE(4, false),
|
||||
WATER_SPLASH(5, false),
|
||||
WATER_WAKE(6, false),
|
||||
SUSPENDED(7, false),
|
||||
SUSPENDED_DEPTH(8, false),
|
||||
CRIT(9, false),
|
||||
CRIT_MAGIC(10, false),
|
||||
SMOKE_NORMAL(11, false),
|
||||
SMOKE_LARGE(12, false),
|
||||
SPELL(13, false),
|
||||
SPELL_INSTANT(14, false),
|
||||
SPELL_MOB(15, false),
|
||||
SPELL_MOB_AMBIENT(16, false),
|
||||
SPELL_WITCH(17, false),
|
||||
DRIP_WATER(18, false),
|
||||
DRIP_LAVA(19, false),
|
||||
VILLAGER_ANGRY(20, false),
|
||||
VILLAGER_HAPPY(21, false),
|
||||
TOWN_AURA(22, false),
|
||||
NOTE(23, false),
|
||||
PORTAL(24, false),
|
||||
ENCHANTMENT_TABLE(25, false),
|
||||
FLAME(26, false),
|
||||
LAVA(27, false),
|
||||
FOOTSTEP(28, false),
|
||||
CLOUD(29, false),
|
||||
REDSTONE(30, false),
|
||||
SNOWBALL(31, false),
|
||||
SNOW_SHOVEL(32, false),
|
||||
SLIME(33, false),
|
||||
HEART(34, false),
|
||||
BARRIER(35, false),
|
||||
ITEM_CRACK(36, false),
|
||||
BLOCK_CRACK(37, false),
|
||||
BLOCK_DUST(38, false),
|
||||
WATER_DROP(39, false),
|
||||
ITEM_TAKE(40, false),
|
||||
MOB_APPEARANCE(41, true);
|
||||
EXPLOSION_NORMAL("explode", 0, true),
|
||||
EXPLOSION_LARGE("largeexplode", 1, true),
|
||||
EXPLOSION_HUGE("hugeexplosion", 2, true),
|
||||
FIREWORKS_SPARK("fireworksSpark", 3, false),
|
||||
WATER_BUBBLE("bubble", 4, false),
|
||||
WATER_SPLASH("splash", 5, false),
|
||||
WATER_WAKE("wake", 6, false),
|
||||
SUSPENDED("suspended", 7, false),
|
||||
SUSPENDED_DEPTH("depthsuspend", 8, false),
|
||||
CRIT("crit", 9, false),
|
||||
CRIT_MAGIC("magicCrit", 10, false),
|
||||
SMOKE_NORMAL("smoke", 11, false),
|
||||
SMOKE_LARGE("largesmoke", 12, false),
|
||||
SPELL("spell", 13, false),
|
||||
SPELL_INSTANT("instantSpell", 14, false),
|
||||
SPELL_MOB("mobSpell", 15, false),
|
||||
SPELL_MOB_AMBIENT("mobSpellAmbient", 16, false),
|
||||
SPELL_WITCH("witchMagic", 17, false),
|
||||
DRIP_WATER("dripWater", 18, false),
|
||||
DRIP_LAVA("dripLava", 19, false),
|
||||
VILLAGER_ANGRY("angryVillager", 20, false),
|
||||
VILLAGER_HAPPY("happyVillager", 21, false),
|
||||
TOWN_AURA("townaura", 22, false),
|
||||
NOTE("note", 23, false),
|
||||
PORTAL("portal", 24, false),
|
||||
ENCHANTMENT_TABLE("enchantmenttable", 25, false),
|
||||
FLAME("flame", 26, false),
|
||||
LAVA("lava", 27, false),
|
||||
FOOTSTEP("footstep", 28, false),
|
||||
CLOUD("cloud", 29, false),
|
||||
REDSTONE("reddust", 30, false),
|
||||
SNOWBALL("snowballpoof", 31, false),
|
||||
SNOW_SHOVEL("snowshovel", 32, false),
|
||||
SLIME("slime", 33, false),
|
||||
HEART("heart", 34, false),
|
||||
BARRIER("barrier", 35, false),
|
||||
ITEM_CRACK("iconcrack_", 36, false, 2),
|
||||
BLOCK_CRACK("blockcrack_", 37, false, 1),
|
||||
BLOCK_DUST("blockdust_", 38, false, 1),
|
||||
WATER_DROP("droplet", 39, false),
|
||||
ITEM_TAKE("take", 40, false),
|
||||
MOB_APPEARANCE("mobappearance", 41, true);
|
||||
|
||||
private static final Map<String, Particle> BY_NAME;
|
||||
private static final Map<Integer, Particle> BY_ID;
|
||||
|
||||
static {
|
||||
BY_ID = new HashMap<Integer, Particle>();
|
||||
BY_NAME = new HashMap<String, Particle>();
|
||||
|
||||
for (Particle particle : values()) {
|
||||
BY_NAME.put(particle.getName().toLowerCase(), particle);
|
||||
BY_ID.put(particle.getId(), particle);
|
||||
}
|
||||
}
|
||||
|
||||
private final String name;
|
||||
private final int id;
|
||||
private final boolean longDistance;
|
||||
private final int dataLength;
|
||||
|
||||
private Particle(int id, boolean longDistance) {
|
||||
private Particle(String name, int id, boolean longDistance) {
|
||||
this(name, id, longDistance, 0);
|
||||
}
|
||||
|
||||
private Particle(String name, int id, boolean longDistance, int dataLength) {
|
||||
this.name = name;
|
||||
this.id = id;
|
||||
this.longDistance = longDistance;
|
||||
this.dataLength = dataLength;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
@ -235,6 +252,14 @@ public abstract class EnumWrappers {
|
||||
return longDistance;
|
||||
}
|
||||
|
||||
public int getDataLength() {
|
||||
return dataLength;
|
||||
}
|
||||
|
||||
public static Particle getByName(String name) {
|
||||
return BY_NAME.get(name.toLowerCase());
|
||||
}
|
||||
|
||||
public static Particle getById(int id) {
|
||||
return BY_ID.get(id);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user