#306 Create PlayerCommand abstract type

- Create PlayerCommand to handle player-only command checks centrally and consistently
- Adjust tests
This commit is contained in:
ljacqu
2015-12-26 19:47:47 +01:00
parent 74ceb66430
commit 27fee3ca64
25 changed files with 250 additions and 393 deletions
@@ -1,30 +1,18 @@
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;
import fr.xephi.authme.command.PlayerCommand;
import org.bukkit.entity.Player;
import java.util.List;
/**
* Logout command.
*/
public class LogoutCommand implements ExecutableCommand {
public class LogoutCommand extends PlayerCommand {
@Override
public void executeCommand(CommandSender sender, List<String> arguments, CommandService commandService) {
// Make sure the current command executor is a player
if (!(sender instanceof Player)) {
return;
}
// Get the player instance
final AuthMe plugin = Wrapper.getInstance().getAuthMe();
final Player player = (Player) sender;
// Logout the player
plugin.getManagement().performLogout(player);
public void runCommand(Player player, List<String> arguments, CommandService commandService) {
commandService.getManagement().performLogout(player);
}
}