mirror of
https://github.com/BentoBoxWorld/Challenges.git
synced 2024-11-22 02:25:52 +01:00
Update all commands.
Commands now will have an option to change their call values.
This commit is contained in:
parent
5da823c7e5
commit
670513e37a
@ -178,12 +178,8 @@ public class ChallengesAddon extends Addon {
|
||||
|
||||
if (this.settings.isUseCommonGUI())
|
||||
{
|
||||
new ChallengesGlobalPlayerCommand(this,
|
||||
this.settings.getGlobalUserCommand(),
|
||||
hookedGameModes);
|
||||
new ChallengesGlobalAdminCommand(this,
|
||||
this.settings.getGlobalAdminCommand(),
|
||||
hookedGameModes);
|
||||
new ChallengesGlobalPlayerCommand(this, hookedGameModes);
|
||||
new ChallengesGlobalAdminCommand(this, hookedGameModes);
|
||||
}
|
||||
|
||||
// Register the reset listener
|
||||
|
@ -9,26 +9,25 @@ import world.bentobox.bentobox.api.user.User;
|
||||
import world.bentobox.challenges.ChallengesAddon;
|
||||
import world.bentobox.challenges.config.SettingsUtils.GuiMode;
|
||||
import world.bentobox.challenges.panel.user.GameModePanel;
|
||||
import world.bentobox.challenges.utils.Utils;
|
||||
|
||||
|
||||
/**
|
||||
* This class provides all necessary thing to implement challenges user command
|
||||
*/
|
||||
public class ChallengesUserCommand extends CompositeCommand
|
||||
public class ChallengesGlobalPlayerCommand extends CompositeCommand
|
||||
{
|
||||
/**
|
||||
* Constructor that inits command with given string.
|
||||
* @param addon Challenges Addon
|
||||
* @param commands String that contains main command and its alias separated via whitespace.
|
||||
* @param gameModeAddons List with GameModes where challenges addon operates.
|
||||
*/
|
||||
public ChallengesUserCommand(ChallengesAddon addon, String commands, List<GameModeAddon> gameModeAddons)
|
||||
public ChallengesGlobalPlayerCommand(ChallengesAddon addon, List<GameModeAddon> gameModeAddons)
|
||||
{
|
||||
super(addon,
|
||||
commands.split(" ")[0],
|
||||
commands.split(" "));
|
||||
addon.getChallengesSettings().getPlayerGlobalCommand().split(" ")[0],
|
||||
addon.getChallengesSettings().getPlayerGlobalCommand().split(" "));
|
||||
this.gameModeAddons = gameModeAddons;
|
||||
this.addon = addon;
|
||||
}
|
||||
|
||||
|
||||
@ -56,10 +55,11 @@ public class ChallengesUserCommand extends CompositeCommand
|
||||
if (this.gameModeAddons.size() == 1)
|
||||
{
|
||||
this.gameModeAddons.get(0).getPlayerCommand().ifPresent(compositeCommand ->
|
||||
user.performCommand(compositeCommand.getTopLabel() + " challenges"));
|
||||
user.performCommand(compositeCommand.getTopLabel() + " " +
|
||||
this.<ChallengesAddon>getAddon().getChallengesSettings().getPlayerMainCommand().split(" ")[0]));
|
||||
return true;
|
||||
}
|
||||
else if (this.addon.getChallengesSettings().getUserGuiMode() == GuiMode.CURRENT_WORLD)
|
||||
else if (this.<ChallengesAddon>getAddon().getChallengesSettings().getUserGuiMode() == GuiMode.CURRENT_WORLD)
|
||||
{
|
||||
// Find GameMode and run command
|
||||
for (GameModeAddon addon : this.gameModeAddons)
|
||||
@ -67,15 +67,18 @@ public class ChallengesUserCommand extends CompositeCommand
|
||||
if (addon.inWorld(user.getWorld()))
|
||||
{
|
||||
addon.getPlayerCommand().ifPresent(compositeCommand ->
|
||||
user.performCommand(compositeCommand.getTopLabel() + " challenges"));
|
||||
user.performCommand(compositeCommand.getTopLabel() + " " +
|
||||
this.<ChallengesAddon>getAddon().getChallengesSettings().getPlayerMainCommand().split(" ")[0]));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Utils.sendMessage(user, user.getTranslation("general.errors.wrong-world"));
|
||||
}
|
||||
else if (this.addon.getChallengesSettings().getUserGuiMode() == GuiMode.GAMEMODE_LIST)
|
||||
else if (this.<ChallengesAddon>getAddon().getChallengesSettings().getUserGuiMode() == GuiMode.GAMEMODE_LIST)
|
||||
{
|
||||
GameModePanel.open(this.addon,
|
||||
GameModePanel.open(this.getAddon(),
|
||||
this.getWorld(),
|
||||
user,
|
||||
this.gameModeAddons,
|
||||
@ -96,9 +99,4 @@ public class ChallengesUserCommand extends CompositeCommand
|
||||
* List with hooked GameMode addons.
|
||||
*/
|
||||
private final List<GameModeAddon> gameModeAddons;
|
||||
|
||||
/**
|
||||
* Challenges addon for easier operations.
|
||||
*/
|
||||
private final ChallengesAddon addon;
|
||||
}
|
@ -9,14 +9,14 @@ import world.bentobox.challenges.ChallengesAddon;
|
||||
import world.bentobox.challenges.panel.user.ChallengesPanel;
|
||||
|
||||
|
||||
public class ChallengesCommand extends CompositeCommand
|
||||
public class ChallengesPlayerCommand extends CompositeCommand
|
||||
{
|
||||
public static final String CHALLENGE_COMMAND = "challenges";
|
||||
|
||||
|
||||
public ChallengesCommand(ChallengesAddon addon, CompositeCommand cmd)
|
||||
public ChallengesPlayerCommand(ChallengesAddon addon, CompositeCommand cmd)
|
||||
{
|
||||
super(addon, cmd, CHALLENGE_COMMAND);
|
||||
super(addon,
|
||||
cmd,
|
||||
addon.getChallengesSettings().getPlayerMainCommand().split(" ")[0],
|
||||
addon.getChallengesSettings().getPlayerMainCommand().split(" "));
|
||||
}
|
||||
|
||||
|
||||
@ -40,9 +40,10 @@ public class ChallengesCommand extends CompositeCommand
|
||||
// Show admin better explanation.
|
||||
if (user.isOp() || user.hasPermission(this.getPermissionPrefix() + "admin.challenges"))
|
||||
{
|
||||
String topLabel = getIWM().getAddon(this.getWorld())
|
||||
.map(GameModeAddon::getAdminCommand)
|
||||
.map(optionalAdminCommand -> optionalAdminCommand.map(ac -> ac.getTopLabel()).orElse(this.getTopLabel())).orElse(this.getTopLabel());
|
||||
String topLabel = this.getIWM().getAddon(this.getWorld()).
|
||||
map(GameModeAddon::getAdminCommand).
|
||||
map(optionalAdminCommand -> optionalAdminCommand.map(CompositeCommand::getTopLabel).orElse(this.getTopLabel())).
|
||||
orElse(this.getTopLabel());
|
||||
user.sendMessage("challenges.errors.no-challenges-admin", "[command]", topLabel + " challenges");
|
||||
}
|
||||
else
|
||||
@ -87,7 +88,7 @@ public class ChallengesCommand extends CompositeCommand
|
||||
@Override
|
||||
public void setup()
|
||||
{
|
||||
this.setPermission(CHALLENGE_COMMAND);
|
||||
this.setPermission("challenges");
|
||||
this.setParametersHelp("challenges.commands.user.main.parameters");
|
||||
this.setDescription("challenges.commands.user.main.description");
|
||||
|
@ -6,7 +6,6 @@ import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import world.bentobox.bentobox.api.addons.Addon;
|
||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||
import world.bentobox.bentobox.api.user.User;
|
||||
import world.bentobox.bentobox.util.Util;
|
||||
@ -26,10 +25,12 @@ public class CompleteChallengeCommand extends CompositeCommand
|
||||
* @param addon Challenges addon.
|
||||
* @param cmd Parent Command.
|
||||
*/
|
||||
public CompleteChallengeCommand(Addon addon, CompositeCommand cmd)
|
||||
public CompleteChallengeCommand(ChallengesAddon addon, CompositeCommand cmd)
|
||||
{
|
||||
super(addon, cmd, "complete");
|
||||
this.addon = (ChallengesAddon) addon;
|
||||
super(addon,
|
||||
cmd,
|
||||
addon.getChallengesSettings().getPlayerCompleteCommand().split(" ")[0],
|
||||
addon.getChallengesSettings().getPlayerCompleteCommand().split(" "));
|
||||
}
|
||||
|
||||
|
||||
@ -62,11 +63,11 @@ public class CompleteChallengeCommand extends CompositeCommand
|
||||
{
|
||||
// Add world name back at the start
|
||||
String challengeName = Utils.getGameMode(this.getWorld()) + "_" + args.get(0);
|
||||
Challenge challenge = this.addon.getChallengesManager().getChallenge(challengeName);
|
||||
Challenge challenge = this.<ChallengesAddon>getAddon().getChallengesManager().getChallenge(challengeName);
|
||||
|
||||
if (challenge != null)
|
||||
{
|
||||
int count = args.size() == 2 ? Integer.valueOf(args.get(1)) : 1;
|
||||
int count = args.size() == 2 ? Integer.parseInt(args.get(1)) : 1;
|
||||
|
||||
boolean canMultipleTimes =
|
||||
user.hasPermission(this.getPermission() + ".multiple");
|
||||
@ -77,7 +78,7 @@ public class CompleteChallengeCommand extends CompositeCommand
|
||||
count = 1;
|
||||
}
|
||||
|
||||
return TryToComplete.complete(this.addon,
|
||||
return TryToComplete.complete(this.getAddon(),
|
||||
user,
|
||||
challenge,
|
||||
this.getWorld(),
|
||||
@ -113,10 +114,12 @@ public class CompleteChallengeCommand extends CompositeCommand
|
||||
case 3:
|
||||
|
||||
// Create suggestions with all challenges that is available for users.
|
||||
returnList.addAll(this.addon.getChallengesManager().getAllChallengesNames(this.getWorld()).stream().
|
||||
filter(challenge -> challenge.startsWith(Utils.getGameMode(this.getWorld()) + "_")).
|
||||
map(challenge -> challenge.substring(Utils.getGameMode(this.getWorld()).length() + 1)).
|
||||
collect(Collectors.toList()));
|
||||
returnList.addAll(this.<ChallengesAddon>getAddon().getChallengesManager().getAllChallengesNames(this.getWorld()).
|
||||
stream().
|
||||
filter(challenge -> challenge.startsWith(Utils.getGameMode(this.getWorld()) + "_") ||
|
||||
challenge.startsWith(Utils.getGameMode(this.getWorld()).toLowerCase() + "_")).
|
||||
map(challenge -> challenge.substring(Utils.getGameMode(this.getWorld()).length() + 1)).
|
||||
collect(Collectors.toList()));
|
||||
break;
|
||||
case 4:
|
||||
// Suggest a number of completions.
|
||||
@ -135,14 +138,4 @@ public class CompleteChallengeCommand extends CompositeCommand
|
||||
|
||||
return Optional.of(Util.tabLimit(returnList, lastString));
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
// Section: Variables
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Variable that holds challenge addon. Single casting.
|
||||
*/
|
||||
private ChallengesAddon addon;
|
||||
}
|
||||
|
@ -1,68 +0,0 @@
|
||||
package world.bentobox.challenges.commands.admin;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||
import world.bentobox.bentobox.api.user.User;
|
||||
import world.bentobox.challenges.ChallengesAddon;
|
||||
import world.bentobox.challenges.panel.admin.AdminPanel;
|
||||
|
||||
|
||||
public class Challenges extends CompositeCommand
|
||||
{
|
||||
|
||||
/**
|
||||
* Admin command for challenges
|
||||
*
|
||||
* @param parent
|
||||
*/
|
||||
public Challenges(ChallengesAddon addon, CompositeCommand parent)
|
||||
{
|
||||
super(addon, parent, "challenges");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setup()
|
||||
{
|
||||
this.setPermission("admin.challenges");
|
||||
this.setParametersHelp("challenges.commands.admin.main.parameters");
|
||||
this.setDescription("challenges.commands.admin.main.description");
|
||||
|
||||
// Register sub commands
|
||||
|
||||
// This method reloads challenges addon
|
||||
new ReloadChallenges(getAddon(), this);
|
||||
|
||||
// Defaults processing command
|
||||
new DefaultsCommand(this.getAddon(), this);
|
||||
|
||||
// Complete challenge command
|
||||
new CompleteCommand(this.getAddon(), this);
|
||||
|
||||
// Reset challenge command
|
||||
new ResetCommand(this.getAddon(), this);
|
||||
|
||||
new ShowChallenges(this.getAddon(), this);
|
||||
|
||||
new MigrateCommand(this.getAddon(), this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean execute(User user, String label, List<String> args)
|
||||
{
|
||||
// Open up the admin challenges GUI
|
||||
if (user.isPlayer())
|
||||
{
|
||||
AdminPanel.open(this.getAddon(),
|
||||
this.getWorld(),
|
||||
user,
|
||||
this.getTopLabel(),
|
||||
this.getPermissionPrefix());
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@ -1,85 +1,71 @@
|
||||
package world.bentobox.challenges.commands.admin;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import world.bentobox.bentobox.api.addons.GameModeAddon;
|
||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||
import world.bentobox.bentobox.api.user.User;
|
||||
import world.bentobox.challenges.ChallengesAddon;
|
||||
import world.bentobox.challenges.panel.user.GameModePanel;
|
||||
import world.bentobox.challenges.panel.admin.AdminPanel;
|
||||
|
||||
|
||||
/**
|
||||
* This class provides all necessary thing to implement challenges admin command
|
||||
*/
|
||||
public class ChallengesAdminCommand extends CompositeCommand
|
||||
{
|
||||
/**
|
||||
* Constructor that inits command with given string.
|
||||
* @param addon Challenges Addon
|
||||
* @param commands String that contains main command and its alias separated via whitespace.
|
||||
* @param gameModeAddons List with GameModes where challenges addon operates.
|
||||
*/
|
||||
public ChallengesAdminCommand(ChallengesAddon addon, String commands, List<GameModeAddon> gameModeAddons)
|
||||
{
|
||||
super(addon,
|
||||
commands.split(" ")[0],
|
||||
commands.split(" "));
|
||||
this.gameModeAddons = gameModeAddons;
|
||||
this.addon = addon;
|
||||
}
|
||||
|
||||
/**
|
||||
* Admin command for challenges
|
||||
*
|
||||
* @param parent
|
||||
*/
|
||||
public ChallengesAdminCommand(ChallengesAddon addon, CompositeCommand parent)
|
||||
{
|
||||
super(addon,
|
||||
parent,
|
||||
addon.getChallengesSettings().getAdminMainCommand().split(" ")[0],
|
||||
addon.getChallengesSettings().getAdminMainCommand().split(" "));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void setup()
|
||||
{
|
||||
this.setPermission("admin.challenges");
|
||||
this.setParametersHelp("challenges.commands.admin.main.parameters");
|
||||
this.setDescription("challenges.commands.admin.main.description");
|
||||
}
|
||||
@Override
|
||||
public void setup()
|
||||
{
|
||||
this.setPermission("admin.challenges");
|
||||
this.setParametersHelp("challenges.commands.admin.main.parameters");
|
||||
this.setDescription("challenges.commands.admin.main.description");
|
||||
|
||||
// Register sub commands
|
||||
|
||||
// This method reloads challenges addon
|
||||
new ReloadChallenges(getAddon(), this);
|
||||
|
||||
// Defaults processing command
|
||||
new DefaultsCommand(this.getAddon(), this);
|
||||
|
||||
// Complete challenge command
|
||||
new CompleteCommand(this.getAddon(), this);
|
||||
|
||||
// Reset challenge command
|
||||
new ResetCommand(this.getAddon(), this);
|
||||
|
||||
new ShowChallenges(this.getAddon(), this);
|
||||
|
||||
new MigrateCommand(this.getAddon(), this);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean execute(User user, String label, List<String> args)
|
||||
{
|
||||
// For single game mode just open correct gui.
|
||||
@Override
|
||||
public boolean execute(User user, String label, List<String> args)
|
||||
{
|
||||
// Open up the admin challenges GUI
|
||||
if (user.isPlayer())
|
||||
{
|
||||
AdminPanel.open(this.getAddon(),
|
||||
this.getWorld(),
|
||||
user,
|
||||
this.getTopLabel(),
|
||||
this.getPermissionPrefix());
|
||||
|
||||
if (this.gameModeAddons.size() == 1)
|
||||
{
|
||||
this.gameModeAddons.get(0).getAdminCommand().ifPresent(compositeCommand ->
|
||||
user.performCommand(compositeCommand.getTopLabel() + " challenges"));
|
||||
}
|
||||
else
|
||||
{
|
||||
GameModePanel.open(this.addon,
|
||||
this.getWorld(),
|
||||
user,
|
||||
this.gameModeAddons,
|
||||
true);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
// Section: Variables
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* This variable stores challenges addon.
|
||||
*/
|
||||
private final ChallengesAddon addon;
|
||||
|
||||
/**
|
||||
* This variable stores List with game modes where challenges addon are hooked in.
|
||||
*/
|
||||
private final List<GameModeAddon> gameModeAddons;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,80 @@
|
||||
package world.bentobox.challenges.commands.admin;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import world.bentobox.bentobox.api.addons.GameModeAddon;
|
||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||
import world.bentobox.bentobox.api.user.User;
|
||||
import world.bentobox.challenges.ChallengesAddon;
|
||||
import world.bentobox.challenges.panel.user.GameModePanel;
|
||||
|
||||
|
||||
/**
|
||||
* This class provides all necessary thing to implement challenges admin command
|
||||
*/
|
||||
public class ChallengesGlobalAdminCommand extends CompositeCommand
|
||||
{
|
||||
/**
|
||||
* Constructor that inits command with given string.
|
||||
* @param addon Challenges Addon
|
||||
* @param gameModeAddons List with GameModes where challenges addon operates.
|
||||
*/
|
||||
public ChallengesGlobalAdminCommand(ChallengesAddon addon, List<GameModeAddon> gameModeAddons)
|
||||
{
|
||||
super(addon,
|
||||
addon.getChallengesSettings().getAdminGlobalCommand().split(" ")[0],
|
||||
addon.getChallengesSettings().getAdminGlobalCommand().split(" "));
|
||||
this.gameModeAddons = gameModeAddons;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void setup()
|
||||
{
|
||||
this.setPermission("admin.challenges");
|
||||
this.setParametersHelp("challenges.commands.admin.main.parameters");
|
||||
this.setDescription("challenges.commands.admin.main.description");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean execute(User user, String label, List<String> args)
|
||||
{
|
||||
// For single game mode just open correct gui.
|
||||
|
||||
if (this.gameModeAddons.size() == 1)
|
||||
{
|
||||
this.gameModeAddons.get(0).getAdminCommand().ifPresent(compositeCommand ->
|
||||
user.performCommand(compositeCommand.getTopLabel() + " " +
|
||||
this.<ChallengesAddon>getAddon().getChallengesSettings().getAdminMainCommand().split(" ")[0]));
|
||||
}
|
||||
else
|
||||
{
|
||||
GameModePanel.open(this.getAddon(),
|
||||
this.getWorld(),
|
||||
user,
|
||||
this.gameModeAddons,
|
||||
true);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
// Section: Variables
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
|
||||
/**
|
||||
* This variable stores List with game modes where challenges addon are hooked in.
|
||||
*/
|
||||
private final List<GameModeAddon> gameModeAddons;
|
||||
}
|
@ -50,20 +50,20 @@ public class Settings implements ConfigObject
|
||||
@ConfigComment("only if `global-commands` is enabled. This allows to execute `/challenges`")
|
||||
@ConfigComment("without referring to the gamemode.")
|
||||
@ConfigEntry(path = "commands.player.global", needsRestart = true)
|
||||
private String globalUserCommand = "challenges c";
|
||||
private String playerGlobalCommand = "challenges c";
|
||||
|
||||
@ConfigComment("")
|
||||
@ConfigComment("Allows to define user command for opening challenges GUI's.")
|
||||
@ConfigComment("Unlike `global` command, this requires to have gamemode player command before it.")
|
||||
@ConfigComment("This will look like: `/[player_cmd] challenges`")
|
||||
@ConfigEntry(path = "commands.player.main", needsRestart = true)
|
||||
private String mainUserCommand = "challenges";
|
||||
private String playerMainCommand = "challenges";
|
||||
|
||||
@ConfigComment("")
|
||||
@ConfigComment("Allows to define complete command.")
|
||||
@ConfigComment("This will look like: `/[player_cmd] challenges complete`")
|
||||
@ConfigEntry(path = "commands.player.complete", needsRestart = true)
|
||||
private String completeUserCommand = "complete";
|
||||
private String playerCompleteCommand = "complete";
|
||||
|
||||
@ConfigComment("")
|
||||
@ConfigComment("Allows to define a global challenges admin command. This command will work")
|
||||
@ -71,14 +71,14 @@ public class Settings implements ConfigObject
|
||||
@ConfigComment("without referring to the gamemode.")
|
||||
@ConfigComment("Note, this must not be the same as user global command.")
|
||||
@ConfigEntry(path = "commands.admin.global", needsRestart = true)
|
||||
private String globalAdminCommand = "challengesadmin chadmin";
|
||||
private String adminGlobalCommand = "challengesadmin chadmin";
|
||||
|
||||
@ConfigComment("")
|
||||
@ConfigComment("Allows to define admin command for opening challenges GUI's.")
|
||||
@ConfigComment("Unlike `global` command, this requires to have gamemode admin command before it.")
|
||||
@ConfigComment("This will look like: `/[admin_cmd] challenges`")
|
||||
@ConfigEntry(path = "commands.admin.main", needsRestart = true)
|
||||
private String mainAdminCommand = "challenges";
|
||||
private String adminMainCommand = "challenges";
|
||||
|
||||
@ConfigComment("")
|
||||
@ConfigComment("This indicate if player challenges data history will be stored or not.")
|
||||
@ -251,9 +251,9 @@ public class Settings implements ConfigObject
|
||||
* This method returns the userCommand value.
|
||||
* @return the value of userCommand.
|
||||
*/
|
||||
public String getGlobalUserCommand()
|
||||
public String getPlayerGlobalCommand()
|
||||
{
|
||||
return globalUserCommand;
|
||||
return playerGlobalCommand;
|
||||
}
|
||||
|
||||
|
||||
@ -262,9 +262,9 @@ public class Settings implements ConfigObject
|
||||
*
|
||||
* @return the main user command
|
||||
*/
|
||||
public String getMainUserCommand()
|
||||
public String getPlayerMainCommand()
|
||||
{
|
||||
return mainUserCommand;
|
||||
return playerMainCommand;
|
||||
}
|
||||
|
||||
|
||||
@ -273,9 +273,9 @@ public class Settings implements ConfigObject
|
||||
*
|
||||
* @return the complete user command
|
||||
*/
|
||||
public String getCompleteUserCommand()
|
||||
public String getPlayerCompleteCommand()
|
||||
{
|
||||
return completeUserCommand;
|
||||
return playerCompleteCommand;
|
||||
}
|
||||
|
||||
|
||||
@ -284,9 +284,9 @@ public class Settings implements ConfigObject
|
||||
*
|
||||
* @return the main admin command
|
||||
*/
|
||||
public String getMainAdminCommand()
|
||||
public String getAdminMainCommand()
|
||||
{
|
||||
return mainAdminCommand;
|
||||
return adminMainCommand;
|
||||
}
|
||||
|
||||
|
||||
@ -294,9 +294,9 @@ public class Settings implements ConfigObject
|
||||
* This method returns the adminCommand value.
|
||||
* @return the value of adminCommand.
|
||||
*/
|
||||
public String getGlobalAdminCommand()
|
||||
public String getAdminGlobalCommand()
|
||||
{
|
||||
return globalAdminCommand;
|
||||
return adminGlobalCommand;
|
||||
}
|
||||
|
||||
|
||||
@ -516,54 +516,54 @@ public class Settings implements ConfigObject
|
||||
|
||||
/**
|
||||
* This method sets the userCommand value.
|
||||
* @param globalUserCommand the userCommand new value.
|
||||
* @param playerGlobalCommand the userCommand new value.
|
||||
*/
|
||||
public void setGlobalUserCommand(String globalUserCommand)
|
||||
public void setPlayerGlobalCommand(String playerGlobalCommand)
|
||||
{
|
||||
this.globalUserCommand = globalUserCommand;
|
||||
this.playerGlobalCommand = playerGlobalCommand;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets main user command.
|
||||
*
|
||||
* @param mainUserCommand the main user command
|
||||
* @param playerMainCommand the main user command
|
||||
*/
|
||||
public void setMainUserCommand(String mainUserCommand)
|
||||
public void setPlayerMainCommand(String playerMainCommand)
|
||||
{
|
||||
this.mainUserCommand = mainUserCommand;
|
||||
this.playerMainCommand = playerMainCommand;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets complete user command.
|
||||
*
|
||||
* @param completeUserCommand the complete user command
|
||||
* @param playerCompleteCommand the complete user command
|
||||
*/
|
||||
public void setCompleteUserCommand(String completeUserCommand)
|
||||
public void setPlayerCompleteCommand(String playerCompleteCommand)
|
||||
{
|
||||
this.completeUserCommand = completeUserCommand;
|
||||
this.playerCompleteCommand = playerCompleteCommand;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets main admin command.
|
||||
*
|
||||
* @param mainAdminCommand the main admin command
|
||||
* @param adminMainCommand the main admin command
|
||||
*/
|
||||
public void setMainAdminCommand(String mainAdminCommand)
|
||||
public void setAdminMainCommand(String adminMainCommand)
|
||||
{
|
||||
this.mainAdminCommand = mainAdminCommand;
|
||||
this.adminMainCommand = adminMainCommand;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method sets the adminCommand value.
|
||||
* @param globalAdminCommand the adminCommand new value.
|
||||
* @param adminGlobalCommand the adminCommand new value.
|
||||
*/
|
||||
public void setGlobalAdminCommand(String globalAdminCommand)
|
||||
public void setAdminGlobalCommand(String adminGlobalCommand)
|
||||
{
|
||||
this.globalAdminCommand = globalAdminCommand;
|
||||
this.adminGlobalCommand = adminGlobalCommand;
|
||||
}
|
||||
|
||||
|
||||
|
@ -170,19 +170,18 @@ public class GameModePanel extends CommonPanel
|
||||
{
|
||||
if (clickType == action.clickType())
|
||||
{
|
||||
Optional<CompositeCommand> command;
|
||||
|
||||
if (this.adminMode)
|
||||
{
|
||||
command = gameModeAddon.getAdminCommand();
|
||||
gameModeAddon.getAdminCommand().ifPresent(compositeCommand ->
|
||||
user.performCommand(compositeCommand.getTopLabel() + " " +
|
||||
this.addon.getChallengesSettings().getAdminMainCommand().split(" ")[0]));
|
||||
}
|
||||
else
|
||||
{
|
||||
command = gameModeAddon.getPlayerCommand();
|
||||
gameModeAddon.getPlayerCommand().ifPresent(compositeCommand ->
|
||||
user.performCommand(compositeCommand.getTopLabel() + " " +
|
||||
this.addon.getChallengesSettings().getPlayerMainCommand().split(" ")[0]));
|
||||
}
|
||||
|
||||
command.ifPresent(compositeCommand ->
|
||||
user.performCommand(compositeCommand.getTopLabel() + " challenges"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ public class ChallengesCommandTest {
|
||||
private Island island;
|
||||
@Mock
|
||||
private ChallengesAddon addon;
|
||||
private ChallengesCommand cc;
|
||||
private ChallengesPlayerCommand cc;
|
||||
@Mock
|
||||
private World world;
|
||||
@Mock
|
||||
@ -151,11 +151,11 @@ public class ChallengesCommandTest {
|
||||
when(im.getIsland(any(), any(User.class))).thenReturn(island);
|
||||
|
||||
// Command under test
|
||||
cc = new ChallengesCommand(addon, ic);
|
||||
cc = new ChallengesPlayerCommand(addon, ic);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.challenges.commands.ChallengesCommand#canExecute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)}.
|
||||
* Test method for {@link ChallengesPlayerCommand#canExecute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)}.
|
||||
*/
|
||||
@Test
|
||||
public void testCanExecuteWrongWorld() {
|
||||
@ -165,7 +165,7 @@ public class ChallengesCommandTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.challenges.commands.ChallengesCommand#canExecute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)}.
|
||||
* Test method for {@link ChallengesPlayerCommand#canExecute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)}.
|
||||
*/
|
||||
@Test
|
||||
public void testCanExecuteNoChallenges() {
|
||||
@ -176,7 +176,7 @@ public class ChallengesCommandTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.challenges.commands.ChallengesCommand#canExecute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)}.
|
||||
* Test method for {@link ChallengesPlayerCommand#canExecute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)}.
|
||||
*/
|
||||
@Test
|
||||
public void testCanExecuteNoChallengesOp() {
|
||||
@ -189,7 +189,7 @@ public class ChallengesCommandTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.challenges.commands.ChallengesCommand#canExecute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)}.
|
||||
* Test method for {@link ChallengesPlayerCommand#canExecute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)}.
|
||||
*/
|
||||
@Test
|
||||
public void testCanExecuteNoChallengesHasPerm() {
|
||||
@ -202,7 +202,7 @@ public class ChallengesCommandTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.challenges.commands.ChallengesCommand#canExecute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)}.
|
||||
* Test method for {@link ChallengesPlayerCommand#canExecute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)}.
|
||||
*/
|
||||
@Test
|
||||
public void testCanExecuteNoAdminCommand() {
|
||||
@ -216,7 +216,7 @@ public class ChallengesCommandTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.challenges.commands.ChallengesCommand#canExecute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)}.
|
||||
* Test method for {@link ChallengesPlayerCommand#canExecute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)}.
|
||||
*/
|
||||
@Test
|
||||
public void testCanExecuteNoIsland() {
|
||||
@ -226,7 +226,7 @@ public class ChallengesCommandTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.challenges.commands.ChallengesCommand#canExecute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)}.
|
||||
* Test method for {@link ChallengesPlayerCommand#canExecute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)}.
|
||||
*/
|
||||
@Test
|
||||
public void testCanExecuteSuccess() {
|
||||
@ -235,7 +235,7 @@ public class ChallengesCommandTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.challenges.commands.ChallengesCommand#execute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)}.
|
||||
* Test method for {@link ChallengesPlayerCommand#execute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)}.
|
||||
*/
|
||||
@Test
|
||||
public void testExecuteUserStringListOfStringConsole() {
|
||||
@ -245,7 +245,7 @@ public class ChallengesCommandTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.challenges.commands.ChallengesCommand#execute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)}.
|
||||
* Test method for {@link ChallengesPlayerCommand#execute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)}.
|
||||
*/
|
||||
@Test
|
||||
public void testExecuteUserStringListOfStringUser() {
|
||||
@ -253,11 +253,11 @@ public class ChallengesCommandTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.challenges.commands.ChallengesCommand#setup()}.
|
||||
* Test method for {@link ChallengesPlayerCommand#setup()}.
|
||||
*/
|
||||
@Test
|
||||
public void testSetup() {
|
||||
assertEquals("bskyblock." + ChallengesCommand.CHALLENGE_COMMAND, cc.getPermission());
|
||||
assertEquals("bskyblock.challenges", cc.getPermission());
|
||||
assertEquals("challenges.commands.user.main.parameters", cc.getParameters());
|
||||
assertEquals("challenges.commands.user.main.description", cc.getDescription());
|
||||
assertTrue(cc.isOnlyPlayer());
|
||||
|
Loading…
Reference in New Issue
Block a user