79 lines
3.1 KiB
Java
Executable File
79 lines
3.1 KiB
Java
Executable File
package us.tastybento.bskyblock.commands;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
import us.tastybento.bskyblock.api.commands.CompositeCommand;
|
|
import us.tastybento.bskyblock.api.localization.TextVariables;
|
|
import us.tastybento.bskyblock.api.user.User;
|
|
import us.tastybento.bskyblock.commands.island.IslandAboutCommand;
|
|
import us.tastybento.bskyblock.commands.island.IslandBanCommand;
|
|
import us.tastybento.bskyblock.commands.island.IslandBanlistCommand;
|
|
import us.tastybento.bskyblock.commands.island.IslandCreateCommand;
|
|
import us.tastybento.bskyblock.commands.island.IslandGoCommand;
|
|
import us.tastybento.bskyblock.commands.island.IslandLanguageCommand;
|
|
import us.tastybento.bskyblock.commands.island.IslandResetCommand;
|
|
import us.tastybento.bskyblock.commands.island.IslandResetnameCommand;
|
|
import us.tastybento.bskyblock.commands.island.IslandSethomeCommand;
|
|
import us.tastybento.bskyblock.commands.island.IslandSetnameCommand;
|
|
import us.tastybento.bskyblock.commands.island.IslandSettingsCommand;
|
|
import us.tastybento.bskyblock.commands.island.IslandUnbanCommand;
|
|
import us.tastybento.bskyblock.commands.island.team.IslandTeamCommand;
|
|
|
|
public class IslandCommand extends CompositeCommand {
|
|
|
|
public IslandCommand() {
|
|
super("island", "is");
|
|
}
|
|
|
|
/* (non-Javadoc)
|
|
* @see us.tastybento.bskyblock.api.commands.CompositeCommand#setup()
|
|
*/
|
|
@Override
|
|
public void setup() {
|
|
setDescription("commands.island.help.description");
|
|
setOnlyPlayer(true);
|
|
// Permission
|
|
setPermissionPrefix("bskyblock");
|
|
setPermission("island");
|
|
setWorld(getPlugin().getIWM().getBSBIslandWorld());
|
|
// Set up subcommands
|
|
new IslandAboutCommand(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);
|
|
}
|
|
|
|
/* (non-Javadoc)
|
|
* @see us.tastybento.bskyblock.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 user has an island, go
|
|
if (getPlugin().getIslands().getIsland(getWorld(), user.getUniqueId()) != null) {
|
|
return getSubCommand("go").map(goCmd -> goCmd.execute(user, goCmd.getLabel(), new ArrayList<>())).orElse(false);
|
|
}
|
|
// No islands currently
|
|
return getSubCommand("create").map(createCmd -> createCmd.execute(user, createCmd.getLabel(), new ArrayList<>())).orElse(false);
|
|
}
|
|
user.sendMessage("general.errors.unknown-command", TextVariables.LABEL, getTopLabel());
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|