Bukkit  1.4.7-R1.0
 All Classes Namespaces Files Functions Variables Enumerator Pages
PotionType.java
Go to the documentation of this file.
1 package org.bukkit.potion;
2 
3 public enum PotionType {
4  WATER(0, null, 0),
16  ;
17 
18  private final int damageValue, maxLevel;
19  private final PotionEffectType effect;
20 
21  PotionType(int damageValue, PotionEffectType effect, int maxLevel) {
22  this.damageValue = damageValue;
23  this.effect = effect;
24  this.maxLevel = maxLevel;
25  }
26 
28  return effect;
29  }
30 
31  public int getDamageValue() {
32  return damageValue;
33  }
34 
35  public int getMaxLevel() {
36  return maxLevel;
37  }
38 
39  public boolean isInstant() {
40  return effect == null ? true : effect.isInstant();
41  }
42 
43  public static PotionType getByDamageValue(int damage) {
44  for (PotionType type : PotionType.values()) {
45  if (type.damageValue == damage)
46  return type;
47  }
48  return null;
49  }
50 
51  public static PotionType getByEffect(PotionEffectType effectType) {
52  if (effectType == null)
53  return WATER;
54  for (PotionType type : PotionType.values()) {
55  if (effectType.equals(type.effect))
56  return type;
57  }
58  return null;
59  }
60 }