2015-10-19 17:43:46 +00:00
|
|
|
package me.totalfreedom.totalfreedommod.commands;
|
|
|
|
|
|
|
|
import lombok.Getter;
|
|
|
|
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;
|
|
|
|
import net.pravian.aero.component.service.AbstractService;
|
2015-11-15 23:32:04 +00:00
|
|
|
import org.bukkit.ChatColor;
|
2015-10-19 17:43:46 +00:00
|
|
|
|
|
|
|
public class CommandLoader extends AbstractService<TotalFreedomMod>
|
|
|
|
{
|
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);
|
|
|
|
|
|
|
|
handler = new SimpleCommandHandler<TotalFreedomMod>(plugin);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onStart()
|
|
|
|
{
|
|
|
|
handler.clearCommands();
|
2015-11-15 23:32:04 +00:00
|
|
|
handler.setExecutorFactory(new FreedomCommandExecutor.FreedomExecutorFactory());
|
2015-10-19 17:43:46 +00:00
|
|
|
handler.setCommandClassPrefix("Command_");
|
2015-11-15 23:32:04 +00:00
|
|
|
handler.setPermissionMessage(ChatColor.YELLOW + "You do not have permission to use this command.");
|
|
|
|
|
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
|
|
|
|
2015-11-15 23:32:04 +00:00
|
|
|
FLog.info("Loaded " + handler.getExecutors().size() + " commands");
|
2015-10-19 17:43:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onStop()
|
|
|
|
{
|
|
|
|
handler.clearCommands();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|