promotional bannermobile promotional banner

CommandAPI

Abandoned
Easier creating Commands

This plugin allows you to register commands without editing the plugin.yml except of dependency e.g.:

depend: [CommandAPI]

A better readable documentation here: https://github.com/ysl3000/CommandAPI/wiki/Documentation

You only have to extend your command from the class CustomCommand. e.g.:

package commands;

import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;

import lib.CustomCommand;
import lib.Factorizer;

public class ConfigReload extends CustomCommand{

public ConfigReload() {
 super("cr", "commandAPI reload", "/cr", "capi.reload", new CommandExecutor() {
			
@Override
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel,
String[] args) {
Factorizer.createHelpFormatLoader().loadConfig();
Factorizer.createPluginConfigLoader().loadConfig();
Factorizer.createCommandConfig().loadConfig();
Factorizer.createSettingsConfig().loadConfig();
sender.sendMessage(Factorizer.createSettingsConfig().
getConfigReloadMessage());
return true;
			}
		});
	}

}

The next step is registering the Command with the Factorizer e.g.:

@Override
public void onEnable(){
Factorizer.createPluginConfigLoader();
Factorizer.createCommandMaper().register(new Help());
Factorizer.createCommandMaper().register(new ConfigReload());
Factorizer.createCommandMaper().register(new HelpPermission());
	}

Each command with it's description, usage, permission and commandname e.g. don't change the key (in this example "cr"):

cr:
   permission: capi.reload
   aliases: []
   usage: /cr
   desc: commandAPI reload
   command: cr

Easier config creation is included too.

Example Config:

package config;

import java.util.ArrayList;

import config.YamlConfigLoader;

public class CommandConfig extends YamlConfigLoader {

public CommandConfig() {
        super("CommandAPI/Commands/", "command.yml");
        this.saveConfig();
 }

public String get(String command, CMD sub, String defaultValue) {

    if (!this.config.contains(command.concat(sub.value()))) {

      this.config.addDefault(command.concat(sub.value()), defaultValue);
      this.config.options().copyDefaults(true);
      this.saveConfig();
      this.loadConfig();
       }
      return this.config.getString(command.concat(sub.value()),
       command.concat(sub.value()));
 }

public ArrayList<String> getAliases(String command,
                        ArrayList<String> defaultValue) {
                
  if (!this.config.contains(command.concat(CMD.ALIASES.value()))) {
   this.config.addDefault(command.concat(CMD.ALIASES.value()),  defaultValue);
   this.config.options().copyDefaults(true);
   this.saveConfig();
   this.loadConfig();
   }
return (ArrayList<String>) this.config.getList(
          command.concat(CMD.ALIASES.value()), defaultValue);
        }

}

I would recommend to register the Config as a Singletonpattern like this.:

public class Factory {

private static CommandConfig commandconfig;

public static CommandConfig createCommandConfig(){
		if(commandconfig==null){
			commandconfig = new CommandConfig();
		}
		return commandconfig;
	}

}

FileTree: - plugins - Commands - command.yml - help.yml - hidden.yml - settings.yml

help.yml :

  • help:
    • format: '&2%command %desc &6%perm'
    • page: '&aHELP'
    • type: '&6type '
    • noperm: §8 color of the description if player has no permissions
    • perm: §7 color of the description if player has permissions
    • registered: true if true only commands registered with this api will be shown

hidden.yml:

  1. Every Plugin listed here will be hidden from the pluginlist /pl or /plugins
  • hidden-plugins:
    • CommandAPI
    • SmartServerTool
    • Groupmanager

settings.yml:

  • message:
    • permission: §4you don't have the permission to perform this command default nopermissionmessage
    • reload: §2Config succesfully reloaded default config has been reloaded message

Github Src: https://github.com/ysl3000/CommandAPI

Plugins implementing this API: - Next version of SmartServerTool: https://github.com/ysl3000/Smart-Server-Tool

The CommandAPI Team

profile avatar
  • 3
    Projects
  • 47.5K
    Downloads

More from Forge_User_76248191

  • SmartServerTool project image

    SmartServerTool

    • 41.5K
    • Bukkit Plugins

    SmartServerTool

    • 41.5K
    • January 29, 2014
    • Bukkit Plugins
    • +3
  • SmartServerTool Recipes project image

    SmartServerTool Recipes

    • 4.7K
    • Bukkit Plugins

    SmartServerTool Recipes

    • 4.7K
    • August 14, 2013
    • Bukkit Plugins
  • Elevators 2 project image

    Elevators 2

    • 0
    • Bukkit Plugins

    Moving elevators and platforms (in any direction and shape).

    • 0
    • March 12, 2013
    • Bukkit Plugins
    • +1
  • SmartServerTool project image

    SmartServerTool

    • 41.5K
    • Bukkit Plugins

    SmartServerTool

    • 41.5K
    • January 29, 2014
    • Bukkit Plugins
    • +3
  • SmartServerTool Recipes project image

    SmartServerTool Recipes

    • 4.7K
    • Bukkit Plugins

    SmartServerTool Recipes

    • 4.7K
    • August 14, 2013
    • Bukkit Plugins
  • Elevators 2 project image

    Elevators 2

    • 0
    • Bukkit Plugins

    Moving elevators and platforms (in any direction and shape).

    • 0
    • March 12, 2013
    • Bukkit Plugins
    • +1