1
0
mirror of https://github.com/BentoBoxWorld/Warps.git synced 2024-06-25 22:24:48 +02:00
addon-welcomewarpsigns/src/main/java/world/bentobox/warps/commands/WarpsCommand.java

63 lines
1.7 KiB
Java
Raw Normal View History

package world.bentobox.warps.commands;
import java.util.List;
import org.bukkit.World;
2018-08-01 18:47:57 +02:00
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;
/**
2019-11-01 01:05:12 +01:00
* Handles the warps command
* @author tastybento
*
*/
public class WarpsCommand extends CompositeCommand {
2021-08-09 03:09:28 +02:00
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() {
2023-11-05 20:35:59 +01:00
this.setPermission(this.getParent() == null ? Warp.WELCOME_WARP_SIGNS + ".warps" : "island.warps");
this.setOnlyPlayer(true);
2017-12-31 23:08:36 +01:00
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
2018-07-19 07:58:14 +02:00
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());
2019-11-01 01:33:34 +01:00
return false;
}
WarpsPanel.openPanel(this.addon, world, user);
return true;
}
}