#306 Adjust ExecutableCommand implementations to interface
This commit is contained in:
parent
8ef1b2ae3e
commit
14f6ecd716
@ -1,6 +1,7 @@
|
||||
package fr.xephi.authme.command.executable.authme;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.command.CommandService;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -10,10 +11,10 @@ import java.util.List;
|
||||
/**
|
||||
* AuthMe base command; shows the version and some command pointers.
|
||||
*/
|
||||
public class AuthMeCommand extends ExecutableCommand {
|
||||
public class AuthMeCommand implements ExecutableCommand {
|
||||
|
||||
@Override
|
||||
public void executeCommand(CommandSender sender, List<String> arguments) {
|
||||
public void executeCommand(CommandSender sender, List<String> arguments, CommandService commandService) {
|
||||
sender.sendMessage(ChatColor.GREEN + "This server is running " + AuthMe.getPluginName() + " v"
|
||||
+ AuthMe.getPluginVersion() + " b" + AuthMe.getPluginBuildNumber()+ "! " + ChatColor.RED + "<3");
|
||||
sender.sendMessage(ChatColor.YELLOW + "Use the command " + ChatColor.GOLD + "/authme help" + ChatColor.YELLOW
|
||||
|
||||
@ -4,6 +4,7 @@ import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.command.CommandService;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.output.MessageKey;
|
||||
import fr.xephi.authme.output.Messages;
|
||||
@ -18,10 +19,10 @@ import java.util.List;
|
||||
/**
|
||||
* Admin command for changing a player's password.
|
||||
*/
|
||||
public class ChangePasswordAdminCommand extends ExecutableCommand {
|
||||
public class ChangePasswordAdminCommand implements ExecutableCommand {
|
||||
|
||||
@Override
|
||||
public void executeCommand(final CommandSender sender, List<String> arguments) {
|
||||
public void executeCommand(final CommandSender sender, List<String> arguments, CommandService commandService) {
|
||||
final AuthMe plugin = AuthMe.getInstance();
|
||||
final Messages m = plugin.getMessages();
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package fr.xephi.authme.command.executable.authme;
|
||||
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.command.CommandService;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.settings.Spawn;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -8,10 +9,10 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class FirstSpawnCommand extends ExecutableCommand {
|
||||
public class FirstSpawnCommand implements ExecutableCommand {
|
||||
|
||||
@Override
|
||||
public void executeCommand(CommandSender sender, List<String> arguments) {
|
||||
public void executeCommand(CommandSender sender, List<String> arguments, CommandService commandService) {
|
||||
// Make sure the command executor is a player
|
||||
try {
|
||||
if (sender instanceof Player) {
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package fr.xephi.authme.command.executable.authme;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.command.CommandService;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.permission.PlayerPermission;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -11,10 +12,10 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class ForceLoginCommand extends ExecutableCommand {
|
||||
public class ForceLoginCommand implements ExecutableCommand {
|
||||
|
||||
@Override
|
||||
public void executeCommand(CommandSender sender, List<String> arguments) {
|
||||
public void executeCommand(CommandSender sender, List<String> arguments, CommandService commandService) {
|
||||
// AuthMe plugin instance
|
||||
final AuthMe plugin = AuthMe.getInstance();
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@ package fr.xephi.authme.command.executable.authme;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.command.CommandService;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.output.MessageKey;
|
||||
import fr.xephi.authme.output.Messages;
|
||||
@ -9,10 +10,10 @@ import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class GetEmailCommand extends ExecutableCommand {
|
||||
public class GetEmailCommand implements ExecutableCommand {
|
||||
|
||||
@Override
|
||||
public void executeCommand(CommandSender sender, List<String> arguments) {
|
||||
public void executeCommand(CommandSender sender, List<String> arguments, CommandService commandService) {
|
||||
String playerName = arguments.isEmpty() ? sender.getName() : arguments.get(0);
|
||||
|
||||
// Get the authenticated user
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package fr.xephi.authme.command.executable.authme;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.command.CommandService;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -8,10 +9,10 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class GetIpCommand extends ExecutableCommand {
|
||||
public class GetIpCommand implements ExecutableCommand {
|
||||
|
||||
@Override
|
||||
public void executeCommand(CommandSender sender, List<String> arguments) {
|
||||
public void executeCommand(CommandSender sender, List<String> arguments, CommandService commandService) {
|
||||
final AuthMe plugin = AuthMe.getInstance();
|
||||
|
||||
// Get the player query
|
||||
|
||||
@ -2,6 +2,7 @@ package fr.xephi.authme.command.executable.authme;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.command.CommandService;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.output.MessageKey;
|
||||
import fr.xephi.authme.output.Messages;
|
||||
@ -12,10 +13,10 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class LastLoginCommand extends ExecutableCommand {
|
||||
public class LastLoginCommand implements ExecutableCommand {
|
||||
|
||||
@Override
|
||||
public void executeCommand(CommandSender sender, List<String> arguments) {
|
||||
public void executeCommand(CommandSender sender, List<String> arguments, CommandService commandService) {
|
||||
// Get the player
|
||||
String playerName = (arguments.size() >= 1) ? arguments.get(0) : sender.getName();
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package fr.xephi.authme.command.executable.authme;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.command.CommandService;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
@ -9,10 +10,10 @@ import org.bukkit.command.CommandSender;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PurgeBannedPlayersCommand extends ExecutableCommand {
|
||||
public class PurgeBannedPlayersCommand implements ExecutableCommand {
|
||||
|
||||
@Override
|
||||
public void executeCommand(CommandSender sender, List<String> arguments) {
|
||||
public void executeCommand(CommandSender sender, List<String> arguments, CommandService commandService) {
|
||||
// AuthMe plugin instance
|
||||
final AuthMe plugin = AuthMe.getInstance();
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package fr.xephi.authme.command.executable.authme;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.command.CommandService;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -9,10 +10,10 @@ import org.bukkit.command.CommandSender;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
public class PurgeCommand extends ExecutableCommand {
|
||||
public class PurgeCommand implements ExecutableCommand {
|
||||
|
||||
@Override
|
||||
public void executeCommand(CommandSender sender, List<String> arguments) {
|
||||
public void executeCommand(CommandSender sender, List<String> arguments, CommandService commandService) {
|
||||
// AuthMe plugin instance
|
||||
AuthMe plugin = AuthMe.getInstance();
|
||||
|
||||
|
||||
@ -3,6 +3,7 @@ package fr.xephi.authme.command.executable.authme;
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.command.CommandService;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.output.MessageKey;
|
||||
import fr.xephi.authme.output.Messages;
|
||||
@ -11,10 +12,10 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PurgeLastPositionCommand extends ExecutableCommand {
|
||||
public class PurgeLastPositionCommand implements ExecutableCommand {
|
||||
|
||||
@Override
|
||||
public void executeCommand(final CommandSender sender, List<String> arguments) {
|
||||
public void executeCommand(final CommandSender sender, List<String> arguments, CommandService commandService) {
|
||||
final AuthMe plugin = AuthMe.getInstance();
|
||||
final Messages m = plugin.getMessages();
|
||||
|
||||
|
||||
@ -3,6 +3,7 @@ package fr.xephi.authme.command.executable.authme;
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.command.CommandService;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.output.MessageKey;
|
||||
import fr.xephi.authme.output.Messages;
|
||||
@ -17,10 +18,10 @@ import java.util.List;
|
||||
/**
|
||||
* Admin command to register a user.
|
||||
*/
|
||||
public class RegisterAdminCommand extends ExecutableCommand {
|
||||
public class RegisterAdminCommand implements ExecutableCommand {
|
||||
|
||||
@Override
|
||||
public void executeCommand(final CommandSender sender, List<String> arguments) {
|
||||
public void executeCommand(final CommandSender sender, List<String> arguments, CommandService commandService) {
|
||||
// AuthMe plugin instance
|
||||
final AuthMe plugin = AuthMe.getInstance();
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@ package fr.xephi.authme.command.executable.authme;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.command.CommandService;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.output.MessageKey;
|
||||
import fr.xephi.authme.output.Messages;
|
||||
@ -11,10 +12,10 @@ import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ReloadCommand extends ExecutableCommand {
|
||||
public class ReloadCommand implements ExecutableCommand {
|
||||
|
||||
@Override
|
||||
public void executeCommand(CommandSender sender, List<String> arguments) {
|
||||
public void executeCommand(CommandSender sender, List<String> arguments, CommandService commandService) {
|
||||
// Profile the reload process
|
||||
Profiler p = new Profiler(true);
|
||||
|
||||
|
||||
@ -3,6 +3,7 @@ package fr.xephi.authme.command.executable.authme;
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.command.CommandService;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.output.MessageKey;
|
||||
import fr.xephi.authme.output.Messages;
|
||||
@ -11,10 +12,10 @@ import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SetEmailCommand extends ExecutableCommand {
|
||||
public class SetEmailCommand implements ExecutableCommand {
|
||||
|
||||
@Override
|
||||
public void executeCommand(final CommandSender sender, List<String> arguments) {
|
||||
public void executeCommand(final CommandSender sender, List<String> arguments, CommandService commandService) {
|
||||
// AuthMe plugin instance
|
||||
final AuthMe plugin = AuthMe.getInstance();
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package fr.xephi.authme.command.executable.authme;
|
||||
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.command.CommandService;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.settings.Spawn;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -8,10 +9,10 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SetFirstSpawnCommand extends ExecutableCommand {
|
||||
public class SetFirstSpawnCommand implements ExecutableCommand {
|
||||
|
||||
@Override
|
||||
public void executeCommand(CommandSender sender, List<String> arguments) {
|
||||
public void executeCommand(CommandSender sender, List<String> arguments, CommandService commandService) {
|
||||
try {
|
||||
if (sender instanceof Player) {
|
||||
if (Spawn.getInstance().setFirstSpawn(((Player) sender).getLocation()))
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package fr.xephi.authme.command.executable.authme;
|
||||
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.command.CommandService;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.settings.Spawn;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -8,10 +9,10 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SetSpawnCommand extends ExecutableCommand {
|
||||
public class SetSpawnCommand implements ExecutableCommand {
|
||||
|
||||
@Override
|
||||
public void executeCommand(CommandSender sender, List<String> arguments) {
|
||||
public void executeCommand(CommandSender sender, List<String> arguments, CommandService commandService) {
|
||||
// Make sure the command executor is a player
|
||||
try {
|
||||
if (sender instanceof Player) {
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package fr.xephi.authme.command.executable.authme;
|
||||
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.command.CommandService;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.settings.Spawn;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -8,10 +9,10 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SpawnCommand extends ExecutableCommand {
|
||||
public class SpawnCommand implements ExecutableCommand {
|
||||
|
||||
@Override
|
||||
public void executeCommand(CommandSender sender, List<String> arguments) {
|
||||
public void executeCommand(CommandSender sender, List<String> arguments, CommandService commandService) {
|
||||
// Make sure the command executor is a player
|
||||
try {
|
||||
if (sender instanceof Player) {
|
||||
|
||||
@ -4,6 +4,7 @@ import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
||||
import fr.xephi.authme.command.CommandService;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.output.MessageKey;
|
||||
import fr.xephi.authme.output.Messages;
|
||||
@ -23,11 +24,11 @@ import java.util.List;
|
||||
/**
|
||||
* Admin command to unregister a player.
|
||||
*/
|
||||
public class UnregisterAdminCommand extends ExecutableCommand {
|
||||
public class UnregisterAdminCommand implements ExecutableCommand {
|
||||
|
||||
|
||||
@Override
|
||||
public void executeCommand(final CommandSender sender, List<String> arguments) {
|
||||
public void executeCommand(final CommandSender sender, List<String> arguments, CommandService commandService) {
|
||||
// AuthMe plugin instance
|
||||
final AuthMe plugin = AuthMe.getInstance();
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package fr.xephi.authme.command.executable.authme;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.command.CommandService;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -10,10 +11,10 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class VersionCommand extends ExecutableCommand {
|
||||
public class VersionCommand implements ExecutableCommand {
|
||||
|
||||
@Override
|
||||
public void executeCommand(CommandSender sender, List<String> arguments) {
|
||||
public void executeCommand(CommandSender sender, List<String> arguments, CommandService commandService) {
|
||||
// Show some version info
|
||||
sender.sendMessage(ChatColor.GOLD + "==========[ " + Settings.helpHeader.toUpperCase() + " ABOUT ]==========");
|
||||
sender.sendMessage(ChatColor.GOLD + "Version: " + ChatColor.WHITE + AuthMe.getPluginName() + " v" + AuthMe.getPluginVersion() + ChatColor.GRAY + " (build: " + AuthMe.getPluginBuildNumber() + ")");
|
||||
|
||||
@ -2,6 +2,7 @@ package fr.xephi.authme.command.executable.captcha;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.command.CommandService;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.output.MessageKey;
|
||||
import fr.xephi.authme.output.Messages;
|
||||
@ -13,10 +14,10 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CaptchaCommand extends ExecutableCommand {
|
||||
public class CaptchaCommand implements ExecutableCommand {
|
||||
|
||||
@Override
|
||||
public void executeCommand(CommandSender sender, List<String> arguments) {
|
||||
public void executeCommand(CommandSender sender, List<String> arguments, CommandService commandService) {
|
||||
// Make sure the current command executor is a player
|
||||
if (!(sender instanceof Player)) {
|
||||
return;
|
||||
|
||||
@ -2,6 +2,7 @@ package fr.xephi.authme.command.executable.changepassword;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.command.CommandService;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.output.MessageKey;
|
||||
import fr.xephi.authme.output.Messages;
|
||||
@ -16,10 +17,10 @@ import java.util.List;
|
||||
/**
|
||||
* The command for a player to change his password with.
|
||||
*/
|
||||
public class ChangePasswordCommand extends ExecutableCommand {
|
||||
public class ChangePasswordCommand implements ExecutableCommand {
|
||||
|
||||
@Override
|
||||
public void executeCommand(CommandSender sender, List<String> arguments) {
|
||||
public void executeCommand(CommandSender sender, List<String> arguments, CommandService commandService) {
|
||||
// Make sure the current command executor is a player
|
||||
if (!(sender instanceof Player)) {
|
||||
return;
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package fr.xephi.authme.command.executable.converter;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.command.CommandService;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.converter.Converter;
|
||||
import fr.xephi.authme.converter.CrazyLoginConverter;
|
||||
@ -19,10 +20,10 @@ import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ConverterCommand extends ExecutableCommand {
|
||||
public class ConverterCommand implements ExecutableCommand {
|
||||
|
||||
@Override
|
||||
public void executeCommand(CommandSender sender, List<String> arguments) {
|
||||
public void executeCommand(CommandSender sender, List<String> arguments, CommandService commandService) {
|
||||
// AuthMe plugin instance
|
||||
final AuthMe plugin = AuthMe.getInstance();
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package fr.xephi.authme.command.executable.email;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.command.CommandService;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.util.Wrapper;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -8,10 +9,10 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class AddEmailCommand extends ExecutableCommand {
|
||||
public class AddEmailCommand implements ExecutableCommand {
|
||||
|
||||
@Override
|
||||
public void executeCommand(CommandSender sender, List<String> arguments) {
|
||||
public void executeCommand(CommandSender sender, List<String> arguments, CommandService commandService) {
|
||||
// Make sure the current command executor is a player
|
||||
if (!(sender instanceof Player)) {
|
||||
return;
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package fr.xephi.authme.command.executable.email;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.command.CommandService;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.util.Wrapper;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -10,10 +11,10 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class ChangeEmailCommand extends ExecutableCommand {
|
||||
public class ChangeEmailCommand implements ExecutableCommand {
|
||||
|
||||
@Override
|
||||
public void executeCommand(CommandSender sender, List<String> arguments) {
|
||||
public void executeCommand(CommandSender sender, List<String> arguments, CommandService commandService) {
|
||||
// Make sure the current command executor is a player
|
||||
if (!(sender instanceof Player)) {
|
||||
return;
|
||||
|
||||
@ -4,6 +4,7 @@ import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.command.CommandService;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.output.MessageKey;
|
||||
import fr.xephi.authme.output.Messages;
|
||||
@ -17,10 +18,10 @@ import org.bukkit.entity.Player;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.List;
|
||||
|
||||
public class RecoverEmailCommand extends ExecutableCommand {
|
||||
public class RecoverEmailCommand implements ExecutableCommand {
|
||||
|
||||
@Override
|
||||
public void executeCommand(CommandSender sender, List<String> arguments) {
|
||||
public void executeCommand(CommandSender sender, List<String> arguments, CommandService commandService) {
|
||||
// Make sure the current command executor is a player
|
||||
if (!(sender instanceof Player)) {
|
||||
return;
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package fr.xephi.authme.command.executable.login;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.command.CommandService;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.util.Wrapper;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -8,10 +9,10 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class LoginCommand extends ExecutableCommand {
|
||||
public class LoginCommand implements ExecutableCommand {
|
||||
|
||||
@Override
|
||||
public void executeCommand(CommandSender sender, List<String> arguments) {
|
||||
public void executeCommand(CommandSender sender, List<String> arguments, CommandService commandService) {
|
||||
// Make sure the current command executor is a player
|
||||
if (!(sender instanceof Player)) {
|
||||
return;
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package fr.xephi.authme.command.executable.logout;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.command.CommandService;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.util.Wrapper;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -10,10 +11,10 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class LogoutCommand extends ExecutableCommand {
|
||||
public class LogoutCommand implements ExecutableCommand {
|
||||
|
||||
@Override
|
||||
public void executeCommand(CommandSender sender, List<String> arguments) {
|
||||
public void executeCommand(CommandSender sender, List<String> arguments, CommandService commandService) {
|
||||
// Make sure the current command executor is a player
|
||||
if (!(sender instanceof Player)) {
|
||||
return;
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package fr.xephi.authme.command.executable.register;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.command.CommandService;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.output.MessageKey;
|
||||
import fr.xephi.authme.output.Messages;
|
||||
@ -13,10 +14,10 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class RegisterCommand extends ExecutableCommand {
|
||||
public class RegisterCommand implements ExecutableCommand {
|
||||
|
||||
@Override
|
||||
public void executeCommand(CommandSender sender, List<String> arguments) {
|
||||
public void executeCommand(CommandSender sender, List<String> arguments, CommandService commandService) {
|
||||
// Make sure the sender is a player
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage("Player Only! Use 'authme register <playername> <password>' instead");
|
||||
|
||||
@ -2,6 +2,7 @@ package fr.xephi.authme.command.executable.unregister;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.command.CommandService;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.output.MessageKey;
|
||||
import fr.xephi.authme.output.Messages;
|
||||
@ -10,10 +11,10 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class UnregisterCommand extends ExecutableCommand {
|
||||
public class UnregisterCommand implements ExecutableCommand {
|
||||
|
||||
@Override
|
||||
public void executeCommand(CommandSender sender, List<String> arguments) {
|
||||
public void executeCommand(CommandSender sender, List<String> arguments, CommandService commandService) {
|
||||
// Make sure the current command executor is a player
|
||||
if (!(sender instanceof Player)) {
|
||||
return;
|
||||
|
||||
@ -41,7 +41,7 @@ public class CommandInitializerTest {
|
||||
@BeforeClass
|
||||
public static void initializeCommandManager() {
|
||||
WrapperMock.createInstance();
|
||||
commands = CommandInitializer.getBaseCommands();
|
||||
commands = CommandInitializer.buildCommands();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package fr.xephi.authme.command.executable.captcha;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.command.CommandService;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.output.MessageKey;
|
||||
import fr.xephi.authme.output.Messages;
|
||||
@ -18,6 +19,7 @@ import java.util.ArrayList;
|
||||
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@ -41,7 +43,7 @@ public class CaptchaCommandTest {
|
||||
ExecutableCommand command = new CaptchaCommand();
|
||||
|
||||
// when
|
||||
command.executeCommand(sender, new ArrayList<String>());
|
||||
command.executeCommand(sender, new ArrayList<String>(), mock(CommandService.class));
|
||||
|
||||
// then
|
||||
assertThat(wrapperMock.wasMockCalled(AuthMe.class), equalTo(false));
|
||||
@ -56,7 +58,7 @@ public class CaptchaCommandTest {
|
||||
ExecutableCommand command = new CaptchaCommand();
|
||||
|
||||
// when
|
||||
command.executeCommand(player, new ArrayList<String>());
|
||||
command.executeCommand(player, new ArrayList<String>(), mock(CommandService.class));
|
||||
|
||||
// then
|
||||
verify(wrapperMock.getMessages()).send(player, MessageKey.USAGE_LOGIN);
|
||||
|
||||
@ -3,6 +3,7 @@ package fr.xephi.authme.command.executable.changepassword;
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ReflectionTestUtils;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.command.CommandService;
|
||||
import fr.xephi.authme.output.MessageKey;
|
||||
import fr.xephi.authme.output.Messages;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
@ -59,7 +60,7 @@ public class ChangePasswordCommandTest {
|
||||
ChangePasswordCommand command = new ChangePasswordCommand();
|
||||
|
||||
// when
|
||||
command.executeCommand(sender, new ArrayList<String>());
|
||||
command.executeCommand(sender, new ArrayList<String>(), mock(CommandService.class));
|
||||
|
||||
// then
|
||||
assertThat(wrapperMock.wasMockCalled(Server.class), equalTo(false));
|
||||
@ -72,7 +73,7 @@ public class ChangePasswordCommandTest {
|
||||
ChangePasswordCommand command = new ChangePasswordCommand();
|
||||
|
||||
// when
|
||||
command.executeCommand(sender, Arrays.asList("pass", "pass"));
|
||||
command.executeCommand(sender, Arrays.asList("pass", "pass"), mock(CommandService.class));
|
||||
|
||||
// then
|
||||
verify(messagesMock).send(sender, MessageKey.NOT_LOGGED_IN);
|
||||
@ -86,7 +87,7 @@ public class ChangePasswordCommandTest {
|
||||
ChangePasswordCommand command = new ChangePasswordCommand();
|
||||
|
||||
// when
|
||||
command.executeCommand(sender, Arrays.asList("old123", "!pass"));
|
||||
command.executeCommand(sender, Arrays.asList("old123", "!pass"), mock(CommandService.class));
|
||||
|
||||
// then
|
||||
verify(messagesMock).send(sender, MessageKey.PASSWORD_MATCH_ERROR);
|
||||
@ -101,7 +102,7 @@ public class ChangePasswordCommandTest {
|
||||
ChangePasswordCommand command = new ChangePasswordCommand();
|
||||
|
||||
// when
|
||||
command.executeCommand(sender, Arrays.asList("old_", "Tester"));
|
||||
command.executeCommand(sender, Arrays.asList("old_", "Tester"), mock(CommandService.class));
|
||||
|
||||
// then
|
||||
verify(messagesMock).send(sender, MessageKey.PASSWORD_IS_USERNAME_ERROR);
|
||||
@ -116,7 +117,7 @@ public class ChangePasswordCommandTest {
|
||||
Settings.passwordMaxLength = 3;
|
||||
|
||||
// when
|
||||
command.executeCommand(sender, Arrays.asList("12", "test"));
|
||||
command.executeCommand(sender, Arrays.asList("12", "test"), mock(CommandService.class));
|
||||
|
||||
// then
|
||||
verify(messagesMock).send(sender, MessageKey.INVALID_PASSWORD_LENGTH);
|
||||
@ -131,7 +132,7 @@ public class ChangePasswordCommandTest {
|
||||
Settings.getPasswordMinLen = 7;
|
||||
|
||||
// when
|
||||
command.executeCommand(sender, Arrays.asList("oldverylongpassword", "tester"));
|
||||
command.executeCommand(sender, Arrays.asList("oldverylongpassword", "tester"), mock(CommandService.class));
|
||||
|
||||
// then
|
||||
verify(messagesMock).send(sender, MessageKey.INVALID_PASSWORD_LENGTH);
|
||||
@ -146,7 +147,7 @@ public class ChangePasswordCommandTest {
|
||||
Settings.unsafePasswords = asList("test", "abc123");
|
||||
|
||||
// when
|
||||
command.executeCommand(sender, Arrays.asList("oldpw", "abc123"));
|
||||
command.executeCommand(sender, Arrays.asList("oldpw", "abc123"), mock(CommandService.class));
|
||||
|
||||
// then
|
||||
verify(messagesMock).send(sender, MessageKey.PASSWORD_UNSAFE_ERROR);
|
||||
@ -160,7 +161,7 @@ public class ChangePasswordCommandTest {
|
||||
ChangePasswordCommand command = new ChangePasswordCommand();
|
||||
|
||||
// when
|
||||
command.executeCommand(sender, Arrays.asList("abc123", "abc123"));
|
||||
command.executeCommand(sender, Arrays.asList("abc123", "abc123"), mock(CommandService.class));
|
||||
|
||||
// then
|
||||
verify(messagesMock, never()).send(eq(sender), any(MessageKey.class));
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package fr.xephi.authme.command.executable.email;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.command.CommandService;
|
||||
import fr.xephi.authme.process.Management;
|
||||
import fr.xephi.authme.util.WrapperMock;
|
||||
import org.bukkit.command.BlockCommandSender;
|
||||
@ -13,6 +14,7 @@ import org.mockito.Mockito;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
@ -40,7 +42,7 @@ public class AddEmailCommandTest {
|
||||
AddEmailCommand command = new AddEmailCommand();
|
||||
|
||||
// when
|
||||
command.executeCommand(sender, new ArrayList<String>());
|
||||
command.executeCommand(sender, new ArrayList<String>(), mock(CommandService.class));
|
||||
|
||||
// then
|
||||
verify(authMeMock, never()).getManagement();
|
||||
@ -53,7 +55,7 @@ public class AddEmailCommandTest {
|
||||
AddEmailCommand command = new AddEmailCommand();
|
||||
|
||||
// when
|
||||
command.executeCommand(sender, Arrays.asList("mail@example", "other_example"));
|
||||
command.executeCommand(sender, Arrays.asList("mail@example", "other_example"), mock(CommandService.class));
|
||||
|
||||
// then
|
||||
verify(authMeMock).getManagement();
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package fr.xephi.authme.command.executable.email;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.command.CommandService;
|
||||
import fr.xephi.authme.process.Management;
|
||||
import fr.xephi.authme.util.WrapperMock;
|
||||
import org.bukkit.command.BlockCommandSender;
|
||||
@ -13,6 +14,7 @@ import org.mockito.Mockito;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
@ -29,18 +31,18 @@ public class ChangeEmailCommandTest {
|
||||
public void setUpMocks() {
|
||||
WrapperMock wrapper = WrapperMock.createInstance();
|
||||
authMeMock = wrapper.getAuthMe();
|
||||
managementMock = Mockito.mock(Management.class);
|
||||
managementMock = mock(Management.class);
|
||||
when(authMeMock.getManagement()).thenReturn(managementMock);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldRejectNonPlayerSender() {
|
||||
// given
|
||||
CommandSender sender = Mockito.mock(BlockCommandSender.class);
|
||||
CommandSender sender = mock(BlockCommandSender.class);
|
||||
ChangeEmailCommand command = new ChangeEmailCommand();
|
||||
|
||||
// when
|
||||
command.executeCommand(sender, new ArrayList<String>());
|
||||
command.executeCommand(sender, new ArrayList<String>(), mock(CommandService.class));
|
||||
|
||||
// then
|
||||
verify(authMeMock, never()).getManagement();
|
||||
@ -49,11 +51,12 @@ public class ChangeEmailCommandTest {
|
||||
@Test
|
||||
public void shouldForwardData() {
|
||||
// given
|
||||
Player sender = Mockito.mock(Player.class);
|
||||
Player sender = mock(Player.class);
|
||||
ChangeEmailCommand command = new ChangeEmailCommand();
|
||||
|
||||
// when
|
||||
command.executeCommand(sender, Arrays.asList("new.mail@example.org", "old_mail@example.org"));
|
||||
command.executeCommand(sender, Arrays.asList("new.mail@example.org", "old_mail@example.org"),
|
||||
mock(CommandService.class));
|
||||
|
||||
// then
|
||||
verify(authMeMock).getManagement();
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package fr.xephi.authme.command.executable.email;
|
||||
|
||||
import fr.xephi.authme.command.CommandService;
|
||||
import fr.xephi.authme.util.WrapperMock;
|
||||
import org.bukkit.command.BlockCommandSender;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -10,6 +11,8 @@ import org.mockito.Mockito;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
/**
|
||||
* Test for {@link RecoverEmailCommand}.
|
||||
*/
|
||||
@ -28,7 +31,7 @@ public class RecoverEmailCommandTest {
|
||||
RecoverEmailCommand command = new RecoverEmailCommand();
|
||||
|
||||
// when
|
||||
command.executeCommand(sender, new ArrayList<String>());
|
||||
command.executeCommand(sender, new ArrayList<String>(), mock(CommandService.class));
|
||||
|
||||
// then
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package fr.xephi.authme.command.executable.login;
|
||||
|
||||
import fr.xephi.authme.command.CommandService;
|
||||
import fr.xephi.authme.process.Management;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.util.WrapperMock;
|
||||
@ -40,7 +41,7 @@ public class LoginCommandTest {
|
||||
LoginCommand command = new LoginCommand();
|
||||
|
||||
// when
|
||||
command.executeCommand(sender, new ArrayList<String>());
|
||||
command.executeCommand(sender, new ArrayList<String>(), mock(CommandService.class));
|
||||
|
||||
// then
|
||||
Mockito.verify(managementMock, never()).performLogin(any(Player.class), anyString(), anyBoolean());
|
||||
@ -53,7 +54,7 @@ public class LoginCommandTest {
|
||||
LoginCommand command = new LoginCommand();
|
||||
|
||||
// when
|
||||
command.executeCommand(sender, Collections.singletonList("password"));
|
||||
command.executeCommand(sender, Collections.singletonList("password"), mock(CommandService.class));
|
||||
|
||||
// then
|
||||
Mockito.verify(managementMock).performLogin(eq(sender), eq("password"), eq(false));
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package fr.xephi.authme.command.executable.logout;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.command.CommandService;
|
||||
import fr.xephi.authme.process.Management;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.util.WrapperMock;
|
||||
@ -42,7 +43,7 @@ public class LogoutCommandTest {
|
||||
LogoutCommand command = new LogoutCommand();
|
||||
|
||||
// when
|
||||
command.executeCommand(sender, new ArrayList<String>());
|
||||
command.executeCommand(sender, new ArrayList<String>(), mock(CommandService.class));
|
||||
|
||||
// then
|
||||
Mockito.verify(managementMock, never()).performLogout(any(Player.class));
|
||||
@ -55,7 +56,7 @@ public class LogoutCommandTest {
|
||||
LogoutCommand command = new LogoutCommand();
|
||||
|
||||
// when
|
||||
command.executeCommand(sender, Collections.singletonList("password"));
|
||||
command.executeCommand(sender, Collections.singletonList("password"), mock(CommandService.class));
|
||||
|
||||
// then
|
||||
Mockito.verify(managementMock).performLogout(sender);
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package fr.xephi.authme.command.executable.register;
|
||||
|
||||
import fr.xephi.authme.command.CommandService;
|
||||
import fr.xephi.authme.process.Management;
|
||||
import fr.xephi.authme.output.MessageKey;
|
||||
import fr.xephi.authme.output.Messages;
|
||||
@ -50,7 +51,7 @@ public class RegisterCommandTest {
|
||||
ArgumentCaptor<String> messageCaptor = ArgumentCaptor.forClass(String.class);
|
||||
|
||||
// when
|
||||
command.executeCommand(sender, new ArrayList<String>());
|
||||
command.executeCommand(sender, new ArrayList<String>(), mock(CommandService.class));
|
||||
|
||||
// then
|
||||
verify(sender).sendMessage(messageCaptor.capture());
|
||||
@ -65,7 +66,7 @@ public class RegisterCommandTest {
|
||||
RegisterCommand command = new RegisterCommand();
|
||||
|
||||
// when
|
||||
command.executeCommand(sender, new ArrayList<String>());
|
||||
command.executeCommand(sender, new ArrayList<String>(), mock(CommandService.class));
|
||||
|
||||
// then
|
||||
verify(messagesMock).send(sender, MessageKey.USAGE_REGISTER);
|
||||
@ -79,7 +80,7 @@ public class RegisterCommandTest {
|
||||
RegisterCommand command = new RegisterCommand();
|
||||
|
||||
// when
|
||||
command.executeCommand(sender, Collections.singletonList("password"));
|
||||
command.executeCommand(sender, Collections.singletonList("password"), mock(CommandService.class));
|
||||
|
||||
// then
|
||||
verify(managementMock).performRegister(sender, "password", "");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user