* Add CommandManager#unregisterCommand(BaseCommand), CommandManager#unregisterCommands(), and CommandManager#getCommandByAlias(String) + implementations * Add to knownCommands upon registration * allSuccess was not the right comparison to check * Add a built-in listener to BukkitCommandManager to listen for plugin disable, so as to unregister commands automatically. * Fix unregistration, because Bukkit is weird. Also ensure we iterate all the BaseCommand's Commands. * Stop abusing AtomicBoolean, use BitSet instead! * Switch to more standard way of checking allSuccess * Didn't see the cool shorthand, changed * Remove pom change * Remove unused imports * Unnecessary to set the first index of that array
Aikar Command Framework (ACF)
Purpose
This is the Framework used on Empire Minecraft.
Many people have wanted to use this framework for themselves, so I am trying to make it general purpose (with help from the community) so that others can use it just as simple as they can TaskChain now.
Beta Testing
I believe the framework may be usable at this stage. Beta testers welcome
See Using ACF on how to add ACF to your plugin and using it.
THE API MAY BREAK! We are on:
- GROUP: co.aikar
- ARTIFACTID: acf-core
- VERSION
0.4.0-SNAPSHOT
Targeted Platforms
Requires CraftBukkit, Spigot or Paper.
We have no intentions to support other Servers. If you want on Sponge or something else, you will need to fork and add support for it.
Example
@CommandAlias("res|residence|resadmin")
public class ResidenceCommand extends BaseCommand {
@Subcommand("pset")
@CommandCompletion("@allplayers:30 @flags @flagstates")
public void onResFlagPSet(Player player, @Flags("admin") Residence res, EmpireUser[] users, String flag, @Values("@flagstates") String state) {
res.getPermissions().setPlayerFlag(player, Stream.of(users).map(EmpireUser::getName).collect(Collectors.joining(",")), flag, state, resadmin, true);
}
@Subcommand("area replace")
@CommandPermission("residence.admin")
public void onResAreaReplace(Player player, CuboidSelection selection, @Flags("verbose") Residence res, @Default("main") @Single String area) {
res.replaceArea(player,
new CuboidArea(selection),
area,
resadmin);
}
}
@CommandAlias("gr")
public class GroupCommand extends BaseCommand {
public GroupCommand() {
super("group");
}
@Subcommand("invitenear|invnear")
@CommandAlias("invitenear|invnear|ginvnear")
@Syntax("[radius=32] &e- Invite Nearby Players to the group.")
public void onInviteNear(Player player, @Default("32") Integer radius) {
int maxRadius = UserUtil.isModerator(player) ? 256 : 64;
radius = !UserUtil.isSrStaff(player) ? Math.min(maxRadius, radius) : radius;
List<String> names = player.getNearbyEntities(radius, Math.min(128, radius), radius)
.stream().filter((e) -> e instanceof Player && !UserUtil.isVanished((Player) e))
.map(CommandSender::getName)
.collect(Collectors.toList());
Groups.invitePlayers(player, names);
}
@Subcommand("invite|inv")
@CommandAlias("invite|inv|ginv")
@Syntax("<name> [name2] [name3] &e- Invite Players to the group.")
public void onInvite(Player player, String[] names) {
Groups.invitePlayers(player, names);
}
@Subcommand("kick|gkick")
@CommandAlias("gkick")
@Syntax("<player> &e- Kick Player from the group.")
public void onKick(Player player, @Flags("leader") Group group, OnlinePlayer toKick) {
group.kickPlayer(player, toKick.getPlayer());
}
}
Why does it require Java 8+?
Get off your dinosaur and get on this rocket ship!
Dinosaurs have been dead for a long time, so get off it before you start to smell.
Contributing
See Issues section.
Join #aikar on Spigot IRC - irc.spi.gt to discuss.
Or Code With Aikar Discord.
License
As with all my other public projects
Commands (c) Daniel Ennis (Aikar) 2016-2017.