Skip to content

Commit e32ac96

Browse files
Started zetacore docs
1 parent bc03649 commit e32ac96

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package com.zetaplugins.pluginTest;
2+
3+
import com.zetaplugins.zetacore.annotations.AutoRegisterCommand;
4+
import com.zetaplugins.zetacore.commands.ArgumentList;
5+
import com.zetaplugins.zetacore.commands.PluginCommand;
6+
import com.zetaplugins.zetacore.commands.exceptions.CommandException;
7+
import org.bukkit.command.Command;
8+
import org.bukkit.command.CommandSender;
9+
import org.bukkit.entity.Player;
10+
11+
import java.util.List;
12+
13+
@AutoRegisterCommand(
14+
commands = "greet",
15+
description = "Greets a player",
16+
usage = "/greet <player>",
17+
permission = "myplugin.command.greet",
18+
aliases = {"hello"}
19+
)
20+
public class GreetCommand extends PluginCommand<PluginTest> {
21+
22+
public GreetCommand(PluginTest plugin) {
23+
super(plugin);
24+
}
25+
26+
@Override
27+
public boolean execute(CommandSender sender, Command command, String label, ArgumentList args) throws CommandException {
28+
Player targetPlayer = args.getPlayer(0, getPlugin());
29+
30+
if (targetPlayer == null) {
31+
sender.sendMessage("Player " + args.getString(0, "[no name]") + " not found.");
32+
return false;
33+
}
34+
35+
sender.sendMessage("Hello, " + targetPlayer.getName() + "!");
36+
return true;
37+
}
38+
39+
@Override
40+
public List<String> tabComplete(CommandSender sender, Command command, ArgumentList args) {
41+
if (args.getCurrentArgIndex() == 0) return getPlayerOptions(args.getCurrentArg());
42+
else return List.of();
43+
}
44+
}

0 commit comments

Comments
 (0)