-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathskills.java
66 lines (52 loc) · 1.46 KB
/
skills.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package com.example.roguecraftplugin;
import java.util.HashMap;
import java.util.Map;
public class SkillManager {
private Map<String, Skill> skills;
public SkillManager() {
this.skills = new HashMap<>();
}
public void registerSkill(Skill skill) {
skills.put(skill.getName(), skill);
}
public Skill getSkill(String name) {
return skills.get(name);
}
public void learnSkill(Player player, Skill skill) {
RoguecraftPlayerData playerData = plugin.getPlayerData(player);
playerData.learnSkill(skill);
}
public void useSkill(Player player, Skill skill) {
RoguecraftPlayerData playerData = plugin.getPlayerData(player);
if (playerData.hasSkill(skill)) {
skill.use(player);
}
}
}
public class Skill {
private String name;
private String description;
private int cooldown;
private SkillEffect effect;
public Skill(String name, String description, int cooldown, SkillEffect effect) {
this.name = name;
this.description = description;
this.cooldown = cooldown;
this.effect = effect;
}
public String getName() {
return name;
}
public String getDescription() {
return description;
}
public int getCooldown() {
return cooldown;
}
public void use(Player player) {
effect.apply(player);
}
}
public interface SkillEffect {
void apply(Player player);
}