1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
package org.bukkit.potion;
public enum PotionType {
WATER(0, null, 0),
REGEN(1, PotionEffectType.REGENERATION, 2),
SPEED(2, PotionEffectType.SPEED, 2),
FIRE_RESISTANCE(3, PotionEffectType.FIRE_RESISTANCE, 1),
POISON(4, PotionEffectType.POISON, 2),
INSTANT_HEAL(5, PotionEffectType.HEAL, 2),
NIGHT_VISION(6, PotionEffectType.NIGHT_VISION, 1),
WEAKNESS(8, PotionEffectType.WEAKNESS, 1),
STRENGTH(9, PotionEffectType.INCREASE_DAMAGE, 2),
SLOWNESS(10, PotionEffectType.SLOW, 1),
INSTANT_DAMAGE(12, PotionEffectType.HARM, 2),
INVISIBILTY(14, PotionEffectType.INVISIBILITY, 1),
;
private final int damageValue, maxLevel;
private final PotionEffectType effect;
PotionType(int damageValue, PotionEffectType effect, int maxLevel) {
this.damageValue = damageValue;
this.effect = effect;
this.maxLevel = maxLevel;
}
public PotionEffectType getEffectType() {
return effect;
}
public int getDamageValue() {
return damageValue;
}
public int getMaxLevel() {
return maxLevel;
}
public boolean isInstant() {
return effect == null ? true : effect.isInstant();
}
public static PotionType getByDamageValue(int damage) {
for (PotionType type : PotionType.values()) {
if (type.damageValue == damage)
return type;
}
return null;
}
public static PotionType getByEffect(PotionEffectType effectType) {
if (effectType == null)
return WATER;
for (PotionType type : PotionType.values()) {
if (effectType.equals(type.effect))
return type;
}
return null;
}
}
|