#450 Move Settings#loadEmailText and #getWelcomeMessage
This commit is contained in:
@@ -36,7 +36,8 @@ public class Management {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
new AsynchronousLogin(player, password, forceLogin, plugin, plugin.getDataSource()).process();
|
||||
new AsynchronousLogin(player, password, forceLogin, plugin, plugin.getDataSource(), settings)
|
||||
.process();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -56,7 +57,7 @@ public class Management {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
new AsyncRegister(player, password, email, plugin, plugin.getDataSource()).process();
|
||||
new AsyncRegister(player, password, email, plugin, plugin.getDataSource(), settings).process();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -11,8 +11,11 @@ import fr.xephi.authme.permission.PlayerPermission;
|
||||
import fr.xephi.authme.security.RandomString;
|
||||
import fr.xephi.authme.output.MessageKey;
|
||||
import fr.xephi.authme.output.Messages;
|
||||
import fr.xephi.authme.settings.NewSetting;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
||||
import fr.xephi.authme.task.MessageTask;
|
||||
import fr.xephi.authme.util.StringUtils;
|
||||
import fr.xephi.authme.util.Utils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -34,6 +37,7 @@ public class AsynchronousLogin {
|
||||
private final DataSource database;
|
||||
private final Messages m;
|
||||
private final String ip;
|
||||
private final NewSetting settings;
|
||||
|
||||
/**
|
||||
* Constructor for AsynchronousLogin.
|
||||
@@ -43,8 +47,10 @@ public class AsynchronousLogin {
|
||||
* @param forceLogin boolean
|
||||
* @param plugin AuthMe
|
||||
* @param data DataSource
|
||||
* @param settings The settings
|
||||
*/
|
||||
public AsynchronousLogin(Player player, String password, boolean forceLogin, AuthMe plugin, DataSource data) {
|
||||
public AsynchronousLogin(Player player, String password, boolean forceLogin, AuthMe plugin, DataSource data,
|
||||
NewSetting settings) {
|
||||
this.m = plugin.getMessages();
|
||||
this.player = player;
|
||||
this.name = player.getName().toLowerCase();
|
||||
@@ -54,6 +60,7 @@ public class AsynchronousLogin {
|
||||
this.plugin = plugin;
|
||||
this.database = data;
|
||||
this.ip = plugin.getIP(player);
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
protected boolean needsCaptcha() {
|
||||
@@ -98,7 +105,7 @@ public class AsynchronousLogin {
|
||||
msg = m.retrieve(MessageKey.REGISTER_MESSAGE);
|
||||
}
|
||||
BukkitTask msgT = Bukkit.getScheduler().runTaskAsynchronously(plugin,
|
||||
new MessageTask(plugin, name, msg, Settings.getWarnMessageInterval));
|
||||
new MessageTask(plugin, name, msg, settings.getProperty(RegistrationSettings.MESSAGE_INTERVAL)));
|
||||
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(msgT);
|
||||
}
|
||||
return null;
|
||||
@@ -165,12 +172,10 @@ public class AsynchronousLogin {
|
||||
if (!forceLogin)
|
||||
m.send(player, MessageKey.LOGIN_SUCCESS);
|
||||
|
||||
displayOtherAccounts(auth, player);
|
||||
displayOtherAccounts(auth);
|
||||
|
||||
if (Settings.recallEmail) {
|
||||
if (email == null || email.isEmpty() || email.equalsIgnoreCase("your@email.com")) {
|
||||
m.send(player, MessageKey.EMAIL_ADDED_SUCCESS);
|
||||
}
|
||||
if (Settings.recallEmail && (StringUtils.isEmpty(email) || "your@email.com".equalsIgnoreCase(email))) {
|
||||
m.send(player, MessageKey.EMAIL_ADDED_SUCCESS);
|
||||
}
|
||||
|
||||
if (!Settings.noConsoleSpam) {
|
||||
@@ -186,7 +191,7 @@ public class AsynchronousLogin {
|
||||
// task, we schedule it in the end
|
||||
// so that we can be sure, and have not to care if it might be
|
||||
// processed in other order.
|
||||
ProcessSyncPlayerLogin syncPlayerLogin = new ProcessSyncPlayerLogin(player, plugin, database);
|
||||
ProcessSyncPlayerLogin syncPlayerLogin = new ProcessSyncPlayerLogin(player, plugin, database, settings);
|
||||
if (syncPlayerLogin.getLimbo() != null) {
|
||||
if (syncPlayerLogin.getLimbo().getTimeoutTaskId() != null) {
|
||||
syncPlayerLogin.getLimbo().getTimeoutTaskId().cancel();
|
||||
@@ -215,7 +220,7 @@ public class AsynchronousLogin {
|
||||
}
|
||||
}
|
||||
|
||||
public void displayOtherAccounts(PlayerAuth auth, Player p) {
|
||||
public void displayOtherAccounts(PlayerAuth auth) {
|
||||
if (!Settings.displayOtherAccounts) {
|
||||
return;
|
||||
}
|
||||
@@ -223,30 +228,16 @@ public class AsynchronousLogin {
|
||||
return;
|
||||
}
|
||||
List<String> auths = this.database.getAllAuthsByName(auth);
|
||||
if (auths.isEmpty()) {
|
||||
if (auths.isEmpty() || auths.size() == 1) {
|
||||
return;
|
||||
}
|
||||
if (auths.size() == 1) {
|
||||
return;
|
||||
}
|
||||
StringBuilder message = new StringBuilder("[AuthMe] ");
|
||||
int i = 0;
|
||||
for (String account : auths) {
|
||||
i++;
|
||||
message.append(account);
|
||||
if (i != auths.size()) {
|
||||
message.append(", ");
|
||||
} else {
|
||||
message.append('.');
|
||||
}
|
||||
}
|
||||
|
||||
String message = "[AuthMe] " + StringUtils.join(", ", auths) + ".";
|
||||
for (Player player : Utils.getOnlinePlayers()) {
|
||||
if (plugin.getPermissionsManager().hasPermission(player, PlayerPermission.SEE_OTHER_ACCOUNTS)
|
||||
|| (player.getName().equals(this.player.getName())
|
||||
&& plugin.getPermissionsManager().hasPermission(player, PlayerPermission.SEE_OWN_ACCOUNTS))) {
|
||||
player.sendMessage("[AuthMe] The player " + auth.getNickname() + " has " + auths.size() + " accounts");
|
||||
player.sendMessage(message.toString());
|
||||
player.sendMessage(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package fr.xephi.authme.process.login;
|
||||
|
||||
import fr.xephi.authme.settings.NewSetting;
|
||||
import fr.xephi.authme.settings.properties.HooksSettings;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -24,6 +26,8 @@ import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.util.Utils;
|
||||
import fr.xephi.authme.util.Utils.GroupType;
|
||||
|
||||
import static fr.xephi.authme.settings.properties.RestrictionSettings.PROTECT_INVENTORY_BEFORE_LOGIN;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class ProcessSyncPlayerLogin implements Runnable {
|
||||
@@ -36,24 +40,26 @@ public class ProcessSyncPlayerLogin implements Runnable {
|
||||
private final DataSource database;
|
||||
private final PluginManager pm;
|
||||
private final JsonCache playerCache;
|
||||
private final NewSetting settings;
|
||||
|
||||
/**
|
||||
* Constructor for ProcessSyncPlayerLogin.
|
||||
*
|
||||
* @param player Player
|
||||
* @param plugin AuthMe
|
||||
* @param data DataSource
|
||||
* @param database DataSource
|
||||
*/
|
||||
public ProcessSyncPlayerLogin(Player player, AuthMe plugin,
|
||||
DataSource data) {
|
||||
DataSource database, NewSetting settings) {
|
||||
this.plugin = plugin;
|
||||
this.database = data;
|
||||
this.database = database;
|
||||
this.pm = plugin.getServer().getPluginManager();
|
||||
this.player = player;
|
||||
this.name = player.getName().toLowerCase();
|
||||
this.limbo = LimboCache.getInstance().getLimboPlayer(name);
|
||||
this.auth = database.getAuth(name);
|
||||
this.playerCache = new JsonCache();
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -152,7 +158,7 @@ public class ProcessSyncPlayerLogin implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
if (Settings.protectInventoryBeforeLogInEnabled) {
|
||||
if (settings.getProperty(PROTECT_INVENTORY_BEFORE_LOGIN)) {
|
||||
restoreInventory();
|
||||
}
|
||||
|
||||
@@ -188,27 +194,27 @@ public class ProcessSyncPlayerLogin implements Runnable {
|
||||
// Login is finish, display welcome message if we use email registration
|
||||
if (Settings.useWelcomeMessage && Settings.emailRegistration)
|
||||
if (Settings.broadcastWelcomeMessage) {
|
||||
for (String s : Settings.welcomeMsg) {
|
||||
for (String s : settings.getWelcomeMessage()) {
|
||||
Bukkit.getServer().broadcastMessage(plugin.replaceAllInfo(s, player));
|
||||
}
|
||||
} else {
|
||||
for (String s : Settings.welcomeMsg) {
|
||||
for (String s : settings.getWelcomeMessage()) {
|
||||
player.sendMessage(plugin.replaceAllInfo(s, player));
|
||||
}
|
||||
}
|
||||
|
||||
// Login is now finish , we can force all commands
|
||||
// Login is now finished; we can force all commands
|
||||
forceCommands();
|
||||
|
||||
sendTo();
|
||||
}
|
||||
|
||||
private void sendTo() {
|
||||
if (Settings.sendPlayerTo.isEmpty())
|
||||
return;
|
||||
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
||||
out.writeUTF("Connect");
|
||||
out.writeUTF(Settings.sendPlayerTo);
|
||||
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
|
||||
if (!settings.getProperty(HooksSettings.BUNGEECORD_SERVER).isEmpty()) {
|
||||
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
||||
out.writeUTF("Connect");
|
||||
out.writeUTF(settings.getProperty(HooksSettings.BUNGEECORD_SERVER));
|
||||
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import fr.xephi.authme.output.MessageKey;
|
||||
import fr.xephi.authme.output.Messages;
|
||||
import fr.xephi.authme.permission.PlayerPermission;
|
||||
import fr.xephi.authme.security.crypts.HashedPassword;
|
||||
import fr.xephi.authme.settings.NewSetting;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -24,8 +25,10 @@ public class AsyncRegister {
|
||||
private final AuthMe plugin;
|
||||
private final DataSource database;
|
||||
private final Messages m;
|
||||
private final NewSetting settings;
|
||||
|
||||
public AsyncRegister(Player player, String password, String email, AuthMe plugin, DataSource data) {
|
||||
public AsyncRegister(Player player, String password, String email, AuthMe plugin, DataSource data,
|
||||
NewSetting settings) {
|
||||
this.m = plugin.getMessages();
|
||||
this.player = player;
|
||||
this.password = password;
|
||||
@@ -34,6 +37,7 @@ public class AsyncRegister {
|
||||
this.plugin = plugin;
|
||||
this.database = data;
|
||||
this.ip = plugin.getIP(player);
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
private boolean preRegisterCheck() throws Exception {
|
||||
@@ -137,7 +141,7 @@ public class AsyncRegister {
|
||||
plugin.getManagement().performLogin(player, "dontneed", true);
|
||||
}
|
||||
plugin.otherAccounts.addPlayer(player.getUniqueId());
|
||||
ProcessSyncPasswordRegister sync = new ProcessSyncPasswordRegister(player, plugin);
|
||||
ProcessSyncPasswordRegister sync = new ProcessSyncPasswordRegister(player, plugin, settings);
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, sync);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package fr.xephi.authme.process.register;
|
||||
|
||||
import fr.xephi.authme.settings.NewSetting;
|
||||
import fr.xephi.authme.settings.properties.HooksSettings;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
@@ -30,6 +32,7 @@ public class ProcessSyncPasswordRegister implements Runnable {
|
||||
protected final String name;
|
||||
private final AuthMe plugin;
|
||||
private final Messages m;
|
||||
private final NewSetting settings;
|
||||
|
||||
/**
|
||||
* Constructor for ProcessSyncPasswordRegister.
|
||||
@@ -37,11 +40,12 @@ public class ProcessSyncPasswordRegister implements Runnable {
|
||||
* @param player Player
|
||||
* @param plugin AuthMe
|
||||
*/
|
||||
public ProcessSyncPasswordRegister(Player player, AuthMe plugin) {
|
||||
public ProcessSyncPasswordRegister(Player player, AuthMe plugin, NewSetting settings) {
|
||||
this.m = plugin.getMessages();
|
||||
this.player = player;
|
||||
this.name = player.getName().toLowerCase();
|
||||
this.plugin = plugin;
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
private void sendBungeeMessage() {
|
||||
@@ -63,11 +67,6 @@ public class ProcessSyncPasswordRegister implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method forceLogin.
|
||||
*
|
||||
* @param player Player
|
||||
*/
|
||||
private void forceLogin(Player player) {
|
||||
Utils.teleportToSpawn(player);
|
||||
LimboCache cache = LimboCache.getInstance();
|
||||
@@ -88,11 +87,6 @@ public class ProcessSyncPasswordRegister implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method run.
|
||||
*
|
||||
* @see java.lang.Runnable#run()
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(name);
|
||||
@@ -141,11 +135,11 @@ public class ProcessSyncPasswordRegister implements Runnable {
|
||||
// Register is finish and player is logged, display welcome message
|
||||
if (Settings.useWelcomeMessage) {
|
||||
if (Settings.broadcastWelcomeMessage) {
|
||||
for (String s : Settings.welcomeMsg) {
|
||||
for (String s : settings.getWelcomeMessage()) {
|
||||
plugin.getServer().broadcastMessage(plugin.replaceAllInfo(s, player));
|
||||
}
|
||||
} else {
|
||||
for (String s : Settings.welcomeMsg) {
|
||||
for (String s : settings.getWelcomeMessage()) {
|
||||
player.sendMessage(plugin.replaceAllInfo(s, player));
|
||||
}
|
||||
}
|
||||
@@ -161,18 +155,18 @@ public class ProcessSyncPasswordRegister implements Runnable {
|
||||
sendBungeeMessage();
|
||||
}
|
||||
|
||||
// Register is now finish , we can force all commands
|
||||
// Register is now finished; we can force all commands
|
||||
forceCommands();
|
||||
|
||||
sendTo();
|
||||
}
|
||||
|
||||
private void sendTo() {
|
||||
if (Settings.sendPlayerTo.isEmpty())
|
||||
return;
|
||||
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
||||
out.writeUTF("Connect");
|
||||
out.writeUTF(Settings.sendPlayerTo);
|
||||
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
|
||||
if (!settings.getProperty(HooksSettings.BUNGEECORD_SERVER).isEmpty()) {
|
||||
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
||||
out.writeUTF("Connect");
|
||||
out.writeUTF(settings.getProperty(HooksSettings.BUNGEECORD_SERVER));
|
||||
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user