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:
ljacqu 2016-02-05 23:28:06 +01:00
commit 85868ca830
23 changed files with 245 additions and 315 deletions

View File

@ -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 (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)

View File

@ -7,7 +7,9 @@ general:
test:
override:
- mvn clean install -B
post:
- cp ./target/AuthMe*.jar $CIRCLE_ARTIFACTS
- cp ./target/AuthMe-*-SNAPSHOT.jar $CIRCLE_ARTIFACTS/AuthMe.jar
notify:
webhooks:
- url: https://webhooks.gitter.im/e/7b92ac1a1741748b26bf

View File

@ -129,7 +129,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<version>3.5</version>
<configuration>
<source>1.7</source>
<target>${javaVersion}</target>
@ -140,7 +140,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.2</version>
<version>2.4.3</version>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<minimizeJar>false</minimizeJar>
@ -298,7 +298,7 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<version>1.7.13</version>
<version>1.7.14</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
@ -335,7 +335,7 @@
<dependency>
<groupId>com.maxmind.geoip</groupId>
<artifactId>geoip-api</artifactId>
<version>1.2.15</version>
<version>1.3.0</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>

View File

@ -1,9 +1,35 @@
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.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 net.minelink.ctplus.CombatTagPlus;
import fr.xephi.authme.api.API;
import fr.xephi.authme.api.NewAPI;
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.Utils;
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_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.
newSettings = createNewSetting();
if (loadSettings()) {
if (!loadSettings()) {
server.shutdown();
setEnabled(false);
return;
@ -225,9 +224,8 @@ public class AuthMe extends JavaPlugin {
try {
setupDatabase();
} catch (Exception e) {
ConsoleLogger.writeStackTrace(e);
ConsoleLogger.showError(e.getMessage());
ConsoleLogger.showError("Fatal error occurred during database connection! Authme initialization ABORTED!");
ConsoleLogger.logException("Fatal error occurred during database connection! "
+ "Authme initialization aborted!", e);
stopOrUnload();
return;
}
@ -242,9 +240,8 @@ public class AuthMe extends JavaPlugin {
// Setup otherAccounts file
this.otherAccounts = OtherAccounts.getInstance();
// Set up Metrics
setupMetrics();
MetricsStarter.setupMetrics(plugin, newSettings);
// Set console filter
setupConsoleFilter();
@ -429,12 +426,11 @@ public class AuthMe extends JavaPlugin {
try {
settings = new Settings(this);
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;
} 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;
}
@ -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
public void onDisable() {
// Save player data
@ -516,40 +472,6 @@ public class AuthMe extends JavaPlugin {
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
if (database != null) {
database.close();

View File

@ -2,6 +2,7 @@ package fr.xephi.authme;
import com.google.common.base.Throwables;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.util.StringUtils;
import fr.xephi.authme.util.Wrapper;
import java.io.IOException;
@ -32,10 +33,9 @@ public final class ConsoleLogger {
*/
public static void info(String message) {
wrapper.getLogger().info(message);
if (!Settings.useLogging) {
return;
if (Settings.useLogging) {
writeLog(message);
}
writeLog("" + message);
}
/**
@ -45,10 +45,9 @@ public final class ConsoleLogger {
*/
public static void showError(String message) {
wrapper.getLogger().warning(message);
if (!Settings.useLogging) {
return;
if (Settings.useLogging) {
writeLog("ERROR: " + message);
}
writeLog("ERROR: " + message);
}
/**
@ -72,12 +71,22 @@ public final class ConsoleLogger {
/**
* 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) {
if (!Settings.useLogging) {
return;
public static void writeStackTrace(Throwable th) {
if (Settings.useLogging) {
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);
}
}

View 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);
}
}
}

View File

@ -24,8 +24,7 @@ public class ReloadCommand implements ExecutableCommand {
commandService.send(sender, MessageKey.CONFIG_RELOAD_SUCCESS);
} catch (Exception e) {
sender.sendMessage("Error occurred during reload of AuthMe: aborting");
ConsoleLogger.showError("Fatal error occurred! AuthMe instance ABORTED!");
ConsoleLogger.writeStackTrace(e);
ConsoleLogger.logException("Aborting! Encountered exception during reload of AuthMe:", e);
plugin.stopOrUnload();
}
}

View File

@ -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());
data.saveAuth(auth);
} catch (Exception e) {
ConsoleLogger.writeStackTrace(e);
ConsoleLogger.showError("Error while trying to import " + o.getName() + " RoyalAuth datas");
ConsoleLogger.logException("Error while trying to import " + o.getName() + " RoyalAuth data", e);
}
}
}

View File

@ -8,6 +8,7 @@ import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import java.io.File;
import java.io.IOException;
import java.util.Scanner;
import java.util.UUID;
@ -27,7 +28,7 @@ class vAuthFileReader {
}
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;
try {
scanner = new Scanner(file);
@ -52,8 +53,8 @@ class vAuthFileReader {
database.saveAuth(auth);
}
scanner.close();
} catch (Exception e) {
ConsoleLogger.writeStackTrace(e);
} catch (IOException e) {
ConsoleLogger.logException("Error while trying to import some vAuth data", e);
}
}
@ -63,12 +64,10 @@ class vAuthFileReader {
}
private String getName(UUID uuid) {
try {
for (OfflinePlayer op : Bukkit.getOfflinePlayers()) {
if (op.getUniqueId().compareTo(uuid) == 0)
return op.getName();
for (OfflinePlayer op : Bukkit.getOfflinePlayers()) {
if (op.getUniqueId().compareTo(uuid) == 0) {
return op.getName();
}
} catch (Exception ignored) {
}
return null;
}

View File

@ -5,17 +5,13 @@ import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.cache.RemovalListener;
import com.google.common.cache.RemovalListeners;
import com.google.common.cache.RemovalNotification;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.security.crypts.HashedPassword;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
/**
@ -23,7 +19,6 @@ import java.util.concurrent.TimeUnit;
public class CacheDataSource implements DataSource {
private final DataSource source;
private final ExecutorService exec;
private final LoadingCache<String, Optional<PlayerAuth>> cachedAuths;
/**
@ -33,10 +28,9 @@ public class CacheDataSource implements DataSource {
*/
public CacheDataSource(DataSource src) {
this.source = src;
this.exec = Executors.newCachedThreadPool();
cachedAuths = CacheBuilder.newBuilder()
.expireAfterWrite(5, TimeUnit.MINUTES)
.removalListener(RemovalListeners.asynchronous(new RemovalListener<String, Optional<PlayerAuth>>() {
this.cachedAuths = CacheBuilder.newBuilder()
.expireAfterWrite(8, TimeUnit.MINUTES)
.removalListener(new RemovalListener<String, Optional<PlayerAuth>>() {
@Override
public void onRemoval(RemovalNotification<String, Optional<PlayerAuth>> removalNotification) {
String name = removalNotification.getKey();
@ -44,7 +38,7 @@ public class CacheDataSource implements DataSource {
cachedAuths.getUnchecked(name);
}
}
}, exec))
})
.build(
new CacheLoader<String, Optional<PlayerAuth>>() {
public Optional<PlayerAuth> load(String key) {
@ -168,24 +162,13 @@ public class CacheDataSource implements DataSource {
@Override
public synchronized void close() {
try {
exec.shutdown();
exec.awaitTermination(8, TimeUnit.SECONDS);
} catch (InterruptedException e) {
ConsoleLogger.writeStackTrace(e);
}
source.close();
}
@Override
public void reload() { // unused method
exec.execute(new Runnable() {
@Override
public void run() {
source.reload();
cachedAuths.invalidateAll();
}
});
source.reload();
cachedAuths.invalidateAll();
}
@Override
@ -214,13 +197,8 @@ public class CacheDataSource implements DataSource {
@Override
public synchronized void purgeBanned(final List<String> banned) {
exec.execute(new Runnable() {
@Override
public void run() {
source.purgeBanned(banned);
cachedAuths.invalidateAll(banned);
}
});
source.purgeBanned(banned);
cachedAuths.invalidateAll(banned);
}
@Override
@ -235,33 +213,18 @@ public class CacheDataSource implements DataSource {
@Override
public void setLogged(final String user) {
exec.execute(new Runnable() {
@Override
public void run() {
source.setLogged(user.toLowerCase());
}
});
source.setLogged(user.toLowerCase());
}
@Override
public void setUnlogged(final String user) {
exec.execute(new Runnable() {
@Override
public void run() {
source.setUnlogged(user.toLowerCase());
}
});
source.setUnlogged(user.toLowerCase());
}
@Override
public void purgeLogged() {
exec.execute(new Runnable() {
@Override
public void run() {
source.purgeLogged();
cachedAuths.invalidateAll();
}
});
source.purgeLogged();
cachedAuths.invalidateAll();
}
@Override
@ -270,14 +233,9 @@ public class CacheDataSource implements DataSource {
}
@Override
public void updateName(final String oldOne, final String newOne) {
exec.execute(new Runnable() {
@Override
public void run() {
source.updateName(oldOne, newOne);
cachedAuths.invalidate(oldOne);
}
});
public void updateName(final String oldOne, final String newOne) { // unused method
source.updateName(oldOne, newOne);
cachedAuths.invalidate(oldOne);
}
@Override

View File

@ -257,8 +257,7 @@ public class MySQL implements DataSource {
ResultSet rs = pst.executeQuery();
return rs.next();
} catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage());
ConsoleLogger.writeStackTrace(ex);
logSqlException(ex);
}
return false;
}
@ -276,8 +275,7 @@ public class MySQL implements DataSource {
!columnSalt.isEmpty() ? rs.getString(columnSalt) : null);
}
} catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage());
ConsoleLogger.writeStackTrace(ex);
logSqlException(ex);
}
return null;
}
@ -322,8 +320,7 @@ public class MySQL implements DataSource {
}
}
} catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage());
ConsoleLogger.writeStackTrace(ex);
logSqlException(ex);
return null;
}
return pAuth;
@ -525,8 +522,7 @@ public class MySQL implements DataSource {
}
return true;
} catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage());
ConsoleLogger.writeStackTrace(ex);
logSqlException(ex);
}
return false;
}
@ -589,8 +585,7 @@ public class MySQL implements DataSource {
}
return true;
} catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage());
ConsoleLogger.writeStackTrace(ex);
logSqlException(ex);
}
return false;
}
@ -623,8 +618,7 @@ public class MySQL implements DataSource {
pst.setLong(1, until);
result = pst.executeUpdate();
} catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage());
ConsoleLogger.writeStackTrace(ex);
logSqlException(ex);
}
return result;
}
@ -647,8 +641,7 @@ public class MySQL implements DataSource {
st.executeUpdate();
st.close();
} catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage());
ConsoleLogger.writeStackTrace(ex);
logSqlException(ex);
}
return list;
}
@ -680,8 +673,7 @@ public class MySQL implements DataSource {
pst.executeUpdate();
return true;
} catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage());
ConsoleLogger.writeStackTrace(ex);
logSqlException(ex);
}
return false;
}
@ -702,8 +694,7 @@ public class MySQL implements DataSource {
pst.close();
return true;
} catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage());
ConsoleLogger.writeStackTrace(ex);
logSqlException(ex);
}
return false;
}
@ -722,8 +713,7 @@ public class MySQL implements DataSource {
rs.close();
pst.close();
} catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage());
ConsoleLogger.writeStackTrace(ex);
logSqlException(ex);
}
return countIp;
}
@ -739,8 +729,7 @@ public class MySQL implements DataSource {
pst.close();
return true;
} catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage());
ConsoleLogger.writeStackTrace(ex);
logSqlException(ex);
}
return false;
}
@ -750,9 +739,8 @@ public class MySQL implements DataSource {
try {
reloadArguments();
} catch (Exception ex) {
ConsoleLogger.showError(ex.getMessage());
ConsoleLogger.showError("Can't reconnect to MySQL database... Please check your MySQL configuration!");
ConsoleLogger.writeStackTrace(ex);
ConsoleLogger.logException("Can't reconnect to MySQL database... " +
"Please check your MySQL configuration! Encountered", ex);
AuthMe.getInstance().stopOrUnload();
}
}
@ -778,8 +766,7 @@ public class MySQL implements DataSource {
rs.close();
pst.close();
} catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage());
ConsoleLogger.writeStackTrace(ex);
logSqlException(ex);
}
return result;
}
@ -798,8 +785,7 @@ public class MySQL implements DataSource {
rs.close();
pst.close();
} catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage());
ConsoleLogger.writeStackTrace(ex);
logSqlException(ex);
}
return result;
}
@ -818,8 +804,7 @@ public class MySQL implements DataSource {
rs.close();
pst.close();
} catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage());
ConsoleLogger.writeStackTrace(ex);
logSqlException(ex);
}
return countEmail;
}
@ -834,8 +819,7 @@ public class MySQL implements DataSource {
}
pst.close();
} catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage());
ConsoleLogger.writeStackTrace(ex);
logSqlException(ex);
}
}
@ -854,8 +838,7 @@ public class MySQL implements DataSource {
ResultSet rs = pst.executeQuery();
isLogged = rs.next() && (rs.getInt(columnLogged) == 1);
} catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage());
ConsoleLogger.writeStackTrace(ex);
logSqlException(ex);
}
return isLogged;
}
@ -870,8 +853,7 @@ public class MySQL implements DataSource {
pst.executeUpdate();
pst.close();
} catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage());
ConsoleLogger.writeStackTrace(ex);
logSqlException(ex);
}
}
@ -885,8 +867,7 @@ public class MySQL implements DataSource {
pst.executeUpdate();
pst.close();
} catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage());
ConsoleLogger.writeStackTrace(ex);
logSqlException(ex);
}
}
@ -899,9 +880,8 @@ public class MySQL implements DataSource {
pst.setInt(2, 1);
pst.executeUpdate();
pst.close();
} catch (Exception ex) {
ConsoleLogger.showError(ex.getMessage());
ConsoleLogger.writeStackTrace(ex);
} catch (SQLException ex) {
logSqlException(ex);
}
}
@ -916,9 +896,8 @@ public class MySQL implements DataSource {
}
rs.close();
st.close();
} catch (Exception ex) {
ConsoleLogger.showError(ex.getMessage());
ConsoleLogger.writeStackTrace(ex);
} catch (SQLException ex) {
logSqlException(ex);
}
return result;
}
@ -931,9 +910,8 @@ public class MySQL implements DataSource {
pst.setString(1, newOne);
pst.setString(2, oldOne);
pst.executeUpdate();
} catch (Exception ex) {
ConsoleLogger.showError(ex.getMessage());
ConsoleLogger.writeStackTrace(ex);
} catch (SQLException ex) {
logSqlException(ex);
}
}
@ -977,9 +955,8 @@ public class MySQL implements DataSource {
pst.close();
rs.close();
st.close();
} catch (Exception ex) {
ConsoleLogger.showError(ex.getMessage());
ConsoleLogger.writeStackTrace(ex);
} catch (SQLException ex) {
logSqlException(ex);
}
return auths;
}
@ -1021,11 +998,14 @@ public class MySQL implements DataSource {
}
auths.add(pAuth);
}
} catch (Exception ex) {
ConsoleLogger.showError(ex.getMessage());
ConsoleLogger.writeStackTrace(ex);
} catch (SQLException ex) {
logSqlException(ex);
}
return auths;
}
private static void logSqlException(SQLException e) {
ConsoleLogger.logException("Error during SQL operation:", e);
}
}

