2016-03-02 19:28:01 +00:00
|
|
|
package me.totalfreedom.totalfreedommod.command;
|
2015-10-19 17:43:46 +00:00
|
|
|
|
2020-07-01 01:51:06 +00:00
|
|
|
import java.util.ArrayList;
|
2020-07-01 16:45:09 +00:00
|
|
|
import java.util.Arrays;
|
2020-07-01 01:51:06 +00:00
|
|
|
import java.util.List;
|
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
|
|
|
|
2016-03-01 16:47:01 +00:00
|
|
|
public class CommandLoader extends FreedomService
|
2015-10-19 17:43:46 +00:00
|
|
|
{
|
|
|
|
@Getter
|
2020-07-01 01:51:06 +00:00
|
|
|
private final List<FreedomCommand> commands;
|
2015-10-19 17:43:46 +00:00
|
|
|
|
2020-07-01 01:51:06 +00:00
|
|
|
public CommandLoader()
|
2015-10-19 17:43:46 +00:00
|
|
|
{
|
2020-07-01 01:51:06 +00:00
|
|
|
commands = new ArrayList<>();
|
2015-10-19 17:43:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2020-07-01 01:51:06 +00:00
|
|
|
public void onStart()
|
2015-10-19 17:43:46 +00:00
|
|
|
{
|
2020-07-01 01:51:06 +00:00
|
|
|
}
|
2015-11-15 23:32:04 +00:00
|
|
|
|
2020-07-01 01:51:06 +00:00
|
|
|
@Override
|
|
|
|
public void onStop()
|
|
|
|
{
|
|
|
|
}
|
2015-10-19 17:43:46 +00:00
|
|
|
|
2020-07-01 01:51:06 +00:00
|
|
|
public void add(FreedomCommand command)
|
|
|
|
{
|
|
|
|
commands.add(command);
|
|
|
|
command.register();
|
2015-10-19 17:43:46 +00:00
|
|
|
}
|
|
|
|
|
2020-07-01 01:51:06 +00:00
|
|
|
public FreedomCommand getByName(String name)
|
2015-10-19 17:43:46 +00:00
|
|
|
{
|
2020-07-01 01:51:06 +00:00
|
|
|
for (FreedomCommand command : commands)
|
|
|
|
{
|
|
|
|
if (name.equals(command.getName()))
|
|
|
|
return command;
|
|
|
|
}
|
|
|
|
return null;
|
2015-10-19 17:43:46 +00:00
|
|
|
}
|
|
|
|
|
2020-07-01 16:45:09 +00:00
|
|
|
public boolean isAlias(String alias)
|
|
|
|
{
|
|
|
|
for (FreedomCommand command : commands)
|
|
|
|
{
|
|
|
|
if (Arrays.asList(command.getAliases().split(",")).contains(alias))
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-07-01 01:51:06 +00:00
|
|
|
public int getCommandAmount()
|
|
|
|
{
|
|
|
|
return commands.size();
|
|
|
|
}
|
2017-10-13 18:35:11 +00:00
|
|
|
}
|