Project cleanup

This commit is contained in:
Gabriele C 2016-06-26 16:19:55 +02:00
parent 54ababdd28
commit a998354fa2
5 changed files with 149 additions and 172 deletions

125
pom.xml
View File

@ -7,7 +7,6 @@
<groupId>fr.xephi</groupId> <groupId>fr.xephi</groupId>
<artifactId>authme</artifactId> <artifactId>authme</artifactId>
<version>5.2-SNAPSHOT</version> <version>5.2-SNAPSHOT</version>
<packaging>jar</packaging>
<name>AuthMeReloaded</name> <name>AuthMeReloaded</name>
<description>The first authentication plugin for the Bukkit API!</description> <description>The first authentication plugin for the Bukkit API!</description>
@ -44,10 +43,6 @@
</license> </license>
</licenses> </licenses>
<prerequisites>
<maven>3.3.3</maven>
</prerequisites>
<properties> <properties>
<!-- Project properties --> <!-- Project properties -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@ -62,6 +57,7 @@
<!-- BukkitPlugin properties --> <!-- BukkitPlugin properties -->
<bukkitplugin.name>${project.outputName}</bukkitplugin.name> <bukkitplugin.name>${project.outputName}</bukkitplugin.name>
<bukkitplugin.version>${project.versionCode}</bukkitplugin.version>
<bukkitplugin.main>${project.groupId}.${project.artifactId}.${bukkitplugin.name}</bukkitplugin.main> <bukkitplugin.main>${project.groupId}.${project.artifactId}.${bukkitplugin.name}</bukkitplugin.main>
<bukkitplugin.authors>Xephi, sgdc3, DNx5, timvisee, games647, ljacqu, Gnat008</bukkitplugin.authors> <bukkitplugin.authors>Xephi, sgdc3, DNx5, timvisee, games647, ljacqu, Gnat008</bukkitplugin.authors>
@ -69,8 +65,9 @@
<bukkit.version>1.10-R0.1-SNAPSHOT</bukkit.version> <bukkit.version>1.10-R0.1-SNAPSHOT</bukkit.version>
</properties> </properties>
<!-- Jenkins profile (add the real buildNumber to the version string) --> <!-- Jenkins profile -->
<profiles> <profiles>
<!-- Set the buildNumber using the jenkins env. variable -->
<profile> <profile>
<id>jenkins</id> <id>jenkins</id>
<activation> <activation>
@ -82,6 +79,7 @@
<project.buildNumber>${env.BUILD_NUMBER}</project.buildNumber> <project.buildNumber>${env.BUILD_NUMBER}</project.buildNumber>
</properties> </properties>
</profile> </profile>
<!-- Skip long hash tests, reduce the test time of 20-30 seconds -->
<profile> <profile>
<id>skipLongHashTests</id> <id>skipLongHashTests</id>
<activation> <activation>
@ -96,7 +94,7 @@
</profiles> </profiles>
<build> <build>
<!-- Name of the NOSHADE jar (no shaded/relocated libraries) --> <!-- Name of the unshaded jar (no shaded/relocated libraries) -->
<finalName>${project.finalName}-noshade</finalName> <finalName>${project.finalName}-noshade</finalName>
<resources> <resources>
@ -135,6 +133,7 @@
<artifactId>maven-surefire-plugin</artifactId> <artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version> <version>2.19.1</version>
<configuration> <configuration>
<!-- Force the right file encoding during unit testing -->
<argLine>-Dfile.encoding=${project.build.sourceEncoding} @{argLine}</argLine> <argLine>-Dfile.encoding=${project.build.sourceEncoding} @{argLine}</argLine>
<systemPropertyVariables> <systemPropertyVariables>
<project.skipExtendedHashTests>${project.skipExtendedHashTests}</project.skipExtendedHashTests> <project.skipExtendedHashTests>${project.skipExtendedHashTests}</project.skipExtendedHashTests>
@ -143,20 +142,16 @@
</plugin> </plugin>
<!-- Libs Shading and Relocation --> <!-- Libs Shading and Relocation -->
<plugin> <plugin>
<!--
Relocate all lib we use in order to fix class loading errors if we use different versions
than already loaded libs (i.e. by Mojang -> gson)
-->
<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.3</version> <version>2.4.3</version>
<configuration> <configuration>
<createDependencyReducedPom>false</createDependencyReducedPom> <createDependencyReducedPom>false</createDependencyReducedPom>
<!--
Let's try to remove this!
<minimizeJar>false</minimizeJar>
-->
</configuration> </configuration>
<!--
Relocate all lib we use in order to fix class loading errors if we use different versions
than already loaded libs (i.e. by Mojang -> gson)
-->
<executions> <executions>
<!-- Spigot 1.8+ --> <!-- Spigot 1.8+ -->
<execution> <execution>
@ -173,36 +168,36 @@
</excludes> </excludes>
</artifactSet> </artifactSet>
<relocations> <relocations>
<!-- We use a newer version of gson so we need to include it! --> <!-- We use a newer version of gson so we need to include and relocate it! -->
<relocation> <relocation>
<pattern>com.google.gson</pattern> <pattern>com.google.gson</pattern>
<shadedPattern>fr.xephi.authme.libs.google</shadedPattern> <shadedPattern>fr.xephi.authme.libs.google.gson</shadedPattern>
</relocation>
<relocation>
<pattern>com.zaxxer.hikari</pattern>
<shadedPattern>fr.xephi.authme.libs.hikari</shadedPattern>
</relocation>
<relocation>
<pattern>org.slf4j</pattern>
<shadedPattern>fr.xephi.authme.libs.slf4j</shadedPattern>
</relocation>
<relocation>
<pattern>com.maxmind.geoip</pattern>
<shadedPattern>fr.xephi.authme.libs.geoip</shadedPattern>
</relocation>
<relocation>
<pattern>net.ricecode.similarity</pattern>
<shadedPattern>fr.xephi.authme.libs.similarity</shadedPattern>
</relocation>
<relocation>
<pattern>javax.inject</pattern>
<shadedPattern>fr.xephi.authme.libs.inject</shadedPattern>
</relocation>
<!-- MCStats.org metrics -->
<relocation>
<pattern>org.mcstats</pattern>
<shadedPattern>fr.xephi.authme</shadedPattern>
</relocation> </relocation>
<relocation>
<pattern>com.zaxxer.hikari</pattern>
<shadedPattern>fr.xephi.authme.libs.zaxxer.hikari</shadedPattern>
</relocation>
<relocation>
<pattern>org.slf4j</pattern>
<shadedPattern>fr.xephi.authme.libs.slf4j.slf4j</shadedPattern>
</relocation>
<relocation>
<pattern>com.maxmind.geoip</pattern>
<shadedPattern>fr.xephi.authme.libs.maxmind.geoip</shadedPattern>
</relocation>
<relocation>
<pattern>net.ricecode.similarity</pattern>
<shadedPattern>fr.xephi.authme.libs.ricecode.similarity</shadedPattern>
</relocation>
<relocation>
<pattern>javax.inject</pattern>
<shadedPattern>fr.xephi.authme.libs.javax.inject</shadedPattern>
</relocation>
<!-- MCStats.org metrics -->
<relocation>
<pattern>org.mcstats</pattern>
<shadedPattern>fr.xephi.authme</shadedPattern>
</relocation>
</relocations> </relocations>
<outputFile>target/${project.finalName}-spigot.jar</outputFile> <outputFile>target/${project.finalName}-spigot.jar</outputFile>
</configuration> </configuration>
@ -215,31 +210,31 @@
<goal>shade</goal> <goal>shade</goal>
</goals> </goals>
<configuration> <configuration>
<!-- Include all google libraries, because they are not available before 1.8 -->
<relocations> <relocations>
<!-- Include all google libraries, because they are not available before 1.8 -->
<relocation> <relocation>
<pattern>com.google</pattern> <pattern>com.google</pattern>
<shadedPattern>fr.xephi.authme.libs.google</shadedPattern> <shadedPattern>fr.xephi.authme.libs.google</shadedPattern>
</relocation> </relocation>
<relocation> <relocation>
<pattern>com.zaxxer.hikari</pattern> <pattern>com.zaxxer.hikari</pattern>
<shadedPattern>fr.xephi.authme.libs.hikari</shadedPattern> <shadedPattern>fr.xephi.authme.libs.zaxxer.hikari</shadedPattern>
</relocation> </relocation>
<relocation> <relocation>
<pattern>org.slf4j</pattern> <pattern>org.slf4j</pattern>
<shadedPattern>fr.xephi.authme.libs.slf4j</shadedPattern> <shadedPattern>fr.xephi.authme.libs.slf4j.slf4j</shadedPattern>
</relocation> </relocation>
<relocation> <relocation>
<pattern>com.maxmind.geoip</pattern> <pattern>com.maxmind.geoip</pattern>
<shadedPattern>fr.xephi.authme.libs.geoip</shadedPattern> <shadedPattern>fr.xephi.authme.libs.maxmind.geoip</shadedPattern>
</relocation> </relocation>
<relocation> <relocation>
<pattern>net.ricecode.similarity</pattern> <pattern>net.ricecode.similarity</pattern>
<shadedPattern>fr.xephi.authme.libs.similarity</shadedPattern> <shadedPattern>fr.xephi.authme.libs.ricecode.similarity</shadedPattern>
</relocation> </relocation>
<relocation> <relocation>
<pattern>javax.inject</pattern> <pattern>javax.inject</pattern>
<shadedPattern>fr.xephi.authme.libs.inject</shadedPattern> <shadedPattern>fr.xephi.authme.libs.javax.inject</shadedPattern>
</relocation> </relocation>
<!-- MCStats.org metrics --> <!-- MCStats.org metrics -->
<relocation> <relocation>
@ -252,7 +247,7 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<!-- Exec Tools --> <!-- Exec Plugin (Tools runner) -->
<plugin> <plugin>
<groupId>org.codehaus.mojo</groupId> <groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId> <artifactId>exec-maven-plugin</artifactId>
@ -267,7 +262,7 @@
<includeProjectDependencies>true</includeProjectDependencies> <includeProjectDependencies>true</includeProjectDependencies>
</configuration> </configuration>
</plugin> </plugin>
<!-- Test coverage --> <!-- Coverage report generator -->
<plugin> <plugin>
<groupId>org.jacoco</groupId> <groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId> <artifactId>jacoco-maven-plugin</artifactId>
@ -281,7 +276,7 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<!-- Coveralls data --> <!-- Coverage report uploader -->
<plugin> <plugin>
<groupId>org.eluder.coveralls</groupId> <groupId>org.eluder.coveralls</groupId>
<artifactId>coveralls-maven-plugin</artifactId> <artifactId>coveralls-maven-plugin</artifactId>
@ -289,9 +284,9 @@
<configuration> <configuration>
<failOnServiceError>false</failOnServiceError> <failOnServiceError>false</failOnServiceError>
</configuration> </configuration>
<!-- The secret token is provided by console! --> <!-- The secret token is provided with a command-line parameter! -->
</plugin> </plugin>
<!-- Javadocs settings --> <!-- JavaDocs generator -->
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId> <artifactId>maven-javadoc-plugin</artifactId>
@ -305,9 +300,9 @@
</build> </build>
<repositories> <repositories>
<!-- SpigotMC Repo (Bukkit and SpigotAPI) --> <!-- SpigotAPI Repo -->
<repository> <repository>
<id>spigot-repo</id> <id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots</url> <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots</url>
</repository> </repository>
@ -319,7 +314,7 @@
<!-- CombatTagPlus Repo --> <!-- CombatTagPlus Repo -->
<repository> <repository>
<id>minelink-thirdparty</id> <id>minelink-repo</id>
<url>http://repo.minelink.net/content/repositories/public</url> <url>http://repo.minelink.net/content/repositories/public</url>
</repository> </repository>
@ -331,33 +326,27 @@
<!-- Multiverse Repo --> <!-- Multiverse Repo -->
<repository> <repository>
<id>onarandombox</id> <id>onarandombox-repo</id>
<url>http://repo.onarandombox.com/content/groups/public</url> <url>http://repo.onarandombox.com/content/groups/public</url>
</repository> </repository>
<!-- Vault Repo --> <!-- Vault Repo -->
<repository> <repository>
<id>vault-repo</id> <id>theyeticave-repo</id>
<url>http://nexus.theyeticave.net/content/repositories/pub_releases</url> <url>http://nexus.theyeticave.net/content/repositories/pub_releases</url>
</repository> </repository>
<!-- XAuth Repo --> <!-- XAuth Repo -->
<repository> <repository>
<id>luricos-releases</id> <id>luricos-repo</id>
<url>http://repo.luricos.de/content/repositories/releases</url> <url>http://repo.luricos.de/content/repositories/releases</url>
</repository> </repository>
<!-- Xephi Repo --> <!-- Our Repo (Many libs) -->
<repository> <repository>
<id>xephi-repo</id> <id>xephi-repo</id>
<url>http://ci.xephi.fr/plugin/repository/everything/</url> <url>http://ci.xephi.fr/plugin/repository/everything/</url>
</repository> </repository>
<!-- PermissionsEx Repo (Re-added, since Xephi's repo was down) -->
<repository>
<id>pex-repo</id>
<url>https://pex-repo.aoeu.xyz/</url>
</repository>
</repositories> </repositories>
<dependencies> <dependencies>
@ -375,6 +364,7 @@
</exclusions> </exclusions>
<optional>true</optional> <optional>true</optional>
</dependency> </dependency>
<!-- HikariCP Logger -->
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId> <artifactId>slf4j-simple</artifactId>
@ -387,8 +377,7 @@
<dependency> <dependency>
<groupId>org.apache.logging.log4j</groupId> <groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId> <artifactId>log4j-core</artifactId>
<!-- Can't use newer versions due to api changes! --> <version>2.5</version>
<version>2.0-beta9</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>

View File

@ -69,6 +69,7 @@ import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.PluginLoader; import org.bukkit.plugin.PluginLoader;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.plugin.messaging.Messenger;
import org.bukkit.scheduler.BukkitScheduler; import org.bukkit.scheduler.BukkitScheduler;
import org.bukkit.scheduler.BukkitTask; import org.bukkit.scheduler.BukkitTask;
@ -90,39 +91,26 @@ import static fr.xephi.authme.settings.properties.EmailSettings.RECALL_PLAYERS;
*/ */
public class AuthMe extends JavaPlugin { public class AuthMe extends JavaPlugin {
// Defines the name of the plugin. // Name of the plugin.
private static final String PLUGIN_NAME = "AuthMeReloaded"; private static final String PLUGIN_NAME = "AuthMeReloaded";
// Default version and build number values; // Default version and build number values;
private static String pluginVersion = "N/D"; private static String pluginVersion = "N/D";
private static String pluginBuildNumber = "Unknown"; private static String pluginBuildNumber = "Unknown";
// Private Instances
private static AuthMe plugin;
/*
* Maps and stuff
*/
public final ConcurrentHashMap<String, BukkitTask> sessions = new ConcurrentHashMap<>();
/*
* Public instances
*/
public NewAPI api;
// TODO #655: Encapsulate mail
public SendMailSSL mail;
/* /*
* Private instances * Private instances
*/ */
// TODO #604: Encapsulate ProtocolLib members
public AuthMeInventoryPacketAdapter inventoryProtector; // Plugin instance
public AuthMeTabCompletePacketAdapter tabComplete; private static AuthMe plugin;
public AuthMeTablistPacketAdapter tablistHider;
private NewAPI api;
private Management management; private Management management;
private CommandHandler commandHandler; private CommandHandler commandHandler;
private PermissionsManager permsMan; private PermissionsManager permsMan;
private NewSetting newSettings; private NewSetting newSettings;
private Messages messages; private Messages messages;
private JsonCache playerBackup;
private PasswordSecurity passwordSecurity; private PasswordSecurity passwordSecurity;
private DataSource database; private DataSource database;
private PluginHooks pluginHooks; private PluginHooks pluginHooks;
@ -130,6 +118,19 @@ public class AuthMe extends JavaPlugin {
private BukkitService bukkitService; private BukkitService bukkitService;
private AuthMeServiceInitializer initializer; private AuthMeServiceInitializer initializer;
/*
* Public instances
*/
// TODO: Encapsulate session management
public final ConcurrentHashMap<String, BukkitTask> sessions = new ConcurrentHashMap<>();
// TODO #655: Encapsulate mail
public SendMailSSL mail;
// TODO #604: Encapsulate ProtocolLib members
public AuthMeInventoryPacketAdapter inventoryProtector;
public AuthMeTabCompletePacketAdapter tabComplete;
public AuthMeTablistPacketAdapter tablistHider;
/** /**
* Constructor. * Constructor.
*/ */
@ -184,7 +185,7 @@ public class AuthMe extends JavaPlugin {
} }
// Get version and build number of the plugin // Get version and build number of the plugin
private void setPluginInfos() { private void loadPluginInfo() {
String versionRaw = this.getDescription().getVersion(); String versionRaw = this.getDescription().getVersion();
int index = versionRaw.lastIndexOf("-"); int index = versionRaw.lastIndexOf("-");
if (index != -1) { if (index != -1) {
@ -201,19 +202,24 @@ public class AuthMe extends JavaPlugin {
*/ */
@Override @Override
public void onEnable() { public void onEnable() {
// Set various instances // Set the plugin instance and load plugin info from the plugin description.
plugin = this; plugin = this;
loadPluginInfo();
// Set the Logger instance and log file path
ConsoleLogger.setLogger(getLogger()); ConsoleLogger.setLogger(getLogger());
setPluginInfos(); ConsoleLogger.setLogFile(new File(getDataFolder(), "authme.log"));
// 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 (newSettings == null) { if (newSettings == null) {
getLogger().warning("Could not load configuration. Aborting."); getLogger().warning("Could not load configuration. Aborting.");
getServer().shutdown(); getServer().shutdown();
setEnabled(false);
return; return;
} }
ConsoleLogger.setLogFile(new File(getDataFolder(), "authme.log"));
// Apply settings to the logger
ConsoleLogger.setLoggingOptions(newSettings); ConsoleLogger.setLoggingOptions(newSettings);
// Old settings manager // Old settings manager
@ -232,10 +238,12 @@ public class AuthMe extends JavaPlugin {
stopOrUnload(); stopOrUnload();
return; return;
} }
// Convert deprecated PLAINTEXT hash entries
MigrationService.changePlainTextToSha256(newSettings, database, new SHA256()); MigrationService.changePlainTextToSha256(newSettings, database, new SHA256());
// Injector initialization
initializer = new AuthMeServiceInitializer("fr.xephi.authme"); initializer = new AuthMeServiceInitializer("fr.xephi.authme");
// Register elements of the Bukkit / JavaPlugin environment // Register elements of the Bukkit / JavaPlugin environment
initializer.register(AuthMe.class, this); initializer.register(AuthMe.class, this);
initializer.register(Server.class, getServer()); initializer.register(Server.class, getServer());
@ -261,21 +269,15 @@ public class AuthMe extends JavaPlugin {
// Set up the mail API // Set up the mail API
setupMailApi(); setupMailApi();
// Check if the ProtocolLib is available. If so we could listen for // Check if the ProtocolLib is available
// inventory protection
checkProtocolLib(); checkProtocolLib();
// End of Hooks
// Do a backup on start // Do a backup on start
// TODO: maybe create a backup manager?
new PerformBackup(this, newSettings).doBackup(PerformBackup.BackupCause.START); new PerformBackup(this, newSettings).doBackup(PerformBackup.BackupCause.START);
// Setup the inventory backup
playerBackup = new JsonCache();
// Set up the BungeeCord hook // Set up the BungeeCord hook
setupBungeeCordHook(newSettings, initializer); setupBungeeCordHook();
// Reload support hook // Reload support hook
reloadSupportHook(); reloadSupportHook();
@ -396,11 +398,11 @@ public class AuthMe extends JavaPlugin {
/** /**
* Set up the BungeeCord hook. * Set up the BungeeCord hook.
*/ */
private void setupBungeeCordHook(NewSetting settings, AuthMeServiceInitializer initializer) { private void setupBungeeCordHook() {
if (settings.getProperty(HooksSettings.BUNGEECORD)) { if (newSettings.getProperty(HooksSettings.BUNGEECORD)) {
Bukkit.getMessenger().registerOutgoingPluginChannel(this, "BungeeCord"); Messenger messenger = Bukkit.getMessenger();
Bukkit.getMessenger().registerIncomingPluginChannel( messenger.registerOutgoingPluginChannel(plugin, "BungeeCord");
this, "BungeeCord", initializer.get(BungeeCordMessage.class)); messenger.registerIncomingPluginChannel(plugin, "BungeeCord", initializer.get(BungeeCordMessage.class));
} }
} }
@ -434,18 +436,20 @@ public class AuthMe extends JavaPlugin {
* Set up the console filter. * Set up the console filter.
*/ */
private void setupConsoleFilter() { private void setupConsoleFilter() {
if (newSettings.getProperty(SecuritySettings.REMOVE_PASSWORD_FROM_CONSOLE)) { if (!newSettings.getProperty(SecuritySettings.REMOVE_PASSWORD_FROM_CONSOLE)) {
return;
}
// Try to set the log4j filter
try {
Class.forName("org.apache.logging.log4j.core.filter.AbstractFilter");
setLog4JFilter();
} catch (ClassNotFoundException | NoClassDefFoundError e) {
// log4j is not available
ConsoleLogger.info("You're using Minecraft 1.6.x or older, Log4J support will be disabled");
ConsoleFilter filter = new ConsoleFilter(); ConsoleFilter filter = new ConsoleFilter();
getLogger().setFilter(filter); getLogger().setFilter(filter);
Bukkit.getLogger().setFilter(filter); Bukkit.getLogger().setFilter(filter);
Logger.getLogger("Minecraft").setFilter(filter); Logger.getLogger("Minecraft").setFilter(filter);
// Set Log4J Filter
try {
Class.forName("org.apache.logging.log4j.core.Filter");
setLog4JFilter();
} catch (ClassNotFoundException | NoClassDefFoundError e) {
ConsoleLogger.info("You're using Minecraft 1.6.x or older, Log4J support will be disabled");
}
} }
} }
@ -570,16 +574,9 @@ public class AuthMe extends JavaPlugin {
// Set the console filter to remove the passwords // Set the console filter to remove the passwords
private void setLog4JFilter() { private void setLog4JFilter() {
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { org.apache.logging.log4j.core.Logger logger;
@Override logger = (org.apache.logging.log4j.core.Logger) LogManager.getRootLogger();
public void run() { logger.addFilter(new Log4JFilter());
org.apache.logging.log4j.core.Logger logger;
logger = (org.apache.logging.log4j.core.Logger) LogManager.getRootLogger();
logger.addFilter(new Log4JFilter());
logger = (org.apache.logging.log4j.core.Logger) LogManager.getLogger("net.minecraft");
logger.addFilter(new Log4JFilter());
}
});
} }
// Check the presence of the ProtocolLib plugin // Check the presence of the ProtocolLib plugin
@ -640,9 +637,6 @@ public class AuthMe extends JavaPlugin {
player.setOp(limbo.isOperator()); player.setOp(limbo.isOperator());
limbo.getTimeoutTask().cancel(); limbo.getTimeoutTask().cancel();
limboCache.deleteLimboPlayer(name); limboCache.deleteLimboPlayer(name);
if (this.playerBackup.doesCacheExist(player)) {
this.playerBackup.removeCache(player);
}
} }
PlayerCache.getInstance().removePlayer(name); PlayerCache.getInstance().removePlayer(name);
} }
@ -719,7 +713,6 @@ public class AuthMe extends JavaPlugin {
return commandHandler.processCommand(sender, commandLabel, args); return commandHandler.processCommand(sender, commandLabel, args);
} }
// ------------- // -------------
// Service getters (deprecated) // Service getters (deprecated)
// Use @Inject fields instead // Use @Inject fields instead

View File

@ -2,9 +2,9 @@ package fr.xephi.authme.output;
import org.apache.logging.log4j.Level; import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.Marker; import org.apache.logging.log4j.Marker;
import org.apache.logging.log4j.core.Filter;
import org.apache.logging.log4j.core.LogEvent; import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.core.Logger; import org.apache.logging.log4j.core.Logger;
import org.apache.logging.log4j.core.filter.AbstractFilter;
import org.apache.logging.log4j.message.Message; import org.apache.logging.log4j.message.Message;
/** /**
@ -12,7 +12,8 @@ import org.apache.logging.log4j.message.Message;
* *
* @author Xephi59 * @author Xephi59
*/ */
public class Log4JFilter implements Filter { @SuppressWarnings("serial")
public class Log4JFilter extends AbstractFilter {
/** /**
* Constructor. * Constructor.
@ -50,42 +51,30 @@ public class Log4JFilter implements Filter {
} }
@Override @Override
public Result filter(LogEvent record) { public Result filter(LogEvent event) {
if (record == null) { Message candidate = null;
return Result.NEUTRAL; if(event != null) {
candidate = event.getMessage();
} }
return validateMessage(record.getMessage()); return validateMessage(candidate);
} }
@Override @Override
public Result filter(Logger arg0, Level arg1, Marker arg2, String message, Object... arg4) { public Result filter(Logger logger, Level level, Marker marker, Message msg, Throwable t) {
if (message == null) { return validateMessage(msg);
return Result.NEUTRAL; }
@Override
public Result filter(Logger logger, Level level, Marker marker, String msg, Object... params) {
return validateMessage(msg);
}
@Override
public Result filter(Logger logger, Level level, Marker marker, Object msg, Throwable t) {
String candidate = null;
if(msg != null) {
candidate = msg.toString();
} }
return validateMessage(message); return validateMessage(candidate);
} }
@Override
public Result filter(Logger arg0, Level arg1, Marker arg2, Object message, Throwable arg4) {
if (message == null) {
return Result.NEUTRAL;
}
return validateMessage(message.toString());
}
@Override
public Result filter(Logger arg0, Level arg1, Marker arg2, Message message, Throwable arg4) {
return validateMessage(message);
}
@Override
public Result getOnMatch() {
return Result.NEUTRAL;
}
@Override
public Result getOnMismatch() {
return Result.NEUTRAL;
}
} }

View File

@ -135,9 +135,7 @@ public class ProcessSyncPlayerLogin implements SynchronousProcess {
// The Login event now fires (as intended) after everything is processed // The Login event now fires (as intended) after everything is processed
bukkitService.callEvent(new LoginEvent(player)); bukkitService.callEvent(new LoginEvent(player));
player.saveData(); player.saveData();
if (service.getProperty(HooksSettings.BUNGEECORD)) { sendBungeeMessage(player);
sendBungeeMessage(player);
}
// Login is done, display welcome message // Login is done, display welcome message
if (service.getProperty(RegistrationSettings.USE_WELCOME_MESSAGE)) { if (service.getProperty(RegistrationSettings.USE_WELCOME_MESSAGE)) {
if (service.getProperty(RegistrationSettings.BROADCAST_WELCOME_MESSAGE)) { if (service.getProperty(RegistrationSettings.BROADCAST_WELCOME_MESSAGE)) {
@ -162,15 +160,24 @@ public class ProcessSyncPlayerLogin implements SynchronousProcess {
} }
private void sendTo(Player player) { private void sendTo(Player player) {
if (!service.getProperty(HooksSettings.BUNGEECORD_SERVER).isEmpty()) { if(!service.getProperty(HooksSettings.BUNGEECORD)) {
ByteArrayDataOutput out = ByteStreams.newDataOutput(); return;
out.writeUTF("Connect");
out.writeUTF(service.getProperty(HooksSettings.BUNGEECORD_SERVER));
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
} }
if(service.getProperty(HooksSettings.BUNGEECORD_SERVER).isEmpty()) {
return;
}
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF("Connect");
out.writeUTF(service.getProperty(HooksSettings.BUNGEECORD_SERVER));
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
} }
private void sendBungeeMessage(Player player) { private void sendBungeeMessage(Player player) {
if(!service.getProperty(HooksSettings.BUNGEECORD)) {
return;
}
ByteArrayDataOutput out = ByteStreams.newDataOutput(); ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF("Forward"); out.writeUTF("Forward");
out.writeUTF("ALL"); out.writeUTF("ALL");
@ -178,5 +185,4 @@ public class ProcessSyncPlayerLogin implements SynchronousProcess {
out.writeUTF("login;" + player.getName()); out.writeUTF("login;" + player.getName());
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray()); player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
} }
} }

View File

@ -3,7 +3,7 @@ authors: [${bukkitplugin.authors}]
website: ${project.url} website: ${project.url}
description: ${project.description} description: ${project.description}
main: ${bukkitplugin.main} main: ${bukkitplugin.main}
version: ${project.versionCode} version: ${bukkitplugin.versionCode}
softdepend: softdepend:
- Vault - Vault
- PermissionsBukkit - PermissionsBukkit