-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCostSpell.java
47 lines (37 loc) · 1.46 KB
/
CostSpell.java
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
public class CostSpell extends Spell {
MagicSpellsListener listener;
// strings
private String STR_USAGE;
private String STR_NO_SPELL;
private String STR_COST_PREFIX;
public CostSpell(MagicSpellsListener listener, PropertiesFile properties) {
super(listener, properties);
this.listener = listener;
listener.registerSpellName(properties.getString("cost-spellname","cost"),this,properties.getString("cost-desc","Shows the reagent cost of a spell"));
// get properties
STR_USAGE = properties.getString("cost-usage-str","Use /cast cost [spell] to check a spell's reagent cost.");
STR_NO_SPELL = properties.getString("cost-invalid-spell-str","You do not know that spell.");
STR_COST_PREFIX = properties.getString("cost-prefix-str","[spell] reagent cost:");
}
public boolean cast(Player player, String [] command) {
if (command.length != 3) {
player.sendMessage(Spell.TEXT_COLOR + STR_USAGE);
} else if (!listener.canCastSpell(player,command[2])) {
player.sendMessage(Spell.TEXT_COLOR + STR_NO_SPELL);
} else {
String [] costs = listener.getSpellNames().get(command[2]).getCostDesc(command[2]).split("@");
for (int i = 0; i < costs.length; i++) {
if (!costs[i].equals("")) {
player.sendMessage(Spell.TEXT_COLOR + (i==0?STR_COST_PREFIX.replace("[spell]",command[2])+" ":" ") + costs[i]);
}
}
}
return true;
}
public boolean needsLearned() {
return false;
}
public String getCostDesc(String s) {
return "free";
}
}