2016-03-02 19:28:01 +00:00
|
|
|
package me.totalfreedom.totalfreedommod.command;
|
2015-10-19 17:43:46 +00:00
|
|
|
|
|
|
|
import lombok.Getter;
|
2016-03-01 16:47:01 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
2015-10-19 17:43:46 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
2015-11-15 23:32:04 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
2015-10-19 17:43:46 +00:00
|
|
|
import net.pravian.aero.command.handler.SimpleCommandHandler;
|
2015-11-15 23:32:04 +00:00
|
|
|
import org.bukkit.ChatColor;
|
2015-10-19 17:43:46 +00:00
|
|
|
|
2016-03-01 16:47:01 +00:00
|
|
|
public class CommandLoader extends FreedomService
|
2015-10-19 17:43:46 +00:00
|
|
|
{
|
2015-11-22 18:26:47 +00:00
|
|
|
|
2015-10-19 17:43:46 +00:00
|
|
|
@Getter
|
|
|
|
private final SimpleCommandHandler<TotalFreedomMod> handler;
|
|
|
|
|
|
|
|
public CommandLoader(TotalFreedomMod plugin)
|
|
|
|
{
|
|
|
|
super(plugin);
|
|
|
|
|
2016-03-02 19:28:01 +00:00
|
|
|
handler = new SimpleCommandHandler<>(plugin);
|
2015-10-19 17:43:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onStart()
|
|
|
|
{
|
|
|
|
handler.clearCommands();
|
2016-05-12 19:40:39 +00:00
|
|
|
handler.setExecutorFactory(new FreedomCommandExecutor.FreedomExecutorFactory(plugin));
|
2015-10-19 17:43:46 +00:00
|
|
|
handler.setCommandClassPrefix("Command_");
|
2016-03-02 19:28:01 +00:00
|
|
|
handler.setPermissionMessage(ChatColor.RED + "You do not have permission to use this command.");
|
|
|
|
handler.setOnlyConsoleMessage(ChatColor.RED + "This command can only be used from the console.");
|
|
|
|
handler.setOnlyPlayerMessage(ChatColor.RED + "This command can only be used by players.");
|
2015-11-15 23:32:04 +00:00
|
|
|
|
2015-10-19 17:43:46 +00:00
|
|
|
handler.loadFrom(FreedomCommand.class.getPackage());
|
2015-11-15 23:32:04 +00:00
|
|
|
handler.registerAll("TotalFreedomMod", true);
|
2015-10-19 17:43:46 +00:00
|
|
|
|
2016-03-06 15:56:15 +00:00
|
|
|
FLog.info("Loaded " + handler.getExecutors().size() + " commands.");
|
2015-10-19 17:43:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onStop()
|
|
|
|
{
|
|
|
|
handler.clearCommands();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|