mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-12-22 00:58:04 +01:00
BREAKING CHANGE: now BSBCommand#execute(User, String, List<String>) !!!
This commit is contained in:
parent
0f61049502
commit
2e26c6a20c
@ -20,11 +20,12 @@ public interface BSBCommand {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* What will be executed when this command is run
|
* What will be executed when this command is run
|
||||||
* @param user - the User
|
* @param user the User who is executing the command
|
||||||
* @param args - command arguments
|
* @param label the label which has been used to execute the command (can be the command's label OR an alias)
|
||||||
|
* @param args the command arguments
|
||||||
* @return true or false - true if the command executed successfully
|
* @return true or false - true if the command executed successfully
|
||||||
*/
|
*/
|
||||||
boolean execute(User user, List<String> args);
|
boolean execute(User user, String label, List<String> args);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tab Completer for CompositeCommands. Note that any registered sub-commands will be automatically
|
* Tab Completer for CompositeCommands. Note that any registered sub-commands will be automatically
|
||||||
|
@ -198,7 +198,7 @@ public abstract class CompositeCommand extends Command implements PluginIdentifi
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Execute and trim args
|
// Execute and trim args
|
||||||
return cmd.execute(user, Arrays.asList(args).subList(cmd.subCommandLevel, args.length));
|
return cmd.execute(user, args[cmd.subCommandLevel-1], Arrays.asList(args).subList(cmd.subCommandLevel, args.length));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -508,7 +508,7 @@ public abstract class CompositeCommand extends Command implements PluginIdentifi
|
|||||||
* @return result of help command or false if no help defined
|
* @return result of help command or false if no help defined
|
||||||
*/
|
*/
|
||||||
protected boolean showHelp(CompositeCommand command, User user) {
|
protected boolean showHelp(CompositeCommand command, User user) {
|
||||||
return command.getSubCommand("help").map(helpCommand -> helpCommand.execute(user, new ArrayList<>())).orElse(false);
|
return command.getSubCommand("help").map(helpCommand -> helpCommand.execute(user, helpCommand.getLabel(), new ArrayList<>())).orElse(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -37,7 +37,7 @@ public class DefaultHelpCommand extends CompositeCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(User user, List<String> args) {
|
public boolean execute(User user, String label, List<String> args) {
|
||||||
int depth = 0;
|
int depth = 0;
|
||||||
if (args.size() == 1) {
|
if (args.size() == 1) {
|
||||||
if (NumberUtils.isDigits(args.get(0))) {
|
if (NumberUtils.isDigits(args.get(0))) {
|
||||||
@ -82,7 +82,7 @@ public class DefaultHelpCommand extends CompositeCommand {
|
|||||||
if (!subCommand.getLabel().equals(HELP)) {
|
if (!subCommand.getLabel().equals(HELP)) {
|
||||||
// Every command should have help because every command has a default help
|
// Every command should have help because every command has a default help
|
||||||
Optional<CompositeCommand> sub = subCommand.getSubCommand(HELP);
|
Optional<CompositeCommand> sub = subCommand.getSubCommand(HELP);
|
||||||
sub.ifPresent(compositeCommand -> compositeCommand.execute(user, Collections.singletonList(String.valueOf(newDepth))));
|
sub.ifPresent(compositeCommand -> compositeCommand.execute(user, HELP, Collections.singletonList(String.valueOf(newDepth))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,17 +58,17 @@ public class IslandCommand extends CompositeCommand {
|
|||||||
* @see us.tastybento.bskyblock.api.commands.CommandArgument#execute(org.bukkit.command.CommandSender, java.lang.String[])
|
* @see us.tastybento.bskyblock.api.commands.CommandArgument#execute(org.bukkit.command.CommandSender, java.lang.String[])
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(User user, List<String> args) {
|
public boolean execute(User user, String label, List<String> args) {
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (args.isEmpty()) {
|
if (args.isEmpty()) {
|
||||||
// If user has an island, go
|
// If user has an island, go
|
||||||
if (getPlugin().getIslands().getIsland(getWorld(), user.getUniqueId()) != null) {
|
if (getPlugin().getIslands().getIsland(getWorld(), user.getUniqueId()) != null) {
|
||||||
return getSubCommand("go").map(goCmd -> goCmd.execute(user, new ArrayList<>())).orElse(false);
|
return getSubCommand("go").map(goCmd -> goCmd.execute(user, goCmd.getLabel(), new ArrayList<>())).orElse(false);
|
||||||
}
|
}
|
||||||
// No islands currently
|
// No islands currently
|
||||||
return getSubCommand("create").map(createCmd -> createCmd.execute(user, new ArrayList<>())).orElse(false);
|
return getSubCommand("create").map(createCmd -> createCmd.execute(user, createCmd.getLabel(), new ArrayList<>())).orElse(false);
|
||||||
}
|
}
|
||||||
user.sendMessage("general.errors.unknown-command", TextVariables.LABEL, getTopLabel());
|
user.sendMessage("general.errors.unknown-command", TextVariables.LABEL, getTopLabel());
|
||||||
return false;
|
return false;
|
||||||
|
@ -39,7 +39,7 @@ public class AdminGetRankCommand extends CompositeCommand {
|
|||||||
* @see us.tastybento.bskyblock.api.commands.BSBCommand#execute(us.tastybento.bskyblock.api.user.User, java.util.List)
|
* @see us.tastybento.bskyblock.api.commands.BSBCommand#execute(us.tastybento.bskyblock.api.user.User, java.util.List)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(User user, List<String> args) {
|
public boolean execute(User user, String label, List<String> args) {
|
||||||
if (args.size() != 1) {
|
if (args.size() != 1) {
|
||||||
// Show help
|
// Show help
|
||||||
showHelp(this, user);
|
showHelp(this, user);
|
||||||
|
@ -21,7 +21,7 @@ public class AdminInfoCommand extends CompositeCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(User user, List<String> args) {
|
public boolean execute(User user, String label, List<String> args) {
|
||||||
if (args.size() > 1 || (args.isEmpty() && !user.isPlayer())) {
|
if (args.size() > 1 || (args.isEmpty() && !user.isPlayer())) {
|
||||||
// Show help
|
// Show help
|
||||||
showHelp(this, user);
|
showHelp(this, user);
|
||||||
|
@ -28,7 +28,7 @@ public class AdminRegisterCommand extends CompositeCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(User user, List<String> args) {
|
public boolean execute(User user, String label, List<String> args) {
|
||||||
// If args are not right, show help
|
// If args are not right, show help
|
||||||
if (args.size() != 1) {
|
if (args.size() != 1) {
|
||||||
showHelp(this, user);
|
showHelp(this, user);
|
||||||
|
@ -30,7 +30,7 @@ public class AdminReloadCommand extends CompositeCommand {
|
|||||||
* @see us.tastybento.bskyblock.api.commands.BSBCommand#execute(us.tastybento.bskyblock.api.user.User, java.util.List)
|
* @see us.tastybento.bskyblock.api.commands.BSBCommand#execute(us.tastybento.bskyblock.api.user.User, java.util.List)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(User user, List<String> args) {
|
public boolean execute(User user, String label, List<String> args) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ public class AdminSchemCommand extends CompositeCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public boolean execute(User user, List<String> args) {
|
public boolean execute(User user, String label, List<String> args) {
|
||||||
if (args.isEmpty()) {
|
if (args.isEmpty()) {
|
||||||
showHelp(this, user);
|
showHelp(this, user);
|
||||||
return false;
|
return false;
|
||||||
|
@ -36,7 +36,7 @@ public class AdminSetRankCommand extends CompositeCommand {
|
|||||||
* @see us.tastybento.bskyblock.api.commands.BSBCommand#execute(us.tastybento.bskyblock.api.user.User, java.util.List)
|
* @see us.tastybento.bskyblock.api.commands.BSBCommand#execute(us.tastybento.bskyblock.api.user.User, java.util.List)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(User user, List<String> args) {
|
public boolean execute(User user, String label, List<String> args) {
|
||||||
if (args.size() != 2) {
|
if (args.size() != 2) {
|
||||||
// Show help
|
// Show help
|
||||||
showHelp(this, user);
|
showHelp(this, user);
|
||||||
|
@ -28,7 +28,7 @@ public class AdminTeleportCommand extends CompositeCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(User user, List<String> args) {
|
public boolean execute(User user, String label, List<String> args) {
|
||||||
if (args.isEmpty()) {
|
if (args.isEmpty()) {
|
||||||
this.showHelp(this, user);
|
this.showHelp(this, user);
|
||||||
return true;
|
return true;
|
||||||
|
@ -23,7 +23,7 @@ public class AdminUnregisterCommand extends CompositeCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(User user, List<String> args) {
|
public boolean execute(User user, String label, List<String> args) {
|
||||||
// If args are not right, show help
|
// If args are not right, show help
|
||||||
if (args.size() != 1) {
|
if (args.size() != 1) {
|
||||||
showHelp(this, user);
|
showHelp(this, user);
|
||||||
|
@ -19,7 +19,7 @@ public class AdminVersionCommand extends CompositeCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(User user, List<String> args) {
|
public boolean execute(User user, String label, List<String> args) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,7 +11,6 @@ public class AdminTeamAddCommand extends CompositeCommand {
|
|||||||
|
|
||||||
public AdminTeamAddCommand(CompositeCommand parent) {
|
public AdminTeamAddCommand(CompositeCommand parent) {
|
||||||
super(parent, "add");
|
super(parent, "add");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -22,7 +21,7 @@ public class AdminTeamAddCommand extends CompositeCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(User user, List<String> args) {
|
public boolean execute(User user, String label, List<String> args) {
|
||||||
// If args are not right, show help
|
// If args are not right, show help
|
||||||
if (args.size() != 2) {
|
if (args.size() != 2) {
|
||||||
showHelp(this, user);
|
showHelp(this, user);
|
||||||
|
@ -20,7 +20,7 @@ public class AdminTeamDisbandCommand extends CompositeCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(User user, List<String> args) {
|
public boolean execute(User user, String label, List<String> args) {
|
||||||
// If args are not right, show help
|
// If args are not right, show help
|
||||||
if (args.size() != 1) {
|
if (args.size() != 1) {
|
||||||
showHelp(this, user);
|
showHelp(this, user);
|
||||||
|
@ -21,7 +21,7 @@ public class AdminTeamKickCommand extends CompositeCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(User user, List<String> args) {
|
public boolean execute(User user, String label, List<String> args) {
|
||||||
// If args are not right, show help
|
// If args are not right, show help
|
||||||
if (args.size() != 1) {
|
if (args.size() != 1) {
|
||||||
showHelp(this, user);
|
showHelp(this, user);
|
||||||
|
@ -20,7 +20,7 @@ public class AdminTeamMakeLeaderCommand extends CompositeCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(User user, List<String> args) {
|
public boolean execute(User user, String label, List<String> args) {
|
||||||
// If args are not right, show help
|
// If args are not right, show help
|
||||||
if (args.size() != 1) {
|
if (args.size() != 1) {
|
||||||
showHelp(this, user);
|
showHelp(this, user);
|
||||||
|
@ -30,7 +30,7 @@ public class CustomIslandMultiHomeHelp extends CompositeCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(User user, List<String> args) {
|
public boolean execute(User user, String label, List<String> args) {
|
||||||
// This will only be shown if it is for a player
|
// This will only be shown if it is for a player
|
||||||
if (user.isPlayer()) {
|
if (user.isPlayer()) {
|
||||||
// Get elements
|
// Get elements
|
||||||
|
@ -22,7 +22,7 @@ public class IslandAboutCommand extends CompositeCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(User user, List<String> args) {
|
public boolean execute(User user, String label, List<String> args) {
|
||||||
user.sendRawMessage("About " + BSkyBlock.getInstance().getDescription().getName() + " v" + BSkyBlock.getInstance().getDescription().getVersion() + ":");
|
user.sendRawMessage("About " + BSkyBlock.getInstance().getDescription().getName() + " v" + BSkyBlock.getInstance().getDescription().getVersion() + ":");
|
||||||
user.sendRawMessage("Copyright (c) 2017 - 2018 Tastybento, Poslovitch");
|
user.sendRawMessage("Copyright (c) 2017 - 2018 Tastybento, Poslovitch");
|
||||||
user.sendRawMessage("All rights reserved.");
|
user.sendRawMessage("All rights reserved.");
|
||||||
|
@ -30,7 +30,7 @@ public class IslandBanCommand extends CompositeCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(User user, List<String> args) {
|
public boolean execute(User user, String label, List<String> args) {
|
||||||
if (args.size() != 1) {
|
if (args.size() != 1) {
|
||||||
// Show help
|
// Show help
|
||||||
showHelp(this, user);
|
showHelp(this, user);
|
||||||
|
@ -22,7 +22,7 @@ public class IslandBanlistCommand extends CompositeCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(User user, List<String> args) {
|
public boolean execute(User user, String label, List<String> args) {
|
||||||
if (!args.isEmpty()) {
|
if (!args.isEmpty()) {
|
||||||
// Show help
|
// Show help
|
||||||
showHelp(this, user);
|
showHelp(this, user);
|
||||||
|
@ -34,7 +34,7 @@ public class IslandCreateCommand extends CompositeCommand {
|
|||||||
* @see us.tastybento.bskyblock.api.commands.CommandArgument#execute(org.bukkit.command.CommandSender, java.lang.String[])
|
* @see us.tastybento.bskyblock.api.commands.CommandArgument#execute(org.bukkit.command.CommandSender, java.lang.String[])
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(User user, List<String> args) {
|
public boolean execute(User user, String label, List<String> args) {
|
||||||
if (getIslands().hasIsland(getWorld(), user.getUniqueId())) {
|
if (getIslands().hasIsland(getWorld(), user.getUniqueId())) {
|
||||||
user.sendMessage("general.errors.already-have-island");
|
user.sendMessage("general.errors.already-have-island");
|
||||||
return false;
|
return false;
|
||||||
|
@ -33,7 +33,7 @@ public class IslandGoCommand extends CompositeCommand {
|
|||||||
* @see us.tastybento.bskyblock.api.commands.CommandArgument#execute(org.bukkit.command.CommandSender, java.lang.String[])
|
* @see us.tastybento.bskyblock.api.commands.CommandArgument#execute(org.bukkit.command.CommandSender, java.lang.String[])
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(User user, List<String> args) {
|
public boolean execute(User user, String label, List<String> args) {
|
||||||
if (getIslands().getIsland(getWorld(), user.getUniqueId()) == null) {
|
if (getIslands().getIsland(getWorld(), user.getUniqueId()) == null) {
|
||||||
user.sendMessage("general.errors.no-island");
|
user.sendMessage("general.errors.no-island");
|
||||||
return false;
|
return false;
|
||||||
|
@ -29,7 +29,7 @@ public class IslandLanguageCommand extends CompositeCommand {
|
|||||||
* @see us.tastybento.bskyblock.api.commands.CommandArgument#execute(org.bukkit.command.CommandSender, java.lang.String[])
|
* @see us.tastybento.bskyblock.api.commands.CommandArgument#execute(org.bukkit.command.CommandSender, java.lang.String[])
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(User user, List<String> args) {
|
public boolean execute(User user, String label, List<String> args) {
|
||||||
LanguagePanel.openPanel(user);
|
LanguagePanel.openPanel(user);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ public class IslandResetCommand extends CompositeCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(User user, List<String> args) {
|
public boolean execute(User user, String label, List<String> args) {
|
||||||
// Check cooldown
|
// Check cooldown
|
||||||
if (getSettings().getResetWait() > 0 && onRestartWaitTime(user) > 0 && !user.isOp()) {
|
if (getSettings().getResetWait() > 0 && onRestartWaitTime(user) > 0 && !user.isOp()) {
|
||||||
user.sendMessage("general.errors.you-must-wait", TextVariables.NUMBER, String.valueOf(onRestartWaitTime(user)));
|
user.sendMessage("general.errors.you-must-wait", TextVariables.NUMBER, String.valueOf(onRestartWaitTime(user)));
|
||||||
|
@ -27,7 +27,7 @@ public class IslandResetnameCommand extends CompositeCommand {
|
|||||||
* @see us.tastybento.bskyblock.api.commands.CommandArgument#execute(org.bukkit.command.CommandSender, java.lang.String[])
|
* @see us.tastybento.bskyblock.api.commands.CommandArgument#execute(org.bukkit.command.CommandSender, java.lang.String[])
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(User user, List<String> args) {
|
public boolean execute(User user, String label, List<String> args) {
|
||||||
UUID playerUUID = user.getUniqueId();
|
UUID playerUUID = user.getUniqueId();
|
||||||
|
|
||||||
if (!getIslands().hasIsland(getWorld(), playerUUID)) {
|
if (!getIslands().hasIsland(getWorld(), playerUUID)) {
|
||||||
|
@ -23,7 +23,7 @@ public class IslandSethomeCommand extends CompositeCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(User user, List<String> args) {
|
public boolean execute(User user, String label, List<String> args) {
|
||||||
UUID playerUUID = user.getUniqueId();
|
UUID playerUUID = user.getUniqueId();
|
||||||
// Check island
|
// Check island
|
||||||
if (getPlugin().getIslands().getIsland(getWorld(), user.getUniqueId()) == null) {
|
if (getPlugin().getIslands().getIsland(getWorld(), user.getUniqueId()) == null) {
|
||||||
|
@ -32,7 +32,7 @@ public class IslandSetnameCommand extends CompositeCommand {
|
|||||||
* @see us.tastybento.bskyblock.api.commands.CommandArgument#execute(org.bukkit.command.CommandSender, java.lang.String[])
|
* @see us.tastybento.bskyblock.api.commands.CommandArgument#execute(org.bukkit.command.CommandSender, java.lang.String[])
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(User user, List<String> args) {
|
public boolean execute(User user, String label, List<String> args) {
|
||||||
UUID playerUUID = user.getUniqueId();
|
UUID playerUUID = user.getUniqueId();
|
||||||
|
|
||||||
if (!getIslands().hasIsland(getWorld(), playerUUID)) {
|
if (!getIslands().hasIsland(getWorld(), playerUUID)) {
|
||||||
|
@ -31,7 +31,7 @@ public class IslandSettingsCommand extends CompositeCommand {
|
|||||||
* @see us.tastybento.bskyblock.api.commands.CommandArgument#execute(org.bukkit.command.CommandSender, java.lang.String[])
|
* @see us.tastybento.bskyblock.api.commands.CommandArgument#execute(org.bukkit.command.CommandSender, java.lang.String[])
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(User user, List<String> args) {
|
public boolean execute(User user, String label, List<String> args) {
|
||||||
// Settings are only shown if you are in the right world
|
// Settings are only shown if you are in the right world
|
||||||
if (Util.getWorld(user.getWorld()).equals(getWorld())) {
|
if (Util.getWorld(user.getWorld()).equals(getWorld())) {
|
||||||
SettingsPanel.openPanel(getPlugin(), user, Flag.Type.PROTECTION, getWorld()); //TODO keep track of history?
|
SettingsPanel.openPanel(getPlugin(), user, Flag.Type.PROTECTION, getWorld()); //TODO keep track of history?
|
||||||
|
@ -26,7 +26,7 @@ public class IslandUnbanCommand extends CompositeCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(User user, List<String> args) {
|
public boolean execute(User user, String label, List<String> args) {
|
||||||
if (args.size() != 1) {
|
if (args.size() != 1) {
|
||||||
// Show help
|
// Show help
|
||||||
showHelp(this, user);
|
showHelp(this, user);
|
||||||
|
@ -33,7 +33,7 @@ public class IslandTeamCommand extends CompositeCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(User user, List<String> args) {
|
public boolean execute(User user, String label, List<String> args) {
|
||||||
// Player issuing the command must have an island
|
// Player issuing the command must have an island
|
||||||
UUID teamLeaderUUID = getTeamLeader(getWorld(), user);
|
UUID teamLeaderUUID = getTeamLeader(getWorld(), user);
|
||||||
if (teamLeaderUUID == null) {
|
if (teamLeaderUUID == null) {
|
||||||
|
@ -30,7 +30,7 @@ public class IslandTeamInviteAcceptCommand extends CompositeCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(User user, List<String> args) {
|
public boolean execute(User user, String label, List<String> args) {
|
||||||
|
|
||||||
UUID playerUUID = user.getUniqueId();
|
UUID playerUUID = user.getUniqueId();
|
||||||
// Check if player has been invited
|
// Check if player has been invited
|
||||||
|
@ -35,7 +35,7 @@ public class IslandTeamInviteCommand extends CompositeCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(User user, List<String> args) {
|
public boolean execute(User user, String label, List<String> args) {
|
||||||
UUID playerUUID = user.getUniqueId();
|
UUID playerUUID = user.getUniqueId();
|
||||||
// Player issuing the command must have an island
|
// Player issuing the command must have an island
|
||||||
if (!getIslands().hasIsland(getWorld(), user.getUniqueId())) {
|
if (!getIslands().hasIsland(getWorld(), user.getUniqueId())) {
|
||||||
|
@ -26,7 +26,7 @@ public class IslandTeamInviteRejectCommand extends CompositeCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(User user, List<String> args) {
|
public boolean execute(User user, String label, List<String> args) {
|
||||||
UUID playerUUID = user.getUniqueId();
|
UUID playerUUID = user.getUniqueId();
|
||||||
// Reject /island reject
|
// Reject /island reject
|
||||||
if (itc.getInviteCommand().getInviteList().containsKey(playerUUID)) {
|
if (itc.getInviteCommand().getInviteList().containsKey(playerUUID)) {
|
||||||
|
@ -28,7 +28,7 @@ public class IslandTeamKickCommand extends CompositeCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(User user, List<String> args) {
|
public boolean execute(User user, String label, List<String> args) {
|
||||||
if (!getIslands().inTeam(getWorld(), user.getUniqueId())) {
|
if (!getIslands().inTeam(getWorld(), user.getUniqueId())) {
|
||||||
user.sendMessage("general.errors.no-team");
|
user.sendMessage("general.errors.no-team");
|
||||||
return false;
|
return false;
|
||||||
|
@ -21,7 +21,7 @@ public class IslandTeamLeaveCommand extends CompositeCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(User user, List<String> args) {
|
public boolean execute(User user, String label, List<String> args) {
|
||||||
if (!getIslands().inTeam(getWorld(), user.getUniqueId())) {
|
if (!getIslands().inTeam(getWorld(), user.getUniqueId())) {
|
||||||
user.sendMessage("general.errors.no-team");
|
user.sendMessage("general.errors.no-team");
|
||||||
return false;
|
return false;
|
||||||
|
@ -26,7 +26,7 @@ public class IslandTeamPromoteCommand extends CompositeCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(User user, List<String> args) {
|
public boolean execute(User user, String label, List<String> args) {
|
||||||
if (!getIslands().inTeam(getWorld(), user.getUniqueId())) {
|
if (!getIslands().inTeam(getWorld(), user.getUniqueId())) {
|
||||||
user.sendMessage("general.errors.no-team");
|
user.sendMessage("general.errors.no-team");
|
||||||
return true;
|
return true;
|
||||||
|
@ -26,7 +26,7 @@ public class IslandTeamSetownerCommand extends CompositeCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(User user, List<String> args) {
|
public boolean execute(User user, String label, List<String> args) {
|
||||||
UUID playerUUID = user.getUniqueId();
|
UUID playerUUID = user.getUniqueId();
|
||||||
// Can use if in a team
|
// Can use if in a team
|
||||||
boolean inTeam = getPlugin().getIslands().inTeam(getWorld(), playerUUID);
|
boolean inTeam = getPlugin().getIslands().inTeam(getWorld(), playerUUID);
|
||||||
|
@ -195,7 +195,7 @@ public class TestBSkyBlock {
|
|||||||
testCommand.setOnlyPlayer(true);
|
testCommand.setOnlyPlayer(true);
|
||||||
testCommand.setPermission("default.permission");
|
testCommand.setPermission("default.permission");
|
||||||
// Test basic execution
|
// Test basic execution
|
||||||
assertTrue(testCommand.execute(user, new ArrayList<>()));
|
assertTrue(testCommand.execute(user, testCommand.getLabel(), new ArrayList<>()));
|
||||||
assertEquals("test",testCommand.getLabel());
|
assertEquals("test",testCommand.getLabel());
|
||||||
assertEquals(2, testCommand.getAliases().size());
|
assertEquals(2, testCommand.getAliases().size());
|
||||||
assertEquals("t", testCommand.getAliases().get(0));
|
assertEquals("t", testCommand.getAliases().get(0));
|
||||||
@ -259,7 +259,7 @@ public class TestBSkyBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(User user, List<String> args) {
|
public boolean execute(User user, String label, List<String> args) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -284,7 +284,7 @@ public class TestBSkyBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(User user, List<String> args) {
|
public boolean execute(User user, String label, List<String> args) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -298,7 +298,7 @@ public class TestBSkyBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(User user, List<String> args) {
|
public boolean execute(User user, String label, List<String> args) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -317,7 +317,7 @@ public class TestBSkyBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(User user, List<String> args) {
|
public boolean execute(User user, String label, List<String> args) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -339,7 +339,7 @@ public class TestBSkyBlock {
|
|||||||
public void setup() {}
|
public void setup() {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(User user, List<String> args) {
|
public boolean execute(User user, String label, List<String> args) {
|
||||||
|
|
||||||
return args.size() == 3;
|
return args.size() == 3;
|
||||||
}
|
}
|
||||||
@ -362,7 +362,7 @@ public class TestBSkyBlock {
|
|||||||
public void setup() {}
|
public void setup() {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(User user, List<String> args) {
|
public boolean execute(User user, String label, List<String> args) {
|
||||||
return args.size() == 3;
|
return args.size() == 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ public class DefaultHelpCommandTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(User user, List<String> args) {
|
public boolean execute(User user, String label, List<String> args) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,7 +145,7 @@ public class DefaultHelpCommandTest {
|
|||||||
when(user.getTranslation("parameters")).thenReturn("");
|
when(user.getTranslation("parameters")).thenReturn("");
|
||||||
when(user.getTranslation("description")).thenReturn("the main island command");
|
when(user.getTranslation("description")).thenReturn("the main island command");
|
||||||
DefaultHelpCommand dhc = new DefaultHelpCommand(parent);
|
DefaultHelpCommand dhc = new DefaultHelpCommand(parent);
|
||||||
dhc.execute(user, new ArrayList<>());
|
dhc.execute(user, dhc.getLabel(), new ArrayList<>());
|
||||||
Mockito.verify(user).sendMessage("commands.help.header", "[label]", "BSkyBlock");
|
Mockito.verify(user).sendMessage("commands.help.header", "[label]", "BSkyBlock");
|
||||||
Mockito.verify(user).getTranslation("island");
|
Mockito.verify(user).getTranslation("island");
|
||||||
Mockito.verify(user).getTranslation("parameters");
|
Mockito.verify(user).getTranslation("parameters");
|
||||||
@ -176,7 +176,7 @@ public class DefaultHelpCommandTest {
|
|||||||
DefaultHelpCommand dhc = new DefaultHelpCommand(parent);
|
DefaultHelpCommand dhc = new DefaultHelpCommand(parent);
|
||||||
List<String> args = new ArrayList<>();
|
List<String> args = new ArrayList<>();
|
||||||
args.add("1");
|
args.add("1");
|
||||||
dhc.execute(user, args);
|
dhc.execute(user, dhc.getLabel(), args);
|
||||||
// There are no header or footer shown
|
// There are no header or footer shown
|
||||||
Mockito.verify(user).getTranslation("island");
|
Mockito.verify(user).getTranslation("island");
|
||||||
Mockito.verify(user).getTranslation("parameters");
|
Mockito.verify(user).getTranslation("parameters");
|
||||||
@ -209,7 +209,7 @@ public class DefaultHelpCommandTest {
|
|||||||
List<String> args = new ArrayList<>();
|
List<String> args = new ArrayList<>();
|
||||||
// Test /island help team
|
// Test /island help team
|
||||||
args.add("team");
|
args.add("team");
|
||||||
dhc.execute(user, args);
|
dhc.execute(user, dhc.getLabel(), args);
|
||||||
// There are no header or footer shown
|
// There are no header or footer shown
|
||||||
Mockito.verify(user).getTranslation("island");
|
Mockito.verify(user).getTranslation("island");
|
||||||
Mockito.verify(user).getTranslation("commands.help.parameters");
|
Mockito.verify(user).getTranslation("commands.help.parameters");
|
||||||
|
@ -102,11 +102,11 @@ public class AdminCommandTest {
|
|||||||
CommandsManager cm = mock(CommandsManager.class);
|
CommandsManager cm = mock(CommandsManager.class);
|
||||||
when(plugin.getCommandsManager()).thenReturn(cm);
|
when(plugin.getCommandsManager()).thenReturn(cm);
|
||||||
AdminCommand ac = new AdminCommand();
|
AdminCommand ac = new AdminCommand();
|
||||||
assertTrue(ac.execute(mock(User.class), new ArrayList<>()));
|
assertTrue(ac.execute(mock(User.class), ac.getLabel(), new ArrayList<>()));
|
||||||
|
|
||||||
// No such command
|
// No such command
|
||||||
String[] args2 = {"random", "junk"};
|
String[] args2 = {"random", "junk"};
|
||||||
assertFalse(ac.execute(mock(User.class), Arrays.asList(args2)));
|
assertFalse(ac.execute(mock(User.class), ac.getLabel(), Arrays.asList(args2)));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -129,7 +129,7 @@ public class IslandCommandTest {
|
|||||||
when(plugin.getCommandsManager()).thenReturn(cm);
|
when(plugin.getCommandsManager()).thenReturn(cm);
|
||||||
// Setup
|
// Setup
|
||||||
IslandCommand ic = new IslandCommand();
|
IslandCommand ic = new IslandCommand();
|
||||||
assertFalse(ic.execute(null, null));
|
assertFalse(ic.execute(null, ic.getLabel(), new ArrayList<>()));
|
||||||
IslandsManager im = mock(IslandsManager.class);
|
IslandsManager im = mock(IslandsManager.class);
|
||||||
when(plugin.getIslands()).thenReturn(im);
|
when(plugin.getIslands()).thenReturn(im);
|
||||||
User user = mock(User.class);
|
User user = mock(User.class);
|
||||||
@ -144,7 +144,7 @@ public class IslandCommandTest {
|
|||||||
|
|
||||||
// User has an island - so go there!
|
// User has an island - so go there!
|
||||||
when(im.getIsland(Mockito.any(), Mockito.eq(uuid))).thenReturn(island);
|
when(im.getIsland(Mockito.any(), Mockito.eq(uuid))).thenReturn(island);
|
||||||
assertTrue(ic.execute(user, new ArrayList<>()));
|
assertTrue(ic.execute(user, ic.getLabel(), new ArrayList<>()));
|
||||||
when(user.getWorld()).thenReturn(world);
|
when(user.getWorld()).thenReturn(world);
|
||||||
|
|
||||||
|
|
||||||
@ -153,11 +153,11 @@ public class IslandCommandTest {
|
|||||||
// No island yet, one will be created
|
// No island yet, one will be created
|
||||||
when(im.createIsland(Mockito.any(), Mockito.any())).thenReturn(island);
|
when(im.createIsland(Mockito.any(), Mockito.any())).thenReturn(island);
|
||||||
when(im.hasIsland(Mockito.any(), Mockito.eq(uuid))).thenReturn(false);
|
when(im.hasIsland(Mockito.any(), Mockito.eq(uuid))).thenReturn(false);
|
||||||
assertTrue(ic.execute(user, new ArrayList<>()));
|
assertTrue(ic.execute(user, ic.getLabel(), new ArrayList<>()));
|
||||||
|
|
||||||
// No such command
|
// No such command
|
||||||
String[] args2 = {"random", "junk"};
|
String[] args2 = {"random", "junk"};
|
||||||
assertFalse(ic.execute(user, Arrays.asList(args2)));
|
assertFalse(ic.execute(user, ic.getLabel(), Arrays.asList(args2)));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,11 +5,7 @@ import static org.junit.Assert.assertTrue;
|
|||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -126,31 +122,31 @@ public class AdminInfoCommandTest {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link us.tastybento.bskyblock.commands.admin.team.AdminInfoCommand#execute(us.tastybento.bskyblock.api.user.User, java.util.List)}.
|
* Test method for {@link AdminInfoCommand#execute(User, String, List)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testExecuteNoTargetConsole() {
|
public void testExecuteNoTargetConsole() {
|
||||||
AdminInfoCommand itl = new AdminInfoCommand(ac);
|
AdminInfoCommand itl = new AdminInfoCommand(ac);
|
||||||
CommandSender sender = mock(CommandSender.class);
|
CommandSender sender = mock(CommandSender.class);
|
||||||
User console = User.getInstance(sender);
|
User console = User.getInstance(sender);
|
||||||
assertFalse(itl.execute(console, new ArrayList<>()));
|
assertFalse(itl.execute(console, itl.getLabel(), new ArrayList<>()));
|
||||||
// Show help
|
// Show help
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link us.tastybento.bskyblock.commands.admin.team.AdminInfoCommand#execute(us.tastybento.bskyblock.api.user.User, java.util.List)}.
|
* Test method for {@link us.tastybento.bskyblock.commands.admin.AdminInfoCommand#execute(User, String, List)} .
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testExecuteUnknownPlayer() {
|
public void testExecuteUnknownPlayer() {
|
||||||
AdminInfoCommand itl = new AdminInfoCommand(ac);
|
AdminInfoCommand itl = new AdminInfoCommand(ac);
|
||||||
String[] name = {"tastybento"};
|
String[] name = {"tastybento"};
|
||||||
when(pm.getUUID(Mockito.any())).thenReturn(null);
|
when(pm.getUUID(Mockito.any())).thenReturn(null);
|
||||||
assertFalse(itl.execute(user, Arrays.asList(name)));
|
assertFalse(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
|
||||||
Mockito.verify(user).sendMessage(Mockito.eq("general.errors.unknown-player"));
|
Mockito.verify(user).sendMessage(Mockito.eq("general.errors.unknown-player"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link us.tastybento.bskyblock.commands.admin.team.AdminInfoCommand#execute(us.tastybento.bskyblock.api.user.User, java.util.List)}.
|
* Test method for {@link us.tastybento.bskyblock.commands.admin.AdminInfoCommand#execute(us.tastybento.bskyblock.api.user.User, java.util.List)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testExecutePlayerHasNoIsland() {
|
public void testExecutePlayerHasNoIsland() {
|
||||||
@ -159,12 +155,12 @@ public class AdminInfoCommandTest {
|
|||||||
when(pm.getUUID(Mockito.any())).thenReturn(notUUID);
|
when(pm.getUUID(Mockito.any())).thenReturn(notUUID);
|
||||||
when(im.hasIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(false);
|
when(im.hasIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(false);
|
||||||
when(im.inTeam(Mockito.any(), Mockito.any())).thenReturn(false);
|
when(im.inTeam(Mockito.any(), Mockito.any())).thenReturn(false);
|
||||||
assertFalse(itl.execute(user, Arrays.asList(name)));
|
assertFalse(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
|
||||||
Mockito.verify(user).sendMessage(Mockito.eq("general.errors.player-has-no-island"));
|
Mockito.verify(user).sendMessage(Mockito.eq("general.errors.player-has-no-island"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link us.tastybento.bskyblock.commands.admin.team.AdminInfoCommand#execute(us.tastybento.bskyblock.api.user.User, java.util.List)}.
|
* Test method for {@link us.tastybento.bskyblock.commands.admin.AdminInfoCommand#execute(User, String, List)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testExecuteSuccess() {
|
public void testExecuteSuccess() {
|
||||||
@ -174,12 +170,12 @@ public class AdminInfoCommandTest {
|
|||||||
when(im.hasIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(true);
|
when(im.hasIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(true);
|
||||||
Island is = mock(Island.class);
|
Island is = mock(Island.class);
|
||||||
when(im.getIsland(Mockito.any(), Mockito.eq(notUUID))).thenReturn(is);
|
when(im.getIsland(Mockito.any(), Mockito.eq(notUUID))).thenReturn(is);
|
||||||
assertTrue(itl.execute(user, Arrays.asList(name)));
|
assertTrue(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
|
||||||
Mockito.verify(is).showInfo(Mockito.eq(plugin), Mockito.eq(user), Mockito.any());
|
Mockito.verify(is).showInfo(Mockito.eq(plugin), Mockito.eq(user), Mockito.any());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link us.tastybento.bskyblock.commands.admin.team.AdminInfoCommand#execute(us.tastybento.bskyblock.api.user.User, java.util.List)}.
|
* Test method for {@link us.tastybento.bskyblock.commands.admin.AdminInfoCommand#execute(User, String, List)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testExecuteUserNotOnIsland() {
|
public void testExecuteUserNotOnIsland() {
|
||||||
@ -187,13 +183,13 @@ public class AdminInfoCommandTest {
|
|||||||
AdminInfoCommand itl = new AdminInfoCommand(ac);
|
AdminInfoCommand itl = new AdminInfoCommand(ac);
|
||||||
// No island here
|
// No island here
|
||||||
when(im.getIslandAt(Mockito.any())).thenReturn(Optional.empty());
|
when(im.getIslandAt(Mockito.any())).thenReturn(Optional.empty());
|
||||||
assertFalse(itl.execute(user, new ArrayList<>()));
|
assertFalse(itl.execute(user, itl.getLabel(), new ArrayList<>()));
|
||||||
// Confirm other verifications
|
// Confirm other verifications
|
||||||
Mockito.verify(user).sendMessage("commands.admin.info.no-island");
|
Mockito.verify(user).sendMessage("commands.admin.info.no-island");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link us.tastybento.bskyblock.commands.admin.team.AdminInfoCommand#execute(us.tastybento.bskyblock.api.user.User, java.util.List)}.
|
* Test method for {@link us.tastybento.bskyblock.commands.admin.AdminInfoCommand#execute(User, String, List)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testExecuteSuccessUserOnIsland() {
|
public void testExecuteSuccessUserOnIsland() {
|
||||||
@ -210,7 +206,7 @@ public class AdminInfoCommandTest {
|
|||||||
when(user.getLocation()).thenReturn(loc);
|
when(user.getLocation()).thenReturn(loc);
|
||||||
|
|
||||||
|
|
||||||
assertTrue(itl.execute(user, new ArrayList<>()));
|
assertTrue(itl.execute(user, itl.getLabel(), new ArrayList<>()));
|
||||||
// Confirm other verifications
|
// Confirm other verifications
|
||||||
Mockito.verify(is).showInfo(Mockito.eq(plugin), Mockito.eq(user), Mockito.any());
|
Mockito.verify(is).showInfo(Mockito.eq(plugin), Mockito.eq(user), Mockito.any());
|
||||||
}
|
}
|
||||||
|
@ -130,7 +130,7 @@ public class AdminRegisterCommandTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testExecuteNoTarget() {
|
public void testExecuteNoTarget() {
|
||||||
AdminRegisterCommand itl = new AdminRegisterCommand(ac);
|
AdminRegisterCommand itl = new AdminRegisterCommand(ac);
|
||||||
assertFalse(itl.execute(user, new ArrayList<>()));
|
assertFalse(itl.execute(user, itl.getLabel(), new ArrayList<>()));
|
||||||
// Show help
|
// Show help
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,7 +142,7 @@ public class AdminRegisterCommandTest {
|
|||||||
AdminRegisterCommand itl = new AdminRegisterCommand(ac);
|
AdminRegisterCommand itl = new AdminRegisterCommand(ac);
|
||||||
String[] name = {"tastybento"};
|
String[] name = {"tastybento"};
|
||||||
when(pm.getUUID(Mockito.any())).thenReturn(null);
|
when(pm.getUUID(Mockito.any())).thenReturn(null);
|
||||||
assertFalse(itl.execute(user, Arrays.asList(name)));
|
assertFalse(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
|
||||||
Mockito.verify(user).sendMessage(Mockito.eq("general.errors.unknown-player"));
|
Mockito.verify(user).sendMessage(Mockito.eq("general.errors.unknown-player"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,7 +156,7 @@ public class AdminRegisterCommandTest {
|
|||||||
when(pm.getUUID(Mockito.any())).thenReturn(notUUID);
|
when(pm.getUUID(Mockito.any())).thenReturn(notUUID);
|
||||||
when(im.hasIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(true);
|
when(im.hasIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(true);
|
||||||
when(im.inTeam(Mockito.any(), Mockito.any())).thenReturn(false);
|
when(im.inTeam(Mockito.any(), Mockito.any())).thenReturn(false);
|
||||||
assertFalse(itl.execute(user, Arrays.asList(name)));
|
assertFalse(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
|
||||||
Mockito.verify(user).sendMessage(Mockito.eq("general.errors.player-has-island"));
|
Mockito.verify(user).sendMessage(Mockito.eq("general.errors.player-has-island"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,7 +170,7 @@ public class AdminRegisterCommandTest {
|
|||||||
String[] name = {"tastybento"};
|
String[] name = {"tastybento"};
|
||||||
when(pm.getUUID(Mockito.any())).thenReturn(notUUID);
|
when(pm.getUUID(Mockito.any())).thenReturn(notUUID);
|
||||||
AdminRegisterCommand itl = new AdminRegisterCommand(ac);
|
AdminRegisterCommand itl = new AdminRegisterCommand(ac);
|
||||||
assertFalse(itl.execute(user, Arrays.asList(name)));
|
assertFalse(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
|
||||||
Mockito.verify(user).sendMessage("commands.admin.register.cannot-register-team-player");
|
Mockito.verify(user).sendMessage("commands.admin.register.cannot-register-team-player");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,7 +192,7 @@ public class AdminRegisterCommandTest {
|
|||||||
when(im.getIslandAt(Mockito.any())).thenReturn(opi);
|
when(im.getIslandAt(Mockito.any())).thenReturn(opi);
|
||||||
when(user.getLocation()).thenReturn(loc);
|
when(user.getLocation()).thenReturn(loc);
|
||||||
AdminRegisterCommand itl = new AdminRegisterCommand(ac);
|
AdminRegisterCommand itl = new AdminRegisterCommand(ac);
|
||||||
assertFalse(itl.execute(user, Arrays.asList(name)));
|
assertFalse(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
|
||||||
Mockito.verify(user).sendMessage("commands.admin.register.already-owned");
|
Mockito.verify(user).sendMessage("commands.admin.register.already-owned");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,7 +215,7 @@ public class AdminRegisterCommandTest {
|
|||||||
when(pm.getUUID(Mockito.any())).thenReturn(notUUID);
|
when(pm.getUUID(Mockito.any())).thenReturn(notUUID);
|
||||||
|
|
||||||
AdminRegisterCommand itl = new AdminRegisterCommand(ac);
|
AdminRegisterCommand itl = new AdminRegisterCommand(ac);
|
||||||
assertTrue(itl.execute(user, Arrays.asList(name)));
|
assertTrue(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
|
||||||
// Add other verifications
|
// Add other verifications
|
||||||
Mockito.verify(user).sendMessage("commands.admin.register.registered-island", "[xyz]", "123,123,432");
|
Mockito.verify(user).sendMessage("commands.admin.register.registered-island", "[xyz]", "123,123,432");
|
||||||
Mockito.verify(user).sendMessage(Mockito.eq("general.success"));
|
Mockito.verify(user).sendMessage(Mockito.eq("general.success"));
|
||||||
|
@ -128,7 +128,7 @@ public class AdminUnregisterCommandTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testExecuteNoTarget() {
|
public void testExecuteNoTarget() {
|
||||||
AdminUnregisterCommand itl = new AdminUnregisterCommand(ac);
|
AdminUnregisterCommand itl = new AdminUnregisterCommand(ac);
|
||||||
assertFalse(itl.execute(user, new ArrayList<>()));
|
assertFalse(itl.execute(user, itl.getLabel(), new ArrayList<>()));
|
||||||
// Show help
|
// Show help
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,7 +140,7 @@ public class AdminUnregisterCommandTest {
|
|||||||
AdminUnregisterCommand itl = new AdminUnregisterCommand(ac);
|
AdminUnregisterCommand itl = new AdminUnregisterCommand(ac);
|
||||||
String[] name = {"tastybento"};
|
String[] name = {"tastybento"};
|
||||||
when(pm.getUUID(Mockito.any())).thenReturn(null);
|
when(pm.getUUID(Mockito.any())).thenReturn(null);
|
||||||
assertFalse(itl.execute(user, Arrays.asList(name)));
|
assertFalse(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
|
||||||
Mockito.verify(user).sendMessage(Mockito.eq("general.errors.unknown-player"));
|
Mockito.verify(user).sendMessage(Mockito.eq("general.errors.unknown-player"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,7 +153,7 @@ public class AdminUnregisterCommandTest {
|
|||||||
String[] name = {"tastybento"};
|
String[] name = {"tastybento"};
|
||||||
when(pm.getUUID(Mockito.any())).thenReturn(notUUID);
|
when(pm.getUUID(Mockito.any())).thenReturn(notUUID);
|
||||||
when(im.hasIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(false);
|
when(im.hasIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(false);
|
||||||
assertFalse(itl.execute(user, Arrays.asList(name)));
|
assertFalse(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
|
||||||
Mockito.verify(user).sendMessage(Mockito.eq("general.errors.player-has-no-island"));
|
Mockito.verify(user).sendMessage(Mockito.eq("general.errors.player-has-no-island"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,7 +166,7 @@ public class AdminUnregisterCommandTest {
|
|||||||
String[] name = {"tastybento"};
|
String[] name = {"tastybento"};
|
||||||
when(pm.getUUID(Mockito.any())).thenReturn(notUUID);
|
when(pm.getUUID(Mockito.any())).thenReturn(notUUID);
|
||||||
AdminUnregisterCommand itl = new AdminUnregisterCommand(ac);
|
AdminUnregisterCommand itl = new AdminUnregisterCommand(ac);
|
||||||
assertFalse(itl.execute(user, Arrays.asList(name)));
|
assertFalse(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
|
||||||
Mockito.verify(user).sendMessage("commands.admin.unregister.cannot-unregister-team-player");
|
Mockito.verify(user).sendMessage("commands.admin.unregister.cannot-unregister-team-player");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,7 +185,7 @@ public class AdminUnregisterCommandTest {
|
|||||||
when(pm.getUUID(Mockito.any())).thenReturn(notUUID);
|
when(pm.getUUID(Mockito.any())).thenReturn(notUUID);
|
||||||
|
|
||||||
AdminUnregisterCommand itl = new AdminUnregisterCommand(ac);
|
AdminUnregisterCommand itl = new AdminUnregisterCommand(ac);
|
||||||
assertTrue(itl.execute(user, Arrays.asList(name)));
|
assertTrue(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
|
||||||
// Add other verifications
|
// Add other verifications
|
||||||
Mockito.verify(user).sendMessage("commands.admin.unregister.unregistered-island", "[xyz]", "123,123,432");
|
Mockito.verify(user).sendMessage("commands.admin.unregister.unregistered-island", "[xyz]", "123,123,432");
|
||||||
Mockito.verify(user).sendMessage(Mockito.eq("general.success"));
|
Mockito.verify(user).sendMessage(Mockito.eq("general.success"));
|
||||||
|
@ -124,25 +124,25 @@ public class AdminTeamAddCommandTest {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link AdminTeamAddCommand#execute(us.tastybento.bskyblock.api.user.User, java.util.List)}.
|
* Test method for {@link AdminTeamAddCommand#execute(User, String, List)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testExecuteWrongArgs() {
|
public void testExecuteWrongArgs() {
|
||||||
AdminTeamAddCommand itl = new AdminTeamAddCommand(ac);
|
AdminTeamAddCommand itl = new AdminTeamAddCommand(ac);
|
||||||
List<String> args = new ArrayList<>();
|
List<String> args = new ArrayList<>();
|
||||||
assertFalse(itl.execute(user, args));
|
assertFalse(itl.execute(user, itl.getLabel(), args));
|
||||||
// Show help
|
// Show help
|
||||||
args.add("arg1");
|
args.add("arg1");
|
||||||
assertFalse(itl.execute(user, args));
|
assertFalse(itl.execute(user, itl.getLabel(), args));
|
||||||
// Show help
|
// Show help
|
||||||
args.add("args2");
|
args.add("args2");
|
||||||
args.add("args3");
|
args.add("args3");
|
||||||
assertFalse(itl.execute(user, args));
|
assertFalse(itl.execute(user, itl.getLabel(), args));
|
||||||
// Show help
|
// Show help
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link AdminTeamAddCommand#execute(us.tastybento.bskyblock.api.user.User, java.util.List)}.
|
* Test method for {@link AdminTeamAddCommand#execute(User, String, List)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testExecuteUnknownPlayer() {
|
public void testExecuteUnknownPlayer() {
|
||||||
@ -152,18 +152,18 @@ public class AdminTeamAddCommandTest {
|
|||||||
// Unknown leader
|
// Unknown leader
|
||||||
when(pm.getUUID(Mockito.eq("tastybento"))).thenReturn(null);
|
when(pm.getUUID(Mockito.eq("tastybento"))).thenReturn(null);
|
||||||
when(pm.getUUID(Mockito.eq("poslovich"))).thenReturn(notUUID);
|
when(pm.getUUID(Mockito.eq("poslovich"))).thenReturn(notUUID);
|
||||||
assertFalse(itl.execute(user, Arrays.asList(name)));
|
assertFalse(itl.execute(user, ac.getLabel(), Arrays.asList(name)));
|
||||||
Mockito.verify(user).sendMessage("general.errors.unknown-player-name", "[name]", "tastybento");
|
Mockito.verify(user).sendMessage("general.errors.unknown-player-name", "[name]", "tastybento");
|
||||||
|
|
||||||
// Unknown target
|
// Unknown target
|
||||||
when(pm.getUUID(Mockito.eq("tastybento"))).thenReturn(uuid);
|
when(pm.getUUID(Mockito.eq("tastybento"))).thenReturn(uuid);
|
||||||
when(pm.getUUID(Mockito.eq("poslovich"))).thenReturn(null);
|
when(pm.getUUID(Mockito.eq("poslovich"))).thenReturn(null);
|
||||||
assertFalse(itl.execute(user, Arrays.asList(name)));
|
assertFalse(itl.execute(user, ac.getLabel(), Arrays.asList(name)));
|
||||||
Mockito.verify(user).sendMessage("general.errors.unknown-player-name", "[name]", "poslovich");
|
Mockito.verify(user).sendMessage("general.errors.unknown-player-name", "[name]", "poslovich");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link AdminTeamAddCommand#execute(us.tastybento.bskyblock.api.user.User, java.util.List)}.
|
* Test method for {@link AdminTeamAddCommand#execute(User, String, List)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testExecuteTargetTargetInTeam() {
|
public void testExecuteTargetTargetInTeam() {
|
||||||
@ -175,13 +175,13 @@ public class AdminTeamAddCommandTest {
|
|||||||
|
|
||||||
when(im.inTeam(Mockito.any(), Mockito.eq(notUUID))).thenReturn(true);
|
when(im.inTeam(Mockito.any(), Mockito.eq(notUUID))).thenReturn(true);
|
||||||
|
|
||||||
assertFalse(itl.execute(user, Arrays.asList(name)));
|
assertFalse(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
|
||||||
Mockito.verify(user).sendMessage(Mockito.eq("commands.island.team.invite.errors.already-on-team"));
|
Mockito.verify(user).sendMessage(Mockito.eq("commands.island.team.invite.errors.already-on-team"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link AdminTeamAddCommand#execute(us.tastybento.bskyblock.api.user.User, java.util.List)}.
|
* Test method for {@link AdminTeamAddCommand#execute(User, String, List)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testExecuteAddNoIsland() {
|
public void testExecuteAddNoIsland() {
|
||||||
@ -194,13 +194,13 @@ public class AdminTeamAddCommandTest {
|
|||||||
// No island,
|
// No island,
|
||||||
when(im.hasIsland(Mockito.any(), Mockito.eq(uuid))).thenReturn(false);
|
when(im.hasIsland(Mockito.any(), Mockito.eq(uuid))).thenReturn(false);
|
||||||
|
|
||||||
assertFalse(itl.execute(user, Arrays.asList(name)));
|
assertFalse(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
|
||||||
Mockito.verify(user).sendMessage("general.errors.player-has-no-island");
|
Mockito.verify(user).sendMessage("general.errors.player-has-no-island");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link AdminTeamAddCommand#execute(us.tastybento.bskyblock.api.user.User, java.util.List)}.
|
* Test method for {@link AdminTeamAddCommand#execute(User, String, List)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testExecuteAddNotLeader() {
|
public void testExecuteAddNotLeader() {
|
||||||
@ -219,13 +219,13 @@ public class AdminTeamAddCommandTest {
|
|||||||
Island island = mock(Island.class);
|
Island island = mock(Island.class);
|
||||||
when(im.getIsland(Mockito.any(), Mockito.eq(uuid))).thenReturn(island);
|
when(im.getIsland(Mockito.any(), Mockito.eq(uuid))).thenReturn(island);
|
||||||
|
|
||||||
assertFalse(itl.execute(user, Arrays.asList(name)));
|
assertFalse(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
|
||||||
Mockito.verify(user).sendMessage("commands.admin.team.add.name-not-leader", "[name]", "tastybento");
|
Mockito.verify(user).sendMessage("commands.admin.team.add.name-not-leader", "[name]", "tastybento");
|
||||||
Mockito.verify(island).showMembers(Mockito.eq(plugin), Mockito.any(), Mockito.any());
|
Mockito.verify(island).showMembers(Mockito.eq(plugin), Mockito.any(), Mockito.any());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link AdminTeamAddCommand#execute(us.tastybento.bskyblock.api.user.User, java.util.List)}.
|
* Test method for {@link AdminTeamAddCommand#execute(User, String, List)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testExecuteAddTargetHasIsland() {
|
public void testExecuteAddTargetHasIsland() {
|
||||||
@ -243,13 +243,13 @@ public class AdminTeamAddCommandTest {
|
|||||||
// Target has island
|
// Target has island
|
||||||
when(im.hasIsland(Mockito.any(), Mockito.eq(notUUID))).thenReturn(true);
|
when(im.hasIsland(Mockito.any(), Mockito.eq(notUUID))).thenReturn(true);
|
||||||
|
|
||||||
assertFalse(itl.execute(user, Arrays.asList(name)));
|
assertFalse(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
|
||||||
Mockito.verify(user).sendMessage("commands.admin.team.add.name-has-island", "[name]", "poslovich");
|
Mockito.verify(user).sendMessage("commands.admin.team.add.name-has-island", "[name]", "poslovich");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link AdminTeamAddCommand#execute(us.tastybento.bskyblock.api.user.User, java.util.List)}.
|
* Test method for {@link AdminTeamAddCommand#execute(User, String, List)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testExecuteAddTargetHasIslandNoTeam() {
|
public void testExecuteAddTargetHasIslandNoTeam() {
|
||||||
@ -266,13 +266,13 @@ public class AdminTeamAddCommandTest {
|
|||||||
// Target has island
|
// Target has island
|
||||||
when(im.hasIsland(Mockito.any(), Mockito.eq(notUUID))).thenReturn(true);
|
when(im.hasIsland(Mockito.any(), Mockito.eq(notUUID))).thenReturn(true);
|
||||||
|
|
||||||
assertFalse(itl.execute(user, Arrays.asList(name)));
|
assertFalse(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
|
||||||
Mockito.verify(user).sendMessage("commands.admin.team.add.name-has-island", "[name]", "poslovich");
|
Mockito.verify(user).sendMessage("commands.admin.team.add.name-has-island", "[name]", "poslovich");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link us.us.tastybento.bskyblock.commands.admin.teams.AdminTeamAddCommand#execute(us.tastybento.bskyblock.api.user.User, java.util.List)}.
|
* Test method for {@link us.tastybento.bskyblock.commands.admin.team.AdminTeamAddCommand#execute(User, String, List)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testExecuteSuccess() {
|
public void testExecuteSuccess() {
|
||||||
@ -299,7 +299,7 @@ public class AdminTeamAddCommandTest {
|
|||||||
when(plugin.getPlayers()).thenReturn(pm);
|
when(plugin.getPlayers()).thenReturn(pm);
|
||||||
|
|
||||||
// Success
|
// Success
|
||||||
assertTrue(itl.execute(user, Arrays.asList(name)));
|
assertTrue(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
|
||||||
Mockito.verify(island).addMember(notUUID);
|
Mockito.verify(island).addMember(notUUID);
|
||||||
Mockito.verify(user).sendMessage(Mockito.eq("general.success"));
|
Mockito.verify(user).sendMessage(Mockito.eq("general.success"));
|
||||||
}
|
}
|
||||||
|
@ -5,12 +5,7 @@ import static org.junit.Assert.assertTrue;
|
|||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@ -123,29 +118,28 @@ public class AdminTeamDisbandCommandTest {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link AdminTeamDisbandCommand#execute(us.tastybento.bskyblock.api.user.User, java.util.List)}.
|
* Test method for {@link AdminTeamDisbandCommand#execute(User, String, List)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testExecuteNoTarget() {
|
public void testExecuteNoTarget() {
|
||||||
AdminTeamDisbandCommand itl = new AdminTeamDisbandCommand(ac);
|
AdminTeamDisbandCommand itl = new AdminTeamDisbandCommand(ac);
|
||||||
assertFalse(itl.execute(user, new ArrayList<>()));
|
assertFalse(itl.execute(user, itl.getLabel(), new ArrayList<>()));
|
||||||
// Show help
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link AdminTeamDisbandCommand#execute(us.tastybento.bskyblock.api.user.User, java.util.List)}.
|
* Test method for {@link AdminTeamDisbandCommand#execute(User, String, List)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testExecuteUnknownPlayer() {
|
public void testExecuteUnknownPlayer() {
|
||||||
AdminTeamDisbandCommand itl = new AdminTeamDisbandCommand(ac);
|
AdminTeamDisbandCommand itl = new AdminTeamDisbandCommand(ac);
|
||||||
String[] name = {"tastybento"};
|
String[] name = {"tastybento"};
|
||||||
when(pm.getUUID(Mockito.any())).thenReturn(null);
|
when(pm.getUUID(Mockito.any())).thenReturn(null);
|
||||||
assertFalse(itl.execute(user, Arrays.asList(name)));
|
assertFalse(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
|
||||||
Mockito.verify(user).sendMessage(Mockito.eq("general.errors.unknown-player"));
|
Mockito.verify(user).sendMessage(Mockito.eq("general.errors.unknown-player"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link AdminTeamDisbandCommand#execute(us.tastybento.bskyblock.api.user.User, java.util.List)}.
|
* Test method for {@link AdminTeamDisbandCommand#execute(User, String, List)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testExecutePlayerNotInTeam() {
|
public void testExecutePlayerNotInTeam() {
|
||||||
@ -153,12 +147,12 @@ public class AdminTeamDisbandCommandTest {
|
|||||||
String[] name = {"tastybento"};
|
String[] name = {"tastybento"};
|
||||||
when(pm.getUUID(Mockito.any())).thenReturn(notUUID);
|
when(pm.getUUID(Mockito.any())).thenReturn(notUUID);
|
||||||
when(im.getMembers(Mockito.any(), Mockito.any())).thenReturn(new HashSet<>());
|
when(im.getMembers(Mockito.any(), Mockito.any())).thenReturn(new HashSet<>());
|
||||||
assertFalse(itl.execute(user, Arrays.asList(name)));
|
assertFalse(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
|
||||||
Mockito.verify(user).sendMessage(Mockito.eq("general.errors.not-in-team"));
|
Mockito.verify(user).sendMessage(Mockito.eq("general.errors.not-in-team"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link AdminTeamDisbandCommand#execute(us.tastybento.bskyblock.api.user.User, java.util.List)}.
|
* Test method for {@link AdminTeamDisbandCommand#execute(User, String, List)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testExecuteDisbandNotLeader() {
|
public void testExecuteDisbandNotLeader() {
|
||||||
@ -172,12 +166,12 @@ public class AdminTeamDisbandCommandTest {
|
|||||||
when(pm.getName(Mockito.any())).thenReturn("leader");
|
when(pm.getName(Mockito.any())).thenReturn("leader");
|
||||||
|
|
||||||
AdminTeamDisbandCommand itl = new AdminTeamDisbandCommand(ac);
|
AdminTeamDisbandCommand itl = new AdminTeamDisbandCommand(ac);
|
||||||
assertFalse(itl.execute(user, Arrays.asList(name)));
|
assertFalse(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
|
||||||
Mockito.verify(user).sendMessage("commands.admin.team.disband.use-disband-leader", "[leader]", "leader");
|
Mockito.verify(user).sendMessage("commands.admin.team.disband.use-disband-leader", "[leader]", "leader");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link us.us.tastybento.bskyblock.commands.admin.teams.AdminTeamDisbandCommand#execute(us.tastybento.bskyblock.api.user.User, java.util.List)}.
|
* Test method for {@link us.tastybento.bskyblock.commands.admin.team.AdminTeamDisbandCommand#execute(User, String, List)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testExecuteSuccess() {
|
public void testExecuteSuccess() {
|
||||||
@ -195,7 +189,7 @@ public class AdminTeamDisbandCommandTest {
|
|||||||
when(im.getMembers(Mockito.any(), Mockito.any())).thenReturn(members);
|
when(im.getMembers(Mockito.any(), Mockito.any())).thenReturn(members);
|
||||||
|
|
||||||
AdminTeamDisbandCommand itl = new AdminTeamDisbandCommand(ac);
|
AdminTeamDisbandCommand itl = new AdminTeamDisbandCommand(ac);
|
||||||
assertTrue(itl.execute(user, Arrays.asList(name)));
|
assertTrue(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
|
||||||
Mockito.verify(im, Mockito.never()).setLeaveTeam(Mockito.any(), Mockito.eq(notUUID));
|
Mockito.verify(im, Mockito.never()).setLeaveTeam(Mockito.any(), Mockito.eq(notUUID));
|
||||||
Mockito.verify(im).setLeaveTeam(Mockito.any(), Mockito.eq(uuid));
|
Mockito.verify(im).setLeaveTeam(Mockito.any(), Mockito.eq(uuid));
|
||||||
Mockito.verify(user).sendMessage(Mockito.eq("general.success"));
|
Mockito.verify(user).sendMessage(Mockito.eq("general.success"));
|
||||||
|
@ -8,11 +8,7 @@ import static org.junit.Assert.assertTrue;
|
|||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@ -126,29 +122,29 @@ public class AdminTeamKickCommandTest {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link AdminTeamKickCommand#execute(us.tastybento.bskyblock.api.user.User, java.util.List)}.
|
* Test method for {@link AdminTeamKickCommand#execute(User, String, List)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testExecuteNoTarget() {
|
public void testExecuteNoTarget() {
|
||||||
AdminTeamKickCommand itl = new AdminTeamKickCommand(ac);
|
AdminTeamKickCommand itl = new AdminTeamKickCommand(ac);
|
||||||
assertFalse(itl.execute(user, new ArrayList<>()));
|
assertFalse(itl.execute(user, itl.getLabel(), new ArrayList<>()));
|
||||||
// Show help
|
// Show help
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link AdminTeamKickCommand#execute(us.tastybento.bskyblock.api.user.User, java.util.List)}.
|
* Test method for {@link AdminTeamKickCommand#execute(User, String, List)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testExecuteUnknownPlayer() {
|
public void testExecuteUnknownPlayer() {
|
||||||
AdminTeamKickCommand itl = new AdminTeamKickCommand(ac);
|
AdminTeamKickCommand itl = new AdminTeamKickCommand(ac);
|
||||||
String[] name = {"tastybento"};
|
String[] name = {"tastybento"};
|
||||||
when(pm.getUUID(Mockito.any())).thenReturn(null);
|
when(pm.getUUID(Mockito.any())).thenReturn(null);
|
||||||
assertFalse(itl.execute(user, Arrays.asList(name)));
|
assertFalse(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
|
||||||
Mockito.verify(user).sendMessage(Mockito.eq("general.errors.unknown-player"));
|
Mockito.verify(user).sendMessage(Mockito.eq("general.errors.unknown-player"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link AdminTeamKickCommand#execute(us.tastybento.bskyblock.api.user.User, java.util.List)}.
|
* Test method for {@link AdminTeamKickCommand#execute(User, String, List)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testExecutePlayerNotInTeam() {
|
public void testExecutePlayerNotInTeam() {
|
||||||
@ -156,12 +152,12 @@ public class AdminTeamKickCommandTest {
|
|||||||
String[] name = {"tastybento"};
|
String[] name = {"tastybento"};
|
||||||
when(pm.getUUID(Mockito.any())).thenReturn(notUUID);
|
when(pm.getUUID(Mockito.any())).thenReturn(notUUID);
|
||||||
when(im.getMembers(Mockito.any(), Mockito.any())).thenReturn(new HashSet<>());
|
when(im.getMembers(Mockito.any(), Mockito.any())).thenReturn(new HashSet<>());
|
||||||
assertFalse(itl.execute(user, Arrays.asList(name)));
|
assertFalse(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
|
||||||
Mockito.verify(user).sendMessage(Mockito.eq("general.errors.not-in-team"));
|
Mockito.verify(user).sendMessage(Mockito.eq("general.errors.not-in-team"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link AdminTeamKickCommand#execute(us.tastybento.bskyblock.api.user.User, java.util.List)}.
|
* Test method for {@link AdminTeamKickCommand#execute(User, String, List)} .
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testExecuteKickLeader() {
|
public void testExecuteKickLeader() {
|
||||||
@ -174,13 +170,13 @@ public class AdminTeamKickCommandTest {
|
|||||||
when(im.getTeamLeader(Mockito.any(), Mockito.eq(notUUID))).thenReturn(notUUID);
|
when(im.getTeamLeader(Mockito.any(), Mockito.eq(notUUID))).thenReturn(notUUID);
|
||||||
|
|
||||||
AdminTeamKickCommand itl = new AdminTeamKickCommand(ac);
|
AdminTeamKickCommand itl = new AdminTeamKickCommand(ac);
|
||||||
assertFalse(itl.execute(user, Arrays.asList(name)));
|
assertFalse(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
|
||||||
Mockito.verify(user).sendMessage(Mockito.eq("commands.admin.team.kick.cannot-kick-leader"));
|
Mockito.verify(user).sendMessage(Mockito.eq("commands.admin.team.kick.cannot-kick-leader"));
|
||||||
Mockito.verify(is).showMembers(Mockito.any(), Mockito.any(), Mockito.any());
|
Mockito.verify(is).showMembers(Mockito.any(), Mockito.any(), Mockito.any());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link us.us.tastybento.bskyblock.commands.admin.teams.AdminTeamKickCommand#execute(us.tastybento.bskyblock.api.user.User, java.util.List)}.
|
* Test method for {@link us.tastybento.bskyblock.commands.admin.team.AdminTeamKickCommand#execute(User, String, List)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testExecute() {
|
public void testExecute() {
|
||||||
@ -193,7 +189,7 @@ public class AdminTeamKickCommandTest {
|
|||||||
when(im.getTeamLeader(Mockito.any(), Mockito.eq(notUUID))).thenReturn(uuid);
|
when(im.getTeamLeader(Mockito.any(), Mockito.eq(notUUID))).thenReturn(uuid);
|
||||||
|
|
||||||
AdminTeamKickCommand itl = new AdminTeamKickCommand(ac);
|
AdminTeamKickCommand itl = new AdminTeamKickCommand(ac);
|
||||||
assertTrue(itl.execute(user, Arrays.asList(name)));
|
assertTrue(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
|
||||||
Mockito.verify(im).removePlayer(Mockito.any(), Mockito.eq(notUUID));
|
Mockito.verify(im).removePlayer(Mockito.any(), Mockito.eq(notUUID));
|
||||||
Mockito.verify(user).sendMessage(Mockito.eq("general.success"));
|
Mockito.verify(user).sendMessage(Mockito.eq("general.success"));
|
||||||
}
|
}
|
||||||
|
@ -5,12 +5,7 @@ import static org.junit.Assert.assertTrue;
|
|||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@ -123,29 +118,29 @@ public class AdminTeamMakeLeaderCommandTest {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link AdminTeamMakeLeaderCommand#execute(us.tastybento.bskyblock.api.user.User, java.util.List)}.
|
* Test method for {@link AdminTeamMakeLeaderCommand#execute(User, String, List)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testExecuteNoTarget() {
|
public void testExecuteNoTarget() {
|
||||||
AdminTeamMakeLeaderCommand itl = new AdminTeamMakeLeaderCommand(ac);
|
AdminTeamMakeLeaderCommand itl = new AdminTeamMakeLeaderCommand(ac);
|
||||||
assertFalse(itl.execute(user, new ArrayList<>()));
|
assertFalse(itl.execute(user, itl.getLabel(), new ArrayList<>()));
|
||||||
// Show help
|
// Show help
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link AdminTeamMakeLeaderCommand#execute(us.tastybento.bskyblock.api.user.User, java.util.List)}.
|
* Test method for {@link AdminTeamMakeLeaderCommand#execute(User, String, List)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testExecuteUnknownPlayer() {
|
public void testExecuteUnknownPlayer() {
|
||||||
AdminTeamMakeLeaderCommand itl = new AdminTeamMakeLeaderCommand(ac);
|
AdminTeamMakeLeaderCommand itl = new AdminTeamMakeLeaderCommand(ac);
|
||||||
String[] name = {"tastybento"};
|
String[] name = {"tastybento"};
|
||||||
when(pm.getUUID(Mockito.any())).thenReturn(null);
|
when(pm.getUUID(Mockito.any())).thenReturn(null);
|
||||||
assertFalse(itl.execute(user, Arrays.asList(name)));
|
assertFalse(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
|
||||||
Mockito.verify(user).sendMessage(Mockito.eq("general.errors.unknown-player"));
|
Mockito.verify(user).sendMessage(Mockito.eq("general.errors.unknown-player"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link AdminTeamMakeLeaderCommand#execute(us.tastybento.bskyblock.api.user.User, java.util.List)}.
|
* Test method for {@link AdminTeamMakeLeaderCommand#execute(User, String, List)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testExecutePlayerNotInTeam() {
|
public void testExecutePlayerNotInTeam() {
|
||||||
@ -153,12 +148,12 @@ public class AdminTeamMakeLeaderCommandTest {
|
|||||||
String[] name = {"tastybento"};
|
String[] name = {"tastybento"};
|
||||||
when(pm.getUUID(Mockito.any())).thenReturn(notUUID);
|
when(pm.getUUID(Mockito.any())).thenReturn(notUUID);
|
||||||
when(im.getMembers(Mockito.any(), Mockito.any())).thenReturn(new HashSet<>());
|
when(im.getMembers(Mockito.any(), Mockito.any())).thenReturn(new HashSet<>());
|
||||||
assertFalse(itl.execute(user, Arrays.asList(name)));
|
assertFalse(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
|
||||||
Mockito.verify(user).sendMessage(Mockito.eq("general.errors.not-in-team"));
|
Mockito.verify(user).sendMessage(Mockito.eq("general.errors.not-in-team"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link AdminTeamMakeLeaderCommand#execute(us.tastybento.bskyblock.api.user.User, java.util.List)}.
|
* Test method for {@link AdminTeamMakeLeaderCommand#execute(User, String, List)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testExecuteMakeLeaderAlreadyLeader() {
|
public void testExecuteMakeLeaderAlreadyLeader() {
|
||||||
@ -171,12 +166,12 @@ public class AdminTeamMakeLeaderCommandTest {
|
|||||||
when(im.getTeamLeader(Mockito.any(), Mockito.eq(notUUID))).thenReturn(notUUID);
|
when(im.getTeamLeader(Mockito.any(), Mockito.eq(notUUID))).thenReturn(notUUID);
|
||||||
|
|
||||||
AdminTeamMakeLeaderCommand itl = new AdminTeamMakeLeaderCommand(ac);
|
AdminTeamMakeLeaderCommand itl = new AdminTeamMakeLeaderCommand(ac);
|
||||||
assertFalse(itl.execute(user, Arrays.asList(name)));
|
assertFalse(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
|
||||||
Mockito.verify(user).sendMessage("commands.admin.team.makeleader.already-leader");
|
Mockito.verify(user).sendMessage("commands.admin.team.makeleader.already-leader");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link us.us.tastybento.bskyblock.commands.admin.teams.AdminTeamMakeLeaderCommand#execute(us.tastybento.bskyblock.api.user.User, java.util.List)}.
|
* Test method for {@link us.tastybento.bskyblock.commands.admin.team.AdminTeamMakeLeaderCommand#execute(User, String, List)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testExecuteSuccess() {
|
public void testExecuteSuccess() {
|
||||||
@ -195,7 +190,7 @@ public class AdminTeamMakeLeaderCommandTest {
|
|||||||
when(im.getMembers(Mockito.any(), Mockito.any())).thenReturn(members);
|
when(im.getMembers(Mockito.any(), Mockito.any())).thenReturn(members);
|
||||||
|
|
||||||
AdminTeamMakeLeaderCommand itl = new AdminTeamMakeLeaderCommand(ac);
|
AdminTeamMakeLeaderCommand itl = new AdminTeamMakeLeaderCommand(ac);
|
||||||
assertTrue(itl.execute(user, Arrays.asList(name)));
|
assertTrue(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
|
||||||
// Add other verifications
|
// Add other verifications
|
||||||
Mockito.verify(im).makeLeader(Mockito.any(), Mockito.eq(user), Mockito.eq(notUUID), Mockito.any());
|
Mockito.verify(im).makeLeader(Mockito.any(), Mockito.eq(user), Mockito.eq(notUUID), Mockito.any());
|
||||||
Mockito.verify(user).sendMessage(Mockito.eq("general.success"));
|
Mockito.verify(user).sendMessage(Mockito.eq("general.success"));
|
||||||
|
@ -123,7 +123,7 @@ public class IslandBanCommandTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link us.tastybento.bskyblock.commands.island.IslandBanCommand#execute(us.tastybento.bskyblock.api.user.User, java.util.List)}.
|
* Test method for {@link us.tastybento.bskyblock.commands.island.IslandBanCommand#execute(User, String, List)}.
|
||||||
*/
|
*/
|
||||||
// Island ban command by itself
|
// Island ban command by itself
|
||||||
|
|
||||||
@ -143,13 +143,13 @@ public class IslandBanCommandTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testNoArgs() {
|
public void testNoArgs() {
|
||||||
IslandBanCommand ibc = new IslandBanCommand(ic);
|
IslandBanCommand ibc = new IslandBanCommand(ic);
|
||||||
assertFalse(ibc.execute(user, new ArrayList<>()));
|
assertFalse(ibc.execute(user, ibc.getLabel(), new ArrayList<>()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNoIsland() {
|
public void testNoIsland() {
|
||||||
IslandBanCommand ibc = new IslandBanCommand(ic);
|
IslandBanCommand ibc = new IslandBanCommand(ic);
|
||||||
assertFalse(ibc.execute(user, Arrays.asList("bill")));
|
assertFalse(ibc.execute(user, ibc.getLabel(), Arrays.asList("bill")));
|
||||||
Mockito.verify(user).sendMessage("general.errors.no-island");
|
Mockito.verify(user).sendMessage("general.errors.no-island");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,7 +157,7 @@ public class IslandBanCommandTest {
|
|||||||
public void testNotOwner() {
|
public void testNotOwner() {
|
||||||
IslandBanCommand ibc = new IslandBanCommand(ic);
|
IslandBanCommand ibc = new IslandBanCommand(ic);
|
||||||
when(im.hasIsland(Mockito.any(), Mockito.eq(uuid))).thenReturn(true);
|
when(im.hasIsland(Mockito.any(), Mockito.eq(uuid))).thenReturn(true);
|
||||||
assertFalse(ibc.execute(user, Arrays.asList("bill")));
|
assertFalse(ibc.execute(user, ibc.getLabel(), Arrays.asList("bill")));
|
||||||
Mockito.verify(user).sendMessage("general.errors.not-leader");
|
Mockito.verify(user).sendMessage("general.errors.not-leader");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,7 +167,7 @@ public class IslandBanCommandTest {
|
|||||||
when(im.hasIsland(Mockito.any(), Mockito.eq(uuid))).thenReturn(true);
|
when(im.hasIsland(Mockito.any(), Mockito.eq(uuid))).thenReturn(true);
|
||||||
when(im.isOwner(Mockito.any(), Mockito.eq(uuid))).thenReturn(true);
|
when(im.isOwner(Mockito.any(), Mockito.eq(uuid))).thenReturn(true);
|
||||||
when(pm.getUUID(Mockito.anyString())).thenReturn(null);
|
when(pm.getUUID(Mockito.anyString())).thenReturn(null);
|
||||||
assertFalse(ibc.execute(user, Arrays.asList("bill")));
|
assertFalse(ibc.execute(user, ibc.getLabel(), Arrays.asList("bill")));
|
||||||
Mockito.verify(user).sendMessage("general.errors.unknown-player");
|
Mockito.verify(user).sendMessage("general.errors.unknown-player");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,7 +177,7 @@ public class IslandBanCommandTest {
|
|||||||
when(im.hasIsland(Mockito.any(), Mockito.eq(uuid))).thenReturn(true);
|
when(im.hasIsland(Mockito.any(), Mockito.eq(uuid))).thenReturn(true);
|
||||||
when(im.isOwner(Mockito.any(), Mockito.eq(uuid))).thenReturn(true);
|
when(im.isOwner(Mockito.any(), Mockito.eq(uuid))).thenReturn(true);
|
||||||
when(pm.getUUID(Mockito.anyString())).thenReturn(uuid);
|
when(pm.getUUID(Mockito.anyString())).thenReturn(uuid);
|
||||||
assertFalse(ibc.execute(user, Arrays.asList("bill")));
|
assertFalse(ibc.execute(user, ibc.getLabel(), Arrays.asList("bill")));
|
||||||
Mockito.verify(user).sendMessage("commands.island.ban.cannot-ban-yourself");
|
Mockito.verify(user).sendMessage("commands.island.ban.cannot-ban-yourself");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,7 +192,7 @@ public class IslandBanCommandTest {
|
|||||||
members.add(uuid);
|
members.add(uuid);
|
||||||
members.add(teamMate);
|
members.add(teamMate);
|
||||||
when(im.getMembers(Mockito.any(), Mockito.any())).thenReturn(members);
|
when(im.getMembers(Mockito.any(), Mockito.any())).thenReturn(members);
|
||||||
assertFalse(ibc.execute(user, Arrays.asList("bill")));
|
assertFalse(ibc.execute(user, ibc.getLabel(), Arrays.asList("bill")));
|
||||||
Mockito.verify(user).sendMessage("commands.island.ban.cannot-ban-member");
|
Mockito.verify(user).sendMessage("commands.island.ban.cannot-ban-member");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,7 +204,7 @@ public class IslandBanCommandTest {
|
|||||||
UUID bannedUser = UUID.randomUUID();
|
UUID bannedUser = UUID.randomUUID();
|
||||||
when(pm.getUUID(Mockito.anyString())).thenReturn(bannedUser);
|
when(pm.getUUID(Mockito.anyString())).thenReturn(bannedUser);
|
||||||
when(island.isBanned(Mockito.eq(bannedUser))).thenReturn(true);
|
when(island.isBanned(Mockito.eq(bannedUser))).thenReturn(true);
|
||||||
assertFalse(ibc.execute(user, Arrays.asList("bill")));
|
assertFalse(ibc.execute(user, ibc.getLabel(), Arrays.asList("bill")));
|
||||||
Mockito.verify(user).sendMessage("commands.island.ban.player-already-banned");
|
Mockito.verify(user).sendMessage("commands.island.ban.player-already-banned");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -220,7 +220,7 @@ public class IslandBanCommandTest {
|
|||||||
when(opUser.isOp()).thenReturn(true);
|
when(opUser.isOp()).thenReturn(true);
|
||||||
when(opUser.isPlayer()).thenReturn(true);
|
when(opUser.isPlayer()).thenReturn(true);
|
||||||
when(User.getInstance(Mockito.any(UUID.class))).thenReturn(opUser);
|
when(User.getInstance(Mockito.any(UUID.class))).thenReturn(opUser);
|
||||||
assertFalse(ibc.execute(user, Arrays.asList("bill")));
|
assertFalse(ibc.execute(user, ibc.getLabel(), Arrays.asList("bill")));
|
||||||
Mockito.verify(user).sendMessage("commands.island.ban.cannot-ban");
|
Mockito.verify(user).sendMessage("commands.island.ban.cannot-ban");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -241,7 +241,7 @@ public class IslandBanCommandTest {
|
|||||||
// Allow adding to ban list
|
// Allow adding to ban list
|
||||||
when(island.addToBanList(Mockito.any())).thenReturn(true);
|
when(island.addToBanList(Mockito.any())).thenReturn(true);
|
||||||
|
|
||||||
assertTrue(ibc.execute(user, Arrays.asList("bill")));
|
assertTrue(ibc.execute(user, ibc.getLabel(), Arrays.asList("bill")));
|
||||||
Mockito.verify(user).sendMessage("general.success");
|
Mockito.verify(user).sendMessage("general.success");
|
||||||
Mockito.verify(targetUser).sendMessage("commands.island.ban.owner-banned-you", TextVariables.NAME, user.getName());
|
Mockito.verify(targetUser).sendMessage("commands.island.ban.owner-banned-you", TextVariables.NAME, user.getName());
|
||||||
}
|
}
|
||||||
@ -262,7 +262,7 @@ public class IslandBanCommandTest {
|
|||||||
// Allow adding to ban list
|
// Allow adding to ban list
|
||||||
when(island.addToBanList(Mockito.any())).thenReturn(true);
|
when(island.addToBanList(Mockito.any())).thenReturn(true);
|
||||||
|
|
||||||
assertTrue(ibc.execute(user, Arrays.asList("bill")));
|
assertTrue(ibc.execute(user, ibc.getLabel(), Arrays.asList("bill")));
|
||||||
Mockito.verify(user).sendMessage("general.success");
|
Mockito.verify(user).sendMessage("general.success");
|
||||||
Mockito.verify(targetUser).sendMessage("commands.island.ban.owner-banned-you", TextVariables.NAME, user.getName());
|
Mockito.verify(targetUser).sendMessage("commands.island.ban.owner-banned-you", TextVariables.NAME, user.getName());
|
||||||
}
|
}
|
||||||
@ -283,7 +283,7 @@ public class IslandBanCommandTest {
|
|||||||
// Disallow adding to ban list - even cancelled
|
// Disallow adding to ban list - even cancelled
|
||||||
when(island.addToBanList(Mockito.any())).thenReturn(false);
|
when(island.addToBanList(Mockito.any())).thenReturn(false);
|
||||||
|
|
||||||
assertFalse(ibc.execute(user, Arrays.asList("bill")));
|
assertFalse(ibc.execute(user, ibc.getLabel(), Arrays.asList("bill")));
|
||||||
Mockito.verify(user, Mockito.never()).sendMessage("general.success");
|
Mockito.verify(user, Mockito.never()).sendMessage("general.success");
|
||||||
Mockito.verify(targetUser, Mockito.never()).sendMessage("commands.island.ban.owner-banned-you", "[owner]", user.getName());
|
Mockito.verify(targetUser, Mockito.never()).sendMessage("commands.island.ban.owner-banned-you", "[owner]", user.getName());
|
||||||
}
|
}
|
||||||
|
@ -124,14 +124,14 @@ public class IslandBanlistCommandTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testWithArgs() {
|
public void testWithArgs() {
|
||||||
IslandBanlistCommand iubc = new IslandBanlistCommand(ic);
|
IslandBanlistCommand iubc = new IslandBanlistCommand(ic);
|
||||||
assertFalse(iubc.execute(user, Arrays.asList("bill")));
|
assertFalse(iubc.execute(user, iubc.getLabel(), Arrays.asList("bill")));
|
||||||
// Verify show help
|
// Verify show help
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNoIsland() {
|
public void testNoIsland() {
|
||||||
IslandBanlistCommand iubc = new IslandBanlistCommand(ic);
|
IslandBanlistCommand iubc = new IslandBanlistCommand(ic);
|
||||||
assertFalse(iubc.execute(user, new ArrayList<>()));
|
assertFalse(iubc.execute(user, iubc.getLabel(), new ArrayList<>()));
|
||||||
Mockito.verify(user).sendMessage("general.errors.no-island");
|
Mockito.verify(user).sendMessage("general.errors.no-island");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,7 +139,7 @@ public class IslandBanlistCommandTest {
|
|||||||
public void testBanlistNooneBanned() {
|
public void testBanlistNooneBanned() {
|
||||||
IslandBanlistCommand iubc = new IslandBanlistCommand(ic);
|
IslandBanlistCommand iubc = new IslandBanlistCommand(ic);
|
||||||
when(im.hasIsland(Mockito.any(), Mockito.eq(uuid))).thenReturn(true);
|
when(im.hasIsland(Mockito.any(), Mockito.eq(uuid))).thenReturn(true);
|
||||||
assertTrue(iubc.execute(user, new ArrayList<>()));
|
assertTrue(iubc.execute(user, iubc.getLabel(), new ArrayList<>()));
|
||||||
Mockito.verify(user).sendMessage("commands.island.banlist.noone");
|
Mockito.verify(user).sendMessage("commands.island.banlist.noone");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,7 +166,7 @@ public class IslandBanlistCommandTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
assertTrue(iubc.execute(user, new ArrayList<>()));
|
assertTrue(iubc.execute(user, iubc.getLabel(), new ArrayList<>()));
|
||||||
Mockito.verify(user).sendMessage("commands.island.banlist.the-following");
|
Mockito.verify(user).sendMessage("commands.island.banlist.the-following");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@ public class IslandGoCommandTest {
|
|||||||
public void testExecuteNoArgsNoIsland() {
|
public void testExecuteNoArgsNoIsland() {
|
||||||
when(im.getIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(null);
|
when(im.getIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(null);
|
||||||
IslandGoCommand igc = new IslandGoCommand(ic);
|
IslandGoCommand igc = new IslandGoCommand(ic);
|
||||||
assertFalse(igc.execute(user, new ArrayList<>()));
|
assertFalse(igc.execute(user, igc.getLabel(), new ArrayList<>()));
|
||||||
Mockito.verify(user).sendMessage("general.errors.no-island");
|
Mockito.verify(user).sendMessage("general.errors.no-island");
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -141,7 +141,7 @@ public class IslandGoCommandTest {
|
|||||||
public void testExecuteNoArgs() {
|
public void testExecuteNoArgs() {
|
||||||
when(im.getIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(island);
|
when(im.getIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(island);
|
||||||
IslandGoCommand igc = new IslandGoCommand(ic);
|
IslandGoCommand igc = new IslandGoCommand(ic);
|
||||||
assertTrue(igc.execute(user, new ArrayList<>()));
|
assertTrue(igc.execute(user, igc.getLabel(), new ArrayList<>()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -152,7 +152,7 @@ public class IslandGoCommandTest {
|
|||||||
when(im.getIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(island);
|
when(im.getIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(island);
|
||||||
when(Util.getPermValue(Mockito.any(Player.class), Mockito.anyString(), Mockito.anyInt())).thenReturn(3);
|
when(Util.getPermValue(Mockito.any(Player.class), Mockito.anyString(), Mockito.anyInt())).thenReturn(3);
|
||||||
IslandGoCommand igc = new IslandGoCommand(ic);
|
IslandGoCommand igc = new IslandGoCommand(ic);
|
||||||
assertTrue(igc.execute(user, new ArrayList<>()));
|
assertTrue(igc.execute(user, igc.getLabel(), new ArrayList<>()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -165,7 +165,7 @@ public class IslandGoCommandTest {
|
|||||||
IslandGoCommand igc = new IslandGoCommand(ic);
|
IslandGoCommand igc = new IslandGoCommand(ic);
|
||||||
List<String> args = new ArrayList<>();
|
List<String> args = new ArrayList<>();
|
||||||
args.add("1");
|
args.add("1");
|
||||||
assertTrue(igc.execute(user, args));
|
assertTrue(igc.execute(user, igc.getLabel(), args));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -178,7 +178,7 @@ public class IslandGoCommandTest {
|
|||||||
IslandGoCommand igc = new IslandGoCommand(ic);
|
IslandGoCommand igc = new IslandGoCommand(ic);
|
||||||
List<String> args = new ArrayList<>();
|
List<String> args = new ArrayList<>();
|
||||||
args.add("2");
|
args.add("2");
|
||||||
assertTrue(igc.execute(user, args));
|
assertTrue(igc.execute(user, igc.getLabel(), args));
|
||||||
Mockito.verify(user).sendMessage("commands.island.go.tip", TextVariables.LABEL, "island");
|
Mockito.verify(user).sendMessage("commands.island.go.tip", TextVariables.LABEL, "island");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -193,6 +193,6 @@ public class IslandGoCommandTest {
|
|||||||
IslandGoCommand igc = new IslandGoCommand(ic);
|
IslandGoCommand igc = new IslandGoCommand(ic);
|
||||||
List<String> args = new ArrayList<>();
|
List<String> args = new ArrayList<>();
|
||||||
args.add("sdfsdf");
|
args.add("sdfsdf");
|
||||||
assertTrue(igc.execute(user, args));
|
assertTrue(igc.execute(user, igc.getLabel(), args));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -123,7 +123,7 @@ public class IslandResetCommandTest {
|
|||||||
IslandResetCommand irc = new IslandResetCommand(ic);
|
IslandResetCommand irc = new IslandResetCommand(ic);
|
||||||
// Test the reset command
|
// Test the reset command
|
||||||
// Does not have island
|
// Does not have island
|
||||||
assertFalse(irc.execute(user, new ArrayList<>()));
|
assertFalse(irc.execute(user, irc.getLabel(), new ArrayList<>()));
|
||||||
Mockito.verify(user).sendMessage("general.errors.no-island");
|
Mockito.verify(user).sendMessage("general.errors.no-island");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,7 +132,7 @@ public class IslandResetCommandTest {
|
|||||||
IslandResetCommand irc = new IslandResetCommand(ic);
|
IslandResetCommand irc = new IslandResetCommand(ic);
|
||||||
// Now has island, but is not the leader
|
// Now has island, but is not the leader
|
||||||
when(im.hasIsland(Mockito.any(), Mockito.eq(uuid))).thenReturn(true);
|
when(im.hasIsland(Mockito.any(), Mockito.eq(uuid))).thenReturn(true);
|
||||||
assertFalse(irc.execute(user, new ArrayList<>()));
|
assertFalse(irc.execute(user, irc.getLabel(), new ArrayList<>()));
|
||||||
Mockito.verify(user).sendMessage("general.errors.not-leader");
|
Mockito.verify(user).sendMessage("general.errors.not-leader");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,7 +143,7 @@ public class IslandResetCommandTest {
|
|||||||
when(im.hasIsland(Mockito.any(), Mockito.eq(uuid))).thenReturn(true);
|
when(im.hasIsland(Mockito.any(), Mockito.eq(uuid))).thenReturn(true);
|
||||||
// Now is owner, but still has team
|
// Now is owner, but still has team
|
||||||
when(im.isOwner(Mockito.any(), Mockito.eq(uuid))).thenReturn(true);
|
when(im.isOwner(Mockito.any(), Mockito.eq(uuid))).thenReturn(true);
|
||||||
assertFalse(irc.execute(user, new ArrayList<>()));
|
assertFalse(irc.execute(user, irc.getLabel(), new ArrayList<>()));
|
||||||
Mockito.verify(user).sendMessage("commands.island.reset.must-remove-members");
|
Mockito.verify(user).sendMessage("commands.island.reset.must-remove-members");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,7 +160,7 @@ public class IslandResetCommandTest {
|
|||||||
// Block based on no resets left
|
// Block based on no resets left
|
||||||
when(pm.getResetsLeft(Mockito.eq(uuid))).thenReturn(0);
|
when(pm.getResetsLeft(Mockito.eq(uuid))).thenReturn(0);
|
||||||
|
|
||||||
assertFalse(irc.execute(user, new ArrayList<>()));
|
assertFalse(irc.execute(user, irc.getLabel(), new ArrayList<>()));
|
||||||
Mockito.verify(user).sendMessage("commands.island.reset.none-left");
|
Mockito.verify(user).sendMessage("commands.island.reset.none-left");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,7 +192,7 @@ public class IslandResetCommandTest {
|
|||||||
when(NewIsland.builder()).thenReturn(builder);
|
when(NewIsland.builder()).thenReturn(builder);
|
||||||
|
|
||||||
// Reset command, no confirmation required
|
// Reset command, no confirmation required
|
||||||
assertTrue(irc.execute(user, new ArrayList<>()));
|
assertTrue(irc.execute(user, irc.getLabel(), new ArrayList<>()));
|
||||||
// Verify that build new island was called and the number of resets left shown
|
// Verify that build new island was called and the number of resets left shown
|
||||||
Mockito.verify(builder).build();
|
Mockito.verify(builder).build();
|
||||||
Mockito.verify(user).sendMessage("commands.island.reset.resets-left", "[number]", "1");
|
Mockito.verify(user).sendMessage("commands.island.reset.resets-left", "[number]", "1");
|
||||||
@ -228,7 +228,7 @@ public class IslandResetCommandTest {
|
|||||||
when(s.getResetLimit()).thenReturn(-1);
|
when(s.getResetLimit()).thenReturn(-1);
|
||||||
|
|
||||||
// Reset
|
// Reset
|
||||||
assertTrue(irc.execute(user, new ArrayList<>()));
|
assertTrue(irc.execute(user, irc.getLabel(), new ArrayList<>()));
|
||||||
// Verify that build new island was called and the number of resets left shown
|
// Verify that build new island was called and the number of resets left shown
|
||||||
Mockito.verify(builder).build();
|
Mockito.verify(builder).build();
|
||||||
// This should not be shown
|
// This should not be shown
|
||||||
@ -267,12 +267,12 @@ public class IslandResetCommandTest {
|
|||||||
when(s.getConfirmationTime()).thenReturn(20);
|
when(s.getConfirmationTime()).thenReturn(20);
|
||||||
|
|
||||||
// Reset
|
// Reset
|
||||||
assertTrue(irc.execute(user, new ArrayList<>()));
|
assertTrue(irc.execute(user, irc.getLabel(), new ArrayList<>()));
|
||||||
// Check for message
|
// Check for message
|
||||||
Mockito.verify(user).sendMessage("general.confirm", "[seconds]", String.valueOf(s.getConfirmationTime()));
|
Mockito.verify(user).sendMessage("general.confirm", "[seconds]", String.valueOf(s.getConfirmationTime()));
|
||||||
|
|
||||||
// Send command again to confirm
|
// Send command again to confirm
|
||||||
assertTrue(irc.execute(user, new ArrayList<>()));
|
assertTrue(irc.execute(user, irc.getLabel(), new ArrayList<>()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -307,7 +307,7 @@ public class IslandResetCommandTest {
|
|||||||
when(s.isResetConfirmation()).thenReturn(false);
|
when(s.isResetConfirmation()).thenReturn(false);
|
||||||
|
|
||||||
// Reset
|
// Reset
|
||||||
assertFalse(irc.execute(user, new ArrayList<>()));
|
assertFalse(irc.execute(user, irc.getLabel(), new ArrayList<>()));
|
||||||
Mockito.verify(user).sendMessage("commands.island.create.unable-create-island");
|
Mockito.verify(user).sendMessage("commands.island.create.unable-create-island");
|
||||||
|
|
||||||
|
|
||||||
|
@ -135,13 +135,13 @@ public class IslandUnbanCommandTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testNoArgs() {
|
public void testNoArgs() {
|
||||||
IslandUnbanCommand iubc = new IslandUnbanCommand(ic);
|
IslandUnbanCommand iubc = new IslandUnbanCommand(ic);
|
||||||
assertFalse(iubc.execute(user, new ArrayList<>()));
|
assertFalse(iubc.execute(user, iubc.getLabel(), new ArrayList<>()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNoIsland() {
|
public void testNoIsland() {
|
||||||
IslandUnbanCommand iubc = new IslandUnbanCommand(ic);
|
IslandUnbanCommand iubc = new IslandUnbanCommand(ic);
|
||||||
assertFalse(iubc.execute(user, Arrays.asList("bill")));
|
assertFalse(iubc.execute(user, iubc.getLabel(), Arrays.asList("bill")));
|
||||||
Mockito.verify(user).sendMessage("general.errors.no-island");
|
Mockito.verify(user).sendMessage("general.errors.no-island");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,7 +149,7 @@ public class IslandUnbanCommandTest {
|
|||||||
public void testNotOwner() {
|
public void testNotOwner() {
|
||||||
IslandUnbanCommand iubc = new IslandUnbanCommand(ic);
|
IslandUnbanCommand iubc = new IslandUnbanCommand(ic);
|
||||||
when(im.hasIsland(Mockito.any(), Mockito.eq(uuid))).thenReturn(true);
|
when(im.hasIsland(Mockito.any(), Mockito.eq(uuid))).thenReturn(true);
|
||||||
assertFalse(iubc.execute(user, Arrays.asList("bill")));
|
assertFalse(iubc.execute(user, iubc.getLabel(), Arrays.asList("bill")));
|
||||||
Mockito.verify(user).sendMessage("general.errors.not-leader");
|
Mockito.verify(user).sendMessage("general.errors.not-leader");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,7 +159,7 @@ public class IslandUnbanCommandTest {
|
|||||||
when(im.hasIsland(Mockito.any(), Mockito.eq(uuid))).thenReturn(true);
|
when(im.hasIsland(Mockito.any(), Mockito.eq(uuid))).thenReturn(true);
|
||||||
when(im.isOwner(Mockito.any(), Mockito.eq(uuid))).thenReturn(true);
|
when(im.isOwner(Mockito.any(), Mockito.eq(uuid))).thenReturn(true);
|
||||||
when(pm.getUUID(Mockito.anyString())).thenReturn(null);
|
when(pm.getUUID(Mockito.anyString())).thenReturn(null);
|
||||||
assertFalse(iubc.execute(user, Arrays.asList("bill")));
|
assertFalse(iubc.execute(user, iubc.getLabel(), Arrays.asList("bill")));
|
||||||
Mockito.verify(user).sendMessage("general.errors.unknown-player");
|
Mockito.verify(user).sendMessage("general.errors.unknown-player");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,7 +169,7 @@ public class IslandUnbanCommandTest {
|
|||||||
when(im.hasIsland(Mockito.any(), Mockito.eq(uuid))).thenReturn(true);
|
when(im.hasIsland(Mockito.any(), Mockito.eq(uuid))).thenReturn(true);
|
||||||
when(im.isOwner(Mockito.any(), Mockito.eq(uuid))).thenReturn(true);
|
when(im.isOwner(Mockito.any(), Mockito.eq(uuid))).thenReturn(true);
|
||||||
when(pm.getUUID(Mockito.anyString())).thenReturn(uuid);
|
when(pm.getUUID(Mockito.anyString())).thenReturn(uuid);
|
||||||
assertFalse(iubc.execute(user, Arrays.asList("bill")));
|
assertFalse(iubc.execute(user, iubc.getLabel(), Arrays.asList("bill")));
|
||||||
Mockito.verify(user).sendMessage("commands.island.unban.cannot-unban-yourself");
|
Mockito.verify(user).sendMessage("commands.island.unban.cannot-unban-yourself");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,7 +181,7 @@ public class IslandUnbanCommandTest {
|
|||||||
UUID bannedUser = UUID.randomUUID();
|
UUID bannedUser = UUID.randomUUID();
|
||||||
when(pm.getUUID(Mockito.anyString())).thenReturn(bannedUser);
|
when(pm.getUUID(Mockito.anyString())).thenReturn(bannedUser);
|
||||||
when(island.isBanned(Mockito.eq(bannedUser))).thenReturn(false);
|
when(island.isBanned(Mockito.eq(bannedUser))).thenReturn(false);
|
||||||
assertFalse(iubc.execute(user, Arrays.asList("bill")));
|
assertFalse(iubc.execute(user, iubc.getLabel(), Arrays.asList("bill")));
|
||||||
Mockito.verify(user).sendMessage("commands.island.unban.player-not-banned");
|
Mockito.verify(user).sendMessage("commands.island.unban.player-not-banned");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,7 +204,7 @@ public class IslandUnbanCommandTest {
|
|||||||
// Allow removing from ban list
|
// Allow removing from ban list
|
||||||
when(island.removeFromBanList(Mockito.any())).thenReturn(true);
|
when(island.removeFromBanList(Mockito.any())).thenReturn(true);
|
||||||
|
|
||||||
assertTrue(iubc.execute(user, Arrays.asList("bill")));
|
assertTrue(iubc.execute(user, iubc.getLabel(), Arrays.asList("bill")));
|
||||||
Mockito.verify(user).sendMessage("general.success");
|
Mockito.verify(user).sendMessage("general.success");
|
||||||
Mockito.verify(targetUser).sendMessage("commands.island.unban.you-are-unbanned", TextVariables.NAME, user.getName());
|
Mockito.verify(targetUser).sendMessage("commands.island.unban.you-are-unbanned", TextVariables.NAME, user.getName());
|
||||||
}
|
}
|
||||||
@ -228,7 +228,7 @@ public class IslandUnbanCommandTest {
|
|||||||
// Allow removing from ban list
|
// Allow removing from ban list
|
||||||
when(island.removeFromBanList(Mockito.any())).thenReturn(false);
|
when(island.removeFromBanList(Mockito.any())).thenReturn(false);
|
||||||
|
|
||||||
assertFalse(iubc.execute(user, Arrays.asList("bill")));
|
assertFalse(iubc.execute(user, iubc.getLabel(), Arrays.asList("bill")));
|
||||||
Mockito.verify(user, Mockito.never()).sendMessage("general.success");
|
Mockito.verify(user, Mockito.never()).sendMessage("general.success");
|
||||||
Mockito.verify(targetUser, Mockito.never()).sendMessage("commands.island.unban.you-are-unbanned", "[owner]", user.getName());
|
Mockito.verify(targetUser, Mockito.never()).sendMessage("commands.island.unban.you-are-unbanned", "[owner]", user.getName());
|
||||||
}
|
}
|
||||||
|
@ -125,7 +125,7 @@ public class IslandTeamInviteCommandTest {
|
|||||||
public void testExecuteNoIsland() {
|
public void testExecuteNoIsland() {
|
||||||
when(im.hasIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(false);
|
when(im.hasIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(false);
|
||||||
IslandTeamInviteCommand itl = new IslandTeamInviteCommand(ic);
|
IslandTeamInviteCommand itl = new IslandTeamInviteCommand(ic);
|
||||||
assertFalse(itl.execute(user, new ArrayList<>()));
|
assertFalse(itl.execute(user, itl.getLabel(), new ArrayList<>()));
|
||||||
Mockito.verify(user).sendMessage(Mockito.eq("general.errors.no-island"));
|
Mockito.verify(user).sendMessage(Mockito.eq("general.errors.no-island"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,7 +136,7 @@ public class IslandTeamInviteCommandTest {
|
|||||||
public void testExecuteNotTeamLeader() {
|
public void testExecuteNotTeamLeader() {
|
||||||
when(im.getTeamLeader(Mockito.any(), Mockito.any())).thenReturn(notUUID);
|
when(im.getTeamLeader(Mockito.any(), Mockito.any())).thenReturn(notUUID);
|
||||||
IslandTeamInviteCommand itl = new IslandTeamInviteCommand(ic);
|
IslandTeamInviteCommand itl = new IslandTeamInviteCommand(ic);
|
||||||
assertFalse(itl.execute(user, new ArrayList<>()));
|
assertFalse(itl.execute(user, itl.getLabel(), new ArrayList<>()));
|
||||||
Mockito.verify(user).sendMessage(Mockito.eq("general.errors.not-leader"));
|
Mockito.verify(user).sendMessage(Mockito.eq("general.errors.not-leader"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,7 +146,7 @@ public class IslandTeamInviteCommandTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testExecuteNoTarget() {
|
public void testExecuteNoTarget() {
|
||||||
IslandTeamInviteCommand itl = new IslandTeamInviteCommand(ic);
|
IslandTeamInviteCommand itl = new IslandTeamInviteCommand(ic);
|
||||||
assertFalse(itl.execute(user, new ArrayList<>()));
|
assertFalse(itl.execute(user, itl.getLabel(), new ArrayList<>()));
|
||||||
// Show help
|
// Show help
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,7 +158,7 @@ public class IslandTeamInviteCommandTest {
|
|||||||
IslandTeamInviteCommand itl = new IslandTeamInviteCommand(ic);
|
IslandTeamInviteCommand itl = new IslandTeamInviteCommand(ic);
|
||||||
String[] name = {"tastybento"};
|
String[] name = {"tastybento"};
|
||||||
when(pm.getUUID(Mockito.any())).thenReturn(null);
|
when(pm.getUUID(Mockito.any())).thenReturn(null);
|
||||||
assertFalse(itl.execute(user, Arrays.asList(name)));
|
assertFalse(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
|
||||||
Mockito.verify(user).sendMessage(Mockito.eq("general.errors.unknown-player"));
|
Mockito.verify(user).sendMessage(Mockito.eq("general.errors.unknown-player"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,7 +174,7 @@ public class IslandTeamInviteCommandTest {
|
|||||||
IslandTeamInviteCommand itl = new IslandTeamInviteCommand(ic);
|
IslandTeamInviteCommand itl = new IslandTeamInviteCommand(ic);
|
||||||
String[] name = {"tastybento"};
|
String[] name = {"tastybento"};
|
||||||
when(pm.getUUID(Mockito.any())).thenReturn(uuid);
|
when(pm.getUUID(Mockito.any())).thenReturn(uuid);
|
||||||
assertFalse(itl.execute(user, Arrays.asList(name)));
|
assertFalse(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
|
||||||
Mockito.verify(user).sendMessage(Mockito.eq("general.errors.offline-player"));
|
Mockito.verify(user).sendMessage(Mockito.eq("general.errors.offline-player"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,7 +189,7 @@ public class IslandTeamInviteCommandTest {
|
|||||||
IslandTeamInviteCommand itl = new IslandTeamInviteCommand(ic);
|
IslandTeamInviteCommand itl = new IslandTeamInviteCommand(ic);
|
||||||
String[] name = {"tastybento"};
|
String[] name = {"tastybento"};
|
||||||
when(pm.getUUID(Mockito.any())).thenReturn(uuid);
|
when(pm.getUUID(Mockito.any())).thenReturn(uuid);
|
||||||
assertFalse(itl.execute(user, Arrays.asList(name)));
|
assertFalse(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
|
||||||
Mockito.verify(user).sendMessage(Mockito.eq("commands.island.team.invite.cannot-invite-self"));
|
Mockito.verify(user).sendMessage(Mockito.eq("commands.island.team.invite.cannot-invite-self"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,7 +206,7 @@ public class IslandTeamInviteCommandTest {
|
|||||||
String[] name = {"tastybento"};
|
String[] name = {"tastybento"};
|
||||||
when(pm.getUUID(Mockito.any())).thenReturn(notUUID);
|
when(pm.getUUID(Mockito.any())).thenReturn(notUUID);
|
||||||
when(im.inTeam(Mockito.any(), Mockito.any())).thenReturn(true);
|
when(im.inTeam(Mockito.any(), Mockito.any())).thenReturn(true);
|
||||||
assertFalse(itl.execute(user, Arrays.asList(name)));
|
assertFalse(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
|
||||||
Mockito.verify(user).sendMessage(Mockito.eq("commands.island.team.invite.already-on-team"));
|
Mockito.verify(user).sendMessage(Mockito.eq("commands.island.team.invite.already-on-team"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ public class IslandTeamKickCommandTest {
|
|||||||
public void testExecuteNoTeam() {
|
public void testExecuteNoTeam() {
|
||||||
when(im.inTeam(Mockito.any(), Mockito.eq(uuid))).thenReturn(false);
|
when(im.inTeam(Mockito.any(), Mockito.eq(uuid))).thenReturn(false);
|
||||||
IslandTeamKickCommand itl = new IslandTeamKickCommand(ic);
|
IslandTeamKickCommand itl = new IslandTeamKickCommand(ic);
|
||||||
assertFalse(itl.execute(user, new ArrayList<>()));
|
assertFalse(itl.execute(user, itl.getLabel(), new ArrayList<>()));
|
||||||
Mockito.verify(user).sendMessage(Mockito.eq("general.errors.no-team"));
|
Mockito.verify(user).sendMessage(Mockito.eq("general.errors.no-team"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,7 +142,7 @@ public class IslandTeamKickCommandTest {
|
|||||||
public void testExecuteNotTeamLeader() {
|
public void testExecuteNotTeamLeader() {
|
||||||
when(im.getTeamLeader(Mockito.any(), Mockito.any())).thenReturn(notUUID);
|
when(im.getTeamLeader(Mockito.any(), Mockito.any())).thenReturn(notUUID);
|
||||||
IslandTeamKickCommand itl = new IslandTeamKickCommand(ic);
|
IslandTeamKickCommand itl = new IslandTeamKickCommand(ic);
|
||||||
assertFalse(itl.execute(user, new ArrayList<>()));
|
assertFalse(itl.execute(user, itl.getLabel(), new ArrayList<>()));
|
||||||
Mockito.verify(user).sendMessage(Mockito.eq("general.errors.not-leader"));
|
Mockito.verify(user).sendMessage(Mockito.eq("general.errors.not-leader"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,7 +152,7 @@ public class IslandTeamKickCommandTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testExecuteNoTarget() {
|
public void testExecuteNoTarget() {
|
||||||
IslandTeamKickCommand itl = new IslandTeamKickCommand(ic);
|
IslandTeamKickCommand itl = new IslandTeamKickCommand(ic);
|
||||||
assertFalse(itl.execute(user, new ArrayList<>()));
|
assertFalse(itl.execute(user, itl.getLabel(), new ArrayList<>()));
|
||||||
// Show help
|
// Show help
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,7 +164,7 @@ public class IslandTeamKickCommandTest {
|
|||||||
IslandTeamKickCommand itl = new IslandTeamKickCommand(ic);
|
IslandTeamKickCommand itl = new IslandTeamKickCommand(ic);
|
||||||
String[] name = {"tastybento"};
|
String[] name = {"tastybento"};
|
||||||
when(pm.getUUID(Mockito.any())).thenReturn(null);
|
when(pm.getUUID(Mockito.any())).thenReturn(null);
|
||||||
assertFalse(itl.execute(user, Arrays.asList(name)));
|
assertFalse(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
|
||||||
Mockito.verify(user).sendMessage(Mockito.eq("general.errors.unknown-player"));
|
Mockito.verify(user).sendMessage(Mockito.eq("general.errors.unknown-player"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,7 +176,7 @@ public class IslandTeamKickCommandTest {
|
|||||||
IslandTeamKickCommand itl = new IslandTeamKickCommand(ic);
|
IslandTeamKickCommand itl = new IslandTeamKickCommand(ic);
|
||||||
String[] name = {"tastybento"};
|
String[] name = {"tastybento"};
|
||||||
when(pm.getUUID(Mockito.any())).thenReturn(uuid);
|
when(pm.getUUID(Mockito.any())).thenReturn(uuid);
|
||||||
assertFalse(itl.execute(user, Arrays.asList(name)));
|
assertFalse(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
|
||||||
Mockito.verify(user).sendMessage(Mockito.eq("commands.island.kick.cannot-kick"));
|
Mockito.verify(user).sendMessage(Mockito.eq("commands.island.kick.cannot-kick"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,7 +190,7 @@ public class IslandTeamKickCommandTest {
|
|||||||
String[] name = {"tastybento"};
|
String[] name = {"tastybento"};
|
||||||
when(pm.getUUID(Mockito.any())).thenReturn(notUUID);
|
when(pm.getUUID(Mockito.any())).thenReturn(notUUID);
|
||||||
when(im.getMembers(Mockito.any(), Mockito.any())).thenReturn(new HashSet<>());
|
when(im.getMembers(Mockito.any(), Mockito.any())).thenReturn(new HashSet<>());
|
||||||
assertFalse(itl.execute(user, Arrays.asList(name)));
|
assertFalse(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
|
||||||
Mockito.verify(user).sendMessage(Mockito.eq("general.errors.not-in-team"));
|
Mockito.verify(user).sendMessage(Mockito.eq("general.errors.not-in-team"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,7 +209,7 @@ public class IslandTeamKickCommandTest {
|
|||||||
when(im.getMembers(Mockito.any(), Mockito.any())).thenReturn(members);
|
when(im.getMembers(Mockito.any(), Mockito.any())).thenReturn(members);
|
||||||
|
|
||||||
IslandTeamKickCommand itl = new IslandTeamKickCommand(ic);
|
IslandTeamKickCommand itl = new IslandTeamKickCommand(ic);
|
||||||
assertTrue(itl.execute(user, Arrays.asList(name)));
|
assertTrue(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
|
||||||
Mockito.verify(im).removePlayer(Mockito.any(), Mockito.eq(notUUID));
|
Mockito.verify(im).removePlayer(Mockito.any(), Mockito.eq(notUUID));
|
||||||
Mockito.verify(user).sendMessage(Mockito.eq("general.success"));
|
Mockito.verify(user).sendMessage(Mockito.eq("general.success"));
|
||||||
}
|
}
|
||||||
@ -229,7 +229,7 @@ public class IslandTeamKickCommandTest {
|
|||||||
when(im.getMembers(Mockito.any(), Mockito.any())).thenReturn(members);
|
when(im.getMembers(Mockito.any(), Mockito.any())).thenReturn(members);
|
||||||
|
|
||||||
IslandTeamKickCommand itl = new IslandTeamKickCommand(ic);
|
IslandTeamKickCommand itl = new IslandTeamKickCommand(ic);
|
||||||
assertFalse(itl.execute(user, Arrays.asList(name)));
|
assertFalse(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
|
||||||
// Confirmation required
|
// Confirmation required
|
||||||
Mockito.verify(user).sendMessage(Mockito.eq("commands.island.team.kick.type-again"));
|
Mockito.verify(user).sendMessage(Mockito.eq("commands.island.team.kick.type-again"));
|
||||||
}
|
}
|
||||||
@ -258,7 +258,7 @@ public class IslandTeamKickCommandTest {
|
|||||||
when(iwm.isOnLeaveResetMoney(Mockito.any())).thenReturn(true);
|
when(iwm.isOnLeaveResetMoney(Mockito.any())).thenReturn(true);
|
||||||
|
|
||||||
IslandTeamKickCommand itl = new IslandTeamKickCommand(ic);
|
IslandTeamKickCommand itl = new IslandTeamKickCommand(ic);
|
||||||
assertTrue(itl.execute(user, Arrays.asList(name)));
|
assertTrue(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
|
||||||
Mockito.verify(im).removePlayer(Mockito.any(), Mockito.eq(notUUID));
|
Mockito.verify(im).removePlayer(Mockito.any(), Mockito.eq(notUUID));
|
||||||
Mockito.verify(user).sendMessage(Mockito.eq("general.success"));
|
Mockito.verify(user).sendMessage(Mockito.eq("general.success"));
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ public class IslandTeamLeaveCommandTest {
|
|||||||
public void testExecuteNoTeam() {
|
public void testExecuteNoTeam() {
|
||||||
when(im.inTeam(Mockito.any(), Mockito.eq(uuid))).thenReturn(false);
|
when(im.inTeam(Mockito.any(), Mockito.eq(uuid))).thenReturn(false);
|
||||||
IslandTeamLeaveCommand itl = new IslandTeamLeaveCommand(ic);
|
IslandTeamLeaveCommand itl = new IslandTeamLeaveCommand(ic);
|
||||||
assertFalse(itl.execute(user, new ArrayList<>()));
|
assertFalse(itl.execute(user, itl.getLabel(), new ArrayList<>()));
|
||||||
Mockito.verify(user).sendMessage(Mockito.eq("general.errors.no-team"));
|
Mockito.verify(user).sendMessage(Mockito.eq("general.errors.no-team"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,7 +122,7 @@ public class IslandTeamLeaveCommandTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testExecuteInTeamLeader() {
|
public void testExecuteInTeamLeader() {
|
||||||
IslandTeamLeaveCommand itl = new IslandTeamLeaveCommand(ic);
|
IslandTeamLeaveCommand itl = new IslandTeamLeaveCommand(ic);
|
||||||
assertFalse(itl.execute(user, new ArrayList<>()));
|
assertFalse(itl.execute(user, itl.getLabel(), new ArrayList<>()));
|
||||||
Mockito.verify(user).sendMessage(Mockito.eq("commands.island.team.leave.cannot-leave"));
|
Mockito.verify(user).sendMessage(Mockito.eq("commands.island.team.leave.cannot-leave"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,7 +138,7 @@ public class IslandTeamLeaveCommandTest {
|
|||||||
when(im.getTeamLeader(Mockito.any(), Mockito.any())).thenReturn(null);
|
when(im.getTeamLeader(Mockito.any(), Mockito.any())).thenReturn(null);
|
||||||
|
|
||||||
IslandTeamLeaveCommand itl = new IslandTeamLeaveCommand(ic);
|
IslandTeamLeaveCommand itl = new IslandTeamLeaveCommand(ic);
|
||||||
assertTrue(itl.execute(user, new ArrayList<>()));
|
assertTrue(itl.execute(user, itl.getLabel(), new ArrayList<>()));
|
||||||
Mockito.verify(im).setLeaveTeam(Mockito.any(), Mockito.eq(uuid));
|
Mockito.verify(im).setLeaveTeam(Mockito.any(), Mockito.eq(uuid));
|
||||||
Mockito.verify(user).sendMessage(Mockito.eq("general.success"));
|
Mockito.verify(user).sendMessage(Mockito.eq("general.success"));
|
||||||
}
|
}
|
||||||
@ -157,7 +157,7 @@ public class IslandTeamLeaveCommandTest {
|
|||||||
when(im.getTeamLeader(Mockito.any(), Mockito.any())).thenReturn(null);
|
when(im.getTeamLeader(Mockito.any(), Mockito.any())).thenReturn(null);
|
||||||
|
|
||||||
IslandTeamLeaveCommand itl = new IslandTeamLeaveCommand(ic);
|
IslandTeamLeaveCommand itl = new IslandTeamLeaveCommand(ic);
|
||||||
assertFalse(itl.execute(user, new ArrayList<>()));
|
assertFalse(itl.execute(user, itl.getLabel(), new ArrayList<>()));
|
||||||
// Confirmation required
|
// Confirmation required
|
||||||
Mockito.verify(user).sendMessage(Mockito.eq("general.confirm"), Mockito.eq("[seconds]"), Mockito.eq("0"));
|
Mockito.verify(user).sendMessage(Mockito.eq("general.confirm"), Mockito.eq("[seconds]"), Mockito.eq("0"));
|
||||||
}
|
}
|
||||||
@ -183,7 +183,7 @@ public class IslandTeamLeaveCommandTest {
|
|||||||
when(iwm.isOnLeaveResetMoney(Mockito.any())).thenReturn(true);
|
when(iwm.isOnLeaveResetMoney(Mockito.any())).thenReturn(true);
|
||||||
|
|
||||||
IslandTeamLeaveCommand itl = new IslandTeamLeaveCommand(ic);
|
IslandTeamLeaveCommand itl = new IslandTeamLeaveCommand(ic);
|
||||||
assertTrue(itl.execute(user, new ArrayList<>()));
|
assertTrue(itl.execute(user, itl.getLabel(), new ArrayList<>()));
|
||||||
Mockito.verify(im).setLeaveTeam(Mockito.any(), Mockito.eq(uuid));
|
Mockito.verify(im).setLeaveTeam(Mockito.any(), Mockito.eq(uuid));
|
||||||
Mockito.verify(user).sendMessage(Mockito.eq("general.success"));
|
Mockito.verify(user).sendMessage(Mockito.eq("general.success"));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user