Command refactor - remove unused fields, reduce variable "scope"

Minor refactorings in the command section for familiarization.

1. Removed suppressWarning("Deprecated") - the method is deprecated for a reason and we should be made aware of that.
2. Removed same javadoc on ExecutableCommand implementation that just had the same as the interface (this is just clutter; @Override signals that it's an implementing class and a developer can view the superclass javadoc)
3. In places where the AuthMe instance was retrieved at the top but used at the very bottom, moved it to the bottom to reduce its "scope"
(cherry picked from commit 45a50f3)
This commit is contained in:
ljacqu
2015-11-21 09:07:12 +01:00
parent 504106f835
commit 3934d67330
18 changed files with 36 additions and 213 deletions
@@ -12,22 +12,8 @@ import fr.xephi.authme.settings.Messages;
*/
public class AddEmailCommand extends ExecutableCommand {
/**
* Execute the command.
*
* @param sender The command sender.
* @param commandReference The command reference.
* @param commandArguments The command arguments.
* @return True if the command was executed successfully, false otherwise. */
@Override
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// AuthMe plugin instance
final AuthMe plugin = AuthMe.getInstance();
// Messages instance
final Messages m = Messages.getInstance();
// Get the parameter values
String playerMail = commandArguments.get(0);
String playerMailVerify = commandArguments.get(1);
@@ -37,11 +23,9 @@ public class AddEmailCommand extends ExecutableCommand {
return true;
}
// Get the player instance and name
// Get the player and perform email addition
final AuthMe plugin = AuthMe.getInstance();
final Player player = (Player) sender;
final String playerName = player.getName().toLowerCase();
// Command logic
plugin.management.performAddEmail(player, playerMail, playerMailVerify);
return true;
}
@@ -6,28 +6,13 @@ import org.bukkit.entity.Player;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.command.CommandParts;
import fr.xephi.authme.command.ExecutableCommand;
import fr.xephi.authme.settings.Messages;
/**
*/
public class ChangeEmailCommand extends ExecutableCommand {
/**
* Execute the command.
*
* @param sender The command sender.
* @param commandReference The command reference.
* @param commandArguments The command arguments.
* @return True if the command was executed successfully, false otherwise. */
@Override
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// AuthMe plugin instance
final AuthMe plugin = AuthMe.getInstance();
// Messages instance
final Messages m = Messages.getInstance();
// Get the parameter values
String playerMailOld = commandArguments.get(0);
String playerMailNew = commandArguments.get(1);
@@ -37,11 +22,9 @@ public class ChangeEmailCommand extends ExecutableCommand {
return true;
}
// Get the player instance and name
// Get the player instance and execute action
final AuthMe plugin = AuthMe.getInstance();
final Player player = (Player) sender;
final String playerName = player.getName();
// Command logic
plugin.management.performChangeEmail(player, playerMailOld, playerMailNew);
return true;
}
@@ -20,23 +20,8 @@ import fr.xephi.authme.settings.Settings;
*/
public class RecoverEmailCommand extends ExecutableCommand {
/**
* Execute the command.
*
* @param sender The command sender.
* @param commandReference The command reference.
* @param commandArguments The command arguments.
*
* @return True if the command was executed successfully, false otherwise. */
@Override
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// AuthMe plugin instance
final AuthMe plugin = AuthMe.getInstance();
// Messages instance
final Messages m = Messages.getInstance();
// Get the parameter values
String playerMail = commandArguments.get(0);
@@ -50,6 +35,9 @@ public class RecoverEmailCommand extends ExecutableCommand {
final String playerName = player.getName();
// Command logic
final AuthMe plugin = AuthMe.getInstance();
final Messages m = Messages.getInstance();
if (plugin.mail == null) {
m.send(player, "error");
return true;