Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ 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
- dependency-name: "org.slf4j:slf4j-simple"
versions: ">= 1.7.36"
4 changes: 0 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/"
Expand Down
442 changes: 161 additions & 281 deletions pom.xml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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, 18479);

metrics.addCustomChart(new SimplePie("messages_language",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,9 @@ public void processPlayerLogin(Player player, boolean isFirstLogin, List<String>

final PlayerAuth auth = playerCache.getAuth(name);

// AuthMeReReloaded start - Fix #57
if (isFirstLogin) {
if (isFirstLogin) { // Save quit location before login teleport
auth.setQuitLocation(player.getLocation());
}
// AuthMeReReloaded end - Fix #57

teleportationService.teleportOnLogin(player, auth, limbo);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ public void processSyncQuit(Player player, boolean wasLoggedIn) {
commandManager.runCommandsOnLogout(player);
} else {
limboService.restoreData(player);
if (!UniversalScheduler.isFolia) { // AuthMeReReloaded - Fix #146 (Very stupid solution, but works)
// player.saveData(); // #1238: Speed is sometimes not restored properly
}
}
player.leaveVehicle();
}
Expand Down
31 changes: 17 additions & 14 deletions src/main/java/fr/xephi/authme/service/GeoIpService.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package fr.xephi.authme.service;

import com.google.common.annotations.VisibleForTesting;
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;
Expand All @@ -33,19 +33,19 @@ public class GeoIpService {
private final ConsoleLogger logger = ConsoleLoggerFactory.get(GeoIpService.class);
private final Path dataFile;

private GeoIp2Provider databaseReader;
private DatabaseReader databaseReader;
private volatile boolean downloading;

@Inject
GeoIpService(@DataFolder File dataFolder) {
public GeoIpService(@DataFolder File dataFolder) {
this.dataFile = dataFolder.toPath().resolve(DATABASE_FILE);

// 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, GeoIp2Provider reader) {
GeoIpService(@DataFolder File dataFolder, DatabaseReader reader) {
this.dataFile = dataFolder.toPath().resolve(DATABASE_FILE);

this.databaseReader = reader;
Expand Down Expand Up @@ -87,14 +87,17 @@ private synchronized boolean isDataAvailable() {
*/

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();

// clear downloading flag, because we now have working reader instance
downloading = false;
}

/**
* 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
Expand All @@ -103,7 +106,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 destination save file
* @return null if no updates were found, the MD5 hash of the downloaded archive if successful
Expand Down Expand Up @@ -175,11 +178,11 @@ private Optional<Country> 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) {
} catch (GeoIp2Exception | IOException ioEx) {
logger.logException("Cannot lookup country for " + ip + " at GEO IP database", ioEx);
}

Expand Down
21 changes: 21 additions & 0 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,27 @@ softdepend:
- ProtocolLib
- floodgate
- PlaceholderAPI
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}
- net.kyori:adventure-text-minimessage:${dependencies.adventure.version}
- net.kyori:adventure-platform-bukkit:${dependencies.adventure-platform.version}
- net.kyori:adventure-text-serializer-gson:${dependencies.adventure.version}
commands:
authme:
description: AuthMe op commands
Expand Down