-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommands.java
114 lines (93 loc) · 3.16 KB
/
commands.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
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
package com.example.roguecraftplugin;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
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);
}
public class RoguecraftCommand implements CommandExecutor {
private final RoguecraftPlugin plugin;
public RoguecraftCommand(RoguecraftPlugin plugin) {
this.plugin = plugin;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage("This command can only be executed by a player.");
return true;
}
Player player = (Player) sender;
RoguecraftPlayerData playerData = plugin.getPlayerData(player);
if (args.length == 0) {
// Display player's stats or other information
player.sendMessage("Your level: " + playerData.getLevel());
player.sendMessage("Your experience: " + playerData.getExperience());
return true;
}
if (args.length >= 1 && args[0].equalsIgnoreCase("skill")) {
// Handle skill-related commands
if (args.length == 2 && args[1].equalsIgnoreCase("fireball")) {
// Cast the fireball skill
Skill fireball = plugin.getSkillManager().getSkill("Fireball");
if (fireball != null) {
plugin.getCombatManager().castSkill(player, fireball);
} else {
player.sendMessage("The Fireball skill is not registered.");
}
return true;
}
// Add more skill-related commands here
}
// Handle other commands here
return false;
}
}