2018-10-31 14:32:21 +01:00
|
|
|
package world.bentobox.warps.commands;
|
2017-12-31 06:15:47 +01:00
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
2019-10-31 18:09:33 +01:00
|
|
|
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;
|
2021-01-10 00:33:27 +01:00
|
|
|
import world.bentobox.warps.Warp;
|
2017-12-31 06:15:47 +01:00
|
|
|
|
|
|
|
/**
|
2019-11-01 01:05:12 +01:00
|
|
|
* Handles the warps command
|
2019-10-31 18:09:33 +01:00
|
|
|
* @author tastybento
|
2017-12-31 06:15:47 +01:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
public class WarpsCommand extends CompositeCommand {
|
|
|
|
|
2021-08-09 03:09:28 +02:00
|
|
|
private final Warp addon;
|
2017-12-31 06:15:47 +01:00
|
|
|
|
2019-07-01 05:09:07 +02:00
|
|
|
public WarpsCommand(Warp addon, CompositeCommand bsbIslandCmd) {
|
2019-10-31 18:09:33 +01:00
|
|
|
super(bsbIslandCmd, addon.getSettings().getWarpsCommand());
|
|
|
|
this.addon = addon;
|
|
|
|
}
|
|
|
|
|
|
|
|
public WarpsCommand(Warp addon) {
|
|
|
|
super(addon.getSettings().getWarpsCommand());
|
2019-07-01 05:09:07 +02:00
|
|
|
this.addon = addon;
|
2017-12-31 06:15:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* (non-Javadoc)
|
|
|
|
* @see us.tastybento.bskyblock.api.commands.BSBCommand#setup()
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public void setup() {
|
2019-11-01 01:05:12 +01:00
|
|
|
this.setPermission(this.getParent() == null ? Warp.WELCOME_WARP_SIGNS + ".warp" : "island.warp");
|
2017-12-31 06:15:47 +01:00
|
|
|
this.setOnlyPlayer(true);
|
2017-12-31 23:08:36 +01:00
|
|
|
this.setDescription("warps.help.description");
|
2017-12-31 06:15:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* (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) {
|
2019-10-31 18:09:33 +01:00
|
|
|
World world = getWorld() == null ? user.getWorld() : getWorld();
|
2020-05-21 03:57:56 +02:00
|
|
|
if (addon
|
|
|
|
.getWarpSignsManager()
|
|
|
|
.listWarps(world)
|
|
|
|
.isEmpty()) {
|
2017-12-31 06:15:47 +01:00
|
|
|
user.sendMessage("warps.error.no-warps-yet");
|
2019-07-01 05:09:07 +02:00
|
|
|
user.sendMessage("warps.warpTip", "[text]", addon.getSettings().getWelcomeLine());
|
2019-11-01 01:33:34 +01:00
|
|
|
return false;
|
2017-12-31 06:15:47 +01:00
|
|
|
}
|
2019-11-01 01:33:34 +01:00
|
|
|
addon.getWarpPanelManager().showWarpPanel(world, user, 0);
|
2017-12-31 06:15:47 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|