* #1119 new permission and email hider * Updated commands.md * Improved email hiding method * Revert "Improved email hiding method" This reverts commit cb60d7b * New config option, updated tests, config.md and permission_nodes.md * Moved to service import, fixed typo and updated config.md * Removed unused imports O.o
This commit is contained in:
@@ -456,6 +456,7 @@ public class CommandInitializer {
|
||||
.labels("show", "myemail")
|
||||
.description("Show Email")
|
||||
.detailedDescription("Show your current email address.")
|
||||
.permission(PlayerPermission.SEE_EMAIL)
|
||||
.executableCommand(ShowEmailCommand.class)
|
||||
.register();
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import fr.xephi.authme.data.auth.PlayerAuth;
|
||||
import fr.xephi.authme.data.auth.PlayerCache;
|
||||
import fr.xephi.authme.message.MessageKey;
|
||||
import fr.xephi.authme.service.CommonService;
|
||||
import fr.xephi.authme.settings.properties.SecuritySettings;
|
||||
import fr.xephi.authme.util.Utils;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -26,9 +27,22 @@ public class ShowEmailCommand extends PlayerCommand {
|
||||
public void runCommand(Player player, List<String> arguments) {
|
||||
PlayerAuth auth = playerCache.getAuth(player.getName());
|
||||
if (auth != null && !Utils.isEmailEmpty(auth.getEmail())) {
|
||||
commonService.send(player, MessageKey.EMAIL_SHOW, auth.getEmail());
|
||||
if(commonService.getProperty(SecuritySettings.USE_EMAIL_MASKING)){
|
||||
commonService.send(player, MessageKey.EMAIL_SHOW, emailMask(auth.getEmail()));
|
||||
} else {
|
||||
commonService.send(player, MessageKey.EMAIL_SHOW, auth.getEmail());
|
||||
}
|
||||
} else {
|
||||
commonService.send(player, MessageKey.SHOW_NO_EMAIL);
|
||||
}
|
||||
}
|
||||
|
||||
private String emailMask(String email){
|
||||
String[] frag = email.split("@"); //Split id and domain
|
||||
int sid = frag[0].length() / 3 + 1; //Define the id view (required length >= 1)
|
||||
int sdomain = frag[1].length() / 3; //Define the domain view (required length >= 0)
|
||||
String id = frag[0].substring(0, sid) + "***"; //Build the id
|
||||
String domain = "***" + frag[1].substring(sdomain); //Build the domain
|
||||
return id + "@" + domain;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user