-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommandExecuter.java
More file actions
109 lines (101 loc) · 3.35 KB
/
CommandExecuter.java
File metadata and controls
109 lines (101 loc) · 3.35 KB
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
package incineratorcow2.incineratorcow2;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Cow;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
public class CommandExecuter implements CommandExecutor{
private JavaPlugin _mainPlugin;
private Cow _myCow;
public CommandExecuter(JavaPlugin mainPlugin, Cow myCow) {
_mainPlugin = mainPlugin;
_myCow = myCow;
}
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (label.equalsIgnoreCase("fire")) {
if (!IsCommandValid(sender, _myCow)) {
return false;
}
AttackProjectile attack = new AttackProjectile(_mainPlugin, _myCow);
attack.Projectile();
return true;
}
else if (label.equalsIgnoreCase("charge")) {
if (!IsCommandValid(sender, _myCow)) {
return false;
}
AttackCharge attack = new AttackCharge(_mainPlugin, _myCow);
attack.Charge();
return true;
}
else if (label.equalsIgnoreCase("missileSheep")) {
if (!IsCommandValid(sender, _myCow)) {
return false;
}
AttackSheep attack = new AttackSheep(_mainPlugin, _myCow);
attack.Sheep();
return true;
}
else if (label.equalsIgnoreCase("moat")) {
if (!IsCommandValid(sender, _myCow)) {
return false;
}
AttackMoat attack = new AttackMoat(_mainPlugin, _myCow);
attack.Moat();
return true;
}
else if (label.equalsIgnoreCase("tunnel")) {
if (!IsCommandValid(sender, _myCow)) {
return false;
}
AttackTunnel tunnel = new AttackTunnel(_mainPlugin, _myCow);
tunnel.Tunnel();
return true;
}
else if (label.equalsIgnoreCase("throw")) {
if (!IsCommandValid(sender, _myCow)) {
return false;
}
AttackThrow AttackThrow = new AttackThrow(_mainPlugin, _myCow);
AttackThrow.Throw();
return true;
}
else if (label.equalsIgnoreCase("debug")) {
if (!IsCommandValid(sender, _myCow)) {
return false;
}
// AttackThrow2 throw2 = new AttackThrow2(_mainPlugin, _myCow);
// throw2.Throw2();
//AIManager AI = new AIManager(_mainPlugin, _myCow);
//AI.RunPhaseOne2();
//phaseOne.SwitchTest();
//myCow.addScoreboardTag("Ready");
return true;
}
return false;
}
private boolean IsPlayer(CommandSender sender) {
if (!(sender instanceof Player)) {
sender.sendMessage("Console can't use this command");
return false;
}
return true;
}
private boolean IsCommandValid(CommandSender sender, Cow cow)
{
if (!IsPlayer(sender)) {
return false;
}
/*
if (!(sender instanceof Player)) {
sender.sendMessage("Console can't use this command");
return false;
}
*/
if(cow.isDead()) {
return false;
}
return true;
}
}