addon-welcomewarpsigns/src/main/java/world/bentobox/warps/commands/WarpsCommand.java

63 lines
1.7 KiB
Java

package world.bentobox.warps.commands;
import java.util.List;
import org.bukkit.World;
import world.bentobox.bentobox.api.commands.CompositeCommand;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.warps.Warp;
import world.bentobox.warps.panels.WarpsPanel;
/**
* Handles the warps command
* @author tastybento
*
*/
public class WarpsCommand extends CompositeCommand {
private final Warp addon;
public WarpsCommand(Warp addon, CompositeCommand bsbIslandCmd) {
super(bsbIslandCmd, addon.getSettings().getWarpsCommand());
this.addon = addon;
}
public WarpsCommand(Warp addon) {
super(addon.getSettings().getWarpsCommand());
this.addon = addon;
}
/* (non-Javadoc)
* @see us.tastybento.bskyblock.api.commands.BSBCommand#setup()
*/
@Override
public void setup() {
this.setPermission(this.getParent() == null ? Warp.WELCOME_WARP_SIGNS + ".warps" : "island.warps");
this.setOnlyPlayer(true);
this.setDescription("warps.help.description");
}
/* (non-Javadoc)
* @see us.tastybento.bskyblock.api.commands.BSBCommand#execute(us.tastybento.bskyblock.api.commands.User, java.util.List)
*/
@Override
public boolean execute(User user, String label, List<String> args) {
World world = getWorld() == null ? user.getWorld() : getWorld();
if (addon
.getWarpSignsManager()
.listWarps(world)
.isEmpty()) {
user.sendMessage("warps.error.no-warps-yet");
user.sendMessage("warps.warpTip", "[text]", addon.getSettings().getWelcomeLine());
return false;
}
WarpsPanel.openPanel(this.addon, world, user);
return true;
}
}