A lightweight,annotation based, easy to use command framework for bukkit and bungeecord
If you need help please come to our support discord: https://discord.com/invite/xaGZhwW
this framework is not working on 1.13x - 1.16x servers
Maven
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
## for bukkit projects
<dependency>
<groupId>com.github.ShiryuDev.commands</groupId>
<artifactId>bukkit</artifactId>
<version>1.5.2</version>
</dependency>
## for bungeecord projects
<dependency>
<groupId>com.github.ShiryuDev.commands</groupId>
<artifactId>bungee</artifactId>
<version>1.5.2</version>
</dependency>
</dependencies>
making basic commands
public class Example implements CommandHandler {
@Command(names = {"mycommand", "mycommand help"}, permission = "mycommand.help")
public void myCommand(@NotNull final CommandSender sender){
sender.sendMessage("test");
}
@Command(names = {"mycommand withparameter"}, permission = "mycommand.withparameter")
public void myCommandParameter(@NotNull final Player sender, @Parameter(name="target") Player target){
player.sendMessage("player target: " + target.getName());
}
}
creating parameter types for your own objects
public class SapphireRankParameterType implements ParameterType<SapphireRank> {
@NotNull
@Override
public SapphireRank transform(@NotNull final SimpleSender sender, @NotNull final String value) {
final SapphireRank rank = Sapphire.getInstance()
.getManagerHandler()
.getManager(RankManager.class)
.findRank(value)
.orElse(null);
if (rank == null){
sender.sendMessage(String.format(CommandLocale.NOT_FOUND, value));
return null;
}
return rank;
}
@Override
@NotNull
public List<String> tabComplete(@NotNull final SimpleSender sender, @NotNull final Set<String> set, @NotNull final String value) {
return Sapphire.getInstance()
.getManagerHandler()
.getManager(RankManager.class)
.getRANKS()
.stream()
.filter(rank -> StringUtils.startsWithIgnoreCase(value, rank.getName()))
.map(SapphireRank::getName)
.collect(Collectors.toList());
}
}
registering to the bukkit
public class ExamplePlugin extends JavaPlugin {
@Override
public void onEnable(){
final BukkitCommandManager commandManager = new BukkitCommandManager();
commandManager.handle(this);
commandManager.registerCommand(new Commands());
}
}
registering to the bungeecord
public class ExamplePlugin extends Plugin {
@Override
public void onEnable() {
final BungeeCommandManager commandManager = new BungeeCommandManager();
commandManager.handle(this);
commandManager.registerCommand(new Commands());
}
}