diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 51a5ca8989..dc5f0b6d6b 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -9,6 +9,6 @@ updates: - dependency-name: com.google.code.gson:gson - dependency-name: com.google.guava:guava - dependency-name: org.apache.logging.log4j:log4j-core - - dependency-name: com.zaxxer:HikariCP - - dependency-name: "org.mockito:mockito-core" # Mockito 5 requires Java 11 + - dependency-name: "org.mockito:mockito-core" versions: ">= 5" + - dependency-name: ch.jalu:configme diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 46d58c20bc..41809c989d 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -10,7 +10,7 @@ jobs: build_and_test: strategy: matrix: - jdkversion: [11] + jdkversion: [11, 17, 21] runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 diff --git a/.travis.yml b/.travis.yml index 7ca0e106e9..e380fd20ae 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,12 +4,8 @@ language: java matrix: include: - - env: - - JDK_VERSION=8 - env: - JDK_VERSION=11 - - env: - - JDK_VERSION=17 before_install: - "[[ -d $HOME/.sdkman/ ]] && [[ -d $HOME/.sdkman/bin/ ]] || rm -rf $HOME/.sdkman/" diff --git a/README.md b/README.md index 9f57cf406b..1a71653cb9 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,6 @@ | Type | Badges | |-------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| **General:** | ![](https://tokei.rs/b1/github/AuthMe/AuthMeReloaded?category=code) ![](https://tokei.rs/b1/github/AuthMe/AuthMeReloaded?category=files) | | **Code quality:** | [![Code Climate](https://codeclimate.com/github/AuthMe/AuthMeReloaded/badges/gpa.svg)](https://codeclimate.com/github/AuthMe/AuthMeReloaded) [![Coverage status](https://coveralls.io/repos/AuthMe-Team/AuthMeReloaded/badge.svg?branch=master&service=github)](https://coveralls.io/github/AuthMe-Team/AuthMeReloaded?branch=master) | | **Jenkins CI:** | [![Jenkins Status](https://img.shields.io/website-up-down-green-red/http/shields.io.svg?label=ci.codemc.org)](https://ci.codemc.org/) [![Build Status](https://ci.codemc.org/buildStatus/icon?job=AuthMe/AuthMeReloaded)](https://ci.codemc.org/job/AuthMe/job/AuthMeReloaded) ![Build Tests](https://img.shields.io/jenkins/t/https/ci.codemc.org/job/AuthMe/job/AuthMeReloaded.svg) | | **Other CIs:** | [![Build Status](https://www.travis-ci.com/AuthMe/AuthMeReloaded.svg?branch=master)](https://www.travis-ci.com/AuthMe/AuthMeReloaded) | @@ -104,7 +103,7 @@ You can also create your own translation file and, if you want, you can share it fr.xephi authme - 5.6.0-SNAPSHOT + 5.6.1-SNAPSHOT provided @@ -116,19 +115,17 @@ You can also create your own translation file and, if you want, you can share it ## Requirements ##### Compiling requirements: ->- JDK 11 (JDK 17 is recommended) ->- Maven ->- Git/Github (Optional) +>- JDK 11+ +>- Maven (3.8.8+) +>- Git/GitHub (Optional) ##### How to compile the project: >- Clone the project with Git/GitHub >- Execute command "mvn clean package" ##### Running requirements: ->- Java 8 (Java 17 is recommended) ->- Paper or Spigot (1.8.X and up)
- (In case you use Thermos, Cauldron or similar, you have to update the SpecialSource library to support Java 8 plugins. - HowTo: https://github.com/games647/FastLogin/issues/111#issuecomment-272331347) +>- Java 11+ +>- Paper or Spigot (1.16.5 and up) >- ProtocolLib (optional, required by some features) ## Credits diff --git a/pom.xml b/pom.xml index cddcb1aa5a..cc753864d4 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ fr.xephi authme - 5.6.0 + 5.6.1-SNAPSHOT AuthMeReloaded The first authentication plugin for the Bukkit API! @@ -60,14 +60,11 @@ UTF-8 UTF-8 - 1.8 - 1.8 - 8 + 11 + 11 + 11 11 - 3.6.3 - - - 1.19.2-R0.1-SNAPSHOT + 3.8.8 AuthMe @@ -80,6 +77,29 @@ ${project.versionCode} ${project.groupId}.${project.artifactId}.${pluginDescription.name} sgdc3, games647, Hex3l, krusic22 + + + 1.0 + 1.0.0 + 4.2.0 + 2.5 + 1.6.0 + 5.1.0 + 2.0.13 + 0.1.2 + 8.3.0 + 3.3.3 + 42.5.1 + 1.1.4 + 2.11 + 0.9.0 + 1.5.0 + 1.3.1 + + 1.16.5-R0.1-SNAPSHOT + 2.8.1 + + 3.0.2 @@ -127,8 +147,10 @@ clean package - + @@ -154,7 +176,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.4.1 + 3.6.3 @@ -164,7 +186,7 @@ org.apache.maven.plugins maven-enforcer-plugin - 3.2.1 + 3.4.1 enforce-environment @@ -177,7 +199,7 @@ ${maven.minimumVersion} - [11,) + [${java.compiler.minimumVersion},) true @@ -189,19 +211,19 @@ org.apache.maven.plugins maven-clean-plugin - 3.2.0 + 3.3.2 org.apache.maven.plugins maven-resources-plugin - 3.3.0 + 3.3.1 org.apache.maven.plugins maven-compiler-plugin - 3.10.1 + 3.13.0 ${java.source} ${java.target} @@ -212,7 +234,13 @@ org.jacoco jacoco-maven-plugin - 0.8.11 + 0.8.12 + + + fr/xephi/authme/* + fr/xephi/authme/**/* + + pre-unit-test @@ -232,11 +260,12 @@ org.apache.maven.plugins maven-surefire-plugin - 2.22.2 + 3.2.5 + - -Dfile.encoding=${project.build.sourceEncoding} -Duser.language=en @{argLine} + --add-opens=java.base/java.lang=ALL-UNNAMED -Dfile.encoding=${project.build.sourceEncoding} -Duser.language=en @{argLine} ${project.skipExtendedHashTests} @@ -248,7 +277,7 @@ org.apache.maven.plugins maven-jar-plugin - 3.3.0 + 3.4.1 @@ -257,7 +286,7 @@ ${project.finalNameBase} - 8 + ${java.source} @@ -272,7 +301,7 @@ org.apache.maven.plugins maven-source-plugin - 3.2.1 + 3.3.1 ${project.finalNameBase} @@ -289,61 +318,17 @@ org.apache.maven.plugins maven-shade-plugin - 3.4.1 + 3.5.3 + - com.google.guava:guava - com.google.guava:failureaccess - com.google.guava:listenablefuture - com.google.errorprone:error_prone_annotations - com.google.j2objc:j2objc-annotations - - com.google.code.gson:gson - - - - - - shaded-jar-legacy - package - - shade - - - ${project.finalNameBase}-legacy - - - com.google.common - fr.xephi.authme.libs.com.google.common - - - com.google.thirdparty - fr.xephi.authme.libs.com.google.thirdparty - - - com.google.j2objc - fr.xephi.authme.libs.com.google.j2objc - - - com.google.errorprone - fr.xephi.authme.libs.com.google.errorprone - - - com.google.gson - fr.xephi.authme.libs.com.google.gson - - - + --> @@ -353,89 +338,14 @@ ${project.finalNameBase} - - - - ch.jalu - fr.xephi.authme.libs.ch.jalu - - - com.zaxxer.hikari - fr.xephi.authme.libs.com.zaxxer.hikari - - - org.slf4j - fr.xephi.authme.libs.org.slf4j - - - com.maxmind.db - fr.xephi.authme.libs.com.maxmind.db - - - com.ice.tar - fr.xephi.authme.libs.com.icetar.tar - - - net.ricecode.similarity - fr.xephi.authme.libs.ricecode.net.ricecode.similarity - - - de.rtner - fr.xephi.authme.libs.de.rtner - - - org.picketbox - fr.xephi.authme.libs.org.picketbox - - - org.jboss.crypto - fr.xephi.authme.libs.org.jboss.crypto - - - org.jboss.security - fr.xephi.authme.libs.org.jboss.security - - - de.mkammerer - fr.xephi.authme.libs.de.mkammerer - - - com.warrenstrange - fr.xephi.authme.libs.com.warrenstrange - - - javax.inject - fr.xephi.authme.libs.javax.inject - - - at.favre.lib - fr.xephi.authme.libs.at.favre.lib - - - org.postgresql - fr.xephi.authme.libs.org.postgresql - - - - org.bstats - fr.xephi.authme.libs.org.bstats - - - org.mariadb.jdbc - fr.xephi.authme.libs.org.mariadb.jdbc - + @@ -467,13 +377,13 @@ org.apache.maven.plugins maven-install-plugin - 3.1.0 + 3.1.1 org.apache.maven.plugins maven-deploy-plugin - 3.0.0 + 3.1.1 @@ -602,54 +512,39 @@ ch.jalu injector - 1.0 - true + ${dependencies.injector.version} + provided net.ricecode string-similarity - 1.0.0 - true + ${dependencies.string-similarity.version} + provided - - + - com.maxmind.db - maxmind-db-gson - 2.0.3 - true - - - com.google.code.gson - gson - - + com.maxmind.geoip2 + geoip2 + ${dependencies.geoip2.version} + provided javatar javatar - 2.5 - true + ${dependencies.javatar.version} + provided org.apache.commons commons-email - 1.6-SNAPSHOT - true - - - - - org.apache.logging.log4j - log4j-core - 2.8.1 + ${dependencies.commons-email.version} provided @@ -657,88 +552,62 @@ com.zaxxer HikariCP - 4.0.3 - true + ${dependencies.hikaricp.version} + provided - slf4j-api org.slf4j + slf4j-api - org.slf4j slf4j-simple - 1.7.36 - true + ${dependencies.slf4j.version} + provided - + - de.rtner - PBKDF2 - 1.1.4 - true + ch.jalu + datasourcecolumns + ${dependencies.datasourcecolumns.version} + provided - + com.mysql mysql-connector-j - 8.2.0 - true + ${dependencies.mysql-connector-j.version} + provided + + org.mariadb.jdbc mariadb-java-client - 3.3.0 - true - - - - - de.mkammerer - argon2-jvm-nolibs - 2.11 - true - - - - - com.warrenstrange - googleauth - 1.5.0 - true - - - - - org.spigotmc - spigot-api - ${spigot.version} + ${dependencies.mariadb-java-client.version} provided - junit - junit - - - bungeecord-chat - net.md-5 + org.checkerframework + checker-qual - com.googlecode.json-simple - json-simple + com.google.errorprone + error_prone_annotations - + + - com.google.guava - guava - 31.0.1-jre - true + org.postgresql + postgresql + ${dependencies.postgresql.version} + provided org.checkerframework @@ -746,22 +615,45 @@ - + + - com.google.code.gson - gson - 2.8.9 - true + de.rtner + PBKDF2 + ${dependencies.pbkdf2.version} + provided - + + + de.mkammerer + argon2-jvm-nolibs + ${dependencies.argon2-jvm-nolibs.version} + provided + + + + + at.favre.lib + bcrypt + ${dependencies.bcrypt.version} + provided + + + + + com.warrenstrange + googleauth + ${dependencies.googleauth.version} + provided + ch.jalu configme - 1.3.0 - true + ${dependencies.configme.version} + provided org.yaml @@ -770,19 +662,47 @@ + + + org.spigotmc + spigot-api + ${dependencies.spigot.version} + provided + + + org.joml + joml + + + net.md-5 + bungeecord-chat + + + + + org.apache.logging.log4j + log4j-core + ${dependencies.log4j-core.version} + provided + + + + org.bstats bstats-bukkit - 3.0.0 - true + ${dependencies.bstats.version} + provided + + com.comphenix.protocol ProtocolLib - 4.8.0 + 5.1.0 provided @@ -971,14 +891,6 @@ - - - at.favre.lib - bcrypt - 0.10.2 - true - - de.luricos.bukkit @@ -987,60 +899,42 @@ provided - - ch.jalu - datasourcecolumns - 0.1.1-SNAPSHOT - true - - - - org.postgresql - postgresql - 42.7.2 - true - - - org.checkerframework - checker-qual - - - - + junit junit test 4.13.2 + + + org.hamcrest + hamcrest-core + + org.hamcrest - java-hamcrest + hamcrest test - 2.0.0.0 + 2.2 + org.mockito mockito-core test - 4.8.1 - - - hamcrest-core - org.hamcrest - - + 4.11.0 org.checkerframework checker-qual - 3.40.0 + 3.42.0 test @@ -1048,13 +942,19 @@ org.xerial sqlite-jdbc - 3.44.0.0 + 3.45.3.0 test + + + org.slf4j + slf4j-api + + com.h2database h2 - 2.2.220 + 2.2.224 test diff --git a/samples/NewConfig.yml b/samples/NewConfig.yml deleted file mode 100644 index c0b392c4b5..0000000000 --- a/samples/NewConfig.yml +++ /dev/null @@ -1,570 +0,0 @@ -# ======================================================================================================= -# _____ __ .__ _____ __________ .__ .___ .___ -# / _ \ __ ___/ |_| |__ / \ ____\______ \ ____ | | _________ __| _/____ __| _/ -# / /_\ \| | \ __| | \ / \ / \_/ __ \| __/ __ \| | / _ \__ \ / __ _/ __ \ / __ | -# / | | | /| | | Y / Y \ ___/| | \ ___/| |_( <_> / __ \/ /_/ \ ___// /_/ | -# \____|__ |____/ |__| |___| \____|__ /\___ |____|_ /\___ |____/\____(____ \____ |\___ \____ | -# \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ -# -# ======================================================================================================= -# -# Authme Main Configuration File. -# -# ======================================================================================================= - -# Plugin infos (overwritten on start, just a simple way to find out your plugin version). -authors: ${pluginAuthors} -version: ${project.version} -buildNumber: ${buildNumber} - -# Set this setting to true when you have configured the plugin, -# when false the server will be stopped with a warning message. -enabled: false - -# Database settings. -data_source: - # =========================== - # Database general settings. - # =========================== - - # Database backend (sqlite, mysql). - backend: sqlite - # Enable database queries caching, should improve performance. - caching: true - - # =========================== - # SqLite db parameters. - # =========================== - - sqlite: - # The name of the database storage file. - filename: 'authme.db' - - # =========================== - # MySql db parameters. - # =========================== - - mysql: - # Connection parameters. - host: '127.0.0.1' - port: 3306 - username: 'change_me' - password: 'change_me' - database: 'my_minecraft_server' - tablename: 'authme' - - # Column names. - column_names: - id: id - # Column for storing nicknames (ignore case nickname). - name: username - # Column for storing the realname (case sensitive nickname). - real_name: realname - # Column for storing passwords. - password: password - # Column for storing email addresses. - email: email - # Column for storing the authentication status (logged or not). - login_status: isLogged - # Column for storing player IPs. - ip: ip - # Column for storing lastlogins date and time. - last_login_timestamp: lastlogin - # Latest logout location of the players. - last_location: - world: world - x: x - y: y - z: z - # Enabled only if the bungeecord integration is activated. - server: world - - # Support for registrations via WebInterfaces/CSM. - # Disable some backend caching parameters. - disableAggressiveCaching: false - -# Main settings -settings: - - # =========================== - # Bungeecord integration - # =========================== - - bungeecord: - # Enable bungeecord integration features - enabled: true - - # Server name (must be unique, please use the name in the bungeecord configuration). - # Use 'auto' for auto configuration (requires the bungeecord module). - serverName: LoginLobby1 - # Keep the auth status when the player moves between servers. - # Required if you're using the bungeecord module. - keepAuthBetweenServers: true - - # Target server after login - send_after_login: - enabled: false - message: '' - delay: 5 - # Server name ("ServerName") or group ("G:GroupName") - # Groups are avariable only when the bungeecord module is avariable. - # If the server change fails the player will be kicked. - target: Lobby1 - failKickMessage: 'Failed to connect to the lobby! Please try to join the server again!' - # Target server after logout - send_after_logout: - enabled: false - message: '' - delay: 5 - # Server name ("ServerName") or group ("G:GroupName") - # Groups are avariable only when the bungeecord module is avariable. - # If the server change fails the player will be kicked. - target: LoginLobby1 - failKickMessage: 'Failed to connect to the lobby! Please try to join the server again!' - - # Variables: - # %p playername - bungee_commands: - player_command_after_register: - enabled: false - cmd: '' - console_command_after_register: - enabled: false - cmd: 'alert %p joined for the first time the network!' - player_command_after_login: - enabled: false - cmd: 'glist' - console_command_after_login: - enabled: false - cmd: 'alert %p logged in correctly!' - player_command_after_join: - enabled: false - cmd: '' - console_command_after_join: - enabled: false - cmd: 'alert %p joined the network!' - player_command_first_join: - enabled: false - cmd: '' - console_command_first_join: - enabled: false - cmd: 'alert %p joined for the first time the network!' - - # =========================== - # Sessions configuration. - # =========================== - - sessions: - # Enable sessions. - # When a player is authenticated, his IP and his nickname is saved. - # The next time the player will join the server, if his IP is the same - # of the last time, and the timeout time hasn't expired, he will be - # automatically authenticated. - enabled: false - # Session timeout. - # 0 for unlimited time (Very dangerous, use it at your own risk!) - # Consider that if player's ip has changed but the timeout hasn't - # expired, player will be kicked out of the sever! - timeout: 10 - # When enabled a player's session will expire if someone tries to - # login with a different IP Address. - expire_on_ip_change: true - - # =========================== - # Registration settings. - # =========================== - - registration: - # After how many time unregistered players should be kicked? - # Set to 0 to disable. (default: 30) - timeout: 30 - - nickname: - min_length: 4 - max_lenght: 16 - # Regex syntax. - allowed_characters: '[a-zA-Z0-9_]*' - - password: - # Enable double check of password on registration: - # /register - double_check: true - # Minimum password lenght. - min_length: 5 - # Regex syntax. - allowed_characters: '[\x21-\x7E]*' - # Denied unsafe passwords. - unsafePasswords: - - '123456' - - 'password' - - 'qwerty' - - '12345' - - '54321' - - # =========================== - # Login settings. - # =========================== - - login: - # After how many time unlogged players should be kicked? - # Set to 0 to disable. (default: 30) - timeout: 30 - - - - # =========================== - # Encryption parameters. - # =========================== - - password_encryption: - # The hashing algorithm. - # Possible values: MD5, SHA1, SHA256, WHIRLPOOL, XAUTH, MD5VB, PHPBB, MYBB, IPB3, - # PHPFUSION, SMF, XENFORO, SALTED2MD5, JOOMLA, BCRYPT, WBB3, SHA512, DOUBLEMD5, - # PBKDF2, PBKDF2DJANGO, WORDPRESS, ROYALAUTH, CUSTOM (developpers only). - encryption_algorithm: SHA256 - # The salt length for the SALTED2MD5 and MD5(MD5(password)+salt) algorithms. - md5_salt_length: 8 - # If password check fails try all the other hash algorithm. - # AuthMe will update the password to the new passwordHash. - enable_convertion: false - - # =========================== - # Unlogged user restrictions. - # =========================== - - unlogged_restrictions: - # Deny chat messages send for unlogged users. - deny_chat: true - # Hide chat to unlogged users. - # Only player messages, plugins will be able to send messages to the player anyway. - hide_chat: false - - # Deny any command message not in the whitelist below. - deny_commands: true - command_whitelist: - - /login - - /register - - /l - - /reg - - /email - - /captcha - - movements: - # Restrict player movements. - restrict: true - # Allowed radius. - allowed_radius: 0 - # Should unlogged players have speed = 0? - # After the login the walking/flying speeed will be reset to the default value. - removeSpeed: true - - # End is there atm xD - - # This option will save the quit location of the players. - SaveQuitLocation: false - # Should not logged in players be teleported to the spawn? - # After the authentication, if SaveQuitLocation is enabled, - # they will be teleported back to their normal position. - teleportUnAuthedToSpawn: false - - # If enabled, after the login, if the ForceSpawnOnTheseWorlds setting contains - # the player's world, he will be teleported to the world spawnpoint. - # The quit location of the player will be overwritten. - # This is different from "teleportUnAuthedToSpawn" that teleports player - # back to his quit location after the authentication. - ForceSpawnLocOnJoinEnabled: false - # WorldNames where we need to force the spawn location - # Warning: This setting is Case Sensitive! - ForceSpawnOnTheseWorlds: - - world - - world_nether - - world_the_end - - # this is very important options, - # every time player join the server, - # if they are registered, AuthMe will switch him - # to unLoggedInGroup, this - # should prevent all major exploit. - # So you can set up on your Permission Plugin - # this special group with 0 permissions, or permissions to chat, - # or permission to - # send private message or all other perms that you want, - # the better way is to set up - # this group with few permissions, - # so if player try to exploit some account, - # they can - # do anything except what you set in perm Group. - # After a correct logged-in player will be - # moved to his correct permissions group! - # Pay attention group name is case sensitive, - # so Admin is different from admin, - # otherwise your group will be wiped, - # and player join in default group []! - # Example unLoggedinGroup: NotLogged - unLoggedinGroup: unLoggedinGroup - - # =========================== - # Address restrictions - # =========================== - - # Max number of registrations per IP (default: 1) - maxRegPerIp: 1 - # Maximum allowed number of Logins per IP, 0 to disable (default: 0) - maxLoginPerIp: 0 - # Maximum allowed number of Joins per IP, 0 to disable (default: 0) - maxJoinPerIp: 0 - - # When this setting is enabled, online players can't be kicked out - # due to "Logged in from another Location" - # This setting will prevent potential security exploits. - ForceSingleSession: true - - # To activate the restricted user feature you need - # to enable this option and configure the - # AllowedRestrictedUser field. - AllowRestrictedUser: false - # The restricted user feature will kick players listed below - # if they dont match of the defined ip address. - # Example: - # AllowedRestrictedUser: - # - playername;127.0.0.1 - AllowedRestrictedUser: - - playername;127.0.0. - # Ban ip when the ip is not the ip registered in database - banUnsafedIP: false - - - - # =============================== - # Other restrictions - # =============================== - - # Should we protect the player inventory before logging in? - # Warning: Requires the latest version of ProtocolLib! - ProtectInventoryBeforeLogIn: true - - # Should unregistered players be kicked immediately? - kickNonRegistered: false - # Should players be kicked on wrong password? - kickOnWrongPassword: false - - # Should we display all other accounts of a player when he joins? - # Required permission: authme.admin.accounts - displayOtherAccounts: true - - # =============================== - # Restrictions compatibility - # =============================== - - # Spawn Priority. Avariable values : authme, essentials, multiverse, default - spawnPriority: authme,essentials,multiverse,default - # AuthMe will NEVER teleport players! - noTeleport: false - - GameMode: - # Do you want to set player's gamemode to survival when he joins? - # This enables also the settings below. - ForceSurvivalMode: false - # Do you want to reset player's inventory if player joins with creative mode? - ResetInventoryIfCreative: false - # Do you want to force the survival mode ONLY after the /login process? - ForceOnlyAfterLogin: false - - # sgdc3: Ok, our configuration is shit.... xD Today I will stop there - - - registration: - # enable registration on the server? - enabled: true - # Send every X seconds a message to a player to - # remind him that he has to login/register - messageInterval: 5 - # Only registered and logged in players can play. - # See restrictions for exceptions - force: true - # Does we replace password registration by an Email registration method ? - enableEmailRegistrationSystem: false - # Enable double check of email when you register - # when it's true, registration require that kind of command: - # /register - doubleEmailCheck: false - # Do we force kicking player after a successful registration ? - # Do not use with login feature below - forceKickAfterRegister: false - # Does AuthMe need to enforce a /login after a successful registration ? - forceLoginAfterRegister: false - unrestrictions: - # below you can list all your account name, that - # AuthMe will ignore for registration or login, configure it - # at your own risk!! Remember that if you are going to add - # nickname with [], you have to delimit name with ' '. - # this option add compatibility with BuildCraft and some - # other mods. - # It is CaseSensitive! - UnrestrictedName: [] - # Message language, available : en, de, br, cz, pl, fr, ru, hu, sk, es, zhtw, fi, zhcn, lt, it, ko, pt - messagesLanguage: en - # Force these commands after /login, without any '/', use %p for replace with player name - forceCommands: [] - # Force these commands after /login as a server console, without any '/', use %p for replace with player name - forceCommandsAsConsole: [] - # Force these commands after /register, without any '/', use %p for replace with player name - forceRegisterCommands: [] - # Force these commands after /register as a server console, without any '/', use %p for replace with player name - forceRegisterCommandsAsConsole: [] - # Do we need to display the welcome message (welcome.txt) after a register or a login? - # You can use colors in this welcome.txt + some replaced strings : - # {PLAYER} : player name, {ONLINE} : display number of online players, {MAXPLAYERS} : display server slots, - # {IP} : player ip, {LOGINS} : number of players logged, {WORLD} : player current world, {SERVER} : server name - # {VERSION} : get current bukkit version, {COUNTRY} : player country - 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 ? - delayJoinMessage: false - removeJoinMessage: false - removeLeaveMessage: false - # Do we need to add potion effect Blinding before login/register ? - applyBlindEffect: false -ExternalBoardOptions: - # MySQL column for the salt , needed for some forum/cms support - mySQLColumnSalt: '' - # MySQL column for the group, needed for some forum/cms support - mySQLColumnGroup: '' - # -1 mean disabled. If u want that only - # activated player can login in your server - # u can put in this options the group number - # of unactivated user, needed for some forum/cms support - nonActivedUserGroup: -1 - # Other MySQL columns where we need to put the Username (case sensitive) - mySQLOtherUsernameColumns: [] - # How much Log to Round needed in BCrypt(do not change it if you do not know what's your doing) - bCryptLog2Round: 10 - # phpBB prefix defined during phpbb installation process - phpbbTablePrefix: 'phpbb_' - # phpBB activated group id , 2 is default registered group defined by phpbb - phpbbActivatedGroupId: 2 - # WordPress prefix defined during WordPress installation process - wordpressTablePrefix: 'wp_' -permission: - # Take care with this options, if you dont want - # to use Vault and Group Switching of - # AuthMe for unloggedIn players put true - # below, default is false. - EnablePermissionCheck: false -BackupSystem: - # Enable or Disable Automatic Backup - ActivateBackup: false - # set Backup at every start of Server - OnServerStart: false - # set Backup at every stop of Server - OnServerStop: true - # Windows only mysql installation Path - MysqlWindowsPath: 'C:\\Program Files\\MySQL\\MySQL Server 5.1\\' -Security: - SQLProblem: - # Stop the server if we can't contact the sql database - # Take care with this, if you set that to false, - # AuthMe automatically disable and the server is not protected! - stopServer: true - ReloadCommand: - # /reload support - useReloadCommandSupport: true - console: - # Remove spam console - noConsoleSpam: false - captcha: - # Player need to put a captcha when he fails too lot the password - useCaptcha: false - # Max allowed tries before request a captcha - maxLoginTry: 5 - # Captcha length - captchaLength: 5 -Converter: - Rakamak: - # Rakamak file name - fileName: users.rak - # Rakamak use ip ? - useIP: false - # IP file name for rakamak - ipFileName: UsersIp.rak - CrazyLogin: - # CrazyLogin database file - fileName: accounts.db -Email: - # Email SMTP server host - mailSMTP: smtp.gmail.com - # Email SMTP server port - mailPort: 465 - # Email account that send the mail - mailAccount: '' - # Email account password - mailPassword: '' - # Custom SenderName, that replace the mailAccount name in the email - mailSenderName: '' - # Random password length - RecoveryPasswordLength: 8 - # Email subject of password get - mailSubject: 'Your new AuthMe Password' - # Email text here - mailText: 'Dear ,

This is your new AuthMe password for the server

:



Do not forget to change password after login!
/changepassword newPassword' - # Like maxRegPerIp but with email - maxRegPerEmail: 1 - # Recall players to add an email ? - recallPlayers: false - # Delay in minute for the recall scheduler - delayRecall: 5 - # Blacklist these domains for emails - emailBlacklisted: - - 10minutemail.com - # WhiteList only these domains for emails - emailWhitelisted: [] - # Do we need to send new password draw in an image ? - generateImage: false -Hooks: - # Do we need to hook with multiverse for spawn checking? - multiverse: true - # Do we need to hook with BungeeCord for get the real Player ip ? - bungeecord: false - # Do we need to disable Essentials SocialSpy on join ? - disableSocialSpy: true - # Do we need to force /motd Essentials command on join ? - useEssentialsMotd: false - # Do we need to cache custom Attributes ? - customAttributes: false -Purge: - # On Enable , does AuthMe need to purge automatically old accounts unused ? - useAutoPurge: false - # Number of Days an account become Unused - daysBeforeRemovePlayer: 60 - # Do we need to remove the player.dat file during purge process ? - removePlayerDat: false - # Do we need to remove the Essentials/users/player.yml file during purge process ? - removeEssentialsFile: false - # World where are players.dat stores - defaultWorld: 'world' - # Do we need to remove LimitedCreative/inventories/player.yml , player_creative.yml files during purge process ? - removeLimitedCreativesInventories: false - # Do we need to remove the AntiXRayData/PlayerData/player file during purge process ? - removeAntiXRayFile: false - # Do we need to remove permissions ? - removePermissions: false -Protection: - # Enable some servers protection ( country based login, antibot ) - enableProtection: false - # Countries allowed to join the server and register, see http://dev.bukkit.org/bukkit-plugins/authme-reloaded/pages/countries-codes/ for countries' codes - countries: - - US - - GB - # Countries blacklisted automatically ( without any needed to enable protection ) - countriesBlacklist: - - A1 - # Do we need to enable automatic antibot system? - enableAntiBot: false - # Max number of player allowed to login in 5 secs before enable AntiBot system automatically - antiBotSensibility: 5 - # Duration in minutes of the antibot automatic system - antiBotDuration: 10 -VeryGames: - # These features are only available on VeryGames Server Provider - enableIpCheck: false diff --git a/samples/NewPlugin.yml b/samples/NewPlugin.yml deleted file mode 100644 index f403da60bd..0000000000 --- a/samples/NewPlugin.yml +++ /dev/null @@ -1,199 +0,0 @@ -name: ${pluginName} -authors: [${pluginAuthors}] -website: ${project.url} -description: ${project.description} -main: ${mainClass} -version: ${project.version}-b${buildNumber} -softdepend: - - Vault - - PermissionsBukkit - - PermissionsEX - - EssentialsGroupManager - - Multiverse-Core - - Essentials - - EssentialsSpawn - - ProtocolLib -commands: - authme: - description: AuthMe admin commands - usage: '/authme reload|register playername password|changepassword playername password|unregister playername|version|converter datatype' - permission: authme.admin - register: - description: Register an account - usage: /register password confirmpassword - aliases: [reg] - permission: authme.player.register - login: - description: Login into a account - usage: /login password - aliases: [l,log] - permission: authme.player.login - changepassword: - description: Change password of a account - usage: /changepassword oldPassword newPassword - permission: authme.player.changepassword - logout: - description: Logout from the server - usage: /logout - permission: authme.player.logout - unregister: - description: unregister your account - usage: /unregister password - permission: authme.player.unregister - email: - description: Add Email or recover password - usage: '/email add your@email.com your@email.com|change oldEmail newEmail|recovery your@email.com' - permission: authme.player.email - captcha: - description: Captcha command - usage: /captcha theCaptcha - permission: authme.player.captcha -permissions: - authme.canbeforced: - description: Allow the user to be forced-logged via API - default: true - authme.player: - description: Gives access to all authme player commands - default: true - children: - authme.player.login: true - authme.player.logout: true - authme.player.register: true - authme.player.unregister: true - authme.player.changepassword: true - authme.player.captcha: true - authme.player.email: true - authme.player.register: - description: Register your account - default: false - authme.player.unregister: - description: Unregister your account - default: false - authme.player.login: - description: Login into your account - default: false - authme.player.logout: - description: Logout from your account - default: false - authme.player.changepassword: - description: Change password of your account - default: false - authme.player.email: - description: Gives access to player's email commands - default: false - children: - authme.player.email.add: true - authme.player.email.change: true - authme.player.email.recover: true - authme.player.email.add: - description: Add an email to your account - default: false - authme.player.email.change: - description: Change email of your account - default: false - authme.player.email.recover: - description: Recover your account - default: false - authme.player.captcha: - description: Captcha command - default: false - authme.admin: - description: Gives access to all authme admin commands - default: op - children: - authme.admin.forcelogin: true - authme.admin.forcelogout: true - authme.admin.register: true - authme.admin.unregister: true - authme.admin.changemail: true - authme.admin.changepassword: true - authme.admin.lastlogin: true - authme.admin.accounts: true - authme.admin.getemail: true - authme.admin.getip: true - authme.admin.setspawn: true - authme.admin.spawn: true - authme.admin.setfirstspawn: true - authme.admin.firstspawn: true - authme.admin.purge: true - authme.admin.purgebannedplayers: true - authme.admin.purgelastpos: true - authme.admin.converter: true - authme.admin.reload: true - authme.admin.switchantibot: true - authme.admin.seeotheraccounts: true - authme.admin.register: - description: Register an account - default: false - authme.admin.unregister: - description: Unregister an account - default: false - authme.admin.forcelogin: - description: Force login for that player - default: false - authme.admin.forcelogout: - description: Force logout for that player - default: false - authme.admin.changepassword: - description: Change the password of an account - default: false - authme.admin.getemail: - description: Get last email about a player - default: false - authme.admin.changeemail: - description: Change a player email - default: false - authme.admin.accounts: - description: Display Players Accounts - default: false - authme.admin.seeotheraccounts: - description: Display other accounts about a player when he logs in - default: false - authme.admin.lastlogin: - description: Get last login date about a player - default: false - authme.admin.getip: - description: Get IP from a player (fake and real) - default: false - authme.admin.setspawn: - description: Set the AuthMe spawn point - default: false - authme.admin.spawn: - description: Teleport to AuthMe spawn point - default: false - authme.admin.setfirstspawn: - description: Set the AuthMe First Spawn Point - default: false - authme.admin.firstspawn: - description: Teleport to AuthMe First Spawn Point - default: false - authme.admin.switchantibot: - description: Switch AntiBot mode on/off - default: false - authme.admin.purge: - description: Database purge command - default: false - authme.admin.purgebannedplayers: - description: Purge banned players - default: false - authme.admin.purgelastpos: - description: Purge last position of a player/players - default: false - authme.admin.converter: - description: Allow the /authme converter command - default: false - authme.admin.reload: - description: Reload the plugin - default: false - authme.vip: - description: Allow vip slot when the server is full - default: false - authme.bypassantibot: - description: Bypass the AntiBot check - default: false - authme.allowmultipleaccounts: - description: Allow more accounts for same ip - default: false - authme.bypassforcesurvival: - description: Bypass all ForceSurvival features - default: false diff --git a/src/main/java/fr/xephi/authme/initialization/OnStartupTasks.java b/src/main/java/fr/xephi/authme/initialization/OnStartupTasks.java index 029c9b608d..c750b6d11b 100644 --- a/src/main/java/fr/xephi/authme/initialization/OnStartupTasks.java +++ b/src/main/java/fr/xephi/authme/initialization/OnStartupTasks.java @@ -32,7 +32,7 @@ */ public class OnStartupTasks { - private static ConsoleLogger consoleLogger = ConsoleLoggerFactory.get(OnStartupTasks.class); + private static final ConsoleLogger consoleLogger = ConsoleLoggerFactory.get(OnStartupTasks.class); @Inject private DataSource dataSource; @@ -53,6 +53,8 @@ public class OnStartupTasks { * @param settings the settings */ public static void sendMetrics(AuthMe plugin, Settings settings) { + // We do not relocate as the library is downloaded at runtime + System.setProperty("bstats.relocatecheck", "false"); final Metrics metrics = new Metrics(plugin, 164); metrics.addCustomChart(new SimplePie("messages_language", @@ -109,6 +111,6 @@ public void run() { } }); } - }, 1, TICKS_PER_MINUTE * settings.getProperty(EmailSettings.DELAY_RECALL)); + }, 1, (long) TICKS_PER_MINUTE * settings.getProperty(EmailSettings.DELAY_RECALL)); } } diff --git a/src/main/java/fr/xephi/authme/listener/protocollib/InventoryPacketAdapter.java b/src/main/java/fr/xephi/authme/listener/protocollib/InventoryPacketAdapter.java index bceeaca7a6..fb8234092d 100644 --- a/src/main/java/fr/xephi/authme/listener/protocollib/InventoryPacketAdapter.java +++ b/src/main/java/fr/xephi/authme/listener/protocollib/InventoryPacketAdapter.java @@ -34,14 +34,13 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import java.lang.reflect.InvocationTargetException; import java.util.Arrays; import java.util.List; class InventoryPacketAdapter extends PacketAdapter { private static final int PLAYER_INVENTORY = 0; - // http://wiki.vg/Inventory#Inventory (0-4 crafting, 5-8 armor, 9-35 main inventory, 36-44 hotbar, 45 off hand) + // http://wiki.vg/Inventory#Inventory (0-4 crafting, 5-8 armor, 9-35 main inventory, 36-44 hotbar, 45 off-hand) // +1 because an index starts with 0 private static final int CRAFTING_SIZE = 5; private static final int ARMOR_SIZE = 4; @@ -116,8 +115,8 @@ public void sendBlankInventoryPacket(Player player) { try { protocolManager.sendServerPacket(player, inventoryPacket, false); - } catch (InvocationTargetException invocationExc) { - logger.logException("Error during sending blank inventory", invocationExc); + } catch (Exception exception) { + logger.logException("Error during sending blank inventory", exception); } } } 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 d5cf1cef53..d60ce4e831 100644 --- a/src/main/java/fr/xephi/authme/process/join/AsynchronousJoin.java +++ b/src/main/java/fr/xephi/authme/process/join/AsynchronousJoin.java @@ -5,8 +5,8 @@ import fr.xephi.authme.data.limbo.LimboService; import fr.xephi.authme.datasource.DataSource; import fr.xephi.authme.events.ProtectInventoryEvent; -import fr.xephi.authme.output.ConsoleLoggerFactory; import fr.xephi.authme.message.MessageKey; +import fr.xephi.authme.output.ConsoleLoggerFactory; import fr.xephi.authme.permission.PlayerStatePermission; import fr.xephi.authme.process.AsynchronousProcess; import fr.xephi.authme.process.login.AsynchronousLogin; @@ -27,11 +27,8 @@ import org.bukkit.GameMode; import org.bukkit.Server; import org.bukkit.entity.Player; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; import javax.inject.Inject; - import java.util.Locale; import static fr.xephi.authme.service.BukkitService.TICKS_PER_SECOND; @@ -197,7 +194,7 @@ private void processJoinSync(Player player, boolean isAuthAvailable) { if (service.getProperty(RegistrationSettings.APPLY_BLIND_EFFECT)) { // Allow infinite blindness effect int blindTimeOut = (registrationTimeout <= 0) ? 99999 : registrationTimeout; - player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, blindTimeOut, 2)); + player.addPotionEffect(bukkitService.createBlindnessEffect(blindTimeOut)); } commandManager.runCommandsOnJoin(player); }); diff --git a/src/main/java/fr/xephi/authme/process/logout/ProcessSyncPlayerLogout.java b/src/main/java/fr/xephi/authme/process/logout/ProcessSyncPlayerLogout.java index 46fd7fefc0..96865e21c3 100644 --- a/src/main/java/fr/xephi/authme/process/logout/ProcessSyncPlayerLogout.java +++ b/src/main/java/fr/xephi/authme/process/logout/ProcessSyncPlayerLogout.java @@ -3,9 +3,9 @@ import fr.xephi.authme.ConsoleLogger; import fr.xephi.authme.data.limbo.LimboService; import fr.xephi.authme.events.LogoutEvent; -import fr.xephi.authme.output.ConsoleLoggerFactory; import fr.xephi.authme.listener.protocollib.ProtocolLibService; import fr.xephi.authme.message.MessageKey; +import fr.xephi.authme.output.ConsoleLoggerFactory; import fr.xephi.authme.process.SynchronousProcess; import fr.xephi.authme.service.BukkitService; import fr.xephi.authme.service.CommonService; @@ -14,8 +14,6 @@ import fr.xephi.authme.settings.properties.RegistrationSettings; import fr.xephi.authme.settings.properties.RestrictionSettings; import org.bukkit.entity.Player; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; import javax.inject.Inject; @@ -75,7 +73,7 @@ private void applyLogoutEffect(Player player) { // Apply Blindness effect if (service.getProperty(RegistrationSettings.APPLY_BLIND_EFFECT)) { int timeout = service.getProperty(RestrictionSettings.TIMEOUT) * TICKS_PER_SECOND; - player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, timeout, 2)); + player.addPotionEffect(bukkitService.createBlindnessEffect(timeout)); } // Set player's data to unauthenticated diff --git a/src/main/java/fr/xephi/authme/process/unregister/AsynchronousUnregister.java b/src/main/java/fr/xephi/authme/process/unregister/AsynchronousUnregister.java index 7beea4be68..5d37c8ad6c 100644 --- a/src/main/java/fr/xephi/authme/process/unregister/AsynchronousUnregister.java +++ b/src/main/java/fr/xephi/authme/process/unregister/AsynchronousUnregister.java @@ -7,22 +7,20 @@ import fr.xephi.authme.datasource.DataSource; import fr.xephi.authme.events.UnregisterByAdminEvent; import fr.xephi.authme.events.UnregisterByPlayerEvent; -import fr.xephi.authme.output.ConsoleLoggerFactory; import fr.xephi.authme.message.MessageKey; +import fr.xephi.authme.output.ConsoleLoggerFactory; import fr.xephi.authme.process.AsynchronousProcess; import fr.xephi.authme.security.PasswordSecurity; import fr.xephi.authme.service.BukkitService; import fr.xephi.authme.service.CommonService; import fr.xephi.authme.service.TeleportationService; +import fr.xephi.authme.service.bungeecord.BungeeSender; import fr.xephi.authme.service.bungeecord.MessageType; import fr.xephi.authme.settings.commandconfig.CommandManager; import fr.xephi.authme.settings.properties.RegistrationSettings; import fr.xephi.authme.settings.properties.RestrictionSettings; -import fr.xephi.authme.service.bungeecord.BungeeSender; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; import javax.inject.Inject; @@ -144,7 +142,7 @@ private void performPostUnregisterActions(String name, Player player) { private void applyBlindEffect(Player player) { if (service.getProperty(RegistrationSettings.APPLY_BLIND_EFFECT)) { int timeout = service.getProperty(RestrictionSettings.TIMEOUT) * TICKS_PER_SECOND; - player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, timeout, 2)); + player.addPotionEffect(bukkitService.createBlindnessEffect(timeout)); } } diff --git a/src/main/java/fr/xephi/authme/service/BukkitService.java b/src/main/java/fr/xephi/authme/service/BukkitService.java index a09b18508a..8864a902ef 100644 --- a/src/main/java/fr/xephi/authme/service/BukkitService.java +++ b/src/main/java/fr/xephi/authme/service/BukkitService.java @@ -13,6 +13,8 @@ import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Player; import org.bukkit.event.Event; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitTask; @@ -338,6 +340,16 @@ public Optional isBungeeCordConfiguredForSpigot() { } } + /** + * Creates a PotionEffect with blindness for the given duration in ticks. + * + * @param timeoutInTicks duration of the effect in ticks + * @return blindness potion effect + */ + public PotionEffect createBlindnessEffect(int timeoutInTicks) { + return new PotionEffect(PotionEffectType.BLINDNESS, timeoutInTicks, 2); + } + /** * @return the IP string that this server is bound to, otherwise empty string */ diff --git a/src/main/java/fr/xephi/authme/service/GeoIpService.java b/src/main/java/fr/xephi/authme/service/GeoIpService.java index ef0d00b6e6..ce16adce62 100644 --- a/src/main/java/fr/xephi/authme/service/GeoIpService.java +++ b/src/main/java/fr/xephi/authme/service/GeoIpService.java @@ -4,12 +4,12 @@ import com.google.common.hash.HashCode; import com.google.common.hash.HashFunction; import com.google.common.hash.Hashing; -import com.maxmind.db.GeoIp2Provider; -import com.maxmind.db.Reader; +import com.maxmind.db.CHMCache; import com.maxmind.db.Reader.FileMode; -import com.maxmind.db.cache.CHMCache; -import com.maxmind.db.model.Country; -import com.maxmind.db.model.CountryResponse; +import com.maxmind.geoip2.DatabaseReader; +import com.maxmind.geoip2.exception.GeoIp2Exception; +import com.maxmind.geoip2.model.AbstractCountryResponse; +import com.maxmind.geoip2.record.Country; import fr.xephi.authme.ConsoleLogger; import fr.xephi.authme.initialization.DataFolder; import fr.xephi.authme.output.ConsoleLoggerFactory; @@ -61,21 +61,21 @@ public class GeoIpService { private final BukkitService bukkitService; private final Settings settings; - private GeoIp2Provider databaseReader; + private DatabaseReader databaseReader; private volatile boolean downloading; @Inject - GeoIpService(@DataFolder File dataFolder, BukkitService bukkitService, Settings settings) { + public GeoIpService(@DataFolder File dataFolder, BukkitService bukkitService, Settings settings) { this.bukkitService = bukkitService; this.dataFile = dataFolder.toPath().resolve(DATABASE_FILE); this.settings = settings; - // Fires download of recent data or the initialization of the look up service + // Fires download of recent data or the initialization of the look-up service isDataAvailable(); } @VisibleForTesting - GeoIpService(@DataFolder File dataFolder, BukkitService bukkitService, Settings settings, GeoIp2Provider reader) { + GeoIpService(@DataFolder File dataFolder, BukkitService bukkitService, Settings settings, DatabaseReader reader) { this.bukkitService = bukkitService; this.settings = settings; this.dataFile = dataFolder.toPath().resolve(DATABASE_FILE); @@ -111,7 +111,7 @@ private synchronized boolean isDataAvailable() { if (Duration.between(lastModifiedTime.toInstant(), Instant.now()).toDays() <= UPDATE_INTERVAL_DAYS) { startReading(); - // don't fire the update task - we are up to date + // don't fire the update task - we are up-to-date return true; } else { logger.debug("GEO IP database is older than " + UPDATE_INTERVAL_DAYS + " Days"); @@ -155,6 +155,7 @@ private void updateDatabase() { extractDatabase(downloadFile, tempFile); // MD5 checksum verification + //noinspection deprecation verifyChecksum(Hashing.md5(), tempFile, expectedChecksum); Files.copy(tempFile, dataFile, StandardCopyOption.REPLACE_EXISTING); @@ -176,7 +177,10 @@ private void updateDatabase() { } private void startReading() throws IOException { - databaseReader = new Reader(dataFile.toFile(), FileMode.MEMORY, new CHMCache()); + databaseReader = new DatabaseReader.Builder(dataFile.toFile()) + .withCache(new CHMCache()) + .fileMode(FileMode.MEMORY) + .build(); logger.info(LICENSE); // clear downloading flag, because we now have working reader instance @@ -184,7 +188,7 @@ private void startReading() throws IOException { } /** - * Downloads the archive to the destination file if it's newer than the locally version. + * Downloads the archive to the destination file if it's newer than the local version. * * @param lastModified modification timestamp of the already present file * @param destination save file @@ -226,7 +230,7 @@ private String downloadDatabaseArchive(Instant lastModified, Path destination) t } /** - * Downloads the archive to the destination file if it's newer than the locally version. + * Downloads the archive to the destination file if it's newer than the local version. * * @param destination save file * @return null if no updates were found, the MD5 hash of the downloaded archive if successful @@ -326,11 +330,11 @@ private Optional getCountry(String ip) { InetAddress address = InetAddress.getByName(ip); // Reader.getCountry() can be null for unknown addresses - return Optional.ofNullable(databaseReader.getCountry(address)).map(CountryResponse::getCountry); + return Optional.ofNullable(databaseReader.country(address)).map(AbstractCountryResponse::getCountry); } catch (UnknownHostException e) { // Ignore invalid ip addresses - // Legacy GEO IP Database returned a unknown country object with Country-Code: '--' and Country-Name: 'N/A' - } catch (IOException ioEx) { + // Legacy GEO IP Database returned an unknown country object with Country-Code: '--' and Country-Name: 'N/A' + } catch (GeoIp2Exception | IOException ioEx) { logger.logException("Cannot lookup country for " + ip + " at GEO IP database", ioEx); } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index aa267deacc..59ee6a764c 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,10 +1,13 @@ +# noinspection YAMLSchemaValidation name: ${pluginDescription.name} +# noinspection YAMLSchemaValidation authors: [${pluginDescription.authors}] website: ${project.url} description: ${project.description} +# noinspection YAMLSchemaValidation main: ${pluginDescription.main} version: ${pluginDescription.version} -api-version: 1.13 +api-version: 1.16 softdepend: - Vault - LuckPerms @@ -15,6 +18,24 @@ softdepend: - Essentials - EssentialsSpawn - ProtocolLib +libraries: + - ch.jalu:injector:${dependencies.injector.version} + - net.ricecode:string-similarity:${dependencies.string-similarity.version} + - com.maxmind.geoip2:geoip2:${dependencies.geoip2.version} + - javatar:javatar:${dependencies.javatar.version} + - org.apache.commons:commons-email:${dependencies.commons-email.version} + - com.zaxxer:HikariCP:${dependencies.hikaricp.version} + - org.slf4j:slf4j-simple:${dependencies.slf4j.version} + - ch.jalu:datasourcecolumns:${dependencies.datasourcecolumns.version} + - com.mysql:mysql-connector-j:${dependencies.mysql-connector-j.version} + - org.mariadb.jdbc:mariadb-java-client:${dependencies.mariadb-java-client.version} + - org.postgresql:postgresql:${dependencies.postgresql.version} + - de.rtner:PBKDF2:${dependencies.pbkdf2.version} + - de.mkammerer:argon2-jvm-nolibs:${dependencies.argon2-jvm-nolibs.version} + - at.favre.lib:bcrypt:${dependencies.bcrypt.version} + - com.warrenstrange:googleauth:${dependencies.googleauth.version} + - ch.jalu:configme:${dependencies.configme.version} + - org.bstats:bstats-bukkit:${dependencies.bstats.version} commands: authme: description: AuthMe op commands diff --git a/src/test/java/fr/xephi/authme/AuthMeInitializationTest.java b/src/test/java/fr/xephi/authme/AuthMeInitializationTest.java index 290312bb54..f1fd62597a 100644 --- a/src/test/java/fr/xephi/authme/AuthMeInitializationTest.java +++ b/src/test/java/fr/xephi/authme/AuthMeInitializationTest.java @@ -41,7 +41,7 @@ import static fr.xephi.authme.settings.properties.AuthMeSettingsRetriever.buildConfigurationData; import static org.hamcrest.Matchers.not; import static org.hamcrest.Matchers.nullValue; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.RETURNS_DEEP_STUBS; diff --git a/src/test/java/fr/xephi/authme/ClassesConsistencyTest.java b/src/test/java/fr/xephi/authme/ClassesConsistencyTest.java index f02b5dc9b2..c4aa4f64b0 100644 --- a/src/test/java/fr/xephi/authme/ClassesConsistencyTest.java +++ b/src/test/java/fr/xephi/authme/ClassesConsistencyTest.java @@ -33,7 +33,7 @@ import java.util.stream.Collectors; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.fail; /** diff --git a/src/test/java/fr/xephi/authme/CodeClimateConfigTest.java b/src/test/java/fr/xephi/authme/CodeClimateConfigTest.java index e645922e7b..669d10b306 100644 --- a/src/test/java/fr/xephi/authme/CodeClimateConfigTest.java +++ b/src/test/java/fr/xephi/authme/CodeClimateConfigTest.java @@ -10,7 +10,7 @@ import static org.hamcrest.Matchers.empty; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.not; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.fail; /** diff --git a/src/test/java/fr/xephi/authme/ConsoleLoggerTest.java b/src/test/java/fr/xephi/authme/ConsoleLoggerTest.java index 3f334e471f..19a64df2d5 100644 --- a/src/test/java/fr/xephi/authme/ConsoleLoggerTest.java +++ b/src/test/java/fr/xephi/authme/ConsoleLoggerTest.java @@ -28,7 +28,7 @@ import static org.hamcrest.Matchers.greaterThan; import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.nullValue; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.doThrow; diff --git a/src/test/java/fr/xephi/authme/command/CommandConsistencyTest.java b/src/test/java/fr/xephi/authme/command/CommandConsistencyTest.java index d2033d1bc0..fc3b3aeee7 100644 --- a/src/test/java/fr/xephi/authme/command/CommandConsistencyTest.java +++ b/src/test/java/fr/xephi/authme/command/CommandConsistencyTest.java @@ -17,7 +17,7 @@ import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.not; import static org.hamcrest.Matchers.nullValue; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Checks that the commands declared in plugin.yml correspond diff --git a/src/test/java/fr/xephi/authme/command/CommandHandlerTest.java b/src/test/java/fr/xephi/authme/command/CommandHandlerTest.java index d80d8f8a56..6efb3b9aea 100644 --- a/src/test/java/fr/xephi/authme/command/CommandHandlerTest.java +++ b/src/test/java/fr/xephi/authme/command/CommandHandlerTest.java @@ -31,7 +31,7 @@ import static fr.xephi.authme.command.FoundResultStatus.UNKNOWN_LABEL; import static java.util.Arrays.asList; import static org.hamcrest.Matchers.containsString; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyList; import static org.mockito.ArgumentMatchers.anyString; diff --git a/src/test/java/fr/xephi/authme/command/CommandInitializerTest.java b/src/test/java/fr/xephi/authme/command/CommandInitializerTest.java index 5cac2462a8..2110e2d660 100644 --- a/src/test/java/fr/xephi/authme/command/CommandInitializerTest.java +++ b/src/test/java/fr/xephi/authme/command/CommandInitializerTest.java @@ -17,7 +17,7 @@ import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.hasSize; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.fail; /** diff --git a/src/test/java/fr/xephi/authme/command/CommandMapperTest.java b/src/test/java/fr/xephi/authme/command/CommandMapperTest.java index 3a23cdc8ce..4311d709cf 100644 --- a/src/test/java/fr/xephi/authme/command/CommandMapperTest.java +++ b/src/test/java/fr/xephi/authme/command/CommandMapperTest.java @@ -27,7 +27,7 @@ import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.not; import static org.hamcrest.Matchers.nullValue; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.isNull; diff --git a/src/test/java/fr/xephi/authme/command/CommandUtilsTest.java b/src/test/java/fr/xephi/authme/command/CommandUtilsTest.java index be17f6cfb6..bd5a18d8a7 100644 --- a/src/test/java/fr/xephi/authme/command/CommandUtilsTest.java +++ b/src/test/java/fr/xephi/authme/command/CommandUtilsTest.java @@ -10,7 +10,7 @@ import java.util.List; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Test for {@link CommandUtils}. diff --git a/src/test/java/fr/xephi/authme/command/executable/HelpCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/HelpCommandTest.java index 33e0508e60..9e40a4c62b 100644 --- a/src/test/java/fr/xephi/authme/command/executable/HelpCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/HelpCommandTest.java @@ -27,7 +27,7 @@ import static java.util.Arrays.asList; import static java.util.Collections.singletonList; import static org.hamcrest.Matchers.containsString; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; diff --git a/src/test/java/fr/xephi/authme/command/executable/authme/AccountsCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/authme/AccountsCommandTest.java index 2fcb0e56e1..654a1aafcc 100644 --- a/src/test/java/fr/xephi/authme/command/executable/authme/AccountsCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/authme/AccountsCommandTest.java @@ -19,7 +19,7 @@ import static fr.xephi.authme.service.BukkitServiceTestHelper.setBukkitServiceToRunTaskAsynchronously; import static org.hamcrest.Matchers.containsString; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; diff --git a/src/test/java/fr/xephi/authme/command/executable/authme/AuthMeCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/authme/AuthMeCommandTest.java index 84ce1a9cc9..303be56fef 100644 --- a/src/test/java/fr/xephi/authme/command/executable/authme/AuthMeCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/authme/AuthMeCommandTest.java @@ -8,7 +8,7 @@ import java.util.Collections; import static org.hamcrest.Matchers.containsString; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; diff --git a/src/test/java/fr/xephi/authme/command/executable/authme/ConverterCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/authme/ConverterCommandTest.java index cad80f9f05..aeae96ab66 100644 --- a/src/test/java/fr/xephi/authme/command/executable/authme/ConverterCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/authme/ConverterCommandTest.java @@ -24,7 +24,7 @@ import static fr.xephi.authme.service.BukkitServiceTestHelper.setBukkitServiceToRunTaskAsynchronously; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.doThrow; diff --git a/src/test/java/fr/xephi/authme/command/executable/authme/LastLoginCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/authme/LastLoginCommandTest.java index 9e35cd7cf4..402b933aca 100644 --- a/src/test/java/fr/xephi/authme/command/executable/authme/LastLoginCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/authme/LastLoginCommandTest.java @@ -17,7 +17,7 @@ import static org.hamcrest.Matchers.allOf; import static org.hamcrest.Matchers.containsString; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; diff --git a/src/test/java/fr/xephi/authme/command/executable/authme/PurgeCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/authme/PurgeCommandTest.java index 70e4f03a12..5d8d8d89e8 100644 --- a/src/test/java/fr/xephi/authme/command/executable/authme/PurgeCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/authme/PurgeCommandTest.java @@ -15,7 +15,7 @@ import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.greaterThan; import static org.hamcrest.Matchers.not; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; diff --git a/src/test/java/fr/xephi/authme/command/executable/authme/RegisterAdminCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/authme/RegisterAdminCommandTest.java index 07808fa586..9a465d53ae 100644 --- a/src/test/java/fr/xephi/authme/command/executable/authme/RegisterAdminCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/authme/RegisterAdminCommandTest.java @@ -26,7 +26,7 @@ import static fr.xephi.authme.service.BukkitServiceTestHelper.setBukkitServiceToRunTaskOptionallyAsync; import static fr.xephi.authme.service.BukkitServiceTestHelper.setBukkitServiceToScheduleSyncTaskFromOptionallyAsyncTask; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; diff --git a/src/test/java/fr/xephi/authme/command/executable/authme/debug/DataStatisticsTest.java b/src/test/java/fr/xephi/authme/command/executable/authme/debug/DataStatisticsTest.java index fe50d83702..1fbc1d3037 100644 --- a/src/test/java/fr/xephi/authme/command/executable/authme/debug/DataStatisticsTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/authme/debug/DataStatisticsTest.java @@ -31,7 +31,7 @@ import static org.hamcrest.Matchers.containsInAnyOrder; import static org.hamcrest.Matchers.hasItem; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.atLeastOnce; import static org.mockito.Mockito.mock; diff --git a/src/test/java/fr/xephi/authme/command/executable/authme/debug/DebugCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/authme/debug/DebugCommandTest.java index 82e39d4113..a92a065754 100644 --- a/src/test/java/fr/xephi/authme/command/executable/authme/debug/DebugCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/authme/debug/DebugCommandTest.java @@ -23,7 +23,7 @@ import static org.hamcrest.Matchers.contains; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyList; import static org.mockito.ArgumentMatchers.eq; diff --git a/src/test/java/fr/xephi/authme/command/executable/authme/debug/DebugSectionConsistencyTest.java b/src/test/java/fr/xephi/authme/command/executable/authme/debug/DebugSectionConsistencyTest.java index ea92f85e6b..26286237b9 100644 --- a/src/test/java/fr/xephi/authme/command/executable/authme/debug/DebugSectionConsistencyTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/authme/debug/DebugSectionConsistencyTest.java @@ -13,7 +13,7 @@ import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.not; import static org.hamcrest.Matchers.nullValue; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.fail; /** diff --git a/src/test/java/fr/xephi/authme/command/executable/authme/debug/DebugSectionUtilsTest.java b/src/test/java/fr/xephi/authme/command/executable/authme/debug/DebugSectionUtilsTest.java index 1157663ba6..7f4d556afa 100644 --- a/src/test/java/fr/xephi/authme/command/executable/authme/debug/DebugSectionUtilsTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/authme/debug/DebugSectionUtilsTest.java @@ -18,7 +18,7 @@ import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.Matchers.sameInstance; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.Mockito.mock; /** diff --git a/src/test/java/fr/xephi/authme/command/executable/authme/debug/HasPermissionCheckerTest.java b/src/test/java/fr/xephi/authme/command/executable/authme/debug/HasPermissionCheckerTest.java index 4bd8eab199..6d5dc18d42 100644 --- a/src/test/java/fr/xephi/authme/command/executable/authme/debug/HasPermissionCheckerTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/authme/debug/HasPermissionCheckerTest.java @@ -23,7 +23,7 @@ import static org.hamcrest.Matchers.containsInAnyOrder; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.atLeast; import static org.mockito.Mockito.mock; diff --git a/src/test/java/fr/xephi/authme/command/executable/authme/debug/MySqlDefaultChangerColumnsTest.java b/src/test/java/fr/xephi/authme/command/executable/authme/debug/MySqlDefaultChangerColumnsTest.java index df891fe68d..99027e44e4 100644 --- a/src/test/java/fr/xephi/authme/command/executable/authme/debug/MySqlDefaultChangerColumnsTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/authme/debug/MySqlDefaultChangerColumnsTest.java @@ -6,7 +6,7 @@ import java.util.Set; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.fail; /** diff --git a/src/test/java/fr/xephi/authme/command/executable/authme/debug/MySqlDefaultChangerTest.java b/src/test/java/fr/xephi/authme/command/executable/authme/debug/MySqlDefaultChangerTest.java index 516d16780d..98ec5fba6a 100644 --- a/src/test/java/fr/xephi/authme/command/executable/authme/debug/MySqlDefaultChangerTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/authme/debug/MySqlDefaultChangerTest.java @@ -21,7 +21,7 @@ import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.Matchers.sameInstance; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; diff --git a/src/test/java/fr/xephi/authme/command/executable/authme/debug/PlayerAuthViewerTest.java b/src/test/java/fr/xephi/authme/command/executable/authme/debug/PlayerAuthViewerTest.java index 8f34bcbf85..3b34f308b0 100644 --- a/src/test/java/fr/xephi/authme/command/executable/authme/debug/PlayerAuthViewerTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/authme/debug/PlayerAuthViewerTest.java @@ -14,7 +14,7 @@ import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.hasItem; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.atLeastOnce; import static org.mockito.Mockito.mock; diff --git a/src/test/java/fr/xephi/authme/command/executable/changepassword/ChangePasswordCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/changepassword/ChangePasswordCommandTest.java index 4c5488cb85..ad02758f83 100644 --- a/src/test/java/fr/xephi/authme/command/executable/changepassword/ChangePasswordCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/changepassword/ChangePasswordCommandTest.java @@ -21,7 +21,7 @@ import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.any; import static org.mockito.Mockito.eq; diff --git a/src/test/java/fr/xephi/authme/command/executable/email/AddEmailCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/email/AddEmailCommandTest.java index c8a57562fa..03b42f2a64 100644 --- a/src/test/java/fr/xephi/authme/command/executable/email/AddEmailCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/email/AddEmailCommandTest.java @@ -16,7 +16,7 @@ import java.util.Collections; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoInteractions; diff --git a/src/test/java/fr/xephi/authme/command/executable/email/ChangeEmailCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/email/ChangeEmailCommandTest.java index 3c99e17dcf..9833c4f7fb 100644 --- a/src/test/java/fr/xephi/authme/command/executable/email/ChangeEmailCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/email/ChangeEmailCommandTest.java @@ -17,7 +17,7 @@ import java.util.Collections; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; diff --git a/src/test/java/fr/xephi/authme/command/executable/email/RecoverEmailCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/email/RecoverEmailCommandTest.java index 06ce4ee5bb..0f8bc20714 100644 --- a/src/test/java/fr/xephi/authme/command/executable/email/RecoverEmailCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/email/RecoverEmailCommandTest.java @@ -26,7 +26,7 @@ import static fr.xephi.authme.service.BukkitServiceTestHelper.setBukkitServiceToRunTaskAsynchronously; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; @@ -62,7 +62,7 @@ public class RecoverEmailCommandTest { @Mock private PasswordRecoveryService recoveryService; - + @Mock private RecoveryCodeService recoveryCodeService; diff --git a/src/test/java/fr/xephi/authme/command/executable/login/LoginCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/login/LoginCommandTest.java index 7f6c66759c..66420cc422 100644 --- a/src/test/java/fr/xephi/authme/command/executable/login/LoginCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/login/LoginCommandTest.java @@ -15,7 +15,7 @@ import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoInteractions; diff --git a/src/test/java/fr/xephi/authme/command/executable/totp/ConfirmTotpCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/totp/ConfirmTotpCommandTest.java index 4c3053647c..d3d3d025c2 100644 --- a/src/test/java/fr/xephi/authme/command/executable/totp/ConfirmTotpCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/totp/ConfirmTotpCommandTest.java @@ -19,7 +19,7 @@ import java.util.Collections; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.BDDMockito.given; diff --git a/src/test/java/fr/xephi/authme/command/executable/totp/RemoveTotpCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/totp/RemoveTotpCommandTest.java index 26c7e87195..d0ae8f3410 100644 --- a/src/test/java/fr/xephi/authme/command/executable/totp/RemoveTotpCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/totp/RemoveTotpCommandTest.java @@ -17,7 +17,7 @@ import static java.util.Collections.singletonList; import static org.hamcrest.Matchers.nullValue; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.only; diff --git a/src/test/java/fr/xephi/authme/command/executable/unregister/UnregisterCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/unregister/UnregisterCommandTest.java index a0fc8d3d17..a085cba473 100644 --- a/src/test/java/fr/xephi/authme/command/executable/unregister/UnregisterCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/unregister/UnregisterCommandTest.java @@ -17,7 +17,7 @@ import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; diff --git a/src/test/java/fr/xephi/authme/command/executable/verification/VerificationCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/verification/VerificationCommandTest.java index d4b38f1ad4..80ae565b7f 100644 --- a/src/test/java/fr/xephi/authme/command/executable/verification/VerificationCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/verification/VerificationCommandTest.java @@ -15,7 +15,7 @@ import java.util.Collections; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; diff --git a/src/test/java/fr/xephi/authme/command/help/HelpMessageAndHelpSectionConsistencyTest.java b/src/test/java/fr/xephi/authme/command/help/HelpMessageAndHelpSectionConsistencyTest.java index 02a42ba998..30eddba19d 100644 --- a/src/test/java/fr/xephi/authme/command/help/HelpMessageAndHelpSectionConsistencyTest.java +++ b/src/test/java/fr/xephi/authme/command/help/HelpMessageAndHelpSectionConsistencyTest.java @@ -7,7 +7,7 @@ import java.util.Set; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.fail; /** diff --git a/src/test/java/fr/xephi/authme/command/help/HelpMessagesConsistencyTest.java b/src/test/java/fr/xephi/authme/command/help/HelpMessagesConsistencyTest.java index 019e6c8630..b91be4e6ad 100644 --- a/src/test/java/fr/xephi/authme/command/help/HelpMessagesConsistencyTest.java +++ b/src/test/java/fr/xephi/authme/command/help/HelpMessagesConsistencyTest.java @@ -18,7 +18,7 @@ import static org.hamcrest.Matchers.contains; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.instanceOf; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Tests that /messages/help_en.yml contains texts that correspond diff --git a/src/test/java/fr/xephi/authme/command/help/HelpMessagesServiceTest.java b/src/test/java/fr/xephi/authme/command/help/HelpMessagesServiceTest.java index 514724a979..3c3f267ce7 100644 --- a/src/test/java/fr/xephi/authme/command/help/HelpMessagesServiceTest.java +++ b/src/test/java/fr/xephi/authme/command/help/HelpMessagesServiceTest.java @@ -24,7 +24,7 @@ import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.sameInstance; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; diff --git a/src/test/java/fr/xephi/authme/command/help/HelpProviderTest.java b/src/test/java/fr/xephi/authme/command/help/HelpProviderTest.java index 8852387fa8..d1d1755361 100644 --- a/src/test/java/fr/xephi/authme/command/help/HelpProviderTest.java +++ b/src/test/java/fr/xephi/authme/command/help/HelpProviderTest.java @@ -39,7 +39,7 @@ import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.hasSize; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.BDDMockito.given; diff --git a/src/test/java/fr/xephi/authme/data/QuickCommandsProtectionManagerTest.java b/src/test/java/fr/xephi/authme/data/QuickCommandsProtectionManagerTest.java index 704075674d..f46bbce126 100644 --- a/src/test/java/fr/xephi/authme/data/QuickCommandsProtectionManagerTest.java +++ b/src/test/java/fr/xephi/authme/data/QuickCommandsProtectionManagerTest.java @@ -11,7 +11,7 @@ import org.mockito.junit.MockitoJUnitRunner; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; diff --git a/src/test/java/fr/xephi/authme/data/TempbanManagerTest.java b/src/test/java/fr/xephi/authme/data/TempbanManagerTest.java index a186920a54..ce5c977480 100644 --- a/src/test/java/fr/xephi/authme/data/TempbanManagerTest.java +++ b/src/test/java/fr/xephi/authme/data/TempbanManagerTest.java @@ -24,7 +24,7 @@ import static org.hamcrest.Matchers.contains; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.lessThan; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; diff --git a/src/test/java/fr/xephi/authme/data/VerificationCodeManagerTest.java b/src/test/java/fr/xephi/authme/data/VerificationCodeManagerTest.java index 147b0dd057..226213a5a2 100644 --- a/src/test/java/fr/xephi/authme/data/VerificationCodeManagerTest.java +++ b/src/test/java/fr/xephi/authme/data/VerificationCodeManagerTest.java @@ -15,7 +15,7 @@ import org.mockito.junit.MockitoJUnitRunner; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.only; diff --git a/src/test/java/fr/xephi/authme/data/captcha/LoginCaptchaManagerTest.java b/src/test/java/fr/xephi/authme/data/captcha/LoginCaptchaManagerTest.java index 3197634581..c313fc571b 100644 --- a/src/test/java/fr/xephi/authme/data/captcha/LoginCaptchaManagerTest.java +++ b/src/test/java/fr/xephi/authme/data/captcha/LoginCaptchaManagerTest.java @@ -12,7 +12,7 @@ import static fr.xephi.authme.AuthMeMatchers.stringWithLength; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.not; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; diff --git a/src/test/java/fr/xephi/authme/data/captcha/RegistrationCaptchaManagerTest.java b/src/test/java/fr/xephi/authme/data/captcha/RegistrationCaptchaManagerTest.java index 4a71ab2ca1..07aeaf0b8b 100644 --- a/src/test/java/fr/xephi/authme/data/captcha/RegistrationCaptchaManagerTest.java +++ b/src/test/java/fr/xephi/authme/data/captcha/RegistrationCaptchaManagerTest.java @@ -9,7 +9,7 @@ import static fr.xephi.authme.AuthMeMatchers.stringWithLength; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; diff --git a/src/test/java/fr/xephi/authme/data/limbo/LimboPlayerTaskManagerTest.java b/src/test/java/fr/xephi/authme/data/limbo/LimboPlayerTaskManagerTest.java index 5cbbb1ffe7..fdc82abe6b 100644 --- a/src/test/java/fr/xephi/authme/data/limbo/LimboPlayerTaskManagerTest.java +++ b/src/test/java/fr/xephi/authme/data/limbo/LimboPlayerTaskManagerTest.java @@ -27,7 +27,7 @@ import static org.hamcrest.Matchers.not; import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.Matchers.sameInstance; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyLong; import static org.mockito.ArgumentMatchers.eq; diff --git a/src/test/java/fr/xephi/authme/data/limbo/LimboServiceHelperTest.java b/src/test/java/fr/xephi/authme/data/limbo/LimboServiceHelperTest.java index 418ce698cc..3b7d03e732 100644 --- a/src/test/java/fr/xephi/authme/data/limbo/LimboServiceHelperTest.java +++ b/src/test/java/fr/xephi/authme/data/limbo/LimboServiceHelperTest.java @@ -13,7 +13,7 @@ import static org.hamcrest.Matchers.contains; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.nullValue; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verifyNoInteractions; diff --git a/src/test/java/fr/xephi/authme/data/limbo/LimboServiceTest.java b/src/test/java/fr/xephi/authme/data/limbo/LimboServiceTest.java index 44839c13bd..45c4a14e2e 100644 --- a/src/test/java/fr/xephi/authme/data/limbo/LimboServiceTest.java +++ b/src/test/java/fr/xephi/authme/data/limbo/LimboServiceTest.java @@ -27,7 +27,7 @@ import static org.hamcrest.Matchers.not; import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.Matchers.sameInstance; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.BDDMockito.given; diff --git a/src/test/java/fr/xephi/authme/data/limbo/persistence/IndividualFilesPersistenceHandlerTest.java b/src/test/java/fr/xephi/authme/data/limbo/persistence/IndividualFilesPersistenceHandlerTest.java index 77af856773..a7c9ce5c39 100644 --- a/src/test/java/fr/xephi/authme/data/limbo/persistence/IndividualFilesPersistenceHandlerTest.java +++ b/src/test/java/fr/xephi/authme/data/limbo/persistence/IndividualFilesPersistenceHandlerTest.java @@ -28,7 +28,7 @@ import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.not; import static org.hamcrest.Matchers.nullValue; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; diff --git a/src/test/java/fr/xephi/authme/data/limbo/persistence/LimboPersistenceTest.java b/src/test/java/fr/xephi/authme/data/limbo/persistence/LimboPersistenceTest.java index b9ac1cd813..e8aba73fe4 100644 --- a/src/test/java/fr/xephi/authme/data/limbo/persistence/LimboPersistenceTest.java +++ b/src/test/java/fr/xephi/authme/data/limbo/persistence/LimboPersistenceTest.java @@ -18,6 +18,7 @@ import java.util.logging.Logger; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.both; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.equalTo; @@ -25,7 +26,6 @@ import static org.hamcrest.Matchers.not; import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.Matchers.sameInstance; -import static org.junit.Assert.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.BDDMockito.given; @@ -40,6 +40,7 @@ @RunWith(DelayedInjectionRunner.class) public class LimboPersistenceTest { + @SuppressWarnings("unused") @InjectDelayed private LimboPersistence limboPersistence; @@ -59,7 +60,7 @@ public static void setUpLogger() { public void setUpMocks() { given(settings.getProperty(LimboSettings.LIMBO_PERSISTENCE_TYPE)).willReturn(LimboPersistenceType.DISABLED); given(handlerFactory.newInstance(any(Class.class))) - .willAnswer(invocation -> mock(invocation.getArgument(0))); + .willAnswer(invocation -> mock((Class) invocation.getArgument(0))); } @Test diff --git a/src/test/java/fr/xephi/authme/data/limbo/persistence/LimboPersistenceTypeTest.java b/src/test/java/fr/xephi/authme/data/limbo/persistence/LimboPersistenceTypeTest.java index 248ab9c143..33fe6924fc 100644 --- a/src/test/java/fr/xephi/authme/data/limbo/persistence/LimboPersistenceTypeTest.java +++ b/src/test/java/fr/xephi/authme/data/limbo/persistence/LimboPersistenceTypeTest.java @@ -6,7 +6,7 @@ import java.util.Set; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.fail; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; diff --git a/src/test/java/fr/xephi/authme/data/limbo/persistence/SegmentNameBuilderTest.java b/src/test/java/fr/xephi/authme/data/limbo/persistence/SegmentNameBuilderTest.java index d5cf31a9df..745a7ff876 100644 --- a/src/test/java/fr/xephi/authme/data/limbo/persistence/SegmentNameBuilderTest.java +++ b/src/test/java/fr/xephi/authme/data/limbo/persistence/SegmentNameBuilderTest.java @@ -14,7 +14,7 @@ import static fr.xephi.authme.data.limbo.persistence.SegmentSize.TWO_FIFTY; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.hasSize; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Test for {@link SegmentNameBuilder}. diff --git a/src/test/java/fr/xephi/authme/datasource/AbstractDataSourceIntegrationTest.java b/src/test/java/fr/xephi/authme/datasource/AbstractDataSourceIntegrationTest.java index a5e50cb964..6ced067416 100644 --- a/src/test/java/fr/xephi/authme/datasource/AbstractDataSourceIntegrationTest.java +++ b/src/test/java/fr/xephi/authme/datasource/AbstractDataSourceIntegrationTest.java @@ -25,7 +25,7 @@ import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.nullValue; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assume.assumeThat; /** diff --git a/src/test/java/fr/xephi/authme/datasource/SQLiteIntegrationTest.java b/src/test/java/fr/xephi/authme/datasource/SQLiteIntegrationTest.java index 06e60eeb6e..60b2a7bd89 100644 --- a/src/test/java/fr/xephi/authme/datasource/SQLiteIntegrationTest.java +++ b/src/test/java/fr/xephi/authme/datasource/SQLiteIntegrationTest.java @@ -19,7 +19,7 @@ import java.sql.Statement; import static org.hamcrest.Matchers.hasSize; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; diff --git a/src/test/java/fr/xephi/authme/datasource/SqLiteMigraterIntegrationTest.java b/src/test/java/fr/xephi/authme/datasource/SqLiteMigraterIntegrationTest.java index b95a0b814c..fc49904c93 100644 --- a/src/test/java/fr/xephi/authme/datasource/SqLiteMigraterIntegrationTest.java +++ b/src/test/java/fr/xephi/authme/datasource/SqLiteMigraterIntegrationTest.java @@ -24,7 +24,7 @@ import static org.hamcrest.Matchers.containsInAnyOrder; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.Mockito.mock; /** diff --git a/src/test/java/fr/xephi/authme/datasource/SqlDataSourceUtilsTest.java b/src/test/java/fr/xephi/authme/datasource/SqlDataSourceUtilsTest.java index ae29740851..29018b1d03 100644 --- a/src/test/java/fr/xephi/authme/datasource/SqlDataSourceUtilsTest.java +++ b/src/test/java/fr/xephi/authme/datasource/SqlDataSourceUtilsTest.java @@ -12,7 +12,7 @@ import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.nullValue; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; diff --git a/src/test/java/fr/xephi/authme/datasource/converter/CrazyLoginConverterTest.java b/src/test/java/fr/xephi/authme/datasource/converter/CrazyLoginConverterTest.java index 8819772de1..e68056eb80 100644 --- a/src/test/java/fr/xephi/authme/datasource/converter/CrazyLoginConverterTest.java +++ b/src/test/java/fr/xephi/authme/datasource/converter/CrazyLoginConverterTest.java @@ -21,7 +21,7 @@ import static fr.xephi.authme.AuthMeMatchers.equalToHash; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; diff --git a/src/test/java/fr/xephi/authme/datasource/converter/LoginSecurityConverterTest.java b/src/test/java/fr/xephi/authme/datasource/converter/LoginSecurityConverterTest.java index 54201fb719..41979e98ef 100644 --- a/src/test/java/fr/xephi/authme/datasource/converter/LoginSecurityConverterTest.java +++ b/src/test/java/fr/xephi/authme/datasource/converter/LoginSecurityConverterTest.java @@ -30,7 +30,7 @@ import static org.hamcrest.Matchers.greaterThan; import static org.hamcrest.Matchers.not; import static org.hamcrest.Matchers.nullValue; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; diff --git a/src/test/java/fr/xephi/authme/events/EventsConsistencyTest.java b/src/test/java/fr/xephi/authme/events/EventsConsistencyTest.java index bb722d3ef7..65b77af49c 100644 --- a/src/test/java/fr/xephi/authme/events/EventsConsistencyTest.java +++ b/src/test/java/fr/xephi/authme/events/EventsConsistencyTest.java @@ -12,7 +12,7 @@ import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.nullValue; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Checks the consistency of the AuthMe event classes. diff --git a/src/test/java/fr/xephi/authme/initialization/TaskCloserTest.java b/src/test/java/fr/xephi/authme/initialization/TaskCloserTest.java index 16613c1348..36566ec5ef 100644 --- a/src/test/java/fr/xephi/authme/initialization/TaskCloserTest.java +++ b/src/test/java/fr/xephi/authme/initialization/TaskCloserTest.java @@ -23,7 +23,7 @@ import java.util.concurrent.Executors; import static org.hamcrest.Matchers.contains; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.doNothing; diff --git a/src/test/java/fr/xephi/authme/listener/EntityListenerTest.java b/src/test/java/fr/xephi/authme/listener/EntityListenerTest.java index ce9fabb072..9fcdd59f53 100644 --- a/src/test/java/fr/xephi/authme/listener/EntityListenerTest.java +++ b/src/test/java/fr/xephi/authme/listener/EntityListenerTest.java @@ -20,7 +20,7 @@ import static fr.xephi.authme.listener.EventCancelVerifier.withServiceMock; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; diff --git a/src/test/java/fr/xephi/authme/listener/ListenerConsistencyTest.java b/src/test/java/fr/xephi/authme/listener/ListenerConsistencyTest.java index 7f320516e3..d7f03a6c5d 100644 --- a/src/test/java/fr/xephi/authme/listener/ListenerConsistencyTest.java +++ b/src/test/java/fr/xephi/authme/listener/ListenerConsistencyTest.java @@ -17,7 +17,7 @@ import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.not; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.fail; /** diff --git a/src/test/java/fr/xephi/authme/listener/ListenerServiceTest.java b/src/test/java/fr/xephi/authme/listener/ListenerServiceTest.java index 76877fcace..ba1fe05875 100644 --- a/src/test/java/fr/xephi/authme/listener/ListenerServiceTest.java +++ b/src/test/java/fr/xephi/authme/listener/ListenerServiceTest.java @@ -18,7 +18,7 @@ import org.mockito.Mock; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; diff --git a/src/test/java/fr/xephi/authme/listener/OnJoinVerifierTest.java b/src/test/java/fr/xephi/authme/listener/OnJoinVerifierTest.java index 3667e1bea1..0d08748e27 100644 --- a/src/test/java/fr/xephi/authme/listener/OnJoinVerifierTest.java +++ b/src/test/java/fr/xephi/authme/listener/OnJoinVerifierTest.java @@ -34,7 +34,7 @@ import java.util.List; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.fail; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; diff --git a/src/test/java/fr/xephi/authme/listener/PlayerListenerTest.java b/src/test/java/fr/xephi/authme/listener/PlayerListenerTest.java index 6ea299732c..19f5a69ee2 100644 --- a/src/test/java/fr/xephi/authme/listener/PlayerListenerTest.java +++ b/src/test/java/fr/xephi/authme/listener/PlayerListenerTest.java @@ -55,6 +55,7 @@ import org.mockito.junit.MockitoJUnitRunner; import java.net.InetAddress; +import java.net.UnknownHostException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -65,12 +66,12 @@ import static com.google.common.collect.Sets.newHashSet; import static fr.xephi.authme.listener.EventCancelVerifier.withServiceMock; import static fr.xephi.authme.service.BukkitServiceTestHelper.setBukkitServiceToScheduleSyncDelayedTaskWithDelay; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsInAnyOrder; import static org.hamcrest.Matchers.empty; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.nullValue; -import static org.junit.Assert.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyString; @@ -711,7 +712,7 @@ public void shouldPerformAllJoinVerificationsSuccessfullyPreLoginLowest() throws UUID uniqueId = UUID.fromString("753493c9-33ba-4a4a-bf61-1bce9d3c9a71"); String ip = "12.34.56.78"; - AsyncPlayerPreLoginEvent preLoginEvent = spy(new AsyncPlayerPreLoginEvent(name, mockAddrWithIp(ip), uniqueId)); + AsyncPlayerPreLoginEvent preLoginEvent = spy(new AsyncPlayerPreLoginEvent(name, createInetAddress(ip), uniqueId)); given(validationService.isUnrestricted(name)).willReturn(false); // when @@ -749,7 +750,7 @@ public void shouldPerformAllJoinVerificationsSuccessfullyPreLoginHighest() throw UUID uniqueId = UUID.fromString("753493c9-33ba-4a4a-bf61-1bce9d3c9a71"); String ip = "12.34.56.78"; - AsyncPlayerPreLoginEvent preLoginEvent = spy(new AsyncPlayerPreLoginEvent(name, mockAddrWithIp(ip), uniqueId)); + AsyncPlayerPreLoginEvent preLoginEvent = spy(new AsyncPlayerPreLoginEvent(name, createInetAddress(ip), uniqueId)); given(validationService.isUnrestricted(name)).willReturn(false); PlayerAuth auth = PlayerAuth.builder().name(name).build(); given(dataSource.getAuth(name)).willReturn(auth); @@ -773,7 +774,7 @@ public void shouldPerformAllJoinVerificationsSuccessfullyLogin() { Player player = mockPlayerWithName(name); String ip = "12.34.56.78"; - PlayerLoginEvent loginEvent = spy(new PlayerLoginEvent(player, "", mockAddrWithIp(ip))); + PlayerLoginEvent loginEvent = spy(new PlayerLoginEvent(player, "", createInetAddress(ip))); given(validationService.isUnrestricted(name)).willReturn(false); given(onJoinVerifier.refusePlayerForFullServer(loginEvent)).willReturn(false); @@ -792,7 +793,7 @@ public void shouldAbortPlayerJoinForInvalidName() throws FailedVerificationExcep // given String name = "inval!dName"; UUID uniqueId = UUID.fromString("753493c9-33ba-4a4a-bf61-1bce9d3c9a71"); - InetAddress ip = mockAddrWithIp("33.32.33.33"); + InetAddress ip = createInetAddress("33.32.33.33"); AsyncPlayerPreLoginEvent event = spy(new AsyncPlayerPreLoginEvent(name, ip, uniqueId)); given(validationService.isUnrestricted(name)).willReturn(false); FailedVerificationException exception = new FailedVerificationException( @@ -1107,9 +1108,11 @@ private static void verifyNoModifyingCalls(AsyncPlayerPreLoginEvent event) { verifyNoMoreInteractions(event); } - private static InetAddress mockAddrWithIp(String ip) { - InetAddress addr = mock(InetAddress.class); - given(addr.getHostAddress()).willReturn(ip); - return addr; + public static InetAddress createInetAddress(String ip) { + try { + return InetAddress.getByName(ip); + } catch (UnknownHostException e) { + throw new IllegalArgumentException("Invalid IP address: " + ip, e); + } } } diff --git a/src/test/java/fr/xephi/authme/mail/EmailServiceTest.java b/src/test/java/fr/xephi/authme/mail/EmailServiceTest.java index 96492daa9c..debafaf2c8 100644 --- a/src/test/java/fr/xephi/authme/mail/EmailServiceTest.java +++ b/src/test/java/fr/xephi/authme/mail/EmailServiceTest.java @@ -23,7 +23,7 @@ import java.io.IOException; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; diff --git a/src/test/java/fr/xephi/authme/mail/SendMailSslTest.java b/src/test/java/fr/xephi/authme/mail/SendMailSslTest.java index cd5b215234..9fb59340dd 100644 --- a/src/test/java/fr/xephi/authme/mail/SendMailSslTest.java +++ b/src/test/java/fr/xephi/authme/mail/SendMailSslTest.java @@ -24,7 +24,7 @@ import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.not; import static org.hamcrest.Matchers.nullValue; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.BDDMockito.given; /** diff --git a/src/test/java/fr/xephi/authme/message/HelpMessageConsistencyTest.java b/src/test/java/fr/xephi/authme/message/HelpMessageConsistencyTest.java index b6fcba7ccc..f675b9e770 100644 --- a/src/test/java/fr/xephi/authme/message/HelpMessageConsistencyTest.java +++ b/src/test/java/fr/xephi/authme/message/HelpMessageConsistencyTest.java @@ -20,7 +20,7 @@ import static org.hamcrest.Matchers.emptyString; import static org.hamcrest.Matchers.not; import static org.hamcrest.Matchers.nullValue; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Tests that all help_xx.yml files contain all entries for diff --git a/src/test/java/fr/xephi/authme/message/MessageKeyTest.java b/src/test/java/fr/xephi/authme/message/MessageKeyTest.java index c60305d68c..87c1da9a97 100644 --- a/src/test/java/fr/xephi/authme/message/MessageKeyTest.java +++ b/src/test/java/fr/xephi/authme/message/MessageKeyTest.java @@ -8,7 +8,7 @@ import java.util.Set; import static org.hamcrest.Matchers.matchesPattern; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.fail; /** diff --git a/src/test/java/fr/xephi/authme/message/MessagePathHelperTest.java b/src/test/java/fr/xephi/authme/message/MessagePathHelperTest.java index 7e12aa4f59..3b03815b11 100644 --- a/src/test/java/fr/xephi/authme/message/MessagePathHelperTest.java +++ b/src/test/java/fr/xephi/authme/message/MessagePathHelperTest.java @@ -5,7 +5,7 @@ import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.nullValue; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Test for {@link MessagePathHelper}. diff --git a/src/test/java/fr/xephi/authme/message/MessagesIntegrationTest.java b/src/test/java/fr/xephi/authme/message/MessagesIntegrationTest.java index bc1e9769d0..18502a0cf3 100644 --- a/src/test/java/fr/xephi/authme/message/MessagesIntegrationTest.java +++ b/src/test/java/fr/xephi/authme/message/MessagesIntegrationTest.java @@ -31,7 +31,7 @@ import static org.hamcrest.Matchers.contains; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; diff --git a/src/test/java/fr/xephi/authme/message/updater/MessageUpdaterTest.java b/src/test/java/fr/xephi/authme/message/updater/MessageUpdaterTest.java index eac3b67e33..10182a6e85 100644 --- a/src/test/java/fr/xephi/authme/message/updater/MessageUpdaterTest.java +++ b/src/test/java/fr/xephi/authme/message/updater/MessageUpdaterTest.java @@ -21,7 +21,7 @@ import static fr.xephi.authme.message.MessagePathHelper.DEFAULT_MESSAGES_FILE; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Test for {@link MessageUpdater}. diff --git a/src/test/java/fr/xephi/authme/message/updater/MigraterYamlFileResourceTest.java b/src/test/java/fr/xephi/authme/message/updater/MigraterYamlFileResourceTest.java index 03d79e71f6..f15e808b7c 100644 --- a/src/test/java/fr/xephi/authme/message/updater/MigraterYamlFileResourceTest.java +++ b/src/test/java/fr/xephi/authme/message/updater/MigraterYamlFileResourceTest.java @@ -17,7 +17,7 @@ import java.util.List; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Test for {@link MigraterYamlFileResource}. diff --git a/src/test/java/fr/xephi/authme/output/ConsoleFilterTest.java b/src/test/java/fr/xephi/authme/output/ConsoleFilterTest.java index 8975068f64..55c76fa7a7 100644 --- a/src/test/java/fr/xephi/authme/output/ConsoleFilterTest.java +++ b/src/test/java/fr/xephi/authme/output/ConsoleFilterTest.java @@ -6,7 +6,7 @@ import java.util.logging.LogRecord; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; diff --git a/src/test/java/fr/xephi/authme/output/ConsoleLoggerFactoryTest.java b/src/test/java/fr/xephi/authme/output/ConsoleLoggerFactoryTest.java index fe53383b4f..38e88fdc47 100644 --- a/src/test/java/fr/xephi/authme/output/ConsoleLoggerFactoryTest.java +++ b/src/test/java/fr/xephi/authme/output/ConsoleLoggerFactoryTest.java @@ -17,7 +17,7 @@ import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.not; import static org.hamcrest.Matchers.sameInstance; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; diff --git a/src/test/java/fr/xephi/authme/output/Log4JFilterTest.java b/src/test/java/fr/xephi/authme/output/Log4JFilterTest.java index 91228c5fc4..5c5a7ab92f 100644 --- a/src/test/java/fr/xephi/authme/output/Log4JFilterTest.java +++ b/src/test/java/fr/xephi/authme/output/Log4JFilterTest.java @@ -1,7 +1,7 @@ package fr.xephi.authme.output; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.Mockito.when; import org.apache.logging.log4j.Level; diff --git a/src/test/java/fr/xephi/authme/output/LogFilterHelperTest.java b/src/test/java/fr/xephi/authme/output/LogFilterHelperTest.java index 302345fb9c..5e8de0e524 100644 --- a/src/test/java/fr/xephi/authme/output/LogFilterHelperTest.java +++ b/src/test/java/fr/xephi/authme/output/LogFilterHelperTest.java @@ -10,7 +10,7 @@ import java.util.stream.Collectors; import static org.hamcrest.Matchers.containsInAnyOrder; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Test for {@link LogFilterHelper}. diff --git a/src/test/java/fr/xephi/authme/output/LogLevelTest.java b/src/test/java/fr/xephi/authme/output/LogLevelTest.java index aa313ae769..76e8105442 100644 --- a/src/test/java/fr/xephi/authme/output/LogLevelTest.java +++ b/src/test/java/fr/xephi/authme/output/LogLevelTest.java @@ -4,7 +4,7 @@ import static java.lang.String.format; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Test for {@link LogLevel}. diff --git a/src/test/java/fr/xephi/authme/permission/PermissionsManagerInitializationTest.java b/src/test/java/fr/xephi/authme/permission/PermissionsManagerInitializationTest.java index bdd1c5e633..a0fc1d7c67 100644 --- a/src/test/java/fr/xephi/authme/permission/PermissionsManagerInitializationTest.java +++ b/src/test/java/fr/xephi/authme/permission/PermissionsManagerInitializationTest.java @@ -39,7 +39,7 @@ import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.instanceOf; import static org.hamcrest.Matchers.nullValue; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.only; diff --git a/src/test/java/fr/xephi/authme/permission/PermissionsManagerTest.java b/src/test/java/fr/xephi/authme/permission/PermissionsManagerTest.java index 6c7efb4520..d0b8569ce5 100644 --- a/src/test/java/fr/xephi/authme/permission/PermissionsManagerTest.java +++ b/src/test/java/fr/xephi/authme/permission/PermissionsManagerTest.java @@ -11,7 +11,7 @@ import org.mockito.junit.MockitoJUnitRunner; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; diff --git a/src/test/java/fr/xephi/authme/permission/PermissionsSystemTypeTest.java b/src/test/java/fr/xephi/authme/permission/PermissionsSystemTypeTest.java index 79b513a146..73658e2f92 100644 --- a/src/test/java/fr/xephi/authme/permission/PermissionsSystemTypeTest.java +++ b/src/test/java/fr/xephi/authme/permission/PermissionsSystemTypeTest.java @@ -9,7 +9,7 @@ import static org.hamcrest.Matchers.hasItem; import static org.hamcrest.Matchers.not; import static org.hamcrest.Matchers.nullValue; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Test for {@link PermissionsSystemType}. diff --git a/src/test/java/fr/xephi/authme/permission/handlers/VaultHandlerTest.java b/src/test/java/fr/xephi/authme/permission/handlers/VaultHandlerTest.java index 852dcaefb9..636072746a 100644 --- a/src/test/java/fr/xephi/authme/permission/handlers/VaultHandlerTest.java +++ b/src/test/java/fr/xephi/authme/permission/handlers/VaultHandlerTest.java @@ -12,7 +12,7 @@ import static java.util.stream.Collectors.toList; import static org.hamcrest.Matchers.contains; import static org.hamcrest.Matchers.empty; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; diff --git a/src/test/java/fr/xephi/authme/process/login/AsynchronousLoginTest.java b/src/test/java/fr/xephi/authme/process/login/AsynchronousLoginTest.java index 673282a477..a3dbfb389b 100644 --- a/src/test/java/fr/xephi/authme/process/login/AsynchronousLoginTest.java +++ b/src/test/java/fr/xephi/authme/process/login/AsynchronousLoginTest.java @@ -28,7 +28,7 @@ import java.util.List; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.BDDMockito.given; diff --git a/src/test/java/fr/xephi/authme/process/register/executors/EmailRegisterExecutorTest.java b/src/test/java/fr/xephi/authme/process/register/executors/EmailRegisterExecutorTest.java index a52b0075d4..6e1006151f 100644 --- a/src/test/java/fr/xephi/authme/process/register/executors/EmailRegisterExecutorTest.java +++ b/src/test/java/fr/xephi/authme/process/register/executors/EmailRegisterExecutorTest.java @@ -23,7 +23,7 @@ import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.greaterThan; import static org.hamcrest.Matchers.not; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; diff --git a/src/test/java/fr/xephi/authme/process/register/executors/PasswordRegisterExecutorTest.java b/src/test/java/fr/xephi/authme/process/register/executors/PasswordRegisterExecutorTest.java index 7e2e5fd010..48bf203080 100644 --- a/src/test/java/fr/xephi/authme/process/register/executors/PasswordRegisterExecutorTest.java +++ b/src/test/java/fr/xephi/authme/process/register/executors/PasswordRegisterExecutorTest.java @@ -26,7 +26,7 @@ import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.greaterThan; import static org.hamcrest.Matchers.not; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; diff --git a/src/test/java/fr/xephi/authme/process/register/executors/PlayerAuthBuilderHelperTest.java b/src/test/java/fr/xephi/authme/process/register/executors/PlayerAuthBuilderHelperTest.java index cbe460dfb9..97d1b52ac2 100644 --- a/src/test/java/fr/xephi/authme/process/register/executors/PlayerAuthBuilderHelperTest.java +++ b/src/test/java/fr/xephi/authme/process/register/executors/PlayerAuthBuilderHelperTest.java @@ -10,7 +10,7 @@ import static fr.xephi.authme.AuthMeMatchers.hasAuthBasicData; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.lessThan; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; diff --git a/src/test/java/fr/xephi/authme/process/unregister/AsynchronousUnregisterTest.java b/src/test/java/fr/xephi/authme/process/unregister/AsynchronousUnregisterTest.java index 99d736ddab..810d73b94c 100644 --- a/src/test/java/fr/xephi/authme/process/unregister/AsynchronousUnregisterTest.java +++ b/src/test/java/fr/xephi/authme/process/unregister/AsynchronousUnregisterTest.java @@ -32,7 +32,7 @@ import static fr.xephi.authme.service.BukkitServiceTestHelper.setBukkitServiceToScheduleSyncTaskFromOptionallyAsyncTask; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; @@ -115,6 +115,7 @@ public void shouldPerformUnregister() { given(service.getProperty(RegistrationSettings.APPLY_BLIND_EFFECT)).willReturn(true); given(service.getProperty(RestrictionSettings.TIMEOUT)).willReturn(21); setBukkitServiceToScheduleSyncTaskFromOptionallyAsyncTask(bukkitService); + given(bukkitService.createBlindnessEffect(21 * 20)).willReturn(mock(PotionEffect.class)); // when asynchronousUnregister.unregister(player, userPassword); @@ -127,7 +128,6 @@ public void shouldPerformUnregister() { verify(teleportationService).teleportOnJoin(player); verifyCalledUnregisterEventFor(player); verify(commandManager).runCommandsOnUnregister(player); - verify(player).addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 21 * 20, 2)); } @Test diff --git a/src/test/java/fr/xephi/authme/security/HashAlgorithmIntegrationTest.java b/src/test/java/fr/xephi/authme/security/HashAlgorithmIntegrationTest.java index 8ebcbda1e5..7af6c38bf1 100644 --- a/src/test/java/fr/xephi/authme/security/HashAlgorithmIntegrationTest.java +++ b/src/test/java/fr/xephi/authme/security/HashAlgorithmIntegrationTest.java @@ -21,7 +21,7 @@ import java.util.Set; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.fail; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; diff --git a/src/test/java/fr/xephi/authme/security/HashUtilsTest.java b/src/test/java/fr/xephi/authme/security/HashUtilsTest.java index 16cba7043f..37c2b8aa37 100644 --- a/src/test/java/fr/xephi/authme/security/HashUtilsTest.java +++ b/src/test/java/fr/xephi/authme/security/HashUtilsTest.java @@ -8,7 +8,7 @@ import static org.hamcrest.Matchers.contains; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Test for {@link HashUtils}. diff --git a/src/test/java/fr/xephi/authme/security/PasswordSecurityTest.java b/src/test/java/fr/xephi/authme/security/PasswordSecurityTest.java index aa3165e767..50ae5ee015 100644 --- a/src/test/java/fr/xephi/authme/security/PasswordSecurityTest.java +++ b/src/test/java/fr/xephi/authme/security/PasswordSecurityTest.java @@ -34,7 +34,7 @@ import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalToIgnoringCase; import static org.hamcrest.Matchers.instanceOf; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.BDDMockito.given; diff --git a/src/test/java/fr/xephi/authme/security/crypts/AbstractEncryptionMethodTest.java b/src/test/java/fr/xephi/authme/security/crypts/AbstractEncryptionMethodTest.java index 6a96425fc8..8789cde63b 100644 --- a/src/test/java/fr/xephi/authme/security/crypts/AbstractEncryptionMethodTest.java +++ b/src/test/java/fr/xephi/authme/security/crypts/AbstractEncryptionMethodTest.java @@ -13,7 +13,7 @@ import static org.hamcrest.Matchers.equalTo; import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.assertTrue; import static org.junit.Assume.assumeThat; diff --git a/src/test/java/fr/xephi/authme/security/crypts/BCrypt2yTest.java b/src/test/java/fr/xephi/authme/security/crypts/BCrypt2yTest.java index f34bac6224..a8cdabdc6a 100644 --- a/src/test/java/fr/xephi/authme/security/crypts/BCrypt2yTest.java +++ b/src/test/java/fr/xephi/authme/security/crypts/BCrypt2yTest.java @@ -4,7 +4,7 @@ import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.Matchers.startsWith; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Test for {@link BCrypt2y}. diff --git a/src/test/java/fr/xephi/authme/security/crypts/BCryptTest.java b/src/test/java/fr/xephi/authme/security/crypts/BCryptTest.java index 9c3946f1c5..093621a159 100644 --- a/src/test/java/fr/xephi/authme/security/crypts/BCryptTest.java +++ b/src/test/java/fr/xephi/authme/security/crypts/BCryptTest.java @@ -5,7 +5,7 @@ import org.junit.Test; import static org.hamcrest.Matchers.startsWith; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; 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 d019f3d791..4ea5addf04 100644 --- a/src/test/java/fr/xephi/authme/security/crypts/Ipb4Test.java +++ b/src/test/java/fr/xephi/authme/security/crypts/Ipb4Test.java @@ -5,7 +5,7 @@ import static fr.xephi.authme.AuthMeMatchers.stringWithLength; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.startsWith; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.fail; /** diff --git a/src/test/java/fr/xephi/authme/security/crypts/Pbkdf2Test.java b/src/test/java/fr/xephi/authme/security/crypts/Pbkdf2Test.java index 8296e56ea0..0d5674cdc4 100644 --- a/src/test/java/fr/xephi/authme/security/crypts/Pbkdf2Test.java +++ b/src/test/java/fr/xephi/authme/security/crypts/Pbkdf2Test.java @@ -5,7 +5,7 @@ import org.junit.Test; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; diff --git a/src/test/java/fr/xephi/authme/security/crypts/SmfTest.java b/src/test/java/fr/xephi/authme/security/crypts/SmfTest.java index 442d5194cd..2750574e1f 100644 --- a/src/test/java/fr/xephi/authme/security/crypts/SmfTest.java +++ b/src/test/java/fr/xephi/authme/security/crypts/SmfTest.java @@ -4,7 +4,7 @@ import static fr.xephi.authme.AuthMeMatchers.stringWithLength; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Test for {@link Smf}. diff --git a/src/test/java/fr/xephi/authme/security/crypts/TwoFactorTest.java b/src/test/java/fr/xephi/authme/security/crypts/TwoFactorTest.java index cdc2526704..da764e6062 100644 --- a/src/test/java/fr/xephi/authme/security/crypts/TwoFactorTest.java +++ b/src/test/java/fr/xephi/authme/security/crypts/TwoFactorTest.java @@ -5,7 +5,7 @@ import org.junit.Test; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Test for {@link TwoFactor}. diff --git a/src/test/java/fr/xephi/authme/security/crypts/XfBCryptTest.java b/src/test/java/fr/xephi/authme/security/crypts/XfBCryptTest.java index 982f5d488d..0459d9b0cb 100644 --- a/src/test/java/fr/xephi/authme/security/crypts/XfBCryptTest.java +++ b/src/test/java/fr/xephi/authme/security/crypts/XfBCryptTest.java @@ -4,7 +4,7 @@ import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.Matchers.startsWith; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Test for {@link XfBCrypt}. diff --git a/src/test/java/fr/xephi/authme/security/totp/GenerateTotpServiceTest.java b/src/test/java/fr/xephi/authme/security/totp/GenerateTotpServiceTest.java index 3778cc1009..b17d26bb79 100644 --- a/src/test/java/fr/xephi/authme/security/totp/GenerateTotpServiceTest.java +++ b/src/test/java/fr/xephi/authme/security/totp/GenerateTotpServiceTest.java @@ -14,7 +14,7 @@ import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.nullValue; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; diff --git a/src/test/java/fr/xephi/authme/security/totp/TotpAuthenticatorTest.java b/src/test/java/fr/xephi/authme/security/totp/TotpAuthenticatorTest.java index 8df9940849..52974238da 100644 --- a/src/test/java/fr/xephi/authme/security/totp/TotpAuthenticatorTest.java +++ b/src/test/java/fr/xephi/authme/security/totp/TotpAuthenticatorTest.java @@ -20,7 +20,7 @@ import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.not; import static org.hamcrest.Matchers.startsWith; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; diff --git a/src/test/java/fr/xephi/authme/service/AntiBotServiceTest.java b/src/test/java/fr/xephi/authme/service/AntiBotServiceTest.java index 6437925476..f26847d386 100644 --- a/src/test/java/fr/xephi/authme/service/AntiBotServiceTest.java +++ b/src/test/java/fr/xephi/authme/service/AntiBotServiceTest.java @@ -22,7 +22,7 @@ import static fr.xephi.authme.service.BukkitServiceTestHelper.setBukkitServiceToScheduleSyncDelayedTaskWithDelay; import static fr.xephi.authme.service.BukkitServiceTestHelper.setBukkitServiceToScheduleSyncTaskFromOptionallyAsyncTask; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyLong; import static org.mockito.BDDMockito.given; diff --git a/src/test/java/fr/xephi/authme/service/BukkitServiceTest.java b/src/test/java/fr/xephi/authme/service/BukkitServiceTest.java index 2e6ee72c74..cecdda92f2 100644 --- a/src/test/java/fr/xephi/authme/service/BukkitServiceTest.java +++ b/src/test/java/fr/xephi/authme/service/BukkitServiceTest.java @@ -22,7 +22,7 @@ import org.mockito.junit.MockitoJUnitRunner; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.doReturn; diff --git a/src/test/java/fr/xephi/authme/service/CommonServiceTest.java b/src/test/java/fr/xephi/authme/service/CommonServiceTest.java index b74762dc26..309e996260 100644 --- a/src/test/java/fr/xephi/authme/service/CommonServiceTest.java +++ b/src/test/java/fr/xephi/authme/service/CommonServiceTest.java @@ -16,7 +16,7 @@ import org.mockito.junit.MockitoJUnitRunner; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; diff --git a/src/test/java/fr/xephi/authme/service/GeoIpServiceTest.java b/src/test/java/fr/xephi/authme/service/GeoIpServiceTest.java index 351049a806..329f973414 100644 --- a/src/test/java/fr/xephi/authme/service/GeoIpServiceTest.java +++ b/src/test/java/fr/xephi/authme/service/GeoIpServiceTest.java @@ -1,8 +1,17 @@ package fr.xephi.authme.service; -import com.maxmind.db.GeoIp2Provider; -import com.maxmind.db.model.Country; -import com.maxmind.db.model.CountryResponse; +import java.io.File; +import java.io.IOException; +import java.net.InetAddress; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +import com.google.common.collect.ImmutableMap; +import com.maxmind.geoip2.DatabaseReader; +import com.maxmind.geoip2.model.CountryResponse; +import com.maxmind.geoip2.record.Continent; +import com.maxmind.geoip2.record.Country; import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.properties.ProtectionSettings; import org.junit.Before; @@ -13,14 +22,11 @@ import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; -import java.io.File; -import java.io.IOException; -import java.net.InetAddress; - -import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.BDDMockito.given; + +import static org.hamcrest.Matchers.equalTo; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; @@ -33,10 +39,9 @@ public class GeoIpServiceTest { private GeoIpService geoIpService; - private File dataFolder; @Mock - private GeoIp2Provider lookupService; + private DatabaseReader lookupService; @Mock private BukkitService bukkitService; @@ -49,7 +54,7 @@ public class GeoIpServiceTest { @Before public void initializeGeoLiteApi() throws IOException { - dataFolder = temporaryFolder.newFolder(); + File dataFolder = temporaryFolder.newFolder(); geoIpService = new GeoIpService(dataFolder, bukkitService, settings, lookupService); } @@ -58,13 +63,8 @@ public void shouldGetCountry() throws Exception { // given InetAddress ip = InetAddress.getByName("123.45.67.89"); String countryCode = "XX"; - - Country country = mock(Country.class); - given(country.getIsoCode()).willReturn(countryCode); - - CountryResponse response = mock(CountryResponse.class); - given(response.getCountry()).willReturn(country); - given(lookupService.getCountry(ip)).willReturn(response); + CountryResponse response = createCountryResponse(countryCode, "Unknown"); + given(lookupService.country(ip)).willReturn(response); given(settings.getProperty(ProtectionSettings.ENABLE_GEOIP)).willReturn(true); // when @@ -72,7 +72,7 @@ public void shouldGetCountry() throws Exception { // then assertThat(result, equalTo(countryCode)); - verify(lookupService).getCountry(ip); + verify(lookupService).country(ip); } @Test @@ -85,7 +85,7 @@ public void shouldNotLookUpCountryForLocalhostIp() throws Exception { // then assertThat(result, equalTo("LOCALHOST")); - verify(lookupService, never()).getCountry(any()); + verify(lookupService, never()).country(any()); } @Test @@ -93,13 +93,8 @@ public void shouldLookUpCountryName() throws Exception { // given InetAddress ip = InetAddress.getByName("24.45.167.89"); String countryName = "Ecuador"; - - Country country = mock(Country.class); - given(country.getName()).willReturn(countryName); - - CountryResponse response = mock(CountryResponse.class); - given(response.getCountry()).willReturn(country); - given(lookupService.getCountry(ip)).willReturn(response); + CountryResponse response = createCountryResponse("EC", countryName); + given(lookupService.country(ip)).willReturn(response); given(settings.getProperty(ProtectionSettings.ENABLE_GEOIP)).willReturn(true); // when @@ -107,7 +102,7 @@ public void shouldLookUpCountryName() throws Exception { // then assertThat(result, equalTo(countryName)); - verify(lookupService).getCountry(ip); + verify(lookupService).country(ip); } @Test @@ -120,7 +115,7 @@ public void shouldNotLookUpCountryNameForLocalhostIp() throws Exception { // then assertThat(result, equalTo("LocalHost")); - verify(lookupService, never()).getCountry(ip); + verify(lookupService, never()).country(ip); } @Test @@ -136,4 +131,13 @@ public void shouldNotLookUpCountryNameIfDisabled() throws Exception { assertThat(result, equalTo("N/A")); verifyNoInteractions(lookupService); } + + private static CountryResponse createCountryResponse(String countryCode, String countryName) { + List locales = Collections.singletonList("en"); + Continent continent = new Continent(locales, "XX", 1L, Collections.emptyMap()); + + Map countryNames = ImmutableMap.of("en", countryName); + Country country = new Country(locales, 100, 3L, false, countryCode, countryNames); + return new CountryResponse(continent, country, null, country, null, null); + } } diff --git a/src/test/java/fr/xephi/authme/service/HelpTranslationGeneratorIntegrationTest.java b/src/test/java/fr/xephi/authme/service/HelpTranslationGeneratorIntegrationTest.java index 3e094cc2bd..0b4329e511 100644 --- a/src/test/java/fr/xephi/authme/service/HelpTranslationGeneratorIntegrationTest.java +++ b/src/test/java/fr/xephi/authme/service/HelpTranslationGeneratorIntegrationTest.java @@ -29,7 +29,7 @@ import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.nullValue; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.fail; import static org.mockito.BDDMockito.given; diff --git a/src/test/java/fr/xephi/authme/service/MigrationServiceTest.java b/src/test/java/fr/xephi/authme/service/MigrationServiceTest.java index ec989a0429..e43a0449fa 100644 --- a/src/test/java/fr/xephi/authme/service/MigrationServiceTest.java +++ b/src/test/java/fr/xephi/authme/service/MigrationServiceTest.java @@ -19,7 +19,7 @@ import static fr.xephi.authme.AuthMeMatchers.equalToHash; import static org.hamcrest.Matchers.equalToIgnoringCase; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.BDDMockito.given; diff --git a/src/test/java/fr/xephi/authme/service/PasswordRecoveryServiceTest.java b/src/test/java/fr/xephi/authme/service/PasswordRecoveryServiceTest.java index bf3dd083f4..a89885a03b 100644 --- a/src/test/java/fr/xephi/authme/service/PasswordRecoveryServiceTest.java +++ b/src/test/java/fr/xephi/authme/service/PasswordRecoveryServiceTest.java @@ -16,7 +16,7 @@ import org.mockito.Mock; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; diff --git a/src/test/java/fr/xephi/authme/service/PluginHookServiceTest.java b/src/test/java/fr/xephi/authme/service/PluginHookServiceTest.java index d949db7dd2..ef1d019f4b 100644 --- a/src/test/java/fr/xephi/authme/service/PluginHookServiceTest.java +++ b/src/test/java/fr/xephi/authme/service/PluginHookServiceTest.java @@ -20,7 +20,7 @@ import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.nullValue; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.doThrow; diff --git a/src/test/java/fr/xephi/authme/service/RecoveryCodeServiceTest.java b/src/test/java/fr/xephi/authme/service/RecoveryCodeServiceTest.java index 9641db9a03..0ec71f5ca0 100644 --- a/src/test/java/fr/xephi/authme/service/RecoveryCodeServiceTest.java +++ b/src/test/java/fr/xephi/authme/service/RecoveryCodeServiceTest.java @@ -14,7 +14,7 @@ import static fr.xephi.authme.AuthMeMatchers.stringWithLength; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.nullValue; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.BDDMockito.given; /** diff --git a/src/test/java/fr/xephi/authme/service/SessionServiceTest.java b/src/test/java/fr/xephi/authme/service/SessionServiceTest.java index 7153f14986..f67b51854b 100644 --- a/src/test/java/fr/xephi/authme/service/SessionServiceTest.java +++ b/src/test/java/fr/xephi/authme/service/SessionServiceTest.java @@ -18,7 +18,7 @@ import java.util.function.Function; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; diff --git a/src/test/java/fr/xephi/authme/service/TeleportationServiceTest.java b/src/test/java/fr/xephi/authme/service/TeleportationServiceTest.java index 46db5e05ca..7041a1e3e7 100644 --- a/src/test/java/fr/xephi/authme/service/TeleportationServiceTest.java +++ b/src/test/java/fr/xephi/authme/service/TeleportationServiceTest.java @@ -23,7 +23,7 @@ import static fr.xephi.authme.service.BukkitServiceTestHelper.setBukkitServiceToScheduleSyncTaskFromOptionallyAsyncTask; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.BDDMockito.given; diff --git a/src/test/java/fr/xephi/authme/service/ValidationServiceTest.java b/src/test/java/fr/xephi/authme/service/ValidationServiceTest.java index da8f16326e..7ca60c0a57 100644 --- a/src/test/java/fr/xephi/authme/service/ValidationServiceTest.java +++ b/src/test/java/fr/xephi/authme/service/ValidationServiceTest.java @@ -31,7 +31,7 @@ import static java.util.Arrays.asList; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.willReturn; diff --git a/src/test/java/fr/xephi/authme/service/yaml/YamlFileResourceProviderTest.java b/src/test/java/fr/xephi/authme/service/yaml/YamlFileResourceProviderTest.java index 3b6bbddbbf..97dcd99e34 100644 --- a/src/test/java/fr/xephi/authme/service/yaml/YamlFileResourceProviderTest.java +++ b/src/test/java/fr/xephi/authme/service/yaml/YamlFileResourceProviderTest.java @@ -9,7 +9,7 @@ import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.instanceOf; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.fail; /** diff --git a/src/test/java/fr/xephi/authme/settings/SettingsIntegrationTest.java b/src/test/java/fr/xephi/authme/settings/SettingsIntegrationTest.java index e9a58c6771..17e4149435 100644 --- a/src/test/java/fr/xephi/authme/settings/SettingsIntegrationTest.java +++ b/src/test/java/fr/xephi/authme/settings/SettingsIntegrationTest.java @@ -25,7 +25,7 @@ import static fr.xephi.authme.TestHelper.getJarFile; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Integration test for {@link Settings} (ConfigMe integration). diff --git a/src/test/java/fr/xephi/authme/settings/SettingsMigrationServiceTest.java b/src/test/java/fr/xephi/authme/settings/SettingsMigrationServiceTest.java index 021bfb93b6..d1d7b8bf85 100644 --- a/src/test/java/fr/xephi/authme/settings/SettingsMigrationServiceTest.java +++ b/src/test/java/fr/xephi/authme/settings/SettingsMigrationServiceTest.java @@ -39,7 +39,7 @@ import static fr.xephi.authme.settings.properties.SecuritySettings.PASSWORD_HASH; import static org.hamcrest.Matchers.contains; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Test for {@link SettingsMigrationService}. diff --git a/src/test/java/fr/xephi/authme/settings/SettingsTest.java b/src/test/java/fr/xephi/authme/settings/SettingsTest.java index 73d3cc8d6c..fa78014a64 100644 --- a/src/test/java/fr/xephi/authme/settings/SettingsTest.java +++ b/src/test/java/fr/xephi/authme/settings/SettingsTest.java @@ -18,7 +18,7 @@ import java.util.Collections; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.RETURNS_DEEP_STUBS; @@ -28,7 +28,7 @@ * Unit tests for {@link Settings}. */ public class SettingsTest { - + private static final ConfigurationData CONFIG_DATA = ConfigurationDataBuilder.createConfiguration(TestConfiguration.class); diff --git a/src/test/java/fr/xephi/authme/settings/SpawnLoaderTest.java b/src/test/java/fr/xephi/authme/settings/SpawnLoaderTest.java index edd561925e..9644403be6 100644 --- a/src/test/java/fr/xephi/authme/settings/SpawnLoaderTest.java +++ b/src/test/java/fr/xephi/authme/settings/SpawnLoaderTest.java @@ -21,7 +21,7 @@ import java.io.IOException; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; diff --git a/src/test/java/fr/xephi/authme/settings/WelcomeMessageConfigurationTest.java b/src/test/java/fr/xephi/authme/settings/WelcomeMessageConfigurationTest.java index 3415a95077..4daad61f1f 100644 --- a/src/test/java/fr/xephi/authme/settings/WelcomeMessageConfigurationTest.java +++ b/src/test/java/fr/xephi/authme/settings/WelcomeMessageConfigurationTest.java @@ -29,7 +29,7 @@ import static org.hamcrest.Matchers.contains; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.hasSize; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verifyNoInteractions; diff --git a/src/test/java/fr/xephi/authme/settings/commandconfig/CommandMigrationServiceTest.java b/src/test/java/fr/xephi/authme/settings/commandconfig/CommandMigrationServiceTest.java index 800bcc0524..8a146a5544 100644 --- a/src/test/java/fr/xephi/authme/settings/commandconfig/CommandMigrationServiceTest.java +++ b/src/test/java/fr/xephi/authme/settings/commandconfig/CommandMigrationServiceTest.java @@ -25,7 +25,7 @@ import static org.hamcrest.Matchers.aMapWithSize; import static org.hamcrest.Matchers.containsInAnyOrder; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.BDDMockito.given; /** diff --git a/src/test/java/fr/xephi/authme/settings/commandconfig/CommandYmlConsistencyTest.java b/src/test/java/fr/xephi/authme/settings/commandconfig/CommandYmlConsistencyTest.java index 99b4d615be..8cccc34387 100644 --- a/src/test/java/fr/xephi/authme/settings/commandconfig/CommandYmlConsistencyTest.java +++ b/src/test/java/fr/xephi/authme/settings/commandconfig/CommandYmlConsistencyTest.java @@ -16,7 +16,7 @@ import java.io.File; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.Mockito.verify; /** diff --git a/src/test/java/fr/xephi/authme/settings/properties/AuthMeSettingsRetrieverTest.java b/src/test/java/fr/xephi/authme/settings/properties/AuthMeSettingsRetrieverTest.java index 35ab9627a7..f119e109d8 100644 --- a/src/test/java/fr/xephi/authme/settings/properties/AuthMeSettingsRetrieverTest.java +++ b/src/test/java/fr/xephi/authme/settings/properties/AuthMeSettingsRetrieverTest.java @@ -4,7 +4,7 @@ import org.junit.Test; import static org.hamcrest.Matchers.closeTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Test for {@link AuthMeSettingsRetriever}. diff --git a/src/test/java/fr/xephi/authme/settings/properties/SettingsClassConsistencyTest.java b/src/test/java/fr/xephi/authme/settings/properties/SettingsClassConsistencyTest.java index 178576bc17..1561d4d425 100644 --- a/src/test/java/fr/xephi/authme/settings/properties/SettingsClassConsistencyTest.java +++ b/src/test/java/fr/xephi/authme/settings/properties/SettingsClassConsistencyTest.java @@ -18,7 +18,7 @@ import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.hasSize; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.fail; /** diff --git a/src/test/java/fr/xephi/authme/task/purge/PurgeServiceTest.java b/src/test/java/fr/xephi/authme/task/purge/PurgeServiceTest.java index 8823f1aa17..d13450c264 100644 --- a/src/test/java/fr/xephi/authme/task/purge/PurgeServiceTest.java +++ b/src/test/java/fr/xephi/authme/task/purge/PurgeServiceTest.java @@ -31,7 +31,7 @@ import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.greaterThan; import static org.hamcrest.Matchers.not; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.ArgumentMatchers.anyCollection; import static org.mockito.ArgumentMatchers.anyLong; import static org.mockito.ArgumentMatchers.eq; diff --git a/src/test/java/fr/xephi/authme/task/purge/PurgeTaskTest.java b/src/test/java/fr/xephi/authme/task/purge/PurgeTaskTest.java index 2ecf6a13a2..2863fa4df4 100644 --- a/src/test/java/fr/xephi/authme/task/purge/PurgeTaskTest.java +++ b/src/test/java/fr/xephi/authme/task/purge/PurgeTaskTest.java @@ -35,7 +35,7 @@ import static org.hamcrest.Matchers.containsInAnyOrder; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.empty; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; diff --git a/src/test/java/fr/xephi/authme/util/ExceptionUtilsTest.java b/src/test/java/fr/xephi/authme/util/ExceptionUtilsTest.java index b42fa97f7b..4eb8ef71ff 100644 --- a/src/test/java/fr/xephi/authme/util/ExceptionUtilsTest.java +++ b/src/test/java/fr/xephi/authme/util/ExceptionUtilsTest.java @@ -9,7 +9,7 @@ import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.Matchers.sameInstance; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Test for {@link ExceptionUtils}. diff --git a/src/test/java/fr/xephi/authme/util/FileUtilsTest.java b/src/test/java/fr/xephi/authme/util/FileUtilsTest.java index 36af67242a..fa5b9ccc66 100644 --- a/src/test/java/fr/xephi/authme/util/FileUtilsTest.java +++ b/src/test/java/fr/xephi/authme/util/FileUtilsTest.java @@ -14,7 +14,7 @@ import static org.hamcrest.Matchers.matchesPattern; import static org.hamcrest.Matchers.not; import static org.hamcrest.Matchers.nullValue; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Test for {@link FileUtils}. diff --git a/src/test/java/fr/xephi/authme/util/InternetProtocolUtilsTest.java b/src/test/java/fr/xephi/authme/util/InternetProtocolUtilsTest.java index 54bc7dcbaa..9fa11a255a 100644 --- a/src/test/java/fr/xephi/authme/util/InternetProtocolUtilsTest.java +++ b/src/test/java/fr/xephi/authme/util/InternetProtocolUtilsTest.java @@ -3,7 +3,7 @@ import org.junit.Test; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Test for {@link InternetProtocolUtils} diff --git a/src/test/java/fr/xephi/authme/util/PlayerUtilsTest.java b/src/test/java/fr/xephi/authme/util/PlayerUtilsTest.java index 69d7b1f0de..9330c7af29 100644 --- a/src/test/java/fr/xephi/authme/util/PlayerUtilsTest.java +++ b/src/test/java/fr/xephi/authme/util/PlayerUtilsTest.java @@ -6,7 +6,7 @@ import org.junit.Test; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; diff --git a/src/test/java/fr/xephi/authme/util/RandomStringUtilsTest.java b/src/test/java/fr/xephi/authme/util/RandomStringUtilsTest.java index a89b4922da..956a54ec90 100644 --- a/src/test/java/fr/xephi/authme/util/RandomStringUtilsTest.java +++ b/src/test/java/fr/xephi/authme/util/RandomStringUtilsTest.java @@ -5,7 +5,7 @@ import java.util.regex.Pattern; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Test for {@link RandomStringUtils}. diff --git a/src/test/java/fr/xephi/authme/util/StringUtilsTest.java b/src/test/java/fr/xephi/authme/util/StringUtilsTest.java index fcd000d951..d4e41ca40d 100644 --- a/src/test/java/fr/xephi/authme/util/StringUtilsTest.java +++ b/src/test/java/fr/xephi/authme/util/StringUtilsTest.java @@ -6,7 +6,7 @@ import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.greaterThan; import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.assertTrue; /** diff --git a/src/test/java/fr/xephi/authme/util/UtilsTest.java b/src/test/java/fr/xephi/authme/util/UtilsTest.java index 37d52163d9..5475274a36 100644 --- a/src/test/java/fr/xephi/authme/util/UtilsTest.java +++ b/src/test/java/fr/xephi/authme/util/UtilsTest.java @@ -16,7 +16,7 @@ import java.util.regex.Pattern; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoInteractions; diff --git a/src/test/java/fr/xephi/authme/util/UuidUtilsTest.java b/src/test/java/fr/xephi/authme/util/UuidUtilsTest.java index b98bdba994..fd94e2a373 100644 --- a/src/test/java/fr/xephi/authme/util/UuidUtilsTest.java +++ b/src/test/java/fr/xephi/authme/util/UuidUtilsTest.java @@ -6,7 +6,7 @@ import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.nullValue; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Test for {@link UuidUtils}. diff --git a/src/test/java/fr/xephi/authme/util/expiring/DurationTest.java b/src/test/java/fr/xephi/authme/util/expiring/DurationTest.java index 03a0f9d471..5577443f0e 100644 --- a/src/test/java/fr/xephi/authme/util/expiring/DurationTest.java +++ b/src/test/java/fr/xephi/authme/util/expiring/DurationTest.java @@ -5,7 +5,7 @@ import java.util.concurrent.TimeUnit; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Test for {@link Duration}. diff --git a/src/test/java/fr/xephi/authme/util/expiring/ExpiringMapTest.java b/src/test/java/fr/xephi/authme/util/expiring/ExpiringMapTest.java index ac9a5a7194..72b2389f93 100644 --- a/src/test/java/fr/xephi/authme/util/expiring/ExpiringMapTest.java +++ b/src/test/java/fr/xephi/authme/util/expiring/ExpiringMapTest.java @@ -8,7 +8,7 @@ import static org.hamcrest.Matchers.containsInAnyOrder; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.nullValue; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Test for {@link ExpiringMap}. diff --git a/src/test/java/fr/xephi/authme/util/expiring/ExpiringSetTest.java b/src/test/java/fr/xephi/authme/util/expiring/ExpiringSetTest.java index 42180ab26d..fe8807ff99 100644 --- a/src/test/java/fr/xephi/authme/util/expiring/ExpiringSetTest.java +++ b/src/test/java/fr/xephi/authme/util/expiring/ExpiringSetTest.java @@ -5,7 +5,7 @@ import java.util.concurrent.TimeUnit; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Test for {@link ExpiringSet}. diff --git a/src/test/java/fr/xephi/authme/util/expiring/TimedCounterTest.java b/src/test/java/fr/xephi/authme/util/expiring/TimedCounterTest.java index c2b65eed31..3bb275f231 100644 --- a/src/test/java/fr/xephi/authme/util/expiring/TimedCounterTest.java +++ b/src/test/java/fr/xephi/authme/util/expiring/TimedCounterTest.java @@ -5,7 +5,7 @@ import java.util.concurrent.TimeUnit; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Test for {@link TimedCounter}. diff --git a/src/test/java/fr/xephi/authme/util/lazytags/TagBuilderTest.java b/src/test/java/fr/xephi/authme/util/lazytags/TagBuilderTest.java index 53362b5ff6..f52ddca1ca 100644 --- a/src/test/java/fr/xephi/authme/util/lazytags/TagBuilderTest.java +++ b/src/test/java/fr/xephi/authme/util/lazytags/TagBuilderTest.java @@ -7,7 +7,7 @@ import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.instanceOf; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Test for {@link TagBuilder}. diff --git a/src/test/java/fr/xephi/authme/util/lazytags/TagReplacerTest.java b/src/test/java/fr/xephi/authme/util/lazytags/TagReplacerTest.java index 8c9a8187f0..9ad3d404ae 100644 --- a/src/test/java/fr/xephi/authme/util/lazytags/TagReplacerTest.java +++ b/src/test/java/fr/xephi/authme/util/lazytags/TagReplacerTest.java @@ -8,7 +8,7 @@ import static fr.xephi.authme.util.lazytags.TagBuilder.createTag; import static org.hamcrest.Matchers.contains; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Test for {@link TagReplacer}. diff --git a/src/test/java/fr/xephi/authme/util/lazytags/WrappedTagReplacerTest.java b/src/test/java/fr/xephi/authme/util/lazytags/WrappedTagReplacerTest.java index 1991505456..6a9a613b47 100644 --- a/src/test/java/fr/xephi/authme/util/lazytags/WrappedTagReplacerTest.java +++ b/src/test/java/fr/xephi/authme/util/lazytags/WrappedTagReplacerTest.java @@ -11,7 +11,7 @@ import static org.hamcrest.Matchers.contains; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Test for {@link WrappedTagReplacer}.