mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-12-19 07:07:55 +01:00
Change calls to Messages to use the MessageKey enum
This commit is contained in:
parent
cb11ae9610
commit
d2b3d416a9
@ -1,5 +1,6 @@
|
||||
package fr.xephi.authme;
|
||||
|
||||
import fr.xephi.authme.settings.MessageKey;
|
||||
import fr.xephi.authme.settings.Messages;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -47,7 +48,7 @@ public class AntiBot {
|
||||
|
||||
public static void activateAntiBot() {
|
||||
antiBotStatus = AntiBotStatus.ACTIVE;
|
||||
for (String s : messages.send("antibot_auto_enabled")) {
|
||||
for (String s : messages.retrieve(MessageKey.ANTIBOT_AUTO_ENABLED_MESSAGE)) {
|
||||
Bukkit.broadcastMessage(s);
|
||||
}
|
||||
|
||||
@ -57,18 +58,14 @@ public class AntiBot {
|
||||
if (antiBotStatus == AntiBotStatus.ACTIVE) {
|
||||
antiBotStatus = AntiBotStatus.LISTENING;
|
||||
antibotPlayers.clear();
|
||||
for (String s : messages.send("antibot_auto_disabled"))
|
||||
for (String s : messages.retrieve(MessageKey.ANTIBOT_AUTO_DISABLED_MESSAGE)) {
|
||||
Bukkit.broadcastMessage(s.replace("%m", "" + Settings.antiBotDuration));
|
||||
}
|
||||
}
|
||||
}
|
||||
}, Settings.antiBotDuration * 1200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method checkAntiBotMod.
|
||||
*
|
||||
* @param player Player
|
||||
*/
|
||||
public static void checkAntiBot(final Player player) {
|
||||
if (antiBotStatus == AntiBotStatus.ACTIVE || antiBotStatus == AntiBotStatus.DISABLED) {
|
||||
return;
|
||||
|
@ -6,6 +6,7 @@ import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
||||
import fr.xephi.authme.command.CommandParts;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.settings.MessageKey;
|
||||
import fr.xephi.authme.settings.Messages;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.task.MessageTask;
|
||||
@ -46,18 +47,17 @@ public class UnregisterCommand extends ExecutableCommand {
|
||||
|
||||
// Make sure the user is valid
|
||||
if (!plugin.database.isAuthAvailable(playerNameLowerCase)) {
|
||||
m.send(sender, "user_unknown");
|
||||
m.send(sender, MessageKey.UNKNOWN_USER);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Remove the player
|
||||
if (!plugin.database.removeAuth(playerNameLowerCase)) {
|
||||
m.send(sender, "error");
|
||||
m.send(sender, MessageKey.ERROR);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Unregister the player
|
||||
@SuppressWarnings("deprecation")
|
||||
Player target = Bukkit.getPlayer(playerNameLowerCase);
|
||||
PlayerCache.getInstance().removePlayer(playerNameLowerCase);
|
||||
Utils.setGroup(target, Utils.GroupType.UNREGISTERED);
|
||||
@ -71,19 +71,21 @@ public class UnregisterCommand extends ExecutableCommand {
|
||||
BukkitTask id = scheduler.runTaskLaterAsynchronously(plugin, new TimeoutTask(plugin, playerNameLowerCase, target), delay);
|
||||
LimboCache.getInstance().getLimboPlayer(playerNameLowerCase).setTimeoutTaskId(id);
|
||||
}
|
||||
LimboCache.getInstance().getLimboPlayer(playerNameLowerCase).setMessageTaskId(scheduler.runTaskAsynchronously(plugin, new MessageTask(plugin, playerNameLowerCase, m.send("reg_msg"), interval)));
|
||||
LimboCache.getInstance().getLimboPlayer(playerNameLowerCase).setMessageTaskId(
|
||||
scheduler.runTaskAsynchronously(plugin,
|
||||
new MessageTask(plugin, playerNameLowerCase, m.retrieve(MessageKey.REGISTER_MESSAGE), interval)));
|
||||
if (Settings.applyBlindEffect)
|
||||
target.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, Settings.getRegistrationTimeout * 20, 2));
|
||||
if (!Settings.isMovementAllowed && Settings.isRemoveSpeedEnabled) {
|
||||
target.setWalkSpeed(0.0f);
|
||||
target.setFlySpeed(0.0f);
|
||||
}
|
||||
m.send(target, "unregistered");
|
||||
m.send(target, MessageKey.UNREGISTERED_SUCCESS);
|
||||
|
||||
}
|
||||
|
||||
// Show a status message
|
||||
m.send(sender, "unregistered");
|
||||
m.send(sender, MessageKey.UNREGISTERED_SUCCESS);
|
||||
ConsoleLogger.info(playerName + " unregistered");
|
||||
return true;
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.command.CommandParts;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.security.RandomString;
|
||||
import fr.xephi.authme.settings.MessageKey;
|
||||
import fr.xephi.authme.settings.Messages;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -14,15 +15,6 @@ import org.bukkit.entity.Player;
|
||||
*/
|
||||
public class CaptchaCommand 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
|
||||
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
||||
// Make sure the current command executor is a player
|
||||
@ -42,12 +34,12 @@ public class CaptchaCommand extends ExecutableCommand {
|
||||
|
||||
// Command logic
|
||||
if (PlayerCache.getInstance().isAuthenticated(playerNameLowerCase)) {
|
||||
m.send(player, "logged_in");
|
||||
m.send(player, MessageKey.ALREADY_LOGGED_IN_ERROR);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!Settings.useCaptcha) {
|
||||
m.send(player, "usage_log");
|
||||
m.send(player, MessageKey.USAGE_LOGIN);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -55,7 +47,7 @@ public class CaptchaCommand extends ExecutableCommand {
|
||||
final AuthMe plugin = AuthMe.getInstance();
|
||||
|
||||
if (!plugin.cap.containsKey(playerNameLowerCase)) {
|
||||
m.send(player, "usage_log");
|
||||
m.send(player, MessageKey.USAGE_LOGIN);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -63,7 +55,7 @@ public class CaptchaCommand extends ExecutableCommand {
|
||||
plugin.cap.remove(playerNameLowerCase);
|
||||
String randStr = new RandomString(Settings.captchaLength).nextString();
|
||||
plugin.cap.put(playerNameLowerCase, randStr);
|
||||
for (String s : m.send("wrong_captcha")) {
|
||||
for (String s : m.retrieve(MessageKey.CAPTCHA_WRONG_ERROR)) {
|
||||
player.sendMessage(s.replace("THE_CAPTCHA", plugin.cap.get(playerNameLowerCase)));
|
||||
}
|
||||
return true;
|
||||
@ -73,8 +65,8 @@ public class CaptchaCommand extends ExecutableCommand {
|
||||
plugin.cap.remove(playerNameLowerCase);
|
||||
|
||||
// Show a status message
|
||||
m.send(player, "valid_captcha");
|
||||
m.send(player, "login_msg");
|
||||
m.send(player, MessageKey.CAPTCHA_SUCCESS);
|
||||
m.send(player, MessageKey.LOGIN_MESSAGE);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user