From 2f2af829b020fa618d7bea66e86102b61fcdc65e Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Sun, 7 Feb 2016 15:35:02 +0100 Subject: [PATCH 01/41] Fix event listener priorities --- .../authme/listener/AuthMePlayerListener.java | 39 ++++++++++++------- .../listener/AuthMePlayerListener16.java | 2 +- .../settings/properties/SecuritySettings.java | 1 - .../authme/command/CommandServiceTest.java | 1 - 4 files changed, 25 insertions(+), 18 deletions(-) diff --git a/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java b/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java index bae29ab7..1a55556e 100644 --- a/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java +++ b/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java @@ -188,7 +188,25 @@ public class AuthMePlayerListener implements Listener { } } - @EventHandler(priority = EventPriority.LOWEST) + @EventHandler(priority = EventPriority.HIGHEST) + public void onJoinMessage(PlayerJoinEvent event) { + final Player player = event.getPlayer(); + if (player == null || !Settings.delayJoinLeaveMessages) { + return; + } + + String name = player.getName().toLowerCase(); + String joinMsg = event.getJoinMessage(); + + // Remove the join message while the player isn't logging in + if (joinMsg == null) { + return; + } + event.setJoinMessage(null); + joinMessage.put(name, joinMsg); + } + + @EventHandler(priority = EventPriority.LOW) public void onPlayerJoin(PlayerJoinEvent event) { final Player player = event.getPlayer(); if (player == null) { @@ -200,15 +218,6 @@ public class AuthMePlayerListener implements Listener { player.setGameMode(GameMode.SURVIVAL); } - String name = player.getName().toLowerCase(); - String joinMsg = event.getJoinMessage(); - - // Remove the join message while the player isn't logging in - if (Settings.delayJoinLeaveMessages && joinMsg != null) { - event.setJoinMessage(null); - joinMessage.put(name, joinMsg); - } - // Shedule login task so works after the prelogin // (Fix found by Koolaid5000) Bukkit.getScheduler().runTask(plugin, new Runnable() { @@ -378,7 +387,7 @@ public class AuthMePlayerListener implements Listener { * <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< */ - @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST) + @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) public void onPlayerPickupItem(PlayerPickupItemEvent event) { if (shouldCancelEvent(event)) { event.setCancelled(true); @@ -392,14 +401,14 @@ public class AuthMePlayerListener implements Listener { } } - @EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL) + @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) public void onPlayerConsumeItem(PlayerItemConsumeEvent event) { if (shouldCancelEvent(event)) { event.setCancelled(true); } } - @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST) + @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) public void onPlayerInventoryOpen(InventoryOpenEvent event) { final Player player = (Player) event.getPlayer(); @@ -491,14 +500,14 @@ public class AuthMePlayerListener implements Listener { } } - @EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL) + @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) public void onPlayerShear(PlayerShearEntityEvent event) { if (shouldCancelEvent(event)) { event.setCancelled(true); } } - @EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL) + @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) public void onPlayerFish(PlayerFishEvent event) { if (shouldCancelEvent(event)) { event.setCancelled(true); diff --git a/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener16.java b/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener16.java index cdb4e82a..ee0e581c 100644 --- a/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener16.java +++ b/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener16.java @@ -10,7 +10,7 @@ import org.bukkit.event.player.PlayerEditBookEvent; */ public class AuthMePlayerListener16 implements Listener { - @EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL) + @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) public void onPlayerEditBook(PlayerEditBookEvent event) { if (ListenerService.shouldCancelEvent(event)) { event.setCancelled(true); diff --git a/src/main/java/fr/xephi/authme/settings/properties/SecuritySettings.java b/src/main/java/fr/xephi/authme/settings/properties/SecuritySettings.java index 0cd8a734..6a2ace71 100644 --- a/src/main/java/fr/xephi/authme/settings/properties/SecuritySettings.java +++ b/src/main/java/fr/xephi/authme/settings/properties/SecuritySettings.java @@ -9,7 +9,6 @@ import java.util.List; import static fr.xephi.authme.settings.domain.Property.newProperty; import static fr.xephi.authme.settings.domain.PropertyType.STRING_LIST; -import static fr.xephi.authme.settings.domain.Property.newProperty; public class SecuritySettings implements SettingsClass { diff --git a/src/test/java/fr/xephi/authme/command/CommandServiceTest.java b/src/test/java/fr/xephi/authme/command/CommandServiceTest.java index 4ebd4c8a..929fd26a 100644 --- a/src/test/java/fr/xephi/authme/command/CommandServiceTest.java +++ b/src/test/java/fr/xephi/authme/command/CommandServiceTest.java @@ -14,7 +14,6 @@ import fr.xephi.authme.settings.domain.Property; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import org.mockito.ArgumentCaptor; From 4d057cf05d7b3aebc20962aca792bff45849c87a Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Sun, 7 Feb 2016 18:17:11 +0100 Subject: [PATCH 02/41] Fix unit test --- .../java/fr/xephi/authme/listener/ListenerConsistencyTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/test/java/fr/xephi/authme/listener/ListenerConsistencyTest.java b/src/test/java/fr/xephi/authme/listener/ListenerConsistencyTest.java index 33be12e9..9c805a5a 100644 --- a/src/test/java/fr/xephi/authme/listener/ListenerConsistencyTest.java +++ b/src/test/java/fr/xephi/authme/listener/ListenerConsistencyTest.java @@ -27,7 +27,8 @@ public final class ListenerConsistencyTest { private static final Set CANCELED_EXCEPTIONS = Sets.newHashSet("AuthMePlayerListener#onPlayerJoin", "AuthMePlayerListener#onPreLogin", "AuthMePlayerListener#onPlayerLogin", "AuthMePlayerListener#onPlayerQuit", "AuthMeServerListener#onPluginDisable", - "AuthMeServerListener#onServerPing", "AuthMeServerListener#onPluginEnable"); + "AuthMeServerListener#onServerPing", "AuthMeServerListener#onPluginEnable", + "AuthMeServerListener#onJoinMessage"); @Test public void shouldSetIgnoreCancelledToTrue() { From dd54de48268f61d833fb32bf87986941db33348b Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Sun, 7 Feb 2016 22:00:58 +0100 Subject: [PATCH 03/41] Try to fix pex repo --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c4118541..6267ba10 100644 --- a/pom.xml +++ b/pom.xml @@ -277,7 +277,7 @@ pex-repo - http://pex-repo.aoeu.xyz/ + https://pex-repo.aoeu.xyz// From eee594543b372ddacc21a1fecc50ea2777b8aa30 Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Sun, 7 Feb 2016 22:11:10 +0100 Subject: [PATCH 04/41] Disable pex repo, now pex is hosted on our jenkins server. --- pom.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6267ba10..075802ac 100644 --- a/pom.xml +++ b/pom.xml @@ -274,11 +274,12 @@ http://ci.xephi.fr/plugin/repository/everything/ - + From 960723e13da3425affa92050548fc982265ad178 Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Sun, 7 Feb 2016 22:26:29 +0100 Subject: [PATCH 05/41] FIx twice javadoc generation --- pom.xml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/pom.xml b/pom.xml index 075802ac..1a220025 100644 --- a/pom.xml +++ b/pom.xml @@ -213,14 +213,6 @@ UTF-8 true - - - attach-javadocs - - jar - - - From 49e6b309aba30977b075b0c81fb2b59955fc7e60 Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Sun, 7 Feb 2016 22:41:22 +0100 Subject: [PATCH 06/41] Fix test --- .../java/fr/xephi/authme/listener/ListenerConsistencyTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/fr/xephi/authme/listener/ListenerConsistencyTest.java b/src/test/java/fr/xephi/authme/listener/ListenerConsistencyTest.java index 9c805a5a..5fe3ce26 100644 --- a/src/test/java/fr/xephi/authme/listener/ListenerConsistencyTest.java +++ b/src/test/java/fr/xephi/authme/listener/ListenerConsistencyTest.java @@ -28,7 +28,7 @@ public final class ListenerConsistencyTest { "AuthMePlayerListener#onPreLogin", "AuthMePlayerListener#onPlayerLogin", "AuthMePlayerListener#onPlayerQuit", "AuthMeServerListener#onPluginDisable", "AuthMeServerListener#onServerPing", "AuthMeServerListener#onPluginEnable", - "AuthMeServerListener#onJoinMessage"); + "AuthMePlayerListener#onJoinMessage"); @Test public void shouldSetIgnoreCancelledToTrue() { From 8c68d7e59ed846e53714a0605d6a5873dd34d8b6 Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Sun, 7 Feb 2016 23:18:54 +0100 Subject: [PATCH 07/41] Ad jitpack badge --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index db5494ad..d306fe86 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,8 @@ - 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): Download +- Alternative Dev Build download link (via CircleCi): Download +- JitPack (just in case): [![](https://jitpack.io/v/AuthMe-Team/AuthMeReloaded.svg)](https://jitpack.io/#AuthMe-Team/AuthMeReloaded) - 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) From e5fd0d20257601c00c8edf26d808c8725aae4b68 Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Sun, 7 Feb 2016 23:21:34 +0100 Subject: [PATCH 08/41] Fix pex dependency --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1a220025..1acedf6d 100644 --- a/pom.xml +++ b/pom.xml @@ -399,7 +399,7 @@ ru.tehkode PermissionsEx - 1.23.1 + 1.23.4 provided From 600c70ad9f8277a07181ea5b4181ffe439dd252c Mon Sep 17 00:00:00 2001 From: DNx5 Date: Tue, 9 Feb 2016 04:48:12 +0700 Subject: [PATCH 09/41] Create new class for IPB4 encryption method. --- .../security/crypts/description/IPB4.java | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/main/java/fr/xephi/authme/security/crypts/description/IPB4.java diff --git a/src/main/java/fr/xephi/authme/security/crypts/description/IPB4.java b/src/main/java/fr/xephi/authme/security/crypts/description/IPB4.java new file mode 100644 index 00000000..c5b707a5 --- /dev/null +++ b/src/main/java/fr/xephi/authme/security/crypts/description/IPB4.java @@ -0,0 +1,35 @@ +package fr.xephi.authme.security.crypts.description; + +import fr.xephi.authme.security.crypts.EncryptionMethod; +import fr.xephi.authme.security.crypts.HashedPassword; + + +@Recommendation(Usage.DOES_NOT_WORK) +@HasSalt(value = SaltType.TEXT) +public class IPB4 implements EncryptionMethod { + + @Override + public String computeHash(String password, String salt, String name) { + return null; + } + + @Override + public HashedPassword computeHash(String password, String name) { + return null; + } + + @Override + public boolean comparePassword(String password, HashedPassword hash, String name) { + return false; + } + + @Override + public String generateSalt() { + return null; + } + + @Override + public boolean hasSeparateSalt() { + return false; + } +} From 9959c0f7d5b7ba30795d278bd13d5bb42c1397dc Mon Sep 17 00:00:00 2001 From: DNx5 Date: Tue, 9 Feb 2016 05:04:29 +0700 Subject: [PATCH 10/41] Cleanup BCryptService class --- .../authme/security/crypts/BCryptService.java | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/main/java/fr/xephi/authme/security/crypts/BCryptService.java b/src/main/java/fr/xephi/authme/security/crypts/BCryptService.java index 94ed32c3..194ea7b6 100644 --- a/src/main/java/fr/xephi/authme/security/crypts/BCryptService.java +++ b/src/main/java/fr/xephi/authme/security/crypts/BCryptService.java @@ -388,7 +388,7 @@ public class BCryptService { private static String encode_base64(byte d[], int len) throws IllegalArgumentException { int off = 0; - StringBuffer rs = new StringBuffer(); + StringBuilder rs = new StringBuilder(); int c1, c2; if (len <= 0 || len > d.length) @@ -441,7 +441,7 @@ public class BCryptService { */ private static byte[] decode_base64(String s, int maxolen) throws IllegalArgumentException { - StringBuffer rs = new StringBuffer(); + StringBuilder rs = new StringBuilder(); int off = 0, slen = s.length(), olen = 0; byte ret[]; byte c1, c2, c3, c4, o; @@ -486,7 +486,7 @@ public class BCryptService { * @param lr an array containing the two 32-bit half blocks * @param off the position in the array of the blocks */ - private final void encipher(int lr[], int off) { + private void encipher(int lr[], int off) { int i, n, l = lr[off], r = lr[off + 1]; l ^= P[0]; @@ -534,8 +534,8 @@ public class BCryptService { * Initialise the Blowfish key schedule */ private void init_key() { - P = (int[])P_orig.clone(); - S = (int[])S_orig.clone(); + P = P_orig.clone(); + S = S_orig.clone(); } /** @@ -653,8 +653,8 @@ public class BCryptService { String real_salt; byte passwordb[], saltb[], hashed[]; char minor = (char)0; - int rounds, off = 0; - StringBuffer rs = new StringBuffer(); + int rounds, off; + StringBuilder rs = new StringBuilder(); if (salt.charAt(0) != '$' || salt.charAt(1) != '2') throw new IllegalArgumentException ("Invalid salt version"); @@ -684,8 +684,7 @@ public class BCryptService { saltb = decode_base64(real_salt, BCRYPT_SALT_LEN); B = new BCryptService(); - hashed = B.crypt_raw(passwordb, saltb, rounds, - (int[])bf_crypt_ciphertext.clone()); + hashed = B.crypt_raw(passwordb, saltb, rounds, bf_crypt_ciphertext.clone()); rs.append("$2"); if (minor >= 'a') @@ -714,7 +713,7 @@ public class BCryptService { * @return an encoded salt value */ public static String gensalt(int log_rounds, SecureRandom random) { - StringBuffer rs = new StringBuffer(); + StringBuilder rs = new StringBuilder(); byte rnd[] = new byte[BCRYPT_SALT_LEN]; random.nextBytes(rnd); From 8e38384a0d7b382fad5864e228f4fbb7df5f2696 Mon Sep 17 00:00:00 2001 From: DNx5 Date: Tue, 9 Feb 2016 05:58:59 +0700 Subject: [PATCH 11/41] Implement the encryption method and test unit. --- .../security/crypts/description/IPB4.java | 29 ++++++++++++++++--- .../authme/security/crypts/IPB4Test.java | 22 ++++++++++++++ 2 files changed, 47 insertions(+), 4 deletions(-) create mode 100644 src/test/java/fr/xephi/authme/security/crypts/IPB4Test.java diff --git a/src/main/java/fr/xephi/authme/security/crypts/description/IPB4.java b/src/main/java/fr/xephi/authme/security/crypts/description/IPB4.java index c5b707a5..267d5e09 100644 --- a/src/main/java/fr/xephi/authme/security/crypts/description/IPB4.java +++ b/src/main/java/fr/xephi/authme/security/crypts/description/IPB4.java @@ -1,35 +1,56 @@ package fr.xephi.authme.security.crypts.description; +import fr.xephi.authme.ConsoleLogger; +import fr.xephi.authme.security.crypts.BCryptService; import fr.xephi.authme.security.crypts.EncryptionMethod; import fr.xephi.authme.security.crypts.HashedPassword; +import fr.xephi.authme.util.StringUtils; + +import java.security.SecureRandom; @Recommendation(Usage.DOES_NOT_WORK) @HasSalt(value = SaltType.TEXT) public class IPB4 implements EncryptionMethod { + SecureRandom random = new SecureRandom(); @Override public String computeHash(String password, String salt, String name) { - return null; + return BCryptService.hashpw(password, "$2a$13$" + salt); } @Override public HashedPassword computeHash(String password, String name) { - return null; + String salt = generateSalt(); + return new HashedPassword(computeHash(password, salt, name), salt); } @Override public boolean comparePassword(String password, HashedPassword hash, String name) { + try { + return hash.getHash().length() > 3 && BCryptService.checkpw(password, hash.getHash()); + } catch (IllegalArgumentException e) { + ConsoleLogger.showError("Bcrypt checkpw() returned " + StringUtils.formatException(e)); + } return false; } @Override public String generateSalt() { - return null; + StringBuilder sb = new StringBuilder(22); + for (int i = 0; i < 22; i++) { + char chr; + do { + chr = (char) (random.nextInt((122 - 48) + 1) + 48); + } + while ((chr >= 58 && chr <= 64) || (chr >= 91 && chr <= 96)); + sb.append(chr); + } + return sb.toString(); } @Override public boolean hasSeparateSalt() { - return false; + return true; } } diff --git a/src/test/java/fr/xephi/authme/security/crypts/IPB4Test.java b/src/test/java/fr/xephi/authme/security/crypts/IPB4Test.java new file mode 100644 index 00000000..fc9f9f92 --- /dev/null +++ b/src/test/java/fr/xephi/authme/security/crypts/IPB4Test.java @@ -0,0 +1,22 @@ +package fr.xephi.authme.security.crypts; + +import fr.xephi.authme.security.crypts.description.IPB4; +import fr.xephi.authme.util.WrapperMock; +import org.junit.BeforeClass; + +public class IPB4Test extends AbstractEncryptionMethodTest { + + @BeforeClass + public static void setUpSettings() { + WrapperMock.createInstance(); + } + + public IPB4Test() { + super(new IPB4(), + new HashedPassword("$2a$13$leEvXu77OIwPwNvtZIJvaeAx8EItGHuR3nIlq8416g0gXeJaQdrr2", "leEvXu77OIwPwNvtZIJval"), //password + new HashedPassword("$2a$13$xyTTP9zhQQtRRKIJPv5AuuOGJ6Ni9FLbDhcuIAcPjt3XzCxIWe3Uu", "xyTTP9zhQQtRRKIJPv5Au3"), //PassWord1 + new HashedPassword("$2a$13$rGBrqErm9DZyzbxIGHlgf.xfA15/4d5Ay/TK.3y9lG3AljcoG9Lsi", "rGBrqErm9DZyzbxIGHlgfN"), //&^%te$t?Pw@_ + new HashedPassword("$2a$13$18dKXZLoGpeHHL81edM9HuipiUcMjn5VDJHlxwRUMRXfJ1b.ZQrJ.", "18dKXZLoGpeHHL81edM9H6")); //âË_3(íù* + } + +} From 0f13206a75542f6b8a54edc09ca5b89b0c6722e6 Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Tue, 9 Feb 2016 21:31:17 +0100 Subject: [PATCH 12/41] Provide a jar with shaded guava! Fix #505 #467 --- circle.yml | 5 ++- pom.xml | 108 +++++++++++++++++++++++++++++++++++++---------------- 2 files changed, 79 insertions(+), 34 deletions(-) diff --git a/circle.yml b/circle.yml index da709f38..dea5e80c 100644 --- a/circle.yml +++ b/circle.yml @@ -8,8 +8,9 @@ test: override: - mvn clean install -B post: - - cp ./target/AuthMe*.jar $CIRCLE_ARTIFACTS - - cp ./target/AuthMe-*-SNAPSHOT.jar $CIRCLE_ARTIFACTS/AuthMe.jar + - cp ./target/AuthMe-*-SNAPSHOT-spigot.jar $CIRCLE_ARTIFACTS + - cp ./target/AuthMe-*-SNAPSHOT-legacy.jar $CIRCLE_ARTIFACTS + - cp ./target/AuthMe-*-SNAPSHOT-spigot.jar $CIRCLE_ARTIFACTS/AuthMe.jar notify: webhooks: - url: https://webhooks.gitter.im/e/7b92ac1a1741748b26bf diff --git a/pom.xml b/pom.xml index 1acedf6d..5b851b95 100644 --- a/pom.xml +++ b/pom.xml @@ -52,6 +52,7 @@ AuthMe + ${pluginName}-${project.version} fr.xephi.authme.AuthMe Xephi, sgdc3, DNx5, timvisee, games647, ljacqu Unknown @@ -78,7 +79,7 @@ - AuthMe-${project.version} + ${jarName}-noshade src/main/java src/test/java @@ -137,47 +138,77 @@ - org.apache.maven.plugins maven-shade-plugin 2.4.3 - - false - false - - - org.mcstats - fr.xephi.authme - - - com.google.gson - fr.xephi.authme.libs.gson - - - com.zaxxer.hikari - fr.xephi.authme.libs.hikari - - - org.slf4j - fr.xephi.authme.libs.slf4j - - - com.maxmind.geoip - fr.xephi.authme.libs.geoip - - - net.ricecode.similarity - fr.xephi.authme.libs.similarity - - - + + false + false + + + org.mcstats + fr.xephi.authme + + + org.apache + fr.xephi.authme.libs.apache + + + javax + fr.xephi.authme.libs.javax + + + com.sun + fr.xephi.authme.libs.sun + + + com.google + fr.xephi.authme.libs.google + + + com.zaxxer.hikari + fr.xephi.authme.libs.hikari + + + org.slf4j + fr.xephi.authme.libs.slf4j + + + com.maxmind.geoip + fr.xephi.authme.libs.geoip + + + net.ricecode.similarity + fr.xephi.authme.libs.similarity + + + + spigot-shade package shade + + target/${jarName}-spigot.jar + + + com.google.guava:guava + + + + + + legacy-shade + package + + shade + + + target/${jarName}-legacy.jar + @@ -325,6 +356,15 @@ true + + + com.google.guava + guava + 17.0 + compile + true + + com.maxmind.geoip @@ -373,6 +413,10 @@ persistence-api javax.persistence + + guava + com.google.guava + From 62d55a512e4238ff0354f111ab45b77a2927b670 Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Wed, 10 Feb 2016 13:56:56 +0100 Subject: [PATCH 13/41] Update geoip library --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5b851b95..fc16d564 100644 --- a/pom.xml +++ b/pom.xml @@ -369,7 +369,7 @@ com.maxmind.geoip geoip-api - 1.3.0 + 1.3.1 compile true From cb50f7b8c47568bf18c86f9a60b90f089384571b Mon Sep 17 00:00:00 2001 From: ljacqu Date: Wed, 10 Feb 2016 18:23:30 +0100 Subject: [PATCH 14/41] Minor - move IPB4 to correct package --- .../fr/xephi/authme/security/crypts/{description => }/IPB4.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename src/main/java/fr/xephi/authme/security/crypts/{description => }/IPB4.java (96%) diff --git a/src/main/java/fr/xephi/authme/security/crypts/description/IPB4.java b/src/main/java/fr/xephi/authme/security/crypts/IPB4.java similarity index 96% rename from src/main/java/fr/xephi/authme/security/crypts/description/IPB4.java rename to src/main/java/fr/xephi/authme/security/crypts/IPB4.java index 267d5e09..8bf815f7 100644 --- a/src/main/java/fr/xephi/authme/security/crypts/description/IPB4.java +++ b/src/main/java/fr/xephi/authme/security/crypts/IPB4.java @@ -12,7 +12,7 @@ import java.security.SecureRandom; @Recommendation(Usage.DOES_NOT_WORK) @HasSalt(value = SaltType.TEXT) public class IPB4 implements EncryptionMethod { - SecureRandom random = new SecureRandom(); + private SecureRandom random = new SecureRandom(); @Override public String computeHash(String password, String salt, String name) { From a16f6ae2d0152ead53426dbab87ac818a573ef3f Mon Sep 17 00:00:00 2001 From: ljacqu Date: Wed, 10 Feb 2016 18:28:04 +0100 Subject: [PATCH 15/41] Add IPB4 to hash algorithm enum --- src/main/java/fr/xephi/authme/security/HashAlgorithm.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/fr/xephi/authme/security/HashAlgorithm.java b/src/main/java/fr/xephi/authme/security/HashAlgorithm.java index f6f31830..7bb5681f 100644 --- a/src/main/java/fr/xephi/authme/security/HashAlgorithm.java +++ b/src/main/java/fr/xephi/authme/security/HashAlgorithm.java @@ -13,6 +13,7 @@ public enum HashAlgorithm { CRAZYCRYPT1(fr.xephi.authme.security.crypts.CRAZYCRYPT1.class), DOUBLEMD5(fr.xephi.authme.security.crypts.DOUBLEMD5.class), IPB3(fr.xephi.authme.security.crypts.IPB3.class), + IPB4(fr.xephi.authme.security.crypts.IPB4.class), JOOMLA(fr.xephi.authme.security.crypts.JOOMLA.class), MD5(fr.xephi.authme.security.crypts.MD5.class), MD5VB(fr.xephi.authme.security.crypts.MD5VB.class), @@ -29,8 +30,8 @@ public enum HashAlgorithm { SHA1(fr.xephi.authme.security.crypts.SHA1.class), SHA256(fr.xephi.authme.security.crypts.SHA256.class), SHA512(fr.xephi.authme.security.crypts.SHA512.class), - TWO_FACTOR(fr.xephi.authme.security.crypts.TwoFactor.class), SMF(fr.xephi.authme.security.crypts.SMF.class), + TWO_FACTOR(fr.xephi.authme.security.crypts.TwoFactor.class), WBB3(fr.xephi.authme.security.crypts.WBB3.class), WBB4(fr.xephi.authme.security.crypts.WBB4.class), WHIRLPOOL(fr.xephi.authme.security.crypts.WHIRLPOOL.class), From 248ea2666b5f33190282038d3c882e6c66337fce Mon Sep 17 00:00:00 2001 From: games647 Date: Wed, 10 Feb 2016 18:48:04 +0100 Subject: [PATCH 16/41] Fix correct package declaration -> Fixes building --- src/main/java/fr/xephi/authme/security/crypts/IPB4.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/main/java/fr/xephi/authme/security/crypts/IPB4.java b/src/main/java/fr/xephi/authme/security/crypts/IPB4.java index 8bf815f7..336864b9 100644 --- a/src/main/java/fr/xephi/authme/security/crypts/IPB4.java +++ b/src/main/java/fr/xephi/authme/security/crypts/IPB4.java @@ -1,9 +1,6 @@ -package fr.xephi.authme.security.crypts.description; +package fr.xephi.authme.security.crypts; import fr.xephi.authme.ConsoleLogger; -import fr.xephi.authme.security.crypts.BCryptService; -import fr.xephi.authme.security.crypts.EncryptionMethod; -import fr.xephi.authme.security.crypts.HashedPassword; import fr.xephi.authme.util.StringUtils; import java.security.SecureRandom; From 225df4f9c919075d9db69dce13b7613ad07022e3 Mon Sep 17 00:00:00 2001 From: games647 Date: Wed, 10 Feb 2016 18:51:15 +0100 Subject: [PATCH 17/41] Add missing imports -> fixes building finally --- src/main/java/fr/xephi/authme/security/crypts/IPB4.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/fr/xephi/authme/security/crypts/IPB4.java b/src/main/java/fr/xephi/authme/security/crypts/IPB4.java index 336864b9..515901bc 100644 --- a/src/main/java/fr/xephi/authme/security/crypts/IPB4.java +++ b/src/main/java/fr/xephi/authme/security/crypts/IPB4.java @@ -1,6 +1,10 @@ package fr.xephi.authme.security.crypts; import fr.xephi.authme.ConsoleLogger; +import fr.xephi.authme.security.crypts.description.HasSalt; +import fr.xephi.authme.security.crypts.description.Recommendation; +import fr.xephi.authme.security.crypts.description.SaltType; +import fr.xephi.authme.security.crypts.description.Usage; import fr.xephi.authme.util.StringUtils; import java.security.SecureRandom; From ee962bce114a3a98f963683866afb01e2d079e14 Mon Sep 17 00:00:00 2001 From: games647 Date: Wed, 10 Feb 2016 18:52:34 +0100 Subject: [PATCH 18/41] Add missing imports -> fixes building finally --- src/test/java/fr/xephi/authme/security/crypts/IPB4Test.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/test/java/fr/xephi/authme/security/crypts/IPB4Test.java b/src/test/java/fr/xephi/authme/security/crypts/IPB4Test.java index fc9f9f92..400a266b 100644 --- a/src/test/java/fr/xephi/authme/security/crypts/IPB4Test.java +++ b/src/test/java/fr/xephi/authme/security/crypts/IPB4Test.java @@ -1,6 +1,5 @@ package fr.xephi.authme.security.crypts; -import fr.xephi.authme.security.crypts.description.IPB4; import fr.xephi.authme.util.WrapperMock; import org.junit.BeforeClass; From b8e2f5fe1d2ffb4cb69564e05b263a8963d2e226 Mon Sep 17 00:00:00 2001 From: ljacqu Date: Wed, 10 Feb 2016 21:16:12 +0100 Subject: [PATCH 19/41] Use RandomString for IPB4 implementation; minor documentation - Improve RandomString and create new generateLowerUpper method - Add documentation to the IPB4 class to explain why the salt is stored twice --- .../xephi/authme/security/RandomString.java | 27 ++++++++++--------- .../fr/xephi/authme/security/crypts/IPB4.java | 24 +++++++---------- .../authme/security/RandomStringTest.java | 16 +++++++++++ .../authme/security/crypts/IPB4Test.java | 5 ++++ 4 files changed, 46 insertions(+), 26 deletions(-) diff --git a/src/main/java/fr/xephi/authme/security/RandomString.java b/src/main/java/fr/xephi/authme/security/RandomString.java index 40274305..10926e11 100644 --- a/src/main/java/fr/xephi/authme/security/RandomString.java +++ b/src/main/java/fr/xephi/authme/security/RandomString.java @@ -8,18 +8,10 @@ import java.util.Random; */ public final class RandomString { - private static final char[] chars = new char[36]; + private static final String CHARS = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; private static final Random RANDOM = new SecureRandom(); private static final int HEX_MAX_INDEX = 16; - - static { - for (int idx = 0; idx < 10; ++idx) { - chars[idx] = (char) ('0' + idx); - } - for (int idx = 10; idx < 36; ++idx) { - chars[idx] = (char) ('a' + idx - 10); - } - } + private static final int LOWER_ALPHANUMERIC_INDEX = 36; private RandomString() { } @@ -31,7 +23,7 @@ public final class RandomString { * @return The random string */ public static String generate(int length) { - return generate(length, chars.length); + return generate(length, LOWER_ALPHANUMERIC_INDEX); } /** @@ -45,13 +37,24 @@ public final class RandomString { return generate(length, HEX_MAX_INDEX); } + /** + * Generate a random string with digits and lowercase and uppercase letters. The result of this + * method matches the pattern [0-9a-zA-Z]. + * + * @param length The length of the random string to generate + * @return The random string + */ + public static String generateLowerUpper(int length) { + return generate(length, CHARS.length()); + } + private static String generate(int length, int maxIndex) { if (length < 0) { throw new IllegalArgumentException("Length must be positive but was " + length); } StringBuilder sb = new StringBuilder(length); for (int i = 0; i < length; ++i) { - sb.append(chars[RANDOM.nextInt(maxIndex)]); + sb.append(CHARS.charAt(RANDOM.nextInt(maxIndex))); } return sb.toString(); } diff --git a/src/main/java/fr/xephi/authme/security/crypts/IPB4.java b/src/main/java/fr/xephi/authme/security/crypts/IPB4.java index 515901bc..e54bcd03 100644 --- a/src/main/java/fr/xephi/authme/security/crypts/IPB4.java +++ b/src/main/java/fr/xephi/authme/security/crypts/IPB4.java @@ -1,19 +1,24 @@ package fr.xephi.authme.security.crypts; import fr.xephi.authme.ConsoleLogger; +import fr.xephi.authme.security.RandomString; import fr.xephi.authme.security.crypts.description.HasSalt; import fr.xephi.authme.security.crypts.description.Recommendation; import fr.xephi.authme.security.crypts.description.SaltType; import fr.xephi.authme.security.crypts.description.Usage; import fr.xephi.authme.util.StringUtils; -import java.security.SecureRandom; - +/** + * Implementation for IPB4 (Invision Power Board 4). + *

+ * The hash uses standard BCrypt with 13 as log2 number of rounds. Additionally, + * IPB4 requires that the salt be stored additionally in the column "members_pass_hash" + * (even though BCrypt hashes already have the salt in the result). + */ @Recommendation(Usage.DOES_NOT_WORK) -@HasSalt(value = SaltType.TEXT) +@HasSalt(value = SaltType.TEXT, length = 22) public class IPB4 implements EncryptionMethod { - private SecureRandom random = new SecureRandom(); @Override public String computeHash(String password, String salt, String name) { @@ -38,16 +43,7 @@ public class IPB4 implements EncryptionMethod { @Override public String generateSalt() { - StringBuilder sb = new StringBuilder(22); - for (int i = 0; i < 22; i++) { - char chr; - do { - chr = (char) (random.nextInt((122 - 48) + 1) + 48); - } - while ((chr >= 58 && chr <= 64) || (chr >= 91 && chr <= 96)); - sb.append(chr); - } - return sb.toString(); + return RandomString.generateLowerUpper(22); } @Override diff --git a/src/test/java/fr/xephi/authme/security/RandomStringTest.java b/src/test/java/fr/xephi/authme/security/RandomStringTest.java index 938f095c..71ea587c 100644 --- a/src/test/java/fr/xephi/authme/security/RandomStringTest.java +++ b/src/test/java/fr/xephi/authme/security/RandomStringTest.java @@ -44,6 +44,22 @@ public class RandomStringTest { } } + @Test + public void shouldGenerateRandomLowerUpperString() { + // given + int[] lengths = {0, 1, 17, 143, 1808}; + Pattern badChars = Pattern.compile(".*[^0-9a-zA-Z].*"); + + // when / then + for (int length : lengths) { + String result = RandomString.generateHex(length); + assertThat("Result '" + result + "' should have length " + length, + result.length(), equalTo(length)); + assertThat("Result '" + result + "' should only have characters a-z, A-Z, 0-9", + badChars.matcher(result).matches(), equalTo(false)); + } + } + @Test(expected = IllegalArgumentException.class) public void shouldThrowForInvalidLength() { // given/when diff --git a/src/test/java/fr/xephi/authme/security/crypts/IPB4Test.java b/src/test/java/fr/xephi/authme/security/crypts/IPB4Test.java index 400a266b..58c6f570 100644 --- a/src/test/java/fr/xephi/authme/security/crypts/IPB4Test.java +++ b/src/test/java/fr/xephi/authme/security/crypts/IPB4Test.java @@ -1,13 +1,18 @@ package fr.xephi.authme.security.crypts; +import fr.xephi.authme.ConsoleLoggerTestInitializer; import fr.xephi.authme.util.WrapperMock; import org.junit.BeforeClass; +/** + * Test for {@link IPB4}. + */ public class IPB4Test extends AbstractEncryptionMethodTest { @BeforeClass public static void setUpSettings() { WrapperMock.createInstance(); + ConsoleLoggerTestInitializer.setupLogger(); } public IPB4Test() { From 806fd4731ebc45d9e2f373f2c6111b99bc8539a1 Mon Sep 17 00:00:00 2001 From: ljacqu Date: Wed, 10 Feb 2016 21:52:11 +0100 Subject: [PATCH 20/41] Update readme to refer to AuthMe-Team/AuthMeReloaded - Updated various "build badges" to display data for the AuthMe repository of AuthMe-Team - Move Gource video a little down - Mention support of IPB4 in readme and config --- README.md | 17 +++++++++-------- src/main/resources/config.yml | 6 +++--- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index d306fe86..c862068f 100644 --- a/README.md +++ b/README.md @@ -2,18 +2,17 @@

The most used authentication plugin for CraftBukkit/Spigot!


-####Development history: -[![Gource AuthMe History Video](http://img.youtube.com/vi/hJRzNfYyd9k/hqdefault.jpg)](https://www.youtube.com/watch?v=hJRzNfYyd9k) - #####Development tools: - DEVELOPMENT TEAM REPO (please send PRs here!): Github Development Page - Developers ChatRoom: [![Join the chat at https://gitter.im/Xephi/AuthMeReloaded](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/Xephi/AuthMeReloaded?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -- 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 Server (DEVELOPMENT BUILDS): Xephi's Jenkins -- Build status (CircleCI): [![Circle CI](https://circleci.com/gh/Xephi/AuthMeReloaded.svg?style=svg)](https://circleci.com/gh/Xephi/AuthMeReloaded) +- Build status: [![Build Status](https://travis-ci.org/AuthMe-Team/AuthMeReloaded.svg?branch=master)](https://travis-ci.org/AuthMe-Team/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/AuthMe-Team/AuthMeReloaded.svg?style=svg)](https://circleci.com/gh/AuthMe-Team/AuthMeReloaded) - Alternative Dev Build download link (via CircleCi): Download - JitPack (just in case): [![](https://jitpack.io/v/AuthMe-Team/AuthMeReloaded.svg)](https://jitpack.io/#AuthMe-Team/AuthMeReloaded) @@ -21,9 +20,7 @@ - Issue Tracking : [![Stories in Ready](https://badge.waffle.io/Xephi/AuthMeReloaded.png?label=ready&title=Ready)](https://waffle.io/Xephi/AuthMeReloaded) [![Stories in Bugs](https://badge.waffle.io/Xephi/AuthMeReloaded.png?label=bugs&title=Bugs)](https://waffle.io/Xephi/AuthMeReloaded) [![Stories in In%20Progress](https://badge.waffle.io/Xephi/AuthMeReloaded.png?label=in%20progress&title=In%20Progress)](https://waffle.io/Xephi/AuthMeReloaded) -- Build Server (DEVELOPMENT BUILDS): Xephi's Jenkins - -- JavaDocs: AuthMe Javadoc +- JavaDoc: AuthMe Javadoc - Maven Repo: AuthMe Repo @@ -37,6 +34,9 @@ McStats: http://mcstats.org/plugin/AuthMe +#####Development history: +[![Gource AuthMe History Video](http://img.youtube.com/vi/hJRzNfYyd9k/hqdefault.jpg)](https://www.youtube.com/watch?v=hJRzNfYyd9k) +
#####Compiling Requirements: @@ -84,6 +84,7 @@ typing commands or using the inventory. It can also kick players with uncommonly
  • Xenforo: XFBCRYPT
  • MyBB: MYBB
  • IPB3: IPB3
  • +
  • IPB4: IPB4
  • PhpFusion: PHPFUSION
  • Joomla: JOOMLA
  • WBB3: WBB3*
  • diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index c9cdbfe6..151bc753 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -186,7 +186,7 @@ settings: # Example unLoggedinGroup: NotLogged unLoggedinGroup: unLoggedinGroup # possible values: MD5, SHA1, SHA256, WHIRLPOOL, XAUTH, MD5VB, PHPBB, - # MYBB, IPB3, PHPFUSION, SMF, XENFORO, SALTED2MD5, JOOMLA, BCRYPT, WBB3, SHA512, + # MYBB, IPB3, IPB4, PHPFUSION, SMF, XENFORO, SALTED2MD5, JOOMLA, BCRYPT, WBB3, SHA512, # DOUBLEMD5, PBKDF2, PBKDF2DJANGO, WORDPRESS, ROYALAUTH, CUSTOM(for developpers only) passwordHash: SHA256 # salt length for the SALTED2MD5 MD5(MD5(password)+salt) @@ -260,7 +260,7 @@ settings: # If Xephi is registered, then Xephi can login, but not XEPHI/xephi/XePhI preventOtherCase: false ExternalBoardOptions: - # MySQL column for the salt , needed for some forum/cms support + # MySQL column for the salt, needed for some forum/cms support mySQLColumnSalt: '' # MySQL column for the group, needed for some forum/cms support mySQLColumnGroup: '' @@ -275,7 +275,7 @@ ExternalBoardOptions: bCryptLog2Round: 10 # phpBB prefix defined during phpbb installation process phpbbTablePrefix: 'phpbb_' - # phpBB activated group id , 2 is default registered group defined by phpbb + # phpBB activated group id, 2 is default registered group defined by phpbb phpbbActivatedGroupId: 2 # WordPress prefix defined during WordPress installation process wordpressTablePrefix: 'wp_' From 0cb0bbcd3726862599a49928dea4968bf81db15e Mon Sep 17 00:00:00 2001 From: games647 Date: Wed, 10 Feb 2016 22:22:53 +0100 Subject: [PATCH 21/41] Don't relocate libraries that are available in spigot --- pom.xml | 164 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 85 insertions(+), 79 deletions(-) diff --git a/pom.xml b/pom.xml index fc16d564..7c867632 100644 --- a/pom.xml +++ b/pom.xml @@ -136,86 +136,92 @@ 1.7 ${javaVersion} - + - - org.apache.maven.plugins - maven-shade-plugin - 2.4.3 - - false - false - - - org.mcstats - fr.xephi.authme - - - org.apache - fr.xephi.authme.libs.apache - - - javax - fr.xephi.authme.libs.javax - - - com.sun - fr.xephi.authme.libs.sun - - - com.google - fr.xephi.authme.libs.google - - - com.zaxxer.hikari - fr.xephi.authme.libs.hikari - - - org.slf4j - fr.xephi.authme.libs.slf4j - - - com.maxmind.geoip - fr.xephi.authme.libs.geoip - - - net.ricecode.similarity - fr.xephi.authme.libs.similarity - - - - - - spigot-shade - package - - shade - - - target/${jarName}-spigot.jar - - - com.google.guava:guava - - - - - - legacy-shade - package - - shade - - - target/${jarName}-legacy.jar - - - - - - - org.jacoco - jacoco-maven-plugin + + org.apache.maven.plugins + maven-shade-plugin + 2.4.3 + + false + false + + + org.mcstats + fr.xephi.authme + + + org.apache + fr.xephi.authme.libs.apache + + + javax.mail + fr.xephi.authme.libs.javax.mail + + + javax.activation + fr.xephi.authme.libs.javax.activation + + + com.sun + fr.xephi.authme.libs.sun + + + com.zaxxer.hikari + fr.xephi.authme.libs.hikari + + + org.slf4j + fr.xephi.authme.libs.slf4j + + + com.maxmind.geoip + fr.xephi.authme.libs.geoip + + + net.ricecode.similarity + fr.xephi.authme.libs.similarity + + + + + + spigot-shade + package + + shade + + + + + com.google.guava:guava + com.google.code.gson:gson + + + target/${jarName}-spigot.jar + + + + legacy-shade + package + + shade + + + + + com.google + fr.xephi.authme.libs.google + + + target/${jarName}-legacy.jar + + + + + + org.jacoco + jacoco-maven-plugin 0.7.5.201505241946 From e1b7303f61d40f50047ba0eade7c89c97b7e2503 Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Wed, 10 Feb 2016 22:43:28 +0100 Subject: [PATCH 22/41] Spaces please! + we need to shade gson because we are using version 2.5, bukkit's one is 2.2.4 (api conflicts)! --- pom.xml | 1460 +++++++++++++++++++++++++++---------------------------- 1 file changed, 727 insertions(+), 733 deletions(-) diff --git a/pom.xml b/pom.xml index 7c867632..dce8e3d5 100644 --- a/pom.xml +++ b/pom.xml @@ -1,782 +1,776 @@ - 4.0.0 + xmlns="http://maven.apache.org/POM/4.0.0" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 - fr.xephi - authme - 5.2-SNAPSHOT - jar + fr.xephi + authme + 5.2-SNAPSHOT + jar - AuthMeReloaded - Authentication plugin for CraftBukkit/Spigot! - 2013 - http://dev.bukkit.org/bukkit-plugins/authme-reloaded/ - + AuthMeReloaded + Authentication plugin for CraftBukkit/Spigot! + 2013 + http://dev.bukkit.org/bukkit-plugins/authme-reloaded/ + - - AuthMe-Team - https://github.com/AuthMe-Team - + + AuthMe-Team + https://github.com/AuthMe-Team + - - scm:git:https://github.com/Xephi/AuthMeReloaded.git - scm:git:git@github.com:Xephi/AuthMeReloaded.git - http://github.com/Xephi/AuthMeReloaded - + + scm:git:https://github.com/Xephi/AuthMeReloaded.git + scm:git:git@github.com:Xephi/AuthMeReloaded.git + http://github.com/Xephi/AuthMeReloaded + - - jenkins - http://ci.xephi.fr/job/AuthMeReloaded/ - + + jenkins + http://ci.xephi.fr/job/AuthMeReloaded/ + - - GitHub - https://github.com/Xephi/AuthMeReloaded/issues - + + GitHub + https://github.com/Xephi/AuthMeReloaded/issues + - - - The GNU General Public Licence version 3 (GPLv3) - http://www.gnu.org/licenses/gpl-3.0.html - - + + + The GNU General Public Licence version 3 (GPLv3) + http://www.gnu.org/licenses/gpl-3.0.html + + - - 3.3.3 - + + 3.3.3 + - - UTF-8 + + UTF-8 - - AuthMe - ${pluginName}-${project.version} - fr.xephi.authme.AuthMe - Xephi, sgdc3, DNx5, timvisee, games647, ljacqu - Unknown + + AuthMe + ${pluginName}-${project.version} + fr.xephi.authme.AuthMe + Xephi, sgdc3, DNx5, timvisee, games647, ljacqu + Unknown - - 1.7 + + 1.7 - - 1.8.8-R0.1-SNAPSHOT - + + 1.8.8-R0.1-SNAPSHOT + - - - jenkins - - - env.BUILD_NUMBER - - - - ${env.BUILD_NUMBER} - - - + + + jenkins + + + env.BUILD_NUMBER + + + + ${env.BUILD_NUMBER} + + + - - ${jarName}-noshade - src/main/java - src/test/java + + ${jarName}-noshade + src/main/java + src/test/java - - - . - true - src/main/resources/ - - plugin.yml - - - - . - true - src/main/resources/ - - email.html + + + . + true + src/main/resources/ + + plugin.yml + + + + . + true + src/main/resources/ + + email.html welcome.txt - - - - . - false - src/main/resources/ - - *.yml - - - plugin.yml - - - - ./messages/ - false - src/main/resources/messages/ - - *.yml - - - - - - src/test/resources - - + + + + . + false + src/main/resources/ + + *.yml + + + plugin.yml + + + + ./messages/ + false + src/main/resources/messages/ + + *.yml + + + + + + src/test/resources + + - - - org.apache.maven.plugins - maven-compiler-plugin - 3.5 - - 1.7 - ${javaVersion} - - + + + org.apache.maven.plugins + maven-compiler-plugin + 3.5 + + 1.7 + ${javaVersion} + + + + org.apache.maven.plugins + maven-shade-plugin + 2.4.3 + + false + false + + + org.mcstats + fr.xephi.authme + + + org.apache + fr.xephi.authme.libs.apache + + + javax.mail + fr.xephi.authme.libs.javax.mail + + + javax.activation + fr.xephi.authme.libs.javax.activation + + + com.sun + fr.xephi.authme.libs.sun + + + com.zaxxer.hikari + fr.xephi.authme.libs.hikari + + + org.slf4j + fr.xephi.authme.libs.slf4j + + + com.maxmind.geoip + fr.xephi.authme.libs.geoip + + + net.ricecode.similarity + fr.xephi.authme.libs.similarity + + + com.google + fr.xephi.authme.libs.google + + + + + + spigot-shade + package + + shade + + + + + com.google.guava:guava + + + target/${jarName}-spigot.jar + + + + legacy-shade + package + + shade + + + target/${jarName}-legacy.jar + + + + + + org.jacoco + jacoco-maven-plugin + 0.7.5.201505241946 + + + prepare-agent + + prepare-agent + + + + + + org.eluder.coveralls + coveralls-maven-plugin + 4.1.0 + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.10.3 + + UTF-8 + UTF-8 + true + + + + - - org.apache.maven.plugins - maven-shade-plugin - 2.4.3 - - false - false - - - org.mcstats - fr.xephi.authme - - - org.apache - fr.xephi.authme.libs.apache - - - javax.mail - fr.xephi.authme.libs.javax.mail - - - javax.activation - fr.xephi.authme.libs.javax.activation - - - com.sun - fr.xephi.authme.libs.sun - - - com.zaxxer.hikari - fr.xephi.authme.libs.hikari - - - org.slf4j - fr.xephi.authme.libs.slf4j - - - com.maxmind.geoip - fr.xephi.authme.libs.geoip - - - net.ricecode.similarity - fr.xephi.authme.libs.similarity - - - - - - spigot-shade - package - - shade - - - - - com.google.guava:guava - com.google.code.gson:gson - - - target/${jarName}-spigot.jar - - - - legacy-shade - package - - shade - - - - - com.google - fr.xephi.authme.libs.google - - - target/${jarName}-legacy.jar - - - - - - org.jacoco - jacoco-maven-plugin - 0.7.5.201505241946 - - - prepare-agent - - prepare-agent - - - - + + + + spigot-repo + https://hub.spigotmc.org/nexus/content/repositories/snapshots + - - org.eluder.coveralls - coveralls-maven-plugin - 4.1.0 - - + + + ess-repo + http://ci.drtshock.net/plugin/repository/everything + - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.10.3 - - UTF-8 - UTF-8 - true - - - - + + + minelink-thirdparty + http://repo.minelink.net/content/repositories/public + - - - - spigot-repo - https://hub.spigotmc.org/nexus/content/repositories/snapshots - + + + dmulloy2-repo + http://repo.dmulloy2.net/content/groups/public/ + - - - ess-repo - http://ci.drtshock.net/plugin/repository/everything - + + + onarandombox + http://repo.onarandombox.com/content/groups/public + - - - minelink-thirdparty - http://repo.minelink.net/content/repositories/public - + + + vault-repo + http://nexus.theyeticave.net/content/repositories/pub_releases + - - - dmulloy2-repo - http://repo.dmulloy2.net/content/groups/public/ - + + + luricos-releases + http://repo.luricos.de/content/repositories/releases + - - - onarandombox - http://repo.onarandombox.com/content/groups/public - + + + xephi-repo + http://ci.xephi.fr/plugin/repository/everything/ + - - - vault-repo - http://nexus.theyeticave.net/content/repositories/pub_releases - + + - - - luricos-releases - http://repo.luricos.de/content/repositories/releases - + + + + com.zaxxer + HikariCP + 2.4.3 + compile + + + slf4j-api + org.slf4j + + + true + + + org.slf4j + slf4j-jdk14 + 1.7.14 + compile + true + - - - xephi-repo - http://ci.xephi.fr/plugin/repository/everything/ - + + + org.apache.logging.log4j + log4j-core + + 2.0-beta9 + provided + true + - - + + + org.apache.commons + commons-email + 1.4 + compile + true + - - - - com.zaxxer - HikariCP - 2.4.3 - compile - - - slf4j-api - org.slf4j - - - true - - - org.slf4j - slf4j-jdk14 - 1.7.14 - compile - true - + + + com.google.code.gson + gson + 2.5 + compile + true + - - - org.apache.logging.log4j - log4j-core - - 2.0-beta9 - provided - true - + + + com.google.guava + guava + 17.0 + compile + true + - - - org.apache.commons - commons-email - 1.4 - compile - true - + + + com.maxmind.geoip + geoip-api + 1.3.1 + compile + true + - - - com.google.code.gson - gson - 2.5 - compile - true - + + + org.mcstats.bukkit + metrics + R8-SNAPSHOT + compile + + + org.bukkit + bukkit + + + true + - - - com.google.guava - guava - 17.0 - compile - true - + + + org.bukkit + bukkit + ${bukkitVersion} + provided + true + + + junit + junit + + + json-simple + com.googlecode.json-simple + + + gson + com.google.code.gson + + + persistence-api + javax.persistence + + + guava + com.google.guava + + + - - - com.maxmind.geoip - geoip-api - 1.3.1 - compile - true - + + + com.comphenix.protocol + ProtocolLib + 3.6.5-SNAPSHOT + provided + true + + + cglib-nodep + cglib + + + BukkitExecutors + com.comphenix.executors + + + - - - org.mcstats.bukkit - metrics - R8-SNAPSHOT - compile - - - org.bukkit - bukkit - - - true - + + + ru.tehkode + PermissionsEx + 1.23.4 + provided + + + org.bukkit + bukkit + + + net.gravitydevelopment.updater + updater + + + commons-dbcp + commons-dbcp + + + AccountsClient + com.mojang + + + - - - org.bukkit - bukkit - ${bukkitVersion} - provided - true - - - junit - junit - - - json-simple - com.googlecode.json-simple - - - gson - com.google.code.gson - - - persistence-api - javax.persistence - - - guava - com.google.guava - - - + + + org.anjocaido + groupmanagerx + 2.2-SNAPSHOT + provided + + + org.bukkit + bukkit + + + - - - com.comphenix.protocol - ProtocolLib - 3.6.5-SNAPSHOT - provided - true - - - cglib-nodep - cglib - - - BukkitExecutors - com.comphenix.executors - - - + + + de.bananaco + bPermissions + 2.12-DEV + provided + + + org.bukkit + bukkit + + + - - - ru.tehkode - PermissionsEx - 1.23.4 - provided - - - org.bukkit - bukkit - - - net.gravitydevelopment.updater - updater - - - commons-dbcp - commons-dbcp - - - AccountsClient - com.mojang - - - + + + org.tyrannyofheaven.bukkit + zPermissions + 1.3-SNAPSHOT + provided + + + org.bukkit + bukkit + + + com.sk89q + worldguard + + + com.sk89q + worldedit + + + VaultAPI + net.milkbowl.vault + + + uuidprovider + net.kaikk.mc + + + ToHPluginUtils + org.tyrannyofheaven.bukkit + + + - - - org.anjocaido - groupmanagerx - 2.2-SNAPSHOT - provided - - - org.bukkit - bukkit - - - + + + net.milkbowl.vault + VaultAPI + 1.5 + provided + + + org.bukkit + bukkit + + + org.bukkit + craftbukkit + + + true + - - - de.bananaco - bPermissions - 2.12-DEV - provided - - - org.bukkit - bukkit - - - + + + com.onarandombox.multiversecore + Multiverse-Core + 2.5 + jar + provided + + + org.bukkit + bukkit + + + org.bukkit + craftbukkit + + + AllPay + com.fernferret.allpay + + + Vault + net.milkbowl.vault + + + VaultAPI + net.milkbowl.vault + + + CommandHandler + com.pneumaticraft.commandhandler + + + SerializationConfig + me.main__.util + + + Logging + com.dumptruckman.minecraft + + + metrics + org.mcstats.bukkit + + + buscript + com.dumptruckman.minecraft + + + junit + junit + + + true + - - - org.tyrannyofheaven.bukkit - zPermissions - 1.3-SNAPSHOT - provided - - - org.bukkit - bukkit - - - com.sk89q - worldguard - - - com.sk89q - worldedit - - - VaultAPI - net.milkbowl.vault - - - uuidprovider - net.kaikk.mc - - - ToHPluginUtils - org.tyrannyofheaven.bukkit - - - + + + net.ess3 + EssentialsX + 2.0.1-SNAPSHOT + provided + + + org.spigotmc + spigot-api + + + true + - - - net.milkbowl.vault - VaultAPI - 1.5 - provided - - - org.bukkit - bukkit - - - org.bukkit - craftbukkit - - - true - + + + net.minelink + CombatTagPlus + 1.2.1-SNAPSHOT + provided + + + org.bukkit + bukkit + + + org.bukkit + craftbukkit + + + CombatTagPlusHook + net.minelink + + + CombatTagPlusFactions-v1_6 + net.minelink + + + CombatTagPlusCompat-v1_7_R3 + net.minelink + + + CombatTagPlusFactions-v1_8 + net.minelink + + + CombatTagPlusCompat-v1_7_R4 + net.minelink + + + CombatTagPlusWG-v5 + net.minelink + + + CombatTagPlusWG-v6 + net.minelink + + + CombatTagPlusCompat-API + net.minelink + + + CombatTagPlusFactions-v2_6 + net.minelink + + + CombatTagPlusCompat-v1_8_R3 + net.minelink + + + CombatTagPlusFactions-v2_7 + net.minelink + + + CombatTagPlusCompat-v1_8_R2 + net.minelink + + + CombatTagPlusCompat-v1_8_R1 + net.minelink + + + metrics-lite + org.mcstats.bukkit + + + true + - - - com.onarandombox.multiversecore - Multiverse-Core - 2.5 - jar - provided - - - org.bukkit - bukkit - - - org.bukkit - craftbukkit - - - AllPay - com.fernferret.allpay - - - Vault - net.milkbowl.vault - - - VaultAPI - net.milkbowl.vault - - - CommandHandler - com.pneumaticraft.commandhandler - - - SerializationConfig - me.main__.util - - - Logging - com.dumptruckman.minecraft - - - metrics - org.mcstats.bukkit - - - buscript - com.dumptruckman.minecraft - - - junit - junit - - - true - + + + de.luricos.bukkit + xAuth + 2.6 + provided + + + org.bukkit + bukkit + + + org.bukkit + craftbukkit + + + updater + net.gravitydevelopment.updater + + + lombok + org.projectlombok + + + EssentialsGroupManager + net.ess3 + + + PermissionsEx + ru.tehkode + + + AccountsClient + com.mojang + + + log4j-core + org.apache.logging.log4j + + + true + - - - net.ess3 - EssentialsX - 2.0.1-SNAPSHOT - provided - - - org.spigotmc - spigot-api - - - true - + + + junit + junit + test + 4.12 + true + + + org.hamcrest + java-hamcrest + test + 2.0.0.0 + true + + + org.mockito + mockito-core + test + 2.0.5-beta + true + + + hamcrest-core + org.hamcrest + + + - - - net.minelink - CombatTagPlus - 1.2.1-SNAPSHOT - provided - - - org.bukkit - bukkit - - - org.bukkit - craftbukkit - - - CombatTagPlusHook - net.minelink - - - CombatTagPlusFactions-v1_6 - net.minelink - - - CombatTagPlusCompat-v1_7_R3 - net.minelink - - - CombatTagPlusFactions-v1_8 - net.minelink - - - CombatTagPlusCompat-v1_7_R4 - net.minelink - - - CombatTagPlusWG-v5 - net.minelink - - - CombatTagPlusWG-v6 - net.minelink - - - CombatTagPlusCompat-API - net.minelink - - - CombatTagPlusFactions-v2_6 - net.minelink - - - CombatTagPlusCompat-v1_8_R3 - net.minelink - - - CombatTagPlusFactions-v2_7 - net.minelink - - - CombatTagPlusCompat-v1_8_R2 - net.minelink - - - CombatTagPlusCompat-v1_8_R1 - net.minelink - - - metrics-lite - org.mcstats.bukkit - - - true - - - - - de.luricos.bukkit - xAuth - 2.6 - provided - - - org.bukkit - bukkit - - - org.bukkit - craftbukkit - - - updater - net.gravitydevelopment.updater - - - lombok - org.projectlombok - - - EssentialsGroupManager - net.ess3 - - - PermissionsEx - ru.tehkode - - - AccountsClient - com.mojang - - - log4j-core - org.apache.logging.log4j - - - true - - - - - junit - junit - test - 4.12 - true - - - org.hamcrest - java-hamcrest - test - 2.0.0.0 - true - - - org.mockito - mockito-core - test - 2.0.5-beta - true - - - hamcrest-core - org.hamcrest - - - - - - - net.ricecode - string-similarity - 1.0.0 - compile - true - - + + + net.ricecode + string-similarity + 1.0.0 + compile + true + + From ccc6aa55cf860196873f09dc0609a8a5322c05b3 Mon Sep 17 00:00:00 2001 From: Nathan Guedes Date: Thu, 11 Feb 2016 00:48:21 -0200 Subject: [PATCH 23/41] Update messages_br.yml --- src/main/resources/messages/messages_br.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/messages/messages_br.yml b/src/main/resources/messages/messages_br.yml index 705007fe..922a5b96 100644 --- a/src/main/resources/messages/messages_br.yml +++ b/src/main/resources/messages/messages_br.yml @@ -59,4 +59,4 @@ email_exists: '&cUm email de recuperação já foi enviado! Você pode reenviar country_banned: '&4Seu país foi banido do servidor! Your country is banned from this server!' antibot_auto_enabled: '&4[AntiBotService] AntiBot ativado devido ao grande número de conexões!' antibot_auto_disabled: '&2[AntiBotService] AntiBot desativado após %m minutos!' -two_factor_create: '&2Your secret code is %code' +two_factor_create: '&2Seu código secreto é %code' From dee194b4dbb28081018889a23ad76a47c93f8503 Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Thu, 11 Feb 2016 11:01:43 +0100 Subject: [PATCH 24/41] move samples into a proper directory --- NewConfig.yml => samples/NewConfig.yml | 0 newPlugin.yml => samples/NewPlugin.yml | 0 xenforo.sql => samples/databases/xenforo.sql | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename NewConfig.yml => samples/NewConfig.yml (100%) rename newPlugin.yml => samples/NewPlugin.yml (100%) rename xenforo.sql => samples/databases/xenforo.sql (100%) diff --git a/NewConfig.yml b/samples/NewConfig.yml similarity index 100% rename from NewConfig.yml rename to samples/NewConfig.yml diff --git a/newPlugin.yml b/samples/NewPlugin.yml similarity index 100% rename from newPlugin.yml rename to samples/NewPlugin.yml diff --git a/xenforo.sql b/samples/databases/xenforo.sql similarity index 100% rename from xenforo.sql rename to samples/databases/xenforo.sql From a74eeb5e448aa17154f52e5cfff71824ded204f2 Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Thu, 11 Feb 2016 11:36:54 +0100 Subject: [PATCH 25/41] update compiler --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index dce8e3d5..cbcc0f0b 100644 --- a/pom.xml +++ b/pom.xml @@ -131,7 +131,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.5 + 3.5.1 1.7 ${javaVersion} From dd8795a1bf2e979f4bc6633aabb6a4ada7cf60e2 Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Thu, 11 Feb 2016 18:13:43 +0100 Subject: [PATCH 26/41] Fix google libs relocation --- pom.xml | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/pom.xml b/pom.xml index cbcc0f0b..61d5f72a 100644 --- a/pom.xml +++ b/pom.xml @@ -182,8 +182,8 @@ fr.xephi.authme.libs.similarity - com.google - fr.xephi.authme.libs.google + com.google.gson + fr.xephi.authme.libs.google.gson @@ -210,6 +210,16 @@ shade + + + com.google.thirdparty + fr.xephi.authme.libs.google.thirdparty + + + com.google.commons + fr.xephi.authme.libs.google.commons + + target/${jarName}-legacy.jar @@ -296,13 +306,6 @@ xephi-repo http://ci.xephi.fr/plugin/repository/everything/ - - From 131cc22248dcbf12311a748af3dbaf08f4e3f4e6 Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Thu, 11 Feb 2016 20:36:07 +0100 Subject: [PATCH 27/41] Hide tablist feature --- src/main/java/fr/xephi/authme/AuthMe.java | 8 +++- .../authme/listener/AuthMePlayerListener.java | 4 +- .../listener/AuthMeTablistPacketAdapter.java | 44 +++++++++++++++++++ .../properties/RestrictionSettings.java | 10 ++++- src/main/resources/config.yml | 6 ++- 5 files changed, 67 insertions(+), 5 deletions(-) create mode 100644 src/main/java/fr/xephi/authme/listener/AuthMeTablistPacketAdapter.java diff --git a/src/main/java/fr/xephi/authme/AuthMe.java b/src/main/java/fr/xephi/authme/AuthMe.java index c5a26048..1c3fb05d 100644 --- a/src/main/java/fr/xephi/authme/AuthMe.java +++ b/src/main/java/fr/xephi/authme/AuthMe.java @@ -60,6 +60,7 @@ import fr.xephi.authme.listener.AuthMePlayerListener16; import fr.xephi.authme.listener.AuthMePlayerListener18; import fr.xephi.authme.listener.AuthMeServerListener; import fr.xephi.authme.listener.AuthMeTabCompletePacketAdapter; +import fr.xephi.authme.listener.AuthMeTablistPacketAdapter; import fr.xephi.authme.mail.SendMailSSL; import fr.xephi.authme.output.ConsoleFilter; import fr.xephi.authme.output.Log4JFilter; @@ -132,6 +133,7 @@ public class AuthMe extends JavaPlugin { public CombatTagPlus combatTagPlus; public AuthMeInventoryPacketAdapter inventoryProtector; public AuthMeTabCompletePacketAdapter tabComplete; + public AuthMeTablistPacketAdapter tablistHider; /* * Maps and stuff @@ -664,10 +666,14 @@ public class AuthMe extends JavaPlugin { inventoryProtector.unregister(); inventoryProtector = null; } - if (tabComplete == null) { + if (tabComplete == null && newSettings.getProperty(RestrictionSettings.DENY_TABCOMPLETE_BEFORE_LOGIN)) { tabComplete = new AuthMeTabCompletePacketAdapter(this); tabComplete.register(); } + if (tablistHider == null && newSettings.getProperty(RestrictionSettings.HIDE_TABLIST_BEFORE_LOGIN)) { + tablistHider = new AuthMeTablistPacketAdapter(this); + tablistHider.register(); + } } // Save Player Data diff --git a/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java b/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java index 1a55556e..8a363b4f 100644 --- a/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java +++ b/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java @@ -202,7 +202,7 @@ public class AuthMePlayerListener implements Listener { if (joinMsg == null) { return; } - event.setJoinMessage(null); + event.setJoinMessage((String)null); joinMessage.put(name, joinMsg); } @@ -358,7 +358,7 @@ public class AuthMePlayerListener implements Listener { } if (Settings.delayJoinLeaveMessages && !Utils.checkAuth(player)) { - event.setQuitMessage(null); + event.setQuitMessage((String)null); } plugin.getManagement().performQuit(player, false); diff --git a/src/main/java/fr/xephi/authme/listener/AuthMeTablistPacketAdapter.java b/src/main/java/fr/xephi/authme/listener/AuthMeTablistPacketAdapter.java new file mode 100644 index 00000000..f4321b40 --- /dev/null +++ b/src/main/java/fr/xephi/authme/listener/AuthMeTablistPacketAdapter.java @@ -0,0 +1,44 @@ +package fr.xephi.authme.listener; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.ProtocolLibrary; +import com.comphenix.protocol.events.ListenerPriority; +import com.comphenix.protocol.events.PacketAdapter; +import com.comphenix.protocol.events.PacketEvent; +import com.comphenix.protocol.reflect.FieldAccessException; + +import fr.xephi.authme.AuthMe; +import fr.xephi.authme.ConsoleLogger; +import fr.xephi.authme.cache.auth.PlayerCache; + +public class AuthMeTablistPacketAdapter extends PacketAdapter { + + public AuthMeTablistPacketAdapter(AuthMe plugin) { + super(plugin, ListenerPriority.NORMAL, PacketType.Play.Server.PLAYER_INFO); + } + + @Override + public void onPacketReceiving(PacketEvent event) + { + if (event.getPacketType() == PacketType.Play.Server.PLAYER_INFO) { + try + { + if (!PlayerCache.getInstance().isAuthenticated(event.getPlayer().getName().toLowerCase())) { + event.setCancelled(true); + } + } + catch (FieldAccessException e) + { + ConsoleLogger.showError("Couldn't access field."); + } + } + } + + public void register() { + ProtocolLibrary.getProtocolManager().addPacketListener(this); + } + + public void unregister() { + ProtocolLibrary.getProtocolManager().removePacketListener(this); + } +} diff --git a/src/main/java/fr/xephi/authme/settings/properties/RestrictionSettings.java b/src/main/java/fr/xephi/authme/settings/properties/RestrictionSettings.java index 386e130c..c140a67a 100644 --- a/src/main/java/fr/xephi/authme/settings/properties/RestrictionSettings.java +++ b/src/main/java/fr/xephi/authme/settings/properties/RestrictionSettings.java @@ -126,10 +126,18 @@ public class RestrictionSettings implements SettingsClass { public static final Property ENABLE_PASSWORD_CONFIRMATION = newProperty("settings.restrictions.enablePasswordConfirmation", true); - @Comment("Should we protect the player inventory before logging in?") + @Comment("Should we protect the player inventory before logging in? Requires ProtocolLib.") public static final Property PROTECT_INVENTORY_BEFORE_LOGIN = newProperty("settings.restrictions.ProtectInventoryBeforeLogIn", true); + @Comment("Should we deny the tabcomplete feature before logging in? Requires ProtocolLib.") + public static final Property DENY_TABCOMPLETE_BEFORE_LOGIN = + newProperty("settings.restrictions.DenyTabcompleteBeforeLogin", true); + + @Comment("Should we hide the tablist before logging in? Requires ProtocolLib.") + public static final Property HIDE_TABLIST_BEFORE_LOGIN = + newProperty("settings.restrictions.HideTablistBeforeLogin", true); + @Comment({ "Should we display all other accounts from a player when he joins?", "permission: /authme.admin.accounts"}) diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 151bc753..cfa7cb01 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -132,8 +132,12 @@ settings: # when it's true, registration require that kind of command: # /register enablePasswordConfirmation: true - # Should we protect the player inventory before logging in? + # Should we protect the player inventory before logging in? Requires ProtocolLib. ProtectInventoryBeforeLogIn: true + # Should we deny the tabcomplete feature before logging in? Requires ProtocolLib. + DenyTabcompleteBeforeLogIn: true + # Should we hide the tablist before logging in? Requires ProtocolLib. + HideTablistBeforeLogIn: true # Should we display all other accounts from a player when he joins? # permission: /authme.admin.accounts displayOtherAccounts: true From 0afa5f05359d47c5b64067cf29f3c2cde36ee8aa Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Thu, 11 Feb 2016 20:53:25 +0100 Subject: [PATCH 28/41] change join/leave messages behaviour --- samples/NewConfig.yml | 4 +++- .../xephi/authme/listener/AuthMePlayerListener.java | 12 ++++++++++-- src/main/java/fr/xephi/authme/settings/Settings.java | 6 ++++-- .../settings/properties/RegistrationSettings.java | 11 +++++++++-- 4 files changed, 26 insertions(+), 7 deletions(-) diff --git a/samples/NewConfig.yml b/samples/NewConfig.yml index 7c79362d..a7b9fc6e 100644 --- a/samples/NewConfig.yml +++ b/samples/NewConfig.yml @@ -421,7 +421,9 @@ settings: # Do we need to broadcast the welcome message to all server or only to the player? set true for server or false for player broadcastWelcomeMessage: false # Do we need to delay the join/leave message to be displayed only when the player is authenticated ? - delayJoinLeaveMessages: true + delayJoinMessage: false + removeJoinMessage: false + removeLeaveMessage: false # Do we need to add potion effect Blinding before login/register ? applyBlindEffect: false ExternalBoardOptions: diff --git a/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java b/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java index 8a363b4f..b15f4043 100644 --- a/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java +++ b/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java @@ -191,7 +191,15 @@ public class AuthMePlayerListener implements Listener { @EventHandler(priority = EventPriority.HIGHEST) public void onJoinMessage(PlayerJoinEvent event) { final Player player = event.getPlayer(); - if (player == null || !Settings.delayJoinLeaveMessages) { + if (player == null) { + return; + } + + if (Settings.removeJoinMessage) { + event.setJoinMessage((String)null); + return; + } + if (!Settings.delayJoinMessage) { return; } @@ -357,7 +365,7 @@ public class AuthMePlayerListener implements Listener { return; } - if (Settings.delayJoinLeaveMessages && !Utils.checkAuth(player)) { + if (Settings.removeLeaveMessage) { event.setQuitMessage((String)null); } diff --git a/src/main/java/fr/xephi/authme/settings/Settings.java b/src/main/java/fr/xephi/authme/settings/Settings.java index ff711621..ac20a9e7 100644 --- a/src/main/java/fr/xephi/authme/settings/Settings.java +++ b/src/main/java/fr/xephi/authme/settings/Settings.java @@ -64,7 +64,7 @@ public final class Settings { purgeLimitedCreative, purgeAntiXray, purgePermissions, enableProtection, enableAntiBot, recallEmail, useWelcomeMessage, broadcastWelcomeMessage, forceRegKick, forceRegLogin, - checkVeryGames, delayJoinLeaveMessages, noTeleport, applyBlindEffect, + checkVeryGames, removeJoinMessage, removeLeaveMessage, delayJoinMessage, noTeleport, applyBlindEffect, kickPlayersBeforeStopping, allowAllCommandsIfRegIsOptional, customAttributes, generateImage, isRemoveSpeedEnabled, preventOtherCase; public static String getNickRegex, getUnloggedinGroup, getMySQLHost, @@ -241,7 +241,9 @@ public final class Settings { getMaxLoginPerIp = configFile.getInt("settings.restrictions.maxLoginPerIp", 0); getMaxJoinPerIp = configFile.getInt("settings.restrictions.maxJoinPerIp", 0); checkVeryGames = configFile.getBoolean("VeryGames.enableIpCheck", false); - delayJoinLeaveMessages = configFile.getBoolean("settings.delayJoinLeaveMessages", false); + removeJoinMessage = configFile.getBoolean("settings.removeJoineMessage", false); + removeLeaveMessage = configFile.getBoolean("settings.removeLeaveMessage", false); + delayJoinMessage = configFile.getBoolean("settings.delayJoineMessage", false); noTeleport = configFile.getBoolean("settings.restrictions.noTeleport", false); crazyloginFileName = configFile.getString("Converter.CrazyLogin.fileName", "accounts.db"); getPassRegex = configFile.getString("settings.restrictions.allowedPasswordCharacters", "[\\x21-\\x7E]*"); diff --git a/src/main/java/fr/xephi/authme/settings/properties/RegistrationSettings.java b/src/main/java/fr/xephi/authme/settings/properties/RegistrationSettings.java index 129e4ab9..e3af011c 100644 --- a/src/main/java/fr/xephi/authme/settings/properties/RegistrationSettings.java +++ b/src/main/java/fr/xephi/authme/settings/properties/RegistrationSettings.java @@ -81,8 +81,15 @@ public class RegistrationSettings implements SettingsClass { newProperty("settings.broadcastWelcomeMessage", false); @Comment("Do we need to delay the join/leave message to be displayed only when the player is authenticated?") - public static final Property DELAY_JOIN_LEAVE_MESSAGES = - newProperty("settings.delayJoinLeaveMessages", true); + public static final Property DELAY_JOIN_MESSAGE = + newProperty("settings.delayJoinMessage", false); + + // TODO: comments! + public static final Property REMOVE_JOIN_MESSAGE = + newProperty("settings.removeJoinMessages", false); + + public static final Property REMOVE_LEAVE_MESSAGE = + newProperty("settings.removeLeaveMessages", false); @Comment("Do we need to add potion effect Blinding before login/reigster?") public static final Property APPLY_BLIND_EFFECT = From 2d8a80049b8530ae3bf04b48b72b57b04760cfe8 Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Thu, 11 Feb 2016 21:05:58 +0100 Subject: [PATCH 29/41] Fix tests --- src/main/java/fr/xephi/authme/settings/Settings.java | 6 +++++- .../authme/settings/properties/RegistrationSettings.java | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/fr/xephi/authme/settings/Settings.java b/src/main/java/fr/xephi/authme/settings/Settings.java index ac20a9e7..c4c8adc5 100644 --- a/src/main/java/fr/xephi/authme/settings/Settings.java +++ b/src/main/java/fr/xephi/authme/settings/Settings.java @@ -64,7 +64,8 @@ public final class Settings { purgeLimitedCreative, purgeAntiXray, purgePermissions, enableProtection, enableAntiBot, recallEmail, useWelcomeMessage, broadcastWelcomeMessage, forceRegKick, forceRegLogin, - checkVeryGames, removeJoinMessage, removeLeaveMessage, delayJoinMessage, noTeleport, applyBlindEffect, + checkVeryGames, removeJoinMessage, removeLeaveMessage, delayJoinMessage, + noTeleport, applyBlindEffect, hideTablistBeforeLogin, denyTabcompleteBeforeLogin, kickPlayersBeforeStopping, allowAllCommandsIfRegIsOptional, customAttributes, generateImage, isRemoveSpeedEnabled, preventOtherCase; public static String getNickRegex, getUnloggedinGroup, getMySQLHost, @@ -165,6 +166,9 @@ public final class Settings { enablePasswordConfirmation = configFile.getBoolean("settings.restrictions.enablePasswordConfirmation", true); protectInventoryBeforeLogInEnabled = configFile.getBoolean("settings.restrictions.ProtectInventoryBeforeLogIn", true); + denyTabcompleteBeforeLogin = configFile.getBoolean("settings.restrictions.DenyTabcompleteBeforeLogin", true); + hideTablistBeforeLogin = configFile.getBoolean("settings.restrictions.DenyTabcompleteBeforeLogin", true); + plugin.checkProtocolLib(); passwordMaxLength = configFile.getInt("settings.security.passwordMaxLength", 20); diff --git a/src/main/java/fr/xephi/authme/settings/properties/RegistrationSettings.java b/src/main/java/fr/xephi/authme/settings/properties/RegistrationSettings.java index e3af011c..fe41709e 100644 --- a/src/main/java/fr/xephi/authme/settings/properties/RegistrationSettings.java +++ b/src/main/java/fr/xephi/authme/settings/properties/RegistrationSettings.java @@ -86,10 +86,10 @@ public class RegistrationSettings implements SettingsClass { // TODO: comments! public static final Property REMOVE_JOIN_MESSAGE = - newProperty("settings.removeJoinMessages", false); + newProperty("settings.removeJoinMessage", false); public static final Property REMOVE_LEAVE_MESSAGE = - newProperty("settings.removeLeaveMessages", false); + newProperty("settings.removeLeaveMessage", false); @Comment("Do we need to add potion effect Blinding before login/reigster?") public static final Property APPLY_BLIND_EFFECT = From 39168bc818b0e36531060d630767cab4d0899a35 Mon Sep 17 00:00:00 2001 From: ljacqu Date: Thu, 11 Feb 2016 21:27:16 +0100 Subject: [PATCH 30/41] #482 Provide better default messages and merge MessagesManager - Return message from the JAR's messages_en.yml file instead of an unusable error for the end user - Merge MessagesManager into Messages --- src/main/java/fr/xephi/authme/AuthMe.java | 2 +- .../java/fr/xephi/authme/output/Messages.java | 76 +++++++++--- .../xephi/authme/output/MessagesManager.java | 58 ---------- .../fr/xephi/authme/settings/NewSetting.java | 16 +++ src/test/java/fr/xephi/authme/TestHelper.java | 28 +++++ .../output/MessagesFileConsistencyTest.java | 43 +++++++ .../output/MessagesIntegrationTest.java | 108 +++++++++++++----- .../settings/ConfigFileConsistencyTest.java | 4 +- .../settings/NewSettingIntegrationTest.java | 27 ++--- .../xephi/authme/settings/NewSettingTest.java | 37 ++++-- src/test/resources/messages_default.yml | 5 + src/test/resources/messages_test.yml | 2 + 12 files changed, 271 insertions(+), 135 deletions(-) delete mode 100644 src/main/java/fr/xephi/authme/output/MessagesManager.java create mode 100644 src/test/java/fr/xephi/authme/TestHelper.java create mode 100644 src/test/java/fr/xephi/authme/output/MessagesFileConsistencyTest.java create mode 100644 src/test/resources/messages_default.yml diff --git a/src/main/java/fr/xephi/authme/AuthMe.java b/src/main/java/fr/xephi/authme/AuthMe.java index 1c3fb05d..630ebf0d 100644 --- a/src/main/java/fr/xephi/authme/AuthMe.java +++ b/src/main/java/fr/xephi/authme/AuthMe.java @@ -231,7 +231,7 @@ public class AuthMe extends JavaPlugin { return; } - messages = new Messages(newSettings.getMessagesFile()); + messages = new Messages(newSettings.getMessagesFile(), newSettings.getDefaultMessagesFile()); // Connect to the database and setup tables try { diff --git a/src/main/java/fr/xephi/authme/output/Messages.java b/src/main/java/fr/xephi/authme/output/Messages.java index 731844d0..c0964ded 100644 --- a/src/main/java/fr/xephi/authme/output/Messages.java +++ b/src/main/java/fr/xephi/authme/output/Messages.java @@ -1,7 +1,11 @@ package fr.xephi.authme.output; +import fr.xephi.authme.ConsoleLogger; import fr.xephi.authme.util.StringUtils; +import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.configuration.file.YamlConfiguration; import java.io.File; @@ -12,15 +16,19 @@ import java.io.File; */ public class Messages { - private MessagesManager manager; + private FileConfiguration configuration; + private String fileName; + private File defaultFile; + private FileConfiguration defaultConfiguration; /** * Constructor. * * @param messageFile The messages file to use */ - public Messages(File messageFile) { - manager = new MessagesManager(messageFile); + public Messages(File messageFile, File defaultFile) { + initializeFile(messageFile); + this.defaultFile = defaultFile; } /** @@ -30,7 +38,7 @@ public class Messages { * @param key The key of the message to send */ public void send(CommandSender sender, MessageKey key) { - String[] lines = manager.retrieve(key.getKey()); + String[] lines = retrieve(key); for (String line : lines) { sender.sendMessage(line); } @@ -38,7 +46,7 @@ public class Messages { /** * Send the given message code to the player with the given tag replacements. Note that this method - * issues an exception if the number of supplied replacements doesn't correspond to the number of tags + * logs an error if the number of supplied replacements doesn't correspond to the number of tags * the message key contains. * * @param sender The entity to send the message to @@ -48,13 +56,13 @@ public class Messages { public void send(CommandSender sender, MessageKey key, String... replacements) { String message = retrieveSingle(key); String[] tags = key.getTags(); - if (replacements.length != tags.length) { - throw new IllegalStateException( - "Given replacement size does not match the tags in message key '" + key + "'"); - } - - for (int i = 0; i < tags.length; ++i) { - message = message.replace(tags[i], replacements[i]); + if (replacements.length == tags.length) { + for (int i = 0; i < tags.length; ++i) { + message = message.replace(tags[i], replacements[i]); + } + } else { + ConsoleLogger.showError("Invalid number of replacements for message key '" + key + "'"); + send(sender, key); } for (String line : message.split("\n")) { @@ -66,11 +74,18 @@ public class Messages { * Retrieve the message from the text file and return it split by new line as an array. * * @param key The message key to retrieve - * * @return The message split by new lines */ public String[] retrieve(MessageKey key) { - return manager.retrieve(key.getKey()); + final String code = key.getKey(); + String message = configuration.getString(code); + + if (message == null) { + ConsoleLogger.showError("Error getting message with key '" + code + "'. " + + "Please verify your config file at '" + fileName + "'"); + return formatMessage(getDefault(code)); + } + return formatMessage(message); } /** @@ -88,7 +103,38 @@ public class Messages { * Reload the messages manager. */ public void reload(File messagesFile) { - manager = new MessagesManager(messagesFile); + initializeFile(messagesFile); + } + + private void initializeFile(File messageFile) { + this.configuration = YamlConfiguration.loadConfiguration(messageFile); + this.fileName = messageFile.getName(); + } + + private String getDefault(String code) { + if (defaultFile == null) { + return getDefaultErrorMessage(code); + } + + if (defaultConfiguration == null) { + defaultConfiguration = YamlConfiguration.loadConfiguration(defaultFile); + } + String message = defaultConfiguration.getString(code); + return (message == null) + ? "Error retrieving message '" + code + "'" + : message; + } + + private static String getDefaultErrorMessage(String code) { + return "Error retrieving message '" + code + "'"; + } + + private static String[] formatMessage(String message) { + String[] lines = message.split("&n"); + for (int i = 0; i < lines.length; ++i) { + lines[i] = ChatColor.translateAlternateColorCodes('&', lines[i]); + } + return lines; } } diff --git a/src/main/java/fr/xephi/authme/output/MessagesManager.java b/src/main/java/fr/xephi/authme/output/MessagesManager.java deleted file mode 100644 index a280ea3a..00000000 --- a/src/main/java/fr/xephi/authme/output/MessagesManager.java +++ /dev/null @@ -1,58 +0,0 @@ -package fr.xephi.authme.output; - -import fr.xephi.authme.ConsoleLogger; -import org.bukkit.ChatColor; -import org.bukkit.configuration.file.YamlConfiguration; - -import java.io.File; - -/** - * Class responsible for reading messages from a file and formatting them for Minecraft. - *

    - * This class is used within {@link Messages}, which offers a high-level interface for accessing - * or sending messages from a properties file. - */ -class MessagesManager { - - private final YamlConfiguration configuration; - private final String fileName; - - /** - * Constructor for Messages. - * - * @param file the configuration file - */ - MessagesManager(File file) { - this.fileName = file.getName(); - this.configuration = YamlConfiguration.loadConfiguration(file); - } - - /** - * Retrieve the message from the configuration file. - * - * @param key The key to retrieve - * - * @return The message - */ - public String[] retrieve(String key) { - String message = configuration.getString(key); - if (message != null) { - return formatMessage(message); - } - - // Message is null: log key not being found and send error back as message - String retrievalError = "Error getting message with key '" + key + "'. "; - ConsoleLogger.showError(retrievalError + "Please verify your config file at '" + fileName + "'"); - return new String[]{ - retrievalError + "Please contact the admin to verify or update the AuthMe messages file."}; - } - - private static String[] formatMessage(String message) { - String[] lines = message.split("&n"); - for (int i = 0; i < lines.length; ++i) { - lines[i] = ChatColor.translateAlternateColorCodes('&', lines[i]); - } - return lines; - } - -} diff --git a/src/main/java/fr/xephi/authme/settings/NewSetting.java b/src/main/java/fr/xephi/authme/settings/NewSetting.java index 29e833d0..7c509c95 100644 --- a/src/main/java/fr/xephi/authme/settings/NewSetting.java +++ b/src/main/java/fr/xephi/authme/settings/NewSetting.java @@ -18,6 +18,7 @@ import org.yaml.snakeyaml.Yaml; import java.io.File; import java.io.FileWriter; import java.io.IOException; +import java.net.URL; import java.nio.charset.Charset; import java.util.ArrayList; import java.util.Arrays; @@ -108,6 +109,21 @@ public class NewSetting { return messagesFile; } + /** + * Return the default messages file within the JAR that should contain all messages. + * + * @return The default messages file, or {@code null} if it could not be retrieved + */ + public File getDefaultMessagesFile() { + String defaultFilePath = "/messages/messages_en.yml"; + URL url = NewSetting.class.getResource(defaultFilePath); + if (url == null) { + return null; + } + File file = new File(url.getFile()); + return file.exists() ? file : null; + } + public String getEmailMessage() { return emailMessage; } diff --git a/src/test/java/fr/xephi/authme/TestHelper.java b/src/test/java/fr/xephi/authme/TestHelper.java new file mode 100644 index 00000000..9f2ec360 --- /dev/null +++ b/src/test/java/fr/xephi/authme/TestHelper.java @@ -0,0 +1,28 @@ +package fr.xephi.authme; + +import java.io.File; +import java.net.URL; + +/** + * AuthMe test utilities. + */ +public final class TestHelper { + + private TestHelper() { + } + + /** + * Return a {@link File} to an existing file from the main (non-test) resources folder. + * + * @param path The absolute path to the file + * @return The project file + */ + public static File getJarFile(String path) { + URL url = TestHelper.class.getResource(path); + if (url == null) { + throw new IllegalStateException("File '" + path + "' could not be loaded"); + } + return new File(url.getFile()); + } + +} diff --git a/src/test/java/fr/xephi/authme/output/MessagesFileConsistencyTest.java b/src/test/java/fr/xephi/authme/output/MessagesFileConsistencyTest.java new file mode 100644 index 00000000..807d54bf --- /dev/null +++ b/src/test/java/fr/xephi/authme/output/MessagesFileConsistencyTest.java @@ -0,0 +1,43 @@ +package fr.xephi.authme.output; + +import fr.xephi.authme.TestHelper; +import fr.xephi.authme.util.StringUtils; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.configuration.file.YamlConfiguration; +import org.junit.Test; + +import java.io.File; + +import static org.hamcrest.Matchers.equalTo; +import static org.junit.Assert.assertThat; + +/** + * Tests that the project's default language file contains a text for all message keys. + */ +public class MessagesFileConsistencyTest { + + private static final String DEFAULT_MESSAGES_FILE = "/messages/messages_en.yml"; + + @Test + public void shouldHaveAllMessages() { + File file = TestHelper.getJarFile(DEFAULT_MESSAGES_FILE); + FileConfiguration configuration = YamlConfiguration.loadConfiguration(file); + for (MessageKey messageKey : MessageKey.values()) { + verifyHasMessage(messageKey, configuration); + } + } + + private static void verifyHasMessage(MessageKey messageKey, FileConfiguration configuration) { + final String key = messageKey.getKey(); + final String message = configuration.getString(key); + + assertThat("Default messages file should have message for key '" + key + "'", + StringUtils.isEmpty(message), equalTo(false)); + + + for (String tag : messageKey.getTags()) { + assertThat("The message for key '" + key + "' contains the tag '" + tag + "' in the default messages file", + message.contains(tag), equalTo(true)); + } + } +} diff --git a/src/test/java/fr/xephi/authme/output/MessagesIntegrationTest.java b/src/test/java/fr/xephi/authme/output/MessagesIntegrationTest.java index 2d3e7b08..e8579077 100644 --- a/src/test/java/fr/xephi/authme/output/MessagesIntegrationTest.java +++ b/src/test/java/fr/xephi/authme/output/MessagesIntegrationTest.java @@ -1,6 +1,8 @@ package fr.xephi.authme.output; +import fr.xephi.authme.ConsoleLogger; import fr.xephi.authme.ConsoleLoggerTestInitializer; +import fr.xephi.authme.TestHelper; import fr.xephi.authme.util.WrapperMock; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -11,11 +13,11 @@ import org.mockito.ArgumentCaptor; import org.mockito.Mockito; import java.io.File; -import java.net.URL; +import java.util.logging.Logger; import static org.hamcrest.Matchers.arrayWithSize; +import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.startsWith; import static org.junit.Assert.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; @@ -26,7 +28,8 @@ import static org.mockito.Mockito.verify; */ public class MessagesIntegrationTest { - private static final String YML_TEST_FILE = "messages_test.yml"; + private static final String YML_TEST_FILE = "/messages_test.yml"; + private static final String YML_DEFAULT_TEST_FILE = "/messages_default.yml"; private Messages messages; @BeforeClass @@ -39,15 +42,15 @@ public class MessagesIntegrationTest { * Loads the messages in the file {@code messages_test.yml} in the test resources folder. * The file does not contain all messages defined in {@link MessageKey} and its contents * reflect various test cases -- not what the keys stand for. + *

    + * Similarly, the {@code messages_default.yml} from the test resources represents a default + * file that should contain all messages, but again, for testing, it just contains a few. */ @Before public void setUpMessages() { - URL url = getClass().getClassLoader().getResource(YML_TEST_FILE); - if (url == null) { - throw new RuntimeException("File '" + YML_TEST_FILE + "' could not be loaded"); - } - - messages = new Messages(new File(url.getFile())); + File testFile = TestHelper.getJarFile(YML_TEST_FILE); + File defaultFile = TestHelper.getJarFile(YML_DEFAULT_TEST_FILE); + messages = new Messages(testFile, defaultFile); } @Test @@ -101,20 +104,6 @@ public class MessagesIntegrationTest { assertThat(message[0], equalTo("Apostrophes ' should be loaded correctly, don't you think?")); } - @Test - public void shouldReturnErrorForUnknownCode() { - // given - // The following is a key that is not defined in the test file - MessageKey key = MessageKey.UNREGISTERED_SUCCESS; - - // when - String[] message = messages.retrieve(key); - - // then - assertThat(message, arrayWithSize(1)); - assertThat(message[0], startsWith("Error getting message with key '")); - } - @Test public void shouldSendMessageToPlayer() { // given @@ -176,25 +165,88 @@ public class MessagesIntegrationTest { assertThat(message, equalTo("Use /captcha THE_CAPTCHA to solve the captcha")); } - @Test(expected = RuntimeException.class) - public void shouldThrowForInvalidReplacementCount() { + @Test + public void shouldLogErrorForInvalidReplacementCount() { // given + Logger logger = mock(Logger.class); + ConsoleLogger.setLogger(logger); MessageKey key = MessageKey.CAPTCHA_WRONG_ERROR; // when messages.send(mock(CommandSender.class), key, "rep", "rep2"); - // then - expect exception + // then + ArgumentCaptor captor = ArgumentCaptor.forClass(String.class); + verify(logger).warning(captor.capture()); + assertThat(captor.getValue(), containsString("Invalid number of replacements")); } - @Test(expected = RuntimeException.class) + @Test public void shouldThrowForReplacementsOnKeyWithNoTags() { // given + Logger logger = mock(Logger.class); + ConsoleLogger.setLogger(logger); MessageKey key = MessageKey.UNKNOWN_USER; // when messages.send(mock(CommandSender.class), key, "Replacement"); - // then - expect exception + // then + ArgumentCaptor captor = ArgumentCaptor.forClass(String.class); + verify(logger).warning(captor.capture()); + assertThat(captor.getValue(), containsString("Invalid number of replacements")); + } + + @Test + public void shouldGetMessageFromDefaultFile() { + // given + // Key is only present in default file + MessageKey key = MessageKey.MUST_REGISTER_MESSAGE; + + // when + String message = messages.retrieveSingle(key); + + // then + assertThat(message, equalTo("Message from default file")); + } + + @Test + public void shouldNotUseMessageFromDefaultFile() { + // given + // Key is present in both files + MessageKey key = MessageKey.WRONG_PASSWORD; + + // when + String message = messages.retrieveSingle(key); + + // then + assertThat(message, equalTo("§cWrong password!")); + } + + @Test + public void shouldReturnErrorForMissingMessage() { + // given + // Key is not present in test file or default file + MessageKey key = MessageKey.TWO_FACTOR_CREATE; + + // when + String message = messages.retrieveSingle(key); + + // then + assertThat(message, containsString("Error retrieving message")); + } + + @Test + public void shouldAllowNullAsDefaultFile() { + // given + Messages testMessages = new Messages(TestHelper.getJarFile(YML_TEST_FILE), null); + // Key not present in test file + MessageKey key = MessageKey.TWO_FACTOR_CREATE; + + // when + String message = testMessages.retrieveSingle(key); + + // then + assertThat(message, containsString("Error retrieving message")); } } diff --git a/src/test/java/fr/xephi/authme/settings/ConfigFileConsistencyTest.java b/src/test/java/fr/xephi/authme/settings/ConfigFileConsistencyTest.java index 755dcc46..7c9170f3 100644 --- a/src/test/java/fr/xephi/authme/settings/ConfigFileConsistencyTest.java +++ b/src/test/java/fr/xephi/authme/settings/ConfigFileConsistencyTest.java @@ -1,5 +1,6 @@ package fr.xephi.authme.settings; +import fr.xephi.authme.TestHelper; import fr.xephi.authme.settings.domain.Property; import fr.xephi.authme.settings.properties.SettingsFieldRetriever; import fr.xephi.authme.settings.propertymap.PropertyMap; @@ -32,8 +33,7 @@ public class ConfigFileConsistencyTest { @Test public void shouldHaveAllConfigs() throws IOException { // given - URL url = this.getClass().getResource(CONFIG_FILE); - File configFile = new File(url.getFile()); + File configFile = TestHelper.getJarFile(CONFIG_FILE); FileConfiguration configuration = YamlConfiguration.loadConfiguration(configFile); // when diff --git a/src/test/java/fr/xephi/authme/settings/NewSettingIntegrationTest.java b/src/test/java/fr/xephi/authme/settings/NewSettingIntegrationTest.java index 646c1845..2cb0197d 100644 --- a/src/test/java/fr/xephi/authme/settings/NewSettingIntegrationTest.java +++ b/src/test/java/fr/xephi/authme/settings/NewSettingIntegrationTest.java @@ -12,12 +12,12 @@ import org.junit.Test; import java.io.File; import java.lang.reflect.Field; -import java.net.URL; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Map; +import static fr.xephi.authme.TestHelper.getJarFile; import static fr.xephi.authme.settings.domain.Property.newProperty; import static org.hamcrest.Matchers.equalTo; import static org.junit.Assert.assertThat; @@ -29,18 +29,18 @@ import static org.junit.Assume.assumeThat; public class NewSettingIntegrationTest { /** File name of the sample config including all {@link TestConfiguration} values. */ - private static final String COMPLETE_FILE = "config-sample-values.yml"; + private static final String COMPLETE_FILE = "/config-sample-values.yml"; /** File name of the sample config missing certain {@link TestConfiguration} values. */ - private static final String INCOMPLETE_FILE = "config-incomplete-sample.yml"; + private static final String INCOMPLETE_FILE = "/config-incomplete-sample.yml"; /** File name for testing difficult values. */ - private static final String DIFFICULT_FILE = "config-difficult-values.yml"; + private static final String DIFFICULT_FILE = "/config-difficult-values.yml"; private static PropertyMap propertyMap = generatePropertyMap(); @Test public void shouldLoadAndReadAllProperties() { // given - YamlConfiguration configuration = YamlConfiguration.loadConfiguration(getConfigFile(COMPLETE_FILE)); + YamlConfiguration configuration = YamlConfiguration.loadConfiguration(getJarFile(COMPLETE_FILE)); File file = new File("unused"); // when / then @@ -67,7 +67,7 @@ public class NewSettingIntegrationTest { @Test public void shouldWriteMissingProperties() { // given/when - File file = getConfigFile(INCOMPLETE_FILE); + File file = getJarFile(INCOMPLETE_FILE); YamlConfiguration configuration = YamlConfiguration.loadConfiguration(file); assumeThat(configuration.contains(TestConfiguration.BORING_COLORS.getPath()), equalTo(false)); // Expectation: File is rewritten to since it does not have all configurations @@ -100,7 +100,7 @@ public class NewSettingIntegrationTest { @Test public void shouldProperlyExportAnyValues() { // given - File file = getConfigFile(DIFFICULT_FILE); + File file = getJarFile(DIFFICULT_FILE); YamlConfiguration configuration = YamlConfiguration.loadConfiguration(file); assumeThat(configuration.contains(TestConfiguration.DUST_LEVEL.getPath()), equalTo(false)); @@ -147,19 +147,6 @@ public class NewSettingIntegrationTest { } } - /** - * Return a {@link File} instance to an existing file in the target/test-classes folder. - * - * @return The generated File - */ - private File getConfigFile(String file) { - URL url = getClass().getClassLoader().getResource(file); - if (url == null) { - throw new IllegalStateException("File '" + file + "' could not be loaded"); - } - return new File(url.getFile()); - } - /** * Generate a property map with all properties in {@link TestConfiguration}. * diff --git a/src/test/java/fr/xephi/authme/settings/NewSettingTest.java b/src/test/java/fr/xephi/authme/settings/NewSettingTest.java index 8ae65128..64a79626 100644 --- a/src/test/java/fr/xephi/authme/settings/NewSettingTest.java +++ b/src/test/java/fr/xephi/authme/settings/NewSettingTest.java @@ -3,7 +3,6 @@ package fr.xephi.authme.settings; import fr.xephi.authme.settings.domain.Property; import fr.xephi.authme.settings.properties.TestConfiguration; import fr.xephi.authme.settings.properties.TestEnum; -import fr.xephi.authme.settings.propertymap.PropertyMap; import org.bukkit.configuration.file.YamlConfiguration; import org.junit.Test; import org.mockito.invocation.InvocationOnMock; @@ -13,6 +12,8 @@ import java.io.File; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.not; +import static org.hamcrest.Matchers.nullValue; import static org.mockito.BDDMockito.given; import static org.mockito.Matchers.anyBoolean; import static org.mockito.Matchers.anyDouble; @@ -30,19 +31,19 @@ public class NewSettingTest { @Test public void shouldLoadAllConfigs() { // given - YamlConfiguration file = mock(YamlConfiguration.class); - given(file.getString(anyString(), anyString())).willAnswer(withDefaultArgument()); - given(file.getBoolean(anyString(), anyBoolean())).willAnswer(withDefaultArgument()); - given(file.getDouble(anyString(), anyDouble())).willAnswer(withDefaultArgument()); - given(file.getInt(anyString(), anyInt())).willAnswer(withDefaultArgument()); + YamlConfiguration configuration = mock(YamlConfiguration.class); + given(configuration.getString(anyString(), anyString())).willAnswer(withDefaultArgument()); + given(configuration.getBoolean(anyString(), anyBoolean())).willAnswer(withDefaultArgument()); + given(configuration.getDouble(anyString(), anyDouble())).willAnswer(withDefaultArgument()); + given(configuration.getInt(anyString(), anyInt())).willAnswer(withDefaultArgument()); - setReturnValue(file, TestConfiguration.VERSION_NUMBER, 20); - setReturnValue(file, TestConfiguration.SKIP_BORING_FEATURES, true); - setReturnValue(file, TestConfiguration.RATIO_ORDER, TestEnum.THIRD); - setReturnValue(file, TestConfiguration.SYSTEM_NAME, "myTestSys"); + setReturnValue(configuration, TestConfiguration.VERSION_NUMBER, 20); + setReturnValue(configuration, TestConfiguration.SKIP_BORING_FEATURES, true); + setReturnValue(configuration, TestConfiguration.RATIO_ORDER, TestEnum.THIRD); + setReturnValue(configuration, TestConfiguration.SYSTEM_NAME, "myTestSys"); // when / then - NewSetting settings = new NewSetting(file, new File("conf.txt"), (PropertyMap) null); + NewSetting settings = new NewSetting(configuration, null, null); assertThat(settings.getProperty(TestConfiguration.VERSION_NUMBER), equalTo(20)); assertThat(settings.getProperty(TestConfiguration.SKIP_BORING_FEATURES), equalTo(true)); @@ -54,6 +55,20 @@ public class NewSettingTest { assertDefaultValue(TestConfiguration.COOL_OPTIONS, settings); } + @Test + public void shouldReturnDefaultFile() { + // given + YamlConfiguration configuration = mock(YamlConfiguration.class); + NewSetting settings = new NewSetting(configuration, null, null); + + // when + File defaultFile = settings.getDefaultMessagesFile(); + + // then + assertThat(defaultFile, not(nullValue())); + assertThat(defaultFile.exists(), equalTo(true)); + } + private static void setReturnValue(YamlConfiguration config, Property property, T value) { if (value instanceof String) { when(config.getString(eq(property.getPath()), anyString())).thenReturn((String) value); diff --git a/src/test/resources/messages_default.yml b/src/test/resources/messages_default.yml new file mode 100644 index 00000000..786d296b --- /dev/null +++ b/src/test/resources/messages_default.yml @@ -0,0 +1,5 @@ +# Simulates a default file + +wrong_pwd: 'This message is overridden in messages_test.yml' +reg_only: 'Message from default file' +logged_in: '&cYou''re already logged in!' diff --git a/src/test/resources/messages_test.yml b/src/test/resources/messages_test.yml index 73aea93e..156a24de 100644 --- a/src/test/resources/messages_test.yml +++ b/src/test/resources/messages_test.yml @@ -1,3 +1,5 @@ +# Sample messages file + unknown_user: 'This test message&nincludes&nsome new lines' unsafe_spawn: '&cHere we have&bdefined some colors &dand some other <hings' not_logged_in: 'Apostrophes '' should be loaded correctly, don''t you think?' From e04ca3c4ae48ff8885a17f697b6e3dec4756e069 Mon Sep 17 00:00:00 2001 From: ljacqu Date: Thu, 11 Feb 2016 22:17:43 +0100 Subject: [PATCH 31/41] #512 Fix inconsistent config names - Harmonize configuration paths in code and in config.yml (fixes failing unit test) - Add way to load Property objects in legacy Settings - Create migration for delayJoinLeaveMessages to separate delayJoin..., removeJoin... and removeLeave... --- .../authme/listener/AuthMePlayerListener.java | 8 +- .../fr/xephi/authme/settings/Settings.java | 132 ++++-------------- .../settings/SettingsMigrationService.java | 33 ++++- .../properties/RegistrationSettings.java | 9 +- .../properties/RestrictionSettings.java | 2 +- src/main/resources/config.yml | 12 +- 6 files changed, 81 insertions(+), 115 deletions(-) diff --git a/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java b/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java index b15f4043..d0b36840 100644 --- a/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java +++ b/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java @@ -196,7 +196,7 @@ public class AuthMePlayerListener implements Listener { } if (Settings.removeJoinMessage) { - event.setJoinMessage((String)null); + event.setJoinMessage(null); return; } if (!Settings.delayJoinMessage) { @@ -210,7 +210,7 @@ public class AuthMePlayerListener implements Listener { if (joinMsg == null) { return; } - event.setJoinMessage((String)null); + event.setJoinMessage(null); joinMessage.put(name, joinMsg); } @@ -366,7 +366,7 @@ public class AuthMePlayerListener implements Listener { } if (Settings.removeLeaveMessage) { - event.setQuitMessage((String)null); + event.setQuitMessage(null); } plugin.getManagement().performQuit(player, false); @@ -391,7 +391,7 @@ public class AuthMePlayerListener implements Listener { /* * <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - * TODO #360: npc status can be used to bypass security!!! + * Note #360: npc status can be used to bypass security!!! * <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< */ diff --git a/src/main/java/fr/xephi/authme/settings/Settings.java b/src/main/java/fr/xephi/authme/settings/Settings.java index c4c8adc5..262838dc 100644 --- a/src/main/java/fr/xephi/authme/settings/Settings.java +++ b/src/main/java/fr/xephi/authme/settings/Settings.java @@ -1,15 +1,18 @@ package fr.xephi.authme.settings; import fr.xephi.authme.AuthMe; -import fr.xephi.authme.ConsoleLogger; -import fr.xephi.authme.datasource.DataSource; import fr.xephi.authme.datasource.DataSource.DataSourceType; import fr.xephi.authme.security.HashAlgorithm; +import fr.xephi.authme.settings.domain.Property; +import fr.xephi.authme.settings.properties.DatabaseSettings; +import fr.xephi.authme.settings.properties.PluginSettings; +import fr.xephi.authme.settings.properties.RegistrationSettings; +import fr.xephi.authme.settings.properties.RestrictionSettings; +import fr.xephi.authme.settings.properties.SecuritySettings; import fr.xephi.authme.util.Wrapper; import org.bukkit.configuration.file.FileConfiguration; import java.io.File; -import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -23,8 +26,6 @@ public final class Settings { public static final File PLUGIN_FOLDER = Wrapper.getInstance().getDataFolder(); public static final File MODULE_FOLDER = new File(PLUGIN_FOLDER, "modules"); public static final File CACHE_FOLDER = new File(PLUGIN_FOLDER, "cache"); - private static final File SETTINGS_FILE = new File(PLUGIN_FOLDER, "config.yml"); - public static final File LOG_FILE = new File(PLUGIN_FOLDER, "authme.log"); // This is not an option! public static boolean antiBotInAction = false; public static List allowCommands; @@ -105,7 +106,7 @@ public final class Settings { } public static void loadVariables() { - isPermissionCheckEnabled = configFile.getBoolean("permission.EnablePermissionCheck", false); + isPermissionCheckEnabled = load(PluginSettings.ENABLE_PERMISSION_CHECK); isForcedRegistrationEnabled = configFile.getBoolean("settings.registration.force", true); isRegistrationEnabled = configFile.getBoolean("settings.registration.enabled", true); isTeleportToSpawnEnabled = configFile.getBoolean("settings.restrictions.teleportUnAuthedToSpawn", false); @@ -132,16 +133,16 @@ public final class Settings { isSaveQuitLocationEnabled = configFile.getBoolean("settings.restrictions.SaveQuitLocation", false); isForceSurvivalModeEnabled = configFile.getBoolean("settings.GameMode.ForceSurvivalMode", false); getmaxRegPerIp = configFile.getInt("settings.restrictions.maxRegPerIp", 1); - getPasswordHash = getPasswordHash(); - getUnloggedinGroup = configFile.getString("settings.security.unLoggedinGroup", "unLoggedInGroup"); - getDataSource = getDataSource(); - isCachingEnabled = configFile.getBoolean("DataSource.caching", true); - getMySQLHost = configFile.getString("DataSource.mySQLHost", "127.0.0.1"); - getMySQLPort = configFile.getString("DataSource.mySQLPort", "3306"); - getMySQLUsername = configFile.getString("DataSource.mySQLUsername", "authme"); - getMySQLPassword = configFile.getString("DataSource.mySQLPassword", "12345"); - getMySQLDatabase = configFile.getString("DataSource.mySQLDatabase", "authme"); - getMySQLTablename = configFile.getString("DataSource.mySQLTablename", "authme"); + getPasswordHash = load(SecuritySettings.PASSWORD_HASH); + getUnloggedinGroup = load(SecuritySettings.UNLOGGEDIN_GROUP); + getDataSource = load(DatabaseSettings.BACKEND); + isCachingEnabled = load(DatabaseSettings.USE_CACHING); + getMySQLHost = load(DatabaseSettings.MYSQL_HOST); + getMySQLPort = load(DatabaseSettings.MYSQL_PORT); + getMySQLUsername = load(DatabaseSettings.MYSQL_USERNAME); + getMySQLPassword = load(DatabaseSettings.MYSQL_PASSWORD); + getMySQLDatabase = load(DatabaseSettings.MYSQL_DATABASE); + getMySQLTablename = load(DatabaseSettings.MYSQL_TABLE); getMySQLColumnEmail = configFile.getString("DataSource.mySQLColumnEmail", "email"); getMySQLColumnName = configFile.getString("DataSource.mySQLColumnName", "username"); getMySQLColumnPassword = configFile.getString("DataSource.mySQLColumnPassword", "password"); @@ -163,15 +164,15 @@ public final class Settings { } getRegisteredGroup = configFile.getString("GroupOptions.RegisteredPlayerGroup", ""); - enablePasswordConfirmation = configFile.getBoolean("settings.restrictions.enablePasswordConfirmation", true); + enablePasswordConfirmation = load(RestrictionSettings.ENABLE_PASSWORD_CONFIRMATION); - protectInventoryBeforeLogInEnabled = configFile.getBoolean("settings.restrictions.ProtectInventoryBeforeLogIn", true); - denyTabcompleteBeforeLogin = configFile.getBoolean("settings.restrictions.DenyTabcompleteBeforeLogin", true); - hideTablistBeforeLogin = configFile.getBoolean("settings.restrictions.DenyTabcompleteBeforeLogin", true); + protectInventoryBeforeLogInEnabled = load(RestrictionSettings.PROTECT_INVENTORY_BEFORE_LOGIN); + denyTabcompleteBeforeLogin = load(RestrictionSettings.DENY_TABCOMPLETE_BEFORE_LOGIN); + hideTablistBeforeLogin = load(RestrictionSettings.HIDE_TABLIST_BEFORE_LOGIN); plugin.checkProtocolLib(); - passwordMaxLength = configFile.getInt("settings.security.passwordMaxLength", 20); + passwordMaxLength = load(SecuritySettings.MAX_PASSWORD_LENGTH); backupWindowsPath = configFile.getString("BackupSystem.MysqlWindowsPath", "C:\\Program Files\\MySQL\\MySQL Server 5.1\\"); isStopEnabled = configFile.getBoolean("Security.SQLProblem.stopServer", true); reloadSupport = configFile.getBoolean("Security.ReloadCommand.useReloadCommandSupport", true); @@ -245,9 +246,9 @@ public final class Settings { getMaxLoginPerIp = configFile.getInt("settings.restrictions.maxLoginPerIp", 0); getMaxJoinPerIp = configFile.getInt("settings.restrictions.maxJoinPerIp", 0); checkVeryGames = configFile.getBoolean("VeryGames.enableIpCheck", false); - removeJoinMessage = configFile.getBoolean("settings.removeJoineMessage", false); - removeLeaveMessage = configFile.getBoolean("settings.removeLeaveMessage", false); - delayJoinMessage = configFile.getBoolean("settings.delayJoineMessage", false); + removeJoinMessage = load(RegistrationSettings.REMOVE_JOIN_MESSAGE); + removeLeaveMessage = load(RegistrationSettings.REMOVE_LEAVE_MESSAGE); + delayJoinMessage = load(RegistrationSettings.DELAY_JOIN_MESSAGE); noTeleport = configFile.getBoolean("settings.restrictions.noTeleport", false); crazyloginFileName = configFile.getString("Converter.CrazyLogin.fileName", "accounts.db"); getPassRegex = configFile.getString("settings.restrictions.allowedPasswordCharacters", "[\\x21-\\x7E]*"); @@ -264,70 +265,6 @@ public final class Settings { } - /** - * Method getPasswordHash. - * - * @return HashAlgorithm - */ - private static HashAlgorithm getPasswordHash() { - String key = "settings.security.passwordHash"; - try { - return HashAlgorithm.valueOf(configFile.getString(key, "SHA256").toUpperCase()); - } catch (IllegalArgumentException ex) { - ConsoleLogger.showError("Unknown Hash Algorithm; defaulting to SHA256"); - return HashAlgorithm.SHA256; - } - } - - /** - * Method getDataSource. - * - * @return DataSourceType - */ - private static DataSourceType getDataSource() { - String key = "DataSource.backend"; - try { - return DataSource.DataSourceType.valueOf(configFile.getString(key, "sqlite").toUpperCase()); - } catch (IllegalArgumentException ex) { - ConsoleLogger.showError("Unknown database backend; defaulting to SQLite database"); - return DataSource.DataSourceType.SQLITE; - } - } - - /** - * Saves the configuration to disk - * - * @return True if saved successfully - */ - private static boolean save() { - try { - configFile.save(SETTINGS_FILE); - return true; - } catch (IOException ex) { - return false; - } - } - - /** - * Method checkLang. - * - * @param lang String - * - * @return String - */ - private static String checkLang(String lang) { - if (new File(PLUGIN_FOLDER, "messages" + File.separator + "messages_" + lang + ".yml").exists()) { - ConsoleLogger.info("Set Language to: " + lang); - return lang; - } - if (AuthMe.class.getResourceAsStream("/messages/messages_" + lang + ".yml") != null) { - ConsoleLogger.info("Set Language to: " + lang); - return lang; - } - ConsoleLogger.info("Language file not found for " + lang + ", set to default language: en !"); - return "en"; - } - /** * Method switchAntiBotMod. * @@ -344,20 +281,13 @@ public final class Settings { } /** - * Saves current configuration (plus defaults) to disk. - *

    - * If defaults and configuration are empty, saves blank file. + * Load the value via the new Property setup for temporary support within this old settings manager. * - * @return True if saved successfully + * @param property The property to load + * @param The property type + * @return The config value of the property */ - private boolean saveDefaults() { - configFile.options() - .copyDefaults(true) - .copyHeader(true); - boolean success = save(); - configFile.options() - .copyDefaults(false) - .copyHeader(false); - return success; + private static T load(Property property) { + return property.getFromFile(configFile); } } diff --git a/src/main/java/fr/xephi/authme/settings/SettingsMigrationService.java b/src/main/java/fr/xephi/authme/settings/SettingsMigrationService.java index 0a41301c..5bb15690 100644 --- a/src/main/java/fr/xephi/authme/settings/SettingsMigrationService.java +++ b/src/main/java/fr/xephi/authme/settings/SettingsMigrationService.java @@ -13,6 +13,9 @@ import java.io.IOException; import java.io.InputStream; import java.nio.file.Files; +import static fr.xephi.authme.settings.properties.RegistrationSettings.DELAY_JOIN_MESSAGE; +import static fr.xephi.authme.settings.properties.RegistrationSettings.REMOVE_JOIN_MESSAGE; +import static fr.xephi.authme.settings.properties.RegistrationSettings.REMOVE_LEAVE_MESSAGE; import static fr.xephi.authme.settings.properties.RestrictionSettings.ALLOWED_NICKNAME_CHARACTERS; import static java.lang.String.format; @@ -43,7 +46,8 @@ public final class SettingsMigrationService { configuration.set(ALLOWED_NICKNAME_CHARACTERS.getPath(), "[a-zA-Z0-9_]*"); changes = true; } - changes = changes || performMailTextToFileMigration(configuration, pluginFolder); + changes = changes || performMailTextToFileMigration(configuration, pluginFolder) + || migrateJoinLeaveMessages(configuration); return changes; } @@ -104,6 +108,33 @@ public final class SettingsMigrationService { return true; } + /** + * Detected deprecated {@code settings.delayJoinLeaveMessages} and inform user of new "remove join messages" + * and "remove leave messages" settings. + * + * @param configuration The file configuration + * @return True if the configuration has changed, false otherwise + */ + private static boolean migrateJoinLeaveMessages(FileConfiguration configuration) { + final String oldDelayJoinPath = "settings.delayJoinLeaveMessages"; + if (configuration.contains(oldDelayJoinPath)) { + ConsoleLogger.info("Detected deprecated property " + oldDelayJoinPath); + ConsoleLogger.info(String.format("Note that we now also have the settings %s and %s", + REMOVE_JOIN_MESSAGE.getPath(), REMOVE_LEAVE_MESSAGE.getPath())); + if (!configuration.contains(DELAY_JOIN_MESSAGE.getPath())) { + configuration.set(DELAY_JOIN_MESSAGE.getPath(), true); + ConsoleLogger.info("Renamed " + oldDelayJoinPath + " to " + DELAY_JOIN_MESSAGE.getPath()); + } + return true; + } + return false; + } + + + // ------- + // Utilities + // ------- + /** * Copy a resource file (from the JAR) to the given file if it doesn't exist. * diff --git a/src/main/java/fr/xephi/authme/settings/properties/RegistrationSettings.java b/src/main/java/fr/xephi/authme/settings/properties/RegistrationSettings.java index fe41709e..0be9f67a 100644 --- a/src/main/java/fr/xephi/authme/settings/properties/RegistrationSettings.java +++ b/src/main/java/fr/xephi/authme/settings/properties/RegistrationSettings.java @@ -80,16 +80,17 @@ public class RegistrationSettings implements SettingsClass { public static final Property BROADCAST_WELCOME_MESSAGE = newProperty("settings.broadcastWelcomeMessage", false); - @Comment("Do we need to delay the join/leave message to be displayed only when the player is authenticated?") + @Comment("Should we delay the join message and display it once the player has logged in?") public static final Property DELAY_JOIN_MESSAGE = newProperty("settings.delayJoinMessage", false); - // TODO: comments! + @Comment("Should we remove join messages altogether?") public static final Property REMOVE_JOIN_MESSAGE = - newProperty("settings.removeJoinMessage", false); + newProperty("settings.removeJoinMessage", false); + @Comment("Should we remove leave messages?") public static final Property REMOVE_LEAVE_MESSAGE = - newProperty("settings.removeLeaveMessage", false); + newProperty("settings.removeLeaveMessage", false); @Comment("Do we need to add potion effect Blinding before login/reigster?") public static final Property APPLY_BLIND_EFFECT = diff --git a/src/main/java/fr/xephi/authme/settings/properties/RestrictionSettings.java b/src/main/java/fr/xephi/authme/settings/properties/RestrictionSettings.java index c140a67a..4025c0be 100644 --- a/src/main/java/fr/xephi/authme/settings/properties/RestrictionSettings.java +++ b/src/main/java/fr/xephi/authme/settings/properties/RestrictionSettings.java @@ -132,7 +132,7 @@ public class RestrictionSettings implements SettingsClass { @Comment("Should we deny the tabcomplete feature before logging in? Requires ProtocolLib.") public static final Property DENY_TABCOMPLETE_BEFORE_LOGIN = - newProperty("settings.restrictions.DenyTabcompleteBeforeLogin", true); + newProperty("settings.restrictions.DenyTabCompleteBeforeLogin", true); @Comment("Should we hide the tablist before logging in? Requires ProtocolLib.") public static final Property HIDE_TABLIST_BEFORE_LOGIN = diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index cfa7cb01..dc52379a 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -135,9 +135,9 @@ settings: # Should we protect the player inventory before logging in? Requires ProtocolLib. ProtectInventoryBeforeLogIn: true # Should we deny the tabcomplete feature before logging in? Requires ProtocolLib. - DenyTabcompleteBeforeLogIn: true + DenyTabCompleteBeforeLogin: true # Should we hide the tablist before logging in? Requires ProtocolLib. - HideTablistBeforeLogIn: true + HideTablistBeforeLogin: true # Should we display all other accounts from a player when he joins? # permission: /authme.admin.accounts displayOtherAccounts: true @@ -256,8 +256,12 @@ settings: useWelcomeMessage: true # Do we need to broadcast the welcome message to all server or only to the player? set true for server or false for player broadcastWelcomeMessage: false - # Do we need to delay the join/leave message to be displayed only when the player is authenticated ? - delayJoinLeaveMessages: true + # Should we delay the join message and display it once the player has logged in? + delayJoinMessage: true + # Should we remove join messages altogether? + removeJoinMessage: true + # Should we remove leave messages? + removeLeaveMessage: true # Do we need to add potion effect Blinding before login/register? applyBlindEffect: false # Do we need to prevent people to login with another case? From 9b1d524bdce01f3f0cb4e123bd1d1d96e65bdb29 Mon Sep 17 00:00:00 2001 From: ljacqu Date: Thu, 11 Feb 2016 22:21:06 +0100 Subject: [PATCH 32/41] Make SettingsMigrationService run all migrations --- .../xephi/authme/settings/SettingsMigrationService.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/fr/xephi/authme/settings/SettingsMigrationService.java b/src/main/java/fr/xephi/authme/settings/SettingsMigrationService.java index 5bb15690..e93fd18c 100644 --- a/src/main/java/fr/xephi/authme/settings/SettingsMigrationService.java +++ b/src/main/java/fr/xephi/authme/settings/SettingsMigrationService.java @@ -46,8 +46,12 @@ public final class SettingsMigrationService { configuration.set(ALLOWED_NICKNAME_CHARACTERS.getPath(), "[a-zA-Z0-9_]*"); changes = true; } - changes = changes || performMailTextToFileMigration(configuration, pluginFolder) - || migrateJoinLeaveMessages(configuration); + + // Note ljacqu 20160211: Concatenating migration methods with | instead of the usual || + // ensures that all migrations will be performed + changes = changes + | performMailTextToFileMigration(configuration, pluginFolder) + | migrateJoinLeaveMessages(configuration); return changes; } From cf52fdac1cb27d721bda4af43b3e805a9db8fd86 Mon Sep 17 00:00:00 2001 From: ljacqu Date: Thu, 11 Feb 2016 22:48:34 +0100 Subject: [PATCH 33/41] #482 Remove English messages in translation files - Messages now default to the one in messages_en.yml if not present in the translation file --- src/main/resources/messages/messages_bg.yml | 6 ----- src/main/resources/messages/messages_cz.yml | 5 ---- src/main/resources/messages/messages_de.yml | 2 +- src/main/resources/messages/messages_es.yml | 8 ++----- src/main/resources/messages/messages_eu.yml | 13 +--------- src/main/resources/messages/messages_fi.yml | 8 ------- src/main/resources/messages/messages_fr.yml | 14 +++++------ src/main/resources/messages/messages_gl.yml | 7 +----- src/main/resources/messages/messages_hu.yml | 1 - src/main/resources/messages/messages_id.yml | 5 ---- src/main/resources/messages/messages_ko.yml | 4 ---- src/main/resources/messages/messages_lt.yml | 18 -------------- src/main/resources/messages/messages_nl.yml | 6 ++--- src/main/resources/messages/messages_pl.yml | 8 ------- src/main/resources/messages/messages_pt.yml | 5 ---- src/main/resources/messages/messages_ru.yml | 7 ++---- src/main/resources/messages/messages_sk.yml | 24 +------------------ src/main/resources/messages/messages_tr.yml | 5 ---- src/main/resources/messages/messages_uk.yml | 3 --- src/main/resources/messages/messages_vn.yml | 5 ---- src/main/resources/messages/messages_zhcn.yml | 1 - src/main/resources/messages/messages_zhhk.yml | 4 +--- src/main/resources/messages/messages_zhtw.yml | 2 -- 23 files changed, 18 insertions(+), 143 deletions(-) diff --git a/src/main/resources/messages/messages_bg.yml b/src/main/resources/messages/messages_bg.yml index 514f3fce..ce477355 100644 --- a/src/main/resources/messages/messages_bg.yml +++ b/src/main/resources/messages/messages_bg.yml @@ -22,9 +22,6 @@ usage_unreg: '&cКоманда: /unregister парола' pwd_changed: '&cПаролата е променена!' user_unknown: '&cПотребителя не е регистриран' password_error: '&fПаролата не съвпада' -password_error_nick: '&fYou can''t use your name as password' -password_error_unsafe: '&fYou can''t use unsafe passwords' -invalid_session: '&cYour IP has been changed and your session data has expired!' reg_only: '&fСамо за регистрирани! Моля посети http://example.com за регистрация' logged_in: '&cВече сте влязъл!' logout: '&cУспешен изход от регистрацията!' @@ -56,6 +53,3 @@ email_send: '[AuthMe] Изпраен е имейл !' country_banned: Твоята държава е забранена в този сървър! antibot_auto_enabled: '[AuthMe] AntiBotMod автоматично включен, открита е потенциална атака!' antibot_auto_disabled: '[AuthMe] AntiBotMod автоматично изключване след %m Минути.' -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:' -two_factor_create: '&2Your secret code is %code' diff --git a/src/main/resources/messages/messages_cz.yml b/src/main/resources/messages/messages_cz.yml index 7dbcff13..3098d463 100644 --- a/src/main/resources/messages/messages_cz.yml +++ b/src/main/resources/messages/messages_cz.yml @@ -8,8 +8,6 @@ reg_disabled: '&cRegistrace je zakazana!' valid_session: '&cAutomaticke znovuprihlaseni.' login: '&cUspesne prihlaseni!' user_regged: '&cUzivatelske jmeno je jiz registrovano.' -password_error_nick: '&fYou can''t use your name as password' -password_error_unsafe: '&fYou can''t use unsafe passwords' usage_reg: '&cPouzij: "/register heslo heslo".' no_perm: '&cNemas opravneni.' error: '&cVyskytla se chyba - kontaktujte administratora ...' @@ -55,6 +53,3 @@ email_send: '[AuthMe] Email pro obnoveni hesla odeslan!' country_banned: 'Vase zeme je na tomto serveru zakazana' antibot_auto_enabled: '[AuthMe] AntiBotMod automaticky spusten z duvodu masivnich pripojeni!' antibot_auto_disabled: '[AuthMe] AntiBotMod automaticky ukoncen po %m minutach, doufejme v konec invaze' -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:' -two_factor_create: '&2Your secret code is %code' \ No newline at end of file diff --git a/src/main/resources/messages/messages_de.yml b/src/main/resources/messages/messages_de.yml index 699e8cca..9a9c0181 100644 --- a/src/main/resources/messages/messages_de.yml +++ b/src/main/resources/messages/messages_de.yml @@ -57,4 +57,4 @@ country_banned: '&4Dein Land ist gesperrt' antibot_auto_enabled: '&4[AntiBotService] AntiBotMod wurde aufgrund hoher Netzauslastung automatisch aktiviert!' antibot_auto_disabled: '&2[AntiBotService] AntiBotMod wurde nach %m Minuten deaktiviert, hoffentlich ist die Invasion vorbei' kick_antibot: 'AntiBotMod ist aktiviert! Bitte warte einige Minuten, bevor du dich mit dem Server verbindest' -two_factor_create: '&2Your secret code is %code' +two_factor_create: '&2Dein geheimer Code ist %code' diff --git a/src/main/resources/messages/messages_es.yml b/src/main/resources/messages/messages_es.yml index 7f0e82bd..70b9f830 100644 --- a/src/main/resources/messages/messages_es.yml +++ b/src/main/resources/messages/messages_es.yml @@ -8,8 +8,6 @@ wrong_pwd: '&cContraseña incorrecta' unregistered: '&c¡Cuenta eliminada del registro!' reg_disabled: '&cEl registro está desactivado' valid_session: '&cInicio de sesión' -password_error_nick: '&fYou can''t use your name as password' -password_error_unsafe: '&fYou can''t use unsafe passwords' login: '&c¡Sesión iniciada!' vb_nonActiv: '&fTu cuenta no está activada aún, ¡revisa tu correo!' user_regged: '&cUsuario ya registrado' @@ -39,7 +37,7 @@ regex: '&cTu usuario tiene carácteres no admitidos, los cuales son: REG_EX' add_email: '&cPor favor agrega tu e-mail con: /email add tuEmail confirmarEmail' recovery_email: '&c¿Olvidaste tu contraseña? Por favor usa /email recovery ' usage_captcha: '&cUso: /captcha ' -wrong_captcha: '&cCaptcha incorrecto, please use : /captcha THE_CAPTCHA' +wrong_captcha: '&cCaptcha incorrecto, por favor usa: /captcha THE_CAPTCHA' valid_captcha: '&c¡ Captcha ingresado correctamente !' kick_forvip: '&cUn jugador VIP ha ingresado al servidor lleno!' kick_fullserver: '&cEl servidor está lleno, lo sentimos!' @@ -56,6 +54,4 @@ email_send: '[AuthMe] Correo de recuperación enviado !' country_banned: 'Tu país ha sido baneado de este servidor!' antibot_auto_enabled: '[AuthMe] AntiBotMod activado automáticamente debido a conexiones masivas!' antibot_auto_disabled: '[AuthMe] AntiBotMod desactivado automáticamente luego de %m minutos. Esperamos que haya terminado' -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:' -two_factor_create: '&2Your secret code is %code' + diff --git a/src/main/resources/messages/messages_eu.yml b/src/main/resources/messages/messages_eu.yml index 30f46260..5775730b 100644 --- a/src/main/resources/messages/messages_eu.yml +++ b/src/main/resources/messages/messages_eu.yml @@ -21,9 +21,6 @@ usage_unreg: '&cErabili: /unregister password' pwd_changed: '&cPasahitza aldatu duzu!' user_unknown: '&cErabiltzailea ez dago erregistratuta' password_error: '&fPasahitzak ez datoz bat' -password_error_nick: '&fYou can''t use your name as password, please choose another one' -password_error_unsafe: '&fThe chosen password is not safe, please choose another one' -invalid_session: '&fSession Dataes doesnt corrispond Plaese wait the end of session' reg_only: '&fErregistratuako erabiltzaileak bakarrik! Mesedez bisitatu http://example.com erregistratzeko' logged_in: '&cDagoeneko saioa hasita!' logout: '&cAtera zara' @@ -37,9 +34,6 @@ name_len: '&cZure erabiltzaile izena motzegia edo luzeegia da' regex: '&cZure erabiltzaileak karaktere debekatuak ditu. Karaktere onartuak: REG_EX' add_email: '&cMesedez gehitu zure emaila : /email add yourEmail confirmEmail' recovery_email: '&cPasahitza ahaztu duzu? Erabili /email recovery ' -usage_captcha: '&cYou need to type a captcha, please type: /captcha ' -wrong_captcha: '&cWrong Captcha, please use : /captcha THE_CAPTCHA' -valid_captcha: '&cYour captcha is valid !' kick_forvip: '&cVIP erabiltzaile bat sartu da zerbitzaria beteta zegoenean!' kick_fullserver: '&cZerbitzaria beteta dago, Barkatu!' usage_email_add: '&fErabili: /email add ' @@ -52,9 +46,4 @@ email_added: '[AuthMe] Emaila gehitu duzu !' email_confirm: '[AuthMe] Konfirmatu zure emaila !' email_changed: '[AuthMe] Emaila aldatua!' email_send: '[AuthMe] Berreskuratze emaila bidalita !' -email_exists: '[AuthMe] An email already exists on your account. You can change it using the command below' -country_banned: '[AuthMe]Zure herrialdea blokeatuta dago zerbitzari honetan' -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.' -two_factor_create: '&2Your secret code is %code' +country_banned: '[AuthMe] Zure herrialdea blokeatuta dago zerbitzari honetan' diff --git a/src/main/resources/messages/messages_fi.yml b/src/main/resources/messages/messages_fi.yml index 318f3e39..2702cd53 100644 --- a/src/main/resources/messages/messages_fi.yml +++ b/src/main/resources/messages/messages_fi.yml @@ -12,8 +12,6 @@ vb_nonActiv: '&fKäyttäjäsi ei ole vahvistettu!' user_regged: '&cPelaaja on jo rekisteröity' usage_reg: '&cKäyttötapa: /register salasana salasana' max_reg: '&fSinulla ei ole oikeuksia tehdä enempää pelaajatilejä!' -password_error_nick: '&fYou can''t use your name as password' -password_error_unsafe: '&fYou can''t use unsafe passwords' no_perm: '&cEi oikeuksia' error: '&fVirhe: Ota yhteys palveluntarjoojaan!' login_msg: '&cKirjaudu palvelimmelle komennolla "/login salasana"' @@ -52,9 +50,3 @@ email_added: '[AuthMe] Sähköposti lisätty!' email_confirm: '[AuthMe] Vahvistuta sähköposti!' email_changed: '[AuthMe] Sähköposti vaihdettu!' email_send: '[AuthMe] Palautus sähköposti lähetetty!' -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:' -two_factor_create: '&2Your secret code is %code' \ No newline at end of file diff --git a/src/main/resources/messages/messages_fr.yml b/src/main/resources/messages/messages_fr.yml index 07b8ccb7..54ca4f5e 100644 --- a/src/main/resources/messages/messages_fr.yml +++ b/src/main/resources/messages/messages_fr.yml @@ -10,7 +10,7 @@ reg_disabled: '&cL''enregistrement est désactivé' valid_session: '&cVous êtes authentifié' login: '&cConnection effectuée!' vb_nonActiv: '&fCe compte n''est pas actif, consultez vos emails!' -user_regged: '&cCe nom est deja utilisé..' +user_regged: '&cCe nom est deja utilisé.' usage_reg: '&cUtilisez la commande /register motdepasse confirmermotdepasse' max_reg: '&fLimite d''enregistrement atteinte pour ce compte' no_perm: '&cVous n''avez pas la permission' @@ -28,9 +28,9 @@ invalid_session: '&fSession invalide, relancez le jeu ou attendez la fin de la s reg_only: '&fSeul les joueurs enregistré sont admis! Visite http://example.com' logged_in: '&cVous êtes déjà connecté!' logout: '&cVous avez été déconnecté!' -same_nick: '&fUne personne ayant ce même pseudo joue déjà..' +same_nick: '&fUne personne ayant ce même pseudo joue déjà.' registered: '&cEnregistrement réussi avec succès!' -pass_len: '&fVotre mot de passe n''est pas assez long..' +pass_len: '&fVotre mot de passe n''est pas assez long.' reload: '&fConfiguration et BDD relancé avec succès' timeout: '&fVous avez été expulsé car vous êtes trop lent pour vous enregistrer !' usage_changepassword: '&fPour changer de mot de passe, utilisez: /changepassword ancienmdp nouveaumdp' @@ -55,7 +55,7 @@ email_changed: '[AuthMe] Email changé !' email_send: '[AuthMe] Email de récupération envoyé!' country_banned: 'Votre pays est banni de ce serveur' antibot_auto_enabled: '[AuthMe] AntiBotMod a été activé automatiquement à cause de nombreuses connections!' -antibot_auto_disabled: '[AuthMe] AntiBotMod a été désactivé automatiquement après %m Minutes, espérons que l''invasion soit arrêtée!' -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:' -two_factor_create: '&2Your secret code is %code' +antibot_auto_disabled: '[AuthMe] AntiBotMod a été désactivé automatiquement après %m minutes, espérons que l''invasion soit arrêtée!' +kick_antibot: 'AntiBotMod est activé ! Veuillez attendre quelques minutes avant de joindre le serveur.' +email_exists: '&cUn email de restauration a déjà été envoyé ! Vous pouvez le jeter et vous en faire envoyez un nouveau en utilisant :' +two_factor_create: '&2Votre code secret est %code' diff --git a/src/main/resources/messages/messages_gl.yml b/src/main/resources/messages/messages_gl.yml index c2904cb3..019e238b 100644 --- a/src/main/resources/messages/messages_gl.yml +++ b/src/main/resources/messages/messages_gl.yml @@ -6,12 +6,10 @@ reg_voluntarily: '&fPodes rexistrar o teu nome no servidor co comando usage_log: '&cUso: /login ' wrong_pwd: '&cContrasinal equivocado' unregistered: '&cFeito! Xa non estás rexistrado!' -password_error_nick: '&fYou can''t use your name as password' -password_error_unsafe: '&fYou can''t use unsafe passwords' reg_disabled: '&cO rexistro está deshabilitado' valid_session: '&cIdentificado mediante a sesión' login: '&cIdentificación con éxito!' -vb_nonActiv: '&fA túa conta aínda non está activada, comproba a túa bandexa de correo!!' +vb_nonActiv: '&fA túa conta aínda non está activada, comproba a túa bandexa de correo!!' user_regged: '&cEse nome de usuario xa está rexistrado' usage_reg: '&cUso: /register contrasinal confirmarContrasinal' max_reg: '&fExcediches o máximo de rexistros para a túa Conta' @@ -57,6 +55,3 @@ country_banned: 'O teu país está bloqueado neste servidor' antibot_auto_enabled: '[AuthMe] AntiBotMod conectouse automáticamente debido a conexións masivas!' antibot_auto_disabled: '[AuthMe] AntiBotMod desactivouse automáticamente despois de %m minutos, esperemos que a invasión se detivera' -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:' -two_factor_create: '&2Your secret code is %code' \ No newline at end of file diff --git a/src/main/resources/messages/messages_hu.yml b/src/main/resources/messages/messages_hu.yml index 6c63f1c4..099179f8 100644 --- a/src/main/resources/messages/messages_hu.yml +++ b/src/main/resources/messages/messages_hu.yml @@ -57,4 +57,3 @@ 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.' -two_factor_create: '&2Your secret code is %code' \ No newline at end of file diff --git a/src/main/resources/messages/messages_id.yml b/src/main/resources/messages/messages_id.yml index facb25f7..fd2b1267 100644 --- a/src/main/resources/messages/messages_id.yml +++ b/src/main/resources/messages/messages_id.yml @@ -10,14 +10,12 @@ valid_session: '&2Otomatis login, karena sesi masih terhubung.' login: '&2Login berhasil!' vb_nonActiv: '&cAkunmu belum diaktifkan, silahkan periksa email kamu!' user_regged: '&cKamu telah mendaftarkan username ini!' -usage_reg: '&cUsage: /register ' max_reg: '&Kamu telah mencapai batas maksimum pendaftaran di server ini!' no_perm: '&4Kamu tidak mempunyai izin melakukan ini!' error: '&4Terjadi kesalahan tak dikenal, silahkan hubungi Administrator!' login_msg: '&cSilahkan login menggunakan command "/login "' reg_msg: '&3Silahkan mendaftar ke server menggunakan command "/register "' reg_email_msg: '&3Silahkan mendaftar ke server menggunakan command "/register "' -usage_unreg: '&cUsage: /unregister ' pwd_changed: '&2Berhasil mengubah password!' user_unknown: '&cUser ini belum terdaftar!' password_error: '&cPassword tidak cocok, silahkan periksa dan ulangi kembali!' @@ -53,8 +51,5 @@ email_confirm: '&cSilahkan konfirmasi alamat email kamu!' email_changed: '&2Alamat email telah diubah dengan benar!' email_send: '&2Email pemulihan akun telah dikirim! Silahkan periksa kotak masuk emailmu!' email_exists: '&cEmail pemulihan sudah dikirim! kamu bisa membatalkan dan mengirimkan yg baru dengan command dibawah:' -country_banned: '&4Your country is banned from this server!' antibot_auto_enabled: '&4[AntiBotService] AntiBot diaktifkan dikarenakan banyak koneksi yg diterima!' antibot_auto_disabled: '&2[AntiBotService] AntiBot dimatikan setelah %m menit!' -kick_antibot: 'AntiBot protection mode is enabled! You have to wait some minutes before joining the server.' -two_factor_create: '&2Your secret code is %code' \ No newline at end of file diff --git a/src/main/resources/messages/messages_ko.yml b/src/main/resources/messages/messages_ko.yml index b90f7ce0..8fca8139 100644 --- a/src/main/resources/messages/messages_ko.yml +++ b/src/main/resources/messages/messages_ko.yml @@ -12,8 +12,6 @@ unregistered: '&c성공적으로 탈퇴했습니다!' reg_disabled: '&c가입이 비활성화 되어있습니다' valid_session: '&c세션 로그인' login: '&c성공적인 접속입니다!' -password_error_nick: '&fYou can''t use your name as password' -password_error_unsafe: '&fYou can''t use unsafe passwords' vb_nonActiv: '&f당신의 계정은 아직 활성화되어있지 않습니다, 당신의 이메일을 확인해보세요!' user_regged: '&c사용자이름은 이미 가입했습니다' usage_reg: '&c사용법: /register 비밀번호 비밀번호확인' @@ -60,5 +58,3 @@ email_exists: '[AuthMe] 당신의 계정에 이미 이메일이 존재합니다. country_banned: '당신의 국가는 이 서버에서 차단당했습니다' antibot_auto_enabled: '[AuthMe] 봇차단모드가 연결 개수 때문에 자동적으로 활성화됩니다!' antibot_auto_disabled: '[AuthMe] 봇차단모드가 %m 분 후에 자동적으로 비활성화됩니다' -kick_antibot: 'AntiBot protection mode is enabled! You have to wait some minutes before joining the server.' -two_factor_create: '&2Your secret code is %code' diff --git a/src/main/resources/messages/messages_lt.yml b/src/main/resources/messages/messages_lt.yml index f19b4b46..ea5c716a 100644 --- a/src/main/resources/messages/messages_lt.yml +++ b/src/main/resources/messages/messages_lt.yml @@ -14,8 +14,6 @@ usage_reg: '&eNaudojimas: /register slaptazodis pakartotiSlaptazodi' max_reg: '&cJus pasiekete maksimalu registraciju skaiciu.' no_perm: '&cNera leidimo' error: '&cAtsirado klaida, praneskite adminstratoriui.' -password_error_nick: '&fYou can''t use your name as password' -password_error_unsafe: '&fYou can''t use unsafe passwords' login_msg: '&ePrasome prisijungti: /login slaptazodis' reg_msg: '&ePrasome prisiregistruoti: /register slaptazodis pakartotiSlaptazodi' reg_email_msg: '&cPlease register with "/register "' @@ -42,19 +40,3 @@ wrong_captcha: '&cNeteisinga Captcha, naudokite : /captcha THE_CAPTCHA' valid_captcha: '&cJusu captcha Teisinga!' kick_forvip: '&cA VIP prisijunge i pilna serveri!' kick_fullserver: '&cServeris yra pilnas, Atsiprasome.' -usage_email_add: '&fUsage: /email add ' -usage_email_change: '&fUsage: /email change ' -usage_email_recovery: '&fUsage: /email recovery ' -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:' -two_factor_create: '&2Your secret code is %code' diff --git a/src/main/resources/messages/messages_nl.yml b/src/main/resources/messages/messages_nl.yml index 9b87f81d..b3d99273 100644 --- a/src/main/resources/messages/messages_nl.yml +++ b/src/main/resources/messages/messages_nl.yml @@ -54,7 +54,5 @@ email_send: '[AuthMe] Herstel E-mail Verzonden!' country_banned: 'Jouw land is geband op deze server' antibot_auto_enabled: '[AuthMe] AntiBotMod automatisch aangezet vanewge veel verbindingen!' antibot_auto_disabled: '[AuthMe] AntiBotMod automatisch uitgezet na %m minuten, hopelijk is de invasie gestopt' -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: '&3Please, register to the server with the command "/register "' -two_factor_create: '&2Your secret code is %code' +kick_antibot: 'AntiBot is aangezet! Wacht alsjeblieft enkele minuten voor je met de server verbindt.' +two_factor_create: '&2Je geheime code is %code' diff --git a/src/main/resources/messages/messages_pl.yml b/src/main/resources/messages/messages_pl.yml index b4184e7d..b0b937cc 100644 --- a/src/main/resources/messages/messages_pl.yml +++ b/src/main/resources/messages/messages_pl.yml @@ -16,8 +16,6 @@ wrong_pwd: '&cNiepoprawne haslo' logout: '&cPomyslnie wylogowany' usage_unreg: '&cUzycie: /unregister haslo' registered: '&aPomyslnie zarejestrowany!' -password_error_nick: '&fYou can''t use your name as password' -password_error_unsafe: '&fYou can''t use unsafe passwords' unregistered: '&4Pomyslnie odrejestrowany!' login: '&aHaslo zaakceptowane!' no_perm: '&4Nie masz uprawnien' @@ -52,9 +50,3 @@ email_added: '[AuthMe] Email dodany!' email_confirm: '[AuthMe] Potwierdz swoj email!' email_changed: '[AuthMe] Email zmieniony!' email_send: '[AuthMe] Email z odzyskaniem wyslany!' -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:' -two_factor_create: '&2Your secret code is %code' diff --git a/src/main/resources/messages/messages_pt.yml b/src/main/resources/messages/messages_pt.yml index 8d793847..f59eba14 100644 --- a/src/main/resources/messages/messages_pt.yml +++ b/src/main/resources/messages/messages_pt.yml @@ -19,8 +19,6 @@ reg_msg: '&cPor favor registe-se com "/register password confirmePassword"' reg_email_msg: '&ePor favor registe-se com "/register "' usage_unreg: '&cUse: /unregister password' pwd_changed: '&cPassword alterada!' -password_error_nick: '&fYou can''t use your name as password' -password_error_unsafe: '&fYou can''t use unsafe passwords' user_unknown: '&cUsername não registado' password_error: '&fAs passwords não coincidem' invalid_session: '&fDados de sessão não correspondem. Por favor aguarde o fim da sessão' @@ -56,6 +54,3 @@ email_send: 'Nova palavra-passe enviada para o seu email!' country_banned: 'O seu país está banido deste servidor' antibot_auto_enabled: '[AuthMe] AntiBotMod activado automaticamente devido a um aumento anormal de tentativas de ligação!' antibot_auto_disabled: '[AuthMe] AntiBotMod desactivado automaticamente após %m minutos, esperamos que a invasão tenha parado' -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:' -two_factor_create: '&2Your secret code is %code' \ No newline at end of file diff --git a/src/main/resources/messages/messages_ru.yml b/src/main/resources/messages/messages_ru.yml index 8ccfb2c2..7b1f2a50 100644 --- a/src/main/resources/messages/messages_ru.yml +++ b/src/main/resources/messages/messages_ru.yml @@ -2,7 +2,7 @@ unknown_user: '&fПользователь не найден в Базе Данн unsafe_spawn: '&eВаше расположение перед выходом было опасным - вы перенесены на спавн' not_logged_in: '&c&lВы еще не вошли!' reg_voluntarily: '&aЧтобы зарегистрироваться введите: &e&l/reg ПАРОЛЬ ПОВТОР_ПАРОЛЯ' -usage_log: '&eСинтаксис: &d/l ПАРОЛЬ &eили &d/login ПАРОЛЬ' +usage_log: '&eСинтаксис: &d/login ПАРОЛЬ' wrong_pwd: '&c&lНеправильный пароль!' unregistered: '&6Вы успешно удалили свой аккаунт!' reg_disabled: '&c&lРегистрация отключена' @@ -14,7 +14,7 @@ usage_reg: '&c&lИспользование: &e&l/reg ПАРОЛЬ ПОВТОР_ max_reg: '&c&lВы превысили макс количество регистраций на ваш IP' no_perm: '&c&lНедостаточно прав' error: '&c&lПроизошла ошибка. Свяжитесь с администратором' -login_msg: '&a&lАвторизация: &e&l/l ПАРОЛЬ' +login_msg: '&a&lАвторизация: &e&l/login ПАРОЛЬ' reg_msg: '&a&lРегистрация: &e&l/reg ПАРОЛЬ ПОВТОР_ПАРОЛЯ' password_error_nick: '&c&lВы не можете использовать ваш ник в роли пароля' password_error_unsafe: '&c&lВы не можете использовать небезопасный пароль' @@ -55,6 +55,3 @@ email_send: '[AuthMe] Письмо с инструкциями для восст country_banned: 'Вход с IP-адресов вашей страны воспрещен на этом сервере' antibot_auto_enabled: '&a[AuthMe] AntiBot-режим автоматически включен из-за большого количества входов!' antibot_auto_disabled: '&a[AuthMe] AntiBot-режим автоматичски отключен после %m мин. Надеюсь атака закончилась' -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:' -two_factor_create: '&2Your secret code is %code' diff --git a/src/main/resources/messages/messages_sk.yml b/src/main/resources/messages/messages_sk.yml index 34096ed8..398df3eb 100644 --- a/src/main/resources/messages/messages_sk.yml +++ b/src/main/resources/messages/messages_sk.yml @@ -17,8 +17,6 @@ reg_msg: '&cZaregistruj sa príkazom "/register heslo zopakujHeslo"' reg_email_msg: '&cPlease register with "/register "' timeout: '&fVyprsal cas na prihlásenie' wrong_pwd: '&cZadal si zlé heslo' -password_error_nick: '&fYou can''t use your name as password' -password_error_unsafe: '&fYou can''t use unsafe passwords' logout: '&cBol si úspesne odhláseny' usage_unreg: '&cPríkaz: /unregister heslo' registered: '&cBol si úspesne zaregistrovany' @@ -41,24 +39,4 @@ name_len: '&cTvoje meno je velmi krátke alebo dlhé' regex: '&cTvoje meno obsahuje zakázané znaky. Povolené znaky: REG_EX' add_email: '&cPridaj svoj e-mail príkazom "/email add email zopakujEmail"' recovery_email: '&cZabudol si heslo? Pouzi príkaz /email recovery ' -usage_captcha: '&cUsage: /captcha ' -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 ' -usage_email_change: '&fUsage: /email change ' -usage_email_recovery: '&fUsage: /email recovery ' -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:' -two_factor_create: '&2Your secret code is %code' + diff --git a/src/main/resources/messages/messages_tr.yml b/src/main/resources/messages/messages_tr.yml index 33e6fb8e..f84ceac4 100644 --- a/src/main/resources/messages/messages_tr.yml +++ b/src/main/resources/messages/messages_tr.yml @@ -21,8 +21,6 @@ usage_unreg: '&cKullanimi: /unregister sifren' pwd_changed: '&cSifreniz degisti!' user_unknown: '&cBu kullaniciyla kaydolunmamis!' password_error: '&fSifren eslesmiyor' -password_error_nick: '&fYou can''t use your name as password, please choose another one' -password_error_unsafe: '&fThe chosen password is not safe, please choose another one' invalid_session: '&fOturum veritabanlari uyusmuyor lutfen sonunu bekleyin' reg_only: '&fSadece kayitli uyeler girebilir ! Kayit olmak icin www.orneksite.com adresini ziyaret ediniz !' logged_in: '&cZaten Giris Yapilmis!' @@ -52,9 +50,6 @@ email_added: '[AuthMe] Eposta Eklendi !' email_confirm: '[AuthMe] Epostani Dogrula !' email_changed: '[AuthMe] Eposta Degistirildi !' email_send: '[AuthMe] Kurtarma postasi gonderildi !' -email_exists: '[AuthMe] An email already exists on your account. You can change it using the command below' country_banned: 'Ulken bu serverdan banlandi !' antibot_auto_enabled: '[AuthMe] AntiBotMode otomatik olarak etkinlestirildi!' antibot_auto_disabled: '[AuthMe] AntiBotMode %m dakika sonra otomatik olarak isgal yuzundan devredisi birakildi' -kick_antibot: 'AntiBot protection mode is enabled! You have to wait some minutes before joining the server.' -two_factor_create: '&2Your secret code is %code' \ No newline at end of file diff --git a/src/main/resources/messages/messages_uk.yml b/src/main/resources/messages/messages_uk.yml index 8f5cd93e..6b132d8d 100644 --- a/src/main/resources/messages/messages_uk.yml +++ b/src/main/resources/messages/messages_uk.yml @@ -55,6 +55,3 @@ email_send: '[AuthMe] Лист для відновлення надіслано country_banned: 'Сервер не доступний для вашої країни | Your country is banned from this server' antibot_auto_enabled: '[AuthMe] AntiBotMod автоматично увімкнений (забагато одначасних з`єднань)!' antibot_auto_disabled: '[AuthMe] AntiBotMod автоматично вимкнувся, сподіваємось атака зупинена' -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:' -two_factor_create: '&2Your secret code is %code' diff --git a/src/main/resources/messages/messages_vn.yml b/src/main/resources/messages/messages_vn.yml index 3181d536..ad175e18 100644 --- a/src/main/resources/messages/messages_vn.yml +++ b/src/main/resources/messages/messages_vn.yml @@ -53,8 +53,3 @@ email_send: '[AuthMe] Đã gửi email khôi phục mật khẩu tới bạn !' country_banned: 'Rất tiếc, quốc gia của bạn không được phép gia nhập server' antibot_auto_enabled: '[AuthMe] AntiBot đã được kích hoạt vì lượng người chơi kết nối vượt quá giới hạn!' antibot_auto_disabled: '[AuthMe] AntiBot tự huỷ kích hoạt sau %m phút, hi vọng lượng kết nối sẽ giảm bớt' -password_error_nick: '&cYou can''t use your name as password, please choose another one...' -password_error_unsafe: '&cThe chosen password isn''t safe, please choose another one...' -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:' -two_factor_create: '&2Your secret code is %code' diff --git a/src/main/resources/messages/messages_zhcn.yml b/src/main/resources/messages/messages_zhcn.yml index 3c67b6fe..897c052d 100644 --- a/src/main/resources/messages/messages_zhcn.yml +++ b/src/main/resources/messages/messages_zhcn.yml @@ -59,4 +59,3 @@ email_send: '&8[&6用戶系統&8] 忘記密碼信件已寄出,請查收。' country_banned: '&8[&6用戶系統&8] 本伺服器已停止對你的國家提供遊戲服務。' antibot_auto_enabled: '&8[&6用戶系統&8] 防止機械人程序已因應現時大量不尋常的連線而啟用。' antibot_auto_disabled: '&8[&6用戶系統&8] 防止機械人程序檢查到不正常連接數已減少,並於 %m 分鐘後停止運作。' -two_factor_create: '&2Your secret code is %code' \ No newline at end of file diff --git a/src/main/resources/messages/messages_zhhk.yml b/src/main/resources/messages/messages_zhhk.yml index ce512b3f..a1c72a99 100644 --- a/src/main/resources/messages/messages_zhhk.yml +++ b/src/main/resources/messages/messages_zhhk.yml @@ -58,6 +58,4 @@ email_send: '&8[&6用戶系統&8] 忘記密碼信件已寄出,請查收。' country_banned: '&8[&6用戶系統&8] 本伺服器已停止對你的國家提供遊戲服務。' antibot_auto_enabled: '&8[&6用戶系統&8] 防止機械人程序已因應現時大量不尋常連線而啟用。' antibot_auto_disabled: '&8[&6用戶系統&8] 不正常連接數已減少,防止機械人程序將於 %m 分鐘後停止。' -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:' -two_factor_create: '&2Your secret code is %code' + diff --git a/src/main/resources/messages/messages_zhtw.yml b/src/main/resources/messages/messages_zhtw.yml index 39b5dafd..97e4a0b4 100644 --- a/src/main/resources/messages/messages_zhtw.yml +++ b/src/main/resources/messages/messages_zhtw.yml @@ -59,5 +59,3 @@ email_exists: '&b【AuthMe】&6這個帳戶已經有設定電子郵件了' country_banned: '&b【AuthMe】&6你所在的地區無法進入此伺服器' antibot_auto_enabled: '&b【AuthMe】&6AntiBotMod已自動啟用!' antibot_auto_disabled: '&b【AuthMe】&6AntiBotMod將會於 &c%m &6分鐘後自動關閉' -kick_antibot: 'AntiBot protection mode is enabled! You have to wait some minutes before joining the server.' -two_factor_create: '&2Your secret code is %code' From ea93a336c3e154e23edf3ab056d24bf2d2b4a3b6 Mon Sep 17 00:00:00 2001 From: ljacqu Date: Thu, 11 Feb 2016 23:09:23 +0100 Subject: [PATCH 34/41] Minor - fix Javadoc warnings --- src/main/java/fr/xephi/authme/PerformBackup.java | 1 + src/main/java/fr/xephi/authme/output/Messages.java | 3 +-- src/main/java/fr/xephi/authme/process/Management.java | 1 + .../fr/xephi/authme/process/login/ProcessSyncPlayerLogin.java | 3 ++- .../authme/process/register/ProcessSyncPasswordRegister.java | 1 + .../fr/xephi/authme/settings/SettingsMigrationService.java | 2 +- 6 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/fr/xephi/authme/PerformBackup.java b/src/main/java/fr/xephi/authme/PerformBackup.java index 36b75d7d..c258f294 100644 --- a/src/main/java/fr/xephi/authme/PerformBackup.java +++ b/src/main/java/fr/xephi/authme/PerformBackup.java @@ -36,6 +36,7 @@ public class PerformBackup { * Constructor for PerformBackup. * * @param instance AuthMe + * @param settings The plugin settings */ public PerformBackup(AuthMe instance, NewSetting settings) { this.dataFolder = instance.getDataFolder(); diff --git a/src/main/java/fr/xephi/authme/output/Messages.java b/src/main/java/fr/xephi/authme/output/Messages.java index c0964ded..c458cbcf 100644 --- a/src/main/java/fr/xephi/authme/output/Messages.java +++ b/src/main/java/fr/xephi/authme/output/Messages.java @@ -11,8 +11,6 @@ import java.io.File; /** * Class for retrieving and sending translatable messages to players. - * This class detects when the language settings have changed and will - * automatically update to use a new language file. */ public class Messages { @@ -25,6 +23,7 @@ public class Messages { * Constructor. * * @param messageFile The messages file to use + * @param defaultFile The file with messages to use as default if missing */ public Messages(File messageFile, File defaultFile) { initializeFile(messageFile); diff --git a/src/main/java/fr/xephi/authme/process/Management.java b/src/main/java/fr/xephi/authme/process/Management.java index ace554b7..597d927e 100644 --- a/src/main/java/fr/xephi/authme/process/Management.java +++ b/src/main/java/fr/xephi/authme/process/Management.java @@ -26,6 +26,7 @@ public class Management { * Constructor for Management. * * @param plugin AuthMe + * @param settings The plugin settings */ public Management(AuthMe plugin, NewSetting settings) { this.plugin = plugin; diff --git a/src/main/java/fr/xephi/authme/process/login/ProcessSyncPlayerLogin.java b/src/main/java/fr/xephi/authme/process/login/ProcessSyncPlayerLogin.java index 07c5b6d4..d1e4fb79 100644 --- a/src/main/java/fr/xephi/authme/process/login/ProcessSyncPlayerLogin.java +++ b/src/main/java/fr/xephi/authme/process/login/ProcessSyncPlayerLogin.java @@ -47,7 +47,8 @@ public class ProcessSyncPlayerLogin implements Runnable { * * @param player Player * @param plugin AuthMe - * @param database DataSource + * @param database DataSource + * @param settings The plugin settings */ public ProcessSyncPlayerLogin(Player player, AuthMe plugin, DataSource database, NewSetting settings) { diff --git a/src/main/java/fr/xephi/authme/process/register/ProcessSyncPasswordRegister.java b/src/main/java/fr/xephi/authme/process/register/ProcessSyncPasswordRegister.java index 6d875ee0..5c787606 100644 --- a/src/main/java/fr/xephi/authme/process/register/ProcessSyncPasswordRegister.java +++ b/src/main/java/fr/xephi/authme/process/register/ProcessSyncPasswordRegister.java @@ -39,6 +39,7 @@ public class ProcessSyncPasswordRegister implements Runnable { * * @param player Player * @param plugin AuthMe + * @param settings The plugin settings */ public ProcessSyncPasswordRegister(Player player, AuthMe plugin, NewSetting settings) { this.m = plugin.getMessages(); diff --git a/src/main/java/fr/xephi/authme/settings/SettingsMigrationService.java b/src/main/java/fr/xephi/authme/settings/SettingsMigrationService.java index e93fd18c..a8347684 100644 --- a/src/main/java/fr/xephi/authme/settings/SettingsMigrationService.java +++ b/src/main/java/fr/xephi/authme/settings/SettingsMigrationService.java @@ -113,7 +113,7 @@ public final class SettingsMigrationService { } /** - * Detected deprecated {@code settings.delayJoinLeaveMessages} and inform user of new "remove join messages" + * Detect deprecated {@code settings.delayJoinLeaveMessages} and inform user of new "remove join messages" * and "remove leave messages" settings. * * @param configuration The file configuration From c28a6922c09a842a087bc1af2a4a48f3c83dee30 Mon Sep 17 00:00:00 2001 From: games647 Date: Fri, 12 Feb 2016 17:37:24 +0100 Subject: [PATCH 35/41] Relocate libraries correctly (Related #467) --- pom.xml | 134 +++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 85 insertions(+), 49 deletions(-) diff --git a/pom.xml b/pom.xml index 61d5f72a..7651f660 100644 --- a/pom.xml +++ b/pom.xml @@ -1,7 +1,7 @@ + xmlns="http://maven.apache.org/POM/4.0.0" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 fr.xephi @@ -138,54 +138,14 @@ + org.apache.maven.plugins maven-shade-plugin 2.4.3 false - false - - - org.mcstats - fr.xephi.authme - - - org.apache - fr.xephi.authme.libs.apache - - - javax.mail - fr.xephi.authme.libs.javax.mail - - - javax.activation - fr.xephi.authme.libs.javax.activation - - - com.sun - fr.xephi.authme.libs.sun - - - com.zaxxer.hikari - fr.xephi.authme.libs.hikari - - - org.slf4j - fr.xephi.authme.libs.slf4j - - - com.maxmind.geoip - fr.xephi.authme.libs.geoip - - - net.ricecode.similarity - fr.xephi.authme.libs.similarity - - - com.google.gson - fr.xephi.authme.libs.google.gson - - + false´ @@ -200,6 +160,49 @@ com.google.guava:guava + + + + com.google.gson + fr.xephi.authme.libs.google + + + org.mcstats + fr.xephi.authme + + + org.apache + fr.xephi.authme.libs.apache + + + javax.mail + fr.xephi.authme.libs.javax.mail + + + javax.activation + fr.xephi.authme.libs.javax.activation + + + com.sun + fr.xephi.authme.libs.sun + + + com.zaxxer.hikari + fr.xephi.authme.libs.hikari + + + org.slf4j + fr.xephi.authme.libs.slf4j + + + com.maxmind.geoip + fr.xephi.authme.libs.geoip + + + net.ricecode.similarity + fr.xephi.authme.libs.similarity + + target/${jarName}-spigot.jar @@ -210,14 +213,47 @@ shade + - com.google.thirdparty - fr.xephi.authme.libs.google.thirdparty + com.google + fr.xephi.authme.libs.google - com.google.commons - fr.xephi.authme.libs.google.commons + org.mcstats + fr.xephi.authme + + + org.apache + fr.xephi.authme.libs.apache + + + javax.mail + fr.xephi.authme.libs.javax.mail + + + javax.activation + fr.xephi.authme.libs.javax.activation + + + com.sun + fr.xephi.authme.libs.sun + + + com.zaxxer.hikari + fr.xephi.authme.libs.hikari + + + org.slf4j + fr.xephi.authme.libs.slf4j + + + com.maxmind.geoip + fr.xephi.authme.libs.geoip + + + net.ricecode.similarity + fr.xephi.authme.libs.similarity target/${jarName}-legacy.jar From 57da572b23c6b5bbba553bedbb21895076d15fc7 Mon Sep 17 00:00:00 2001 From: ljacqu Date: Fri, 12 Feb 2016 23:31:55 +0100 Subject: [PATCH 36/41] #421 Clean up events javadoc and interface - Add proper javadoc to all events - Use proper handling of the Eventlist in all events: each event has its own EventList and its static method, as specified by Bukkit's Event class - Add common supertype to all AuthMe events - Remove unused events - Remove unused methods (setters to fields that we ignore entirely) --- .../authme/events/AbstractTeleportEvent.java | 90 ++++++++++++++++++ .../events/AuthMeAsyncPreLoginEvent.java | 32 ++++--- .../authme/events/AuthMeTeleportEvent.java | 59 ++++-------- .../fr/xephi/authme/events/CustomEvent.java | 60 ++---------- .../events/FirstSpawnTeleportEvent.java | 63 ++++--------- .../fr/xephi/authme/events/LoginEvent.java | 74 ++++----------- .../fr/xephi/authme/events/LogoutEvent.java | 41 +++----- .../events/PasswordEncryptionEvent.java | 32 ++++++- .../authme/events/ProtectInventoryEvent.java | 94 ++++++++----------- .../authme/events/RegisterTeleportEvent.java | 67 ------------- .../authme/events/ResetInventoryEvent.java | 43 --------- .../authme/events/RestoreInventoryEvent.java | 58 +++++++----- .../authme/events/SpawnTeleportEvent.java | 84 ++++++----------- .../process/login/ProcessSyncPlayerLogin.java | 40 ++++---- .../register/ProcessSyncPasswordRegister.java | 2 +- 15 files changed, 327 insertions(+), 512 deletions(-) create mode 100644 src/main/java/fr/xephi/authme/events/AbstractTeleportEvent.java delete mode 100644 src/main/java/fr/xephi/authme/events/RegisterTeleportEvent.java delete mode 100644 src/main/java/fr/xephi/authme/events/ResetInventoryEvent.java diff --git a/src/main/java/fr/xephi/authme/events/AbstractTeleportEvent.java b/src/main/java/fr/xephi/authme/events/AbstractTeleportEvent.java new file mode 100644 index 00000000..57a456b6 --- /dev/null +++ b/src/main/java/fr/xephi/authme/events/AbstractTeleportEvent.java @@ -0,0 +1,90 @@ +package fr.xephi.authme.events; + +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; + +/** + * Common supertype for all AuthMe teleport events. + */ +public abstract class AbstractTeleportEvent extends CustomEvent implements Cancellable { + + private final Player player; + private final Location from; + private Location to; + private boolean isCancelled; + + /** + * Constructor. + * + * @param isAsync Whether to fire the event asynchronously or not + * @param player The player + * @param from The location the player is being teleported away from + * @param to The teleport destination + */ + public AbstractTeleportEvent(boolean isAsync, Player player, Location from, Location to) { + super(isAsync); + this.player = player; + this.from = from; + this.to = to; + } + + /** + * Constructor, using the player's current location as "from" location. + * + * @param isAsync Whether to fire the event asynchronously or not + * @param player The player + * @param to The teleport destination + */ + public AbstractTeleportEvent(boolean isAsync, Player player, Location to) { + this(isAsync, player, player.getLocation(), to); + } + + /** + * Return the player planned to be teleported. + * + * @return The player + */ + public Player getPlayer() { + return player; + } + + /** + * Return the location the player is being teleported away from. + * + * @return The location prior to the teleport + */ + public Location getFrom() { + return from; + } + + /** + * Set the destination of the teleport. + * + * @param to The location to teleport the player to + */ + public void setTo(Location to) { + this.to = to; + } + + /** + * Return the destination the player is being teleported to. + * + * @return The teleport destination + */ + public Location getTo() { + return to; + } + + @Override + public void setCancelled(boolean isCancelled) { + this.isCancelled = isCancelled; + } + + @Override + public boolean isCancelled() { + return isCancelled; + } + + +} diff --git a/src/main/java/fr/xephi/authme/events/AuthMeAsyncPreLoginEvent.java b/src/main/java/fr/xephi/authme/events/AuthMeAsyncPreLoginEvent.java index bd1cb1c0..963593fd 100644 --- a/src/main/java/fr/xephi/authme/events/AuthMeAsyncPreLoginEvent.java +++ b/src/main/java/fr/xephi/authme/events/AuthMeAsyncPreLoginEvent.java @@ -5,21 +5,19 @@ import org.bukkit.event.Event; import org.bukkit.event.HandlerList; /** - * This event is call when a player try to /login - * - * @author Xephi59 - * @version $Revision: 1.0 $ + * This event is called when a player uses the /login command with correct credentials. + * {@link #setCanLogin(boolean) {@code event.setCanLogin(false)}} prevents the player from logging in. */ -public class AuthMeAsyncPreLoginEvent extends Event { +public class AuthMeAsyncPreLoginEvent extends CustomEvent { private static final HandlerList handlers = new HandlerList(); private final Player player; private boolean canLogin = true; /** - * Constructor for AuthMeAsyncPreLoginEvent. + * Constructor. * - * @param player Player + * @param player The player */ public AuthMeAsyncPreLoginEvent(Player player) { super(true); @@ -27,37 +25,41 @@ public class AuthMeAsyncPreLoginEvent extends Event { } /** - * Method getPlayer. + * Return the player concerned by this event. * - * @return Player + * @return The player who executed a valid {@code /login} command */ public Player getPlayer() { return player; } /** - * Method canLogin. + * Return whether the player is allowed to log in. * - * @return boolean + * @return True if the player can log in, false otherwise */ public boolean canLogin() { return canLogin; } /** - * Method setCanLogin. + * Define whether or not the player may log in. * - * @param canLogin boolean + * @param canLogin True to allow the player to log in; false to prevent him */ public void setCanLogin(boolean canLogin) { this.canLogin = canLogin; } /** - * Method getHandlers. + * Return the list of handlers, equivalent to {@link #getHandlers()} and required by {@link Event}. * - * @return HandlerList + * @return The list of handlers */ + public static HandlerList getHandlerList() { + return handlers; + } + @Override public HandlerList getHandlers() { return handlers; diff --git a/src/main/java/fr/xephi/authme/events/AuthMeTeleportEvent.java b/src/main/java/fr/xephi/authme/events/AuthMeTeleportEvent.java index 305efa46..ed8a08d3 100644 --- a/src/main/java/fr/xephi/authme/events/AuthMeTeleportEvent.java +++ b/src/main/java/fr/xephi/authme/events/AuthMeTeleportEvent.java @@ -2,65 +2,38 @@ package fr.xephi.authme.events; import org.bukkit.Location; import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; /** - * This event is call when AuthMe try to teleport a player - * - * @author Xephi59 - * @version $Revision: 1.0 $ + * This event is fired before AuthMe teleports a player for general purposes. */ -public class AuthMeTeleportEvent extends CustomEvent { +public class AuthMeTeleportEvent extends AbstractTeleportEvent { - private final Player player; - private Location to; - private final Location from; + private static final HandlerList handlers = new HandlerList(); /** - * Constructor for AuthMeTeleportEvent. + * Constructor. * - * @param player Player - * @param to Location + * @param player The player + * @param to The teleport destination */ public AuthMeTeleportEvent(Player player, Location to) { - this.player = player; - this.from = player.getLocation(); - this.to = to; + super(false, player, to); } /** - * Method getPlayer. + * Return the list of handlers, equivalent to {@link #getHandlers()} and required by {@link Event}. * - * @return Player + * @return The list of handlers */ - public Player getPlayer() { - return player; + public static HandlerList getHandlerList() { + return handlers; } - /** - * Method getTo. - * - * @return Location - */ - public Location getTo() { - return to; - } - - /** - * Method setTo. - * - * @param to Location - */ - public void setTo(Location to) { - this.to = to; - } - - /** - * Method getFrom. - * - * @return Location - */ - public Location getFrom() { - return from; + @Override + public HandlerList getHandlers() { + return handlers; } } diff --git a/src/main/java/fr/xephi/authme/events/CustomEvent.java b/src/main/java/fr/xephi/authme/events/CustomEvent.java index 0dfd0005..f647b6d5 100644 --- a/src/main/java/fr/xephi/authme/events/CustomEvent.java +++ b/src/main/java/fr/xephi/authme/events/CustomEvent.java @@ -1,67 +1,27 @@ package fr.xephi.authme.events; -import org.bukkit.event.Cancellable; import org.bukkit.event.Event; -import org.bukkit.event.HandlerList; /** - * @author Xephi59 - * @version $Revision: 1.0 $ + * The parent of all AuthMe events. */ -public class CustomEvent extends Event implements Cancellable { - - private static final HandlerList handlers = new HandlerList(); - private boolean isCancelled; +public abstract class CustomEvent extends Event { + /** + * Constructor. + */ public CustomEvent() { super(false); } /** - * Constructor for CustomEvent. + * Constructor, specifying whether the event is asynchronous or not. * - * @param b boolean + * @param isAsync {@code true} to fire the event asynchronously, false otherwise + * @see Event#Event(boolean) */ - public CustomEvent(boolean b) { - super(b); - } - - /** - * Method getHandlerList. - * - * @return HandlerList - */ - public static HandlerList getHandlerList() { - return handlers; - } - - /** - * Method getHandlers. - * - * @return HandlerList - */ - public HandlerList getHandlers() { - return handlers; - } - - /** - * Method isCancelled. - * - * @return boolean * @see org.bukkit.event.Cancellable#isCancelled() - */ - public boolean isCancelled() { - return this.isCancelled; - } - - /** - * Method setCancelled. - * - * @param cancelled boolean - * - * @see org.bukkit.event.Cancellable#setCancelled(boolean) - */ - public void setCancelled(boolean cancelled) { - this.isCancelled = cancelled; + public CustomEvent(boolean isAsync) { + super(isAsync); } } diff --git a/src/main/java/fr/xephi/authme/events/FirstSpawnTeleportEvent.java b/src/main/java/fr/xephi/authme/events/FirstSpawnTeleportEvent.java index 136a4d45..28532b39 100644 --- a/src/main/java/fr/xephi/authme/events/FirstSpawnTeleportEvent.java +++ b/src/main/java/fr/xephi/authme/events/FirstSpawnTeleportEvent.java @@ -2,67 +2,40 @@ package fr.xephi.authme.events; import org.bukkit.Location; import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; /** - * Called if a player is teleported to the authme first spawn - * - * @author Xephi59 - * @version $Revision: 1.0 $ + * Event that is called if a player is teleported to the AuthMe first spawn, i.e. to the + * spawn location for players who have never played before. */ -public class FirstSpawnTeleportEvent extends CustomEvent { +public class FirstSpawnTeleportEvent extends AbstractTeleportEvent { - private final Player player; - private Location to; - private final Location from; + private static final HandlerList handlers = new HandlerList(); /** - * Constructor for FirstSpawnTeleportEvent. + * Constructor. * - * @param player Player - * @param from Location - * @param to Location + * @param player The player + * @param from The location the player is being teleported away from + * @param to The teleport destination */ public FirstSpawnTeleportEvent(Player player, Location from, Location to) { - super(true); - this.player = player; - this.from = from; - this.to = to; + super(true, player, from, to); } /** - * Method getPlayer. + * Return the list of handlers, equivalent to {@link #getHandlers()} and required by {@link Event}. * - * @return Player + * @return The list of handlers */ - public Player getPlayer() { - return player; + public static HandlerList getHandlerList() { + return handlers; } - /** - * Method getTo. - * - * @return Location - */ - public Location getTo() { - return to; - } - - /** - * Method setTo. - * - * @param to Location - */ - public void setTo(Location to) { - this.to = to; - } - - /** - * Method getFrom. - * - * @return Location - */ - public Location getFrom() { - return from; + @Override + public HandlerList getHandlers() { + return handlers; } } diff --git a/src/main/java/fr/xephi/authme/events/LoginEvent.java b/src/main/java/fr/xephi/authme/events/LoginEvent.java index c5149327..6c2647fd 100644 --- a/src/main/java/fr/xephi/authme/events/LoginEvent.java +++ b/src/main/java/fr/xephi/authme/events/LoginEvent.java @@ -5,80 +5,40 @@ import org.bukkit.event.Event; import org.bukkit.event.HandlerList; /** - * This event is called when a player login or register through AuthMe. The - * boolean 'isLogin' will be false if, and only if, login/register failed. - * - * @author Xephi59 - * @version $Revision: 1.0 $ + * Event fired when a player has successfully logged in or registered. */ -public class LoginEvent extends Event { +public class LoginEvent extends CustomEvent { private static final HandlerList handlers = new HandlerList(); - private Player player; - private boolean isLogin; + private final Player player; /** - * Constructor for LoginEvent. + * Constructor. * - * @param player Player - * @param isLogin boolean + * @param player The player */ - public LoginEvent(Player player, boolean isLogin) { + public LoginEvent(Player player) { this.player = player; - this.isLogin = isLogin; } /** - * Method getHandlerList. + * Return the player that has successfully logged in or registered. * - * @return HandlerList + * @return The player + */ + public Player getPlayer() { + return player; + } + + /** + * Return the list of handlers, equivalent to {@link #getHandlers()} and required by {@link Event}. + * + * @return The list of handlers */ public static HandlerList getHandlerList() { return handlers; } - /** - * Method getPlayer. - * - * @return Player - */ - public Player getPlayer() { - return this.player; - } - - /** - * Method setPlayer. - * - * @param player Player - */ - public void setPlayer(Player player) { - this.player = player; - } - - /** - * Method isLogin. - * - * @return boolean - */ - public boolean isLogin() { - return isLogin; - } - - /** - * Method setLogin. - * - * @param isLogin boolean - */ - @Deprecated - public void setLogin(boolean isLogin) { - this.isLogin = isLogin; - } - - /** - * Method getHandlers. - * - * @return HandlerList - */ @Override public HandlerList getHandlers() { return handlers; diff --git a/src/main/java/fr/xephi/authme/events/LogoutEvent.java b/src/main/java/fr/xephi/authme/events/LogoutEvent.java index 09d2abd9..70fae096 100644 --- a/src/main/java/fr/xephi/authme/events/LogoutEvent.java +++ b/src/main/java/fr/xephi/authme/events/LogoutEvent.java @@ -5,57 +5,42 @@ import org.bukkit.event.Event; import org.bukkit.event.HandlerList; /** - * This event is called when a player logout through AuthMe. - * - * @author Xephi59 - * @version $Revision: 1.0 $ + * This event is called when a player logs out through AuthMe, i.e. only when the player + * has executed the {@code /logout} command. This event is not fired if a player simply + * leaves the server. */ -public class LogoutEvent extends Event { +public class LogoutEvent extends CustomEvent { private static final HandlerList handlers = new HandlerList(); - private Player player; + private final Player player; /** - * Constructor for LogoutEvent. + * Constructor. * - * @param player Player + * @param player The player */ public LogoutEvent(Player player) { this.player = player; } /** - * Method getHandlerList. + * Return the player who logged out. * - * @return HandlerList - */ - public static HandlerList getHandlerList() { - return handlers; - } - - /** - * Method getPlayer. - * - * @return Player + * @return The player */ public Player getPlayer() { return this.player; } /** - * Method setPlayer. + * Return the list of handlers, equivalent to {@link #getHandlers()} and required by {@link Event}. * - * @param player Player + * @return The list of handlers */ - public void setPlayer(Player player) { - this.player = player; + public static HandlerList getHandlerList() { + return handlers; } - /** - * Method getHandlers. - * - * @return HandlerList - */ @Override public HandlerList getHandlers() { return handlers; diff --git a/src/main/java/fr/xephi/authme/events/PasswordEncryptionEvent.java b/src/main/java/fr/xephi/authme/events/PasswordEncryptionEvent.java index 572d1c9a..6e710ddc 100644 --- a/src/main/java/fr/xephi/authme/events/PasswordEncryptionEvent.java +++ b/src/main/java/fr/xephi/authme/events/PasswordEncryptionEvent.java @@ -5,24 +5,33 @@ import org.bukkit.event.Event; import org.bukkit.event.HandlerList; /** - * This event is called when we need to compare or hash password and allows + * This event is called when we need to compare or hash a password for a player and allows * third-party listeners to change the encryption method. This is typically * done with the {@link fr.xephi.authme.security.HashAlgorithm#CUSTOM} setting. - * - * @author Xephi59 */ -public class PasswordEncryptionEvent extends Event { +public class PasswordEncryptionEvent extends CustomEvent { private static final HandlerList handlers = new HandlerList(); private EncryptionMethod method; private String playerName; + /** + * Constructor. + * + * @param method The method used to encrypt the password + * @param playerName The name of the player + */ public PasswordEncryptionEvent(EncryptionMethod method, String playerName) { super(false); this.method = method; this.playerName = playerName; } + /** + * Return the list of handlers, equivalent to {@link #getHandlers()} and required by {@link Event}. + * + * @return The list of handlers + */ public static HandlerList getHandlerList() { return handlers; } @@ -32,14 +41,29 @@ public class PasswordEncryptionEvent extends Event { return handlers; } + /** + * Return the encryption method used to hash the password. + * + * @return The encryption method + */ public EncryptionMethod getMethod() { return method; } + /** + * Set the encryption method to hash the password with. + * + * @param method The encryption method to use + */ public void setMethod(EncryptionMethod method) { this.method = method; } + /** + * Return the name of the player the event has been fired for. + * + * @return The player name + */ public String getPlayerName() { return playerName; } diff --git a/src/main/java/fr/xephi/authme/events/ProtectInventoryEvent.java b/src/main/java/fr/xephi/authme/events/ProtectInventoryEvent.java index dea3a460..2541c3ee 100644 --- a/src/main/java/fr/xephi/authme/events/ProtectInventoryEvent.java +++ b/src/main/java/fr/xephi/authme/events/ProtectInventoryEvent.java @@ -1,98 +1,84 @@ package fr.xephi.authme.events; import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; import org.bukkit.inventory.ItemStack; /** - * This event is call just after store inventory into cache and will empty the - * player inventory. - * - * @author Xephi59 - * @version $Revision: 1.0 $ + * This event is called before the inventory data of a player is suppressed, + * i.e. the inventory of the player is not displayed until he has authenticated. */ -public class ProtectInventoryEvent extends CustomEvent { +public class ProtectInventoryEvent extends CustomEvent implements Cancellable { - private final ItemStack[] storedinventory; - private final ItemStack[] storedarmor; - private ItemStack[] emptyInventory = null; - private ItemStack[] emptyArmor = null; + private static final HandlerList handlers = new HandlerList(); + private final ItemStack[] storedInventory; + private final ItemStack[] storedArmor; private final Player player; + private boolean isCancelled; /** - * Constructor for ProtectInventoryEvent. + * Constructor. * - * @param player Player + * @param player The player */ public ProtectInventoryEvent(Player player) { super(true); this.player = player; - this.storedinventory = player.getInventory().getContents(); - this.storedarmor = player.getInventory().getArmorContents(); - this.emptyInventory = new ItemStack[36]; - this.emptyArmor = new ItemStack[4]; + this.storedInventory = player.getInventory().getContents(); + this.storedArmor = player.getInventory().getArmorContents(); } /** - * Method getStoredInventory. + * Return the inventory of the player. * - * @return ItemStack[] + * @return The player's inventory */ public ItemStack[] getStoredInventory() { - return this.storedinventory; + return storedInventory; } /** - * Method getStoredArmor. + * Return the armor of the player. * - * @return ItemStack[] + * @return The player's armor */ public ItemStack[] getStoredArmor() { - return this.storedarmor; + return storedArmor; } /** - * Method getPlayer. + * Return the player whose inventory will be hidden. * - * @return Player + * @return The player associated with this event */ public Player getPlayer() { - return this.player; + return player; + } + + @Override + public void setCancelled(boolean isCancelled) { + this.isCancelled = isCancelled; + } + + @Override + public boolean isCancelled() { + return isCancelled; } /** - * Method setNewInventory. + * Return the list of handlers, equivalent to {@link #getHandlers()} and required by {@link Event}. * - * @param emptyInventory ItemStack[] + * @return The list of handlers */ - public void setNewInventory(ItemStack[] emptyInventory) { - this.emptyInventory = emptyInventory; + public static HandlerList getHandlerList() { + return handlers; } - /** - * Method getEmptyInventory. - * - * @return ItemStack[] - */ - public ItemStack[] getEmptyInventory() { - return this.emptyInventory; - } - - /** - * Method setNewArmor. - * - * @param emptyArmor ItemStack[] - */ - public void setNewArmor(ItemStack[] emptyArmor) { - this.emptyArmor = emptyArmor; - } - - /** - * Method getEmptyArmor. - * - * @return ItemStack[] - */ - public ItemStack[] getEmptyArmor() { - return this.emptyArmor; + @Override + public HandlerList getHandlers() { + return handlers; } } diff --git a/src/main/java/fr/xephi/authme/events/RegisterTeleportEvent.java b/src/main/java/fr/xephi/authme/events/RegisterTeleportEvent.java deleted file mode 100644 index a4fef0b6..00000000 --- a/src/main/java/fr/xephi/authme/events/RegisterTeleportEvent.java +++ /dev/null @@ -1,67 +0,0 @@ -package fr.xephi.authme.events; - -import org.bukkit.Location; -import org.bukkit.entity.Player; - -/** - * This event is call if, and only if, a player is teleported just after a - * register. - * - * @author Xephi59 - * @version $Revision: 1.0 $ - */ -public class RegisterTeleportEvent extends CustomEvent { - - private final Player player; - private Location to; - private final Location from; - - /** - * Constructor for RegisterTeleportEvent. - * - * @param player Player - * @param to Location - */ - public RegisterTeleportEvent(Player player, Location to) { - this.player = player; - this.from = player.getLocation(); - this.to = to; - } - - /** - * Method getPlayer. - * - * @return Player - */ - public Player getPlayer() { - return player; - } - - /** - * Method getTo. - * - * @return Location - */ - public Location getTo() { - return to; - } - - /** - * Method setTo. - * - * @param to Location - */ - public void setTo(Location to) { - this.to = to; - } - - /** - * Method getFrom. - * - * @return Location - */ - public Location getFrom() { - return from; - } - -} diff --git a/src/main/java/fr/xephi/authme/events/ResetInventoryEvent.java b/src/main/java/fr/xephi/authme/events/ResetInventoryEvent.java deleted file mode 100644 index 75c48636..00000000 --- a/src/main/java/fr/xephi/authme/events/ResetInventoryEvent.java +++ /dev/null @@ -1,43 +0,0 @@ -package fr.xephi.authme.events; - -import org.bukkit.entity.Player; - -/** - * This event is call when a creative inventory is reseted. - * - * @author Xephi59 - * @version $Revision: 1.0 $ - */ -public class ResetInventoryEvent extends CustomEvent { - - private Player player; - - /** - * Constructor for ResetInventoryEvent. - * - * @param player Player - */ - public ResetInventoryEvent(Player player) { - super(true); - this.player = player; - } - - /** - * Method getPlayer. - * - * @return Player - */ - public Player getPlayer() { - return this.player; - } - - /** - * Method setPlayer. - * - * @param player Player - */ - public void setPlayer(Player player) { - this.player = player; - } - -} diff --git a/src/main/java/fr/xephi/authme/events/RestoreInventoryEvent.java b/src/main/java/fr/xephi/authme/events/RestoreInventoryEvent.java index e34d7c97..eb9bf71d 100644 --- a/src/main/java/fr/xephi/authme/events/RestoreInventoryEvent.java +++ b/src/main/java/fr/xephi/authme/events/RestoreInventoryEvent.java @@ -1,52 +1,60 @@ package fr.xephi.authme.events; import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; /** - * This event restore the inventory. - * - * @author Xephi59 - * @version $Revision: 1.0 $ + * This event is fired when the inventory of a player is restored + * (the inventory data is no longer hidden from the user). */ -public class RestoreInventoryEvent extends CustomEvent { +public class RestoreInventoryEvent extends CustomEvent implements Cancellable { - private Player player; + private static final HandlerList handlers = new HandlerList(); + private final Player player; + private boolean isCancelled; /** - * Constructor for RestoreInventoryEvent. + * Constructor. * - * @param player Player + * @param player The player */ public RestoreInventoryEvent(Player player) { this.player = player; } /** - * Constructor for RestoreInventoryEvent. - * - * @param player Player - * @param async boolean - */ - public RestoreInventoryEvent(Player player, boolean async) { - super(async); - this.player = player; - } - - /** - * Method getPlayer. + * Return the player whose inventory will be restored. * * @return Player */ public Player getPlayer() { - return this.player; + return player; + } + + @Override + public boolean isCancelled() { + return isCancelled; + } + + @Override + public void setCancelled(boolean isCancelled) { + this.isCancelled = isCancelled; } /** - * Method setPlayer. + * Return the list of handlers, equivalent to {@link #getHandlers()} and required by {@link Event}. * - * @param player Player + * @return The list of handlers */ - public void setPlayer(Player player) { - this.player = player; + public static HandlerList getHandlerList() { + return handlers; } + + @Override + public HandlerList getHandlers() { + return handlers; + } + } diff --git a/src/main/java/fr/xephi/authme/events/SpawnTeleportEvent.java b/src/main/java/fr/xephi/authme/events/SpawnTeleportEvent.java index c971f572..3a429bc3 100644 --- a/src/main/java/fr/xephi/authme/events/SpawnTeleportEvent.java +++ b/src/main/java/fr/xephi/authme/events/SpawnTeleportEvent.java @@ -2,79 +2,51 @@ package fr.xephi.authme.events; import org.bukkit.Location; import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; /** - * Called if a player is teleported to a specific spawn - * - * @author Xephi59 - * @version $Revision: 1.0 $ + * Called if a player is teleported to a specific spawn upon joining or logging in. */ -public class SpawnTeleportEvent extends CustomEvent { +public class SpawnTeleportEvent extends AbstractTeleportEvent { - private final Player player; - private Location to; - private final Location from; + private static final HandlerList handlers = new HandlerList(); private final boolean isAuthenticated; /** - * Constructor for SpawnTeleportEvent. + * Constructor. * - * @param player Player - * @param from Location - * @param to Location - * @param isAuthenticated boolean + * @param player The player + * @param from The location the player is being teleported away from + * @param to The teleport destination + * @param isAuthenticated Whether or not the player is logged in */ - public SpawnTeleportEvent(Player player, Location from, Location to, - boolean isAuthenticated) { - this.player = player; - this.from = from; - this.to = to; + public SpawnTeleportEvent(Player player, Location from, Location to, boolean isAuthenticated) { + super(false, player, from, to); this.isAuthenticated = isAuthenticated; } /** - * Method getPlayer. + * Return whether or not the player is authenticated. * - * @return Player - */ - public Player getPlayer() { - return player; - } - - /** - * Method getTo. - * - * @return Location - */ - public Location getTo() { - return to; - } - - /** - * Method setTo. - * - * @param to Location - */ - public void setTo(Location to) { - this.to = to; - } - - /** - * Method getFrom. - * - * @return Location - */ - public Location getFrom() { - return from; - } - - /** - * Method isAuthenticated. - * - * @return boolean + * @return true if the player is logged in, false otherwise */ public boolean isAuthenticated() { return isAuthenticated; } + /** + * Return the list of handlers, equivalent to {@link #getHandlers()} and required by {@link Event}. + * + * @return The list of handlers + */ + public static HandlerList getHandlerList() { + return handlers; + } + + @Override + public HandlerList getHandlers() { + return handlers; + } + } diff --git a/src/main/java/fr/xephi/authme/process/login/ProcessSyncPlayerLogin.java b/src/main/java/fr/xephi/authme/process/login/ProcessSyncPlayerLogin.java index d1e4fb79..21bb427b 100644 --- a/src/main/java/fr/xephi/authme/process/login/ProcessSyncPlayerLogin.java +++ b/src/main/java/fr/xephi/authme/process/login/ProcessSyncPlayerLogin.java @@ -28,8 +28,7 @@ import fr.xephi.authme.util.Utils.GroupType; import static fr.xephi.authme.settings.properties.RestrictionSettings.PROTECT_INVENTORY_BEFORE_LOGIN; -/** - */ + public class ProcessSyncPlayerLogin implements Runnable { private final LimboPlayer limbo; @@ -63,24 +62,19 @@ public class ProcessSyncPlayerLogin implements Runnable { this.settings = settings; } - /** - * Method getLimbo. - * - * @return LimboPlayer - */ public LimboPlayer getLimbo() { return limbo; } - protected void restoreOpState() { + private void restoreOpState() { player.setOp(limbo.getOperator()); } - protected void packQuitLocation() { + private void packQuitLocation() { Utils.packCoords(auth.getQuitLocX(), auth.getQuitLocY(), auth.getQuitLocZ(), auth.getWorld(), player); } - protected void teleportBackFromSpawn() { + private void teleportBackFromSpawn() { AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(player, limbo.getLoc()); pm.callEvent(tpEvent); if (!tpEvent.isCancelled() && tpEvent.getTo() != null) { @@ -88,7 +82,7 @@ public class ProcessSyncPlayerLogin implements Runnable { } } - protected void teleportToSpawn() { + private void teleportToSpawn() { Location spawnL = plugin.getSpawnLocation(player); SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawnL, true); pm.callEvent(tpEvent); @@ -97,14 +91,14 @@ public class ProcessSyncPlayerLogin implements Runnable { } } - protected void restoreSpeedEffects() { + private void restoreSpeedEffects() { if (Settings.isRemoveSpeedEnabled) { player.setWalkSpeed(0.2F); player.setFlySpeed(0.1F); } } - protected void restoreInventory() { + private void restoreInventory() { RestoreInventoryEvent event = new RestoreInventoryEvent(player); pm.callEvent(event); if (!event.isCancelled() && plugin.inventoryProtector != null) { @@ -112,7 +106,7 @@ public class ProcessSyncPlayerLogin implements Runnable { } } - protected void forceCommands() { + private void forceCommands() { for (String command : Settings.forceCommands) { player.performCommand(command.replace("%p", player.getName())); } @@ -121,7 +115,7 @@ public class ProcessSyncPlayerLogin implements Runnable { } } - protected void sendBungeeMessage() { + private void sendBungeeMessage() { ByteArrayDataOutput out = ByteStreams.newDataOutput(); out.writeUTF("Forward"); out.writeUTF("ALL"); @@ -130,11 +124,6 @@ public class ProcessSyncPlayerLogin implements Runnable { player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray()); } - /** - * Method run. - * - * @see java.lang.Runnable#run() - */ @Override public void run() { // Limbo contains the State of the Player before /login @@ -175,8 +164,9 @@ public class ProcessSyncPlayerLogin implements Runnable { if (jm != null) { if (!jm.isEmpty()) { for (Player p : Utils.getOnlinePlayers()) { - if (p.isOnline()) + if (p.isOnline()) { p.sendMessage(jm); + } } } AuthMePlayerListener.joinMessage.remove(name); @@ -188,12 +178,13 @@ public class ProcessSyncPlayerLogin implements Runnable { } // The Login event now fires (as intended) after everything is processed - Bukkit.getServer().getPluginManager().callEvent(new LoginEvent(player, true)); + Bukkit.getServer().getPluginManager().callEvent(new LoginEvent(player)); player.saveData(); - if (Settings.bungee) + if (Settings.bungee) { sendBungeeMessage(); + } // Login is finish, display welcome message if we use email registration - if (Settings.useWelcomeMessage && Settings.emailRegistration) + if (Settings.useWelcomeMessage && Settings.emailRegistration) { if (Settings.broadcastWelcomeMessage) { for (String s : settings.getWelcomeMessage()) { Bukkit.getServer().broadcastMessage(plugin.replaceAllInfo(s, player)); @@ -203,6 +194,7 @@ public class ProcessSyncPlayerLogin implements Runnable { player.sendMessage(plugin.replaceAllInfo(s, player)); } } + } // Login is now finished; we can force all commands forceCommands(); diff --git a/src/main/java/fr/xephi/authme/process/register/ProcessSyncPasswordRegister.java b/src/main/java/fr/xephi/authme/process/register/ProcessSyncPasswordRegister.java index 5c787606..60f5bc18 100644 --- a/src/main/java/fr/xephi/authme/process/register/ProcessSyncPasswordRegister.java +++ b/src/main/java/fr/xephi/authme/process/register/ProcessSyncPasswordRegister.java @@ -120,7 +120,7 @@ public class ProcessSyncPasswordRegister implements Runnable { } // The LoginEvent now fires (as intended) after everything is processed - plugin.getServer().getPluginManager().callEvent(new LoginEvent(player, true)); + plugin.getServer().getPluginManager().callEvent(new LoginEvent(player)); player.saveData(); if (!Settings.noConsoleSpam) { From fcfe26f34dfc4650a1697b75d758748ebe205d4d Mon Sep 17 00:00:00 2001 From: ljacqu Date: Fri, 12 Feb 2016 23:38:00 +0100 Subject: [PATCH 37/41] Minor - fix incorrect javadoc and add unit test for Messages#reload --- .../java/fr/xephi/authme/output/Messages.java | 9 ++- .../authme/process/join/AsynchronousJoin.java | 58 ++++++++----------- src/test/java/fr/xephi/authme/TestHelper.java | 2 +- .../output/MessagesIntegrationTest.java | 18 ++++++ src/test/resources/messages_test2.yml | 6 ++ 5 files changed, 54 insertions(+), 39 deletions(-) create mode 100644 src/test/resources/messages_test2.yml diff --git a/src/main/java/fr/xephi/authme/output/Messages.java b/src/main/java/fr/xephi/authme/output/Messages.java index c458cbcf..fed90c91 100644 --- a/src/main/java/fr/xephi/authme/output/Messages.java +++ b/src/main/java/fr/xephi/authme/output/Messages.java @@ -16,7 +16,7 @@ public class Messages { private FileConfiguration configuration; private String fileName; - private File defaultFile; + private final File defaultFile; private FileConfiguration defaultConfiguration; /** @@ -91,7 +91,6 @@ public class Messages { * Retrieve the message from the text file. * * @param key The message key to retrieve - * * @return The message from the file */ public String retrieveSingle(MessageKey key) { @@ -100,6 +99,8 @@ public class Messages { /** * Reload the messages manager. + * + * @param messagesFile The new file to load messages from */ public void reload(File messagesFile) { initializeFile(messagesFile); @@ -119,9 +120,7 @@ public class Messages { defaultConfiguration = YamlConfiguration.loadConfiguration(defaultFile); } String message = defaultConfiguration.getString(code); - return (message == null) - ? "Error retrieving message '" + code + "'" - : message; + return message == null ? getDefaultErrorMessage(code) : message; } private static String getDefaultErrorMessage(String code) { diff --git a/src/main/java/fr/xephi/authme/process/join/AsynchronousJoin.java b/src/main/java/fr/xephi/authme/process/join/AsynchronousJoin.java index 040c98fb..90c51fb5 100644 --- a/src/main/java/fr/xephi/authme/process/join/AsynchronousJoin.java +++ b/src/main/java/fr/xephi/authme/process/join/AsynchronousJoin.java @@ -80,18 +80,17 @@ public class AsynchronousJoin { if (Settings.getMaxJoinPerIp > 0 && !plugin.getPermissionsManager().hasPermission(player, PlayerPermission.ALLOW_MULTIPLE_ACCOUNTS) && !ip.equalsIgnoreCase("127.0.0.1") - && !ip.equalsIgnoreCase("localhost")) { - if (plugin.hasJoinedIp(player.getName(), ip)) { - sched.scheduleSyncDelayedTask(plugin, new Runnable() { + && !ip.equalsIgnoreCase("localhost") + && plugin.hasJoinedIp(player.getName(), ip)) { + sched.scheduleSyncDelayedTask(plugin, new Runnable() { - @Override - public void run() { - player.kickPlayer("A player with the same IP is already in game!"); - } + @Override + public void run() { + player.kickPlayer("A player with the same IP is already in game!"); + } - }); - return; - } + }); + return; } final Location spawnLoc = plugin.getSpawnLocation(player); final boolean isAuthAvailable = database.isAuthAvailable(name); @@ -104,12 +103,9 @@ public class AsynchronousJoin { public void run() { SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawnLoc, PlayerCache.getInstance().isAuthenticated(name)); plugin.getServer().getPluginManager().callEvent(tpEvent); - if (!tpEvent.isCancelled()) { - if (player.isOnline() && tpEvent.getTo() != null) { - if (tpEvent.getTo().getWorld() != null) { - player.teleport(tpEvent.getTo()); - } - } + if (!tpEvent.isCancelled() && player.isOnline() && tpEvent.getTo() != null + && tpEvent.getTo().getWorld() != null) { + player.teleport(tpEvent.getTo()); } } @@ -155,25 +151,21 @@ public class AsynchronousJoin { return; } - if (!Settings.noTeleport) { - if (!needFirstSpawn() && Settings.isTeleportToSpawnEnabled || (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName()))) { - sched.scheduleSyncDelayedTask(plugin, new Runnable() { + if (!Settings.noTeleport && !needFirstSpawn() && Settings.isTeleportToSpawnEnabled + || (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName()))) { + sched.scheduleSyncDelayedTask(plugin, new Runnable() { - @Override - public void run() { - SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawnLoc, PlayerCache.getInstance().isAuthenticated(name)); - plugin.getServer().getPluginManager().callEvent(tpEvent); - if (!tpEvent.isCancelled()) { - if (player.isOnline() && tpEvent.getTo() != null) { - if (tpEvent.getTo().getWorld() != null) { - player.teleport(tpEvent.getTo()); - } - } - } - } + @Override + public void run() { + SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawnLoc, PlayerCache.getInstance().isAuthenticated(name)); + plugin.getServer().getPluginManager().callEvent(tpEvent); + if (!tpEvent.isCancelled() && player.isOnline() && tpEvent.getTo() != null + && tpEvent.getTo().getWorld() != null) { + player.teleport(tpEvent.getTo()); + } + } - }); - } + }); } } diff --git a/src/test/java/fr/xephi/authme/TestHelper.java b/src/test/java/fr/xephi/authme/TestHelper.java index 9f2ec360..a7a60865 100644 --- a/src/test/java/fr/xephi/authme/TestHelper.java +++ b/src/test/java/fr/xephi/authme/TestHelper.java @@ -12,7 +12,7 @@ public final class TestHelper { } /** - * Return a {@link File} to an existing file from the main (non-test) resources folder. + * Return a {@link File} to a file in the JAR's resources (main or test). * * @param path The absolute path to the file * @return The project file diff --git a/src/test/java/fr/xephi/authme/output/MessagesIntegrationTest.java b/src/test/java/fr/xephi/authme/output/MessagesIntegrationTest.java index e8579077..ca7e5f70 100644 --- a/src/test/java/fr/xephi/authme/output/MessagesIntegrationTest.java +++ b/src/test/java/fr/xephi/authme/output/MessagesIntegrationTest.java @@ -19,6 +19,7 @@ import static org.hamcrest.Matchers.arrayWithSize; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.equalTo; import static org.junit.Assert.assertThat; +import static org.junit.Assume.assumeThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -249,4 +250,21 @@ public class MessagesIntegrationTest { // then assertThat(message, containsString("Error retrieving message")); } + + @Test + public void shouldLoadOtherFile() { + // given + MessageKey key = MessageKey.WRONG_PASSWORD; + // assumption: message comes back as defined in messages_test.yml + assumeThat(messages.retrieveSingle(key), equalTo("§cWrong password!")); + + // when + messages.reload(TestHelper.getJarFile("/messages_test2.yml")); + + // then + assertThat(messages.retrieveSingle(key), equalTo("test2 - wrong password")); + // check that default message handling still works + assertThat(messages.retrieveSingle(MessageKey.MUST_REGISTER_MESSAGE), + equalTo("Message from default file")); + } } diff --git a/src/test/resources/messages_test2.yml b/src/test/resources/messages_test2.yml new file mode 100644 index 00000000..bdbedb8a --- /dev/null +++ b/src/test/resources/messages_test2.yml @@ -0,0 +1,6 @@ +# Sample messages file + +unknown_user: 'Message from test2' +unsafe_spawn: 'test2 - unsafe spawn' +not_logged_in: 'test2 - not logged in' +wrong_pwd: 'test2 - wrong password' From cae9fc70fe05515c42dbdda911a0c640182358e7 Mon Sep 17 00:00:00 2001 From: ljacqu Date: Sat, 13 Feb 2016 10:56:15 +0100 Subject: [PATCH 38/41] #518 Create injection-safe website integration and demo form --- samples/website_integration/form.php | 52 ++++++++++++++++ samples/website_integration/integration.php | 67 +++++++++++++++++++++ 2 files changed, 119 insertions(+) create mode 100644 samples/website_integration/form.php create mode 100644 samples/website_integration/integration.php diff --git a/samples/website_integration/form.php b/samples/website_integration/form.php new file mode 100644 index 00000000..120d4287 --- /dev/null +++ b/samples/website_integration/form.php @@ -0,0 +1,52 @@ + + + + + AuthMe Integration Sample + + + +Hello, %s!', htmlspecialchars($user)); + echo 'Successful login. Nice to have you back!' + . '
    Back to form'; + $was_successful = true; + } else { + echo '

    Error

    Invalid username or password.'; + } +} + +if (!$was_successful) { + echo '

    Login sample

    +This is a demo form for AuthMe website integration. Enter your AuthMe login details +into the following form to test it. +
    + + + +
    Name
    Pass
    +
    +
    '; +} + +function get_from_post_or_empty($index_name) { + return trim( + filter_input(INPUT_POST, $index_name, FILTER_UNSAFE_RAW, FILTER_REQUIRE_SCALAR | FILTER_FLAG_STRIP_LOW) + ?: ''); +} +?> + + + diff --git a/samples/website_integration/integration.php b/samples/website_integration/integration.php new file mode 100644 index 00000000..56d51d36 --- /dev/null +++ b/samples/website_integration/integration.php @@ -0,0 +1,67 @@ +prepare("SELECT password FROM $authme_table WHERE username = ?"); + $stmt->bind_param('s', $username); + $stmt->execute(); + $stmt->bind_result($password); + if ($stmt->fetch()) { + return $password; + } + } + return null; +} + +/** + * Checks the given clear-text password against the hash. + * + * @param string $password the clear-text password to check + * @param string $hash the hash to check the password against + * @return bool true iff the password matches the hash, false otherwise + */ +function authme_check_hash($password, $hash) { + // $SHA$salt$hash, where hash := sha256(sha256(password) . salt) + $parts = explode('$', $hash); + return count($parts) === 4 + && $parts[3] === hash('sha256', hash('sha256', $password) . $parts[2]); +} From 84741e2882b1f2f6784023b1b2be78b1896e77b5 Mon Sep 17 00:00:00 2001 From: ljacqu Date: Sat, 13 Feb 2016 11:00:56 +0100 Subject: [PATCH 39/41] Minor - replace tabs to spaces in php integration sample --- samples/website_integration/form.php | 26 ++++++++++----------- samples/website_integration/integration.php | 14 +++++------ 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/samples/website_integration/form.php b/samples/website_integration/form.php index 120d4287..5f2985cb 100644 --- a/samples/website_integration/form.php +++ b/samples/website_integration/form.php @@ -17,19 +17,19 @@ $pass = get_from_post_or_empty('password'); $was_successful = false; if ($user && $pass) { - require_once('integration.php'); - if (authme_check_password($user, $pass)) { - printf('

    Hello, %s!

    ', htmlspecialchars($user)); - echo 'Successful login. Nice to have you back!' - . '
    Back to form'; - $was_successful = true; - } else { - echo '

    Error

    Invalid username or password.'; - } + require_once('integration.php'); + if (authme_check_password($user, $pass)) { + printf('

    Hello, %s!

    ', htmlspecialchars($user)); + echo 'Successful login. Nice to have you back!' + . '
    Back to form'; + $was_successful = true; + } else { + echo '

    Error

    Invalid username or password.'; + } } if (!$was_successful) { - echo '

    Login sample

    + echo '

    Login sample

    This is a demo form for AuthMe website integration. Enter your AuthMe login details into the following form to test it.
    @@ -42,9 +42,9 @@ into the following form to test it. } function get_from_post_or_empty($index_name) { - return trim( - filter_input(INPUT_POST, $index_name, FILTER_UNSAFE_RAW, FILTER_REQUIRE_SCALAR | FILTER_FLAG_STRIP_LOW) - ?: ''); + return trim( + filter_input(INPUT_POST, $index_name, FILTER_UNSAFE_RAW, FILTER_REQUIRE_SCALAR | FILTER_FLAG_STRIP_LOW) + ?: ''); } ?> diff --git a/samples/website_integration/integration.php b/samples/website_integration/integration.php index 56d51d36..3008fb98 100644 --- a/samples/website_integration/integration.php +++ b/samples/website_integration/integration.php @@ -34,13 +34,13 @@ function authme_check_password($username, $password) { */ function authme_get_hash($username) { // Add here your database host, username, password and database name - $mysqli = new mysqli('HOST', 'USER', 'PWD', 'DB'); - $authme_table = 'authme'; + $mysqli = new mysqli('HOST', 'USER', 'PWD', 'DB'); + $authme_table = 'authme'; - if (mysqli_connect_error()) { - printf('Could not connect to AuthMe database. Errno: %d, error: "%s"', - mysqli_connect_errno(), mysqli_connect_error()); - } else { + if (mysqli_connect_error()) { + printf('Could not connect to AuthMe database. Errno: %d, error: "%s"', + mysqli_connect_errno(), mysqli_connect_error()); + } else { $stmt = $mysqli->prepare("SELECT password FROM $authme_table WHERE username = ?"); $stmt->bind_param('s', $username); $stmt->execute(); @@ -48,7 +48,7 @@ function authme_get_hash($username) { if ($stmt->fetch()) { return $password; } - } + } return null; } From 432ed4620c8bb0e0ec1e7c0a04848735538fadad Mon Sep 17 00:00:00 2001 From: ljacqu Date: Sat, 13 Feb 2016 12:35:33 +0100 Subject: [PATCH 40/41] Fix AuthMe thinking config needs a migration - Old, deprecated property now exists again -> stop checking for its presence as a reason for migration - Create test for SettingsMigrationService to detect such issues in the future --- .../settings/SettingsMigrationService.java | 7 +- .../SettingsMigrationServiceTest.java | 66 +++++++++++++++++++ 2 files changed, 68 insertions(+), 5 deletions(-) create mode 100644 src/test/java/fr/xephi/authme/settings/SettingsMigrationServiceTest.java diff --git a/src/main/java/fr/xephi/authme/settings/SettingsMigrationService.java b/src/main/java/fr/xephi/authme/settings/SettingsMigrationService.java index a8347684..dc448027 100644 --- a/src/main/java/fr/xephi/authme/settings/SettingsMigrationService.java +++ b/src/main/java/fr/xephi/authme/settings/SettingsMigrationService.java @@ -49,11 +49,9 @@ public final class SettingsMigrationService { // Note ljacqu 20160211: Concatenating migration methods with | instead of the usual || // ensures that all migrations will be performed - changes = changes + return changes | performMailTextToFileMigration(configuration, pluginFolder) | migrateJoinLeaveMessages(configuration); - - return changes; } @VisibleForTesting @@ -69,8 +67,7 @@ public final class SettingsMigrationService { private static boolean hasDeprecatedProperties(FileConfiguration configuration) { String[] deprecatedProperties = { "Converter.Rakamak.newPasswordHash", "Hooks.chestshop", "Hooks.legacyChestshop", "Hooks.notifications", - "Passpartu", "Performances", "settings.delayJoinMessage", "settings.restrictions.enablePasswordVerifier", - "Xenoforo.predefinedSalt"}; + "Passpartu", "Performances", "settings.restrictions.enablePasswordVerifier", "Xenoforo.predefinedSalt"}; for (String deprecatedPath : deprecatedProperties) { if (configuration.contains(deprecatedPath)) { return true; diff --git a/src/test/java/fr/xephi/authme/settings/SettingsMigrationServiceTest.java b/src/test/java/fr/xephi/authme/settings/SettingsMigrationServiceTest.java new file mode 100644 index 00000000..cc89a463 --- /dev/null +++ b/src/test/java/fr/xephi/authme/settings/SettingsMigrationServiceTest.java @@ -0,0 +1,66 @@ +package fr.xephi.authme.settings; + +import com.google.common.io.Files; +import fr.xephi.authme.TestHelper; +import fr.xephi.authme.settings.properties.SettingsFieldRetriever; +import fr.xephi.authme.settings.propertymap.PropertyMap; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.configuration.file.YamlConfiguration; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; + +import java.io.File; +import java.io.IOException; + +import static org.hamcrest.Matchers.arrayWithSize; +import static org.hamcrest.Matchers.equalTo; +import static org.junit.Assert.assertThat; +import static org.junit.Assume.assumeThat; + +/** + * Test for {@link SettingsMigrationService}. + */ +public class SettingsMigrationServiceTest { + + @Rule + public TemporaryFolder testFolderHandler = new TemporaryFolder(); + + private File testFolder; + private File configTestFile; + + /** + * Ensure that AuthMe regards the JAR's own config.yml as complete. + * If something legitimately needs migrating, a test from {@link ConfigFileConsistencyTest} should fail. + * If none fails in that class, it means something is wrong with the migration service + * as it wants to perform a migration on our up-to-date config.yml. + */ + @Test + public void shouldNotRewriteJarConfig() throws IOException { + // given + copyConfigToTestFolder(); + FileConfiguration configuration = YamlConfiguration.loadConfiguration(configTestFile); + PropertyMap propertyMap = SettingsFieldRetriever.getAllPropertyFields(); + assumeThat(testFolder.listFiles(), arrayWithSize(1)); + + // when + boolean result = SettingsMigrationService.checkAndMigrate(configuration, propertyMap, testFolder); + + // then + assertThat(result, equalTo(false)); + assertThat(testFolder.listFiles(), arrayWithSize(1)); + } + + private void copyConfigToTestFolder() throws IOException { + testFolder = testFolderHandler.newFolder("migrationtest"); + + final File testConfig = testFolderHandler.newFile("migrationtest/config.yml"); + final File realConfig = TestHelper.getJarFile("/config.yml"); + + Files.copy(realConfig, testConfig); + if (!testConfig.exists()) { + throw new IOException("Could not copy project's config.yml to test folder"); + } + configTestFile = testConfig; + } +} From 88ee5b5f92a66edf24d339ec07df465dca4a1526 Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Sat, 13 Feb 2016 13:12:19 +0100 Subject: [PATCH 41/41] Fix hide tablist --- .../fr/xephi/authme/listener/AuthMeTablistPacketAdapter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/fr/xephi/authme/listener/AuthMeTablistPacketAdapter.java b/src/main/java/fr/xephi/authme/listener/AuthMeTablistPacketAdapter.java index f4321b40..ea8effd0 100644 --- a/src/main/java/fr/xephi/authme/listener/AuthMeTablistPacketAdapter.java +++ b/src/main/java/fr/xephi/authme/listener/AuthMeTablistPacketAdapter.java @@ -18,7 +18,7 @@ public class AuthMeTablistPacketAdapter extends PacketAdapter { } @Override - public void onPacketReceiving(PacketEvent event) + public void onPacketSending(PacketEvent event) { if (event.getPacketType() == PacketType.Play.Server.PLAYER_INFO) { try