mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-12-22 00:27:36 +01:00
Merge branch 'master' of https://github.com/AuthMe-Team/AuthMeReloaded into 450-new-settings-rewrite
Conflicts: src/main/java/fr/xephi/authme/AuthMe.java src/main/java/fr/xephi/authme/settings/Settings.java src/main/java/fr/xephi/authme/settings/custom/NewSetting.java
This commit is contained in:
commit
85868ca830
@ -14,6 +14,7 @@
|
|||||||
- Build status: [![Build Status](https://travis-ci.org/Xephi/AuthMeReloaded.svg?branch=master)](https://travis-ci.org/Xephi/AuthMeReloaded) [![Dependency Status](https://www.versioneye.com/user/projects/55bab9e8653762002000190a/badge.svg?style=flat)](https://www.versioneye.com/user/projects/55bab9e8653762002000190a)
|
- Build status: [![Build Status](https://travis-ci.org/Xephi/AuthMeReloaded.svg?branch=master)](https://travis-ci.org/Xephi/AuthMeReloaded) [![Dependency Status](https://www.versioneye.com/user/projects/55bab9e8653762002000190a/badge.svg?style=flat)](https://www.versioneye.com/user/projects/55bab9e8653762002000190a)
|
||||||
|
|
||||||
- Build status (CircleCI): [![Circle CI](https://circleci.com/gh/Xephi/AuthMeReloaded.svg?style=svg)](https://circleci.com/gh/Xephi/AuthMeReloaded)
|
- Build status (CircleCI): [![Circle CI](https://circleci.com/gh/Xephi/AuthMeReloaded.svg?style=svg)](https://circleci.com/gh/Xephi/AuthMeReloaded)
|
||||||
|
- Alternative Dev Build download link (via CircleCi): <a href="https://circleci-tkn.rhcloud.com/api/v1/project/AuthMe-Team/AuthMeReloaded/tree/master/latest/artifacts/AuthMe.jar">Download</a>
|
||||||
|
|
||||||
- Code Coverage: [![Coverage Status](https://coveralls.io/repos/AuthMe-Team/AuthMeReloaded/badge.svg?branch=master&service=github)](https://coveralls.io/github/AuthMe-Team/AuthMeReloaded?branch=master)
|
- Code Coverage: [![Coverage Status](https://coveralls.io/repos/AuthMe-Team/AuthMeReloaded/badge.svg?branch=master&service=github)](https://coveralls.io/github/AuthMe-Team/AuthMeReloaded?branch=master)
|
||||||
|
|
||||||
|
@ -7,7 +7,9 @@ general:
|
|||||||
test:
|
test:
|
||||||
override:
|
override:
|
||||||
- mvn clean install -B
|
- mvn clean install -B
|
||||||
|
post:
|
||||||
|
- cp ./target/AuthMe*.jar $CIRCLE_ARTIFACTS
|
||||||
|
- cp ./target/AuthMe-*-SNAPSHOT.jar $CIRCLE_ARTIFACTS/AuthMe.jar
|
||||||
notify:
|
notify:
|
||||||
webhooks:
|
webhooks:
|
||||||
- url: https://webhooks.gitter.im/e/7b92ac1a1741748b26bf
|
- url: https://webhooks.gitter.im/e/7b92ac1a1741748b26bf
|
||||||
|
8
pom.xml
8
pom.xml
@ -129,7 +129,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.3</version>
|
<version>3.5</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.7</source>
|
<source>1.7</source>
|
||||||
<target>${javaVersion}</target>
|
<target>${javaVersion}</target>
|
||||||
@ -140,7 +140,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
<version>2.4.2</version>
|
<version>2.4.3</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||||
<minimizeJar>false</minimizeJar>
|
<minimizeJar>false</minimizeJar>
|
||||||
@ -298,7 +298,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>slf4j-jdk14</artifactId>
|
<artifactId>slf4j-jdk14</artifactId>
|
||||||
<version>1.7.13</version>
|
<version>1.7.14</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
@ -335,7 +335,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.maxmind.geoip</groupId>
|
<groupId>com.maxmind.geoip</groupId>
|
||||||
<artifactId>geoip-api</artifactId>
|
<artifactId>geoip-api</artifactId>
|
||||||
<version>1.2.15</version>
|
<version>1.3.0</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
@ -1,9 +1,35 @@
|
|||||||
package fr.xephi.authme;
|
package fr.xephi.authme;
|
||||||
|
|
||||||
import com.earth2me.essentials.Essentials;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import com.google.common.base.Charsets;
|
import com.google.common.base.Charsets;
|
||||||
import com.google.common.io.Resources;
|
import com.google.common.io.Resources;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Server;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.PluginManager;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
|
import com.earth2me.essentials.Essentials;
|
||||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||||
|
import net.minelink.ctplus.CombatTagPlus;
|
||||||
|
|
||||||
import fr.xephi.authme.api.API;
|
import fr.xephi.authme.api.API;
|
||||||
import fr.xephi.authme.api.NewAPI;
|
import fr.xephi.authme.api.NewAPI;
|
||||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||||
@ -58,33 +84,6 @@ import fr.xephi.authme.util.GeoLiteAPI;
|
|||||||
import fr.xephi.authme.util.StringUtils;
|
import fr.xephi.authme.util.StringUtils;
|
||||||
import fr.xephi.authme.util.Utils;
|
import fr.xephi.authme.util.Utils;
|
||||||
import fr.xephi.authme.util.Wrapper;
|
import fr.xephi.authme.util.Wrapper;
|
||||||
import net.minelink.ctplus.CombatTagPlus;
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.Server;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.plugin.PluginManager;
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
|
||||||
import org.mcstats.Metrics;
|
|
||||||
import org.mcstats.Metrics.Graph;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import static fr.xephi.authme.settings.properties.EmailSettings.MAIL_ACCOUNT;
|
import static fr.xephi.authme.settings.properties.EmailSettings.MAIL_ACCOUNT;
|
||||||
import static fr.xephi.authme.settings.properties.EmailSettings.MAIL_PASSWORD;
|
import static fr.xephi.authme.settings.properties.EmailSettings.MAIL_PASSWORD;
|
||||||
@ -213,7 +212,7 @@ public class AuthMe extends JavaPlugin {
|
|||||||
|
|
||||||
// Load settings and custom configurations, if it fails, stop the server due to security reasons.
|
// Load settings and custom configurations, if it fails, stop the server due to security reasons.
|
||||||
newSettings = createNewSetting();
|
newSettings = createNewSetting();
|
||||||
if (loadSettings()) {
|
if (!loadSettings()) {
|
||||||
server.shutdown();
|
server.shutdown();
|
||||||
setEnabled(false);
|
setEnabled(false);
|
||||||
return;
|
return;
|
||||||
@ -225,9 +224,8 @@ public class AuthMe extends JavaPlugin {
|
|||||||
try {
|
try {
|
||||||
setupDatabase();
|
setupDatabase();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
ConsoleLogger.writeStackTrace(e);
|
ConsoleLogger.logException("Fatal error occurred during database connection! "
|
||||||
ConsoleLogger.showError(e.getMessage());
|
+ "Authme initialization aborted!", e);
|
||||||
ConsoleLogger.showError("Fatal error occurred during database connection! Authme initialization ABORTED!");
|
|
||||||
stopOrUnload();
|
stopOrUnload();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -242,9 +240,8 @@ public class AuthMe extends JavaPlugin {
|
|||||||
// Setup otherAccounts file
|
// Setup otherAccounts file
|
||||||
this.otherAccounts = OtherAccounts.getInstance();
|
this.otherAccounts = OtherAccounts.getInstance();
|
||||||
|
|
||||||
|
|
||||||
// Set up Metrics
|
// Set up Metrics
|
||||||
setupMetrics();
|
MetricsStarter.setupMetrics(plugin, newSettings);
|
||||||
|
|
||||||
// Set console filter
|
// Set console filter
|
||||||
setupConsoleFilter();
|
setupConsoleFilter();
|
||||||
@ -429,12 +426,11 @@ public class AuthMe extends JavaPlugin {
|
|||||||
try {
|
try {
|
||||||
settings = new Settings(this);
|
settings = new Settings(this);
|
||||||
Settings.reload();
|
Settings.reload();
|
||||||
} catch (Exception e) {
|
|
||||||
ConsoleLogger.writeStackTrace(e);
|
|
||||||
ConsoleLogger.showError("Can't load the configuration file... Something went wrong. "
|
|
||||||
+ "To avoid security issues the server will shut down!");
|
|
||||||
server.shutdown();
|
|
||||||
return true;
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
ConsoleLogger.logException("Can't load the configuration file... Something went wrong. "
|
||||||
|
+ "To avoid security issues the server will shut down!", e);
|
||||||
|
server.shutdown();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -463,46 +459,6 @@ public class AuthMe extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set up Metrics.
|
|
||||||
*/
|
|
||||||
private void setupMetrics() {
|
|
||||||
try {
|
|
||||||
Metrics metrics = new Metrics(this);
|
|
||||||
Graph languageGraph = metrics.createGraph("Messages language");
|
|
||||||
Graph backendGraph = metrics.createGraph("Database backend");
|
|
||||||
|
|
||||||
// Custom graphs
|
|
||||||
if (newSettings.getMessagesFile().exists()) {
|
|
||||||
String messagesLanguage = newSettings.getProperty(PluginSettings.MESSAGES_LANGUAGE);
|
|
||||||
languageGraph.addPlotter(new Metrics.Plotter(messagesLanguage) {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getValue() {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
DataSource.DataSourceType dataSource = newSettings.getProperty(DatabaseSettings.BACKEND);
|
|
||||||
backendGraph.addPlotter(new Metrics.Plotter(dataSource.toString()) {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getValue() {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
metrics.start();
|
|
||||||
ConsoleLogger.info("Metrics started successfully!");
|
|
||||||
} catch (Exception e) {
|
|
||||||
// Failed to submit the metrics data
|
|
||||||
ConsoleLogger.showError("Can't start Metrics! The plugin will work anyway... (Encountered "
|
|
||||||
+ StringUtils.formatException(e) + ")");
|
|
||||||
ConsoleLogger.writeStackTrace(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
// Save player data
|
// Save player data
|
||||||
@ -516,40 +472,6 @@ public class AuthMe extends JavaPlugin {
|
|||||||
new PerformBackup(plugin, newSettings).doBackup(PerformBackup.BackupCause.STOP);
|
new PerformBackup(plugin, newSettings).doBackup(PerformBackup.BackupCause.STOP);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<BukkitTask> pendingTasks = getServer().getScheduler().getPendingTasks();
|
|
||||||
for (Iterator<BukkitTask> iterator = pendingTasks.iterator(); iterator.hasNext();) {
|
|
||||||
BukkitTask pendingTask = iterator.next();
|
|
||||||
if (!pendingTask.getOwner().equals(this) || pendingTask.isSync()) {
|
|
||||||
//remove all irrelevant tasks
|
|
||||||
iterator.remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
getLogger().log(Level.INFO, "Waiting for {0} tasks to finish", pendingTasks.size());
|
|
||||||
int progress = 0;
|
|
||||||
try {
|
|
||||||
for (BukkitTask pendingTask : pendingTasks) {
|
|
||||||
int maxTries = 5;
|
|
||||||
int taskId = pendingTask.getTaskId();
|
|
||||||
while (getServer().getScheduler().isCurrentlyRunning(taskId)) {
|
|
||||||
if (maxTries <= 0) {
|
|
||||||
getLogger().log(Level.INFO, "Async task {0} times out after to many tries", taskId);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
//one second
|
|
||||||
Thread.sleep(1000);
|
|
||||||
maxTries--;
|
|
||||||
}
|
|
||||||
|
|
||||||
progress++;
|
|
||||||
getLogger().log(Level.INFO, "Progress: {0} / {1}", new Object[]{progress, pendingTasks.size()});
|
|
||||||
}
|
|
||||||
} catch (InterruptedException interruptedException) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Close the database
|
// Close the database
|
||||||
if (database != null) {
|
if (database != null) {
|
||||||
database.close();
|
database.close();
|
||||||
|
@ -2,6 +2,7 @@ package fr.xephi.authme;
|
|||||||
|
|
||||||
import com.google.common.base.Throwables;
|
import com.google.common.base.Throwables;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
|
import fr.xephi.authme.util.StringUtils;
|
||||||
import fr.xephi.authme.util.Wrapper;
|
import fr.xephi.authme.util.Wrapper;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -32,10 +33,9 @@ public final class ConsoleLogger {
|
|||||||
*/
|
*/
|
||||||
public static void info(String message) {
|
public static void info(String message) {
|
||||||
wrapper.getLogger().info(message);
|
wrapper.getLogger().info(message);
|
||||||
if (!Settings.useLogging) {
|
if (Settings.useLogging) {
|
||||||
return;
|
writeLog(message);
|
||||||
}
|
}
|
||||||
writeLog("" + message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -45,10 +45,9 @@ public final class ConsoleLogger {
|
|||||||
*/
|
*/
|
||||||
public static void showError(String message) {
|
public static void showError(String message) {
|
||||||
wrapper.getLogger().warning(message);
|
wrapper.getLogger().warning(message);
|
||||||
if (!Settings.useLogging) {
|
if (Settings.useLogging) {
|
||||||
return;
|
writeLog("ERROR: " + message);
|
||||||
}
|
}
|
||||||
writeLog("ERROR: " + message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -72,12 +71,22 @@ public final class ConsoleLogger {
|
|||||||
/**
|
/**
|
||||||
* Write a StackTrace into the log.
|
* Write a StackTrace into the log.
|
||||||
*
|
*
|
||||||
* @param ex Exception
|
* @param th The Throwable whose stack trace should be logged
|
||||||
*/
|
*/
|
||||||
public static void writeStackTrace(Exception ex) {
|
public static void writeStackTrace(Throwable th) {
|
||||||
if (!Settings.useLogging) {
|
if (Settings.useLogging) {
|
||||||
return;
|
writeLog(Throwables.getStackTraceAsString(th));
|
||||||
}
|
}
|
||||||
writeLog(Throwables.getStackTraceAsString(ex));
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs a Throwable with the provided message and saves the stack trace to the log file.
|
||||||
|
*
|
||||||
|
* @param message The message to accompany the exception
|
||||||
|
* @param th The Throwable to log
|
||||||
|
*/
|
||||||
|
public static void logException(String message, Throwable th) {
|
||||||
|
showError(message + " " + StringUtils.formatException(th));
|
||||||
|
writeStackTrace(th);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
45
src/main/java/fr/xephi/authme/MetricsStarter.java
Normal file
45
src/main/java/fr/xephi/authme/MetricsStarter.java
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
package fr.xephi.authme;
|
||||||
|
|
||||||
|
import fr.xephi.authme.settings.NewSetting;
|
||||||
|
import fr.xephi.authme.settings.properties.DatabaseSettings;
|
||||||
|
import fr.xephi.authme.settings.properties.PluginSettings;
|
||||||
|
import org.mcstats.Metrics;
|
||||||
|
import org.mcstats.Metrics.Graph;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class MetricsStarter {
|
||||||
|
|
||||||
|
private MetricsStarter() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setupMetrics(AuthMe plugin, NewSetting settings) {
|
||||||
|
try {
|
||||||
|
final Metrics metrics = new Metrics(plugin);
|
||||||
|
|
||||||
|
final 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;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
final 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 start Metrics! The plugin will work anyway...", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -24,8 +24,7 @@ public class ReloadCommand implements ExecutableCommand {
|
|||||||
commandService.send(sender, MessageKey.CONFIG_RELOAD_SUCCESS);
|
commandService.send(sender, MessageKey.CONFIG_RELOAD_SUCCESS);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
sender.sendMessage("Error occurred during reload of AuthMe: aborting");
|
sender.sendMessage("Error occurred during reload of AuthMe: aborting");
|
||||||
ConsoleLogger.showError("Fatal error occurred! AuthMe instance ABORTED!");
|
ConsoleLogger.logException("Aborting! Encountered exception during reload of AuthMe:", e);
|
||||||
ConsoleLogger.writeStackTrace(e);
|
|
||||||
plugin.stopOrUnload();
|
plugin.stopOrUnload();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,8 +33,7 @@ public class RoyalAuthConverter implements Converter {
|
|||||||
PlayerAuth auth = new PlayerAuth(name, ra.getHash(), "127.0.0.1", ra.getLastLogin(), "your@email.com", o.getName());
|
PlayerAuth auth = new PlayerAuth(name, ra.getHash(), "127.0.0.1", ra.getLastLogin(), "your@email.com", o.getName());
|
||||||
data.saveAuth(auth);
|
data.saveAuth(auth);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
ConsoleLogger.writeStackTrace(e);
|
ConsoleLogger.logException("Error while trying to import " + o.getName() + " RoyalAuth data", e);
|
||||||
ConsoleLogger.showError("Error while trying to import " + o.getName() + " RoyalAuth datas");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@ -27,7 +28,7 @@ class vAuthFileReader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void convert() {
|
public void convert() {
|
||||||
final File file = new File(plugin.getDataFolder().getParent() + "" + File.separator + "vAuth" + File.separator + "passwords.yml");
|
final File file = new File(plugin.getDataFolder().getParent() + File.separator + "vAuth" + File.separator + "passwords.yml");
|
||||||
Scanner scanner;
|
Scanner scanner;
|
||||||
try {
|
try {
|
||||||
scanner = new Scanner(file);
|
scanner = new Scanner(file);
|
||||||
@ -52,8 +53,8 @@ class vAuthFileReader {
|
|||||||
database.saveAuth(auth);
|
database.saveAuth(auth);
|
||||||
}
|
}
|
||||||
scanner.close();
|
scanner.close();
|
||||||
} catch (Exception e) {
|
} catch (IOException e) {
|
||||||
ConsoleLogger.writeStackTrace(e);
|
ConsoleLogger.logException("Error while trying to import some vAuth data", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -63,12 +64,10 @@ class vAuthFileReader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String getName(UUID uuid) {
|
private String getName(UUID uuid) {
|
||||||
try {
|
for (OfflinePlayer op : Bukkit.getOfflinePlayers()) {
|
||||||
for (OfflinePlayer op : Bukkit.getOfflinePlayers()) {
|
if (op.getUniqueId().compareTo(uuid) == 0) {
|
||||||
if (op.getUniqueId().compareTo(uuid) == 0)
|
return op.getName();
|
||||||
return op.getName();
|
|
||||||
}
|
}
|
||||||
} catch (Exception ignored) {
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -5,17 +5,13 @@ import com.google.common.cache.CacheBuilder;
|
|||||||
import com.google.common.cache.CacheLoader;
|
import com.google.common.cache.CacheLoader;
|
||||||
import com.google.common.cache.LoadingCache;
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.cache.RemovalListener;
|
import com.google.common.cache.RemovalListener;
|
||||||
import com.google.common.cache.RemovalListeners;
|
|
||||||
import com.google.common.cache.RemovalNotification;
|
import com.google.common.cache.RemovalNotification;
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
|
||||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||||
import fr.xephi.authme.security.crypts.HashedPassword;
|
import fr.xephi.authme.security.crypts.HashedPassword;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.ExecutorService;
|
|
||||||
import java.util.concurrent.Executors;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -23,7 +19,6 @@ import java.util.concurrent.TimeUnit;
|
|||||||
public class CacheDataSource implements DataSource {
|
public class CacheDataSource implements DataSource {
|
||||||
|
|
||||||
private final DataSource source;
|
private final DataSource source;
|
||||||
private final ExecutorService exec;
|
|
||||||
private final LoadingCache<String, Optional<PlayerAuth>> cachedAuths;
|
private final LoadingCache<String, Optional<PlayerAuth>> cachedAuths;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -33,10 +28,9 @@ public class CacheDataSource implements DataSource {
|
|||||||
*/
|
*/
|
||||||
public CacheDataSource(DataSource src) {
|
public CacheDataSource(DataSource src) {
|
||||||
this.source = src;
|
this.source = src;
|
||||||
this.exec = Executors.newCachedThreadPool();
|
this.cachedAuths = CacheBuilder.newBuilder()
|
||||||
cachedAuths = CacheBuilder.newBuilder()
|
.expireAfterWrite(8, TimeUnit.MINUTES)
|
||||||
.expireAfterWrite(5, TimeUnit.MINUTES)
|
.removalListener(new RemovalListener<String, Optional<PlayerAuth>>() {
|
||||||
.removalListener(RemovalListeners.asynchronous(new RemovalListener<String, Optional<PlayerAuth>>() {
|
|
||||||
@Override
|
@Override
|
||||||
public void onRemoval(RemovalNotification<String, Optional<PlayerAuth>> removalNotification) {
|
public void onRemoval(RemovalNotification<String, Optional<PlayerAuth>> removalNotification) {
|
||||||
String name = removalNotification.getKey();
|
String name = removalNotification.getKey();
|
||||||
@ -44,7 +38,7 @@ public class CacheDataSource implements DataSource {
|
|||||||
cachedAuths.getUnchecked(name);
|
cachedAuths.getUnchecked(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, exec))
|
})
|
||||||
.build(
|
.build(
|
||||||
new CacheLoader<String, Optional<PlayerAuth>>() {
|
new CacheLoader<String, Optional<PlayerAuth>>() {
|
||||||
public Optional<PlayerAuth> load(String key) {
|
public Optional<PlayerAuth> load(String key) {
|
||||||
@ -168,24 +162,13 @@ public class CacheDataSource implements DataSource {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void close() {
|
public synchronized void close() {
|
||||||
try {
|
|
||||||
exec.shutdown();
|
|
||||||
exec.awaitTermination(8, TimeUnit.SECONDS);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
ConsoleLogger.writeStackTrace(e);
|
|
||||||
}
|
|
||||||
source.close();
|
source.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reload() { // unused method
|
public void reload() { // unused method
|
||||||
exec.execute(new Runnable() {
|
source.reload();
|
||||||
@Override
|
cachedAuths.invalidateAll();
|
||||||
public void run() {
|
|
||||||
source.reload();
|
|
||||||
cachedAuths.invalidateAll();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -214,13 +197,8 @@ public class CacheDataSource implements DataSource {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void purgeBanned(final List<String> banned) {
|
public synchronized void purgeBanned(final List<String> banned) {
|
||||||
exec.execute(new Runnable() {
|
source.purgeBanned(banned);
|
||||||
@Override
|
cachedAuths.invalidateAll(banned);
|
||||||
public void run() {
|
|
||||||
source.purgeBanned(banned);
|
|
||||||
cachedAuths.invalidateAll(banned);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -235,33 +213,18 @@ public class CacheDataSource implements DataSource {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setLogged(final String user) {
|
public void setLogged(final String user) {
|
||||||
exec.execute(new Runnable() {
|
source.setLogged(user.toLowerCase());
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
source.setLogged(user.toLowerCase());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setUnlogged(final String user) {
|
public void setUnlogged(final String user) {
|
||||||
exec.execute(new Runnable() {
|
source.setUnlogged(user.toLowerCase());
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
source.setUnlogged(user.toLowerCase());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void purgeLogged() {
|
public void purgeLogged() {
|
||||||
exec.execute(new Runnable() {
|
source.purgeLogged();
|
||||||
@Override
|
cachedAuths.invalidateAll();
|
||||||
public void run() {
|
|
||||||
source.purgeLogged();
|
|
||||||
cachedAuths.invalidateAll();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -270,14 +233,9 @@ public class CacheDataSource implements DataSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateName(final String oldOne, final String newOne) {
|
public void updateName(final String oldOne, final String newOne) { // unused method
|
||||||
exec.execute(new Runnable() {
|
source.updateName(oldOne, newOne);
|
||||||
@Override
|
cachedAuths.invalidate(oldOne);
|
||||||
public void run() {
|
|
||||||
source.updateName(oldOne, newOne);
|
|
||||||
cachedAuths.invalidate(oldOne);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -257,8 +257,7 @@ public class MySQL implements DataSource {
|
|||||||
ResultSet rs = pst.executeQuery();
|
ResultSet rs = pst.executeQuery();
|
||||||
return rs.next();
|
return rs.next();
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
logSqlException(ex);
|
||||||
ConsoleLogger.writeStackTrace(ex);
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -276,8 +275,7 @@ public class MySQL implements DataSource {
|
|||||||
!columnSalt.isEmpty() ? rs.getString(columnSalt) : null);
|
!columnSalt.isEmpty() ? rs.getString(columnSalt) : null);
|
||||||
}
|
}
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
logSqlException(ex);
|
||||||
ConsoleLogger.writeStackTrace(ex);
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -322,8 +320,7 @@ public class MySQL implements DataSource {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
logSqlException(ex);
|
||||||
ConsoleLogger.writeStackTrace(ex);
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return pAuth;
|
return pAuth;
|
||||||
@ -525,8 +522,7 @@ public class MySQL implements DataSource {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
logSqlException(ex);
|
||||||
ConsoleLogger.writeStackTrace(ex);
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -589,8 +585,7 @@ public class MySQL implements DataSource {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
logSqlException(ex);
|
||||||
ConsoleLogger.writeStackTrace(ex);
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -623,8 +618,7 @@ public class MySQL implements DataSource {
|
|||||||
pst.setLong(1, until);
|
pst.setLong(1, until);
|
||||||
result = pst.executeUpdate();
|
result = pst.executeUpdate();
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
logSqlException(ex);
|
||||||
ConsoleLogger.writeStackTrace(ex);
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -647,8 +641,7 @@ public class MySQL implements DataSource {
|
|||||||
st.executeUpdate();
|
st.executeUpdate();
|
||||||
st.close();
|
st.close();
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
logSqlException(ex);
|
||||||
ConsoleLogger.writeStackTrace(ex);
|
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
@ -680,8 +673,7 @@ public class MySQL implements DataSource {
|
|||||||
pst.executeUpdate();
|
pst.executeUpdate();
|
||||||
return true;
|
return true;
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
logSqlException(ex);
|
||||||
ConsoleLogger.writeStackTrace(ex);
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -702,8 +694,7 @@ public class MySQL implements DataSource {
|
|||||||
pst.close();
|
pst.close();
|
||||||
return true;
|
return true;
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
logSqlException(ex);
|
||||||
ConsoleLogger.writeStackTrace(ex);
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -722,8 +713,7 @@ public class MySQL implements DataSource {
|
|||||||
rs.close();
|
rs.close();
|
||||||
pst.close();
|
pst.close();
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
logSqlException(ex);
|
||||||
ConsoleLogger.writeStackTrace(ex);
|
|
||||||
}
|
}
|
||||||
return countIp;
|
return countIp;
|
||||||
}
|
}
|
||||||
@ -739,8 +729,7 @@ public class MySQL implements DataSource {
|
|||||||
pst.close();
|
pst.close();
|
||||||
return true;
|
return true;
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
logSqlException(ex);
|
||||||
ConsoleLogger.writeStackTrace(ex);
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -750,9 +739,8 @@ public class MySQL implements DataSource {
|
|||||||
try {
|
try {
|
||||||
reloadArguments();
|
reloadArguments();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
ConsoleLogger.logException("Can't reconnect to MySQL database... " +
|
||||||
ConsoleLogger.showError("Can't reconnect to MySQL database... Please check your MySQL configuration!");
|
"Please check your MySQL configuration! Encountered", ex);
|
||||||
ConsoleLogger.writeStackTrace(ex);
|
|
||||||
AuthMe.getInstance().stopOrUnload();
|
AuthMe.getInstance().stopOrUnload();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -778,8 +766,7 @@ public class MySQL implements DataSource {
|
|||||||
rs.close();
|
rs.close();
|
||||||
pst.close();
|
pst.close();
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
logSqlException(ex);
|
||||||
ConsoleLogger.writeStackTrace(ex);
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -798,8 +785,7 @@ public class MySQL implements DataSource {
|
|||||||
rs.close();
|
rs.close();
|
||||||
pst.close();
|
pst.close();
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
logSqlException(ex);
|
||||||
ConsoleLogger.writeStackTrace(ex);
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -818,8 +804,7 @@ public class MySQL implements DataSource {
|
|||||||
rs.close();
|
rs.close();
|
||||||
pst.close();
|
pst.close();
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
logSqlException(ex);
|
||||||
ConsoleLogger.writeStackTrace(ex);
|
|
||||||
}
|
}
|
||||||
return countEmail;
|
return countEmail;
|
||||||
}
|
}
|
||||||
@ -834,8 +819,7 @@ public class MySQL implements DataSource {
|
|||||||
}
|
}
|
||||||
pst.close();
|
pst.close();
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
logSqlException(ex);
|
||||||
ConsoleLogger.writeStackTrace(ex);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -854,8 +838,7 @@ public class MySQL implements DataSource {
|
|||||||
ResultSet rs = pst.executeQuery();
|
ResultSet rs = pst.executeQuery();
|
||||||
isLogged = rs.next() && (rs.getInt(columnLogged) == 1);
|
isLogged = rs.next() && (rs.getInt(columnLogged) == 1);
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
logSqlException(ex);
|
||||||
ConsoleLogger.writeStackTrace(ex);
|
|
||||||
}
|
}
|
||||||
return isLogged;
|
return isLogged;
|
||||||
}
|
}
|
||||||
@ -870,8 +853,7 @@ public class MySQL implements DataSource {
|
|||||||
pst.executeUpdate();
|
pst.executeUpdate();
|
||||||
pst.close();
|
pst.close();
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
logSqlException(ex);
|
||||||
ConsoleLogger.writeStackTrace(ex);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -885,8 +867,7 @@ public class MySQL implements DataSource {
|
|||||||
pst.executeUpdate();
|
pst.executeUpdate();
|
||||||
pst.close();
|
pst.close();
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
logSqlException(ex);
|
||||||
ConsoleLogger.writeStackTrace(ex);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -899,9 +880,8 @@ public class MySQL implements DataSource {
|
|||||||
pst.setInt(2, 1);
|
pst.setInt(2, 1);
|
||||||
pst.executeUpdate();
|
pst.executeUpdate();
|
||||||
pst.close();
|
pst.close();
|
||||||
} catch (Exception ex) {
|
} catch (SQLException ex) {
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
logSqlException(ex);
|
||||||
ConsoleLogger.writeStackTrace(ex);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -916,9 +896,8 @@ public class MySQL implements DataSource {
|
|||||||
}
|
}
|
||||||
rs.close();
|
rs.close();
|
||||||
st.close();
|
st.close();
|
||||||
} catch (Exception ex) {
|
} catch (SQLException ex) {
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
logSqlException(ex);
|
||||||
ConsoleLogger.writeStackTrace(ex);
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -931,9 +910,8 @@ public class MySQL implements DataSource {
|
|||||||
pst.setString(1, newOne);
|
pst.setString(1, newOne);
|
||||||
pst.setString(2, oldOne);
|
pst.setString(2, oldOne);
|
||||||
pst.executeUpdate();
|
pst.executeUpdate();
|
||||||
} catch (Exception ex) {
|
} catch (SQLException ex) {
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
logSqlException(ex);
|
||||||
ConsoleLogger.writeStackTrace(ex);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -977,9 +955,8 @@ public class MySQL implements DataSource {
|
|||||||
pst.close();
|
pst.close();
|
||||||
rs.close();
|
rs.close();
|
||||||
st.close();
|
st.close();
|
||||||
} catch (Exception ex) {
|
} catch (SQLException ex) {
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
logSqlException(ex);
|
||||||
ConsoleLogger.writeStackTrace(ex);
|
|
||||||
}
|
}
|
||||||
return auths;
|
return auths;
|
||||||
}
|
}
|
||||||
@ -1021,11 +998,14 @@ public class MySQL implements DataSource {
|
|||||||
}
|
}
|
||||||
auths.add(pAuth);
|
auths.add(pAuth);
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (SQLException ex) {
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
logSqlException(ex);
|
||||||
ConsoleLogger.writeStackTrace(ex);
|
|
||||||
}
|
}
|
||||||
return auths;
|
return auths;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void logSqlException(SQLException e) {
|
||||||
|
ConsoleLogger.logException("Error during SQL operation:", e);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -170,8 +170,7 @@ public class SQLite implements DataSource {
|
|||||||
!columnSalt.isEmpty() ? rs.getString(columnSalt) : null);
|
!columnSalt.isEmpty() ? rs.getString(columnSalt) : null);
|
||||||
}
|
}
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
ConsoleLogger.logException("Error getting password:", ex);
|
||||||
ConsoleLogger.writeStackTrace(ex);
|
|
||||||
} finally {
|
} finally {
|
||||||
close(rs);
|
close(rs);
|
||||||
close(pst);
|
close(pst);
|
||||||
|
@ -108,6 +108,9 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
if (Settings.useEssentialsMotd && cmd.equals("/motd")) {
|
if (Settings.useEssentialsMotd && cmd.equals("/motd")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if(!Settings.isForcedRegistrationEnabled && Settings.allowAllCommandsIfRegIsOptional) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (Settings.allowCommands.contains(cmd)) {
|
if (Settings.allowCommands.contains(cmd)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -135,8 +135,7 @@ public class ModuleManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ConsoleLogger.writeStackTrace(ex);
|
ConsoleLogger.logException("Cannot load " + pathToJar.getName() + " jar file!", ex);
|
||||||
ConsoleLogger.showError("Cannot load " + pathToJar.getName() + " jar file !");
|
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
if (jarFile != null) {
|
if (jarFile != null) {
|
||||||
|
@ -49,6 +49,13 @@ public class ProcessSyncronousPlayerLogout implements Runnable {
|
|||||||
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
|
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void restoreSpeedEffect() {
|
||||||
|
if (Settings.isRemoveSpeedEnabled) {
|
||||||
|
player.setWalkSpeed(0.0F);
|
||||||
|
player.setFlySpeed(0.0F);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method run.
|
* Method run.
|
||||||
*
|
*
|
||||||
@ -77,6 +84,7 @@ public class ProcessSyncronousPlayerLogout implements Runnable {
|
|||||||
if (Settings.applyBlindEffect)
|
if (Settings.applyBlindEffect)
|
||||||
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, Settings.getRegistrationTimeout * 20, 2));
|
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, Settings.getRegistrationTimeout * 20, 2));
|
||||||
player.setOp(false);
|
player.setOp(false);
|
||||||
|
restoreSpeedEffect();
|
||||||
// Player is now logout... Time to fire event !
|
// Player is now logout... Time to fire event !
|
||||||
Bukkit.getServer().getPluginManager().callEvent(new LogoutEvent(player));
|
Bukkit.getServer().getPluginManager().callEvent(new LogoutEvent(player));
|
||||||
if (Settings.bungee)
|
if (Settings.bungee)
|
||||||
|
@ -85,8 +85,7 @@ public class AsyncRegister {
|
|||||||
passwordRegister();
|
passwordRegister();
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
ConsoleLogger.showError(e.getMessage());
|
ConsoleLogger.logException("Error during async register process", e);
|
||||||
ConsoleLogger.writeStackTrace(e);
|
|
||||||
m.send(player, MessageKey.ERROR);
|
m.send(player, MessageKey.ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,8 +77,7 @@ public abstract class CustomConfiguration extends YamlConfiguration {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
ConsoleLogger.writeStackTrace(e);
|
ConsoleLogger.logException("Failed to load config from JAR", e);
|
||||||
ConsoleLogger.showError("Failed to load config from JAR");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -181,8 +181,7 @@ public class NewSetting {
|
|||||||
writer.flush();
|
writer.flush();
|
||||||
writer.close();
|
writer.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
ConsoleLogger.showError("Could not save config file - " + StringUtils.formatException(e));
|
ConsoleLogger.logException("Could not save config file:", e);
|
||||||
ConsoleLogger.writeStackTrace(e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ public final class Settings {
|
|||||||
enableProtection, enableAntiBot, recallEmail, useWelcomeMessage,
|
enableProtection, enableAntiBot, recallEmail, useWelcomeMessage,
|
||||||
broadcastWelcomeMessage, forceRegKick, forceRegLogin,
|
broadcastWelcomeMessage, forceRegKick, forceRegLogin,
|
||||||
checkVeryGames, delayJoinLeaveMessages, noTeleport, applyBlindEffect,
|
checkVeryGames, delayJoinLeaveMessages, noTeleport, applyBlindEffect,
|
||||||
kickPlayersBeforeStopping,
|
kickPlayersBeforeStopping, allowAllCommandsIfRegIsOptional,
|
||||||
customAttributes, generateImage, isRemoveSpeedEnabled, preventOtherCase;
|
customAttributes, generateImage, isRemoveSpeedEnabled, preventOtherCase;
|
||||||
public static String getNickRegex, getUnloggedinGroup, getMySQLHost,
|
public static String getNickRegex, getUnloggedinGroup, getMySQLHost,
|
||||||
getMySQLPort, getMySQLUsername, getMySQLPassword, getMySQLDatabase,
|
getMySQLPort, getMySQLUsername, getMySQLPassword, getMySQLDatabase,
|
||||||
@ -189,6 +189,7 @@ public final class Settings {
|
|||||||
isStopEnabled = configFile.getBoolean("Security.SQLProblem.stopServer", true);
|
isStopEnabled = configFile.getBoolean("Security.SQLProblem.stopServer", true);
|
||||||
reloadSupport = configFile.getBoolean("Security.ReloadCommand.useReloadCommandSupport", true);
|
reloadSupport = configFile.getBoolean("Security.ReloadCommand.useReloadCommandSupport", true);
|
||||||
|
|
||||||
|
allowAllCommandsIfRegIsOptional = configFile.getBoolean("settings.restrictions.allowAllCommandsIfRegistrationIsOptional", false);
|
||||||
allowCommands = new ArrayList<>();
|
allowCommands = new ArrayList<>();
|
||||||
allowCommands.addAll(Arrays.asList("/login", "/l", "/register", "/reg", "/email", "/captcha"));
|
allowCommands.addAll(Arrays.asList("/login", "/l", "/register", "/reg", "/email", "/captcha"));
|
||||||
for (String cmd : configFile.getStringList("settings.restrictions.allowCommands")) {
|
for (String cmd : configFile.getStringList("settings.restrictions.allowCommands")) {
|
||||||
|
@ -18,13 +18,19 @@ public class RestrictionSettings implements SettingsClass {
|
|||||||
public static final Property<Boolean> ALLOW_CHAT =
|
public static final Property<Boolean> ALLOW_CHAT =
|
||||||
newProperty("settings.restrictions.allowChat", false);
|
newProperty("settings.restrictions.allowChat", false);
|
||||||
|
|
||||||
|
@Comment({
|
||||||
|
"Allow unlogged users to use all the commands if registration is not forced!",
|
||||||
|
"WARNING: use this only if you need it!)"})
|
||||||
|
public static final Property<Boolean> ALLOW_ALL_COMMANDS_IF_REGISTRATION_IS_OPTIONAL =
|
||||||
|
newProperty("settings.restrictions.allowAllCommandsIfRegistrationIsOptional", false);
|
||||||
|
|
||||||
@Comment("Allowed commands for unauthenticated players")
|
@Comment("Allowed commands for unauthenticated players")
|
||||||
public static final Property<List<String>> ALLOW_COMMANDS =
|
public static final Property<List<String>> ALLOW_COMMANDS =
|
||||||
newProperty(PropertyType.STRING_LIST, "settings.restrictions.allowCommands",
|
newProperty(PropertyType.STRING_LIST, "settings.restrictions.allowCommands",
|
||||||
"login", "register", "l", "reg", "email", "captcha");
|
"login", "register", "l", "reg", "email", "captcha");
|
||||||
|
|
||||||
@Comment("Max number of allowed registrations per IP")
|
@Comment("Max number of allowed registrations per IP")
|
||||||
// TODO ljacqu 20160109: If 0 == unlimited, add this fact ot the comment
|
// TODO ljacqu 20160109: If 0 == unlimited, add this fact to the comment
|
||||||
public static final Property<Integer> MAX_REGISTRATION_PER_IP =
|
public static final Property<Integer> MAX_REGISTRATION_PER_IP =
|
||||||
newProperty("settings.restrictions.maxRegPerIp", 1);
|
newProperty("settings.restrictions.maxRegPerIp", 1);
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ public class GeoLiteAPI {
|
|||||||
plugin.getLogger().info(LICENSE);
|
plugin.getLogger().info(LICENSE);
|
||||||
return true;
|
return true;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
// TODO ljacqu 20151123: Log the exception instead of just swallowing it
|
ConsoleLogger.logException("Could not find/download GeoLiteAPI", e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -63,7 +63,7 @@ public class GeoLiteAPI {
|
|||||||
output.close();
|
output.close();
|
||||||
input.close();
|
input.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
ConsoleLogger.writeStackTrace(e);
|
ConsoleLogger.logException("Could not download GeoLiteAPI", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -67,6 +67,9 @@ settings:
|
|||||||
# Care that this feature blocks also all the commands not
|
# Care that this feature blocks also all the commands not
|
||||||
# listed in the list below.
|
# listed in the list below.
|
||||||
allowChat: false
|
allowChat: false
|
||||||
|
# WARNING: use this only if you need it!
|
||||||
|
# Allow unlogged users to use all the commands if registration is not forced!
|
||||||
|
allowAllCommandsIfRegistrationIsOptional: false
|
||||||
# Commands allowed when a player is not authenticated
|
# Commands allowed when a player is not authenticated
|
||||||
allowCommands:
|
allowCommands:
|
||||||
- /login
|
- /login
|
||||||
|
@ -4,56 +4,56 @@ registered: '&aSikeres regisztráció. Üdvözöllek!'
|
|||||||
user_regged: '&cJátékosnév már regisztrálva'
|
user_regged: '&cJátékosnév már regisztrálva'
|
||||||
login_msg: '&cKérlek jelentkezz be: "/login jelszó"'
|
login_msg: '&cKérlek jelentkezz be: "/login jelszó"'
|
||||||
not_logged_in: '&cNem vagy bejelentkezve!'
|
not_logged_in: '&cNem vagy bejelentkezve!'
|
||||||
logout: '&cSikeresen kijelentkeztél'
|
logout: '&cSikeresen kijelentkeztél!'
|
||||||
usage_log: '&cBejelentkezés: /login jelszó'
|
usage_log: '&cBejelentkezés: /login <jelszó>'
|
||||||
unknown_user: User is not in database
|
unknown_user: '&cA kért felhasználó nem telálható az adatbázisban!'
|
||||||
reg_voluntarily: Regisztrálhatod beceneved a szerveren a következö parancsal "/register jelszó jelszó"
|
reg_voluntarily: Regisztrálhatod magad a szerveren a következö parancsal "/register <jelszó> <jelszó újra>"
|
||||||
reg_disabled: '&cRegisztráció letiltva'
|
reg_disabled: '&cRegisztráció letiltva!'
|
||||||
no_perm: '&cNincs engedélyed'
|
no_perm: '&cNincs jogod ehhez!'
|
||||||
usage_reg: '&cHasználat: /register jelszó jelszóújra'
|
usage_reg: '&cHasználat: /register <jelszó> <jelszó újra>'
|
||||||
password_error_nick: '&fYou can''t use your name as password'
|
password_error_nick: '&cNem használhatod a felhasználóneved jelszónak, kérlek válassz másikat...'
|
||||||
password_error_unsafe: '&fYou can''t use unsafe passwords'
|
password_error_unsafe: '&cA választott jelszó nem biztonságos, kérlek válassz másikat...'
|
||||||
unregistered: '&cRegisztráció sikeresen törölve!'
|
unregistered: '&cRegisztráció sikeresen törölve!'
|
||||||
same_nick: Ezen a játékosnéven már játszanak
|
same_nick: 'Ezzel a játékosnévvel már játszanak a szerveren.'
|
||||||
valid_session: '&cSession login'
|
valid_session: '&2A hálózati kapcsolat újraépítése megtörtént.'
|
||||||
pwd_changed: '&cJelszó cserélve!'
|
pwd_changed: '&cJelszó cserélve!'
|
||||||
reload: Beálítások és adatbázis újratöltve!
|
reload: 'Beálítások és adatbázis újratöltve!'
|
||||||
timeout: Bejelentkezési idötúllépés
|
timeout: 'Bejelentkezési időtúllépés!'
|
||||||
error: Hiba lépett fel; Lépj kapcsolatba a tulajjal'
|
error: 'Hiba lépett fel; Lépj kapcsolatba a tulajjal'
|
||||||
logged_in: '&cMár be vagy jelentkezve!'
|
logged_in: '&cMár be vagy jelentkezve!'
|
||||||
login: '&aSikeresen Beléptél! Üdvözöllek!!!'
|
login: '&aSikeresen beléptél!'
|
||||||
wrong_pwd: '&4Hibás jelszó'
|
wrong_pwd: '&4Hibás jelszó!'
|
||||||
user_unknown: '&cJátékosnév nem regisztrált'
|
user_unknown: '&cEz a felhasználó nincs regisztrálva!'
|
||||||
reg_msg: '&cKérlek Regisztrálj: "/register jelszó jelszóújra"'
|
reg_msg: '&cKérlek Regisztrálj: "/register jelszó jelszóújra"'
|
||||||
reg_email_msg: '&cPlease register with "/register <email> <confirmEmail>"'
|
reg_email_msg: '&cKérlek regisztrálj: "/register <Email> <Email újra>"'
|
||||||
unsafe_spawn: A kilépési helyzeted nem biztonságos, teleportálás a kezdö Spawnra.
|
unsafe_spawn: 'A kilépési helyzeted nem biztonságos, teleportálás a Spawnra.'
|
||||||
max_reg: Csak egy karakterrel Registrálhatsz!!!
|
max_reg: 'Csak egy karakterrel registrálhatsz!'
|
||||||
password_error: A jelszó nem illik össze
|
password_error: 'A két jelszó nem egyezik!'
|
||||||
invalid_session: Session Dataes doesnt corrispond Plaese wait the end of session
|
invalid_session: '&cAz IP címed megváltozott és a hálózati kapcsolatod lejárt. Kapcsolódj újra.'
|
||||||
pass_len: A jelszavad nem éri el a minimális hosszat
|
pass_len: 'A jelszavad nem éri el a minimális hosszúságot!'
|
||||||
vb_nonActiv: Your Account isent Activated yet check your Emails!
|
vb_nonActiv: '&cA felhasználód aktiválása még nem történt meg, ellenőrizd a leveleid!'
|
||||||
usage_changepassword: 'használat: /changepassword régiJelszó újJelszó'
|
usage_changepassword: 'Használat: /changepassword <régi Jelszó> <új Jelszó>'
|
||||||
name_len: '&cYour nickname is too Short or too long'
|
name_len: '&4A felhasználó neved túl hosszú, vagy túl rövid! Válassz másikat!'
|
||||||
regex: '&cYour nickname contains illegal characters. Allowed chars: REG_EX'
|
regex: '&4A felhasználóneved nem használható karaktereket tartalmaz. Elfogadott karakterek: REG_EX'
|
||||||
add_email: '&cPlease add your email with : /email add yourEmail confirmEmail'
|
add_email: '&3Kérlek add hozzá a felhasználódhoz az email címedet "/email add <Email címed> <Email címed ismét>"'
|
||||||
recovery_email: '&cForgot your password? Please use /email recovery <yourEmail>'
|
recovery_email: '&3Ha elfelejtetted a jelszavad, használd az: "/email recovery <regisztrált Email címed>"'
|
||||||
usage_captcha: '&cUsage: /captcha <theCaptcha>'
|
usage_captcha: '&3A bejelentkezéshez CAPTCHA szükséges, kérem használd a következő parancsot "/captcha <Captcha>"'
|
||||||
wrong_captcha: '&cWrong Captcha, please use : /captcha THE_CAPTCHA'
|
wrong_captcha: '&cHibás captcha, kérlek írd be a következő parancsot "/captcha THE_CAPTCHA" a chat-be!'
|
||||||
valid_captcha: '&cYour captcha is valid !'
|
valid_captcha: '&2Captcha sikeresen feloldva!'
|
||||||
kick_forvip: '&cA VIP Player join the full server!'
|
kick_forvip: '&3VIP játékos csatlakozott a szerverhez!'
|
||||||
kick_fullserver: '&cThe server is actually full, Sorry!'
|
kick_fullserver: '&4A szerver megtelt, próbálj csatlakozni később!'
|
||||||
usage_email_add: '&fUsage: /email add <email> <confirmEmail> '
|
usage_email_add: '&cHasználat: /email add <email> <Email újra>'
|
||||||
usage_email_change: '&fUsage: /email change <oldEmail> <newEmail> '
|
usage_email_change: '&cHasználat: /email change <régi Email> <új Email>'
|
||||||
usage_email_recovery: '&fUsage: /email recovery <Email>'
|
usage_email_recovery: '&cHasználat: /email recovery <email>'
|
||||||
new_email_invalid: '[AuthMe] New email invalid!'
|
new_email_invalid: '&cHibás az új email cím, próbáld újra!'
|
||||||
old_email_invalid: '[AuthMe] Old email invalid!'
|
old_email_invalid: '&cHibás a régi email cím, próbáld újra!'
|
||||||
email_invalid: '[AuthMe] Invalid Email'
|
email_invalid: '&cHibás az email cím, próbáld újra!'
|
||||||
email_added: '[AuthMe] Email Added !'
|
email_added: '&2Az email címed rögzítése sikeresen megtörtént!'
|
||||||
email_confirm: '[AuthMe] Confirm your Email !'
|
email_confirm: '&cKérlek ellenőrízd az email címedet!'
|
||||||
email_changed: '[AuthMe] Email Change !'
|
email_changed: '&2Az email cím cseréje sikeresen megtörtént!'
|
||||||
email_send: '[AuthMe] Recovery Email Send !'
|
email_send: '&2A jelszó visszaállításhoz szükséges emailt elküldtük! Ellenőrízd a leveleidet!'
|
||||||
country_banned: 'Your country is banned from this server'
|
email_exists: '&cA visszaállító emailt elküldtük! Hiba esetén újkérheted az alábbi parancs segítségével:'
|
||||||
antibot_auto_enabled: '[AuthMe] AntiBotMod automatically enabled due to massive connections!'
|
country_banned: '&4Az országod tiltólistán van ezen a szerveren!'
|
||||||
antibot_auto_disabled: '[AuthMe] AntiBotMod automatically disabled after %m Minutes, hope invasion stopped'
|
antibot_auto_enabled: '&4[AntiBot] Az AntiBot védelem bekapcsolt a nagy számú hálózati kapcsolat miatt!'
|
||||||
kick_antibot: 'AntiBot protection mode is enabled! You have to wait some minutes before joining the server.'
|
antibot_auto_disabled: '&2[AntiBot] Az AntiBot kikapcsol %m múlva!'
|
||||||
email_exists: '&cA recovery email was already sent! You can discard it and send a new one using the command below:'
|
kick_antibot: 'Az AntiBot védelem bekapcsolva! Kérünk várj pár másodpercet a csatlakozáshoz.'
|
||||||
|
Loading…
Reference in New Issue
Block a user