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:
parent
504106f835
commit
3934d67330
@ -39,8 +39,8 @@ public class CommandArgumentDescription {
|
|||||||
/**
|
/**
|
||||||
* Get the argument label.
|
* Get the argument label.
|
||||||
*
|
*
|
||||||
|
* @return Argument label.
|
||||||
* @return Argument label. */
|
*/
|
||||||
public String getLabel() {
|
public String getLabel() {
|
||||||
return this.label;
|
return this.label;
|
||||||
}
|
}
|
||||||
@ -57,8 +57,8 @@ public class CommandArgumentDescription {
|
|||||||
/**
|
/**
|
||||||
* Get the argument description.
|
* Get the argument description.
|
||||||
*
|
*
|
||||||
|
* @return Argument description.
|
||||||
* @return Argument description. */
|
*/
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
@ -75,8 +75,8 @@ public class CommandArgumentDescription {
|
|||||||
/**
|
/**
|
||||||
* Check whether the argument is optional.
|
* Check whether the argument is optional.
|
||||||
*
|
*
|
||||||
|
* @return True if the argument is optional, false otherwise.
|
||||||
* @return True if the argument is optional, false otherwise. */
|
*/
|
||||||
public boolean isOptional() {
|
public boolean isOptional() {
|
||||||
return optional;
|
return optional;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package fr.xephi.authme.command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Base class for AuthMe commands that can be executed.
|
||||||
*/
|
*/
|
||||||
public abstract class ExecutableCommand {
|
public abstract class ExecutableCommand {
|
||||||
|
|
||||||
@ -13,7 +14,7 @@ public abstract class ExecutableCommand {
|
|||||||
* @param commandReference The command reference.
|
* @param commandReference The command reference.
|
||||||
* @param commandArguments The command arguments.
|
* @param commandArguments The command arguments.
|
||||||
*
|
*
|
||||||
|
* @return True if the command was executed successfully, false otherwise.
|
||||||
* @return True if the command was executed successfully, false otherwise. */
|
*/
|
||||||
public abstract boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments);
|
public abstract boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,31 +10,19 @@ import fr.xephi.authme.command.help.HelpProvider;
|
|||||||
*/
|
*/
|
||||||
public class HelpCommand extends ExecutableCommand {
|
public class HelpCommand 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
|
@Override
|
||||||
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
||||||
// Check whether quick help should be shown
|
// Check whether quick help should be shown
|
||||||
boolean quickHelp = commandArguments.getCount() == 0;
|
boolean quickHelp = commandArguments.getCount() == 0;
|
||||||
|
|
||||||
// Set the proper command arguments for the quick help
|
// Set the proper command arguments for the quick help and show it
|
||||||
if(quickHelp)
|
if (quickHelp) {
|
||||||
commandArguments = new CommandParts(commandReference.get(0));
|
commandArguments = new CommandParts(commandReference.get(0));
|
||||||
|
|
||||||
// Show the new help
|
|
||||||
if(quickHelp)
|
|
||||||
HelpProvider.showHelp(sender, commandReference, commandArguments, false, false, false, false, false, true);
|
HelpProvider.showHelp(sender, commandReference, commandArguments, false, false, false, false, false, true);
|
||||||
else
|
} else {
|
||||||
HelpProvider.showHelp(sender, commandReference, commandArguments);
|
HelpProvider.showHelp(sender, commandReference, commandArguments);
|
||||||
|
}
|
||||||
|
|
||||||
// Return the result
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,15 +16,6 @@ import fr.xephi.authme.settings.Messages;
|
|||||||
*/
|
*/
|
||||||
public class AccountsCommand extends ExecutableCommand {
|
public class AccountsCommand 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
|
@Override
|
||||||
public boolean executeCommand(final CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
public boolean executeCommand(final CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
||||||
// AuthMe plugin instance
|
// AuthMe plugin instance
|
||||||
|
|||||||
@ -11,15 +11,6 @@ import fr.xephi.authme.command.ExecutableCommand;
|
|||||||
*/
|
*/
|
||||||
public class AuthMeCommand extends ExecutableCommand {
|
public class AuthMeCommand 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
|
@Override
|
||||||
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
||||||
// Show some version info
|
// Show some version info
|
||||||
|
|||||||
@ -19,20 +19,8 @@ import fr.xephi.authme.settings.Settings;
|
|||||||
*/
|
*/
|
||||||
public class ChangePasswordCommand extends ExecutableCommand {
|
public class ChangePasswordCommand 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
|
@Override
|
||||||
public boolean executeCommand(final CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
public boolean executeCommand(final CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
||||||
// AuthMe plugin instance
|
|
||||||
final AuthMe plugin = AuthMe.getInstance();
|
|
||||||
|
|
||||||
// Messages instance
|
// Messages instance
|
||||||
final Messages m = Messages.getInstance();
|
final Messages m = Messages.getInstance();
|
||||||
|
|
||||||
@ -62,6 +50,7 @@ public class ChangePasswordCommand extends ExecutableCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set the password
|
// Set the password
|
||||||
|
final AuthMe plugin = AuthMe.getInstance();
|
||||||
final String playerNameLowerCase = playerName.toLowerCase();
|
final String playerNameLowerCase = playerName.toLowerCase();
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||||
|
|
||||||
|
|||||||
@ -12,15 +12,6 @@ import fr.xephi.authme.settings.Spawn;
|
|||||||
*/
|
*/
|
||||||
public class FirstSpawnCommand extends ExecutableCommand {
|
public class FirstSpawnCommand 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
|
@Override
|
||||||
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
||||||
// Make sure the command executor is a player
|
// Make sure the command executor is a player
|
||||||
@ -33,6 +24,7 @@ public class FirstSpawnCommand extends ExecutableCommand {
|
|||||||
sender.sendMessage("[AuthMe] Please use that command in game");
|
sender.sendMessage("[AuthMe] Please use that command in game");
|
||||||
}
|
}
|
||||||
} catch (NullPointerException ex) {
|
} catch (NullPointerException ex) {
|
||||||
|
// TODO ljacqu 20151119: Catching NullPointerException is never a good idea. Find what can cause one instead
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
ConsoleLogger.showError(ex.getMessage());
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@ -12,15 +12,6 @@ import fr.xephi.authme.command.ExecutableCommand;
|
|||||||
*/
|
*/
|
||||||
public class ForceLoginCommand extends ExecutableCommand {
|
public class ForceLoginCommand 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
|
@Override
|
||||||
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
||||||
// AuthMe plugin instance
|
// AuthMe plugin instance
|
||||||
@ -33,7 +24,6 @@ public class ForceLoginCommand extends ExecutableCommand {
|
|||||||
|
|
||||||
// Command logic
|
// Command logic
|
||||||
try {
|
try {
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
Player player = Bukkit.getPlayer(playerName);
|
Player player = Bukkit.getPlayer(playerName);
|
||||||
if (player == null || !player.isOnline()) {
|
if (player == null || !player.isOnline()) {
|
||||||
sender.sendMessage("Player needs to be online!");
|
sender.sendMessage("Player needs to be online!");
|
||||||
|
|||||||
@ -23,18 +23,14 @@ public class GetEmailCommand extends ExecutableCommand {
|
|||||||
* @return True if the command was executed successfully, false otherwise. */
|
* @return True if the command was executed successfully, false otherwise. */
|
||||||
@Override
|
@Override
|
||||||
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
||||||
// AuthMe plugin instance
|
|
||||||
AuthMe plugin = AuthMe.getInstance();
|
|
||||||
|
|
||||||
// Messages instance
|
|
||||||
Messages m = Messages.getInstance();
|
|
||||||
|
|
||||||
// Get the player name
|
// Get the player name
|
||||||
String playerName = sender.getName();
|
String playerName = sender.getName();
|
||||||
if(commandArguments.getCount() >= 1)
|
if(commandArguments.getCount() >= 1)
|
||||||
playerName = commandArguments.get(0);
|
playerName = commandArguments.get(0);
|
||||||
|
|
||||||
// Get the authenticated user
|
// Get the authenticated user
|
||||||
|
AuthMe plugin = AuthMe.getInstance();
|
||||||
|
Messages m = Messages.getInstance();
|
||||||
PlayerAuth auth = plugin.database.getAuth(playerName.toLowerCase());
|
PlayerAuth auth = plugin.database.getAuth(playerName.toLowerCase());
|
||||||
if (auth == null) {
|
if (auth == null) {
|
||||||
m.send(sender, "unknown_user");
|
m.send(sender, "unknown_user");
|
||||||
|
|||||||
@ -12,15 +12,6 @@ import fr.xephi.authme.command.ExecutableCommand;
|
|||||||
*/
|
*/
|
||||||
public class GetIpCommand extends ExecutableCommand {
|
public class GetIpCommand 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
|
@Override
|
||||||
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
||||||
// AuthMe plugin instance
|
// AuthMe plugin instance
|
||||||
@ -31,7 +22,6 @@ public class GetIpCommand extends ExecutableCommand {
|
|||||||
if(commandArguments.getCount() >= 1)
|
if(commandArguments.getCount() >= 1)
|
||||||
playerName = commandArguments.get(0);
|
playerName = commandArguments.get(0);
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
Player player = Bukkit.getPlayer(playerName);
|
Player player = Bukkit.getPlayer(playerName);
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
sender.sendMessage("This player is not actually online");
|
sender.sendMessage("This player is not actually online");
|
||||||
|
|||||||
@ -14,29 +14,17 @@ import fr.xephi.authme.settings.Messages;
|
|||||||
*/
|
*/
|
||||||
public class LastLoginCommand extends ExecutableCommand {
|
public class LastLoginCommand 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
|
@Override
|
||||||
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
||||||
// AuthMe plugin instance
|
|
||||||
AuthMe plugin = AuthMe.getInstance();
|
|
||||||
|
|
||||||
// Messages instance
|
|
||||||
Messages m = Messages.getInstance();
|
|
||||||
|
|
||||||
// Get the player
|
// Get the player
|
||||||
String playerName = sender.getName();
|
String playerName = sender.getName();
|
||||||
if(commandArguments.getCount() >= 1)
|
if(commandArguments.getCount() >= 1)
|
||||||
playerName = commandArguments.get(0);
|
playerName = commandArguments.get(0);
|
||||||
|
|
||||||
// Validate the player
|
// Validate the player
|
||||||
|
AuthMe plugin = AuthMe.getInstance();
|
||||||
|
Messages m = Messages.getInstance();
|
||||||
|
|
||||||
PlayerAuth auth;
|
PlayerAuth auth;
|
||||||
try {
|
try {
|
||||||
auth = plugin.database.getAuth(playerName.toLowerCase());
|
auth = plugin.database.getAuth(playerName.toLowerCase());
|
||||||
|
|||||||
@ -15,21 +15,8 @@ import fr.xephi.authme.task.ChangePasswordTask;
|
|||||||
*/
|
*/
|
||||||
public class ChangePasswordCommand extends ExecutableCommand {
|
public class ChangePasswordCommand 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
|
@Override
|
||||||
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
||||||
// AuthMe plugin instance
|
|
||||||
final AuthMe plugin = AuthMe.getInstance();
|
|
||||||
|
|
||||||
// Messages instance
|
|
||||||
final Messages m = Messages.getInstance();
|
final Messages m = Messages.getInstance();
|
||||||
|
|
||||||
// Get the passwords
|
// Get the passwords
|
||||||
@ -71,6 +58,7 @@ public class ChangePasswordCommand extends ExecutableCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set the password
|
// Set the password
|
||||||
|
final AuthMe plugin = AuthMe.getInstance();
|
||||||
plugin.getServer().getScheduler().runTaskAsynchronously(plugin, new ChangePasswordTask(plugin, player, playerPass, playerPassVerify));
|
plugin.getServer().getScheduler().runTaskAsynchronously(plugin, new ChangePasswordTask(plugin, player, playerPass, playerPassVerify));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,22 +12,8 @@ import fr.xephi.authme.settings.Messages;
|
|||||||
*/
|
*/
|
||||||
public class AddEmailCommand extends ExecutableCommand {
|
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
|
@Override
|
||||||
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
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
|
// Get the parameter values
|
||||||
String playerMail = commandArguments.get(0);
|
String playerMail = commandArguments.get(0);
|
||||||
String playerMailVerify = commandArguments.get(1);
|
String playerMailVerify = commandArguments.get(1);
|
||||||
@ -37,11 +23,9 @@ public class AddEmailCommand extends ExecutableCommand {
|
|||||||
return true;
|
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 Player player = (Player) sender;
|
||||||
final String playerName = player.getName().toLowerCase();
|
|
||||||
|
|
||||||
// Command logic
|
|
||||||
plugin.management.performAddEmail(player, playerMail, playerMailVerify);
|
plugin.management.performAddEmail(player, playerMail, playerMailVerify);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,28 +6,13 @@ import org.bukkit.entity.Player;
|
|||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.command.CommandParts;
|
import fr.xephi.authme.command.CommandParts;
|
||||||
import fr.xephi.authme.command.ExecutableCommand;
|
import fr.xephi.authme.command.ExecutableCommand;
|
||||||
import fr.xephi.authme.settings.Messages;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
public class ChangeEmailCommand extends ExecutableCommand {
|
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
|
@Override
|
||||||
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
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
|
// Get the parameter values
|
||||||
String playerMailOld = commandArguments.get(0);
|
String playerMailOld = commandArguments.get(0);
|
||||||
String playerMailNew = commandArguments.get(1);
|
String playerMailNew = commandArguments.get(1);
|
||||||
@ -37,11 +22,9 @@ public class ChangeEmailCommand extends ExecutableCommand {
|
|||||||
return true;
|
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 Player player = (Player) sender;
|
||||||
final String playerName = player.getName();
|
|
||||||
|
|
||||||
// Command logic
|
|
||||||
plugin.management.performChangeEmail(player, playerMailOld, playerMailNew);
|
plugin.management.performChangeEmail(player, playerMailOld, playerMailNew);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,23 +20,8 @@ import fr.xephi.authme.settings.Settings;
|
|||||||
*/
|
*/
|
||||||
public class RecoverEmailCommand extends ExecutableCommand {
|
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
|
@Override
|
||||||
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
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
|
// Get the parameter values
|
||||||
String playerMail = commandArguments.get(0);
|
String playerMail = commandArguments.get(0);
|
||||||
|
|
||||||
@ -50,6 +35,9 @@ public class RecoverEmailCommand extends ExecutableCommand {
|
|||||||
final String playerName = player.getName();
|
final String playerName = player.getName();
|
||||||
|
|
||||||
// Command logic
|
// Command logic
|
||||||
|
final AuthMe plugin = AuthMe.getInstance();
|
||||||
|
final Messages m = Messages.getInstance();
|
||||||
|
|
||||||
if (plugin.mail == null) {
|
if (plugin.mail == null) {
|
||||||
m.send(player, "error");
|
m.send(player, "error");
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@ -11,32 +11,19 @@ import fr.xephi.authme.command.ExecutableCommand;
|
|||||||
*/
|
*/
|
||||||
public class LoginCommand extends ExecutableCommand {
|
public class LoginCommand 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
|
@Override
|
||||||
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
||||||
// AuthMe plugin instance
|
|
||||||
final AuthMe plugin = AuthMe.getInstance();
|
|
||||||
|
|
||||||
// Make sure the current command executor is a player
|
// Make sure the current command executor is a player
|
||||||
if(!(sender instanceof Player)) {
|
if (!(sender instanceof Player)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the player instance
|
// Get the necessary objects
|
||||||
|
final AuthMe plugin = AuthMe.getInstance();
|
||||||
final Player player = (Player) sender;
|
final Player player = (Player) sender;
|
||||||
|
final String playerPass = commandArguments.get(0);
|
||||||
|
|
||||||
// Get the password
|
// Log the player in
|
||||||
String playerPass = commandArguments.get(0);
|
|
||||||
|
|
||||||
// Login the player
|
|
||||||
plugin.management.performLogin(player, playerPass, false);
|
plugin.management.performLogin(player, playerPass, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,26 +11,15 @@ import fr.xephi.authme.command.ExecutableCommand;
|
|||||||
*/
|
*/
|
||||||
public class LogoutCommand extends ExecutableCommand {
|
public class LogoutCommand 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
|
@Override
|
||||||
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
||||||
// AuthMe plugin instance
|
|
||||||
final AuthMe plugin = AuthMe.getInstance();
|
|
||||||
|
|
||||||
// Make sure the current command executor is a player
|
// Make sure the current command executor is a player
|
||||||
if(!(sender instanceof Player)) {
|
if (!(sender instanceof Player)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the player instance
|
// Get the player instance
|
||||||
|
final AuthMe plugin = AuthMe.getInstance();
|
||||||
final Player player = (Player) sender;
|
final Player player = (Player) sender;
|
||||||
|
|
||||||
// Logout the player
|
// Logout the player
|
||||||
|
|||||||
@ -14,21 +14,8 @@ import fr.xephi.authme.settings.Settings;
|
|||||||
*/
|
*/
|
||||||
public class RegisterCommand extends ExecutableCommand {
|
public class RegisterCommand 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
|
@Override
|
||||||
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
||||||
// AuthMe plugin instance
|
|
||||||
final AuthMe plugin = AuthMe.getInstance();
|
|
||||||
|
|
||||||
// Messages instance
|
|
||||||
final Messages m = Messages.getInstance();
|
final Messages m = Messages.getInstance();
|
||||||
|
|
||||||
// Make sure the sender is a player
|
// Make sure the sender is a player
|
||||||
@ -44,6 +31,7 @@ public class RegisterCommand extends ExecutableCommand {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final AuthMe plugin = AuthMe.getInstance();
|
||||||
if (Settings.emailRegistration && !Settings.getmailAccount.isEmpty()) {
|
if (Settings.emailRegistration && !Settings.getmailAccount.isEmpty()) {
|
||||||
if (Settings.doubleEmailCheck) {
|
if (Settings.doubleEmailCheck) {
|
||||||
if (commandArguments.getCount() < 2 || !commandArguments.get(0).equals(commandArguments.get(1))) {
|
if (commandArguments.getCount() < 2 || !commandArguments.get(0).equals(commandArguments.get(1))) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user