Add "/email show" command.

#922
This commit is contained in:
DNx5
2016-10-17 22:16:29 +07:00
parent dc5fe64b15
commit 71e4c59c20
29 changed files with 355 additions and 251 deletions
@@ -28,6 +28,7 @@ import fr.xephi.authme.command.executable.changepassword.ChangePasswordCommand;
import fr.xephi.authme.command.executable.email.AddEmailCommand;
import fr.xephi.authme.command.executable.email.ChangeEmailCommand;
import fr.xephi.authme.command.executable.email.EmailBaseCommand;
import fr.xephi.authme.command.executable.email.EmailShowCommand;
import fr.xephi.authme.command.executable.email.RecoverEmailCommand;
import fr.xephi.authme.command.executable.login.LoginCommand;
import fr.xephi.authme.command.executable.logout.LogoutCommand;
@@ -353,6 +354,15 @@ public class CommandInitializer {
.executableCommand(EmailBaseCommand.class)
.build();
// Register the show command
CommandDescription.builder()
.parent(EMAIL_BASE)
.labels("show", "myemail")
.description("Show Email")
.detailedDescription("Show your current email address")
.executableCommand(EmailShowCommand.class)
.build();
// Register the add command
CommandDescription.builder()
.parent(EMAIL_BASE)
@@ -0,0 +1,38 @@
package fr.xephi.authme.command.executable.email;
import fr.xephi.authme.command.CommandService;
import fr.xephi.authme.command.PlayerCommand;
import fr.xephi.authme.data.auth.PlayerAuth;
import fr.xephi.authme.data.auth.PlayerCache;
import fr.xephi.authme.message.MessageKey;
import fr.xephi.authme.process.Management;
import org.bukkit.entity.Player;
import javax.inject.Inject;
import java.util.List;
/**
* Created on 17/10/2016.
* Author: DNx
*/
public class EmailShowCommand extends PlayerCommand {
@Inject
private Management management;
@Inject
private CommandService commandService;
@Inject
private PlayerCache playerCache;
@Override
public void runCommand(Player player, List<String> arguments) {
PlayerAuth auth = playerCache.getAuth(player.getName());
if (auth.getEmail() != null && !auth.getEmail().equalsIgnoreCase("your@email.com")) {
commandService.send(player, MessageKey.EMAIL_SHOW, auth.getEmail());
} else {
commandService.send(player, MessageKey.SHOW_NO_EMAIL);
}
}
}