Change calls to Messages to use the MessageKey enum
This commit is contained in:
@@ -4,6 +4,7 @@ import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.settings.MessageKey;
|
||||
import fr.xephi.authme.settings.Messages;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -21,15 +22,6 @@ public class AsyncChangeEmail {
|
||||
private final String newEmailVerify;
|
||||
private final Messages m;
|
||||
|
||||
/**
|
||||
* Constructor for AsyncChangeEmail.
|
||||
*
|
||||
* @param player Player
|
||||
* @param plugin AuthMe
|
||||
* @param oldEmail String
|
||||
* @param newEmail String
|
||||
* @param newEmailVerify String
|
||||
*/
|
||||
public AsyncChangeEmail(Player player, AuthMe plugin, String oldEmail, String newEmail, String newEmailVerify) {
|
||||
this.player = player;
|
||||
this.plugin = plugin;
|
||||
@@ -39,14 +31,6 @@ public class AsyncChangeEmail {
|
||||
this.m = Messages.getInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for AsyncChangeEmail.
|
||||
*
|
||||
* @param player Player
|
||||
* @param plugin AuthMe
|
||||
* @param oldEmail String
|
||||
* @param newEmail String
|
||||
*/
|
||||
public AsyncChangeEmail(Player player, AuthMe plugin, String oldEmail, String newEmail) {
|
||||
this(player, plugin, oldEmail, newEmail, newEmail);
|
||||
}
|
||||
@@ -56,7 +40,9 @@ public class AsyncChangeEmail {
|
||||
String playerName = player.getName().toLowerCase();
|
||||
|
||||
if (Settings.getmaxRegPerEmail > 0) {
|
||||
if (!plugin.getPermissionsManager().hasPermission(player, "authme.allow2accounts") && plugin.database.getAllAuthsByEmail(newEmail).size() >= Settings.getmaxRegPerEmail) {
|
||||
if (!plugin.getPermissionsManager().hasPermission(player, "authme.allow2accounts")
|
||||
&& plugin.database.getAllAuthsByEmail(newEmail).size() >= Settings.getmaxRegPerEmail) {
|
||||
// TODO ljacqu 20151124: max_reg is not in enum
|
||||
m.send(player, "max_reg");
|
||||
return;
|
||||
}
|
||||
@@ -64,53 +50,54 @@ public class AsyncChangeEmail {
|
||||
|
||||
if (PlayerCache.getInstance().isAuthenticated(playerName)) {
|
||||
if (!newEmail.equals(newEmailVerify)) {
|
||||
m.send(player, "email_confirm");
|
||||
m.send(player, MessageKey.CONFIRM_EMAIL_MESSAGE);
|
||||
return;
|
||||
}
|
||||
PlayerAuth auth = PlayerCache.getInstance().getAuth(playerName);
|
||||
if (oldEmail != null) {
|
||||
if (auth.getEmail() == null || auth.getEmail().equals("your@email.com") || auth.getEmail().isEmpty()) {
|
||||
m.send(player, "usage_email_add");
|
||||
m.send(player, MessageKey.USAGE_ADD_EMAIL);
|
||||
return;
|
||||
}
|
||||
if (!oldEmail.equals(auth.getEmail())) {
|
||||
m.send(player, "old_email_invalid");
|
||||
m.send(player, MessageKey.INVALID_OLD_EMAIL);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!Settings.isEmailCorrect(newEmail)) {
|
||||
m.send(player, "new_email_invalid");
|
||||
m.send(player, MessageKey.INVALID_NEW_EMAIL);
|
||||
return;
|
||||
}
|
||||
String old = auth.getEmail();
|
||||
auth.setEmail(newEmail);
|
||||
if (!plugin.database.updateEmail(auth)) {
|
||||
m.send(player, "error");
|
||||
m.send(player, MessageKey.ERROR);
|
||||
auth.setEmail(old);
|
||||
return;
|
||||
}
|
||||
PlayerCache.getInstance().updatePlayer(auth);
|
||||
if (oldEmail == null) {
|
||||
m.send(player, "email_added");
|
||||
m.send(player, MessageKey.EMAIL_ADDED_SUCCESS);
|
||||
player.sendMessage(auth.getEmail());
|
||||
return;
|
||||
}
|
||||
m.send(player, "email_changed");
|
||||
m.send(player, MessageKey.EMAIL_CHANGED_SUCCESS);
|
||||
// TODO ljacqu 20151124: Did I really miss "email_defined" or is it not present in the 'en' messages?
|
||||
player.sendMessage(Arrays.toString(m.send("email_defined")) + auth.getEmail());
|
||||
} else {
|
||||
if (plugin.database.isAuthAvailable(playerName)) {
|
||||
m.send(player, "login_msg");
|
||||
m.send(player, MessageKey.LOGIN_MESSAGE);
|
||||
} else {
|
||||
if (Settings.emailRegistration)
|
||||
m.send(player, "reg_email_msg");
|
||||
m.send(player, MessageKey.REGISTER_EMAIL_MESSAGE);
|
||||
else
|
||||
m.send(player, "reg_msg");
|
||||
m.send(player, MessageKey.REGISTER_MESSAGE);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ConsoleLogger.showError(e.getMessage());
|
||||
ConsoleLogger.writeStackTrace(e);
|
||||
m.send(player, "error");
|
||||
m.send(player, MessageKey.ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import fr.xephi.authme.events.FirstSpawnTeleportEvent;
|
||||
import fr.xephi.authme.events.ProtectInventoryEvent;
|
||||
import fr.xephi.authme.events.SpawnTeleportEvent;
|
||||
import fr.xephi.authme.listener.AuthMePlayerListener;
|
||||
import fr.xephi.authme.settings.MessageKey;
|
||||
import fr.xephi.authme.settings.Messages;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.settings.Spawn;
|
||||
@@ -38,13 +39,6 @@ public class AsynchronousJoin {
|
||||
private final Messages m;
|
||||
private final BukkitScheduler sched;
|
||||
|
||||
/**
|
||||
* Constructor for AsynchronousJoin.
|
||||
*
|
||||
* @param player Player
|
||||
* @param plugin AuthMe
|
||||
* @param database DataSource
|
||||
*/
|
||||
public AsynchronousJoin(Player player, AuthMe plugin, DataSource database) {
|
||||
this.player = player;
|
||||
this.plugin = plugin;
|
||||
@@ -239,25 +233,26 @@ public class AsynchronousJoin {
|
||||
database.setUnlogged(name);
|
||||
PlayerCache.getInstance().removePlayer(name);
|
||||
if (auth != null && auth.getIp().equals(ip)) {
|
||||
m.send(player, "valid_session");
|
||||
m.send(player, MessageKey.SESSION_RECONNECTION);
|
||||
plugin.management.performLogin(player, "dontneed", true);
|
||||
return;
|
||||
} else if (Settings.sessionExpireOnIpChange) {
|
||||
m.send(player, "invalid_session");
|
||||
m.send(player, MessageKey.SESSION_EXPIRED);
|
||||
}
|
||||
}
|
||||
|
||||
String[] msg = isAuthAvailable ? m.send("login_msg") :
|
||||
m.send("reg_" + (Settings.emailRegistration ? "email_" : "") + "msg");
|
||||
String[] msg;
|
||||
if (isAuthAvailable) {
|
||||
msg = m.retrieve(MessageKey.LOGIN_MESSAGE);
|
||||
} else {
|
||||
msg = Settings.emailRegistration
|
||||
? m.retrieve(MessageKey.REGISTER_EMAIL_MESSAGE)
|
||||
: m.retrieve(MessageKey.REGISTER_MESSAGE);
|
||||
}
|
||||
BukkitTask msgTask = sched.runTaskAsynchronously(plugin, new MessageTask(plugin, name, msg, msgInterval));
|
||||
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(msgTask);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method needFirstSpawn.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
private boolean needFirstSpawn() {
|
||||
if (player.hasPlayedBefore())
|
||||
return false;
|
||||
@@ -282,12 +277,6 @@ public class AsynchronousJoin {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method placePlayerSafely.
|
||||
*
|
||||
* @param player Player
|
||||
* @param spawnLoc Location
|
||||
*/
|
||||
private void placePlayerSafely(final Player player, final Location spawnLoc) {
|
||||
if (spawnLoc == null)
|
||||
return;
|
||||
@@ -307,7 +296,7 @@ public class AsynchronousJoin {
|
||||
Material top = player.getLocation().add(0D, 1D, 0D).getBlock().getType();
|
||||
if (cur == Material.PORTAL || cur == Material.ENDER_PORTAL
|
||||
|| top == Material.PORTAL || top == Material.ENDER_PORTAL) {
|
||||
m.send(player, "unsafe_spawn");
|
||||
m.send(player, MessageKey.UNSAFE_QUIT_LOCATION);
|
||||
player.teleport(spawnLoc);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user