Project cleanup
This commit is contained in:
parent
54ababdd28
commit
a998354fa2
85
pom.xml
85
pom.xml
@ -7,7 +7,6 @@
|
||||
<groupId>fr.xephi</groupId>
|
||||
<artifactId>authme</artifactId>
|
||||
<version>5.2-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>AuthMeReloaded</name>
|
||||
<description>The first authentication plugin for the Bukkit API!</description>
|
||||
@ -44,10 +43,6 @@
|
||||
</license>
|
||||
</licenses>
|
||||
|
||||
<prerequisites>
|
||||
<maven>3.3.3</maven>
|
||||
</prerequisites>
|
||||
|
||||
<properties>
|
||||
<!-- Project properties -->
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
@ -62,6 +57,7 @@
|
||||
|
||||
<!-- BukkitPlugin properties -->
|
||||
<bukkitplugin.name>${project.outputName}</bukkitplugin.name>
|
||||
<bukkitplugin.version>${project.versionCode}</bukkitplugin.version>
|
||||
<bukkitplugin.main>${project.groupId}.${project.artifactId}.${bukkitplugin.name}</bukkitplugin.main>
|
||||
<bukkitplugin.authors>Xephi, sgdc3, DNx5, timvisee, games647, ljacqu, Gnat008</bukkitplugin.authors>
|
||||
|
||||
@ -69,8 +65,9 @@
|
||||
<bukkit.version>1.10-R0.1-SNAPSHOT</bukkit.version>
|
||||
</properties>
|
||||
|
||||
<!-- Jenkins profile (add the real buildNumber to the version string) -->
|
||||
<!-- Jenkins profile -->
|
||||
<profiles>
|
||||
<!-- Set the buildNumber using the jenkins env. variable -->
|
||||
<profile>
|
||||
<id>jenkins</id>
|
||||
<activation>
|
||||
@ -82,6 +79,7 @@
|
||||
<project.buildNumber>${env.BUILD_NUMBER}</project.buildNumber>
|
||||
</properties>
|
||||
</profile>
|
||||
<!-- Skip long hash tests, reduce the test time of 20-30 seconds -->
|
||||
<profile>
|
||||
<id>skipLongHashTests</id>
|
||||
<activation>
|
||||
@ -96,7 +94,7 @@
|
||||
</profiles>
|
||||
|
||||
<build>
|
||||
<!-- Name of the NOSHADE jar (no shaded/relocated libraries) -->
|
||||
<!-- Name of the unshaded jar (no shaded/relocated libraries) -->
|
||||
<finalName>${project.finalName}-noshade</finalName>
|
||||
|
||||
<resources>
|
||||
@ -135,6 +133,7 @@
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.19.1</version>
|
||||
<configuration>
|
||||
<!-- Force the right file encoding during unit testing -->
|
||||
<argLine>-Dfile.encoding=${project.build.sourceEncoding} @{argLine}</argLine>
|
||||
<systemPropertyVariables>
|
||||
<project.skipExtendedHashTests>${project.skipExtendedHashTests}</project.skipExtendedHashTests>
|
||||
@ -143,20 +142,16 @@
|
||||
</plugin>
|
||||
<!-- Libs Shading and Relocation -->
|
||||
<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>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>2.4.3</version>
|
||||
<configuration>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
<!--
|
||||
Let's try to remove this!
|
||||
<minimizeJar>false</minimizeJar>
|
||||
-->
|
||||
</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>
|
||||
<!-- Spigot 1.8+ -->
|
||||
<execution>
|
||||
@ -173,30 +168,30 @@
|
||||
</excludes>
|
||||
</artifactSet>
|
||||
<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>
|
||||
<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>
|
||||
<shadedPattern>fr.xephi.authme.libs.zaxxer.hikari</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>org.slf4j</pattern>
|
||||
<shadedPattern>fr.xephi.authme.libs.slf4j</shadedPattern>
|
||||
<shadedPattern>fr.xephi.authme.libs.slf4j.slf4j</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.maxmind.geoip</pattern>
|
||||
<shadedPattern>fr.xephi.authme.libs.geoip</shadedPattern>
|
||||
<shadedPattern>fr.xephi.authme.libs.maxmind.geoip</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>net.ricecode.similarity</pattern>
|
||||
<shadedPattern>fr.xephi.authme.libs.similarity</shadedPattern>
|
||||
<shadedPattern>fr.xephi.authme.libs.ricecode.similarity</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>javax.inject</pattern>
|
||||
<shadedPattern>fr.xephi.authme.libs.inject</shadedPattern>
|
||||
<shadedPattern>fr.xephi.authme.libs.javax.inject</shadedPattern>
|
||||
</relocation>
|
||||
<!-- MCStats.org metrics -->
|
||||
<relocation>
|
||||
@ -215,31 +210,31 @@
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<!-- Include all google libraries, because they are not available before 1.8 -->
|
||||
<relocations>
|
||||
<!-- Include all google libraries, because they are not available before 1.8 -->
|
||||
<relocation>
|
||||
<pattern>com.google</pattern>
|
||||
<shadedPattern>fr.xephi.authme.libs.google</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.zaxxer.hikari</pattern>
|
||||
<shadedPattern>fr.xephi.authme.libs.hikari</shadedPattern>
|
||||
<shadedPattern>fr.xephi.authme.libs.zaxxer.hikari</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>org.slf4j</pattern>
|
||||
<shadedPattern>fr.xephi.authme.libs.slf4j</shadedPattern>
|
||||
<shadedPattern>fr.xephi.authme.libs.slf4j.slf4j</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.maxmind.geoip</pattern>
|
||||
<shadedPattern>fr.xephi.authme.libs.geoip</shadedPattern>
|
||||
<shadedPattern>fr.xephi.authme.libs.maxmind.geoip</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>net.ricecode.similarity</pattern>
|
||||
<shadedPattern>fr.xephi.authme.libs.similarity</shadedPattern>
|
||||
<shadedPattern>fr.xephi.authme.libs.ricecode.similarity</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>javax.inject</pattern>
|
||||
<shadedPattern>fr.xephi.authme.libs.inject</shadedPattern>
|
||||
<shadedPattern>fr.xephi.authme.libs.javax.inject</shadedPattern>
|
||||
</relocation>
|
||||
<!-- MCStats.org metrics -->
|
||||
<relocation>
|
||||
@ -252,7 +247,7 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<!-- Exec Tools -->
|
||||
<!-- Exec Plugin (Tools runner) -->
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
@ -267,7 +262,7 @@
|
||||
<includeProjectDependencies>true</includeProjectDependencies>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- Test coverage -->
|
||||
<!-- Coverage report generator -->
|
||||
<plugin>
|
||||
<groupId>org.jacoco</groupId>
|
||||
<artifactId>jacoco-maven-plugin</artifactId>
|
||||
@ -281,7 +276,7 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<!-- Coveralls data -->
|
||||
<!-- Coverage report uploader -->
|
||||
<plugin>
|
||||
<groupId>org.eluder.coveralls</groupId>
|
||||
<artifactId>coveralls-maven-plugin</artifactId>
|
||||
@ -289,9 +284,9 @@
|
||||
<configuration>
|
||||
<failOnServiceError>false</failOnServiceError>
|
||||
</configuration>
|
||||
<!-- The secret token is provided by console! -->
|
||||
<!-- The secret token is provided with a command-line parameter! -->
|
||||
</plugin>
|
||||
<!-- Javadocs settings -->
|
||||
<!-- JavaDocs generator -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
@ -305,9 +300,9 @@
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
<!-- SpigotMC Repo (Bukkit and SpigotAPI) -->
|
||||
<!-- SpigotAPI Repo -->
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<id>spigotmc-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots</url>
|
||||
</repository>
|
||||
|
||||
@ -319,7 +314,7 @@
|
||||
|
||||
<!-- CombatTagPlus Repo -->
|
||||
<repository>
|
||||
<id>minelink-thirdparty</id>
|
||||
<id>minelink-repo</id>
|
||||
<url>http://repo.minelink.net/content/repositories/public</url>
|
||||
</repository>
|
||||
|
||||
@ -331,33 +326,27 @@
|
||||
|
||||
<!-- Multiverse Repo -->
|
||||
<repository>
|
||||
<id>onarandombox</id>
|
||||
<id>onarandombox-repo</id>
|
||||
<url>http://repo.onarandombox.com/content/groups/public</url>
|
||||
</repository>
|
||||
|
||||
<!-- Vault Repo -->
|
||||
<repository>
|
||||
<id>vault-repo</id>
|
||||
<id>theyeticave-repo</id>
|
||||
<url>http://nexus.theyeticave.net/content/repositories/pub_releases</url>
|
||||
</repository>
|
||||
|
||||
<!-- XAuth Repo -->
|
||||
<repository>
|
||||
<id>luricos-releases</id>
|
||||
<id>luricos-repo</id>
|
||||
<url>http://repo.luricos.de/content/repositories/releases</url>
|
||||
</repository>
|
||||
|
||||
<!-- Xephi Repo -->
|
||||
<!-- Our Repo (Many libs) -->
|
||||
<repository>
|
||||
<id>xephi-repo</id>
|
||||
<url>http://ci.xephi.fr/plugin/repository/everything/</url>
|
||||
</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>
|
||||
|
||||
<dependencies>
|
||||
@ -375,6 +364,7 @@
|
||||
</exclusions>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<!-- HikariCP Logger -->
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
@ -387,8 +377,7 @@
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-core</artifactId>
|
||||
<!-- Can't use newer versions due to api changes! -->
|
||||
<version>2.0-beta9</version>
|
||||
<version>2.5</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
@ -69,6 +69,7 @@ import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.bukkit.plugin.PluginLoader;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.plugin.messaging.Messenger;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
@ -90,39 +91,26 @@ import static fr.xephi.authme.settings.properties.EmailSettings.RECALL_PLAYERS;
|
||||
*/
|
||||
public class AuthMe extends JavaPlugin {
|
||||
|
||||
// Defines the name of the plugin.
|
||||
// Name of the plugin.
|
||||
private static final String PLUGIN_NAME = "AuthMeReloaded";
|
||||
|
||||
// Default version and build number values;
|
||||
private static String pluginVersion = "N/D";
|
||||
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
|
||||
*/
|
||||
// TODO #604: Encapsulate ProtocolLib members
|
||||
public AuthMeInventoryPacketAdapter inventoryProtector;
|
||||
public AuthMeTabCompletePacketAdapter tabComplete;
|
||||
public AuthMeTablistPacketAdapter tablistHider;
|
||||
|
||||
// Plugin instance
|
||||
private static AuthMe plugin;
|
||||
|
||||
private NewAPI api;
|
||||
private Management management;
|
||||
private CommandHandler commandHandler;
|
||||
private PermissionsManager permsMan;
|
||||
private NewSetting newSettings;
|
||||
private Messages messages;
|
||||
private JsonCache playerBackup;
|
||||
private PasswordSecurity passwordSecurity;
|
||||
private DataSource database;
|
||||
private PluginHooks pluginHooks;
|
||||
@ -130,6 +118,19 @@ public class AuthMe extends JavaPlugin {
|
||||
private BukkitService bukkitService;
|
||||
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.
|
||||
*/
|
||||
@ -184,7 +185,7 @@ public class AuthMe extends JavaPlugin {
|
||||
}
|
||||
|
||||
// Get version and build number of the plugin
|
||||
private void setPluginInfos() {
|
||||
private void loadPluginInfo() {
|
||||
String versionRaw = this.getDescription().getVersion();
|
||||
int index = versionRaw.lastIndexOf("-");
|
||||
if (index != -1) {
|
||||
@ -201,19 +202,24 @@ public class AuthMe extends JavaPlugin {
|
||||
*/
|
||||
@Override
|
||||
public void onEnable() {
|
||||
// Set various instances
|
||||
// Set the plugin instance and load plugin info from the plugin description.
|
||||
plugin = this;
|
||||
loadPluginInfo();
|
||||
|
||||
// Set the Logger instance and log file path
|
||||
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.
|
||||
newSettings = createNewSetting();
|
||||
if (newSettings == null) {
|
||||
getLogger().warning("Could not load configuration. Aborting.");
|
||||
getServer().shutdown();
|
||||
setEnabled(false);
|
||||
return;
|
||||
}
|
||||
ConsoleLogger.setLogFile(new File(getDataFolder(), "authme.log"));
|
||||
|
||||
// Apply settings to the logger
|
||||
ConsoleLogger.setLoggingOptions(newSettings);
|
||||
|
||||
// Old settings manager
|
||||
@ -232,10 +238,12 @@ public class AuthMe extends JavaPlugin {
|
||||
stopOrUnload();
|
||||
return;
|
||||
}
|
||||
// Convert deprecated PLAINTEXT hash entries
|
||||
MigrationService.changePlainTextToSha256(newSettings, database, new SHA256());
|
||||
|
||||
|
||||
// Injector initialization
|
||||
initializer = new AuthMeServiceInitializer("fr.xephi.authme");
|
||||
|
||||
// Register elements of the Bukkit / JavaPlugin environment
|
||||
initializer.register(AuthMe.class, this);
|
||||
initializer.register(Server.class, getServer());
|
||||
@ -261,21 +269,15 @@ public class AuthMe extends JavaPlugin {
|
||||
// Set up the mail API
|
||||
setupMailApi();
|
||||
|
||||
// Check if the ProtocolLib is available. If so we could listen for
|
||||
// inventory protection
|
||||
// Check if the ProtocolLib is available
|
||||
checkProtocolLib();
|
||||
// End of Hooks
|
||||
|
||||
// Do a backup on start
|
||||
// TODO: maybe create a backup manager?
|
||||
new PerformBackup(this, newSettings).doBackup(PerformBackup.BackupCause.START);
|
||||
|
||||
|
||||
// Setup the inventory backup
|
||||
playerBackup = new JsonCache();
|
||||
|
||||
|
||||
// Set up the BungeeCord hook
|
||||
setupBungeeCordHook(newSettings, initializer);
|
||||
setupBungeeCordHook();
|
||||
|
||||
// Reload support hook
|
||||
reloadSupportHook();
|
||||
@ -396,11 +398,11 @@ public class AuthMe extends JavaPlugin {
|
||||
/**
|
||||
* Set up the BungeeCord hook.
|
||||
*/
|
||||
private void setupBungeeCordHook(NewSetting settings, AuthMeServiceInitializer initializer) {
|
||||
if (settings.getProperty(HooksSettings.BUNGEECORD)) {
|
||||
Bukkit.getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
|
||||
Bukkit.getMessenger().registerIncomingPluginChannel(
|
||||
this, "BungeeCord", initializer.get(BungeeCordMessage.class));
|
||||
private void setupBungeeCordHook() {
|
||||
if (newSettings.getProperty(HooksSettings.BUNGEECORD)) {
|
||||
Messenger messenger = Bukkit.getMessenger();
|
||||
messenger.registerOutgoingPluginChannel(plugin, "BungeeCord");
|
||||
messenger.registerIncomingPluginChannel(plugin, "BungeeCord", initializer.get(BungeeCordMessage.class));
|
||||
}
|
||||
}
|
||||
|
||||
@ -434,18 +436,20 @@ public class AuthMe extends JavaPlugin {
|
||||
* Set up the console filter.
|
||||
*/
|
||||
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();
|
||||
getLogger().setFilter(filter);
|
||||
Bukkit.getLogger().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
|
||||
private void setLog4JFilter() {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
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
|
||||
@ -640,9 +637,6 @@ public class AuthMe extends JavaPlugin {
|
||||
player.setOp(limbo.isOperator());
|
||||
limbo.getTimeoutTask().cancel();
|
||||
limboCache.deleteLimboPlayer(name);
|
||||
if (this.playerBackup.doesCacheExist(player)) {
|
||||
this.playerBackup.removeCache(player);
|
||||
}
|
||||
}
|
||||
PlayerCache.getInstance().removePlayer(name);
|
||||
}
|
||||
@ -719,7 +713,6 @@ public class AuthMe extends JavaPlugin {
|
||||
return commandHandler.processCommand(sender, commandLabel, args);
|
||||
}
|
||||
|
||||
|
||||
// -------------
|
||||
// Service getters (deprecated)
|
||||
// Use @Inject fields instead
|
||||
|
||||
@ -2,9 +2,9 @@ package fr.xephi.authme.output;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
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.Logger;
|
||||
import org.apache.logging.log4j.core.filter.AbstractFilter;
|
||||
import org.apache.logging.log4j.message.Message;
|
||||
|
||||
/**
|
||||
@ -12,7 +12,8 @@ import org.apache.logging.log4j.message.Message;
|
||||
*
|
||||
* @author Xephi59
|
||||
*/
|
||||
public class Log4JFilter implements Filter {
|
||||
@SuppressWarnings("serial")
|
||||
public class Log4JFilter extends AbstractFilter {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@ -50,42 +51,30 @@ public class Log4JFilter implements Filter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result filter(LogEvent record) {
|
||||
if (record == null) {
|
||||
return Result.NEUTRAL;
|
||||
public Result filter(LogEvent event) {
|
||||
Message candidate = null;
|
||||
if(event != null) {
|
||||
candidate = event.getMessage();
|
||||
}
|
||||
return validateMessage(record.getMessage());
|
||||
return validateMessage(candidate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result filter(Logger arg0, Level arg1, Marker arg2, String message, Object... arg4) {
|
||||
if (message == null) {
|
||||
return Result.NEUTRAL;
|
||||
}
|
||||
return validateMessage(message);
|
||||
public Result filter(Logger logger, Level level, Marker marker, Message msg, Throwable t) {
|
||||
return validateMessage(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result filter(Logger arg0, Level arg1, Marker arg2, Object message, Throwable arg4) {
|
||||
if (message == null) {
|
||||
return Result.NEUTRAL;
|
||||
}
|
||||
return validateMessage(message.toString());
|
||||
public Result filter(Logger logger, Level level, Marker marker, String msg, Object... params) {
|
||||
return validateMessage(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result filter(Logger arg0, Level arg1, Marker arg2, Message message, Throwable arg4) {
|
||||
return validateMessage(message);
|
||||
public Result filter(Logger logger, Level level, Marker marker, Object msg, Throwable t) {
|
||||
String candidate = null;
|
||||
if(msg != null) {
|
||||
candidate = msg.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result getOnMatch() {
|
||||
return Result.NEUTRAL;
|
||||
return validateMessage(candidate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result getOnMismatch() {
|
||||
return Result.NEUTRAL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -135,9 +135,7 @@ public class ProcessSyncPlayerLogin implements SynchronousProcess {
|
||||
// The Login event now fires (as intended) after everything is processed
|
||||
bukkitService.callEvent(new LoginEvent(player));
|
||||
player.saveData();
|
||||
if (service.getProperty(HooksSettings.BUNGEECORD)) {
|
||||
sendBungeeMessage(player);
|
||||
}
|
||||
// Login is done, display welcome message
|
||||
if (service.getProperty(RegistrationSettings.USE_WELCOME_MESSAGE)) {
|
||||
if (service.getProperty(RegistrationSettings.BROADCAST_WELCOME_MESSAGE)) {
|
||||
@ -162,15 +160,24 @@ public class ProcessSyncPlayerLogin implements SynchronousProcess {
|
||||
}
|
||||
|
||||
private void sendTo(Player player) {
|
||||
if (!service.getProperty(HooksSettings.BUNGEECORD_SERVER).isEmpty()) {
|
||||
if(!service.getProperty(HooksSettings.BUNGEECORD)) {
|
||||
return;
|
||||
}
|
||||
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) {
|
||||
if(!service.getProperty(HooksSettings.BUNGEECORD)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
||||
out.writeUTF("Forward");
|
||||
out.writeUTF("ALL");
|
||||
@ -178,5 +185,4 @@ public class ProcessSyncPlayerLogin implements SynchronousProcess {
|
||||
out.writeUTF("login;" + player.getName());
|
||||
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@ authors: [${bukkitplugin.authors}]
|
||||
website: ${project.url}
|
||||
description: ${project.description}
|
||||
main: ${bukkitplugin.main}
|
||||
version: ${project.versionCode}
|
||||
version: ${bukkitplugin.versionCode}
|
||||
softdepend:
|
||||
- Vault
|
||||
- PermissionsBukkit
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user