Merge branch 'master' of https://github.com/AuthMe-Team/AuthMeReloaded into 761-permission-groups
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package fr.xephi.authme.data.limbo;
|
||||
|
||||
import fr.xephi.authme.data.backup.LimboPlayerStorage;
|
||||
import fr.xephi.authme.permission.PermissionsManager;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.settings.SpawnLoader;
|
||||
|
||||
+2
-3
@@ -1,4 +1,4 @@
|
||||
package fr.xephi.authme.data.backup;
|
||||
package fr.xephi.authme.data.limbo;
|
||||
|
||||
import com.google.common.io.Files;
|
||||
import com.google.gson.Gson;
|
||||
@@ -10,11 +10,10 @@ import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
import com.google.gson.JsonSerializer;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.data.limbo.LimboPlayer;
|
||||
import fr.xephi.authme.initialization.DataFolder;
|
||||
import fr.xephi.authme.permission.PermissionsManager;
|
||||
import fr.xephi.authme.settings.SpawnLoader;
|
||||
import fr.xephi.authme.service.BukkitService;
|
||||
import fr.xephi.authme.settings.SpawnLoader;
|
||||
import fr.xephi.authme.util.FileUtils;
|
||||
import fr.xephi.authme.util.PlayerUtils;
|
||||
import org.bukkit.Location;
|
||||
@@ -2,7 +2,7 @@ package fr.xephi.authme.initialization;
|
||||
|
||||
import fr.xephi.authme.data.auth.PlayerAuth;
|
||||
import fr.xephi.authme.data.auth.PlayerCache;
|
||||
import fr.xephi.authme.data.backup.LimboPlayerStorage;
|
||||
import fr.xephi.authme.data.limbo.LimboPlayerStorage;
|
||||
import fr.xephi.authme.data.limbo.LimboCache;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.service.PluginHookService;
|
||||
|
||||
@@ -6,6 +6,7 @@ import fr.xephi.authme.data.auth.PlayerAuth;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.message.MessageKey;
|
||||
import fr.xephi.authme.message.Messages;
|
||||
import fr.xephi.authme.metrics.Metrics;
|
||||
import fr.xephi.authme.output.ConsoleFilter;
|
||||
import fr.xephi.authme.output.Log4JFilter;
|
||||
import fr.xephi.authme.service.BukkitService;
|
||||
@@ -18,10 +19,8 @@ import fr.xephi.authme.util.StringUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.mcstats.Metrics;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.io.IOException;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static fr.xephi.authme.service.BukkitService.TICKS_PER_MINUTE;
|
||||
@@ -45,40 +44,28 @@ public class OnStartupTasks {
|
||||
}
|
||||
|
||||
public static void sendMetrics(AuthMe plugin, Settings settings) {
|
||||
try {
|
||||
final Metrics metrics = new Metrics(plugin);
|
||||
final Metrics metrics = new Metrics(plugin);
|
||||
|
||||
final Metrics.Graph languageGraph = metrics.createGraph("Messages Language");
|
||||
final String messagesLanguage = settings.getProperty(PluginSettings.MESSAGES_LANGUAGE);
|
||||
languageGraph.addPlotter(new Metrics.Plotter(messagesLanguage) {
|
||||
@Override
|
||||
public int getValue() {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new Metrics.SimplePie("messages_language") {
|
||||
@Override
|
||||
public String getValue() {
|
||||
return settings.getProperty(PluginSettings.MESSAGES_LANGUAGE);
|
||||
}
|
||||
});
|
||||
|
||||
final Metrics.Graph databaseBackend = metrics.createGraph("Database Backend");
|
||||
final String dataSource = settings.getProperty(DatabaseSettings.BACKEND).toString();
|
||||
databaseBackend.addPlotter(new Metrics.Plotter(dataSource) {
|
||||
@Override
|
||||
public int getValue() {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
|
||||
// Submit metrics
|
||||
metrics.start();
|
||||
} catch (IOException e) {
|
||||
// Failed to submit the metrics data
|
||||
ConsoleLogger.logException("Can't send Metrics data! The plugin will work anyway...", e);
|
||||
}
|
||||
metrics.addCustomChart(new Metrics.SimplePie("database_backend") {
|
||||
@Override
|
||||
public String getValue() {
|
||||
return settings.getProperty(DatabaseSettings.BACKEND).toString();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the console filter if enabled.
|
||||
*
|
||||
* @param settings the settings
|
||||
* @param logger the plugin logger
|
||||
* @param logger the plugin logger
|
||||
*/
|
||||
public static void setupConsoleFilter(Settings settings, Logger logger) {
|
||||
if (!settings.getProperty(SecuritySettings.REMOVE_PASSWORD_FROM_CONSOLE)) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package fr.xephi.authme.message;
|
||||
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.util.FileUtils;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
@@ -16,6 +17,7 @@ public class MessageFileHandler {
|
||||
// regular file
|
||||
private final String filename;
|
||||
private final FileConfiguration configuration;
|
||||
private final String updateAddition;
|
||||
// default file
|
||||
private final String defaultFile;
|
||||
private FileConfiguration defaultConfiguration;
|
||||
@@ -25,11 +27,15 @@ public class MessageFileHandler {
|
||||
*
|
||||
* @param file the file to use for messages
|
||||
* @param defaultFile the default file from the JAR to use if no message is found
|
||||
* @param updateCommand command to update the messages file (nullable) to show in error messages
|
||||
*/
|
||||
public MessageFileHandler(File file, String defaultFile) {
|
||||
public MessageFileHandler(File file, String defaultFile, String updateCommand) {
|
||||
this.filename = file.getName();
|
||||
this.configuration = YamlConfiguration.loadConfiguration(file);
|
||||
this.defaultFile = defaultFile;
|
||||
this.updateAddition = updateCommand == null
|
||||
? ""
|
||||
: " (or run " + updateCommand + ")";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -53,7 +59,7 @@ public class MessageFileHandler {
|
||||
|
||||
if (message == null) {
|
||||
ConsoleLogger.warning("Error getting message with key '" + key + "'. "
|
||||
+ "Please update your config file '" + filename + "' (or run /authme messages)");
|
||||
+ "Please update your config file '" + filename + "'" + updateAddition);
|
||||
return getDefault(key);
|
||||
}
|
||||
return message;
|
||||
@@ -78,7 +84,7 @@ public class MessageFileHandler {
|
||||
*/
|
||||
private String getDefault(String key) {
|
||||
if (defaultConfiguration == null) {
|
||||
InputStream stream = MessageFileHandler.class.getClassLoader().getResourceAsStream(defaultFile);
|
||||
InputStream stream = FileUtils.getResourceFromJar(defaultFile);
|
||||
defaultConfiguration = YamlConfiguration.loadConfiguration(new InputStreamReader(stream));
|
||||
}
|
||||
String message = defaultConfiguration.getString(key);
|
||||
|
||||
@@ -36,10 +36,23 @@ public class MessageFileHandlerProvider {
|
||||
* @return the message file handler
|
||||
*/
|
||||
public MessageFileHandler initializeHandler(Function<String, String> pathBuilder) {
|
||||
return initializeHandler(pathBuilder, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes a message file handler with the messages file of the configured language.
|
||||
* Ensures beforehand that the messages file exists or creates it otherwise.
|
||||
*
|
||||
* @param pathBuilder function taking the configured language code as argument and returning the messages file
|
||||
* @param updateCommand command to run to update the languages file (nullable)
|
||||
* @return the message file handler
|
||||
*/
|
||||
public MessageFileHandler initializeHandler(Function<String, String> pathBuilder, String updateCommand) {
|
||||
String language = settings.getProperty(PluginSettings.MESSAGES_LANGUAGE);
|
||||
return new MessageFileHandler(
|
||||
initializeFile(language, pathBuilder),
|
||||
pathBuilder.apply(DEFAULT_LANGUAGE));
|
||||
pathBuilder.apply(DEFAULT_LANGUAGE),
|
||||
updateCommand);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -53,7 +66,8 @@ public class MessageFileHandlerProvider {
|
||||
File initializeFile(String language, Function<String, String> pathBuilder) {
|
||||
String filePath = pathBuilder.apply(language);
|
||||
File file = new File(dataFolder, filePath);
|
||||
if (FileUtils.copyFileFromResource(file, filePath)) {
|
||||
// Check that JAR file exists to avoid logging an error
|
||||
if (FileUtils.getResourceFromJar(filePath) != null && FileUtils.copyFileFromResource(file, filePath)) {
|
||||
return file;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ public enum MessageKey {
|
||||
/** AntiBot protection mode is enabled! You have to wait some minutes before joining the server. */
|
||||
KICK_ANTIBOT("kick_antibot"),
|
||||
|
||||
/** Can't find the requested user in the database! */
|
||||
/** This user isn't registered! */
|
||||
UNKNOWN_USER("unknown_user"),
|
||||
|
||||
/** Your quit location was unsafe, you have been teleported to the world's spawnpoint. */
|
||||
@@ -26,7 +26,7 @@ public enum MessageKey {
|
||||
/** You're not logged in! */
|
||||
NOT_LOGGED_IN("not_logged_in"),
|
||||
|
||||
/** Usage: /login <password> */
|
||||
/** Usage: /login <password> */
|
||||
USAGE_LOGIN("usage_log"),
|
||||
|
||||
/** Wrong password! */
|
||||
@@ -56,19 +56,19 @@ public enum MessageKey {
|
||||
/** An unexpected error occurred, please contact an administrator! */
|
||||
ERROR("error"),
|
||||
|
||||
/** Please, login with the command "/login <password>" */
|
||||
/** Please, login with the command: /login <password> */
|
||||
LOGIN_MESSAGE("login_msg"),
|
||||
|
||||
/** Please, register to the server with the command "/register <password> <ConfirmPassword>" */
|
||||
/** Please, register to the server with the command: /register <password> <ConfirmPassword> */
|
||||
REGISTER_MESSAGE("reg_msg"),
|
||||
|
||||
/** You have exceeded the maximum number of registrations (%reg_count/%max_acc %reg_names) for your connection! */
|
||||
MAX_REGISTER_EXCEEDED("max_reg", "%max_acc", "%reg_count", "%reg_names"),
|
||||
|
||||
/** Usage: /register <password> <ConfirmPassword> */
|
||||
/** Usage: /register <password> <ConfirmPassword> */
|
||||
USAGE_REGISTER("usage_reg"),
|
||||
|
||||
/** Usage: /unregister <password> */
|
||||
/** Usage: /unregister <password> */
|
||||
USAGE_UNREGISTER("usage_unreg"),
|
||||
|
||||
/** Password changed successfully! */
|
||||
@@ -95,7 +95,7 @@ public enum MessageKey {
|
||||
/** You're already logged in! */
|
||||
ALREADY_LOGGED_IN_ERROR("logged_in"),
|
||||
|
||||
/** Logged-out successfully! */
|
||||
/** Logged out successfully! */
|
||||
LOGOUT_SUCCESS("logout"),
|
||||
|
||||
/** The same username is already playing on the server! */
|
||||
@@ -113,7 +113,7 @@ public enum MessageKey {
|
||||
/** Login timeout exceeded, you have been kicked from the server, please try again! */
|
||||
LOGIN_TIMEOUT_ERROR("timeout"),
|
||||
|
||||
/** Usage: /changepassword <oldPassword> <newPassword> */
|
||||
/** Usage: /changepassword <oldPassword> <newPassword> */
|
||||
USAGE_CHANGE_PASSWORD("usage_changepassword"),
|
||||
|
||||
/** Your username is either too short or too long! */
|
||||
@@ -122,13 +122,13 @@ public enum MessageKey {
|
||||
/** Your username contains illegal characters. Allowed chars: REG_EX */
|
||||
INVALID_NAME_CHARACTERS("regex", "REG_EX"),
|
||||
|
||||
/** Please add your email to your account with the command "/email add <yourEmail> <confirmEmail>" */
|
||||
/** Please add your email to your account with the command: /email add <yourEmail> <confirmEmail> */
|
||||
ADD_EMAIL_MESSAGE("add_email"),
|
||||
|
||||
/** Forgot your password? Please use the command "/email recovery <yourEmail>" */
|
||||
/** Forgot your password? Please use the command: /email recovery <yourEmail> */
|
||||
FORGOT_PASSWORD_MESSAGE("recovery_email"),
|
||||
|
||||
/** To login you have to solve a captcha code, please use the command "/captcha <theCaptcha>" */
|
||||
/** To login you have to solve a captcha code, please use the command: /captcha <theCaptcha> */
|
||||
USAGE_CAPTCHA("usage_captcha", "<theCaptcha>"),
|
||||
|
||||
/** Wrong captcha, please type "/captcha THE_CAPTCHA" into the chat! */
|
||||
@@ -143,13 +143,13 @@ public enum MessageKey {
|
||||
/** The server is full, try again later! */
|
||||
KICK_FULL_SERVER("kick_fullserver"),
|
||||
|
||||
/** Usage: /email add <email> <confirmEmail> */
|
||||
/** Usage: /email add <email> <confirmEmail> */
|
||||
USAGE_ADD_EMAIL("usage_email_add"),
|
||||
|
||||
/** Usage: /email change <oldEmail> <newEmail> */
|
||||
/** Usage: /email change <oldEmail> <newEmail> */
|
||||
USAGE_CHANGE_EMAIL("usage_email_change"),
|
||||
|
||||
/** Usage: /email recovery <Email> */
|
||||
/** Usage: /email recovery <Email> */
|
||||
USAGE_RECOVER_EMAIL("usage_email_recovery"),
|
||||
|
||||
/** Invalid new email, try again! */
|
||||
@@ -224,7 +224,7 @@ public enum MessageKey {
|
||||
/** A recovery code to reset your password has been sent to your email. */
|
||||
RECOVERY_CODE_SENT("recovery_code_sent"),
|
||||
|
||||
/** The recovery code is not correct! Use /email recovery [email] to generate a new one */
|
||||
/** The recovery code is not correct! Use "/email recovery [email]" to generate a new one */
|
||||
INCORRECT_RECOVERY_CODE("recovery_code_incorrect");
|
||||
|
||||
private String key;
|
||||
|
||||
@@ -107,7 +107,7 @@ public class Messages implements Reloadable {
|
||||
@Override
|
||||
public void reload() {
|
||||
this.messageFileHandler = messageFileHandlerProvider
|
||||
.initializeHandler(lang -> "messages/messages_" + lang + ".yml");
|
||||
.initializeHandler(lang -> "messages/messages_" + lang + ".yml", "/authme messages");
|
||||
}
|
||||
|
||||
private static String formatMessage(String message) {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
package fr.xephi.authme.process.quit;
|
||||
|
||||
import fr.xephi.authme.data.backup.LimboPlayerStorage;
|
||||
import fr.xephi.authme.data.limbo.LimboPlayerStorage;
|
||||
import fr.xephi.authme.data.limbo.LimboCache;
|
||||
import fr.xephi.authme.process.SynchronousProcess;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -30,7 +30,6 @@ public class AntiBotService implements SettingsDependent {
|
||||
// Settings
|
||||
private int duration;
|
||||
private int sensibility;
|
||||
private int delay;
|
||||
private int interval;
|
||||
// Service status
|
||||
private AntiBotStatus antiBotStatus;
|
||||
@@ -60,7 +59,6 @@ public class AntiBotService implements SettingsDependent {
|
||||
// Load settings
|
||||
duration = settings.getProperty(ProtectionSettings.ANTIBOT_DURATION);
|
||||
sensibility = settings.getProperty(ProtectionSettings.ANTIBOT_SENSIBILITY);
|
||||
delay = settings.getProperty(ProtectionSettings.ANTIBOT_DELAY);
|
||||
interval = settings.getProperty(ProtectionSettings.ANTIBOT_INTERVAL);
|
||||
|
||||
// Stop existing protection
|
||||
@@ -77,6 +75,7 @@ public class AntiBotService implements SettingsDependent {
|
||||
|
||||
// Delay the schedule on first start
|
||||
if (startup) {
|
||||
int delay = settings.getProperty(ProtectionSettings.ANTIBOT_DELAY);
|
||||
bukkitService.scheduleSyncDelayedTask(enableTask, delay * TICKS_PER_SECOND);
|
||||
startup = false;
|
||||
} else {
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
package fr.xephi.authme.settings;
|
||||
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.service.PluginHookService;
|
||||
import fr.xephi.authme.initialization.DataFolder;
|
||||
import fr.xephi.authme.initialization.Reloadable;
|
||||
import fr.xephi.authme.service.PluginHookService;
|
||||
import fr.xephi.authme.settings.properties.HooksSettings;
|
||||
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
||||
import fr.xephi.authme.util.FileUtils;
|
||||
@@ -43,11 +42,9 @@ public class SpawnLoader implements Reloadable {
|
||||
* @param pluginFolder The AuthMe data folder
|
||||
* @param settings The setting instance
|
||||
* @param pluginHookService The plugin hooks instance
|
||||
* @param dataSource The plugin auth database instance
|
||||
*/
|
||||
@Inject
|
||||
SpawnLoader(@DataFolder File pluginFolder, Settings settings, PluginHookService pluginHookService,
|
||||
DataSource dataSource) {
|
||||
SpawnLoader(@DataFolder File pluginFolder, Settings settings, PluginHookService pluginHookService) {
|
||||
// TODO ljacqu 20160312: Check if resource could be copied and handle the case if not
|
||||
File spawnFile = new File(pluginFolder, "spawn.yml");
|
||||
FileUtils.copyFileFromResource(spawnFile, "spawn.yml");
|
||||
|
||||
@@ -28,7 +28,7 @@ public class WrappedTagReplacer<T, A> {
|
||||
* @param allTags all available tags
|
||||
* @param items the items to apply the replacements on
|
||||
* @param stringGetter getter of the String property to adapt on the items
|
||||
* @param itemCreator a function of signature (T, String) -> T: the original item and the adapted String are passed
|
||||
* @param itemCreator a function taking (T, String): the original item and the adapted String, returning a new item
|
||||
*/
|
||||
public WrappedTagReplacer(Collection<Tag<A>> allTags,
|
||||
Collection<T> items,
|
||||
|
||||
Reference in New Issue
Block a user