Update to spigot 1.20.5, bump mvn plugin version, require jvm 17, require mvn 3.9, require spigot 1.19, use the spigot runtime dependency download system, use the official maxmind geoip database parser

This commit is contained in:
Gabriele C. 2024-04-26 01:29:21 +02:00
parent a14df80a87
commit 1b69abd09e
7 changed files with 277 additions and 340 deletions

518
pom.xml
View File

@ -60,14 +60,13 @@
<!-- Environment properties -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.source>1.8</java.source>
<java.target>1.8</java.target>
<java.apiVersion>8</java.apiVersion>
<java.compiler.minimumVersion>11</java.compiler.minimumVersion>
<maven.minimumVersion>3.6.3</maven.minimumVersion>
<java.source>17</java.source>
<java.target>17</java.target>
<java.apiVersion>17</java.apiVersion>
<java.compiler.minimumVersion>17</java.compiler.minimumVersion>
<maven.minimumVersion>3.9.0</maven.minimumVersion>
<!-- Dependencies versions -->
<spigot.version>1.19.2-R0.1-SNAPSHOT</spigot.version>
<!-- Versioning properties -->
<project.outputName>AuthMe</project.outputName>
@ -80,6 +79,31 @@
<pluginDescription.version>${project.versionCode}</pluginDescription.version>
<pluginDescription.main>${project.groupId}.${project.artifactId}.${pluginDescription.name}</pluginDescription.main>
<pluginDescription.authors>sgdc3, ljacqu, games647, Hex3l, krusic22</pluginDescription.authors>
<!-- Java libraries -->
<dependencies.injector.version>1.0</dependencies.injector.version>
<dependencies.string-similarity.version>1.0.0</dependencies.string-similarity.version>
<dependencies.geoip2.version>4.2.0</dependencies.geoip2.version>
<dependencies.javatar.version>2.5</dependencies.javatar.version>
<dependencies.commons-email.version>1.6.0</dependencies.commons-email.version>
<dependencies.hikaricp.version>5.1.0</dependencies.hikaricp.version>
<dependencies.slf4j.version>2.0.13</dependencies.slf4j.version>
<dependencies.datasourcecolumns.version>0.1.1-SNAPSHOT</dependencies.datasourcecolumns.version>
<dependencies.mysql-connector-j.version>8.3.0</dependencies.mysql-connector-j.version>
<dependencies.mariadb-java-client.version>3.3.3</dependencies.mariadb-java-client.version>
<dependencies.postgresql.version>42.5.1</dependencies.postgresql.version>
<dependencies.pbkdf2.version>1.1.4</dependencies.pbkdf2.version>
<dependencies.argon2-jvm-nolibs.version>2.11</dependencies.argon2-jvm-nolibs.version>
<dependencies.bcrypt.version>0.9.0</dependencies.bcrypt.version>
<dependencies.googleauth.version>1.5.0</dependencies.googleauth.version>
<dependencies.configme.version>1.4.1</dependencies.configme.version>
<!-- Spigot -->
<dependencies.spigot.version>1.20.5-R0.1-SNAPSHOT</dependencies.spigot.version>
<dependencies.guava.version>31.1-jre</dependencies.guava.version> <!-- version bundled in 1.19.4 -->
<dependencies.gson.version>2.10</dependencies.gson.version> <!-- version bundled in 1.19.4 -->
<dependencies.log4j-core.version>2.19.0</dependencies.log4j-core.version> <!-- version bundled in 1.19.4 -->
<!-- Spigot libraries -->
<dependencies.bstats.version>3.0.2</dependencies.bstats.version>
</properties>
<!-- Jenkins profile -->
@ -154,7 +178,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.4.1</version>
<version>3.6.3</version>
</plugin>
</plugins>
</pluginManagement>
@ -164,7 +188,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.1.0</version>
<version>3.4.1</version>
<executions>
<execution>
<id>enforce-environment</id>
@ -177,7 +201,7 @@
<version>${maven.minimumVersion}</version>
</requireMavenVersion>
<requireJavaVersion>
<version>[11,)</version>
<version>[${java.compiler.minimumVersion},)</version>
</requireJavaVersion>
</rules>
<fail>true</fail>
@ -189,19 +213,19 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>3.2.0</version>
<version>3.3.2</version>
</plugin>
<!-- Include resource files -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.3.0</version>
<version>3.3.1</version>
</plugin>
<!-- Compile and include classes -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<version>3.13.0</version>
<configuration>
<source>${java.source}</source>
<target>${java.target}</target>
@ -212,7 +236,13 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.8</version>
<version>0.8.12</version>
<configuration>
<includes>
<include>fr/xephi/authme/*</include>
<include>fr/xephi/authme/**/*</include>
</includes>
</configuration>
<executions>
<execution>
<id>pre-unit-test</id>
@ -232,11 +262,12 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<version>3.2.5</version>
<configuration>
<!-- Fix java.base opens for new JDK versions -->
<!-- Force the right file encoding during unit testing -->
<!-- Set language to English in order to get consistent results for localized time formatting -->
<argLine>-Dfile.encoding=${project.build.sourceEncoding} -Duser.language=en @{argLine}</argLine>
<argLine>--add-opens=java.base/java.lang=ALL-UNNAMED -Dfile.encoding=${project.build.sourceEncoding} -Duser.language=en @{argLine}</argLine>
<systemPropertyVariables>
<project.skipExtendedHashTests>${project.skipExtendedHashTests}</project.skipExtendedHashTests>
</systemPropertyVariables>
@ -248,7 +279,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.3.0</version>
<version>3.4.1</version>
</plugin>
<!-- Generate a jar containing the source javadoc -->
<plugin>
@ -257,7 +288,7 @@
<configuration>
<finalName>${project.finalNameBase}</finalName>
<!-- In sync with the source/target properties of the maven-compiler-plugin -->
<source>8</source>
<source>${java.source}</source>
</configuration>
<executions>
<execution>
@ -272,7 +303,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.2.1</version>
<version>3.3.1</version>
<configuration>
<finalName>${project.finalNameBase}</finalName>
</configuration>
@ -289,7 +320,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.4.0</version>
<version>3.5.3</version>
<executions>
<execution>
<id>shaded-jar</id>
@ -297,52 +328,6 @@
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<excludes>
<!-- Guava -->
<exclude>com.google.guava:guava</exclude>
<exclude>com.google.guava:failureaccess</exclude>
<exclude>com.google.guava:listenablefuture</exclude>
<exclude>com.google.errorprone:error_prone_annotations</exclude>
<exclude>com.google.j2objc:j2objc-annotations</exclude>
<!-- Gson -->
<exclude>com.google.code.gson:gson</exclude>
</excludes>
</artifactSet>
</configuration>
</execution>
<execution>
<id>shaded-jar-legacy</id>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<finalName>${project.finalNameBase}-legacy</finalName>
<relocations>
<relocation>
<pattern>com.google.common</pattern>
<shadedPattern>fr.xephi.authme.libs.com.google.common</shadedPattern>
</relocation>
<relocation>
<pattern>com.google.thirdparty</pattern>
<shadedPattern>fr.xephi.authme.libs.com.google.thirdparty</shadedPattern>
</relocation>
<relocation>
<pattern>com.google.j2objc</pattern>
<shadedPattern>fr.xephi.authme.libs.com.google.j2objc</shadedPattern>
</relocation>
<relocation>
<pattern>com.google.errorprone</pattern>
<shadedPattern>fr.xephi.authme.libs.com.google.errorprone</shadedPattern>
</relocation>
<relocation>
<pattern>com.google.gson</pattern>
<shadedPattern>fr.xephi.authme.libs.com.google.gson</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
<configuration>
@ -353,87 +338,10 @@
<!-- Use the base jar name, to help server owners download the right jar -->
<finalName>${project.finalNameBase}</finalName>
<!--
Relocate all lib we use in order to fix class loading errors if we use different versions
than already loaded libs
-->
<relocations combine.children="append">
<relocations>
<relocation>
<pattern>ch.jalu</pattern>
<shadedPattern>fr.xephi.authme.libs.ch.jalu</shadedPattern>
</relocation>
<relocation>
<pattern>com.zaxxer.hikari</pattern>
<shadedPattern>fr.xephi.authme.libs.com.zaxxer.hikari</shadedPattern>
</relocation>
<relocation>
<pattern>org.slf4j</pattern>
<shadedPattern>fr.xephi.authme.libs.org.slf4j</shadedPattern>
</relocation>
<relocation>
<pattern>com.maxmind.db</pattern>
<shadedPattern>fr.xephi.authme.libs.com.maxmind.db</shadedPattern>
</relocation>
<relocation>
<pattern>com.ice.tar</pattern>
<shadedPattern>fr.xephi.authme.libs.com.icetar.tar</shadedPattern>
</relocation>
<relocation>
<pattern>net.ricecode.similarity</pattern>
<shadedPattern>fr.xephi.authme.libs.ricecode.net.ricecode.similarity</shadedPattern>
</relocation>
<relocation>
<pattern>de.rtner</pattern>
<shadedPattern>fr.xephi.authme.libs.de.rtner</shadedPattern>
</relocation>
<relocation>
<pattern>org.picketbox</pattern>
<shadedPattern>fr.xephi.authme.libs.org.picketbox</shadedPattern>
</relocation>
<relocation>
<pattern>org.jboss.crypto</pattern>
<shadedPattern>fr.xephi.authme.libs.org.jboss.crypto</shadedPattern>
</relocation>
<relocation>
<pattern>org.jboss.security</pattern>
<shadedPattern>fr.xephi.authme.libs.org.jboss.security</shadedPattern>
</relocation>
<relocation>
<pattern>de.mkammerer</pattern>
<shadedPattern>fr.xephi.authme.libs.de.mkammerer</shadedPattern>
</relocation>
<relocation>
<pattern>com.warrenstrange</pattern>
<shadedPattern>fr.xephi.authme.libs.com.warrenstrange</shadedPattern>
</relocation>
<relocation>
<pattern>javax.inject</pattern>
<shadedPattern>fr.xephi.authme.libs.javax.inject</shadedPattern>
</relocation>
<relocation>
<pattern>at.favre.lib</pattern>
<shadedPattern>fr.xephi.authme.libs.at.favre.lib</shadedPattern>
</relocation>
<relocation>
<pattern>org.postgresql</pattern>
<shadedPattern>fr.xephi.authme.libs.org.postgresql</shadedPattern>
</relocation>
<!-- bStats metrics class -->
<relocation>
<pattern>org.bstats</pattern>
<shadedPattern>fr.xephi.authme.libs.org.bstats</shadedPattern>
</relocation>
<relocation>
<pattern>org.mariadb.jdbc</pattern>
<shadedPattern>fr.xephi.authme.libs.org.mariadb.jdbc</shadedPattern>
</relocation>
<relocation>
<pattern>com.mysql</pattern>
<shadedPattern>fr.xephi.authme.libs.com.mysql</shadedPattern>
</relocation>
<relocation>
<pattern>com.google.protobuf</pattern>
<shadedPattern>fr.xephi.authme.libs.com.google.protobuf</shadedPattern>
<pattern>ch.jalu.datasourcecolumns</pattern>
<shadedPattern>fr.xephi.authme.libs.ch.jalu.datasourcecolumns</shadedPattern>
</relocation>
</relocations>
@ -467,13 +375,13 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>3.0.1</version>
<version>3.1.1</version>
</plugin>
<!-- Deploy the jars as artifacts into the remote repository -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.0.0</version>
<version>3.1.1</version>
</plugin>
<!-- Handle documentation generation, required by other plugins -->
<plugin>
@ -602,54 +510,39 @@
<dependency>
<groupId>ch.jalu</groupId>
<artifactId>injector</artifactId>
<version>1.0</version>
<optional>true</optional>
<version>${dependencies.injector.version}</version>
<scope>provided</scope>
</dependency>
<!-- String comparison library. Used for dynamic help system. -->
<dependency>
<groupId>net.ricecode</groupId>
<artifactId>string-similarity</artifactId>
<version>1.0.0</version>
<optional>true</optional>
<version>${dependencies.string-similarity.version}</version>
<scope>provided</scope>
</dependency>
<!-- MaxMind GEO IP with our modifications to use GSON in replacement of the big Jackson dependency -->
<!-- GSON is already included and therefore it reduces the file size in comparison to the original version -->
<!-- MaxMind GEO IP -->
<dependency>
<groupId>com.maxmind.db</groupId>
<artifactId>maxmind-db-gson</artifactId>
<version>2.0.3</version>
<optional>true</optional>
<exclusions>
<exclusion>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</exclusion>
</exclusions>
<groupId>com.maxmind.geoip2</groupId>
<artifactId>geoip2</artifactId>
<version>${dependencies.geoip2.version}</version>
<scope>provided</scope>
</dependency>
<!-- Library for tar archives -->
<dependency>
<groupId>javatar</groupId>
<artifactId>javatar</artifactId>
<version>2.5</version>
<optional>true</optional>
<version>${dependencies.javatar.version}</version>
<scope>provided</scope>
</dependency>
<!-- Java Email Library -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-email</artifactId>
<version>1.6-SNAPSHOT</version>
<optional>true</optional>
</dependency>
<!-- Log4J Logger (required by the console filter) -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.8.1</version> <!-- Log4J version bundled in 1.12.2 -->
<version>${dependencies.commons-email.version}</version>
<scope>provided</scope>
</dependency>
@ -657,88 +550,62 @@
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<version>4.0.3</version> <!-- Latest java 8 release -->
<optional>true</optional>
<exclusions>
<exclusion>
<artifactId>slf4j-api</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
</exclusions>
</dependency>
<!-- HikariCP Logger -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.36</version> <!-- We can't update to 2.x as long as we use HikariCP for java 8 -->
<optional>true</optional>
</dependency>
<!-- PBKDF2 implementation -->
<dependency>
<groupId>de.rtner</groupId>
<artifactId>PBKDF2</artifactId>
<version>1.1.4</version>
<optional>true</optional>
</dependency>
<!-- MySQL connector, shaded into the legacy jar -->
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<version>8.0.31</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>3.0.8</version>
<optional>true</optional>
</dependency>
<!-- Argon2 implementation -->
<dependency>
<groupId>de.mkammerer</groupId>
<artifactId>argon2-jvm-nolibs</artifactId>
<version>2.11</version>
<optional>true</optional>
</dependency>
<!-- TOTP client -->
<dependency>
<groupId>com.warrenstrange</groupId>
<artifactId>googleauth</artifactId>
<version>1.5.0</version>
<optional>true</optional>
</dependency>
<!-- Spigot API, https://www.spigotmc.org/ -->
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>${spigot.version}</version>
<version>${dependencies.hikaricp.version}</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<artifactId>junit</artifactId>
<groupId>junit</groupId>
</exclusion>
<exclusion>
<artifactId>bungeecord-chat</artifactId>
<groupId>net.md-5</groupId>
</exclusion>
<exclusion>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Keep in sync with spigot 1.19 -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>31.0.1-jre</version>
<optional>true</optional>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>${dependencies.slf4j.version}</version>
<scope>provided</scope>
</dependency>
<!-- Data source columns -->
<dependency>
<groupId>ch.jalu</groupId>
<artifactId>datasourcecolumns</artifactId>
<version>${dependencies.datasourcecolumns.version}</version>
<!-- We need to shade it as it is not published on Maven Central -->
</dependency>
<!-- MySQL connector -->
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<version>${dependencies.mysql-connector-j.version}</version>
<scope>provided</scope>
</dependency>
<!-- MariaDB connector -->
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>${dependencies.mariadb-java-client.version}</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>org.checkerframework</groupId>
<artifactId>checker-qual</artifactId>
</exclusion>
<exclusion>
<groupId>com.google.errorprone</groupId>
<artifactId>error_prone_annotations</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- PostgreSQL -->
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>${dependencies.postgresql.version}</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>org.checkerframework</groupId>
@ -746,43 +613,112 @@
</exclusion>
</exclusions>
</dependency>
<!-- Keep in sync with spigot 1.19 -->
<!-- PBKDF2 implementation -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.9</version>
<optional>true</optional>
<groupId>de.rtner</groupId>
<artifactId>PBKDF2</artifactId>
<version>${dependencies.pbkdf2.version}</version>
<scope>provided</scope>
</dependency>
<!-- Bukkit Libraries -->
<!-- Argon2 implementation -->
<dependency>
<groupId>de.mkammerer</groupId>
<artifactId>argon2-jvm-nolibs</artifactId>
<version>${dependencies.argon2-jvm-nolibs.version}</version>
<scope>provided</scope>
</dependency>
<!-- BCrypt implementation -->
<dependency>
<groupId>at.favre.lib</groupId>
<artifactId>bcrypt</artifactId>
<version>${dependencies.bcrypt.version}</version>
<scope>provided</scope>
</dependency>
<!-- TOTP client -->
<dependency>
<groupId>com.warrenstrange</groupId>
<artifactId>googleauth</artifactId>
<version>${dependencies.googleauth.version}</version>
<scope>provided</scope>
</dependency>
<!-- ConfigMe -->
<dependency>
<groupId>ch.jalu</groupId>
<artifactId>configme</artifactId>
<version>1.3.0</version>
<optional>true</optional>
<version>${dependencies.configme.version}</version>
<scope>provided</scope>
</dependency>
<!-- Spigot API, https://www.spigotmc.org/ -->
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>${dependencies.spigot.version}</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</exclusion>
<exclusion>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</exclusion>
<exclusion>
<groupId>org.joml</groupId>
<artifactId>joml</artifactId>
</exclusion>
<exclusion>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-chat</artifactId>
</exclusion>
<exclusion>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>${dependencies.guava.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>${dependencies.gson.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${dependencies.log4j-core.version}</version>
<scope>provided</scope>
</dependency>
<!-- Bukkit Libraries -->
<!-- bStats metrics -->
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-bukkit</artifactId>
<version>3.0.0</version>
<optional>true</optional>
<version>${dependencies.bstats.version}</version>
<scope>provided</scope>
</dependency>
<!-- Plugin Hooks -->
<!-- ProtocolLib -->
<dependency>
<groupId>com.comphenix.protocol</groupId>
<artifactId>ProtocolLib</artifactId>
<version>4.8.0</version>
<version>5.1.0</version>
<scope>provided</scope>
<exclusions>
<exclusion>
@ -925,7 +861,7 @@
<dependency>
<groupId>net.essentialsx</groupId>
<artifactId>EssentialsX</artifactId>
<version>2.19.7</version>
<version>2.20.1</version>
<scope>provided</scope>
<exclusions>
<exclusion>
@ -971,14 +907,6 @@
</exclusions>
</dependency>
<!-- BCrypt implementation -->
<dependency>
<groupId>at.favre.lib</groupId>
<artifactId>bcrypt</artifactId>
<version>0.9.0</version>
<optional>true</optional>
</dependency>
<!-- XAuth, another authentication plugin, required by the database converter -->
<dependency>
<groupId>de.luricos.bukkit</groupId>
@ -987,60 +915,42 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>ch.jalu</groupId>
<artifactId>datasourcecolumns</artifactId>
<version>0.1.1-SNAPSHOT</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.5.0</version>
<optional>true</optional>
<exclusions>
<exclusion>
<groupId>org.checkerframework</groupId>
<artifactId>checker-qual</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Unit Testing Libraries -->
<!-- TODO: update to junit 5 -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
<version>4.13.2</version>
<exclusions>
<exclusion>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>java-hamcrest</artifactId>
<artifactId>hamcrest</artifactId>
<scope>test</scope>
<version>2.0.0.0</version>
<version>2.2</version>
</dependency>
<!-- TODO: update to mockito 5 -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
<version>4.8.1</version>
<exclusions>
<exclusion>
<artifactId>hamcrest-core</artifactId>
<groupId>org.hamcrest</groupId>
</exclusion>
</exclusions>
<version>4.11.0</version>
</dependency>
<!-- Required to mock the LuckPerms API-->
<dependency>
<groupId>org.checkerframework</groupId>
<artifactId>checker-qual</artifactId>
<version>3.26.0</version>
<version>3.42.0</version>
<scope>test</scope>
</dependency>
@ -1048,13 +958,19 @@
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.39.3.0</version>
<version>3.45.3.0</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>2.1.214</version>
<version>2.2.224</version>
<scope>test</scope>
</dependency>

View File

@ -32,7 +32,7 @@ import static fr.xephi.authme.settings.properties.EmailSettings.RECALL_PLAYERS;
*/
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 class OnStartupTasks {
}
});
}
}, 1, TICKS_PER_MINUTE * settings.getProperty(EmailSettings.DELAY_RECALL));
}, 1, (long) TICKS_PER_MINUTE * settings.getProperty(EmailSettings.DELAY_RECALL));
}
}

