summaryrefslogtreecommitdiffstats
path: root/Essentials/src/com/earth2me/essentials/Potions.java
blob: e79237a0fb065280091510b27e1cc9078fb31dc7 (plain)
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
package com.earth2me.essentials;

import com.earth2me.essentials.utils.NumberUtil;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.bukkit.potion.PotionEffectType;


public class Potions
{
	private static final Map<String, PotionEffectType> POTIONS = new HashMap<String, PotionEffectType>();
	private static final Map<String, PotionEffectType> ALIASPOTIONS = new HashMap<String, PotionEffectType>();

	static
	{

		POTIONS.put("speed", PotionEffectType.SPEED);
		ALIASPOTIONS.put("fast", PotionEffectType.SPEED);
		ALIASPOTIONS.put("runfast", PotionEffectType.SPEED);
		ALIASPOTIONS.put("sprint", PotionEffectType.SPEED);
		ALIASPOTIONS.put("swift", PotionEffectType.SPEED);

		POTIONS.put("slowness", PotionEffectType.SLOW);
		ALIASPOTIONS.put("slow", PotionEffectType.SLOW);
		ALIASPOTIONS.put("sluggish", PotionEffectType.SLOW);

		POTIONS.put("haste", PotionEffectType.FAST_DIGGING);
		ALIASPOTIONS.put("superpick", PotionEffectType.FAST_DIGGING);
		ALIASPOTIONS.put("quickmine", PotionEffectType.FAST_DIGGING);
		ALIASPOTIONS.put("digspeed", PotionEffectType.FAST_DIGGING);
		ALIASPOTIONS.put("digfast", PotionEffectType.FAST_DIGGING);
		ALIASPOTIONS.put("sharp", PotionEffectType.FAST_DIGGING);

		POTIONS.put("fatigue", PotionEffectType.SLOW_DIGGING);
		ALIASPOTIONS.put("slow", PotionEffectType.SLOW_DIGGING);
		ALIASPOTIONS.put("dull", PotionEffectType.SLOW_DIGGING);

		POTIONS.put("strength", PotionEffectType.INCREASE_DAMAGE);
		ALIASPOTIONS.put("strong", PotionEffectType.INCREASE_DAMAGE);
		ALIASPOTIONS.put("bull", PotionEffectType.INCREASE_DAMAGE);
		ALIASPOTIONS.put("attack", PotionEffectType.INCREASE_DAMAGE);

		POTIONS.put("heal", PotionEffectType.HEAL);
		ALIASPOTIONS.put("healthy", PotionEffectType.HEAL);
		ALIASPOTIONS.put("instaheal", PotionEffectType.HEAL);

		POTIONS.put("harm", PotionEffectType.HARM);
		ALIASPOTIONS.put("harming", PotionEffectType.HARM);
		ALIASPOTIONS.put("injure", PotionEffectType.HARM);
		ALIASPOTIONS.put("damage", PotionEffectType.HARM);
		ALIASPOTIONS.put("inflict", PotionEffectType.HARM);

		POTIONS.put("jump", PotionEffectType.JUMP);
		ALIASPOTIONS.put("leap", PotionEffectType.JUMP);

		POTIONS.put("nausea", PotionEffectType.CONFUSION);
		ALIASPOTIONS.put("sick", PotionEffectType.CONFUSION);
		ALIASPOTIONS.put("sickness", PotionEffectType.CONFUSION);
		ALIASPOTIONS.put("confusion", PotionEffectType.CONFUSION);

		POTIONS.put("regeneration", PotionEffectType.REGENERATION);
		ALIASPOTIONS.put("regen", PotionEffectType.REGENERATION);

		POTIONS.put("resistance", PotionEffectType.DAMAGE_RESISTANCE);
		ALIASPOTIONS.put("dmgresist", PotionEffectType.DAMAGE_RESISTANCE);
		ALIASPOTIONS.put("armor", PotionEffectType.DAMAGE_RESISTANCE);

		POTIONS.put("fireresist", PotionEffectType.FIRE_RESISTANCE);
		ALIASPOTIONS.put("fireresistance", PotionEffectType.FIRE_RESISTANCE);
		ALIASPOTIONS.put("resistfire", PotionEffectType.FIRE_RESISTANCE);

		POTIONS.put("waterbreath", PotionEffectType.WATER_BREATHING);
		ALIASPOTIONS.put("waterbreathing", PotionEffectType.WATER_BREATHING);

		POTIONS.put("invisibility", PotionEffectType.INVISIBILITY);
		ALIASPOTIONS.put("invisible", PotionEffectType.INVISIBILITY);
		ALIASPOTIONS.put("invis", PotionEffectType.INVISIBILITY);
		ALIASPOTIONS.put("vanish", PotionEffectType.INVISIBILITY);
		ALIASPOTIONS.put("disappear", PotionEffectType.INVISIBILITY);

		POTIONS.put("blindness", PotionEffectType.BLINDNESS);
		ALIASPOTIONS.put("blind", PotionEffectType.BLINDNESS);

		POTIONS.put("nightvision", PotionEffectType.NIGHT_VISION);
		ALIASPOTIONS.put("vision", PotionEffectType.NIGHT_VISION);

		POTIONS.put("hunger", PotionEffectType.HUNGER);
		ALIASPOTIONS.put("hungry", PotionEffectType.HUNGER);
		ALIASPOTIONS.put("starve", PotionEffectType.HUNGER);

		POTIONS.put("weakness", PotionEffectType.WEAKNESS);
		ALIASPOTIONS.put("weak", PotionEffectType.WEAKNESS);

		POTIONS.put("poison", PotionEffectType.POISON);
		ALIASPOTIONS.put("venom", PotionEffectType.POISON);

		POTIONS.put("wither", PotionEffectType.WITHER);
		ALIASPOTIONS.put("decay", PotionEffectType.WITHER);


		try // 1.6 update
		{
			POTIONS.put("healthboost", PotionEffectType.HEALTH_BOOST);
			ALIASPOTIONS.put("boost", PotionEffectType.HEALTH_BOOST);

			POTIONS.put("absorption", PotionEffectType.ABSORPTION);
			ALIASPOTIONS.put("absorb", PotionEffectType.ABSORPTION);

			POTIONS.put("saturation", PotionEffectType.SATURATION);
			ALIASPOTIONS.put("food", PotionEffectType.SATURATION);
		}
		catch (java.lang.NoSuchFieldError e)
		{
			Essentials.wrongVersion();
		}
		
		try // 1.7 update
		{
			POTIONS.put("waterbreathing", PotionEffectType.WATER_BREATHING);
			ALIASPOTIONS.put("underwaterbreathing", PotionEffectType.WATER_BREATHING);
			ALIASPOTIONS.put("waterbreath", PotionEffectType.WATER_BREATHING);
			ALIASPOTIONS.put("underwaterbreath", PotionEffectType.WATER_BREATHING);
			ALIASPOTIONS.put("air", PotionEffectType.WATER_BREATHING);
		}
		catch (java.lang.NoSuchFieldError e)
		{
			Essentials.wrongVersion();
		}
	}

	public static PotionEffectType getByName(String name)
	{
		PotionEffectType peffect;
		if (NumberUtil.isInt(name))
		{
			peffect = PotionEffectType.getById(Integer.parseInt(name));
		}
		else
		{
			peffect = PotionEffectType.getByName(name.toUpperCase(Locale.ENGLISH));
		}
		if (peffect == null)
		{
			peffect = POTIONS.get(name.toLowerCase(Locale.ENGLISH));
		}
		if (peffect == null)
		{
			peffect = ALIASPOTIONS.get(name.toLowerCase(Locale.ENGLISH));
		}
		return peffect;
	}

	public static Set<Entry<String, PotionEffectType>> entrySet()
	{
		return POTIONS.entrySet();
	}
}