2018-12-30 14:31:26 +01:00
|
|
|
package world.bentobox.challenges.commands;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import world.bentobox.challenges.ChallengesAddon;
|
|
|
|
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
|
|
|
import world.bentobox.bentobox.api.user.User;
|
2019-01-23 16:30:30 +01:00
|
|
|
import world.bentobox.challenges.panel.user.ChallengesGUI;
|
|
|
|
|
2018-12-30 14:31:26 +01:00
|
|
|
|
2019-02-18 00:29:42 +01:00
|
|
|
public class ChallengesCommand extends CompositeCommand
|
|
|
|
{
|
2018-12-30 14:31:26 +01:00
|
|
|
public static final String CHALLENGE_COMMAND = "challenges";
|
|
|
|
|
2019-02-18 00:29:42 +01:00
|
|
|
|
|
|
|
public ChallengesCommand(ChallengesAddon addon, CompositeCommand cmd)
|
|
|
|
{
|
2018-12-30 14:31:26 +01:00
|
|
|
super(addon, cmd, CHALLENGE_COMMAND);
|
|
|
|
}
|
|
|
|
|
2019-02-18 00:29:42 +01:00
|
|
|
|
2018-12-30 14:31:26 +01:00
|
|
|
@Override
|
2019-02-18 00:29:42 +01:00
|
|
|
public boolean execute(User user, String label, List<String> args)
|
|
|
|
{
|
2018-12-30 14:31:26 +01:00
|
|
|
// Open up the challenges GUI
|
2019-02-18 00:29:42 +01:00
|
|
|
if (user.isPlayer())
|
|
|
|
{
|
|
|
|
if (this.getPlugin().getIslands().getIsland(this.getWorld(), user.getUniqueId()) != null)
|
|
|
|
{
|
|
|
|
new ChallengesGUI((ChallengesAddon) this.getAddon(),
|
|
|
|
this.getWorld(),
|
|
|
|
user,
|
|
|
|
this.getTopLabel(),
|
|
|
|
this.getPermissionPrefix()).build();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
user.sendMessage("general.errors.no-island");
|
|
|
|
return false;
|
|
|
|
}
|
2018-12-30 14:31:26 +01:00
|
|
|
}
|
|
|
|
// Show help
|
|
|
|
showHelp(this, user);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-02-18 00:29:42 +01:00
|
|
|
|
2018-12-30 14:31:26 +01:00
|
|
|
@Override
|
2019-02-18 00:29:42 +01:00
|
|
|
public void setup()
|
|
|
|
{
|
2018-12-30 14:31:26 +01:00
|
|
|
this.setPermission(CHALLENGE_COMMAND);
|
2019-05-01 23:31:36 +02:00
|
|
|
this.setParametersHelp("challenges.commands.user.main.parameters");
|
|
|
|
this.setDescription("challenges.commands.user.main.description");
|
|
|
|
|
|
|
|
new CompleteChallengeCommand(this.getAddon(), this);
|
2018-12-30 14:31:26 +01:00
|
|
|
}
|
|
|
|
}
|