View File

@ -34,14 +34,13 @@ import org.bukkit.Material;
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 offhand)
// +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 @@ class InventoryPacketAdapter extends PacketAdapter {
try {
protocolManager.sendServerPacket(player, inventoryPacket, false);
} catch (InvocationTargetException invocationExc) {
logger.logException("Error during sending blank inventory", invocationExc);
} catch (Throwable throwable) {
logger.logException("Error during sending blank inventory", throwable);
}
}
}

View File

@ -4,12 +4,12 @@ import com.google.common.annotations.VisibleForTesting;
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);
@ -105,7 +105,7 @@ public class GeoIpService {
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");
@ -149,6 +149,7 @@ public class GeoIpService {
extractDatabase(downloadFile, tempFile);
// MD5 checksum verification
//noinspection deprecation
verifyChecksum(Hashing.md5(), tempFile, expectedChecksum);
Files.copy(tempFile, dataFile, StandardCopyOption.REPLACE_EXISTING);
@ -170,7 +171,7 @@ public class GeoIpService {
}
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
@ -178,7 +179,7 @@ public class GeoIpService {
}
/**
* 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
@ -220,7 +221,7 @@ public class GeoIpService {
}
/**
* 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
@ -320,11 +321,11 @@ public class GeoIpService {
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);
}

View File

@ -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.19
softdepend:
- Vault
- LuckPerms
@ -15,6 +18,23 @@ 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}
- 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

View File

@ -18,6 +18,7 @@ import org.mockito.Mock;
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.instanceOf;
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 @@ import static org.mockito.hamcrest.MockitoHamcrest.argThat;
@RunWith(DelayedInjectionRunner.class)
public class LimboPersistenceTest {
@SuppressWarnings("unused")
@InjectDelayed
private LimboPersistence limboPersistence;
@ -59,7 +60,7 @@ public class LimboPersistenceTest {
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

View File

@ -1,13 +1,12 @@
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 com.maxmind.geoip2.DatabaseReader;
import com.maxmind.geoip2.model.CountryResponse;
import com.maxmind.geoip2.record.Country;
import fr.xephi.authme.settings.Settings;
import org.junit.Before;
import org.junit.Rule;
@ -17,11 +16,11 @@ import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
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.junit.Assert.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
@ -33,10 +32,9 @@ import static org.mockito.Mockito.verify;
public class GeoIpServiceTest {
private GeoIpService geoIpService;
private File dataFolder;
@Mock
private GeoIp2Provider lookupService;
private DatabaseReader lookupService;
@Mock
private BukkitService bukkitService;
@ -49,7 +47,7 @@ public class GeoIpServiceTest {
@Before
public void initializeGeoLiteApi() throws IOException {
dataFolder = temporaryFolder.newFolder();
File dataFolder = temporaryFolder.newFolder();
geoIpService = new GeoIpService(dataFolder, bukkitService, settings, lookupService);
}
@ -64,14 +62,14 @@ public class GeoIpServiceTest {
CountryResponse response = mock(CountryResponse.class);
given(response.getCountry()).willReturn(country);
given(lookupService.getCountry(ip)).willReturn(response);
given(lookupService.country(ip)).willReturn(response);
// when
String result = geoIpService.getCountryCode(ip.getHostAddress());
// then
assertThat(result, equalTo(countryCode));
verify(lookupService).getCountry(ip);
verify(lookupService).country(ip);
}
@Test
@ -84,7 +82,7 @@ public class GeoIpServiceTest {
// then
assertThat(result, equalTo("LOCALHOST"));
verify(lookupService, never()).getCountry(any());
verify(lookupService, never()).country(any());
}
@Test
@ -98,14 +96,14 @@ public class GeoIpServiceTest {
CountryResponse response = mock(CountryResponse.class);
given(response.getCountry()).willReturn(country);
given(lookupService.getCountry(ip)).willReturn(response);
given(lookupService.country(ip)).willReturn(response);
// when
String result = geoIpService.getCountryName(ip.getHostAddress());
// then
assertThat(result, equalTo(countryName));
verify(lookupService).getCountry(ip);
verify(lookupService).country(ip);
}
@Test
@ -118,6 +116,6 @@ public class GeoIpServiceTest {
// then
assertThat(result, equalTo("LocalHost"));
verify(lookupService, never()).getCountry(ip);
verify(lookupService, never()).country(ip);
}
}