AcidIsland/src/main/java/world/bentobox/acidisland/commands/AiCommand.java
2018-12-22 22:50:52 +01:00

88 lines
3.6 KiB
Java

package world.bentobox.acidisland.commands;
import java.util.ArrayList;
import java.util.List;
import world.bentobox.acidisland.AcidIsland;
import world.bentobox.bentobox.api.addons.Addon;
import world.bentobox.bentobox.api.commands.CompositeCommand;
import world.bentobox.bentobox.api.commands.island.IslandBanCommand;
import world.bentobox.bentobox.api.commands.island.IslandBanlistCommand;
import world.bentobox.bentobox.api.commands.island.IslandCreateCommand;
import world.bentobox.bentobox.api.commands.island.IslandGoCommand;
import world.bentobox.bentobox.api.commands.island.IslandInfoCommand;
import world.bentobox.bentobox.api.commands.island.IslandLanguageCommand;
import world.bentobox.bentobox.api.commands.island.IslandResetCommand;
import world.bentobox.bentobox.api.commands.island.IslandResetnameCommand;
import world.bentobox.bentobox.api.commands.island.IslandSethomeCommand;
import world.bentobox.bentobox.api.commands.island.IslandSetnameCommand;
import world.bentobox.bentobox.api.commands.island.IslandSettingsCommand;
import world.bentobox.bentobox.api.commands.island.IslandUnbanCommand;
import world.bentobox.bentobox.api.commands.island.team.IslandTeamCommand;
import world.bentobox.bentobox.api.commands.island.team.IslandTeamCoopCommand;
import world.bentobox.bentobox.api.commands.island.team.IslandTeamTrustCommand;
import world.bentobox.bentobox.api.commands.island.team.IslandTeamUncoopCommand;
import world.bentobox.bentobox.api.commands.island.team.IslandTeamUntrustCommand;
import world.bentobox.bentobox.api.user.User;
public class AiCommand extends CompositeCommand {
public AiCommand(Addon addon, String command) {
super(addon, command);
}
/* (non-Javadoc)
* @see world.bentobox.bbox.api.commands.CompositeCommand#setup()
*/
@Override
public void setup() {
setDescription("commands.island.help.description");
setOnlyPlayer(true);
// Permission
setPermission("island");
// Set up world
setWorld(((AcidIsland)getAddon()).getIslandWorld());
// Set up subcommands
new IslandAboutCommand(this);
new IslandInfoCommand(this);
new IslandCreateCommand(this);
new IslandGoCommand(this);
new IslandResetCommand(this);
new IslandSetnameCommand(this);
new IslandResetnameCommand(this);
new IslandSethomeCommand(this);
new IslandSettingsCommand(this);
new IslandLanguageCommand(this);
new IslandBanCommand(this);
new IslandUnbanCommand(this);
new IslandBanlistCommand(this);
// Team commands
new IslandTeamCommand(this);
new IslandTeamTrustCommand(this);
new IslandTeamUntrustCommand(this);
new IslandTeamCoopCommand(this);
new IslandTeamUncoopCommand(this);
}
/* (non-Javadoc)
* @see world.bentobox.bbox.api.commands.CommandArgument#execute(org.bukkit.command.CommandSender, java.lang.String[])
*/
@Override
public boolean execute(User user, String label, List<String> args) {
if (user == null) {
return false;
}
if (args.isEmpty()) {
// If in world, go
if (getPlugin().getIslands().getIsland(getWorld(), user.getUniqueId()) != null) {
return getSubCommand("go").map(goCmd -> goCmd.execute(user, label, new ArrayList<>())).orElse(false);
}
// No islands currently
return getSubCommand("create").map(createCmd -> createCmd.execute(user, label, new ArrayList<>())).orElse(false);
}
user.sendMessage("general.errors.unknown-command", "[label]", getLabel());
return false;
}
}