View File

@ -170,8 +170,7 @@ public class SQLite implements DataSource {
!columnSalt.isEmpty() ? rs.getString(columnSalt) : null);
}
} catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage());
ConsoleLogger.writeStackTrace(ex);
ConsoleLogger.logException("Error getting password:", ex);
} finally {
close(rs);
close(pst);

View File

@ -108,6 +108,9 @@ public class AuthMePlayerListener implements Listener {
if (Settings.useEssentialsMotd && cmd.equals("/motd")) {
return;
}
if(!Settings.isForcedRegistrationEnabled && Settings.allowAllCommandsIfRegIsOptional) {
return;
}
if (Settings.allowCommands.contains(cmd)) {
return;
}

View File

@ -135,8 +135,7 @@ public class ModuleManager {
}
} catch (Exception ex) {
ConsoleLogger.writeStackTrace(ex);
ConsoleLogger.showError("Cannot load " + pathToJar.getName() + " jar file !");
ConsoleLogger.logException("Cannot load " + pathToJar.getName() + " jar file!", ex);
} finally {
try {
if (jarFile != null) {

View File

@ -49,6 +49,13 @@ public class ProcessSyncronousPlayerLogout implements Runnable {
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
}
protected void restoreSpeedEffect() {
if (Settings.isRemoveSpeedEnabled) {
player.setWalkSpeed(0.0F);
player.setFlySpeed(0.0F);
}
}
/**
* Method run.
*
@ -77,6 +84,7 @@ public class ProcessSyncronousPlayerLogout implements Runnable {
if (Settings.applyBlindEffect)
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, Settings.getRegistrationTimeout * 20, 2));
player.setOp(false);
restoreSpeedEffect();
// Player is now logout... Time to fire event !
Bukkit.getServer().getPluginManager().callEvent(new LogoutEvent(player));
if (Settings.bungee)

View File

@ -85,8 +85,7 @@ public class AsyncRegister {
passwordRegister();
}
} catch (Exception e) {
ConsoleLogger.showError(e.getMessage());
ConsoleLogger.writeStackTrace(e);
ConsoleLogger.logException("Error during async register process", e);
m.send(player, MessageKey.ERROR);
}
}

View File

@ -77,8 +77,7 @@ public abstract class CustomConfiguration extends YamlConfiguration {
return true;
}
} catch (Exception e) {
ConsoleLogger.writeStackTrace(e);
ConsoleLogger.showError("Failed to load config from JAR");
ConsoleLogger.logException("Failed to load config from JAR", e);
}
}
return false;

View File

@ -181,8 +181,7 @@ public class NewSetting {
writer.flush();
writer.close();
} catch (IOException e) {
ConsoleLogger.showError("Could not save config file - " + StringUtils.formatException(e));
ConsoleLogger.writeStackTrace(e);
ConsoleLogger.logException("Could not save config file:", e);
}
}

View File

@ -65,7 +65,7 @@ public final class Settings {
enableProtection, enableAntiBot, recallEmail, useWelcomeMessage,
broadcastWelcomeMessage, forceRegKick, forceRegLogin,
checkVeryGames, delayJoinLeaveMessages, noTeleport, applyBlindEffect,
kickPlayersBeforeStopping,
kickPlayersBeforeStopping, allowAllCommandsIfRegIsOptional,
customAttributes, generateImage, isRemoveSpeedEnabled, preventOtherCase;
public static String getNickRegex, getUnloggedinGroup, getMySQLHost,
getMySQLPort, getMySQLUsername, getMySQLPassword, getMySQLDatabase,
@ -189,6 +189,7 @@ public final class Settings {
isStopEnabled = configFile.getBoolean("Security.SQLProblem.stopServer", true);
reloadSupport = configFile.getBoolean("Security.ReloadCommand.useReloadCommandSupport", true);
allowAllCommandsIfRegIsOptional = configFile.getBoolean("settings.restrictions.allowAllCommandsIfRegistrationIsOptional", false);
allowCommands = new ArrayList<>();
allowCommands.addAll(Arrays.asList("/login", "/l", "/register", "/reg", "/email", "/captcha"));
for (String cmd : configFile.getStringList("settings.restrictions.allowCommands")) {

View File

@ -18,13 +18,19 @@ public class RestrictionSettings implements SettingsClass {
public static final Property<Boolean> ALLOW_CHAT =
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")
public static final Property<List<String>> ALLOW_COMMANDS =
newProperty(PropertyType.STRING_LIST, "settings.restrictions.allowCommands",
"login", "register", "l", "reg", "email", "captcha");
@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 =
newProperty("settings.restrictions.maxRegPerIp", 1);

View File

@ -36,7 +36,7 @@ public class GeoLiteAPI {
plugin.getLogger().info(LICENSE);
return true;
} catch (IOException e) {
// TODO ljacqu 20151123: Log the exception instead of just swallowing it
ConsoleLogger.logException("Could not find/download GeoLiteAPI", e);
return false;
}
}
@ -63,7 +63,7 @@ public class GeoLiteAPI {
output.close();
input.close();
} catch (IOException e) {
ConsoleLogger.writeStackTrace(e);
ConsoleLogger.logException("Could not download GeoLiteAPI", e);
}
}
});

View File

@ -67,6 +67,9 @@ settings:
# Care that this feature blocks also all the commands not
# listed in the list below.
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
allowCommands:
- /login

View File

@ -4,56 +4,56 @@ registered: '&aSikeres regisztráció. Üdvözöllek!'
user_regged: '&cJátékosnév már regisztrálva'
login_msg: '&cKérlek jelentkezz be: "/login jelszó"'
not_logged_in: '&cNem vagy bejelentkezve!'
logout: '&cSikeresen kijelentkeztél'
usage_log: '&cBejelentkezés: /login jelszó'
unknown_user: User is not in database
reg_voluntarily: Regisztrálhatod beceneved a szerveren a következö parancsal "/register jelszó jelszó"
reg_disabled: '&cRegisztráció letiltva'
no_perm: '&cNincs engedélyed'
usage_reg: '&cHasználat: /register jelszó jelszóújra'
password_error_nick: '&fYou can''t use your name as password'
password_error_unsafe: '&fYou can''t use unsafe passwords'
logout: '&cSikeresen kijelentkeztél!'
usage_log: '&cBejelentkezés: /login <jelszó>'
unknown_user: '&cA kért felhasználó nem telálható az adatbázisban!'
reg_voluntarily: Regisztrálhatod magad a szerveren a következö parancsal "/register <jelszó> <jelszó újra>"
reg_disabled: '&cRegisztráció letiltva!'
no_perm: '&cNincs jogod ehhez!'
usage_reg: '&cHasználat: /register <jelszó> <jelszó újra>'
password_error_nick: '&cNem használhatod a felhasználóneved jelszónak, kérlek válassz másikat...'
password_error_unsafe: '&cA választott jelszó nem biztonságos, kérlek válassz másikat...'
unregistered: '&cRegisztráció sikeresen törölve!'
same_nick: Ezen a játékosnéven már játszanak
valid_session: '&cSession login'
same_nick: 'Ezzel a játékosnévvel már játszanak a szerveren.'
valid_session: '&2A hálózati kapcsolat újraépítése megtörtént.'
pwd_changed: '&cJelszó cserélve!'
reload: Beálítások és adatbázis újratöltve!
timeout: Bejelentkezési idötúllépés
error: Hiba lépett fel; Lépj kapcsolatba a tulajjal'
reload: 'Beálítások és adatbázis újratöltve!'
timeout: 'Bejelentkezési időtúllépés!'
error: 'Hiba lépett fel; Lépj kapcsolatba a tulajjal'
logged_in: '&cMár be vagy jelentkezve!'
login: '&aSikeresen Beléptél! Üdvözöllek!!!'
wrong_pwd: '&4Hibás jelszó'
user_unknown: '&cJátékosnév nem regisztrált'
login: '&aSikeresen beléptél!'
wrong_pwd: '&4Hibás jelszó!'
user_unknown: '&cEz a felhasználó nincs regisztrálva!'
reg_msg: '&cKérlek Regisztrálj: "/register jelszó jelszóújra"'
reg_email_msg: '&cPlease register with "/register <email> <confirmEmail>"'
unsafe_spawn: A kilépési helyzeted nem biztonságos, teleportálás a kezdö Spawnra.
max_reg: Csak egy karakterrel Registrálhatsz!!!
password_error: A jelszó nem illik össze
invalid_session: Session Dataes doesnt corrispond Plaese wait the end of session
pass_len: A jelszavad nem éri el a minimális hosszat
vb_nonActiv: Your Account isent Activated yet check your Emails!
usage_changepassword: 'használat: /changepassword régiJelszó újJelszó'
name_len: '&cYour nickname is too Short or too long'
regex: '&cYour nickname contains illegal characters. Allowed chars: REG_EX'
add_email: '&cPlease add your email with : /email add yourEmail confirmEmail'
recovery_email: '&cForgot your password? Please use /email recovery <yourEmail>'
usage_captcha: '&cUsage: /captcha <theCaptcha>'
wrong_captcha: '&cWrong Captcha, please use : /captcha THE_CAPTCHA'
valid_captcha: '&cYour captcha is valid !'
kick_forvip: '&cA VIP Player join the full server!'
kick_fullserver: '&cThe server is actually full, Sorry!'
usage_email_add: '&fUsage: /email add <email> <confirmEmail> '
usage_email_change: '&fUsage: /email change <oldEmail> <newEmail> '
usage_email_recovery: '&fUsage: /email recovery <Email>'
new_email_invalid: '[AuthMe] New email invalid!'
old_email_invalid: '[AuthMe] Old email invalid!'
email_invalid: '[AuthMe] Invalid Email'
email_added: '[AuthMe] Email Added !'
email_confirm: '[AuthMe] Confirm your Email !'
email_changed: '[AuthMe] Email Change !'
email_send: '[AuthMe] Recovery Email Send !'
country_banned: 'Your country is banned from this server'
antibot_auto_enabled: '[AuthMe] AntiBotMod automatically enabled due to massive connections!'
antibot_auto_disabled: '[AuthMe] AntiBotMod automatically disabled after %m Minutes, hope invasion stopped'
kick_antibot: 'AntiBot protection mode is enabled! You have to wait some minutes before joining the server.'
email_exists: '&cA recovery email was already sent! You can discard it and send a new one using the command below:'
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 Spawnra.'
max_reg: 'Csak egy karakterrel registrálhatsz!'
password_error: 'A két jelszó nem egyezik!'
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 hosszúságot!'
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égi Jelszó> <új Jelszó>'
name_len: '&4A felhasználó neved túl hosszú, vagy túl rövid! Válassz másikat!'
regex: '&4A felhasználóneved nem használható karaktereket tartalmaz. Elfogadott karakterek: REG_EX'
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: '&3Ha elfelejtetted a jelszavad, használd az: "/email recovery <regisztrált Email címed>"'
usage_captcha: '&3A bejelentkezéshez CAPTCHA szükséges, kérem használd a következő parancsot "/captcha <Captcha>"'
wrong_captcha: '&cHibás captcha, kérlek írd be a következő parancsot "/captcha THE_CAPTCHA" a chat-be!'
valid_captcha: '&2Captcha sikeresen feloldva!'
kick_forvip: '&3VIP játékos csatlakozott a szerverhez!'
kick_fullserver: '&4A szerver megtelt, próbálj csatlakozni később!'
usage_email_add: '&cHasználat: /email add <email> <Email újra>'
usage_email_change: '&cHasználat: /email change <régi Email> <új Email>'
usage_email_recovery: '&cHasználat: /email recovery <email>'
new_email_invalid: '&cHibás az új email cím, próbáld újra!'
old_email_invalid: '&cHibás a régi email cím, próbáld újra!'
email_invalid: '&cHibás az email cím, próbáld újra!'
email_added: '&2Az email címed rögzítése sikeresen megtörtént!'
email_confirm: '&cKérlek ellenőrízd az email címedet!'
email_changed: '&2Az email cím cseréje sikeresen megtörtént!'
email_send: '&2A jelszó visszaállításhoz szükséges emailt elküldtük! Ellenőrízd a leveleidet!'
email_exists: '&cA visszaállító emailt elküldtük! Hiba esetén újkérheted az alábbi parancs segítségével:'
country_banned: '&4Az országod tiltólistán van ezen a szerveren!'
antibot_auto_enabled: '&4[AntiBot] Az AntiBot védelem bekapcsolt a nagy számú hálózati kapcsolat miatt!'
antibot_auto_disabled: '&2[AntiBot] Az AntiBot kikapcsol %m múlva!'
kick_antibot: 'Az AntiBot védelem bekapcsolva! Kérünk várj pár másodpercet a csatlakozáshoz.'