Injecting sub commands
Since 1.0.0
import net.codersky.mcutils.general.MCCommand;
import net.codersky.clans.ClanPlugin;
public class ClanInfo extends MCPlugin<ClanPlugin> {
public ClanCommand(ClanPlugin plugin) {
// The sub command name will be "info", but yes, aliases are supported.
super(plugin, "info");
// Making this command player only isn't required as ClanCommand
// will take preference and prevent the console from reaching this point.
}
@Override
public boolean onCommand(CommandSender sender, String[] args) {
// Example code to send the info of a clan to the sender.
// The sender can be safely casted to player because of class restrictions.
Player receiver = (Player) sender;
// We get the clan, which may be null, but let's ignore that for now.
Clan clan = getPlugin().getClanManager().getClan(receiver);
clan.sendInfo(sender);
}
@Override
public List<String> onTab(CommandSender sender, String[] args) {
// We just return null as no suggestions will be made by this
// specific command at this point to the sender.
return null;
}
}Automatizations
Last updated