From 5c83f5e26169eb60eb0f411dc7530e675e84c6af Mon Sep 17 00:00:00 2001 From: ItsLukassz <55624853+ItsLukassz@users.noreply.github.com> Date: Sat, 5 Feb 2022 15:07:32 +0200 Subject: [PATCH 01/97] Finished translating messages_lt.yml (#2498) Fixed some typo's and finished translating --- src/main/resources/messages/messages_lt.yml | 142 ++++++++++---------- 1 file changed, 71 insertions(+), 71 deletions(-) diff --git a/src/main/resources/messages/messages_lt.yml b/src/main/resources/messages/messages_lt.yml index 7452d49bf..f8606b01f 100644 --- a/src/main/resources/messages/messages_lt.yml +++ b/src/main/resources/messages/messages_lt.yml @@ -11,14 +11,14 @@ registration: command_usage: '&eNaudojimas: /register slaptazodis pakartotiSlaptazodi' reg_only: '&cTik prisiregistravusiem zaidejams: apsilankykite: http://example.com tam kad uzsiregistruoti.' success: '&aSekmingai prisiregistravote.' - # TODO kicked_admin_registered: 'An admin just registered you; please log in again' + kicked_admin_registered: 'Administatorius jus uzregistravo. Prisijunkite isnaujo' # Password errors on registration password: match_error: '&cSlaptazodziai nesutampa' - # TODO name_in_password: '&cYou can''t use your name as password, please choose another one...' - # TODO unsafe_password: '&cThe chosen password isn''t safe, please choose another one...' - # TODO forbidden_characters: '&4Your password contains illegal characters. Allowed chars: %valid_chars' + name_in_password: '&cJus negalite naudoti savo varda slaptazodyje' + unsafe_password: '&cSi slaptazodi lengva nulausti, pasirinkite kita slaptazodi' + forbidden_characters: '&4Jusus slaptazodis turi netinkamu simboliu. Leidziami simboliai: %valid_chars' wrong_length: '&cJusu slaptazodis buvo per ilgas arba per trumpas.' # Login @@ -31,23 +31,23 @@ login: # Errors error: - # TODO denied_command: '&cIn order to use this command you must be authenticated!' - # TODO denied_chat: '&cIn order to chat you must be authenticated!' + denied_command: '&cKad galetumete naudoti sia komanda turite buti prisijunge!' + denied_chat: '&cKad galetumete kalbeti jus turite buti prisijunge!' unregistered_user: '&cVartotojas neprisiregistraves' not_logged_in: '&cTu neprisijunges!' no_permission: '&cNera leidimo' unexpected_error: '&cAtsirado klaida, praneskite adminstratoriui.' max_registration: '&cJus pasiekete maksimalu registraciju skaiciu.' - logged_in: '&cTu aju prisijunges!' + logged_in: '&cTu jau prisijunges!' kick_for_vip: '&cA VIP prisijunge i pilna serveri!' - # TODO kick_unresolved_hostname: '&cAn error occurred: unresolved player hostname!' - # TODO tempban_max_logins: '&cYou have been temporarily banned for failing to log in too many times.' + kick_unresolved_hostname: '&cIvyko klaida: Ivyko klaida su zaidejo adresu!' + tempban_max_logins: '&cJus laikinai uzblokuotas nes kelis kartus neteisingai suvedete salptazodi.' # AntiBot antibot: - # TODO kick_antibot: 'AntiBot protection mode is enabled! You have to wait some minutes before joining the server.' - # TODO auto_enabled: '&4[AntiBotService] AntiBot enabled due to the huge number of connections!' - # TODO auto_disabled: '&2[AntiBotService] AntiBot disabled after %m minutes!' + kick_antibot: 'AntiBot prevencija ijungta! Palaukite pries prisijungiant.' + auto_enabled: '&4[AntiBotService] AntiBot prevencija pajungta del didelio kiekio prisijungimu!' + auto_disabled: '&2[AntiBotService] AntiBot isjungtas po: %m minutes!' # Unregister unregister: @@ -61,8 +61,8 @@ misc: logout: '&aSekmingai atsijungete' reload: '&aNustatymai ir duomenu baze buvo perkrauta.' usage_change_password: '&ePanaudojimas: /changepassword senasSlaptazodis naujasSlaptazodis' - # TODO accounts_owned_self: 'You own %count accounts:' - # TODO accounts_owned_other: 'The player %name has %count accounts:' + accounts_owned_self: 'Jus turite %count paskyra(-s):' + accounts_owned_other: 'Zaidejas %name turi %count paskyra(-s):' # Session messages session: @@ -71,87 +71,87 @@ session: # Error messages when joining on_join_validation: - # TODO same_ip_online: 'A player with the same IP is already in game!' + same_ip_online: 'Zaidejas su tuo paciu ip jau yra zaidime!' same_nick_online: '&cKazkas situo vardu jau zaidzia.' name_length: '&cJusu varsdas yra per ilgas arba per trumpas.' characters_in_name: '&cJusu varde yra neledziamu simboliu, leidziami: %valid_chars' kick_full_server: '&cServeris yra pilnas, Atsiprasome.' - # TODO country_banned: '&4Your country is banned from this server!' - # TODO not_owner_error: 'You are not the owner of this account. Please choose another name!' - # TODO invalid_name_case: 'You should join using username %valid, not %invalid.' - # TODO quick_command: 'You used a command too fast! Please, join the server again and wait more before using any command.' + country_banned: '&4Jusu salis yra uzblokuota siame serveryje!' + not_owner_error: 'Tu neesi sios paskyros savininkas, pasirinkite kita varda!' + invalid_name_case: 'Turetumete prisijungti su vardu: %valid, o ne su: %invalid.' + quick_command: 'Tu panaudojai komanda per greitai! Prisijunkite isnaujo ir siek tiek palaukite pries naudojant komandas.' # Email email: - add_email_request: '&ePrasau pridekite savo el.pasta : /email add Email confirmEmail' - # TODO usage_email_add: '&cUsage: /email add ' - # TODO usage_email_change: '&cUsage: /email change ' - # TODO new_email_invalid: '&cInvalid new email, try again!' - # TODO old_email_invalid: '&cInvalid old email, try again!' - # TODO invalid: '&cInvalid email address, try again!' - # TODO added: '&2Email address successfully added to your account!' - # TODO add_not_allowed: '&cAdding email was not allowed' - # TODO request_confirmation: '&cPlease confirm your email address!' - # TODO changed: '&2Email address changed correctly!' - # TODO change_not_allowed: '&cChanging email was not allowed' - # TODO email_show: '&2Your current email address is: &f%email' - # TODO no_email_for_account: '&2You currently don''t have email address associated with this account.' - # TODO already_used: '&4The email address is already being used' - # TODO incomplete_settings: 'Error: not all required settings are set for sending emails. Please contact an admin.' - # TODO send_failure: 'The email could not be sent. Please contact an administrator.' - # TODO change_password_expired: 'You cannot change your password using this command anymore.' - # TODO email_cooldown_error: '&cAn email was already sent recently. You must wait %time before you can send a new one.' + add_email_request: '&ePrasau pridekite savo el.pasta : /email add ' + usage_email_add: '&cNaudojimas: /email add ' + usage_email_change: '&cNaudojimas: /email change ' + new_email_invalid: '&cNeteisingas el.pastas, bandykite isnaujo!' + old_email_invalid: '&cNeteisingas senas el.pastas, bandykite isnaujo!' + invalid: '&cNeteisingas el.pastas, bandykite isnaujo!' + added: '&2El.pastas sekmingai pridetas!' + add_not_allowed: '&cNaujo el.pasto pridejimas nera galimas' + request_confirmation: '&cPatvirtinkite savo el.pasta!' + changed: '&2El.pasta pakeistas sekmingai!' + change_not_allowed: '&cEl.pasto keitimas nera galimas' + email_show: '&2Jusu dabartinis el.pasto adresas: &f%email' + no_email_for_account: '&2Siuo metu jus neturite prideja jokio el.pasto adreso.' + already_used: '&4Jis el.pasto adresas jau yra naudojamas' + incomplete_settings: 'Klaidas: Nevisi nustatymai yra nustatyti laisko siuntimui. Susikietite su administratorium.' + send_failure: 'El.pasto laiskas nebuvo issiustas. Susikietite su administratorium.' + change_password_expired: 'Jus nebegalite pakeisti savo slaptazodzio naudojant sia komanda.' + email_cooldown_error: '&cEl.pasto laiskas jau buvo issiustas. Palaukite %time pries siunciant nauja.' # Password recovery by email recovery: forgot_password_hint: '&cPamirsote slaptazodi? Rasykite: /email recovery el.pastas' - # TODO command_usage: '&cUsage: /email recovery ' - # TODO email_sent: '&2Recovery email sent successfully! Please check your email inbox!' + command_usage: '&cNaudojimas: /email recovery el.pastas' + email_sent: '&2Laiskas i jusu pasto adresa buvo issiustas!' code: - # TODO code_sent: 'A recovery code to reset your password has been sent to your email.' - # TODO incorrect: 'The recovery code is not correct! You have %count tries remaining.' - # TODO tries_exceeded: 'You have exceeded the maximum number attempts to enter the recovery code. Use "/email recovery [email]" to generate a new one.' - # TODO correct: 'Recovery code entered correctly!' - # TODO change_password: 'Please use the command /email setpassword to change your password immediately.' + code_sent: 'Kodas slaptazodzio atstatymui buvo issiustas i jusu pasta.' + incorrect: 'Kodas neteisingas! jums liko %count bandymai(-as).' + tries_exceeded: 'Jus isnaudojote visus bandymus. Naudokite "/email recovery el.pastas" kad gauti nauja koda.' + correct: 'Kodas ivestas sekmingai!' + change_password: 'Naudokite /email setpassword kad pasikeistumete slaptazodi.' # Captcha captcha: usage_captcha: '&cPanaudojimas: /captcha %captcha_code' wrong_captcha: '&cNeteisinga Captcha, naudokite : /captcha %captcha_code' valid_captcha: '&cJusu captcha Teisinga!' - # TODO captcha_for_registration: 'To register you have to solve a captcha first, please use the command: /captcha %captcha_code' - # TODO register_captcha_valid: '&2Valid captcha! You may now register with /register' + captcha_for_registration: 'Kad prisiregistruotumete turite ivygdyti captcha, rasykite: /captcha %captcha_code' + register_captcha_valid: '&2Captcha Teisinga! Galite naudoti /register' # Verification code verification: - # TODO code_required: '&3This command is sensitive and requires an email verification! Check your inbox and follow the email''s instructions.' - # TODO command_usage: '&cUsage: /verification ' - # TODO incorrect_code: '&cIncorrect code, please type "/verification " into the chat, using the code you received by email' - # TODO success: '&2Your identity has been verified! You can now execute all commands within the current session!' - # TODO already_verified: '&2You can already execute every sensitive command within the current session!' - # TODO code_expired: '&3Your code has expired! Execute another sensitive command to get a new code!' - # TODO email_needed: '&3To verify your identity you need to link an email address with your account!!' + code_required: '&3Kad naudotumete sia komanda turi patvirtinti savo pasto adresa! Sekite instrukcijas savo el.paste.' + command_usage: '&cNaudojimas: /verification ' + incorrect_code: '&cNeteisingas kodas, naudokite "/verification " ivesdami koda gauta savo el.paste' + success: '&2Jusu paskyra patvirtinta! Jus galite naudoti visas komandas!' + already_verified: '&2Jus jau esate patvirtintas ir galite naudoti visas komandas!' + code_expired: '&3Jusu kodo galiojimas baigesi! Panaudokite komanda isnaujo kad gauti nauja koda!' + email_needed: '&3Kad patvirtinti savo paskyra turite prideti el.pasto adresa!' # Time units time: - # TODO second: 'second' - # TODO seconds: 'seconds' - # TODO minute: 'minute' - # TODO minutes: 'minutes' - # TODO hour: 'hour' - # TODO hours: 'hours' - # TODO day: 'day' - # TODO days: 'days' + second: 'sekunde' + seconds: 'sekundes' + minute: 'minute' + minutes: 'minutes' + hour: 'valanda' + hours: 'valandas' + day: 'diena' + days: 'dienas' # Two-factor authentication two_factor: - # TODO code_created: '&2Your secret code is %code. You can scan it from here %url' - # TODO confirmation_required: 'Please confirm your code with /2fa confirm ' - # TODO code_required: 'Please submit your two-factor authentication code with /2fa code ' - # TODO already_enabled: 'Two-factor authentication is already enabled for your account!' - # TODO enable_error_no_code: 'No 2fa key has been generated for you or it has expired. Please run /2fa add' - # TODO enable_success: 'Successfully enabled two-factor authentication for your account' - # TODO enable_error_wrong_code: 'Wrong code or code has expired. Please run /2fa add' - # TODO not_enabled_error: 'Two-factor authentication is not enabled for your account. Run /2fa add' - # TODO removed_success: 'Successfully removed two-factor auth from your account' - # TODO invalid_code: 'Invalid code!' + code_created: '&2Tavo slaptas kodas yra %code. Ji gali nuskenuoti cia: %url' + confirmation_required: 'Patvirtinkite savo koda su: /2fa confirm ' + code_required: 'Patvirkinkite savo koda su: /2fa code ' + already_enabled: 'Jus jau turite dvieju faktoriu autentifikacija!' + enable_error_no_code: 'Jus neturite dvieju faktoriu autentifikacijos arba ji pasibaige. Rasykite /2fa add' + enable_success: 'Dvieju faktoriu autentifikacija sekmingai ijungta' + enable_error_wrong_code: 'Wrong code or code has expired. Please run /2fa add' + not_enabled_error: 'Two-factor authentication is not enabled for your account. Run /2fa add' + removed_success: 'Successfully removed two-factor auth from your account' + invalid_code: 'Neteisingas kodas!' From 677a3f5dd66f93641e7387f7356d1c489562e396 Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Sun, 10 Apr 2022 18:46:28 +0200 Subject: [PATCH 02/97] Fix travis builds --- .travis.yml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 91135f66c..cb4ece531 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,13 +1,12 @@ sudo: false -dist: trusty +dist: focal language: java -jdk: - - openjdk16 before_install: - - wget https://downloads.apache.org/maven/maven-3/3.8.4/binaries/apache-maven-3.8.4-bin.tar.gz - - tar xzvf apache-maven-3.8.4-bin.tar.gz - - export PATH=`pwd`/apache-maven-3.8.4/bin:$PATH - - mvn -v + - curl -s "https://get.sdkman.io" | bash + - source "$HOME/.sdkman/bin/sdkman-init.sh" + - sdk install java 17-open + - sdk use java 17-open + - sdk install maven cache: directories: - '$HOME/.m2/repository' From c32d09081267ede771b4f2e78b9ebe9b98e0d2c6 Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Sun, 10 Apr 2022 19:57:53 +0200 Subject: [PATCH 03/97] Fix the TravisCI pipeline (#2527) * Fix maven version * Attempt to fix travis Maven version * Attempt to fix mvn and java version on travis CI * Attempt to fix travis builds * Update .travis.yml * Update .travis.yml * Update .travis.yml --- .travis.yml | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index cb4ece531..7ca0e106e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,35 @@ -sudo: false dist: focal + 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/" - curl -s "https://get.sdkman.io" | bash + - mkdir -p "$HOME/.sdkman/etc/" + - echo sdkman_auto_answer=true > "$HOME/.sdkman/etc/config" + - echo sdkman_auto_selfupdate=true >> "$HOME/.sdkman/etc/config" - source "$HOME/.sdkman/bin/sdkman-init.sh" - - sdk install java 17-open - - sdk use java 17-open + +install: + - sdk install java $(sdk list java | grep -o "$JDK_VERSION\.[0-9]*\.[0-9]*\-open" | head -1) - sdk install maven + - export JAVA_HOME="$HOME/.sdkman/candidates/java/current" + - export PATH=${JAVA_HOME}/bin:${PATH} + - export MAVEN_HOME="$HOME/.sdkman/candidates/maven/current" + - export M2_HOME="$MAVEN_HOME" + - export PATH=${M2_HOME}/bin:${PATH} + - env + - mvn -v + cache: directories: - - '$HOME/.m2/repository' + - $HOME/.m2/repository From d166c951fad9e5e07d73c81b46b9ecaf01e662e9 Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Sun, 10 Apr 2022 20:25:31 +0200 Subject: [PATCH 04/97] Use java version matrix in github actions --- .github/workflows/maven.yml | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index b6a309674..407749a8a 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -4,14 +4,16 @@ on: [push] jobs: build_and_test: - + strategy: + matrix: + jdkversion: [8, 11, 17] runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - name: Set up JDK 1.8 - uses: actions/setup-java@v1 + - uses: actions/checkout@v3 + - uses: actions/setup-java@v3 with: - java-version: 1.8 + distribution: 'temurin' + java-version: ${{ matrix.jdkversion }} + cache: 'maven' - name: Build with Maven - run: mvn -B clean package --file pom.xml + run: mvn -V -B clean package --file pom.xml From cd1aa0133a83f571b26174ea1bb9a77e7d02d18e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 10 Apr 2022 20:33:48 +0200 Subject: [PATCH 05/97] Bump checker-qual from 3.20.0 to 3.21.4 (#2526) Bumps [checker-qual](https://github.com/typetools/checker-framework) from 3.20.0 to 3.21.4. - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.20.0...checker-framework-3.21.4) --- updated-dependencies: - dependency-name: org.checkerframework:checker-qual dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 22fcb51ab..fbeaa0330 100644 --- a/pom.xml +++ b/pom.xml @@ -972,7 +972,7 @@ org.checkerframework checker-qual - 3.20.0 + 3.21.4 test From db72276b925a91af73fafbd30f0dfb6540bbc813 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 10 Apr 2022 20:33:55 +0200 Subject: [PATCH 06/97] Bump mariadb-java-client from 2.7.4 to 3.0.4 (#2523) Bumps [mariadb-java-client](https://github.com/mariadb-corporation/mariadb-connector-j) from 2.7.4 to 3.0.4. - [Release notes](https://github.com/mariadb-corporation/mariadb-connector-j/releases) - [Changelog](https://github.com/mariadb-corporation/mariadb-connector-j/blob/master/CHANGELOG.md) - [Commits](https://github.com/mariadb-corporation/mariadb-connector-j/compare/2.7.4...3.0.4) --- updated-dependencies: - dependency-name: org.mariadb.jdbc:mariadb-java-client dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index fbeaa0330..f21d34920 100644 --- a/pom.xml +++ b/pom.xml @@ -648,7 +648,7 @@ org.mariadb.jdbc mariadb-java-client - 2.7.4 + 3.0.4 true From f2bcd821602796b2c5defbee808392a88808fdf8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 10 Apr 2022 20:34:02 +0200 Subject: [PATCH 07/97] Bump mockito-core from 4.1.0 to 4.4.0 (#2520) Bumps [mockito-core](https://github.com/mockito/mockito) from 4.1.0 to 4.4.0. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v4.1.0...v4.4.0) --- updated-dependencies: - dependency-name: org.mockito:mockito-core dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f21d34920..18ab78746 100644 --- a/pom.xml +++ b/pom.xml @@ -959,7 +959,7 @@ org.mockito mockito-core test - 4.1.0 + 4.4.0 hamcrest-core From 72bd204597697a8ed1788f04b7d02875dc2c586c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 10 Apr 2022 20:34:11 +0200 Subject: [PATCH 08/97] Bump maven-compiler-plugin from 3.8.1 to 3.10.1 (#2518) Bumps [maven-compiler-plugin](https://github.com/apache/maven-compiler-plugin) from 3.8.1 to 3.10.1. - [Release notes](https://github.com/apache/maven-compiler-plugin/releases) - [Commits](https://github.com/apache/maven-compiler-plugin/compare/maven-compiler-plugin-3.8.1...maven-compiler-plugin-3.10.1) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-compiler-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 18ab78746..85e26cc4b 100644 --- a/pom.xml +++ b/pom.xml @@ -195,7 +195,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.8.1 + 3.10.1 ${java.version} ${java.version} From 6acf26f9734f6f69a554b4f4e7ed240ea0d1778a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 10 Apr 2022 20:34:24 +0200 Subject: [PATCH 09/97] Bump maven-site-plugin from 3.9.1 to 3.11.0 (#2512) Bumps [maven-site-plugin](https://github.com/apache/maven-site-plugin) from 3.9.1 to 3.11.0. - [Release notes](https://github.com/apache/maven-site-plugin/releases) - [Commits](https://github.com/apache/maven-site-plugin/compare/maven-site-plugin-3.9.1...maven-site-plugin-3.11.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-site-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 85e26cc4b..781dd80c2 100644 --- a/pom.xml +++ b/pom.xml @@ -442,7 +442,7 @@ org.apache.maven.plugins maven-site-plugin - 3.9.1 + 3.11.0 From c0c5d93a4828bdf100407afbae6cb44d20a0dfa9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 10 Apr 2022 20:34:52 +0200 Subject: [PATCH 10/97] Bump postgresql from 42.3.1 to 42.3.3 (#2507) Bumps [postgresql](https://github.com/pgjdbc/pgjdbc) from 42.3.1 to 42.3.3. - [Release notes](https://github.com/pgjdbc/pgjdbc/releases) - [Changelog](https://github.com/pgjdbc/pgjdbc/blob/master/CHANGELOG.md) - [Commits](https://github.com/pgjdbc/pgjdbc/compare/REL42.3.1...REL42.3.3) --- updated-dependencies: - dependency-name: org.postgresql:postgresql dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 781dd80c2..490064ff6 100644 --- a/pom.xml +++ b/pom.xml @@ -935,7 +935,7 @@ org.postgresql postgresql - 42.3.1 + 42.3.3 true From e8f2bfaf5f22eabe61273ba9975bdda2138341bb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 10 Apr 2022 20:35:39 +0200 Subject: [PATCH 11/97] Bump api from 5.3 to 5.4 (#2506) Bumps [api](https://github.com/LuckPerms/LuckPerms) from 5.3 to 5.4. - [Release notes](https://github.com/LuckPerms/LuckPerms/releases) - [Commits](https://github.com/LuckPerms/LuckPerms/compare/v5.3...v5.4) --- updated-dependencies: - dependency-name: net.luckperms:api dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 490064ff6..7c4e3569e 100644 --- a/pom.xml +++ b/pom.xml @@ -750,7 +750,7 @@ net.luckperms api - 5.3 + 5.4 provided From f86982a33cac622d56406100cbc3a65ca57e85e4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 10 Apr 2022 20:36:01 +0200 Subject: [PATCH 12/97] Bump slf4j-simple from 1.7.32 to 1.7.36 (#2501) Bumps [slf4j-simple](https://github.com/qos-ch/slf4j) from 1.7.32 to 1.7.36. - [Release notes](https://github.com/qos-ch/slf4j/releases) - [Commits](https://github.com/qos-ch/slf4j/compare/v_1.7.32...v_1.7.36) --- updated-dependencies: - dependency-name: org.slf4j:slf4j-simple dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7c4e3569e..ec01d7724 100644 --- a/pom.xml +++ b/pom.xml @@ -626,7 +626,7 @@ org.slf4j slf4j-simple - 1.7.32 + 1.7.36 true From a4d13552c06f31d482665bebbae05fa6fe3336a8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 10 Apr 2022 20:36:11 +0200 Subject: [PATCH 13/97] Bump maven-jar-plugin from 3.2.0 to 3.2.2 (#2485) Bumps [maven-jar-plugin](https://github.com/apache/maven-jar-plugin) from 3.2.0 to 3.2.2. - [Release notes](https://github.com/apache/maven-jar-plugin/releases) - [Commits](https://github.com/apache/maven-jar-plugin/compare/maven-jar-plugin-3.2.0...maven-jar-plugin-3.2.2) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-jar-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ec01d7724..2e92e2ba2 100644 --- a/pom.xml +++ b/pom.xml @@ -241,7 +241,7 @@ org.apache.maven.plugins maven-jar-plugin - 3.2.0 + 3.2.2 From 35efc054c7ac96a3a835a114c7d1a6d58c044ead Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Sun, 10 Apr 2022 20:56:17 +0200 Subject: [PATCH 14/97] Ignore HikariCP in dependabot We need to maintain java 8 support --- .github/dependabot.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 16f9401c9..3b0775a28 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -10,3 +10,4 @@ updates: - dependency-name: com.google.guava:guava - dependency-name: org.apache.logging.log4j:log4j-core - dependency-name: mysql:mysql-connector-java + - dependency-name: com.zaxxer:HikariCP From 1ac7849fe33a9b6c0eee2a37c86f0e8e20deb4f0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 10 Apr 2022 21:08:55 +0200 Subject: [PATCH 15/97] Bump maven-clean-plugin from 3.1.0 to 3.2.0 (#2528) Bumps [maven-clean-plugin](https://github.com/apache/maven-clean-plugin) from 3.1.0 to 3.2.0. - [Release notes](https://github.com/apache/maven-clean-plugin/releases) - [Commits](https://github.com/apache/maven-clean-plugin/compare/maven-clean-plugin-3.1.0...maven-clean-plugin-3.2.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-clean-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2e92e2ba2..128a01a44 100644 --- a/pom.xml +++ b/pom.xml @@ -183,7 +183,7 @@ org.apache.maven.plugins maven-clean-plugin - 3.1.0 + 3.2.0 From 33d1ef1c125ef8abc89a823b0ff176b2ac109cd6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 4 Jun 2022 02:10:41 +0200 Subject: [PATCH 16/97] Bump ProtocolLib from 4.7.0 to 4.8.0 (#2529) Bumps [ProtocolLib](https://github.com/dmulloy2/ProtocolLib) from 4.7.0 to 4.8.0. - [Release notes](https://github.com/dmulloy2/ProtocolLib/releases) - [Commits](https://github.com/dmulloy2/ProtocolLib/compare/4.7.0...4.8.0) --- updated-dependencies: - dependency-name: com.comphenix.protocol:ProtocolLib dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 128a01a44..d89f57629 100644 --- a/pom.xml +++ b/pom.xml @@ -732,7 +732,7 @@ com.comphenix.protocol ProtocolLib - 4.7.0 + 4.8.0 provided From 0e6cb322deac70d0c7dcb1f5276e614703484af3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 4 Jun 2022 02:10:55 +0200 Subject: [PATCH 17/97] Bump h2 from 2.1.210 to 2.1.212 (#2530) Bumps [h2](https://github.com/h2database/h2database) from 2.1.210 to 2.1.212. - [Release notes](https://github.com/h2database/h2database/releases) - [Commits](https://github.com/h2database/h2database/compare/version-2.1.210...version-2.1.212) --- updated-dependencies: - dependency-name: com.h2database:h2 dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d89f57629..1aa5995ad 100644 --- a/pom.xml +++ b/pom.xml @@ -986,7 +986,7 @@ com.h2database h2 - 2.1.210 + 2.1.212 test From 54bdba1abde501a455e318367dc26acb166d1037 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 4 Jun 2022 02:11:08 +0200 Subject: [PATCH 18/97] Bump maven-shade-plugin from 3.2.4 to 3.3.0 (#2531) Bumps [maven-shade-plugin](https://github.com/apache/maven-shade-plugin) from 3.2.4 to 3.3.0. - [Release notes](https://github.com/apache/maven-shade-plugin/releases) - [Commits](https://github.com/apache/maven-shade-plugin/compare/maven-shade-plugin-3.2.4...maven-shade-plugin-3.3.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-shade-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1aa5995ad..5cc398b38 100644 --- a/pom.xml +++ b/pom.xml @@ -282,7 +282,7 @@ org.apache.maven.plugins maven-shade-plugin - 3.2.4 + 3.3.0 shaded-jar From ff3f0251337593d783fe306320c98d16fb8790e2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 4 Jun 2022 02:11:27 +0200 Subject: [PATCH 19/97] Bump jacoco-maven-plugin from 0.8.7 to 0.8.8 (#2534) Bumps [jacoco-maven-plugin](https://github.com/jacoco/jacoco) from 0.8.7 to 0.8.8. - [Release notes](https://github.com/jacoco/jacoco/releases) - [Commits](https://github.com/jacoco/jacoco/compare/v0.8.7...v0.8.8) --- updated-dependencies: - dependency-name: org.jacoco:jacoco-maven-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5cc398b38..09140df84 100644 --- a/pom.xml +++ b/pom.xml @@ -205,7 +205,7 @@ org.jacoco jacoco-maven-plugin - 0.8.7 + 0.8.8 pre-unit-test From aca50ec87abe720ac190398a5fcc1f9607c75080 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 4 Jun 2022 02:11:34 +0200 Subject: [PATCH 20/97] Bump maven-javadoc-plugin from 3.3.1 to 3.4.0 (#2536) Bumps [maven-javadoc-plugin](https://github.com/apache/maven-javadoc-plugin) from 3.3.1 to 3.4.0. - [Release notes](https://github.com/apache/maven-javadoc-plugin/releases) - [Commits](https://github.com/apache/maven-javadoc-plugin/compare/maven-javadoc-plugin-3.3.1...maven-javadoc-plugin-3.4.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-javadoc-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 09140df84..a362a1fd2 100644 --- a/pom.xml +++ b/pom.xml @@ -151,7 +151,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.3.1 + 3.4.0 From 84955599de76885cb790ef2b9d534bf505cfaad7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 4 Jun 2022 02:11:43 +0200 Subject: [PATCH 21/97] Bump maven-site-plugin from 3.11.0 to 3.12.0 (#2537) Bumps [maven-site-plugin](https://github.com/apache/maven-site-plugin) from 3.11.0 to 3.12.0. - [Release notes](https://github.com/apache/maven-site-plugin/releases) - [Commits](https://github.com/apache/maven-site-plugin/compare/maven-site-plugin-3.11.0...maven-site-plugin-3.12.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-site-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a362a1fd2..fdf89b480 100644 --- a/pom.xml +++ b/pom.xml @@ -442,7 +442,7 @@ org.apache.maven.plugins maven-site-plugin - 3.11.0 + 3.12.0 From 507d5ed27658ab2b3fae0ba0c8d2ca236363e78c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 4 Jun 2022 02:12:26 +0200 Subject: [PATCH 22/97] Bump postgresql from 42.3.3 to 42.3.6 (#2547) Bumps [postgresql](https://github.com/pgjdbc/pgjdbc) from 42.3.3 to 42.3.6. - [Release notes](https://github.com/pgjdbc/pgjdbc/releases) - [Changelog](https://github.com/pgjdbc/pgjdbc/blob/master/CHANGELOG.md) - [Commits](https://github.com/pgjdbc/pgjdbc/compare/REL42.3.3...REL42.3.6) --- updated-dependencies: - dependency-name: org.postgresql:postgresql dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index fdf89b480..47c412c49 100644 --- a/pom.xml +++ b/pom.xml @@ -935,7 +935,7 @@ org.postgresql postgresql - 42.3.3 + 42.3.6 true From 8d4942731d05eeaf36f648429fb25b25d64cf750 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 4 Jun 2022 02:12:44 +0200 Subject: [PATCH 23/97] Bump checker-qual from 3.21.4 to 3.22.1 (#2549) Bumps [checker-qual](https://github.com/typetools/checker-framework) from 3.21.4 to 3.22.1. - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/checker-framework-3.22.1/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.21.4...checker-framework-3.22.1) --- updated-dependencies: - dependency-name: org.checkerframework:checker-qual dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 47c412c49..e48960f46 100644 --- a/pom.xml +++ b/pom.xml @@ -972,7 +972,7 @@ org.checkerframework checker-qual - 3.21.4 + 3.22.1 test From 3892bb692354d4591aac023f5eb05f68466c8353 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 4 Jun 2022 02:13:01 +0200 Subject: [PATCH 24/97] Bump mockito-core from 4.4.0 to 4.6.1 (#2551) Bumps [mockito-core](https://github.com/mockito/mockito) from 4.4.0 to 4.6.1. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v4.4.0...v4.6.1) --- updated-dependencies: - dependency-name: org.mockito:mockito-core dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e48960f46..370b2728e 100644 --- a/pom.xml +++ b/pom.xml @@ -959,7 +959,7 @@ org.mockito mockito-core test - 4.4.0 + 4.6.1 hamcrest-core From 25cf85a7dc5c55566c3d2381e42738d54f019bea Mon Sep 17 00:00:00 2001 From: Ghost_chu <2908803755@qq.com> Date: Wed, 6 Jul 2022 15:39:06 +0800 Subject: [PATCH 25/97] Execute simple check before enable BungeeCord hook. This commit added a simple check that check spigot.yml -> settings.bungeecord status by using AuthMe built-in method bukkitService.isBungeeCordConfiguredForSpigot() and disable hook if it enabled and not behind an BungeeCord proxy. Register plugin message channel without BungeeCord proxy will allow attacker send fake login payload to treat AuthMe login with Plugin Message for him and bypass the user login. This commit also updated SettingsWarner for new behavior. --- .../xephi/authme/service/bungeecord/BungeeReceiver.java | 8 +++++--- .../java/fr/xephi/authme/settings/SettingsWarner.java | 8 ++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/main/java/fr/xephi/authme/service/bungeecord/BungeeReceiver.java b/src/main/java/fr/xephi/authme/service/bungeecord/BungeeReceiver.java index 04f55033e..c66a6d6b0 100644 --- a/src/main/java/fr/xephi/authme/service/bungeecord/BungeeReceiver.java +++ b/src/main/java/fr/xephi/authme/service/bungeecord/BungeeReceiver.java @@ -20,7 +20,7 @@ import javax.inject.Inject; import java.util.Optional; public class BungeeReceiver implements PluginMessageListener, SettingsDependent { - + private final ConsoleLogger logger = ConsoleLoggerFactory.get(BungeeReceiver.class); private final AuthMe plugin; @@ -45,7 +45,9 @@ public class BungeeReceiver implements PluginMessageListener, SettingsDependent @Override public void reload(final Settings settings) { this.isEnabled = settings.getProperty(HooksSettings.BUNGEECORD); - + if (this.isEnabled) { + this.isEnabled = bukkitService.isBungeeCordConfiguredForSpigot().orElse(false); + } if (this.isEnabled) { final Messenger messenger = plugin.getServer().getMessenger(); if (!messenger.isIncomingChannelRegistered(plugin, "BungeeCord")) { @@ -159,7 +161,7 @@ public class BungeeReceiver implements PluginMessageListener, SettingsDependent proxySessionManager.processProxySessionMessage(name); logger.info("The user " + name + " should be automatically logged in, " + "as requested via plugin messaging but has not been detected, nickname has been" - +" added to autologin queue."); + + " added to autologin queue."); } } diff --git a/src/main/java/fr/xephi/authme/settings/SettingsWarner.java b/src/main/java/fr/xephi/authme/settings/SettingsWarner.java index c51bdf6b3..b12f84ef2 100644 --- a/src/main/java/fr/xephi/authme/settings/SettingsWarner.java +++ b/src/main/java/fr/xephi/authme/settings/SettingsWarner.java @@ -67,6 +67,14 @@ public class SettingsWarner { + " AuthMeBungee add-on to work properly you have to enable this option!"); } + if (!isTrue(bukkitService.isBungeeCordConfiguredForSpigot()) + && settings.getProperty(HooksSettings.BUNGEECORD)) { + logger.warning("Note: Hooks.bungeecord is set to true but your server appears to be running in" + + " non-bungeecord mode (see your spigot.yml). In order to prevent untrusted payload attack, " + + "BungeeCord hook will be automatically disabled!"); + } + + // Check if argon2 library is present and can be loaded if (settings.getProperty(SecuritySettings.PASSWORD_HASH).equals(HashAlgorithm.ARGON2) && !Argon2.isLibraryLoaded()) { From 0b6c92949c34c84e2c4dcefbe3030c037a6e9ecc Mon Sep 17 00:00:00 2001 From: games647 Date: Wed, 6 Jul 2022 15:27:49 +0200 Subject: [PATCH 26/97] Add test for the warning if the BungeeCord is enabled --- .../authme/settings/SettingsWarnerTest.java | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/test/java/fr/xephi/authme/settings/SettingsWarnerTest.java b/src/test/java/fr/xephi/authme/settings/SettingsWarnerTest.java index cdf4f8ac1..fbea9f9af 100644 --- a/src/test/java/fr/xephi/authme/settings/SettingsWarnerTest.java +++ b/src/test/java/fr/xephi/authme/settings/SettingsWarnerTest.java @@ -36,9 +36,6 @@ public class SettingsWarnerTest { @Mock private Settings settings; - @Mock - private AuthMe authMe; - @Mock private BukkitService bukkitService; @@ -62,6 +59,26 @@ public class SettingsWarnerTest { verify(logger, times(4)).warning(anyString()); } + @Test + public void shouldWarnBungeeWithoutSpigot() { + Logger logger = TestHelper.setupLogger(); + + // this cannot be covered above, because it's conflicting with the other settings + given(settings.getProperty(RestrictionSettings.FORCE_SINGLE_SESSION)).willReturn(true); + given(settings.getProperty(EmailSettings.SMTP_PORT)).willReturn(25); + given(settings.getProperty(EmailSettings.PORT25_USE_TLS)).willReturn(false); + given(settings.getProperty(PluginSettings.SESSIONS_ENABLED)).willReturn(false); + given(settings.getProperty(SecuritySettings.PASSWORD_HASH)).willReturn(HashAlgorithm.MD5); + given(settings.getProperty(HooksSettings.BUNGEECORD)).willReturn(true); + given(bukkitService.isBungeeCordConfiguredForSpigot()).willReturn(Optional.of(false)); + + // when + settingsWarner.logWarningsForMisconfigurations(); + + // then + verify(logger, times(1)).warning(anyString()); + } + @Test public void shouldNotLogAnyWarning() { Logger logger = TestHelper.setupLogger(); @@ -70,6 +87,7 @@ public class SettingsWarnerTest { given(settings.getProperty(EmailSettings.PORT25_USE_TLS)).willReturn(false); given(settings.getProperty(PluginSettings.SESSIONS_ENABLED)).willReturn(false); given(settings.getProperty(SecuritySettings.PASSWORD_HASH)).willReturn(HashAlgorithm.MD5); + given(settings.getProperty(HooksSettings.BUNGEECORD)).willReturn(false); given(bukkitService.isBungeeCordConfiguredForSpigot()).willReturn(Optional.empty()); // when From 18613cb3ccb3633f21574c25703ea09cadd06182 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 16 Jul 2022 18:34:25 +0200 Subject: [PATCH 27/97] Bump postgresql from 42.3.6 to 42.4.0 (#2554) Bumps [postgresql](https://github.com/pgjdbc/pgjdbc) from 42.3.6 to 42.4.0. - [Release notes](https://github.com/pgjdbc/pgjdbc/releases) - [Changelog](https://github.com/pgjdbc/pgjdbc/blob/master/CHANGELOG.md) - [Commits](https://github.com/pgjdbc/pgjdbc/compare/REL42.3.6...REL42.4.0) --- updated-dependencies: - dependency-name: org.postgresql:postgresql dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 370b2728e..3b58de9d7 100644 --- a/pom.xml +++ b/pom.xml @@ -935,7 +935,7 @@ org.postgresql postgresql - 42.3.6 + 42.4.0 true From a14b8bd60e715a553ab988cf03c213d5120fc3b2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 16 Jul 2022 18:34:35 +0200 Subject: [PATCH 28/97] Bump maven-enforcer-plugin from 3.0.0 to 3.1.0 (#2561) Bumps [maven-enforcer-plugin](https://github.com/apache/maven-enforcer) from 3.0.0 to 3.1.0. - [Release notes](https://github.com/apache/maven-enforcer/releases) - [Commits](https://github.com/apache/maven-enforcer/compare/enforcer-3.0.0...enforcer-3.1.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-enforcer-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3b58de9d7..ec961d98a 100644 --- a/pom.xml +++ b/pom.xml @@ -161,7 +161,7 @@ org.apache.maven.plugins maven-enforcer-plugin - 3.0.0 + 3.1.0 enforce-environment From a111d6799ef8ba3584ccfc468eb3f8829a98e02e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 16 Jul 2022 18:34:43 +0200 Subject: [PATCH 29/97] Bump h2 from 2.1.212 to 2.1.214 (#2563) Bumps [h2](https://github.com/h2database/h2database) from 2.1.212 to 2.1.214. - [Release notes](https://github.com/h2database/h2database/releases) - [Commits](https://github.com/h2database/h2database/compare/version-2.1.212...version-2.1.214) --- updated-dependencies: - dependency-name: com.h2database:h2 dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ec961d98a..9fbc9cb47 100644 --- a/pom.xml +++ b/pom.xml @@ -986,7 +986,7 @@ com.h2database h2 - 2.1.212 + 2.1.214 test From 291790178d927fdda7281f734848a1f0e314f631 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 16 Jul 2022 18:34:50 +0200 Subject: [PATCH 30/97] Bump mariadb-java-client from 3.0.4 to 3.0.6 (#2570) Bumps [mariadb-java-client](https://github.com/mariadb-corporation/mariadb-connector-j) from 3.0.4 to 3.0.6. - [Release notes](https://github.com/mariadb-corporation/mariadb-connector-j/releases) - [Changelog](https://github.com/mariadb-corporation/mariadb-connector-j/blob/master/CHANGELOG.md) - [Commits](https://github.com/mariadb-corporation/mariadb-connector-j/compare/3.0.4...3.0.6) --- updated-dependencies: - dependency-name: org.mariadb.jdbc:mariadb-java-client dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 9fbc9cb47..7c598c075 100644 --- a/pom.xml +++ b/pom.xml @@ -648,7 +648,7 @@ org.mariadb.jdbc mariadb-java-client - 3.0.4 + 3.0.6 true From dbf9afbf82a1faa759ca7a407edfbba34da39344 Mon Sep 17 00:00:00 2001 From: games647 Date: Sat, 16 Jul 2022 18:35:03 +0200 Subject: [PATCH 31/97] Run workflows for pull requests too to verify the test results (#2574) --- .github/workflows/maven.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 407749a8a..0e1946805 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -1,6 +1,10 @@ name: Java CI -on: [push] +on: + push: + pull_request: + branches: + - master jobs: build_and_test: From 9d9e039cac1db112193788762cfc912fb99a1899 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 16 Jul 2022 18:35:09 +0200 Subject: [PATCH 32/97] Bump checker-qual from 3.22.1 to 3.23.0 (#2578) Bumps [checker-qual](https://github.com/typetools/checker-framework) from 3.22.1 to 3.23.0. - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.22.1...checker-framework-3.23.0) --- updated-dependencies: - dependency-name: org.checkerframework:checker-qual dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7c598c075..4cf9ce339 100644 --- a/pom.xml +++ b/pom.xml @@ -972,7 +972,7 @@ org.checkerframework checker-qual - 3.22.1 + 3.23.0 test From 753052843212f9c290b956d8001b63b43dc0440d Mon Sep 17 00:00:00 2001 From: Caro Date: Sat, 16 Jul 2022 18:35:42 +0200 Subject: [PATCH 33/97] Add test for AuthMeApi.getLastLoginMillis (#2562) --- src/test/java/fr/xephi/authme/api/v3/AuthMeApiTest.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/test/java/fr/xephi/authme/api/v3/AuthMeApiTest.java b/src/test/java/fr/xephi/authme/api/v3/AuthMeApiTest.java index 18ec07f70..b3fd01581 100644 --- a/src/test/java/fr/xephi/authme/api/v3/AuthMeApiTest.java +++ b/src/test/java/fr/xephi/authme/api/v3/AuthMeApiTest.java @@ -241,6 +241,12 @@ public class AuthMeApiTest { assertThat(result, equalTo(Instant.ofEpochMilli(1501597979L))); } + @Test + public void testGetLastLoginMillis() { + AuthMeApi result = AuthMeApi.getInstance(); + assertThat(result.getLastLoginTime("notAPlayer"), nullValue()); + } + @Test public void shouldHandleNullLastLoginTime() { // given From f1f5434b4b3542b4ecb9cb9d34c544bdf0f8f51d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=AA=20Huy=20M=E1=BA=A1nh=20T=C3=A2n?= <81731577+lehuymanhtan@users.noreply.github.com> Date: Sat, 16 Jul 2022 23:36:10 +0700 Subject: [PATCH 34/97] Finished translating messages_vn.yml (#2569) Fixed some typo's and finished translating --- src/main/resources/messages/messages_vn.yml | 64 ++++++++++----------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/src/main/resources/messages/messages_vn.yml b/src/main/resources/messages/messages_vn.yml index 8d33f5b21..17895d017 100644 --- a/src/main/resources/messages/messages_vn.yml +++ b/src/main/resources/messages/messages_vn.yml @@ -6,7 +6,7 @@ # Registration registration: disabled: '&cKhông cho phép đăng ký tài khoản trong máy chủ!' - name_taken: '&cBạn có thể đăng ký với tên tài khoản này!' + name_taken: '&cTài khoản này đã được đăng ký!' register_request: '&2Xin vui lòng đăng ký tài khoản với lệnh "/register "' command_usage: '&cSử dụng: /register ' reg_only: '&4Chỉ có thành viên mới có thể tham gia máy chủ, vui lòng truy cập trang web http://example.com để đăng ký thành viên!' @@ -15,7 +15,7 @@ registration: # Password errors on registration password: - match_error: '&cMật khẩu không hợp, xin vui lòng kiểm tra lại!' + match_error: '&cMật khẩu không đúng, vui lòng kiểm tra lại!' name_in_password: '&cBạn không thể đặt mật khẩu bằng tên của mình, vui lòng đặt lại...' unsafe_password: '&cMật khẩu của bạn vừa đặt không an toàn, vui lòng đặt lại...' forbidden_characters: '&4Mật khẩu của bạn chứa ký tự không hợp lệ. Các ký tự cho phép: %valid_chars' @@ -31,17 +31,17 @@ login: # Errors error: - denied_command: '&cĐể được sử dụng lệnh bạn phải hoàn thành xác thực tài khoản đã!' - denied_chat: '&cĐể được chát bạn phải hoàn thành xác thực tài khoản đã!' - unregistered_user: '&cNgười dùng này đã được đăng ký!' + denied_command: '&cBạn phải đăng nhập trước rồi mới có thể dùng lệnh này!' + denied_chat: '&cBạn phải đăng nhập trước rồi mới có thể chat!' + unregistered_user: '&cNgười dùng này chưa được đăng ký!' not_logged_in: '&cBạn chưa đăng nhập!' - no_permission: '&4Bạn không có quyền truy cập lệnh này!' - unexpected_error: '&4Lỗi! Vui lòng liên hệ quản trị viên hoặc admin' - max_registration: '&cBạn đã vượt quá giới hạn tối đa đăng ký tài khoản (%reg_count/%max_acc %reg_names) cho những lần kết nối tài khoản!' - logged_in: '&cBạn đã đăng nhập!' + no_permission: '&4Bạn không có quyền dùng cập lệnh này!' + unexpected_error: '&4Lỗi! Vui lòng liên hệ quản trị viên.' + max_registration: '&cBạn đã vượt quá giới hạn tối đa đăng ký tài khoản (%reg_count/%max_acc %reg_names) trên đường truyền của bạn!' + logged_in: '&cBạn đã đăng nhập rồi!' kick_for_vip: '&eChỉ có thành viên VIP mới được tham gia khi máy chủ đầy!' - kick_unresolved_hostname: '&cLôi đã xảy ra: Không thể phân giải hostname!' - tempban_max_logins: '&cBạn đã bị tạm thời khóa truy cập do đăng nhập sai nhiều lần.' + kick_unresolved_hostname: '&cLỗi đã xảy ra: Không thể phân giải hostname của người chơi!' + tempban_max_logins: '&cBạn đã bị chặn tạm thời do đăng nhập sai quá nhiều lần.' # AntiBot antibot: @@ -59,7 +59,7 @@ misc: account_not_activated: '&cTài khoản của bạn chưa được kích hoạt, vui lòng kiểm tra email!' password_changed: '&2Thay đổi mật khẩu thành công!' logout: '&2Bạn đã đăng xuất!' - reload: '&2Cấu hình và cơ sở dử liệu đã được nạp lại!' + reload: '&2Cấu hình và cơ sở dử liệu đã được tải lại thành công!' usage_change_password: '&cSử dụng: /changepassword ' accounts_owned_self: 'Bạn sở hữu %count tài khoản:' accounts_owned_other: 'Người chơi %name có %count tài khoản:' @@ -71,7 +71,7 @@ session: # Error messages when joining on_join_validation: - same_ip_online: 'Một người chơi với cùng địa chỉ IP đã đang chơi!' + same_ip_online: 'Một người chơi với cùng địa chỉ IP đã kết nối vào máy chủ!' same_nick_online: '&4Tài khoản đang được sử dụng trên máy chủ!' name_length: '&4Tên đăng nhập của bạn quá ngắn hoặc quá dài!' characters_in_name: '&4Tên nhân vật có chứa ký tự không hợp lệ. Các ký tự được cho phép: %valid_chars' @@ -79,7 +79,7 @@ on_join_validation: country_banned: '&4Quốc gia của bạn bị cấm tham gia máy chủ này!' not_owner_error: 'Bạn không phải là chủ sở hữu tài khoản này, hãy chọn tên khác!' invalid_name_case: 'Bạn nên vào máy chủ với tên đăng nhập là %valid, không phải là %invalid.' - quick_command: 'Bạn đang xài lệnh quá nhanh. Hãy thoát máy chủ và chờ một lúc trước khi sử dụng lệnh' + quick_command: 'Bạn đang xài lệnh quá nhanh. Hãy thoát máy chủ và chờ một lúc trước khi sử dụng lệnh.' # Email email: @@ -89,24 +89,24 @@ email: new_email_invalid: '&cEmail mới không hợp lệ, vui lòng thử lại!' old_email_invalid: '&cEmail cũ không hợp lệ, vui lòng thử lại!' invalid: '&cĐại chỉ email không hợp lệ, vui lòng thử lại!' - added: '&2Địa chỉ email đã thêm vào tài khoản của bạn thành công!' - add_not_allowed: '&cViệc thêm email không được cho phép!' + added: '&2Địa chỉ email đã được thêm vào tài khoản của bạn.' + add_not_allowed: '&cKhông được phép thêm địa chỉ email!' request_confirmation: '&cVui lòng xác nhận địa chỉ email của bạn!' changed: '&2Địa chỉ email đã thay đổi!' - change_not_allowed: '&cViệc đổi địa chỉ email không được cho phép' + change_not_allowed: '&cKhông được phép thay đổi địa chỉ email!' email_show: '&2Địa chỉ email hiện tại của bạn là: &f%email' no_email_for_account: '&2Hiện tại bạn chưa liên kết bất kỳ email nào với tài khoản này.' - already_used: '&4Địa chỉ email đã được sử dụng' - incomplete_settings: 'Lỗi: các thiết lập để gửi thư không được cài đặt đầy đủ. Vui lòng liên hệ với quản trị viên để thông báo lỗi.' + already_used: '&4Địa chỉ email đã được sử dụng!' + incomplete_settings: 'Lỗi: các thiết lập để gửi thư không được cài đặt đúng cách. Vui lòng liên hệ với quản trị viên để báo lỗi.' send_failure: 'Không thể gửi thư. Vui lòng liên hệ với ban quản trị.' - change_password_expired: '&cBạn không thể thay đổi mật khẩu bằng lệnh này từ nay.' - email_cooldown_error: '&cMột bức thư đã được gửi gần đây. Bạn phải chờ %time trước khi có thể gửi một bức thư mới.' + change_password_expired: '&cBạn không thể thay đổi mật khẩu bằng lệnh này nữa.' + email_cooldown_error: '&cMột email đã được gửi gần đây. Bạn phải chờ %time trước khi có thể gửi một email mới.' # Password recovery by email recovery: forgot_password_hint: '&aBạn quên mật khẩu? Vui lòng gõ lệnh "/email recovery "' command_usage: '&cSử dụng: /email recovery ' - email_sent: '&2Email phục hồi đã được gửi thành công! Vui lòng kiểm tra hộp thư đến trong email của bạn.' + email_sent: '&2Email khôi phục đã được gửi thành công! Vui lòng kiểm tra hộp thư đến trong email của bạn.' code: code_sent: 'Một mã khôi phục mật khẩu đã được gửi đến địa chỉ email của bạn.' incorrect: 'Mã khôi phục không đúng! Dùng lệnh /email recovery [email] để tạo một mã mới' @@ -116,20 +116,20 @@ recovery: # Captcha captcha: - usage_captcha: '&eĐể đăng nhập vui lòng hãy nhập mã Captcha, gõ lệnh "/captcha %captcha_code"' + usage_captcha: '&eĐể đăng nhập, hãy nhập mã Captcha, Vui lòng gõ lệnh "/captcha %captcha_code"' wrong_captcha: '&cSai mã captcha, Vui lòng gõ lệnh "/captcha %captcha_code"!' - valid_captcha: '&2Mã captcha đã được xác nhận!' - # TODO captcha_for_registration: 'To register you have to solve a captcha first, please use the command: /captcha %captcha_code' - # TODO register_captcha_valid: '&2Valid captcha! You may now register with /register' + valid_captcha: '&2Đã xác minh captcha!' + captcha_for_registration: 'Để đăng ký, hãy nhập mã Captcha trước. Vui lòng gõ lệnh "/captcha %captcha_code"' + register_captcha_valid: '&2Đã xác minh captcha! Bây giờ bạn có thể đăng ký với lệnh "/register"' # Verification code verification: - # TODO code_required: '&3This command is sensitive and requires an email verification! Check your inbox and follow the email''s instructions.' + code_required: '&3Lệnh này nhạy cảm và yêu cầu xác minh email! Vui lòng iểm tra hộp thư đến của bạn và làm theo hướng dẫn trong email.' command_usage: '&cLệnh: /verification ' - # TODO incorrect_code: '&cIncorrect code, please type "/verification " into the chat, using the code you received by email' - success: '&2Danh tính của bạn đã được xác minh! Bạn đã có thể sử dụng các lệnh trong phiên đăng nhập này' - # TODO already_verified: '&2You can already execute every sensitive command within the current session!' - # TODO code_expired: '&3Your code has expired! Execute another sensitive command to get a new code!' + incorrect_code: '&cMã xác minh không chính xác, vui lòng nhập "/verify " với mã bạn nhận được qua email.' + success: '&2Xác minh thành công! Bạn đã có thể sử dụng các lệnh trong phiên đăng nhập này.' + already_verified: '&2Bạn đã có thể thực hiện mọi lệnh nhạy cảm trong phiên hiện tại!' + code_expired: '&3Mã xác minh đã hết han! Hãy sử dụng một lệnh nhạy cảm để lấy mã mới.' email_needed: '&3Để xác định danh tính của bạn, bạn cần kết nối tài khoản này với 1 email!' # Time units @@ -147,7 +147,7 @@ time: two_factor: code_created: '&2Mã bí mật của bạn là %code. Bạn có thể quét nó tại đây %url' confirmation_required: 'Hãy xác thực mã của bạn bằng lệnh /2fa confirm ' - code_required: 'Hãy gửi đi mã xác thực 2 lớp của bạn bằng lệnh /2fa code ' + code_required: 'Hãy nhập mã xác thực 2 lớp của bạn bằng lệnh /2fa code ' already_enabled: 'Xác thực 2 lớp đã được kích hoạt trên tài khoản của bạn!' enable_error_no_code: 'Không có mã xác thực nào đã được tạo cho tài khoản của bạn hoặc nó đã hết hạn. Hãy sử dụng lệnh /2fa add' enable_success: 'Đã thành công kích hoạt xác thực 2 lớp cho tài khoản của bạn!' From 64c45c43df683f514f32f6591a45380f3fd817bb Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Sun, 17 Jul 2022 18:36:06 +0200 Subject: [PATCH 35/97] Update dependencies --- pom.xml | 61 +++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 40 insertions(+), 21 deletions(-) diff --git a/pom.xml b/pom.xml index 4cf9ce339..4dc043741 100644 --- a/pom.xml +++ b/pom.xml @@ -64,7 +64,7 @@ 3.6.0 - 1.18-rc3-R0.1-SNAPSHOT + 1.19-R0.1-SNAPSHOT AuthMe @@ -549,6 +549,17 @@ true + + + essentialsx-repo + https://repo.essentialsx.net/releases/ + + true + + + false + + @@ -689,18 +700,18 @@ - + com.google.guava guava 31.0.1-jre true - + com.google.code.gson gson - 2.8.8 + 2.8.9 true @@ -724,7 +735,7 @@ org.bstats bstats-bukkit - 2.2.1 + 3.0.0 true @@ -869,9 +880,9 @@ - net.ess3 + net.essentialsx EssentialsX - 2.16.1 + 2.19.4 provided @@ -879,32 +890,40 @@ paperlib - net.ess3 - NMSProvider + org.bstats + bstats-bukkit - net.ess3 - UpdatedMetaProvider + net.essentialsx + BaseProviders - net.ess3 - 1_8_R1Provider + net.essentialsx + PaperProvider - net.ess3 - 1_8_R2Provider + net.essentialsx + NMSReflectionProvider - net.ess3 - LegacyProvider + net.essentialsx + 1_8Provider - net.ess3 - ReflectionProvider + net.essentialsx + 1_12Provider - net.ess3 - FlattenedProvider + org.spigotmc + spigot-api + + + org.spongepowered + configurate-yaml + + + org.checkerframework + checker-qual From a67a4bb72b955ddda337a8dd0fa2a71143e1bad4 Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Sun, 17 Jul 2022 18:40:11 +0200 Subject: [PATCH 36/97] Don't let unrestricted usernames bypass the locked ip-username check --- .../fr/xephi/authme/process/join/AsynchronousJoin.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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 cacfdbd6c..0e49eeee1 100644 --- a/src/main/java/fr/xephi/authme/process/join/AsynchronousJoin.java +++ b/src/main/java/fr/xephi/authme/process/join/AsynchronousJoin.java @@ -93,6 +93,11 @@ public class AsynchronousJoin implements AsynchronousProcess { final String name = player.getName().toLowerCase(); final String ip = PlayerUtils.getPlayerIp(player); + if (!validationService.fulfillsNameRestrictions(player)) { + handlePlayerWithUnmetNameRestriction(player, ip); + return; + } + if (service.getProperty(RestrictionSettings.UNRESTRICTED_NAMES).contains(name)) { return; } @@ -107,11 +112,6 @@ public class AsynchronousJoin implements AsynchronousProcess { pluginHookService.setEssentialsSocialSpyStatus(player, false); } - if (!validationService.fulfillsNameRestrictions(player)) { - handlePlayerWithUnmetNameRestriction(player, ip); - return; - } - if (!validatePlayerCountForIp(player, ip)) { return; } From d07cb90858a0e8de1f3143ad3c89df5765f6e2df Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Mon, 18 Jul 2022 13:01:51 +0200 Subject: [PATCH 37/97] Fix build under jdk 9+ --- pom.xml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pom.xml b/pom.xml index 4dc043741..2427e3366 100644 --- a/pom.xml +++ b/pom.xml @@ -453,6 +453,13 @@ false + + + javax.xml.bind + jaxb-api + 2.3.1 + + From 0ac1854a5230b28cd81d51deab0353b35787db24 Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Mon, 18 Jul 2022 13:03:05 +0200 Subject: [PATCH 38/97] Implement allowPublicKeyRetrieval option in mysql datasource --- docs/config.md | 7 +++++-- src/main/java/fr/xephi/authme/datasource/MySQL.java | 5 +++++ .../xephi/authme/settings/properties/DatabaseSettings.java | 5 +++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/docs/config.md b/docs/config.md index 6d01f5e4f..3edfd611c 100644 --- a/docs/config.md +++ b/docs/config.md @@ -1,5 +1,5 @@ - + ## AuthMe Configuration The first time you run AuthMe it will create a config.yml file in the plugins/AuthMe folder, @@ -24,6 +24,9 @@ DataSource: # We would not recommend to set this option to false. # Set this option to false at your own risk if and only if you know what you're doing mySQLCheckServerCertificate: true + # Authorize client to retrieve RSA server public key. + # Advanced option, ignore if you don't know what it means. + mySQLAllowPublicKeyRetrieval: true # Username to connect to the MySQL database mySQLUsername: authme # Password to connect to the MySQL database @@ -590,4 +593,4 @@ To change settings on a running server, save your changes to config.yml and use --- -This page was automatically generated on the [AuthMe/AuthMeReloaded repository](https://github.com/AuthMe/AuthMeReloaded/tree/master/docs/) on Sat Dec 25 15:40:26 CET 2021 +This page was automatically generated on the [AuthMe/AuthMeReloaded repository](https://github.com/AuthMe/AuthMeReloaded/tree/master/docs/) on Mon Jul 18 13:02:11 CEST 2022 diff --git a/src/main/java/fr/xephi/authme/datasource/MySQL.java b/src/main/java/fr/xephi/authme/datasource/MySQL.java index e55a24fd7..465084a11 100644 --- a/src/main/java/fr/xephi/authme/datasource/MySQL.java +++ b/src/main/java/fr/xephi/authme/datasource/MySQL.java @@ -39,6 +39,7 @@ public class MySQL extends AbstractSqlDataSource { private boolean useSsl; private boolean serverCertificateVerification; + private boolean allowPublicKeyRetrieval; private String host; private String port; private String username; @@ -118,6 +119,7 @@ public class MySQL extends AbstractSqlDataSource { this.maxLifetime = settings.getProperty(DatabaseSettings.MYSQL_CONNECTION_MAX_LIFETIME); this.useSsl = settings.getProperty(DatabaseSettings.MYSQL_USE_SSL); this.serverCertificateVerification = settings.getProperty(DatabaseSettings.MYSQL_CHECK_SERVER_CERTIFICATE); + this.allowPublicKeyRetrieval = settings.getProperty(DatabaseSettings.MYSQL_ALLOW_PUBLIC_KEY_RETRIEVAL); } /** @@ -147,6 +149,9 @@ public class MySQL extends AbstractSqlDataSource { // Disabling server certificate verification on need if (!serverCertificateVerification) { ds.addDataSourceProperty("verifyServerCertificate", String.valueOf(false)); + } // Disabling server certificate verification on need + if (allowPublicKeyRetrieval) { + ds.addDataSourceProperty("allowPublicKeyRetrieval", String.valueOf(true)); } // Encoding diff --git a/src/main/java/fr/xephi/authme/settings/properties/DatabaseSettings.java b/src/main/java/fr/xephi/authme/settings/properties/DatabaseSettings.java index c0c570c2b..9f299263d 100644 --- a/src/main/java/fr/xephi/authme/settings/properties/DatabaseSettings.java +++ b/src/main/java/fr/xephi/authme/settings/properties/DatabaseSettings.java @@ -37,6 +37,11 @@ public final class DatabaseSettings implements SettingsHolder { public static final Property MYSQL_CHECK_SERVER_CERTIFICATE = newProperty( "DataSource.mySQLCheckServerCertificate", true ); + @Comment({"Authorize client to retrieve RSA server public key.", + "Advanced option, ignore if you don't know what it means."}) + public static final Property MYSQL_ALLOW_PUBLIC_KEY_RETRIEVAL = + newProperty( "DataSource.mySQLAllowPublicKeyRetrieval", true ); + @Comment("Username to connect to the MySQL database") public static final Property MYSQL_USERNAME = newProperty("DataSource.mySQLUsername", "authme"); From ed4200b23f82216c77873f72bc04b9119e48552d Mon Sep 17 00:00:00 2001 From: HarvelsX <90945793+HarvelsX@users.noreply.github.com> Date: Mon, 25 Jul 2022 12:12:44 +0300 Subject: [PATCH 39/97] Fix column check: https://github.com/AuthMe/AuthMeReloaded/issues/2543; --- src/main/java/fr/xephi/authme/datasource/MySQL.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/fr/xephi/authme/datasource/MySQL.java b/src/main/java/fr/xephi/authme/datasource/MySQL.java index 465084a11..5eb188788 100644 --- a/src/main/java/fr/xephi/authme/datasource/MySQL.java +++ b/src/main/java/fr/xephi/authme/datasource/MySQL.java @@ -299,7 +299,7 @@ public class MySQL extends AbstractSqlDataSource { } private boolean isColumnMissing(DatabaseMetaData metaData, String columnName) throws SQLException { - try (ResultSet rs = metaData.getColumns(null, null, tableName, columnName)) { + try (ResultSet rs = metaData.getColumns(database, null, tableName, columnName)) { return !rs.next(); } } @@ -348,6 +348,11 @@ public class MySQL extends AbstractSqlDataSource { return false; } + @Override + String getJdbcUrl(String host, String port, String database) { + return "jdbc:mysql://" + host + ":" + port + "/" + database; + } + @Override public Set getRecordsToPurge(long until) { Set list = new HashSet<>(); From a9898fd806a37413691dc89c05153cf30040c30d Mon Sep 17 00:00:00 2001 From: HarvelsX <90945793+HarvelsX@users.noreply.github.com> Date: Mon, 25 Jul 2022 12:13:46 +0300 Subject: [PATCH 40/97] Add support MariaDB driver: https://github.com/AuthMe/AuthMeReloaded/issues/2556; --- .../datasource/AbstractSqlDataSource.java | 2 ++ .../authme/datasource/DataSourceType.java | 2 ++ .../fr/xephi/authme/datasource/MariaDB.java | 22 +++++++++++++++++++ .../fr/xephi/authme/datasource/MySQL.java | 2 +- .../datasource/PostgreSqlDataSource.java | 7 +++++- .../fr/xephi/authme/datasource/SQLite.java | 7 +++++- .../initialization/DataSourceProvider.java | 4 ++++ 7 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 src/main/java/fr/xephi/authme/datasource/MariaDB.java diff --git a/src/main/java/fr/xephi/authme/datasource/AbstractSqlDataSource.java b/src/main/java/fr/xephi/authme/datasource/AbstractSqlDataSource.java index 067851684..6c12a1710 100644 --- a/src/main/java/fr/xephi/authme/datasource/AbstractSqlDataSource.java +++ b/src/main/java/fr/xephi/authme/datasource/AbstractSqlDataSource.java @@ -167,4 +167,6 @@ public abstract class AbstractSqlDataSource implements DataSource { return DataSourceValueImpl.unknownRow(); } } + + abstract String getJdbcUrl(String host, String port, String database); } diff --git a/src/main/java/fr/xephi/authme/datasource/DataSourceType.java b/src/main/java/fr/xephi/authme/datasource/DataSourceType.java index d9969ac95..841542a51 100644 --- a/src/main/java/fr/xephi/authme/datasource/DataSourceType.java +++ b/src/main/java/fr/xephi/authme/datasource/DataSourceType.java @@ -7,6 +7,8 @@ public enum DataSourceType { MYSQL, + MARIADB, + POSTGRESQL, SQLITE diff --git a/src/main/java/fr/xephi/authme/datasource/MariaDB.java b/src/main/java/fr/xephi/authme/datasource/MariaDB.java new file mode 100644 index 000000000..e6e26c1ce --- /dev/null +++ b/src/main/java/fr/xephi/authme/datasource/MariaDB.java @@ -0,0 +1,22 @@ +package fr.xephi.authme.datasource; + +import fr.xephi.authme.datasource.mysqlextensions.MySqlExtensionsFactory; +import fr.xephi.authme.settings.Settings; + +import java.sql.SQLException; + +public class MariaDB extends MySQL { + public MariaDB(Settings settings, MySqlExtensionsFactory extensionsFactory) throws SQLException { + super(settings, extensionsFactory); + } + + @Override + String getJdbcUrl(String host, String port, String database) { + return "jdbc:mariadb://" + host + ":" + port + "/" + database; + } + + @Override + public DataSourceType getType() { + return DataSourceType.MARIADB; + } +} diff --git a/src/main/java/fr/xephi/authme/datasource/MySQL.java b/src/main/java/fr/xephi/authme/datasource/MySQL.java index 5eb188788..2f524704e 100644 --- a/src/main/java/fr/xephi/authme/datasource/MySQL.java +++ b/src/main/java/fr/xephi/authme/datasource/MySQL.java @@ -134,7 +134,7 @@ public class MySQL extends AbstractSqlDataSource { ds.setMaxLifetime(maxLifetime * 1000L); // Database URL - ds.setJdbcUrl("jdbc:mysql://" + this.host + ":" + this.port + "/" + this.database); + ds.setJdbcUrl(this.getJdbcUrl(this.host, this.port, this.database)); // Auth ds.setUsername(this.username); diff --git a/src/main/java/fr/xephi/authme/datasource/PostgreSqlDataSource.java b/src/main/java/fr/xephi/authme/datasource/PostgreSqlDataSource.java index b0186f4b7..070c719a5 100644 --- a/src/main/java/fr/xephi/authme/datasource/PostgreSqlDataSource.java +++ b/src/main/java/fr/xephi/authme/datasource/PostgreSqlDataSource.java @@ -119,7 +119,7 @@ public class PostgreSqlDataSource extends AbstractSqlDataSource { // Database URL ds.setDriverClassName("org.postgresql.Driver"); - ds.setJdbcUrl("jdbc:postgresql://" + this.host + ":" + this.port + "/" + this.database); + ds.setJdbcUrl(this.getJdbcUrl(this.host, this.port, this.database)); // Auth ds.setUsername(this.username); @@ -306,6 +306,11 @@ public class PostgreSqlDataSource extends AbstractSqlDataSource { return false; } + @Override + String getJdbcUrl(String host, String port, String database) { + return "jdbc:postgresql://" + host + ":" + port + "/" + database; + } + @Override public Set getRecordsToPurge(long until) { Set list = new HashSet<>(); diff --git a/src/main/java/fr/xephi/authme/datasource/SQLite.java b/src/main/java/fr/xephi/authme/datasource/SQLite.java index 24b8b9462..966508082 100644 --- a/src/main/java/fr/xephi/authme/datasource/SQLite.java +++ b/src/main/java/fr/xephi/authme/datasource/SQLite.java @@ -88,7 +88,7 @@ public class SQLite extends AbstractSqlDataSource { } logger.debug("SQLite driver loaded"); - this.con = DriverManager.getConnection("jdbc:sqlite:" + this.dataFolder + File.separator + database + ".db"); + this.con = DriverManager.getConnection(this.getJdbcUrl(this.dataFolder.getAbsolutePath(), "", this.database)); this.columnsHandler = AuthMeColumnsHandler.createForSqlite(con, settings); } @@ -405,6 +405,11 @@ public class SQLite extends AbstractSqlDataSource { + currentTimestamp + ", to all " + updatedRows + " rows"); } + @Override + String getJdbcUrl(String dataPath, String ignored, String database) { + return "jdbc:sqlite:" + dataPath + File.separator + database + ".db"; + } + private static void close(Connection con) { if (con != null) { try { diff --git a/src/main/java/fr/xephi/authme/initialization/DataSourceProvider.java b/src/main/java/fr/xephi/authme/initialization/DataSourceProvider.java index 857a795a9..de5eea463 100644 --- a/src/main/java/fr/xephi/authme/initialization/DataSourceProvider.java +++ b/src/main/java/fr/xephi/authme/initialization/DataSourceProvider.java @@ -5,6 +5,7 @@ import fr.xephi.authme.data.auth.PlayerCache; import fr.xephi.authme.datasource.CacheDataSource; import fr.xephi.authme.datasource.DataSource; import fr.xephi.authme.datasource.DataSourceType; +import fr.xephi.authme.datasource.MariaDB; import fr.xephi.authme.datasource.MySQL; import fr.xephi.authme.datasource.PostgreSqlDataSource; import fr.xephi.authme.datasource.SQLite; @@ -66,6 +67,9 @@ public class DataSourceProvider implements Provider { case MYSQL: dataSource = new MySQL(settings, mySqlExtensionsFactory); break; + case MARIADB: + dataSource = new MariaDB(settings, mySqlExtensionsFactory); + break; case POSTGRESQL: dataSource = new PostgreSqlDataSource(settings, mySqlExtensionsFactory); break; From 61710e9a47f982cb5e806444c57d38176cc55d04 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 27 Jul 2022 23:37:26 +0200 Subject: [PATCH 41/97] Bump maven-deploy-plugin from 2.8.2 to 3.0.0 (#2580) Bumps [maven-deploy-plugin](https://github.com/apache/maven-deploy-plugin) from 2.8.2 to 3.0.0. - [Release notes](https://github.com/apache/maven-deploy-plugin/releases) - [Commits](https://github.com/apache/maven-deploy-plugin/compare/maven-deploy-plugin-2.8.2...maven-deploy-plugin-3.0.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-deploy-plugin dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2427e3366..bebdb452a 100644 --- a/pom.xml +++ b/pom.xml @@ -436,7 +436,7 @@ org.apache.maven.plugins maven-deploy-plugin - 2.8.2 + 3.0.0 From 4652aae8f7d8a1001c1da529ae0bb570d91de633 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 27 Jul 2022 23:37:37 +0200 Subject: [PATCH 42/97] Bump maven-install-plugin from 2.5.2 to 3.0.1 (#2583) Bumps [maven-install-plugin](https://github.com/apache/maven-install-plugin) from 2.5.2 to 3.0.1. - [Release notes](https://github.com/apache/maven-install-plugin/releases) - [Commits](https://github.com/apache/maven-install-plugin/compare/maven-install-plugin-2.5.2...maven-install-plugin-3.0.1) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-install-plugin dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index bebdb452a..27ddfd7ac 100644 --- a/pom.xml +++ b/pom.xml @@ -430,7 +430,7 @@ org.apache.maven.plugins maven-install-plugin - 2.5.2 + 3.0.1 From be2881182f1a201cd21531822a2c84cab478e82b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 27 Jul 2022 23:37:43 +0200 Subject: [PATCH 43/97] Bump maven-resources-plugin from 3.2.0 to 3.3.0 (#2586) Bumps [maven-resources-plugin](https://github.com/apache/maven-resources-plugin) from 3.2.0 to 3.3.0. - [Release notes](https://github.com/apache/maven-resources-plugin/releases) - [Commits](https://github.com/apache/maven-resources-plugin/compare/maven-resources-plugin-3.2.0...maven-resources-plugin-3.3.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-resources-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 27ddfd7ac..3c3739381 100644 --- a/pom.xml +++ b/pom.xml @@ -189,7 +189,7 @@ org.apache.maven.plugins maven-resources-plugin - 3.2.0 + 3.3.0 From 24d03aa1e20e8fb045604185b21a81596fd4057c Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Thu, 28 Jul 2022 18:11:57 +0200 Subject: [PATCH 44/97] Add missing "MARIADB" datasource backend to the configuration file, remove "mySQLDriverClassName" property as it is no longer needed. --- docs/config.md | 11 +++------- .../fr/xephi/authme/datasource/MariaDB.java | 5 +++++ .../fr/xephi/authme/datasource/MySQL.java | 20 +++++++++---------- .../settings/SettingsMigrationService.java | 11 +++++----- .../settings/properties/DatabaseSettings.java | 9 +-------- 5 files changed, 25 insertions(+), 31 deletions(-) diff --git a/docs/config.md b/docs/config.md index 3edfd611c..dfe816b87 100644 --- a/docs/config.md +++ b/docs/config.md @@ -1,5 +1,5 @@ - + ## AuthMe Configuration The first time you run AuthMe it will create a config.yml file in the plugins/AuthMe folder, @@ -9,7 +9,7 @@ the generated config.yml file. ```yml DataSource: # What type of database do you want to use? - # Valid values: SQLITE, MYSQL, POSTGRESQL + # Valid values: SQLITE, MARIADB, MYSQL, POSTGRESQL backend: SQLITE # Enable the database caching system, should be disabled on bungeecord environments # or when a website integration is being used. @@ -31,11 +31,6 @@ DataSource: mySQLUsername: authme # Password to connect to the MySQL database mySQLPassword: '12345' - # Driver Name of the MySQL database. - # Built-in drivers: - # MySQL: 'fr.xephi.authme.libs.com.mysql.cj.jdbc.Driver' - # MariaDB: 'fr.xephi.authme.libs.org.mariadb.jdbc.Driver' - mySQLDriverClassName: fr.xephi.authme.libs.com.mysql.cj.jdbc.Driver # Database Name, use with converters or as SQLITE database name mySQLDatabase: authme # Table of the database @@ -593,4 +588,4 @@ To change settings on a running server, save your changes to config.yml and use --- -This page was automatically generated on the [AuthMe/AuthMeReloaded repository](https://github.com/AuthMe/AuthMeReloaded/tree/master/docs/) on Mon Jul 18 13:02:11 CEST 2022 +This page was automatically generated on the [AuthMe/AuthMeReloaded repository](https://github.com/AuthMe/AuthMeReloaded/tree/master/docs/) on Thu Jul 28 18:11:22 CEST 2022 diff --git a/src/main/java/fr/xephi/authme/datasource/MariaDB.java b/src/main/java/fr/xephi/authme/datasource/MariaDB.java index e6e26c1ce..8fa35595f 100644 --- a/src/main/java/fr/xephi/authme/datasource/MariaDB.java +++ b/src/main/java/fr/xephi/authme/datasource/MariaDB.java @@ -15,6 +15,11 @@ public class MariaDB extends MySQL { return "jdbc:mariadb://" + host + ":" + port + "/" + database; } + @Override + protected String getDriverClassName() { + return "org.mariadb.jdbc.Driver"; + } + @Override public DataSourceType getType() { return DataSourceType.MARIADB; diff --git a/src/main/java/fr/xephi/authme/datasource/MySQL.java b/src/main/java/fr/xephi/authme/datasource/MySQL.java index 2f524704e..ff571c54f 100644 --- a/src/main/java/fr/xephi/authme/datasource/MySQL.java +++ b/src/main/java/fr/xephi/authme/datasource/MySQL.java @@ -44,7 +44,6 @@ public class MySQL extends AbstractSqlDataSource { private String port; private String username; private String password; - private String className; private String database; private String tableName; private int poolSize; @@ -90,6 +89,15 @@ public class MySQL extends AbstractSqlDataSource { setParameters(settings, extensionsFactory); } + /** + * Returns the path of the Driver class to use when connecting to the database. + * + * @return the dotted path of the SQL driver class to be used + */ + protected String getDriverClassName() { + return "com.mysql.cj.jdbc.Driver"; + } + /** * Retrieves various settings. * @@ -101,14 +109,6 @@ public class MySQL extends AbstractSqlDataSource { this.port = settings.getProperty(DatabaseSettings.MYSQL_PORT); this.username = settings.getProperty(DatabaseSettings.MYSQL_USERNAME); this.password = settings.getProperty(DatabaseSettings.MYSQL_PASSWORD); - this.className = settings.getProperty(DatabaseSettings.MYSQL_DRIVER_CLASS_NAME); - try { - Class.forName(this.className); - } catch (ClassNotFoundException e) { - this.className = DatabaseSettings.MYSQL_DRIVER_CLASS_NAME.getDefaultValue(); - logger.info("Driver class '" + this.className + "' not found! Falling back to the built-in MySQL driver (" - + this.className + ")"); - } this.database = settings.getProperty(DatabaseSettings.MYSQL_DATABASE); this.tableName = settings.getProperty(DatabaseSettings.MYSQL_TABLE); this.columnOthers = settings.getProperty(HooksSettings.MYSQL_OTHER_USERNAME_COLS); @@ -141,7 +141,7 @@ public class MySQL extends AbstractSqlDataSource { ds.setPassword(this.password); // Driver - ds.setDriverClassName(this.className); + ds.setDriverClassName(this.getDriverClassName()); // Request mysql over SSL ds.addDataSourceProperty("useSSL", String.valueOf(useSsl)); diff --git a/src/main/java/fr/xephi/authme/settings/SettingsMigrationService.java b/src/main/java/fr/xephi/authme/settings/SettingsMigrationService.java index a8b437d76..2152baf5c 100644 --- a/src/main/java/fr/xephi/authme/settings/SettingsMigrationService.java +++ b/src/main/java/fr/xephi/authme/settings/SettingsMigrationService.java @@ -6,6 +6,7 @@ import ch.jalu.configme.properties.Property; import ch.jalu.configme.properties.convertresult.PropertyValue; import ch.jalu.configme.resource.PropertyReader; import fr.xephi.authme.ConsoleLogger; +import fr.xephi.authme.datasource.DataSourceType; import fr.xephi.authme.initialization.DataFolder; import fr.xephi.authme.output.ConsoleLoggerFactory; import fr.xephi.authme.output.LogLevel; @@ -65,10 +66,10 @@ public class SettingsMigrationService extends PlainMigrationService { configurationData.setValue(ALLOWED_NICKNAME_CHARACTERS, "[a-zA-Z0-9_]*"); changes = true; } - String driverClass = reader.getString(DatabaseSettings.MYSQL_DRIVER_CLASS_NAME.getPath()); - if ("com.mysql.jdbc.Driver".equals(driverClass) || "com.mysql.cj.jdbc.Driver".equals(driverClass)) { - configurationData.setValue(DatabaseSettings.MYSQL_DRIVER_CLASS_NAME, - DatabaseSettings.MYSQL_DRIVER_CLASS_NAME.getDefaultValue()); + + String driverClass = reader.getString("DataSource.mySQLDriverClassName"); + if ("fr.xephi.authme.libs.org.mariadb.jdbc.Driver".equals(driverClass)) { + configurationData.setValue(DatabaseSettings.BACKEND, DataSourceType.MARIADB); changes = true; } @@ -100,7 +101,7 @@ public class SettingsMigrationService extends PlainMigrationService { "settings.restrictions.keepCollisionsDisabled", "settings.forceCommands", "settings.forceCommandsAsConsole", "settings.forceRegisterCommands", "settings.forceRegisterCommandsAsConsole", "settings.sessions.sessionExpireOnIpChange", "settings.restrictions.otherAccountsCmd", - "settings.restrictions.otherAccountsCmdThreshold"}; + "settings.restrictions.otherAccountsCmdThreshold, DataSource.mySQLDriverClassName"}; for (String deprecatedPath : deprecatedProperties) { if (reader.contains(deprecatedPath)) { return true; diff --git a/src/main/java/fr/xephi/authme/settings/properties/DatabaseSettings.java b/src/main/java/fr/xephi/authme/settings/properties/DatabaseSettings.java index 9f299263d..0792d9d74 100644 --- a/src/main/java/fr/xephi/authme/settings/properties/DatabaseSettings.java +++ b/src/main/java/fr/xephi/authme/settings/properties/DatabaseSettings.java @@ -10,7 +10,7 @@ import static ch.jalu.configme.properties.PropertyInitializer.newProperty; public final class DatabaseSettings implements SettingsHolder { @Comment({"What type of database do you want to use?", - "Valid values: SQLITE, MYSQL, POSTGRESQL"}) + "Valid values: SQLITE, MARIADB, MYSQL, POSTGRESQL"}) public static final Property BACKEND = newProperty(DataSourceType.class, "DataSource.backend", DataSourceType.SQLITE); @@ -49,13 +49,6 @@ public final class DatabaseSettings implements SettingsHolder { @Comment("Password to connect to the MySQL database") public static final Property MYSQL_PASSWORD = newProperty("DataSource.mySQLPassword", "12345"); - - @Comment({"Driver Name of the MySQL database.", - "Built-in drivers:", - " MySQL: 'fr.xephi.authme.libs.com.mysql.cj.jdbc.Driver'", - " MariaDB: 'fr.xephi.authme.libs.org.mariadb.jdbc.Driver'"}) - public static final Property MYSQL_DRIVER_CLASS_NAME = - newProperty("DataSource.mySQLDriverClassName", "fr.xephi.authme.libs.com.mysql.cj.jdbc.Driver"); @Comment("Database Name, use with converters or as SQLITE database name") public static final Property MYSQL_DATABASE = From 4fe6cfe485bcd56e8b0e7fe4aba33ea6e858f489 Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Thu, 28 Jul 2022 18:42:06 +0200 Subject: [PATCH 45/97] Bump the mysql connector version, fix minor dependency shading issues --- .github/dependabot.yml | 1 - pom.xml | 48 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 3b0775a28..240dd9bb0 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -9,5 +9,4 @@ updates: - dependency-name: com.google.code.gson:gson - dependency-name: com.google.guava:guava - dependency-name: org.apache.logging.log4j:log4j-core - - dependency-name: mysql:mysql-connector-java - dependency-name: com.zaxxer:HikariCP diff --git a/pom.xml b/pom.xml index 3c3739381..94e4fde72 100644 --- a/pom.xml +++ b/pom.xml @@ -293,7 +293,13 @@ + 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 @@ -316,6 +322,14 @@ 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 @@ -365,6 +379,18 @@ 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 @@ -398,6 +424,10 @@ com.mysql fr.xephi.authme.libs.com.mysql + + com.google.protobuf + fr.xephi.authme.libs.com.google.protobuf + @@ -660,7 +690,7 @@ mysql mysql-connector-java - 8.0.26 + 8.0.28 true @@ -713,6 +743,12 @@ guava 31.0.1-jre true + + + org.checkerframework + checker-qual + + @@ -761,6 +797,10 @@ BukkitExecutors com.comphenix.executors + + byte-buddy + net.bytebuddy + @@ -963,6 +1003,12 @@ postgresql 42.4.0 true + + + org.checkerframework + checker-qual + + From 9c928e04e5077d80dbe03b246f8463ef49b17a4d Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Thu, 28 Jul 2022 18:48:35 +0200 Subject: [PATCH 46/97] Bump the mysql connector version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 94e4fde72..fed253cc8 100644 --- a/pom.xml +++ b/pom.xml @@ -690,7 +690,7 @@ mysql mysql-connector-java - 8.0.28 + 8.0.30 true From aaba6dc24dfc42b18de8946acf63017404f56b8d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 10 Aug 2022 12:26:32 +0200 Subject: [PATCH 47/97] Bump postgresql from 42.4.0 to 42.4.1 (#2592) Bumps [postgresql](https://github.com/pgjdbc/pgjdbc) from 42.4.0 to 42.4.1. - [Release notes](https://github.com/pgjdbc/pgjdbc/releases) - [Changelog](https://github.com/pgjdbc/pgjdbc/blob/master/CHANGELOG.md) - [Commits](https://github.com/pgjdbc/pgjdbc/compare/REL42.4.0...REL42.4.1) --- updated-dependencies: - dependency-name: org.postgresql:postgresql dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index fed253cc8..424696248 100644 --- a/pom.xml +++ b/pom.xml @@ -1001,7 +1001,7 @@ org.postgresql postgresql - 42.4.0 + 42.4.1 true From 817a4af65b78ec91983e353b3e6645a1dfe7e48a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 10 Aug 2022 12:26:40 +0200 Subject: [PATCH 48/97] Bump checker-qual from 3.23.0 to 3.24.0 (#2593) Bumps [checker-qual](https://github.com/typetools/checker-framework) from 3.23.0 to 3.24.0. - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.23.0...checker-framework-3.24.0) --- updated-dependencies: - dependency-name: org.checkerframework:checker-qual dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 424696248..9cb846a35 100644 --- a/pom.xml +++ b/pom.xml @@ -1044,7 +1044,7 @@ org.checkerframework checker-qual - 3.23.0 + 3.24.0 test From 4b2a122581b52a61b321d638463a3483d44ff0e4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 10 Aug 2022 12:26:47 +0200 Subject: [PATCH 49/97] Bump mariadb-java-client from 3.0.6 to 3.0.7 (#2594) Bumps [mariadb-java-client](https://github.com/mariadb-corporation/mariadb-connector-j) from 3.0.6 to 3.0.7. - [Release notes](https://github.com/mariadb-corporation/mariadb-connector-j/releases) - [Changelog](https://github.com/mariadb-corporation/mariadb-connector-j/blob/master/CHANGELOG.md) - [Commits](https://github.com/mariadb-corporation/mariadb-connector-j/compare/3.0.6...3.0.7) --- updated-dependencies: - dependency-name: org.mariadb.jdbc:mariadb-java-client dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 9cb846a35..1e864bcb5 100644 --- a/pom.xml +++ b/pom.xml @@ -696,7 +696,7 @@ org.mariadb.jdbc mariadb-java-client - 3.0.6 + 3.0.7 true From 1869c3097f4be179bb890eb34d430fa57d2a9a11 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 10 Aug 2022 12:26:54 +0200 Subject: [PATCH 50/97] Bump maven-site-plugin from 3.12.0 to 3.12.1 (#2595) Bumps [maven-site-plugin](https://github.com/apache/maven-site-plugin) from 3.12.0 to 3.12.1. - [Release notes](https://github.com/apache/maven-site-plugin/releases) - [Commits](https://github.com/apache/maven-site-plugin/compare/maven-site-plugin-3.12.0...maven-site-plugin-3.12.1) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-site-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1e864bcb5..7d778f3c5 100644 --- a/pom.xml +++ b/pom.xml @@ -472,7 +472,7 @@ org.apache.maven.plugins maven-site-plugin - 3.12.0 + 3.12.1 From 70f06b6da820d00fc7721855171a5884832a63eb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 10 Aug 2022 12:26:59 +0200 Subject: [PATCH 51/97] Bump sqlite-jdbc from 3.36.0.3 to 3.39.2.0 (#2596) Bumps [sqlite-jdbc](https://github.com/xerial/sqlite-jdbc) from 3.36.0.3 to 3.39.2.0. - [Release notes](https://github.com/xerial/sqlite-jdbc/releases) - [Changelog](https://github.com/xerial/sqlite-jdbc/blob/master/CHANGELOG) - [Commits](https://github.com/xerial/sqlite-jdbc/compare/3.36.0.3...3.39.2.0) --- updated-dependencies: - dependency-name: org.xerial:sqlite-jdbc dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7d778f3c5..3f648fdb2 100644 --- a/pom.xml +++ b/pom.xml @@ -1052,7 +1052,7 @@ org.xerial sqlite-jdbc - 3.36.0.3 + 3.39.2.0 test From ec9de15bb986fff097e1c5ecbc23b61819096f86 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 18 Aug 2022 00:44:44 +0200 Subject: [PATCH 52/97] Bump EssentialsX from 2.19.4 to 2.19.6 (#2602) Bumps [EssentialsX](https://github.com/EssentialsX/Essentials) from 2.19.4 to 2.19.6. - [Release notes](https://github.com/EssentialsX/Essentials/releases) - [Commits](https://github.com/EssentialsX/Essentials/compare/2.19.4...2.19.6) --- updated-dependencies: - dependency-name: net.essentialsx:EssentialsX dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3f648fdb2..afccd4488 100644 --- a/pom.xml +++ b/pom.xml @@ -929,7 +929,7 @@ net.essentialsx EssentialsX - 2.19.4 + 2.19.6 provided From af2fbd0558bf055ff85b477d105ae15658c3e738 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 18 Aug 2022 00:44:55 +0200 Subject: [PATCH 53/97] Bump maven-javadoc-plugin from 3.4.0 to 3.4.1 (#2603) Bumps [maven-javadoc-plugin](https://github.com/apache/maven-javadoc-plugin) from 3.4.0 to 3.4.1. - [Release notes](https://github.com/apache/maven-javadoc-plugin/releases) - [Commits](https://github.com/apache/maven-javadoc-plugin/compare/maven-javadoc-plugin-3.4.0...maven-javadoc-plugin-3.4.1) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-javadoc-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index afccd4488..186fec1cf 100644 --- a/pom.xml +++ b/pom.xml @@ -151,7 +151,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.4.0 + 3.4.1 From fd0a0a1155f01ad3bacdacba8320fa68353f74f5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 18 Aug 2022 00:45:10 +0200 Subject: [PATCH 54/97] Bump mockito-core from 4.6.1 to 4.7.0 (#2604) Bumps [mockito-core](https://github.com/mockito/mockito) from 4.6.1 to 4.7.0. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v4.6.1...v4.7.0) --- updated-dependencies: - dependency-name: org.mockito:mockito-core dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 186fec1cf..1f3ebe534 100644 --- a/pom.xml +++ b/pom.xml @@ -1031,7 +1031,7 @@ org.mockito mockito-core test - 4.6.1 + 4.7.0 hamcrest-core From 7c8bbe62941e5b2ba2dafd0449c943b665ed883c Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Thu, 18 Aug 2022 01:48:34 +0200 Subject: [PATCH 55/97] Remove cache-update bungee messages, always use the player in the context to send bungee messages, minor codestyle changes --- .../authme/PurgeLastPositionCommand.java | 11 +-- .../initialization/OnShutdownPlayerSaver.java | 10 +-- .../changepassword/AsyncChangePassword.java | 19 +++--- .../authme/process/email/AsyncAddEmail.java | 9 +-- .../process/email/AsyncChangeEmail.java | 9 +-- .../authme/process/join/AsynchronousJoin.java | 14 ++-- .../process/login/AsynchronousLogin.java | 23 ++++--- .../process/logout/AsynchronousLogout.java | 8 +-- .../authme/process/quit/AsynchronousQuit.java | 14 ++-- .../process/register/AsyncRegister.java | 11 +-- .../unregister/AsynchronousUnregister.java | 14 ++-- .../xephi/authme/service/BukkitService.java | 11 ++- .../service/bungeecord/BungeeReceiver.java | 48 ++++++------- .../service/bungeecord/BungeeSender.java | 67 +++++++++---------- .../service/bungeecord/MessageType.java | 23 +------ .../AsynchronousUnregisterTest.java | 7 -- 16 files changed, 112 insertions(+), 186 deletions(-) diff --git a/src/main/java/fr/xephi/authme/command/executable/authme/PurgeLastPositionCommand.java b/src/main/java/fr/xephi/authme/command/executable/authme/PurgeLastPositionCommand.java index 39af8ef64..4e20b0313 100644 --- a/src/main/java/fr/xephi/authme/command/executable/authme/PurgeLastPositionCommand.java +++ b/src/main/java/fr/xephi/authme/command/executable/authme/PurgeLastPositionCommand.java @@ -5,8 +5,6 @@ import fr.xephi.authme.data.auth.PlayerAuth; import fr.xephi.authme.datasource.DataSource; import fr.xephi.authme.message.MessageKey; import fr.xephi.authme.service.CommonService; -import fr.xephi.authme.service.bungeecord.BungeeSender; -import fr.xephi.authme.service.bungeecord.MessageType; import org.bukkit.command.CommandSender; import javax.inject.Inject; @@ -23,18 +21,15 @@ public class PurgeLastPositionCommand implements ExecutableCommand { @Inject private CommonService commonService; - @Inject - private BungeeSender bungeeSender; - @Override - public void executeCommand(final CommandSender sender, List arguments) { + public void executeCommand(CommandSender sender, List arguments) { String playerName = arguments.isEmpty() ? sender.getName() : arguments.get(0); if ("*".equals(playerName)) { for (PlayerAuth auth : dataSource.getAllAuths()) { resetLastPosition(auth); dataSource.updateQuitLoc(auth); - bungeeSender.sendAuthMeBungeecordMessage(MessageType.REFRESH_QUITLOC, playerName); + // TODO: send an update when a messaging service will be implemented (QUITLOC) } sender.sendMessage("All players last position locations are now reset"); } else { @@ -47,7 +42,7 @@ public class PurgeLastPositionCommand implements ExecutableCommand { resetLastPosition(auth); dataSource.updateQuitLoc(auth); - bungeeSender.sendAuthMeBungeecordMessage(MessageType.REFRESH_QUITLOC, playerName); + // TODO: send an update when a messaging service will be implemented (QUITLOC) sender.sendMessage(playerName + "'s last position location is now reset"); } } diff --git a/src/main/java/fr/xephi/authme/initialization/OnShutdownPlayerSaver.java b/src/main/java/fr/xephi/authme/initialization/OnShutdownPlayerSaver.java index 063948008..742318e4c 100644 --- a/src/main/java/fr/xephi/authme/initialization/OnShutdownPlayerSaver.java +++ b/src/main/java/fr/xephi/authme/initialization/OnShutdownPlayerSaver.java @@ -6,8 +6,6 @@ import fr.xephi.authme.data.limbo.LimboService; import fr.xephi.authme.datasource.DataSource; import fr.xephi.authme.service.BukkitService; import fr.xephi.authme.service.ValidationService; -import fr.xephi.authme.service.bungeecord.BungeeSender; -import fr.xephi.authme.service.bungeecord.MessageType; import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.SpawnLoader; import fr.xephi.authme.settings.properties.RestrictionSettings; @@ -36,8 +34,6 @@ public class OnShutdownPlayerSaver { private PlayerCache playerCache; @Inject private LimboService limboService; - @Inject - private BungeeSender bungeeSender; OnShutdownPlayerSaver() { } @@ -52,7 +48,7 @@ public class OnShutdownPlayerSaver { } private void savePlayer(Player player) { - final String name = player.getName().toLowerCase(); + String name = player.getName().toLowerCase(); if (PlayerUtils.isNpc(player) || validationService.isUnrestricted(name)) { return; } @@ -67,12 +63,12 @@ public class OnShutdownPlayerSaver { private void saveLoggedinPlayer(Player player) { if (settings.getProperty(RestrictionSettings.SAVE_QUIT_LOCATION)) { Location loc = spawnLoader.getPlayerLocationOrSpawn(player); - final PlayerAuth auth = PlayerAuth.builder() + PlayerAuth auth = PlayerAuth.builder() .name(player.getName().toLowerCase()) .realName(player.getName()) .location(loc).build(); dataSource.updateQuitLoc(auth); - bungeeSender.sendAuthMeBungeecordMessage(MessageType.REFRESH_QUITLOC, player.getName()); + // TODO: send an update when a messaging service will be implemented (QUITLOC) } } } diff --git a/src/main/java/fr/xephi/authme/process/changepassword/AsyncChangePassword.java b/src/main/java/fr/xephi/authme/process/changepassword/AsyncChangePassword.java index 11495c54c..9ae2934a1 100644 --- a/src/main/java/fr/xephi/authme/process/changepassword/AsyncChangePassword.java +++ b/src/main/java/fr/xephi/authme/process/changepassword/AsyncChangePassword.java @@ -10,8 +10,6 @@ import fr.xephi.authme.process.AsynchronousProcess; import fr.xephi.authme.security.PasswordSecurity; import fr.xephi.authme.security.crypts.HashedPassword; import fr.xephi.authme.service.CommonService; -import fr.xephi.authme.service.bungeecord.BungeeSender; -import fr.xephi.authme.service.bungeecord.MessageType; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -33,9 +31,6 @@ public class AsyncChangePassword implements AsynchronousProcess { @Inject private PlayerCache playerCache; - @Inject - private BungeeSender bungeeSender; - AsyncChangePassword() { } @@ -46,8 +41,8 @@ public class AsyncChangePassword implements AsynchronousProcess { * @param oldPassword the old password used by the player * @param newPassword the new password chosen by the player */ - public void changePassword(final Player player, String oldPassword, String newPassword) { - final String name = player.getName().toLowerCase(); + public void changePassword(Player player, String oldPassword, String newPassword) { + String name = player.getName().toLowerCase(); PlayerAuth auth = playerCache.getAuth(name); if (passwordSecurity.comparePassword(oldPassword, auth.getPassword(), player.getName())) { HashedPassword hashedPassword = passwordSecurity.computeHash(newPassword, name); @@ -57,7 +52,8 @@ public class AsyncChangePassword implements AsynchronousProcess { commonService.send(player, MessageKey.ERROR); return; } - bungeeSender.sendAuthMeBungeecordMessage(MessageType.REFRESH_PASSWORD, name); + + // TODO: send an update when a messaging service will be implemented (PASSWORD_CHANGED) playerCache.updatePlayer(auth); commonService.send(player, MessageKey.PASSWORD_CHANGED_SUCCESS); @@ -74,8 +70,8 @@ public class AsyncChangePassword implements AsynchronousProcess { * @param playerName the player name * @param newPassword the new password chosen for the player */ - public void changePasswordAsAdmin(CommandSender sender, final String playerName, String newPassword) { - final String lowerCaseName = playerName.toLowerCase(); + public void changePasswordAsAdmin(CommandSender sender, String playerName, String newPassword) { + String lowerCaseName = playerName.toLowerCase(); if (!(playerCache.isAuthenticated(lowerCaseName) || dataSource.isAuthAvailable(lowerCaseName))) { if (sender == null) { logger.warning("Tried to change password for user " + lowerCaseName + " but it doesn't exist!"); @@ -87,7 +83,8 @@ public class AsyncChangePassword implements AsynchronousProcess { HashedPassword hashedPassword = passwordSecurity.computeHash(newPassword, lowerCaseName); if (dataSource.updatePassword(lowerCaseName, hashedPassword)) { - bungeeSender.sendAuthMeBungeecordMessage(MessageType.REFRESH_PASSWORD, lowerCaseName); + // TODO: send an update when a messaging service will be implemented (PASSWORD_CHANGED) + if (sender != null) { commonService.send(sender, MessageKey.PASSWORD_CHANGED_SUCCESS); logger.info(sender.getName() + " changed password of " + lowerCaseName); diff --git a/src/main/java/fr/xephi/authme/process/email/AsyncAddEmail.java b/src/main/java/fr/xephi/authme/process/email/AsyncAddEmail.java index 63dd75408..9041e01a5 100644 --- a/src/main/java/fr/xephi/authme/process/email/AsyncAddEmail.java +++ b/src/main/java/fr/xephi/authme/process/email/AsyncAddEmail.java @@ -11,8 +11,6 @@ import fr.xephi.authme.process.AsynchronousProcess; import fr.xephi.authme.service.BukkitService; import fr.xephi.authme.service.CommonService; import fr.xephi.authme.service.ValidationService; -import fr.xephi.authme.service.bungeecord.BungeeSender; -import fr.xephi.authme.service.bungeecord.MessageType; import fr.xephi.authme.util.Utils; import org.bukkit.entity.Player; @@ -37,9 +35,6 @@ public class AsyncAddEmail implements AsynchronousProcess { @Inject private ValidationService validationService; - @Inject - private BungeeSender bungeeSender; - @Inject private BukkitService bukkitService; @@ -57,7 +52,7 @@ public class AsyncAddEmail implements AsynchronousProcess { if (playerCache.isAuthenticated(playerName)) { PlayerAuth auth = playerCache.getAuth(playerName); - final String currentEmail = auth.getEmail(); + String currentEmail = auth.getEmail(); if (!Utils.isEmailEmpty(currentEmail)) { service.send(player, MessageKey.USAGE_CHANGE_EMAIL); @@ -76,7 +71,7 @@ public class AsyncAddEmail implements AsynchronousProcess { auth.setEmail(email); if (dataSource.updateEmail(auth)) { playerCache.updatePlayer(auth); - bungeeSender.sendAuthMeBungeecordMessage(MessageType.REFRESH_EMAIL, playerName); + // TODO: send an update when a messaging service will be implemented (ADD_MAIL) service.send(player, MessageKey.EMAIL_ADDED_SUCCESS); } else { logger.warning("Could not save email for player '" + player + "'"); diff --git a/src/main/java/fr/xephi/authme/process/email/AsyncChangeEmail.java b/src/main/java/fr/xephi/authme/process/email/AsyncChangeEmail.java index 4e00d4869..ccbe5ba1f 100644 --- a/src/main/java/fr/xephi/authme/process/email/AsyncChangeEmail.java +++ b/src/main/java/fr/xephi/authme/process/email/AsyncChangeEmail.java @@ -11,8 +11,6 @@ import fr.xephi.authme.process.AsynchronousProcess; import fr.xephi.authme.service.BukkitService; import fr.xephi.authme.service.CommonService; import fr.xephi.authme.service.ValidationService; -import fr.xephi.authme.service.bungeecord.BungeeSender; -import fr.xephi.authme.service.bungeecord.MessageType; import org.bukkit.entity.Player; import javax.inject.Inject; @@ -36,9 +34,6 @@ public class AsyncChangeEmail implements AsynchronousProcess { @Inject private ValidationService validationService; - @Inject - private BungeeSender bungeeSender; - @Inject private BukkitService bukkitService; @@ -56,7 +51,7 @@ public class AsyncChangeEmail implements AsynchronousProcess { String playerName = player.getName().toLowerCase(); if (playerCache.isAuthenticated(playerName)) { PlayerAuth auth = playerCache.getAuth(playerName); - final String currentEmail = auth.getEmail(); + String currentEmail = auth.getEmail(); if (currentEmail == null) { service.send(player, MessageKey.USAGE_ADD_EMAIL); @@ -94,7 +89,7 @@ public class AsyncChangeEmail implements AsynchronousProcess { auth.setEmail(newEmail); if (dataSource.updateEmail(auth)) { playerCache.updatePlayer(auth); - bungeeSender.sendAuthMeBungeecordMessage(MessageType.REFRESH_EMAIL, player.getName()); + // TODO: send an update when a messaging service will be implemented (CHANGE_MAIL) service.send(player, MessageKey.EMAIL_CHANGED_SUCCESS); } else { service.send(player, MessageKey.ERROR); 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 0e49eeee1..93d38947c 100644 --- a/src/main/java/fr/xephi/authme/process/join/AsynchronousJoin.java +++ b/src/main/java/fr/xephi/authme/process/join/AsynchronousJoin.java @@ -89,9 +89,9 @@ public class AsynchronousJoin implements AsynchronousProcess { * * @param player the player to process */ - public void processJoin(final Player player) { - final String name = player.getName().toLowerCase(); - final String ip = PlayerUtils.getPlayerIp(player); + public void processJoin(Player player) { + String name = player.getName().toLowerCase(); + String ip = PlayerUtils.getPlayerIp(player); if (!validationService.fulfillsNameRestrictions(player)) { handlePlayerWithUnmetNameRestriction(player, ip); @@ -116,7 +116,7 @@ public class AsynchronousJoin implements AsynchronousProcess { return; } - final boolean isAuthAvailable = database.isAuthAvailable(name); + boolean isAuthAvailable = database.isAuthAvailable(name); if (isAuthAvailable) { // Protect inventory @@ -153,7 +153,7 @@ public class AsynchronousJoin implements AsynchronousProcess { }); // Skip if registration is optional - bungeeSender.sendAuthMeBungeecordMessage(MessageType.LOGIN, name); + bungeeSender.sendAuthMeBungeecordMessage(player, MessageType.LOGIN); return; } @@ -177,7 +177,7 @@ public class AsynchronousJoin implements AsynchronousProcess { * @param isAuthAvailable true if the player is registered, false otherwise */ private void processJoinSync(Player player, boolean isAuthAvailable) { - final int registrationTimeout = service.getProperty(RestrictionSettings.TIMEOUT) * TICKS_PER_SECOND; + int registrationTimeout = service.getProperty(RestrictionSettings.TIMEOUT) * TICKS_PER_SECOND; bukkitService.scheduleSyncTaskFromOptionallyAsyncTask(() -> { limboService.createLimboPlayer(player, isAuthAvailable); @@ -204,7 +204,7 @@ public class AsynchronousJoin implements AsynchronousProcess { * * @return true if the verification is OK (no infraction), false if player has been kicked */ - private boolean validatePlayerCountForIp(final Player player, String ip) { + private boolean validatePlayerCountForIp(Player player, String ip) { if (service.getProperty(RestrictionSettings.MAX_JOIN_PER_IP) > 0 && !service.hasPermission(player, PlayerStatePermission.ALLOW_MULTIPLE_ACCOUNTS) && !InternetProtocolUtils.isLoopbackAddress(ip) diff --git a/src/main/java/fr/xephi/authme/process/login/AsynchronousLogin.java b/src/main/java/fr/xephi/authme/process/login/AsynchronousLogin.java index 371c2a355..897daa0fa 100644 --- a/src/main/java/fr/xephi/authme/process/login/AsynchronousLogin.java +++ b/src/main/java/fr/xephi/authme/process/login/AsynchronousLogin.java @@ -153,7 +153,7 @@ public class AsynchronousLogin implements AsynchronousProcess { * (e.g. because he is already logged in) */ private PlayerAuth getPlayerAuth(Player player, boolean quiet) { - final String name = player.getName().toLowerCase(); + String name = player.getName().toLowerCase(); if (playerCache.isAuthenticated(name)) { if (!quiet) { service.send(player, MessageKey.ALREADY_LOGGED_IN_ERROR); @@ -179,7 +179,7 @@ public class AsynchronousLogin implements AsynchronousProcess { return null; } - final String ip = PlayerUtils.getPlayerIp(player); + String ip = PlayerUtils.getPlayerIp(player); if (hasReachedMaxLoggedInPlayersForIp(player, ip)) { if (!quiet) { service.send(player, MessageKey.ALREADY_LOGGED_IN_ERROR); @@ -206,7 +206,7 @@ public class AsynchronousLogin implements AsynchronousProcess { * false otherwise */ private boolean checkPlayerInfo(Player player, PlayerAuth auth, String password) { - final String name = player.getName().toLowerCase(); + String name = player.getName().toLowerCase(); // If captcha is required send a message to the player and deny to log in if (loginCaptchaManager.isCaptchaRequired(name)) { @@ -214,7 +214,7 @@ public class AsynchronousLogin implements AsynchronousProcess { return false; } - final String ip = PlayerUtils.getPlayerIp(player); + String ip = PlayerUtils.getPlayerIp(player); // Increase the counts here before knowing the result of the login. loginCaptchaManager.increaseLoginFailureCount(name); @@ -266,18 +266,19 @@ public class AsynchronousLogin implements AsynchronousProcess { */ public void performLogin(Player player, PlayerAuth auth) { if (player.isOnline()) { - final boolean isFirstLogin = (auth.getLastLogin() == null); + boolean isFirstLogin = (auth.getLastLogin() == null); // Update auth to reflect this new login - final String ip = PlayerUtils.getPlayerIp(player); + String ip = PlayerUtils.getPlayerIp(player); auth.setRealName(player.getName()); auth.setLastLogin(System.currentTimeMillis()); auth.setLastIp(ip); dataSource.updateSession(auth); - bungeeSender.sendAuthMeBungeecordMessage(MessageType.REFRESH_SESSION, player.getName()); + + // TODO: send an update when a messaging service will be implemented (SESSION) // Successful login, so reset the captcha & temp ban count - final String name = player.getName(); + String name = player.getName(); loginCaptchaManager.resetLoginFailureCount(name); tempbanManager.resetCount(ip, name); player.setNoDamageTicks(0); @@ -288,7 +289,7 @@ public class AsynchronousLogin implements AsynchronousProcess { List auths = dataSource.getAllAuthsByIp(auth.getLastIp()); displayOtherAccounts(auths, player); - final String email = auth.getEmail(); + String email = auth.getEmail(); if (service.getProperty(EmailSettings.RECALL_PLAYERS) && Utils.isEmailEmpty(email)) { service.send(player, MessageKey.ADD_EMAIL_MESSAGE); } @@ -299,7 +300,7 @@ public class AsynchronousLogin implements AsynchronousProcess { playerCache.updatePlayer(auth); dataSource.setLogged(name); sessionService.grantSession(name); - bungeeSender.sendAuthMeBungeecordMessage(MessageType.LOGIN, name); + bungeeSender.sendAuthMeBungeecordMessage(player, MessageType.LOGIN); // As the scheduling executes the Task most likely after the current // task, we schedule it in the end @@ -368,7 +369,7 @@ public class AsynchronousLogin implements AsynchronousProcess { } // Count logged in players with same IP address - final String name = player.getName(); + String name = player.getName(); int count = 0; for (Player onlinePlayer : bukkitService.getOnlinePlayers()) { if (ip.equalsIgnoreCase(PlayerUtils.getPlayerIp(onlinePlayer)) diff --git a/src/main/java/fr/xephi/authme/process/logout/AsynchronousLogout.java b/src/main/java/fr/xephi/authme/process/logout/AsynchronousLogout.java index 41cedf4bc..3628669b8 100644 --- a/src/main/java/fr/xephi/authme/process/logout/AsynchronousLogout.java +++ b/src/main/java/fr/xephi/authme/process/logout/AsynchronousLogout.java @@ -51,7 +51,7 @@ public class AsynchronousLogout implements AsynchronousProcess { * @param player the player wanting to log out */ public void logout(Player player) { - final String name = player.getName().toLowerCase(); + String name = player.getName().toLowerCase(); if (!playerCache.isAuthenticated(name)) { service.send(player, MessageKey.NOT_LOGGED_IN); return; @@ -59,18 +59,18 @@ public class AsynchronousLogout implements AsynchronousProcess { PlayerAuth auth = playerCache.getAuth(name); database.updateSession(auth); - bungeeSender.sendAuthMeBungeecordMessage(MessageType.REFRESH_SESSION, name); + // TODO: send an update when a messaging service will be implemented (SESSION) if (service.getProperty(RestrictionSettings.SAVE_QUIT_LOCATION)) { auth.setQuitLocation(player.getLocation()); database.updateQuitLoc(auth); - bungeeSender.sendAuthMeBungeecordMessage(MessageType.REFRESH_QUITLOC, name); + // TODO: send an update when a messaging service will be implemented (QUITLOC) } playerCache.removePlayer(name); codeManager.unverify(name); database.setUnlogged(name); sessionService.revokeSession(name); - bungeeSender.sendAuthMeBungeecordMessage(MessageType.LOGOUT, name); + bungeeSender.sendAuthMeBungeecordMessage(player, MessageType.LOGOUT); syncProcessManager.processSyncPlayerLogout(player); } } diff --git a/src/main/java/fr/xephi/authme/process/quit/AsynchronousQuit.java b/src/main/java/fr/xephi/authme/process/quit/AsynchronousQuit.java index b5643217f..e2ad6d432 100644 --- a/src/main/java/fr/xephi/authme/process/quit/AsynchronousQuit.java +++ b/src/main/java/fr/xephi/authme/process/quit/AsynchronousQuit.java @@ -10,8 +10,6 @@ import fr.xephi.authme.process.SyncProcessManager; import fr.xephi.authme.service.CommonService; import fr.xephi.authme.service.SessionService; import fr.xephi.authme.service.ValidationService; -import fr.xephi.authme.service.bungeecord.BungeeSender; -import fr.xephi.authme.service.bungeecord.MessageType; import fr.xephi.authme.settings.SpawnLoader; import fr.xephi.authme.settings.properties.PluginSettings; import fr.xephi.authme.settings.properties.RestrictionSettings; @@ -53,9 +51,6 @@ public class AsynchronousQuit implements AsynchronousProcess { @Inject private SessionService sessionService; - @Inject - private BungeeSender bungeeSender; - AsynchronousQuit() { } @@ -68,8 +63,8 @@ public class AsynchronousQuit implements AsynchronousProcess { if (player == null || validationService.isUnrestricted(player.getName())) { return; } - final String name = player.getName().toLowerCase(); - final boolean wasLoggedIn = playerCache.isAuthenticated(name); + String name = player.getName().toLowerCase(); + boolean wasLoggedIn = playerCache.isAuthenticated(name); if (wasLoggedIn) { if (service.getProperty(RestrictionSettings.SAVE_QUIT_LOCATION)) { @@ -80,7 +75,7 @@ public class AsynchronousQuit implements AsynchronousProcess { database.updateQuitLoc(auth); } - final String ip = PlayerUtils.getPlayerIp(player); + String ip = PlayerUtils.getPlayerIp(player); PlayerAuth auth = PlayerAuth.builder() .name(name) .realName(player.getName()) @@ -88,7 +83,8 @@ public class AsynchronousQuit implements AsynchronousProcess { .lastLogin(System.currentTimeMillis()) .build(); database.updateSession(auth); - bungeeSender.sendAuthMeBungeecordMessage(MessageType.REFRESH_QUITLOC, name); + + // TODO: send an update when a messaging service will be implemented (QUITLOC) } //always unauthenticate the player - use session only for auto logins on the same ip diff --git a/src/main/java/fr/xephi/authme/process/register/AsyncRegister.java b/src/main/java/fr/xephi/authme/process/register/AsyncRegister.java index 608267f00..979d6db7d 100644 --- a/src/main/java/fr/xephi/authme/process/register/AsyncRegister.java +++ b/src/main/java/fr/xephi/authme/process/register/AsyncRegister.java @@ -12,8 +12,6 @@ import fr.xephi.authme.process.register.executors.RegistrationMethod; import fr.xephi.authme.process.register.executors.RegistrationParameters; import fr.xephi.authme.service.BukkitService; import fr.xephi.authme.service.CommonService; -import fr.xephi.authme.service.bungeecord.BungeeSender; -import fr.xephi.authme.service.bungeecord.MessageType; import fr.xephi.authme.settings.properties.RegistrationSettings; import fr.xephi.authme.settings.properties.RestrictionSettings; import fr.xephi.authme.util.InternetProtocolUtils; @@ -40,8 +38,6 @@ public class AsyncRegister implements AsynchronousProcess { private CommonService service; @Inject private SingletonStore registrationExecutorFactory; - @Inject - private BungeeSender bungeeSender; AsyncRegister() { } @@ -71,7 +67,7 @@ public class AsyncRegister implements AsynchronousProcess { * @return true if the checks are successful and the event hasn't marked the action as denied, false otherwise. */ private boolean preRegisterCheck(RegistrationMethod variant, Player player) { - final String name = player.getName().toLowerCase(); + String name = player.getName().toLowerCase(); if (playerCache.isAuthenticated(name)) { service.send(player, MessageKey.ALREADY_LOGGED_IN_ERROR); return false; @@ -104,7 +100,6 @@ public class AsyncRegister implements AsynchronousProcess { PlayerAuth auth = executor.buildPlayerAuth(parameters); if (database.saveAuth(auth)) { executor.executePostPersistAction(parameters); - bungeeSender.sendAuthMeBungeecordMessage(MessageType.REGISTER, parameters.getPlayerName()); } else { service.send(parameters.getPlayer(), MessageKey.ERROR); } @@ -118,8 +113,8 @@ public class AsyncRegister implements AsynchronousProcess { * @return true if registration may take place, false otherwise (IP check failed) */ private boolean isPlayerIpAllowedToRegister(Player player) { - final int maxRegPerIp = service.getProperty(RestrictionSettings.MAX_REGISTRATION_PER_IP); - final String ip = PlayerUtils.getPlayerIp(player); + int maxRegPerIp = service.getProperty(RestrictionSettings.MAX_REGISTRATION_PER_IP); + String ip = PlayerUtils.getPlayerIp(player); if (maxRegPerIp > 0 && !InternetProtocolUtils.isLoopbackAddress(ip) && !service.hasPermission(player, ALLOW_MULTIPLE_ACCOUNTS)) { 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 22d7cf9be..623c93acf 100644 --- a/src/main/java/fr/xephi/authme/process/unregister/AsynchronousUnregister.java +++ b/src/main/java/fr/xephi/authme/process/unregister/AsynchronousUnregister.java @@ -14,8 +14,6 @@ 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; @@ -56,9 +54,6 @@ public class AsynchronousUnregister implements AsynchronousProcess { @Inject private CommandManager commandManager; - @Inject - private BungeeSender bungeeSender; - AsynchronousUnregister() { } @@ -70,8 +65,8 @@ public class AsynchronousUnregister implements AsynchronousProcess { * @param password the input password to check before unregister */ public void unregister(Player player, String password) { - final String name = player.getName(); - final PlayerAuth cachedAuth = playerCache.getAuth(name); + String name = player.getName(); + PlayerAuth cachedAuth = playerCache.getAuth(name); if (passwordSecurity.comparePassword(password, cachedAuth.getPassword(), name)) { if (dataSource.removeAuth(name)) { performPostUnregisterActions(name, player); @@ -118,7 +113,8 @@ public class AsynchronousUnregister implements AsynchronousProcess { */ private void performPostUnregisterActions(String name, Player player) { playerCache.removePlayer(name); - bungeeSender.sendAuthMeBungeecordMessage(MessageType.UNREGISTER, name); + + // TODO: send an update when a messaging service will be implemented (UNREGISTER) if (player == null || !player.isOnline()) { return; @@ -137,7 +133,7 @@ public class AsynchronousUnregister implements AsynchronousProcess { service.send(player, MessageKey.UNREGISTERED_SUCCESS); } - private void applyBlindEffect(final 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)); diff --git a/src/main/java/fr/xephi/authme/service/BukkitService.java b/src/main/java/fr/xephi/authme/service/BukkitService.java index b1262678f..e02c6f100 100644 --- a/src/main/java/fr/xephi/authme/service/BukkitService.java +++ b/src/main/java/fr/xephi/authme/service/BukkitService.java @@ -1,6 +1,5 @@ package fr.xephi.authme.service; -import com.google.common.collect.Iterables; import fr.xephi.authme.AuthMe; import fr.xephi.authme.initialization.SettingsDependent; import fr.xephi.authme.settings.Settings; @@ -299,15 +298,13 @@ public class BukkitService implements SettingsDependent { } /** - * Send the specified message to bungeecord using the first available player connection. + * Send the specified bytes to bungeecord using the specified player connection. * + * @param player the player * @param bytes the message */ - public void sendBungeeMessage(byte[] bytes) { - Player player = Iterables.getFirst(getOnlinePlayers(), null); - if (player != null) { - player.sendPluginMessage(authMe, "BungeeCord", bytes); - } + public void sendBungeeMessage(Player player, byte[] bytes) { + player.sendPluginMessage(authMe, "BungeeCord", bytes); } /** diff --git a/src/main/java/fr/xephi/authme/service/bungeecord/BungeeReceiver.java b/src/main/java/fr/xephi/authme/service/bungeecord/BungeeReceiver.java index c66a6d6b0..091c796b4 100644 --- a/src/main/java/fr/xephi/authme/service/bungeecord/BungeeReceiver.java +++ b/src/main/java/fr/xephi/authme/service/bungeecord/BungeeReceiver.java @@ -5,7 +5,6 @@ import com.google.common.io.ByteStreams; import fr.xephi.authme.AuthMe; import fr.xephi.authme.ConsoleLogger; import fr.xephi.authme.data.ProxySessionManager; -import fr.xephi.authme.datasource.DataSource; import fr.xephi.authme.initialization.SettingsDependent; import fr.xephi.authme.output.ConsoleLoggerFactory; import fr.xephi.authme.process.Management; @@ -27,29 +26,27 @@ public class BungeeReceiver implements PluginMessageListener, SettingsDependent private final BukkitService bukkitService; private final ProxySessionManager proxySessionManager; private final Management management; - private final DataSource dataSource; private boolean isEnabled; @Inject BungeeReceiver(AuthMe plugin, BukkitService bukkitService, ProxySessionManager proxySessionManager, - Management management, DataSource dataSource, Settings settings) { + Management management, Settings settings) { this.plugin = plugin; this.bukkitService = bukkitService; this.proxySessionManager = proxySessionManager; this.management = management; - this.dataSource = dataSource; reload(settings); } @Override - public void reload(final Settings settings) { + public void reload(Settings settings) { this.isEnabled = settings.getProperty(HooksSettings.BUNGEECORD); if (this.isEnabled) { this.isEnabled = bukkitService.isBungeeCordConfiguredForSpigot().orElse(false); } if (this.isEnabled) { - final Messenger messenger = plugin.getServer().getMessenger(); + Messenger messenger = plugin.getServer().getMessenger(); if (!messenger.isIncomingChannelRegistered(plugin, "BungeeCord")) { messenger.registerIncomingPluginChannel(plugin, "BungeeCord", this); } @@ -61,23 +58,23 @@ public class BungeeReceiver implements PluginMessageListener, SettingsDependent * * @param in the input to handle */ - private void handleBroadcast(final ByteArrayDataInput in) { + private void handleBroadcast(ByteArrayDataInput in) { // Read data byte array - final short dataLength = in.readShort(); - final byte[] dataBytes = new byte[dataLength]; + short dataLength = in.readShort(); + byte[] dataBytes = new byte[dataLength]; in.readFully(dataBytes); - final ByteArrayDataInput dataIn = ByteStreams.newDataInput(dataBytes); + ByteArrayDataInput dataIn = ByteStreams.newDataInput(dataBytes); // Parse type - final String typeId = dataIn.readUTF(); - final Optional type = MessageType.fromId(typeId); + String typeId = dataIn.readUTF(); + Optional type = MessageType.fromId(typeId); if (!type.isPresent()) { logger.debug("Received unsupported forwarded bungeecord message type! ({0})", typeId); return; } // Parse argument - final String argument; + String argument; try { argument = dataIn.readUTF(); } catch (IllegalStateException e) { @@ -88,14 +85,9 @@ public class BungeeReceiver implements PluginMessageListener, SettingsDependent // Handle type switch (type.get()) { - case UNREGISTER: - dataSource.invalidateCache(argument); - break; - case REFRESH_PASSWORD: - case REFRESH_QUITLOC: - case REFRESH_EMAIL: - case REFRESH: - dataSource.refreshCache(argument); + case LOGIN: + case LOGOUT: + // TODO: unused break; default: } @@ -108,15 +100,15 @@ public class BungeeReceiver implements PluginMessageListener, SettingsDependent */ private void handle(ByteArrayDataInput in) { // Parse type - final String typeId = in.readUTF(); - final Optional type = MessageType.fromId(typeId); + String typeId = in.readUTF(); + Optional type = MessageType.fromId(typeId); if (!type.isPresent()) { logger.debug("Received unsupported bungeecord message type! ({0})", typeId); return; } // Parse argument - final String argument; + String argument; try { argument = in.readUTF(); } catch (IllegalStateException e) { @@ -135,15 +127,15 @@ public class BungeeReceiver implements PluginMessageListener, SettingsDependent } @Override - public void onPluginMessageReceived(final String channel, final Player player, final byte[] data) { + public void onPluginMessageReceived(String channel, Player player, byte[] data) { if (!isEnabled) { return; } - final ByteArrayDataInput in = ByteStreams.newDataInput(data); + ByteArrayDataInput in = ByteStreams.newDataInput(data); // Check subchannel - final String subChannel = in.readUTF(); + String subChannel = in.readUTF(); if ("AuthMe.v2.Broadcast".equals(subChannel)) { handleBroadcast(in); } else if ("AuthMe.v2".equals(subChannel)) { @@ -151,7 +143,7 @@ public class BungeeReceiver implements PluginMessageListener, SettingsDependent } } - private void performLogin(final String name) { + private void performLogin(String name) { Player player = bukkitService.getPlayerExact(name); if (player != null && player.isOnline()) { management.forceLogin(player, true); diff --git a/src/main/java/fr/xephi/authme/service/bungeecord/BungeeSender.java b/src/main/java/fr/xephi/authme/service/bungeecord/BungeeSender.java index b99bb1b8e..25080e019 100644 --- a/src/main/java/fr/xephi/authme/service/bungeecord/BungeeSender.java +++ b/src/main/java/fr/xephi/authme/service/bungeecord/BungeeSender.java @@ -4,7 +4,6 @@ import com.google.common.io.ByteArrayDataOutput; import com.google.common.io.ByteStreams; import fr.xephi.authme.AuthMe; import fr.xephi.authme.ConsoleLogger; -import fr.xephi.authme.datasource.DataSource; import fr.xephi.authme.initialization.SettingsDependent; import fr.xephi.authme.output.ConsoleLoggerFactory; import fr.xephi.authme.service.BukkitService; @@ -20,7 +19,6 @@ public class BungeeSender implements SettingsDependent { private final ConsoleLogger logger = ConsoleLoggerFactory.get(BungeeSender.class); private final AuthMe plugin; private final BukkitService bukkitService; - private final DataSource dataSource; private boolean isEnabled; private String destinationServerOnLogin; @@ -29,21 +27,19 @@ public class BungeeSender implements SettingsDependent { * Constructor. */ @Inject - BungeeSender(final AuthMe plugin, final BukkitService bukkitService, final DataSource dataSource, - final Settings settings) { + BungeeSender(AuthMe plugin, BukkitService bukkitService, Settings settings) { this.plugin = plugin; this.bukkitService = bukkitService; - this.dataSource = dataSource; reload(settings); } @Override - public void reload(final Settings settings) { + public void reload(Settings settings) { this.isEnabled = settings.getProperty(HooksSettings.BUNGEECORD); this.destinationServerOnLogin = settings.getProperty(HooksSettings.BUNGEECORD_SERVER); if (this.isEnabled) { - final Messenger messenger = plugin.getServer().getMessenger(); + Messenger messenger = plugin.getServer().getMessenger(); if (!messenger.isOutgoingChannelRegistered(plugin, "BungeeCord")) { messenger.registerOutgoingPluginChannel(plugin, "BungeeCord"); } @@ -54,27 +50,27 @@ public class BungeeSender implements SettingsDependent { return isEnabled; } - private void sendBungeecordMessage(final String... data) { - final ByteArrayDataOutput out = ByteStreams.newDataOutput(); - for (final String element : data) { + private void sendBungeecordMessage(Player player, String... data) { + ByteArrayDataOutput out = ByteStreams.newDataOutput(); + for (String element : data) { out.writeUTF(element); } - bukkitService.sendBungeeMessage(out.toByteArray()); + bukkitService.sendBungeeMessage(player, out.toByteArray()); } - private void sendForwardedBungeecordMessage(final String subChannel, final String... data) { - final ByteArrayDataOutput out = ByteStreams.newDataOutput(); + private void sendForwardedBungeecordMessage(Player player, String subChannel, String... data) { + ByteArrayDataOutput out = ByteStreams.newDataOutput(); out.writeUTF("Forward"); out.writeUTF("ONLINE"); out.writeUTF(subChannel); - final ByteArrayDataOutput dataOut = ByteStreams.newDataOutput(); - for (final String element : data) { + ByteArrayDataOutput dataOut = ByteStreams.newDataOutput(); + for (String element : data) { dataOut.writeUTF(element); } - final byte[] dataBytes = dataOut.toByteArray(); + byte[] dataBytes = dataOut.toByteArray(); out.writeShort(dataBytes.length); out.write(dataBytes); - bukkitService.sendBungeeMessage(out.toByteArray()); + bukkitService.sendBungeeMessage(player, out.toByteArray()); } /** @@ -83,33 +79,32 @@ public class BungeeSender implements SettingsDependent { * * @param player The player to send. */ - public void connectPlayerOnLogin(final Player player) { - if (isEnabled && !destinationServerOnLogin.isEmpty()) { - bukkitService.scheduleSyncDelayedTask(() -> - sendBungeecordMessage("ConnectOther", player.getName(), destinationServerOnLogin), 5L); + public void connectPlayerOnLogin(Player player) { + if (!isEnabled || destinationServerOnLogin.isEmpty()) { + return; } + bukkitService.scheduleSyncDelayedTask(() -> + sendBungeecordMessage(player, "Connect", destinationServerOnLogin), 5L); } /** * Sends a message to the AuthMe plugin messaging channel, if enabled. * + * @param player The player related to the message * @param type The message type, See {@link MessageType} - * @param playerName the player related to the message */ - public void sendAuthMeBungeecordMessage(final MessageType type, final String playerName) { - if (isEnabled) { - if (!plugin.isEnabled()) { - logger.debug("Tried to send a " + type + " bungeecord message but the plugin was disabled!"); - return; - } - if (type.isRequiresCaching() && !dataSource.isCached()) { - return; - } - if (type.isBroadcast()) { - sendForwardedBungeecordMessage("AuthMe.v2.Broadcast", type.getId(), playerName.toLowerCase()); - } else { - sendBungeecordMessage("AuthMe.v2", type.getId(), playerName.toLowerCase()); - } + public void sendAuthMeBungeecordMessage(Player player, MessageType type) { + if (!isEnabled) { + return; + } + if (!plugin.isEnabled()) { + logger.debug("Tried to send a " + type + " bungeecord message but the plugin was disabled!"); + return; + } + if (type.isBroadcast()) { + sendForwardedBungeecordMessage(player, "AuthMe.v2.Broadcast", type.getId(), player.getName().toLowerCase()); + } else { + sendBungeecordMessage(player, "AuthMe.v2", type.getId(), player.getName().toLowerCase()); } } diff --git a/src/main/java/fr/xephi/authme/service/bungeecord/MessageType.java b/src/main/java/fr/xephi/authme/service/bungeecord/MessageType.java index f90edd725..ac63e41eb 100644 --- a/src/main/java/fr/xephi/authme/service/bungeecord/MessageType.java +++ b/src/main/java/fr/xephi/authme/service/bungeecord/MessageType.java @@ -3,29 +3,16 @@ package fr.xephi.authme.service.bungeecord; import java.util.Optional; public enum MessageType { - REFRESH_PASSWORD("refresh.password", true, true), - REFRESH_SESSION("refresh.session", true, true), - REFRESH_QUITLOC("refresh.quitloc", true, true), - REFRESH_EMAIL("refresh.email", true, true), - REFRESH("refresh", true, true), - REGISTER("register", true), - UNREGISTER("unregister", true), LOGIN("login", true), LOGOUT("logout", true), PERFORM_LOGIN("perform.login", false); private final String id; private final boolean broadcast; - private final boolean requiresCaching; - MessageType(final String id, final boolean broadcast, final boolean requiresCaching) { + MessageType(String id, boolean broadcast) { this.id = id; this.broadcast = broadcast; - this.requiresCaching = requiresCaching; - } - - MessageType(final String id, final boolean broadcast) { - this(id, broadcast, false); } public String getId() { @@ -36,10 +23,6 @@ public enum MessageType { return broadcast; } - public boolean isRequiresCaching() { - return requiresCaching; - } - /** * Returns the MessageType with the given ID. * @@ -47,8 +30,8 @@ public enum MessageType { * * @return the MessageType with the given id, empty if invalid. */ - public static Optional fromId(final String id) { - for (final MessageType current : values()) { + public static Optional fromId(String id) { + for (MessageType current : values()) { if (current.getId().equals(id)) { return Optional.of(current); } 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 99a1913b3..99d736dda 100644 --- a/src/test/java/fr/xephi/authme/process/unregister/AsynchronousUnregisterTest.java +++ b/src/test/java/fr/xephi/authme/process/unregister/AsynchronousUnregisterTest.java @@ -13,7 +13,6 @@ 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; @@ -128,7 +127,6 @@ public class AsynchronousUnregisterTest { verify(teleportationService).teleportOnJoin(player); verifyCalledUnregisterEventFor(player); verify(commandManager).runCommandsOnUnregister(player); - verify(bungeeSender).sendAuthMeBungeecordMessage(MessageType.UNREGISTER, name); verify(player).addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 21 * 20, 2)); } @@ -161,7 +159,6 @@ public class AsynchronousUnregisterTest { verify(teleportationService).teleportOnJoin(player); verifyCalledUnregisterEventFor(player); verify(commandManager).runCommandsOnUnregister(player); - verify(bungeeSender).sendAuthMeBungeecordMessage(MessageType.UNREGISTER, name); verify(player, never()).addPotionEffect(any(PotionEffect.class)); } @@ -191,7 +188,6 @@ public class AsynchronousUnregisterTest { verify(playerCache).removePlayer(name); verifyNoInteractions(teleportationService, limboService); verifyCalledUnregisterEventFor(player); - verify(bungeeSender).sendAuthMeBungeecordMessage(MessageType.UNREGISTER, name); verify(commandManager).runCommandsOnUnregister(player); } @@ -243,7 +239,6 @@ public class AsynchronousUnregisterTest { verify(playerCache).removePlayer(name); verifyNoInteractions(teleportationService); verifyCalledUnregisterEventFor(player); - verify(bungeeSender).sendAuthMeBungeecordMessage(MessageType.UNREGISTER, name); } // Initiator known and Player object available @@ -270,7 +265,6 @@ public class AsynchronousUnregisterTest { verify(teleportationService).teleportOnJoin(player); verifyCalledUnregisterEventFor(player); verify(commandManager).runCommandsOnUnregister(player); - verify(bungeeSender).sendAuthMeBungeecordMessage(MessageType.UNREGISTER, name); } @Test @@ -287,7 +281,6 @@ public class AsynchronousUnregisterTest { verify(playerCache).removePlayer(name); verifyNoInteractions(teleportationService); verifyCalledUnregisterEventFor(null); - verify(bungeeSender).sendAuthMeBungeecordMessage(MessageType.UNREGISTER, name); } @Test From b65ffd7c741e783168ba36c56cf85b4142e632a3 Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Thu, 18 Aug 2022 02:04:08 +0200 Subject: [PATCH 56/97] Send logout message to bungee on self-unregister --- .../command/executable/unregister/UnregisterCommand.java | 2 +- .../authme/process/unregister/AsynchronousUnregister.java | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/fr/xephi/authme/command/executable/unregister/UnregisterCommand.java b/src/main/java/fr/xephi/authme/command/executable/unregister/UnregisterCommand.java index 91088f1b3..21993f38e 100644 --- a/src/main/java/fr/xephi/authme/command/executable/unregister/UnregisterCommand.java +++ b/src/main/java/fr/xephi/authme/command/executable/unregister/UnregisterCommand.java @@ -31,7 +31,7 @@ public class UnregisterCommand extends PlayerCommand { @Override public void runCommand(Player player, List arguments) { String playerPass = arguments.get(0); - final String playerName = player.getName(); + String playerName = player.getName(); // Make sure the player is authenticated if (!playerCache.isAuthenticated(playerName)) { 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 623c93acf..7beea4be6 100644 --- a/src/main/java/fr/xephi/authme/process/unregister/AsynchronousUnregister.java +++ b/src/main/java/fr/xephi/authme/process/unregister/AsynchronousUnregister.java @@ -14,9 +14,11 @@ 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.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; @@ -54,6 +56,9 @@ public class AsynchronousUnregister implements AsynchronousProcess { @Inject private CommandManager commandManager; + @Inject + private BungeeSender bungeeSender; + AsynchronousUnregister() { } @@ -112,6 +117,9 @@ public class AsynchronousUnregister implements AsynchronousProcess { * @param player the according Player object (nullable) */ private void performPostUnregisterActions(String name, Player player) { + if (player != null && playerCache.isAuthenticated(name)) { + bungeeSender.sendAuthMeBungeecordMessage(player, MessageType.LOGOUT); + } playerCache.removePlayer(name); // TODO: send an update when a messaging service will be implemented (UNREGISTER) From 6f1c63e693fbd337dd3fdb365a9d146a56bf6197 Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Thu, 18 Aug 2022 03:39:40 +0200 Subject: [PATCH 57/97] Add delay to bungee force-login messages --- .../fr/xephi/authme/process/join/AsynchronousJoin.java | 8 +++++++- .../fr/xephi/authme/process/login/AsynchronousLogin.java | 8 +++++++- src/main/java/fr/xephi/authme/service/BukkitService.java | 2 +- .../xephi/authme/service/bungeecord/BungeeReceiver.java | 2 +- .../fr/xephi/authme/service/bungeecord/BungeeSender.java | 1 + 5 files changed, 17 insertions(+), 4 deletions(-) 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 93d38947c..160e125cb 100644 --- a/src/main/java/fr/xephi/authme/process/join/AsynchronousJoin.java +++ b/src/main/java/fr/xephi/authme/process/join/AsynchronousJoin.java @@ -153,7 +153,13 @@ public class AsynchronousJoin implements AsynchronousProcess { }); // Skip if registration is optional - bungeeSender.sendAuthMeBungeecordMessage(player, MessageType.LOGIN); + + if (bungeeSender.isEnabled()) { + // As described at https://www.spigotmc.org/wiki/bukkit-bungee-plugin-messaging-channel/ + // "Keep in mind that you can't send plugin messages directly after a player joins." + bukkitService.scheduleSyncDelayedTask(() -> + bungeeSender.sendAuthMeBungeecordMessage(player, MessageType.LOGIN), 10L); + } return; } diff --git a/src/main/java/fr/xephi/authme/process/login/AsynchronousLogin.java b/src/main/java/fr/xephi/authme/process/login/AsynchronousLogin.java index 897daa0fa..e465803cd 100644 --- a/src/main/java/fr/xephi/authme/process/login/AsynchronousLogin.java +++ b/src/main/java/fr/xephi/authme/process/login/AsynchronousLogin.java @@ -300,7 +300,13 @@ public class AsynchronousLogin implements AsynchronousProcess { playerCache.updatePlayer(auth); dataSource.setLogged(name); sessionService.grantSession(name); - bungeeSender.sendAuthMeBungeecordMessage(player, MessageType.LOGIN); + + if (bungeeSender.isEnabled()) { + // As described at https://www.spigotmc.org/wiki/bukkit-bungee-plugin-messaging-channel/ + // "Keep in mind that you can't send plugin messages directly after a player joins." + bukkitService.scheduleSyncDelayedTask(() -> + bungeeSender.sendAuthMeBungeecordMessage(player, MessageType.LOGIN), 10L); + } // As the scheduling executes the Task most likely after the current // task, we schedule it in the end diff --git a/src/main/java/fr/xephi/authme/service/BukkitService.java b/src/main/java/fr/xephi/authme/service/BukkitService.java index e02c6f100..a09b18508 100644 --- a/src/main/java/fr/xephi/authme/service/BukkitService.java +++ b/src/main/java/fr/xephi/authme/service/BukkitService.java @@ -308,7 +308,7 @@ public class BukkitService implements SettingsDependent { } /** - * Adds a ban to the this list. If a previous ban exists, this will + * Adds a ban to the list. If a previous ban exists, this will * update the previous entry. * * @param ip the ip of the ban diff --git a/src/main/java/fr/xephi/authme/service/bungeecord/BungeeReceiver.java b/src/main/java/fr/xephi/authme/service/bungeecord/BungeeReceiver.java index 091c796b4..05c7c944f 100644 --- a/src/main/java/fr/xephi/authme/service/bungeecord/BungeeReceiver.java +++ b/src/main/java/fr/xephi/authme/service/bungeecord/BungeeReceiver.java @@ -46,7 +46,7 @@ public class BungeeReceiver implements PluginMessageListener, SettingsDependent this.isEnabled = bukkitService.isBungeeCordConfiguredForSpigot().orElse(false); } if (this.isEnabled) { - Messenger messenger = plugin.getServer().getMessenger(); + final Messenger messenger = plugin.getServer().getMessenger(); if (!messenger.isIncomingChannelRegistered(plugin, "BungeeCord")) { messenger.registerIncomingPluginChannel(plugin, "BungeeCord", this); } diff --git a/src/main/java/fr/xephi/authme/service/bungeecord/BungeeSender.java b/src/main/java/fr/xephi/authme/service/bungeecord/BungeeSender.java index 25080e019..68edfcf27 100644 --- a/src/main/java/fr/xephi/authme/service/bungeecord/BungeeSender.java +++ b/src/main/java/fr/xephi/authme/service/bungeecord/BungeeSender.java @@ -83,6 +83,7 @@ public class BungeeSender implements SettingsDependent { if (!isEnabled || destinationServerOnLogin.isEmpty()) { return; } + // Add a small delay, just in case... bukkitService.scheduleSyncDelayedTask(() -> sendBungeecordMessage(player, "Connect", destinationServerOnLogin), 5L); } From c38e2aba281e0799050c3a99a69d782d7bf10d0e Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Thu, 18 Aug 2022 03:41:31 +0200 Subject: [PATCH 58/97] Fix bungee message order (login -> connect) --- .../java/fr/xephi/authme/process/join/AsynchronousJoin.java | 2 +- .../java/fr/xephi/authme/process/login/AsynchronousLogin.java | 2 +- .../java/fr/xephi/authme/service/bungeecord/BungeeSender.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) 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 160e125cb..725faa83c 100644 --- a/src/main/java/fr/xephi/authme/process/join/AsynchronousJoin.java +++ b/src/main/java/fr/xephi/authme/process/join/AsynchronousJoin.java @@ -158,7 +158,7 @@ public class AsynchronousJoin implements AsynchronousProcess { // As described at https://www.spigotmc.org/wiki/bukkit-bungee-plugin-messaging-channel/ // "Keep in mind that you can't send plugin messages directly after a player joins." bukkitService.scheduleSyncDelayedTask(() -> - bungeeSender.sendAuthMeBungeecordMessage(player, MessageType.LOGIN), 10L); + bungeeSender.sendAuthMeBungeecordMessage(player, MessageType.LOGIN), 5L); } return; } diff --git a/src/main/java/fr/xephi/authme/process/login/AsynchronousLogin.java b/src/main/java/fr/xephi/authme/process/login/AsynchronousLogin.java index e465803cd..4b86a5673 100644 --- a/src/main/java/fr/xephi/authme/process/login/AsynchronousLogin.java +++ b/src/main/java/fr/xephi/authme/process/login/AsynchronousLogin.java @@ -305,7 +305,7 @@ public class AsynchronousLogin implements AsynchronousProcess { // As described at https://www.spigotmc.org/wiki/bukkit-bungee-plugin-messaging-channel/ // "Keep in mind that you can't send plugin messages directly after a player joins." bukkitService.scheduleSyncDelayedTask(() -> - bungeeSender.sendAuthMeBungeecordMessage(player, MessageType.LOGIN), 10L); + bungeeSender.sendAuthMeBungeecordMessage(player, MessageType.LOGIN), 5L); } // As the scheduling executes the Task most likely after the current diff --git a/src/main/java/fr/xephi/authme/service/bungeecord/BungeeSender.java b/src/main/java/fr/xephi/authme/service/bungeecord/BungeeSender.java index 68edfcf27..d4a9f7ef1 100644 --- a/src/main/java/fr/xephi/authme/service/bungeecord/BungeeSender.java +++ b/src/main/java/fr/xephi/authme/service/bungeecord/BungeeSender.java @@ -85,7 +85,7 @@ public class BungeeSender implements SettingsDependent { } // Add a small delay, just in case... bukkitService.scheduleSyncDelayedTask(() -> - sendBungeecordMessage(player, "Connect", destinationServerOnLogin), 5L); + sendBungeecordMessage(player, "Connect", destinationServerOnLogin), 10L); } /** From 909617fce1df295573f5c705f138eb1d208e1e92 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 19 Aug 2022 16:45:52 +0200 Subject: [PATCH 59/97] Bump postgresql from 42.4.1 to 42.4.2 (#2605) Bumps [postgresql](https://github.com/pgjdbc/pgjdbc) from 42.4.1 to 42.4.2. - [Release notes](https://github.com/pgjdbc/pgjdbc/releases) - [Changelog](https://github.com/pgjdbc/pgjdbc/blob/master/CHANGELOG.md) - [Commits](https://github.com/pgjdbc/pgjdbc/compare/REL42.4.1...REL42.4.2) --- updated-dependencies: - dependency-name: org.postgresql:postgresql dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1f3ebe534..5dd647092 100644 --- a/pom.xml +++ b/pom.xml @@ -1001,7 +1001,7 @@ org.postgresql postgresql - 42.4.1 + 42.4.2 true From 75b3a571e1786368659a0e69209f5735a400ea5e Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Sat, 20 Aug 2022 04:41:04 +0200 Subject: [PATCH 60/97] =?UTF-8?q?Always=20specify=20Locale=20on=20toLowerC?= =?UTF-8?q?ase=20and=20toUpperCase=20usages,=20fixes=20AuthMe=20not=20work?= =?UTF-8?q?ing=20correctly=20on=20machines=20with=20turkish=20locale.=20('?= =?UTF-8?q?I'.toLowerCase()=20=3D>=20'=C4=B1')?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/fr/xephi/authme/api/v3/AuthMeApi.java | 5 +++-- .../java/fr/xephi/authme/command/CommandMapper.java | 5 +++-- .../command/executable/authme/AccountsCommand.java | 3 ++- .../command/executable/authme/ConverterCommand.java | 3 ++- .../authme/PurgeBannedPlayersCommand.java | 3 ++- .../executable/authme/PurgePlayerCommand.java | 3 ++- .../executable/authme/RegisterAdminCommand.java | 3 ++- .../executable/authme/debug/DebugCommand.java | 3 ++- .../changepassword/ChangePasswordCommand.java | 3 ++- .../fr/xephi/authme/data/ProxySessionManager.java | 3 ++- .../xephi/authme/data/VerificationCodeManager.java | 13 +++++++------ .../java/fr/xephi/authme/data/auth/PlayerAuth.java | 5 +++-- .../java/fr/xephi/authme/data/auth/PlayerCache.java | 9 +++++---- .../authme/data/captcha/CaptchaCodeStorage.java | 7 ++++--- .../authme/data/captcha/LoginCaptchaManager.java | 9 +++++---- .../data/captcha/RegistrationCaptchaManager.java | 5 +++-- .../fr/xephi/authme/data/limbo/LimboService.java | 11 ++++++----- .../fr/xephi/authme/datasource/CacheDataSource.java | 13 +++++++------ src/main/java/fr/xephi/authme/datasource/MySQL.java | 11 ++++++----- .../authme/datasource/PostgreSqlDataSource.java | 13 +++++++------ .../java/fr/xephi/authme/datasource/SQLite.java | 7 ++++--- .../columnshandler/AuthMeColumnsHandler.java | 9 +++++---- .../datasource/converter/CrazyLoginConverter.java | 3 ++- .../datasource/converter/RoyalAuthConverter.java | 3 ++- .../authme/datasource/converter/VAuthConverter.java | 5 +++-- .../authme/datasource/converter/XAuthConverter.java | 5 +++-- .../initialization/OnShutdownPlayerSaver.java | 5 +++-- .../fr/xephi/authme/listener/OnJoinVerifier.java | 3 ++- .../fr/xephi/authme/listener/PlayerListener.java | 7 ++++--- .../fr/xephi/authme/output/LogFilterHelper.java | 3 ++- .../process/changepassword/AsyncChangePassword.java | 5 +++-- .../xephi/authme/process/email/AsyncAddEmail.java | 3 ++- .../authme/process/email/AsyncChangeEmail.java | 3 ++- .../xephi/authme/process/join/AsynchronousJoin.java | 4 +++- .../authme/process/login/AsynchronousLogin.java | 7 ++++--- .../process/login/ProcessSyncPlayerLogin.java | 3 ++- .../authme/process/logout/AsynchronousLogout.java | 3 ++- .../xephi/authme/process/quit/AsynchronousQuit.java | 3 ++- .../authme/process/register/AsyncRegister.java | 3 ++- .../register/executors/PlayerAuthBuilderHelper.java | 4 +++- .../fr/xephi/authme/security/PasswordSecurity.java | 5 +++-- .../java/fr/xephi/authme/security/crypts/Smf.java | 4 +++- .../java/fr/xephi/authme/security/crypts/XAuth.java | 4 +++- .../authme/security/totp/GenerateTotpService.java | 9 +++++---- .../authme/security/totp/TotpAuthenticator.java | 4 +++- .../fr/xephi/authme/service/AntiBotService.java | 5 +++-- .../java/fr/xephi/authme/service/BackupService.java | 3 ++- .../authme/service/PasswordRecoveryService.java | 7 ++++--- .../fr/xephi/authme/service/ValidationService.java | 9 +++++---- .../authme/service/bungeecord/BungeeSender.java | 5 +++-- .../java/fr/xephi/authme/settings/SpawnLoader.java | 3 ++- .../fr/xephi/authme/task/purge/PurgeExecutor.java | 5 +++-- .../java/fr/xephi/authme/task/purge/PurgeTask.java | 3 ++- .../java/fr/xephi/authme/api/v3/AuthMeApiTest.java | 7 ++++--- .../authme/command/CommandInitializerTest.java | 3 ++- .../executable/authme/ConverterCommandTest.java | 3 ++- .../authme/PurgeBannedPlayersCommandTest.java | 3 ++- .../executable/authme/PurgePlayerCommandTest.java | 6 ++++-- .../executable/authme/RegisterAdminCommandTest.java | 3 ++- .../executable/authme/debug/DebugCommandTest.java | 5 +++-- .../executable/email/RecoverEmailCommandTest.java | 3 ++- .../xephi/authme/command/help/HelpProviderTest.java | 13 +++++++------ .../data/captcha/LoginCaptchaManagerTest.java | 6 ++++-- .../xephi/authme/security/PasswordSecurityTest.java | 9 +++++---- .../crypts/AbstractEncryptionMethodTest.java | 9 +++++---- .../xephi/authme/service/MigrationServiceTest.java | 3 ++- .../hashmethods/HashAlgorithmsDescriptionTask.java | 3 ++- 67 files changed, 217 insertions(+), 143 deletions(-) diff --git a/src/main/java/fr/xephi/authme/api/v3/AuthMeApi.java b/src/main/java/fr/xephi/authme/api/v3/AuthMeApi.java index ca133c516..3d8ab194f 100644 --- a/src/main/java/fr/xephi/authme/api/v3/AuthMeApi.java +++ b/src/main/java/fr/xephi/authme/api/v3/AuthMeApi.java @@ -21,6 +21,7 @@ import java.time.Instant; import java.util.ArrayList; import java.util.Date; import java.util.List; +import java.util.Locale; import java.util.Optional; /** @@ -217,7 +218,7 @@ public class AuthMeApi { * @return true if player is registered, false otherwise */ public boolean isRegistered(String playerName) { - String player = playerName.toLowerCase(); + String player = playerName.toLowerCase(Locale.ROOT); return dataSource.isAuthAvailable(player); } @@ -241,7 +242,7 @@ public class AuthMeApi { * @return true if the player was registered successfully */ public boolean registerPlayer(String playerName, String password) { - String name = playerName.toLowerCase(); + String name = playerName.toLowerCase(Locale.ROOT); if (isRegistered(name)) { return false; } diff --git a/src/main/java/fr/xephi/authme/command/CommandMapper.java b/src/main/java/fr/xephi/authme/command/CommandMapper.java index b7ed21704..5beb5e33e 100644 --- a/src/main/java/fr/xephi/authme/command/CommandMapper.java +++ b/src/main/java/fr/xephi/authme/command/CommandMapper.java @@ -11,6 +11,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; import java.util.List; +import java.util.Locale; import java.util.Set; import static fr.xephi.authme.command.FoundResultStatus.INCORRECT_ARGUMENTS; @@ -130,7 +131,7 @@ public class CommandMapper { } private CommandDescription getBaseCommand(String label) { - String baseLabel = label.toLowerCase(); + String baseLabel = label.toLowerCase(Locale.ROOT); if (baseLabel.startsWith("authme:")) { baseLabel = baseLabel.substring("authme:".length()); } @@ -157,7 +158,7 @@ public class CommandMapper { return null; } - final String label = parts.get(0).toLowerCase(); + final String label = parts.get(0).toLowerCase(Locale.ROOT); final int argumentCount = parts.size() - 1; for (CommandDescription child : baseCommand.getChildren()) { diff --git a/src/main/java/fr/xephi/authme/command/executable/authme/AccountsCommand.java b/src/main/java/fr/xephi/authme/command/executable/authme/AccountsCommand.java index 2a87802eb..20f6bff8a 100644 --- a/src/main/java/fr/xephi/authme/command/executable/authme/AccountsCommand.java +++ b/src/main/java/fr/xephi/authme/command/executable/authme/AccountsCommand.java @@ -10,6 +10,7 @@ import org.bukkit.command.CommandSender; import javax.inject.Inject; import java.util.List; +import java.util.Locale; /** * Shows all accounts registered by the same IP address for the given player name or IP address. @@ -44,7 +45,7 @@ public class AccountsCommand implements ExecutableCommand { }); } else { bukkitService.runTaskAsynchronously(() -> { - PlayerAuth auth = dataSource.getAuth(playerName.toLowerCase()); + PlayerAuth auth = dataSource.getAuth(playerName.toLowerCase(Locale.ROOT)); if (auth == null) { commonService.send(sender, MessageKey.UNKNOWN_USER); return; diff --git a/src/main/java/fr/xephi/authme/command/executable/authme/ConverterCommand.java b/src/main/java/fr/xephi/authme/command/executable/authme/ConverterCommand.java index fd0a73513..b035b63e9 100644 --- a/src/main/java/fr/xephi/authme/command/executable/authme/ConverterCommand.java +++ b/src/main/java/fr/xephi/authme/command/executable/authme/ConverterCommand.java @@ -22,6 +22,7 @@ import org.bukkit.command.CommandSender; import javax.inject.Inject; import java.util.List; +import java.util.Locale; import java.util.Map; /** @@ -71,7 +72,7 @@ public class ConverterCommand implements ExecutableCommand { private static Class getConverterClassFromArgs(List arguments) { return arguments.isEmpty() ? null - : CONVERTERS.get(arguments.get(0).toLowerCase()); + : CONVERTERS.get(arguments.get(0).toLowerCase(Locale.ROOT)); } /** diff --git a/src/main/java/fr/xephi/authme/command/executable/authme/PurgeBannedPlayersCommand.java b/src/main/java/fr/xephi/authme/command/executable/authme/PurgeBannedPlayersCommand.java index 82b109cc3..860ae73d2 100644 --- a/src/main/java/fr/xephi/authme/command/executable/authme/PurgeBannedPlayersCommand.java +++ b/src/main/java/fr/xephi/authme/command/executable/authme/PurgeBannedPlayersCommand.java @@ -9,6 +9,7 @@ import org.bukkit.command.CommandSender; import javax.inject.Inject; import java.util.HashSet; import java.util.List; +import java.util.Locale; import java.util.Set; /** @@ -29,7 +30,7 @@ public class PurgeBannedPlayersCommand implements ExecutableCommand { Set bannedPlayers = bukkitService.getBannedPlayers(); Set namedBanned = new HashSet<>(bannedPlayers.size()); for (OfflinePlayer offlinePlayer : bannedPlayers) { - namedBanned.add(offlinePlayer.getName().toLowerCase()); + namedBanned.add(offlinePlayer.getName().toLowerCase(Locale.ROOT)); } purgeService.purgePlayers(sender, namedBanned, bannedPlayers.toArray(new OfflinePlayer[bannedPlayers.size()])); diff --git a/src/main/java/fr/xephi/authme/command/executable/authme/PurgePlayerCommand.java b/src/main/java/fr/xephi/authme/command/executable/authme/PurgePlayerCommand.java index ded4dd9d7..e0bf9040f 100644 --- a/src/main/java/fr/xephi/authme/command/executable/authme/PurgePlayerCommand.java +++ b/src/main/java/fr/xephi/authme/command/executable/authme/PurgePlayerCommand.java @@ -9,6 +9,7 @@ import org.bukkit.command.CommandSender; import javax.inject.Inject; import java.util.List; +import java.util.Locale; import static java.util.Collections.singletonList; @@ -36,7 +37,7 @@ public class PurgePlayerCommand implements ExecutableCommand { private void executeCommand(CommandSender sender, String name, String option) { if ("force".equals(option) || !dataSource.isAuthAvailable(name)) { OfflinePlayer offlinePlayer = bukkitService.getOfflinePlayer(name); - purgeExecutor.executePurge(singletonList(offlinePlayer), singletonList(name.toLowerCase())); + purgeExecutor.executePurge(singletonList(offlinePlayer), singletonList(name.toLowerCase(Locale.ROOT))); sender.sendMessage("Purged data for player " + name); } else { sender.sendMessage("This player is still registered! Are you sure you want to proceed? " diff --git a/src/main/java/fr/xephi/authme/command/executable/authme/RegisterAdminCommand.java b/src/main/java/fr/xephi/authme/command/executable/authme/RegisterAdminCommand.java index ada52966a..eaa56a41e 100644 --- a/src/main/java/fr/xephi/authme/command/executable/authme/RegisterAdminCommand.java +++ b/src/main/java/fr/xephi/authme/command/executable/authme/RegisterAdminCommand.java @@ -17,6 +17,7 @@ import org.bukkit.entity.Player; import javax.inject.Inject; import java.util.List; +import java.util.Locale; /** * Admin command to register a user. @@ -45,7 +46,7 @@ public class RegisterAdminCommand implements ExecutableCommand { // Get the player name and password final String playerName = arguments.get(0); final String playerPass = arguments.get(1); - final String playerNameLowerCase = playerName.toLowerCase(); + final String playerNameLowerCase = playerName.toLowerCase(Locale.ROOT); // Command logic ValidationResult passwordValidation = validationService.validatePassword(playerPass, playerName); diff --git a/src/main/java/fr/xephi/authme/command/executable/authme/debug/DebugCommand.java b/src/main/java/fr/xephi/authme/command/executable/authme/debug/DebugCommand.java index c7b0d8fce..4198a19eb 100644 --- a/src/main/java/fr/xephi/authme/command/executable/authme/debug/DebugCommand.java +++ b/src/main/java/fr/xephi/authme/command/executable/authme/debug/DebugCommand.java @@ -9,6 +9,7 @@ import org.bukkit.command.CommandSender; import javax.inject.Inject; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Set; import java.util.TreeMap; @@ -45,7 +46,7 @@ public class DebugCommand implements ExecutableCommand { if (arguments.isEmpty()) { return null; } - return getSections().get(arguments.get(0).toLowerCase()); + return getSections().get(arguments.get(0).toLowerCase(Locale.ROOT)); } private void sendAvailableSections(CommandSender sender) { diff --git a/src/main/java/fr/xephi/authme/command/executable/changepassword/ChangePasswordCommand.java b/src/main/java/fr/xephi/authme/command/executable/changepassword/ChangePasswordCommand.java index a1cc4f034..72ff55bc0 100644 --- a/src/main/java/fr/xephi/authme/command/executable/changepassword/ChangePasswordCommand.java +++ b/src/main/java/fr/xephi/authme/command/executable/changepassword/ChangePasswordCommand.java @@ -12,6 +12,7 @@ import org.bukkit.entity.Player; import javax.inject.Inject; import java.util.List; +import java.util.Locale; /** * The command for a player to change his password with. @@ -35,7 +36,7 @@ public class ChangePasswordCommand extends PlayerCommand { @Override public void runCommand(Player player, List arguments) { - String name = player.getName().toLowerCase(); + String name = player.getName().toLowerCase(Locale.ROOT); if (!playerCache.isAuthenticated(name)) { commonService.send(player, MessageKey.NOT_LOGGED_IN); diff --git a/src/main/java/fr/xephi/authme/data/ProxySessionManager.java b/src/main/java/fr/xephi/authme/data/ProxySessionManager.java index c5a6fee97..d0c60fb2a 100644 --- a/src/main/java/fr/xephi/authme/data/ProxySessionManager.java +++ b/src/main/java/fr/xephi/authme/data/ProxySessionManager.java @@ -4,6 +4,7 @@ import fr.xephi.authme.initialization.HasCleanup; import fr.xephi.authme.util.expiring.ExpiringSet; import javax.inject.Inject; +import java.util.Locale; import java.util.concurrent.TimeUnit; public class ProxySessionManager implements HasCleanup { @@ -21,7 +22,7 @@ public class ProxySessionManager implements HasCleanup { * @param name the player's name */ private void setActiveSession(String name) { - activeProxySessions.add(name.toLowerCase()); + activeProxySessions.add(name.toLowerCase(Locale.ROOT)); } /** diff --git a/src/main/java/fr/xephi/authme/data/VerificationCodeManager.java b/src/main/java/fr/xephi/authme/data/VerificationCodeManager.java index 1cd176684..0a8ff0616 100644 --- a/src/main/java/fr/xephi/authme/data/VerificationCodeManager.java +++ b/src/main/java/fr/xephi/authme/data/VerificationCodeManager.java @@ -16,6 +16,7 @@ import org.bukkit.entity.Player; import javax.inject.Inject; import java.util.HashSet; +import java.util.Locale; import java.util.Set; import java.util.concurrent.TimeUnit; @@ -82,7 +83,7 @@ public class VerificationCodeManager implements SettingsDependent, HasCleanup { * @return true if the player has been verified, false otherwise */ private boolean isPlayerVerified(String name) { - return verifiedPlayers.contains(name.toLowerCase()); + return verifiedPlayers.contains(name.toLowerCase(Locale.ROOT)); } /** @@ -92,7 +93,7 @@ public class VerificationCodeManager implements SettingsDependent, HasCleanup { * @return true if the code exists, false otherwise */ public boolean hasCode(String name) { - return (verificationCodes.get(name.toLowerCase()) != null); + return (verificationCodes.get(name.toLowerCase(Locale.ROOT)) != null); } /** @@ -135,7 +136,7 @@ public class VerificationCodeManager implements SettingsDependent, HasCleanup { final String email = emailResult.getValue(); if (!Utils.isEmailEmpty(email)) { String code = RandomStringUtils.generateNum(6); // 6 digits code - verificationCodes.put(name.toLowerCase(), code); + verificationCodes.put(name.toLowerCase(Locale.ROOT), code); emailService.sendVerificationMail(name, email, code); } } @@ -150,7 +151,7 @@ public class VerificationCodeManager implements SettingsDependent, HasCleanup { */ public boolean checkCode(String name, String code) { boolean correct = false; - if (code.equals(verificationCodes.get(name.toLowerCase()))) { + if (code.equals(verificationCodes.get(name.toLowerCase(Locale.ROOT)))) { verify(name); correct = true; } @@ -163,7 +164,7 @@ public class VerificationCodeManager implements SettingsDependent, HasCleanup { * @param name the name of the player to generate a code for */ public void verify(String name) { - verifiedPlayers.add(name.toLowerCase()); + verifiedPlayers.add(name.toLowerCase(Locale.ROOT)); } /** @@ -172,7 +173,7 @@ public class VerificationCodeManager implements SettingsDependent, HasCleanup { * @param name the name of the player to generate a code for */ public void unverify(String name){ - verifiedPlayers.remove(name.toLowerCase()); + verifiedPlayers.remove(name.toLowerCase(Locale.ROOT)); } @Override diff --git a/src/main/java/fr/xephi/authme/data/auth/PlayerAuth.java b/src/main/java/fr/xephi/authme/data/auth/PlayerAuth.java index 23aa8116d..820826290 100644 --- a/src/main/java/fr/xephi/authme/data/auth/PlayerAuth.java +++ b/src/main/java/fr/xephi/authme/data/auth/PlayerAuth.java @@ -3,6 +3,7 @@ package fr.xephi.authme.data.auth; import fr.xephi.authme.security.crypts.HashedPassword; import org.bukkit.Location; +import java.util.Locale; import java.util.Objects; import java.util.Optional; import java.util.UUID; @@ -54,7 +55,7 @@ public class PlayerAuth { public void setNickname(String nickname) { - this.nickname = nickname.toLowerCase(); + this.nickname = nickname.toLowerCase(Locale.ROOT); } public String getNickname() { @@ -239,7 +240,7 @@ public class PlayerAuth { */ public PlayerAuth build() { PlayerAuth auth = new PlayerAuth(); - auth.nickname = checkNotNull(name).toLowerCase(); + auth.nickname = checkNotNull(name).toLowerCase(Locale.ROOT); auth.realName = Optional.ofNullable(realName).orElse("Player"); auth.password = Optional.ofNullable(password).orElse(new HashedPassword("")); auth.totpKey = totpKey; diff --git a/src/main/java/fr/xephi/authme/data/auth/PlayerCache.java b/src/main/java/fr/xephi/authme/data/auth/PlayerCache.java index 46fafbf77..e617f20ec 100644 --- a/src/main/java/fr/xephi/authme/data/auth/PlayerCache.java +++ b/src/main/java/fr/xephi/authme/data/auth/PlayerCache.java @@ -1,6 +1,7 @@ package fr.xephi.authme.data.auth; +import java.util.Locale; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -20,7 +21,7 @@ public class PlayerCache { * @param auth the player auth object to save */ public void updatePlayer(PlayerAuth auth) { - cache.put(auth.getNickname().toLowerCase(), auth); + cache.put(auth.getNickname().toLowerCase(Locale.ROOT), auth); } /** @@ -29,7 +30,7 @@ public class PlayerCache { * @param user name of the player to remove */ public void removePlayer(String user) { - cache.remove(user.toLowerCase()); + cache.remove(user.toLowerCase(Locale.ROOT)); } /** @@ -40,7 +41,7 @@ public class PlayerCache { * @return true if player is logged in, false otherwise. */ public boolean isAuthenticated(String user) { - return cache.containsKey(user.toLowerCase()); + return cache.containsKey(user.toLowerCase(Locale.ROOT)); } /** @@ -51,7 +52,7 @@ public class PlayerCache { * @return the associated auth object, or null if not available */ public PlayerAuth getAuth(String user) { - return cache.get(user.toLowerCase()); + return cache.get(user.toLowerCase(Locale.ROOT)); } /** diff --git a/src/main/java/fr/xephi/authme/data/captcha/CaptchaCodeStorage.java b/src/main/java/fr/xephi/authme/data/captcha/CaptchaCodeStorage.java index 713edd69b..5667a6f15 100644 --- a/src/main/java/fr/xephi/authme/data/captcha/CaptchaCodeStorage.java +++ b/src/main/java/fr/xephi/authme/data/captcha/CaptchaCodeStorage.java @@ -3,6 +3,7 @@ package fr.xephi.authme.data.captcha; import fr.xephi.authme.util.RandomStringUtils; import fr.xephi.authme.util.expiring.ExpiringMap; +import java.util.Locale; import java.util.concurrent.TimeUnit; /** @@ -51,7 +52,7 @@ public class CaptchaCodeStorage { * @return the code the player is required to enter */ public String getCodeOrGenerateNew(String name) { - String code = captchaCodes.get(name.toLowerCase()); + String code = captchaCodes.get(name.toLowerCase(Locale.ROOT)); return code == null ? generateCode(name) : code; } @@ -63,7 +64,7 @@ public class CaptchaCodeStorage { */ private String generateCode(String name) { String code = RandomStringUtils.generate(captchaLength); - captchaCodes.put(name.toLowerCase(), code); + captchaCodes.put(name.toLowerCase(Locale.ROOT), code); return code; } @@ -76,7 +77,7 @@ public class CaptchaCodeStorage { * @return true if the code matches, false otherwise */ public boolean checkCode(String name, String code) { - String nameLowerCase = name.toLowerCase(); + String nameLowerCase = name.toLowerCase(Locale.ROOT); String savedCode = captchaCodes.get(nameLowerCase); if (savedCode != null && savedCode.equalsIgnoreCase(code)) { captchaCodes.remove(nameLowerCase); diff --git a/src/main/java/fr/xephi/authme/data/captcha/LoginCaptchaManager.java b/src/main/java/fr/xephi/authme/data/captcha/LoginCaptchaManager.java index cf3958a1d..1d97af69c 100644 --- a/src/main/java/fr/xephi/authme/data/captcha/LoginCaptchaManager.java +++ b/src/main/java/fr/xephi/authme/data/captcha/LoginCaptchaManager.java @@ -8,6 +8,7 @@ import fr.xephi.authme.util.expiring.TimedCounter; import org.bukkit.entity.Player; import javax.inject.Inject; +import java.util.Locale; import java.util.concurrent.TimeUnit; /** @@ -36,14 +37,14 @@ public class LoginCaptchaManager implements CaptchaManager, SettingsDependent, H */ public void increaseLoginFailureCount(String name) { if (isEnabled) { - String playerLower = name.toLowerCase(); + String playerLower = name.toLowerCase(Locale.ROOT); playerCounts.increment(playerLower); } } @Override public boolean isCaptchaRequired(String playerName) { - return isEnabled && playerCounts.get(playerName.toLowerCase()) >= threshold; + return isEnabled && playerCounts.get(playerName.toLowerCase(Locale.ROOT)) >= threshold; } @Override @@ -53,7 +54,7 @@ public class LoginCaptchaManager implements CaptchaManager, SettingsDependent, H @Override public boolean checkCode(Player player, String code) { - String nameLower = player.getName().toLowerCase(); + String nameLower = player.getName().toLowerCase(Locale.ROOT); boolean isCodeCorrect = captchaCodeStorage.checkCode(nameLower, code); if (isCodeCorrect) { playerCounts.remove(nameLower); @@ -68,7 +69,7 @@ public class LoginCaptchaManager implements CaptchaManager, SettingsDependent, H */ public void resetLoginFailureCount(String name) { if (isEnabled) { - playerCounts.remove(name.toLowerCase()); + playerCounts.remove(name.toLowerCase(Locale.ROOT)); } } diff --git a/src/main/java/fr/xephi/authme/data/captcha/RegistrationCaptchaManager.java b/src/main/java/fr/xephi/authme/data/captcha/RegistrationCaptchaManager.java index 3b751247e..655d99408 100644 --- a/src/main/java/fr/xephi/authme/data/captcha/RegistrationCaptchaManager.java +++ b/src/main/java/fr/xephi/authme/data/captcha/RegistrationCaptchaManager.java @@ -8,6 +8,7 @@ import fr.xephi.authme.util.expiring.ExpiringSet; import org.bukkit.entity.Player; import javax.inject.Inject; +import java.util.Locale; import java.util.concurrent.TimeUnit; /** @@ -31,7 +32,7 @@ public class RegistrationCaptchaManager implements CaptchaManager, SettingsDepen @Override public boolean isCaptchaRequired(String name) { - return isEnabled && !verifiedNamesForRegistration.contains(name.toLowerCase()); + return isEnabled && !verifiedNamesForRegistration.contains(name.toLowerCase(Locale.ROOT)); } @Override @@ -41,7 +42,7 @@ public class RegistrationCaptchaManager implements CaptchaManager, SettingsDepen @Override public boolean checkCode(Player player, String code) { - String nameLower = player.getName().toLowerCase(); + String nameLower = player.getName().toLowerCase(Locale.ROOT); boolean isCodeCorrect = captchaCodeStorage.checkCode(nameLower, code); if (isCodeCorrect) { verifiedNamesForRegistration.add(nameLower); diff --git a/src/main/java/fr/xephi/authme/data/limbo/LimboService.java b/src/main/java/fr/xephi/authme/data/limbo/LimboService.java index 937ed912d..c8b469224 100644 --- a/src/main/java/fr/xephi/authme/data/limbo/LimboService.java +++ b/src/main/java/fr/xephi/authme/data/limbo/LimboService.java @@ -9,6 +9,7 @@ import org.bukkit.Location; import org.bukkit.entity.Player; import javax.inject.Inject; +import java.util.Locale; import java.util.Map; import java.util.Optional; import java.util.concurrent.ConcurrentHashMap; @@ -55,7 +56,7 @@ public class LimboService { * @param isRegistered whether or not the player is registered */ public void createLimboPlayer(Player player, boolean isRegistered) { - final String name = player.getName().toLowerCase(); + final String name = player.getName().toLowerCase(Locale.ROOT); LimboPlayer limboFromDisk = persistence.getLimboPlayer(player); if (limboFromDisk != null) { @@ -89,7 +90,7 @@ public class LimboService { * @return the associated limbo player, or null if none available */ public LimboPlayer getLimboPlayer(String name) { - return entries.get(name.toLowerCase()); + return entries.get(name.toLowerCase(Locale.ROOT)); } /** @@ -99,7 +100,7 @@ public class LimboService { * @return true if present, false otherwise */ public boolean hasLimboPlayer(String name) { - return entries.containsKey(name.toLowerCase()); + return entries.containsKey(name.toLowerCase(Locale.ROOT)); } /** @@ -111,7 +112,7 @@ public class LimboService { * @param player the player whose data should be restored */ public void restoreData(Player player) { - String lowerName = player.getName().toLowerCase(); + String lowerName = player.getName().toLowerCase(Locale.ROOT); LimboPlayer limbo = entries.remove(lowerName); if (limbo == null) { @@ -178,7 +179,7 @@ public class LimboService { * @return Optional with the limbo player */ private Optional getLimboOrLogError(Player player, String context) { - LimboPlayer limbo = entries.get(player.getName().toLowerCase()); + LimboPlayer limbo = entries.get(player.getName().toLowerCase(Locale.ROOT)); if (limbo == null) { logger.debug("No LimboPlayer found for `{0}`. Action: {1}", player.getName(), context); } diff --git a/src/main/java/fr/xephi/authme/datasource/CacheDataSource.java b/src/main/java/fr/xephi/authme/datasource/CacheDataSource.java index e1418dcaf..f6030e920 100644 --- a/src/main/java/fr/xephi/authme/datasource/CacheDataSource.java +++ b/src/main/java/fr/xephi/authme/datasource/CacheDataSource.java @@ -18,6 +18,7 @@ import fr.xephi.authme.util.Utils; import java.util.Collection; import java.util.List; +import java.util.Locale; import java.util.Optional; import java.util.Set; import java.util.concurrent.Executors; @@ -86,7 +87,7 @@ public class CacheDataSource implements DataSource { @Override public HashedPassword getPassword(String user) { - user = user.toLowerCase(); + user = user.toLowerCase(Locale.ROOT); Optional pAuthOpt = cachedAuths.getIfPresent(user); if (pAuthOpt != null && pAuthOpt.isPresent()) { return pAuthOpt.get().getPassword(); @@ -96,7 +97,7 @@ public class CacheDataSource implements DataSource { @Override public PlayerAuth getAuth(String user) { - user = user.toLowerCase(); + user = user.toLowerCase(Locale.ROOT); return cachedAuths.getUnchecked(user).orElse(null); } @@ -120,7 +121,7 @@ public class CacheDataSource implements DataSource { @Override public boolean updatePassword(String user, HashedPassword password) { - user = user.toLowerCase(); + user = user.toLowerCase(Locale.ROOT); boolean result = source.updatePassword(user, password); if (result) { cachedAuths.refresh(user); @@ -153,7 +154,7 @@ public class CacheDataSource implements DataSource { @Override public boolean removeAuth(String name) { - name = name.toLowerCase(); + name = name.toLowerCase(Locale.ROOT); boolean result = source.removeAuth(name); if (result) { cachedAuths.invalidate(name); @@ -210,12 +211,12 @@ public class CacheDataSource implements DataSource { @Override public void setLogged(final String user) { - source.setLogged(user.toLowerCase()); + source.setLogged(user.toLowerCase(Locale.ROOT)); } @Override public void setUnlogged(final String user) { - source.setUnlogged(user.toLowerCase()); + source.setUnlogged(user.toLowerCase(Locale.ROOT)); } @Override diff --git a/src/main/java/fr/xephi/authme/datasource/MySQL.java b/src/main/java/fr/xephi/authme/datasource/MySQL.java index ff571c54f..0a3fcd432 100644 --- a/src/main/java/fr/xephi/authme/datasource/MySQL.java +++ b/src/main/java/fr/xephi/authme/datasource/MySQL.java @@ -24,6 +24,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; import java.util.List; +import java.util.Locale; import java.util.Set; import java.util.UUID; @@ -309,7 +310,7 @@ public class MySQL extends AbstractSqlDataSource { String sql = "SELECT * FROM " + tableName + " WHERE " + col.NAME + "=?;"; PlayerAuth auth; try (Connection con = getConnection(); PreparedStatement pst = con.prepareStatement(sql)) { - pst.setString(1, user.toLowerCase()); + pst.setString(1, user.toLowerCase(Locale.ROOT)); try (ResultSet rs = pst.executeQuery()) { if (rs.next()) { int id = rs.getInt(col.ID); @@ -377,11 +378,11 @@ public class MySQL extends AbstractSqlDataSource { @Override public boolean removeAuth(String user) { - user = user.toLowerCase(); + user = user.toLowerCase(Locale.ROOT); String sql = "DELETE FROM " + tableName + " WHERE " + col.NAME + "=?;"; try (Connection con = getConnection(); PreparedStatement pst = con.prepareStatement(sql)) { sqlExtension.removeAuth(user, con); - pst.setString(1, user.toLowerCase()); + pst.setString(1, user.toLowerCase(Locale.ROOT)); pst.executeUpdate(); return true; } catch (SQLException ex) { @@ -402,7 +403,7 @@ public class MySQL extends AbstractSqlDataSource { String sql = "DELETE FROM " + tableName + " WHERE " + col.NAME + "=?;"; try (Connection con = getConnection(); PreparedStatement pst = con.prepareStatement(sql)) { for (String name : toPurge) { - pst.setString(1, name.toLowerCase()); + pst.setString(1, name.toLowerCase(Locale.ROOT)); pst.executeUpdate(); } } catch (SQLException ex) { @@ -470,7 +471,7 @@ public class MySQL extends AbstractSqlDataSource { String sql = "UPDATE " + tableName + " SET " + col.TOTP_KEY + " = ? WHERE " + col.NAME + " = ?"; try (Connection con = getConnection(); PreparedStatement pst = con.prepareStatement(sql)) { pst.setString(1, totpKey); - pst.setString(2, user.toLowerCase()); + pst.setString(2, user.toLowerCase(Locale.ROOT)); pst.executeUpdate(); return true; } catch (SQLException e) { diff --git a/src/main/java/fr/xephi/authme/datasource/PostgreSqlDataSource.java b/src/main/java/fr/xephi/authme/datasource/PostgreSqlDataSource.java index 070c719a5..cc308934b 100644 --- a/src/main/java/fr/xephi/authme/datasource/PostgreSqlDataSource.java +++ b/src/main/java/fr/xephi/authme/datasource/PostgreSqlDataSource.java @@ -23,6 +23,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; import java.util.List; +import java.util.Locale; import java.util.Set; import static fr.xephi.authme.datasource.SqlDataSourceUtils.getNullableLong; @@ -257,7 +258,7 @@ public class PostgreSqlDataSource extends AbstractSqlDataSource { } private boolean isColumnMissing(DatabaseMetaData metaData, String columnName) throws SQLException { - try (ResultSet rs = metaData.getColumns(null, null, tableName, columnName.toLowerCase())) { + try (ResultSet rs = metaData.getColumns(null, null, tableName, columnName.toLowerCase(Locale.ROOT))) { return !rs.next(); } } @@ -267,7 +268,7 @@ public class PostgreSqlDataSource extends AbstractSqlDataSource { String sql = "SELECT * FROM " + tableName + " WHERE " + col.NAME + "=?;"; PlayerAuth auth; try (Connection con = getConnection(); PreparedStatement pst = con.prepareStatement(sql)) { - pst.setString(1, user.toLowerCase()); + pst.setString(1, user.toLowerCase(Locale.ROOT)); try (ResultSet rs = pst.executeQuery()) { if (rs.next()) { int id = rs.getInt(col.ID); @@ -335,11 +336,11 @@ public class PostgreSqlDataSource extends AbstractSqlDataSource { @Override public boolean removeAuth(String user) { - user = user.toLowerCase(); + user = user.toLowerCase(Locale.ROOT); String sql = "DELETE FROM " + tableName + " WHERE " + col.NAME + "=?;"; try (Connection con = getConnection(); PreparedStatement pst = con.prepareStatement(sql)) { sqlExtension.removeAuth(user, con); - pst.setString(1, user.toLowerCase()); + pst.setString(1, user.toLowerCase(Locale.ROOT)); pst.executeUpdate(); return true; } catch (SQLException ex) { @@ -360,7 +361,7 @@ public class PostgreSqlDataSource extends AbstractSqlDataSource { String sql = "DELETE FROM " + tableName + " WHERE " + col.NAME + "=?;"; try (Connection con = getConnection(); PreparedStatement pst = con.prepareStatement(sql)) { for (String name : toPurge) { - pst.setString(1, name.toLowerCase()); + pst.setString(1, name.toLowerCase(Locale.ROOT)); pst.executeUpdate(); } } catch (SQLException ex) { @@ -428,7 +429,7 @@ public class PostgreSqlDataSource extends AbstractSqlDataSource { String sql = "UPDATE " + tableName + " SET " + col.TOTP_KEY + " = ? WHERE " + col.NAME + " = ?"; try (Connection con = getConnection(); PreparedStatement pst = con.prepareStatement(sql)) { pst.setString(1, totpKey); - pst.setString(2, user.toLowerCase()); + pst.setString(2, user.toLowerCase(Locale.ROOT)); pst.executeUpdate(); return true; } catch (SQLException e) { diff --git a/src/main/java/fr/xephi/authme/datasource/SQLite.java b/src/main/java/fr/xephi/authme/datasource/SQLite.java index 966508082..b261b5d54 100644 --- a/src/main/java/fr/xephi/authme/datasource/SQLite.java +++ b/src/main/java/fr/xephi/authme/datasource/SQLite.java @@ -20,6 +20,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; import java.util.List; +import java.util.Locale; import java.util.Set; import static fr.xephi.authme.datasource.SqlDataSourceUtils.getNullableLong; @@ -268,7 +269,7 @@ public class SQLite extends AbstractSqlDataSource { String delete = "DELETE FROM " + tableName + " WHERE " + col.NAME + "=?;"; try (PreparedStatement deletePst = con.prepareStatement(delete)) { for (String name : toPurge) { - deletePst.setString(1, name.toLowerCase()); + deletePst.setString(1, name.toLowerCase(Locale.ROOT)); deletePst.executeUpdate(); } } catch (SQLException ex) { @@ -280,7 +281,7 @@ public class SQLite extends AbstractSqlDataSource { public boolean removeAuth(String user) { String sql = "DELETE FROM " + tableName + " WHERE " + col.NAME + "=?;"; try (PreparedStatement pst = con.prepareStatement(sql)) { - pst.setString(1, user.toLowerCase()); + pst.setString(1, user.toLowerCase(Locale.ROOT)); pst.executeUpdate(); return true; } catch (SQLException ex) { @@ -355,7 +356,7 @@ public class SQLite extends AbstractSqlDataSource { String sql = "UPDATE " + tableName + " SET " + col.TOTP_KEY + " = ? WHERE " + col.NAME + " = ?"; try (PreparedStatement pst = con.prepareStatement(sql)) { pst.setString(1, totpKey); - pst.setString(2, user.toLowerCase()); + pst.setString(2, user.toLowerCase(Locale.ROOT)); pst.executeUpdate(); return true; } catch (SQLException e) { diff --git a/src/main/java/fr/xephi/authme/datasource/columnshandler/AuthMeColumnsHandler.java b/src/main/java/fr/xephi/authme/datasource/columnshandler/AuthMeColumnsHandler.java index f923bffeb..fc172dcf5 100644 --- a/src/main/java/fr/xephi/authme/datasource/columnshandler/AuthMeColumnsHandler.java +++ b/src/main/java/fr/xephi/authme/datasource/columnshandler/AuthMeColumnsHandler.java @@ -14,6 +14,7 @@ import fr.xephi.authme.settings.properties.DatabaseSettings; import java.sql.Connection; import java.sql.SQLException; import java.util.List; +import java.util.Locale; import static ch.jalu.datasourcecolumns.sqlimplementation.SqlColumnsHandlerConfig.forConnectionPool; import static ch.jalu.datasourcecolumns.sqlimplementation.SqlColumnsHandlerConfig.forSingleConnection; @@ -78,7 +79,7 @@ public final class AuthMeColumnsHandler { */ public boolean update(String name, DataSourceColumn column, T value) { try { - return internalHandler.update(name.toLowerCase(), column, value); + return internalHandler.update(name.toLowerCase(Locale.ROOT), column, value); } catch (SQLException e) { logSqlException(e); return false; @@ -110,7 +111,7 @@ public final class AuthMeColumnsHandler { */ public boolean update(String name, UpdateValues updateValues) { try { - return internalHandler.update(name.toLowerCase(), updateValues); + return internalHandler.update(name.toLowerCase(Locale.ROOT), updateValues); } catch (SQLException e) { logSqlException(e); return false; @@ -145,7 +146,7 @@ public final class AuthMeColumnsHandler { * @throws SQLException . */ public DataSourceValue retrieve(String name, DataSourceColumn column) throws SQLException { - return internalHandler.retrieve(name.toLowerCase(), column); + return internalHandler.retrieve(name.toLowerCase(Locale.ROOT), column); } /** @@ -157,7 +158,7 @@ public final class AuthMeColumnsHandler { * @throws SQLException . */ public DataSourceValues retrieve(String name, DataSourceColumn... columns) throws SQLException { - return internalHandler.retrieve(name.toLowerCase(), columns); + return internalHandler.retrieve(name.toLowerCase(Locale.ROOT), columns); } /** diff --git a/src/main/java/fr/xephi/authme/datasource/converter/CrazyLoginConverter.java b/src/main/java/fr/xephi/authme/datasource/converter/CrazyLoginConverter.java index b1c9613e2..a91972239 100644 --- a/src/main/java/fr/xephi/authme/datasource/converter/CrazyLoginConverter.java +++ b/src/main/java/fr/xephi/authme/datasource/converter/CrazyLoginConverter.java @@ -14,6 +14,7 @@ import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; +import java.util.Locale; /** * Converter for CrazyLogin to AuthMe. @@ -70,7 +71,7 @@ public class CrazyLoginConverter implements Converter { String password = args[1]; if (password != null) { PlayerAuth auth = PlayerAuth.builder() - .name(playerName.toLowerCase()) + .name(playerName.toLowerCase(Locale.ROOT)) .realName(playerName) .password(password, null) .build(); diff --git a/src/main/java/fr/xephi/authme/datasource/converter/RoyalAuthConverter.java b/src/main/java/fr/xephi/authme/datasource/converter/RoyalAuthConverter.java index 7c45aebfa..ebb9080e0 100644 --- a/src/main/java/fr/xephi/authme/datasource/converter/RoyalAuthConverter.java +++ b/src/main/java/fr/xephi/authme/datasource/converter/RoyalAuthConverter.java @@ -12,6 +12,7 @@ import org.bukkit.configuration.file.YamlConfiguration; import javax.inject.Inject; import java.io.File; +import java.util.Locale; import static fr.xephi.authme.util.FileUtils.makePath; @@ -35,7 +36,7 @@ public class RoyalAuthConverter implements Converter { public void execute(CommandSender sender) { for (OfflinePlayer player : plugin.getServer().getOfflinePlayers()) { try { - String name = player.getName().toLowerCase(); + String name = player.getName().toLowerCase(Locale.ROOT); File file = new File(makePath(".", "plugins", "RoyalAuth", "userdata", name + ".yml")); if (dataSource.isAuthAvailable(name) || !file.exists()) { diff --git a/src/main/java/fr/xephi/authme/datasource/converter/VAuthConverter.java b/src/main/java/fr/xephi/authme/datasource/converter/VAuthConverter.java index e9c706077..95af90117 100644 --- a/src/main/java/fr/xephi/authme/datasource/converter/VAuthConverter.java +++ b/src/main/java/fr/xephi/authme/datasource/converter/VAuthConverter.java @@ -12,6 +12,7 @@ import org.bukkit.command.CommandSender; import javax.inject.Inject; import java.io.File; import java.io.IOException; +import java.util.Locale; import java.util.Scanner; import java.util.UUID; @@ -48,12 +49,12 @@ public class VAuthConverter implements Converter { continue; } auth = PlayerAuth.builder() - .name(pname.toLowerCase()) + .name(pname.toLowerCase(Locale.ROOT)) .realName(pname) .password(password, null).build(); } else { auth = PlayerAuth.builder() - .name(name.toLowerCase()) + .name(name.toLowerCase(Locale.ROOT)) .realName(name) .password(password, null).build(); } diff --git a/src/main/java/fr/xephi/authme/datasource/converter/XAuthConverter.java b/src/main/java/fr/xephi/authme/datasource/converter/XAuthConverter.java index 928566583..0f04310cb 100644 --- a/src/main/java/fr/xephi/authme/datasource/converter/XAuthConverter.java +++ b/src/main/java/fr/xephi/authme/datasource/converter/XAuthConverter.java @@ -18,6 +18,7 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; +import java.util.Locale; import static fr.xephi.authme.util.FileUtils.makePath; @@ -66,7 +67,7 @@ public class XAuthConverter implements Converter { String psw = getPassword(id); if (psw != null && !psw.isEmpty() && pl != null) { PlayerAuth auth = PlayerAuth.builder() - .name(pl.toLowerCase()) + .name(pl.toLowerCase(Locale.ROOT)) .realName(pl) .password(psw, null).build(); database.saveAuth(auth); @@ -89,7 +90,7 @@ public class XAuthConverter implements Converter { if (!rs.next()) { return null; } - realPass = rs.getString("playername").toLowerCase(); + realPass = rs.getString("playername").toLowerCase(Locale.ROOT); } catch (SQLException e) { xAuthLog.severe("Failed to retrieve name for account: " + id, e); return null; diff --git a/src/main/java/fr/xephi/authme/initialization/OnShutdownPlayerSaver.java b/src/main/java/fr/xephi/authme/initialization/OnShutdownPlayerSaver.java index 742318e4c..261e7dd59 100644 --- a/src/main/java/fr/xephi/authme/initialization/OnShutdownPlayerSaver.java +++ b/src/main/java/fr/xephi/authme/initialization/OnShutdownPlayerSaver.java @@ -14,6 +14,7 @@ import org.bukkit.Location; import org.bukkit.entity.Player; import javax.inject.Inject; +import java.util.Locale; /** * Saves all players' data when the plugin shuts down. @@ -48,7 +49,7 @@ public class OnShutdownPlayerSaver { } private void savePlayer(Player player) { - String name = player.getName().toLowerCase(); + String name = player.getName().toLowerCase(Locale.ROOT); if (PlayerUtils.isNpc(player) || validationService.isUnrestricted(name)) { return; } @@ -64,7 +65,7 @@ public class OnShutdownPlayerSaver { if (settings.getProperty(RestrictionSettings.SAVE_QUIT_LOCATION)) { Location loc = spawnLoader.getPlayerLocationOrSpawn(player); PlayerAuth auth = PlayerAuth.builder() - .name(player.getName().toLowerCase()) + .name(player.getName().toLowerCase(Locale.ROOT)) .realName(player.getName()) .location(loc).build(); dataSource.updateQuitLoc(auth); diff --git a/src/main/java/fr/xephi/authme/listener/OnJoinVerifier.java b/src/main/java/fr/xephi/authme/listener/OnJoinVerifier.java index ce61b8f2b..9ceccbaf7 100644 --- a/src/main/java/fr/xephi/authme/listener/OnJoinVerifier.java +++ b/src/main/java/fr/xephi/authme/listener/OnJoinVerifier.java @@ -25,6 +25,7 @@ import org.bukkit.event.player.PlayerLoginEvent; import javax.annotation.PostConstruct; import javax.inject.Inject; import java.util.Collection; +import java.util.Locale; import java.util.regex.Pattern; /** @@ -160,7 +161,7 @@ public class OnJoinVerifier implements Reloadable { String realName = auth.getRealName(); // might be null or "Player" if (StringUtils.isEmpty(realName) || "Player".equals(realName)) { - dataSource.updateRealName(connectingName.toLowerCase(), connectingName); + dataSource.updateRealName(connectingName.toLowerCase(Locale.ROOT), connectingName); } else if (!realName.equals(connectingName)) { throw new FailedVerificationException(MessageKey.INVALID_NAME_CASE, realName, connectingName); } diff --git a/src/main/java/fr/xephi/authme/listener/PlayerListener.java b/src/main/java/fr/xephi/authme/listener/PlayerListener.java index 727f45a76..53ea908f0 100644 --- a/src/main/java/fr/xephi/authme/listener/PlayerListener.java +++ b/src/main/java/fr/xephi/authme/listener/PlayerListener.java @@ -52,6 +52,7 @@ import org.bukkit.event.player.PlayerShearEntityEvent; import org.bukkit.inventory.InventoryView; import javax.inject.Inject; +import java.util.Locale; import java.util.Set; import static fr.xephi.authme.settings.properties.RestrictionSettings.ALLOWED_MOVEMENT_RADIUS; @@ -214,7 +215,7 @@ public class PlayerListener implements Listener { return; } - String name = player.getName().toLowerCase(); + String name = player.getName().toLowerCase(Locale.ROOT); String joinMsg = event.getJoinMessage(); // Remove the join message while the player isn't logging in @@ -292,7 +293,7 @@ public class PlayerListener implements Listener { @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) { - String cmd = event.getMessage().split(" ")[0].toLowerCase(); + String cmd = event.getMessage().split(" ")[0].toLowerCase(Locale.ROOT); if (settings.getProperty(HooksSettings.USE_ESSENTIALS_MOTD) && "/motd".equals(cmd)) { return; } @@ -482,7 +483,7 @@ public class PlayerListener implements Listener { return false; } Set whitelist = settings.getProperty(RestrictionSettings.UNRESTRICTED_INVENTORIES); - return whitelist.contains(ChatColor.stripColor(inventory.getTitle()).toLowerCase()); + return whitelist.contains(ChatColor.stripColor(inventory.getTitle()).toLowerCase(Locale.ROOT)); } @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) diff --git a/src/main/java/fr/xephi/authme/output/LogFilterHelper.java b/src/main/java/fr/xephi/authme/output/LogFilterHelper.java index fa43a01c8..6058584ae 100644 --- a/src/main/java/fr/xephi/authme/output/LogFilterHelper.java +++ b/src/main/java/fr/xephi/authme/output/LogFilterHelper.java @@ -6,6 +6,7 @@ import fr.xephi.authme.util.StringUtils; import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.Locale; /** * Service class for the log filters. @@ -35,7 +36,7 @@ final class LogFilterHelper { if (message == null) { return false; } - String lowerMessage = message.toLowerCase(); + String lowerMessage = message.toLowerCase(Locale.ROOT); return lowerMessage.contains(ISSUED_COMMAND_TEXT) && StringUtils.containsAny(lowerMessage, COMMANDS_TO_SKIP); } diff --git a/src/main/java/fr/xephi/authme/process/changepassword/AsyncChangePassword.java b/src/main/java/fr/xephi/authme/process/changepassword/AsyncChangePassword.java index 9ae2934a1..62bd4ea08 100644 --- a/src/main/java/fr/xephi/authme/process/changepassword/AsyncChangePassword.java +++ b/src/main/java/fr/xephi/authme/process/changepassword/AsyncChangePassword.java @@ -14,6 +14,7 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import javax.inject.Inject; +import java.util.Locale; public class AsyncChangePassword implements AsynchronousProcess { @@ -42,7 +43,7 @@ public class AsyncChangePassword implements AsynchronousProcess { * @param newPassword the new password chosen by the player */ public void changePassword(Player player, String oldPassword, String newPassword) { - String name = player.getName().toLowerCase(); + String name = player.getName().toLowerCase(Locale.ROOT); PlayerAuth auth = playerCache.getAuth(name); if (passwordSecurity.comparePassword(oldPassword, auth.getPassword(), player.getName())) { HashedPassword hashedPassword = passwordSecurity.computeHash(newPassword, name); @@ -71,7 +72,7 @@ public class AsyncChangePassword implements AsynchronousProcess { * @param newPassword the new password chosen for the player */ public void changePasswordAsAdmin(CommandSender sender, String playerName, String newPassword) { - String lowerCaseName = playerName.toLowerCase(); + String lowerCaseName = playerName.toLowerCase(Locale.ROOT); if (!(playerCache.isAuthenticated(lowerCaseName) || dataSource.isAuthAvailable(lowerCaseName))) { if (sender == null) { logger.warning("Tried to change password for user " + lowerCaseName + " but it doesn't exist!"); diff --git a/src/main/java/fr/xephi/authme/process/email/AsyncAddEmail.java b/src/main/java/fr/xephi/authme/process/email/AsyncAddEmail.java index 9041e01a5..f1c3030a3 100644 --- a/src/main/java/fr/xephi/authme/process/email/AsyncAddEmail.java +++ b/src/main/java/fr/xephi/authme/process/email/AsyncAddEmail.java @@ -15,6 +15,7 @@ import fr.xephi.authme.util.Utils; import org.bukkit.entity.Player; import javax.inject.Inject; +import java.util.Locale; /** * Async task to add an email to an account. @@ -48,7 +49,7 @@ public class AsyncAddEmail implements AsynchronousProcess { * @param email the email to add */ public void addEmail(Player player, String email) { - String playerName = player.getName().toLowerCase(); + String playerName = player.getName().toLowerCase(Locale.ROOT); if (playerCache.isAuthenticated(playerName)) { PlayerAuth auth = playerCache.getAuth(playerName); diff --git a/src/main/java/fr/xephi/authme/process/email/AsyncChangeEmail.java b/src/main/java/fr/xephi/authme/process/email/AsyncChangeEmail.java index ccbe5ba1f..61cba0fbe 100644 --- a/src/main/java/fr/xephi/authme/process/email/AsyncChangeEmail.java +++ b/src/main/java/fr/xephi/authme/process/email/AsyncChangeEmail.java @@ -14,6 +14,7 @@ import fr.xephi.authme.service.ValidationService; import org.bukkit.entity.Player; import javax.inject.Inject; +import java.util.Locale; /** * Async task for changing the email. @@ -48,7 +49,7 @@ public class AsyncChangeEmail implements AsynchronousProcess { * @param newEmail provided new email */ public void changeEmail(Player player, String oldEmail, String newEmail) { - String playerName = player.getName().toLowerCase(); + String playerName = player.getName().toLowerCase(Locale.ROOT); if (playerCache.isAuthenticated(playerName)) { PlayerAuth auth = playerCache.getAuth(playerName); String currentEmail = auth.getEmail(); 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 725faa83c..d5cf1cef5 100644 --- a/src/main/java/fr/xephi/authme/process/join/AsynchronousJoin.java +++ b/src/main/java/fr/xephi/authme/process/join/AsynchronousJoin.java @@ -32,6 +32,8 @@ import org.bukkit.potion.PotionEffectType; import javax.inject.Inject; +import java.util.Locale; + import static fr.xephi.authme.service.BukkitService.TICKS_PER_SECOND; import static fr.xephi.authme.settings.properties.RestrictionSettings.PROTECT_INVENTORY_BEFORE_LOGIN; @@ -90,7 +92,7 @@ public class AsynchronousJoin implements AsynchronousProcess { * @param player the player to process */ public void processJoin(Player player) { - String name = player.getName().toLowerCase(); + String name = player.getName().toLowerCase(Locale.ROOT); String ip = PlayerUtils.getPlayerIp(player); if (!validationService.fulfillsNameRestrictions(player)) { diff --git a/src/main/java/fr/xephi/authme/process/login/AsynchronousLogin.java b/src/main/java/fr/xephi/authme/process/login/AsynchronousLogin.java index 4b86a5673..5ce23d8b4 100644 --- a/src/main/java/fr/xephi/authme/process/login/AsynchronousLogin.java +++ b/src/main/java/fr/xephi/authme/process/login/AsynchronousLogin.java @@ -40,6 +40,7 @@ import org.bukkit.entity.Player; import javax.inject.Inject; import java.util.ArrayList; import java.util.List; +import java.util.Locale; /** * Asynchronous task for a player login. @@ -153,7 +154,7 @@ public class AsynchronousLogin implements AsynchronousProcess { * (e.g. because he is already logged in) */ private PlayerAuth getPlayerAuth(Player player, boolean quiet) { - String name = player.getName().toLowerCase(); + String name = player.getName().toLowerCase(Locale.ROOT); if (playerCache.isAuthenticated(name)) { if (!quiet) { service.send(player, MessageKey.ALREADY_LOGGED_IN_ERROR); @@ -206,7 +207,7 @@ public class AsynchronousLogin implements AsynchronousProcess { * false otherwise */ private boolean checkPlayerInfo(Player player, PlayerAuth auth, String password) { - String name = player.getName().toLowerCase(); + String name = player.getName().toLowerCase(Locale.ROOT); // If captcha is required send a message to the player and deny to log in if (loginCaptchaManager.isCaptchaRequired(name)) { @@ -380,7 +381,7 @@ public class AsynchronousLogin implements AsynchronousProcess { for (Player onlinePlayer : bukkitService.getOnlinePlayers()) { if (ip.equalsIgnoreCase(PlayerUtils.getPlayerIp(onlinePlayer)) && !onlinePlayer.getName().equals(name) - && dataSource.isLogged(onlinePlayer.getName().toLowerCase())) { + && dataSource.isLogged(onlinePlayer.getName().toLowerCase(Locale.ROOT))) { ++count; } } diff --git a/src/main/java/fr/xephi/authme/process/login/ProcessSyncPlayerLogin.java b/src/main/java/fr/xephi/authme/process/login/ProcessSyncPlayerLogin.java index 8501e85cb..74946039a 100644 --- a/src/main/java/fr/xephi/authme/process/login/ProcessSyncPlayerLogin.java +++ b/src/main/java/fr/xephi/authme/process/login/ProcessSyncPlayerLogin.java @@ -22,6 +22,7 @@ import org.bukkit.potion.PotionEffectType; import javax.inject.Inject; import java.util.List; +import java.util.Locale; import static fr.xephi.authme.settings.properties.RestrictionSettings.PROTECT_INVENTORY_BEFORE_LOGIN; @@ -76,7 +77,7 @@ public class ProcessSyncPlayerLogin implements SynchronousProcess { * @param authsWithSameIp registered names with the same IP address as the player's */ public void processPlayerLogin(Player player, boolean isFirstLogin, List authsWithSameIp) { - final String name = player.getName().toLowerCase(); + final String name = player.getName().toLowerCase(Locale.ROOT); final LimboPlayer limbo = limboService.getLimboPlayer(name); // Limbo contains the State of the Player before /login diff --git a/src/main/java/fr/xephi/authme/process/logout/AsynchronousLogout.java b/src/main/java/fr/xephi/authme/process/logout/AsynchronousLogout.java index 3628669b8..2e5bd87c0 100644 --- a/src/main/java/fr/xephi/authme/process/logout/AsynchronousLogout.java +++ b/src/main/java/fr/xephi/authme/process/logout/AsynchronousLogout.java @@ -15,6 +15,7 @@ import fr.xephi.authme.settings.properties.RestrictionSettings; import org.bukkit.entity.Player; import javax.inject.Inject; +import java.util.Locale; /** * Async task when a player wants to log out. @@ -51,7 +52,7 @@ public class AsynchronousLogout implements AsynchronousProcess { * @param player the player wanting to log out */ public void logout(Player player) { - String name = player.getName().toLowerCase(); + String name = player.getName().toLowerCase(Locale.ROOT); if (!playerCache.isAuthenticated(name)) { service.send(player, MessageKey.NOT_LOGGED_IN); return; diff --git a/src/main/java/fr/xephi/authme/process/quit/AsynchronousQuit.java b/src/main/java/fr/xephi/authme/process/quit/AsynchronousQuit.java index e2ad6d432..f4b1d3250 100644 --- a/src/main/java/fr/xephi/authme/process/quit/AsynchronousQuit.java +++ b/src/main/java/fr/xephi/authme/process/quit/AsynchronousQuit.java @@ -18,6 +18,7 @@ import org.bukkit.Location; import org.bukkit.entity.Player; import javax.inject.Inject; +import java.util.Locale; /** * Async process called when a player quits the server. @@ -63,7 +64,7 @@ public class AsynchronousQuit implements AsynchronousProcess { if (player == null || validationService.isUnrestricted(player.getName())) { return; } - String name = player.getName().toLowerCase(); + String name = player.getName().toLowerCase(Locale.ROOT); boolean wasLoggedIn = playerCache.isAuthenticated(name); if (wasLoggedIn) { diff --git a/src/main/java/fr/xephi/authme/process/register/AsyncRegister.java b/src/main/java/fr/xephi/authme/process/register/AsyncRegister.java index 979d6db7d..f5fe3be65 100644 --- a/src/main/java/fr/xephi/authme/process/register/AsyncRegister.java +++ b/src/main/java/fr/xephi/authme/process/register/AsyncRegister.java @@ -20,6 +20,7 @@ import org.bukkit.entity.Player; import javax.inject.Inject; import java.util.List; +import java.util.Locale; import static fr.xephi.authme.permission.PlayerStatePermission.ALLOW_MULTIPLE_ACCOUNTS; @@ -67,7 +68,7 @@ public class AsyncRegister implements AsynchronousProcess { * @return true if the checks are successful and the event hasn't marked the action as denied, false otherwise. */ private boolean preRegisterCheck(RegistrationMethod variant, Player player) { - String name = player.getName().toLowerCase(); + String name = player.getName().toLowerCase(Locale.ROOT); if (playerCache.isAuthenticated(name)) { service.send(player, MessageKey.ALREADY_LOGGED_IN_ERROR); return false; diff --git a/src/main/java/fr/xephi/authme/process/register/executors/PlayerAuthBuilderHelper.java b/src/main/java/fr/xephi/authme/process/register/executors/PlayerAuthBuilderHelper.java index a9717fdce..9b29dac2f 100644 --- a/src/main/java/fr/xephi/authme/process/register/executors/PlayerAuthBuilderHelper.java +++ b/src/main/java/fr/xephi/authme/process/register/executors/PlayerAuthBuilderHelper.java @@ -5,6 +5,8 @@ import fr.xephi.authme.security.crypts.HashedPassword; import fr.xephi.authme.util.PlayerUtils; import org.bukkit.entity.Player; +import java.util.Locale; + /** * Helper for constructing PlayerAuth objects. */ @@ -23,7 +25,7 @@ final class PlayerAuthBuilderHelper { */ static PlayerAuth createPlayerAuth(Player player, HashedPassword hashedPassword, String email) { return PlayerAuth.builder() - .name(player.getName().toLowerCase()) + .name(player.getName().toLowerCase(Locale.ROOT)) .realName(player.getName()) .password(hashedPassword) .email(email) diff --git a/src/main/java/fr/xephi/authme/security/PasswordSecurity.java b/src/main/java/fr/xephi/authme/security/PasswordSecurity.java index d6cb6e71c..012fd3e51 100644 --- a/src/main/java/fr/xephi/authme/security/PasswordSecurity.java +++ b/src/main/java/fr/xephi/authme/security/PasswordSecurity.java @@ -13,6 +13,7 @@ import org.bukkit.plugin.PluginManager; import javax.annotation.PostConstruct; import javax.inject.Inject; import java.util.Collection; +import java.util.Locale; /** * Manager class for password-related operations. @@ -54,7 +55,7 @@ public class PasswordSecurity implements Reloadable { * @return The password hash */ public HashedPassword computeHash(String password, String playerName) { - String playerLowerCase = playerName.toLowerCase(); + String playerLowerCase = playerName.toLowerCase(Locale.ROOT); return encryptionMethod.computeHash(password, playerLowerCase); } @@ -81,7 +82,7 @@ public class PasswordSecurity implements Reloadable { * @return True if the password matches, false otherwise */ public boolean comparePassword(String password, HashedPassword hashedPassword, String playerName) { - String playerLowerCase = playerName.toLowerCase(); + String playerLowerCase = playerName.toLowerCase(Locale.ROOT); return methodMatches(encryptionMethod, password, hashedPassword, playerLowerCase) || compareWithLegacyHashes(password, hashedPassword, playerLowerCase); } diff --git a/src/main/java/fr/xephi/authme/security/crypts/Smf.java b/src/main/java/fr/xephi/authme/security/crypts/Smf.java index e24c1b83d..19193d633 100644 --- a/src/main/java/fr/xephi/authme/security/crypts/Smf.java +++ b/src/main/java/fr/xephi/authme/security/crypts/Smf.java @@ -7,6 +7,8 @@ import fr.xephi.authme.security.crypts.description.SaltType; import fr.xephi.authme.security.crypts.description.Usage; import fr.xephi.authme.util.RandomStringUtils; +import java.util.Locale; + import static fr.xephi.authme.security.HashUtils.isEqual; /** @@ -29,7 +31,7 @@ public class Smf implements EncryptionMethod { @Override public String computeHash(String password, String salt, String name) { - return HashUtils.sha1(name.toLowerCase() + password); + return HashUtils.sha1(name.toLowerCase(Locale.ROOT) + password); } @Override diff --git a/src/main/java/fr/xephi/authme/security/crypts/XAuth.java b/src/main/java/fr/xephi/authme/security/crypts/XAuth.java index 62f2e0d71..3cd4ceab0 100644 --- a/src/main/java/fr/xephi/authme/security/crypts/XAuth.java +++ b/src/main/java/fr/xephi/authme/security/crypts/XAuth.java @@ -3,6 +3,8 @@ package fr.xephi.authme.security.crypts; import fr.xephi.authme.security.crypts.description.Recommendation; import fr.xephi.authme.security.crypts.description.Usage; +import java.util.Locale; + import static fr.xephi.authme.security.HashUtils.isEqual; @Recommendation(Usage.RECOMMENDED) @@ -19,7 +21,7 @@ public class XAuth extends HexSaltedMethod { @Override public String computeHash(String password, String salt, String name) { - String hash = getWhirlpool(salt + password).toLowerCase(); + String hash = getWhirlpool(salt + password).toLowerCase(Locale.ROOT); int saltPos = password.length() >= hash.length() ? hash.length() - 1 : password.length(); return hash.substring(0, saltPos) + salt + hash.substring(saltPos); } diff --git a/src/main/java/fr/xephi/authme/security/totp/GenerateTotpService.java b/src/main/java/fr/xephi/authme/security/totp/GenerateTotpService.java index 3d00f78a0..8c689dde0 100644 --- a/src/main/java/fr/xephi/authme/security/totp/GenerateTotpService.java +++ b/src/main/java/fr/xephi/authme/security/totp/GenerateTotpService.java @@ -6,6 +6,7 @@ import fr.xephi.authme.util.expiring.ExpiringMap; import org.bukkit.entity.Player; import javax.inject.Inject; +import java.util.Locale; import java.util.concurrent.TimeUnit; /** @@ -32,7 +33,7 @@ public class GenerateTotpService implements HasCleanup { */ public TotpGenerationResult generateTotpKey(Player player) { TotpGenerationResult credentials = totpAuthenticator.generateTotpKey(player); - totpKeys.put(player.getName().toLowerCase(), credentials); + totpKeys.put(player.getName().toLowerCase(Locale.ROOT), credentials); return credentials; } @@ -43,11 +44,11 @@ public class GenerateTotpService implements HasCleanup { * @return TOTP generation result */ public TotpGenerationResult getGeneratedTotpKey(Player player) { - return totpKeys.get(player.getName().toLowerCase()); + return totpKeys.get(player.getName().toLowerCase(Locale.ROOT)); } public void removeGenerateTotpKey(Player player) { - totpKeys.remove(player.getName().toLowerCase()); + totpKeys.remove(player.getName().toLowerCase(Locale.ROOT)); } /** @@ -58,7 +59,7 @@ public class GenerateTotpService implements HasCleanup { * @return true if the input code is correct, false if the code is invalid or no unexpired totp key is available */ public boolean isTotpCodeCorrectForGeneratedTotpKey(Player player, String totpCode) { - TotpGenerationResult totpDetails = totpKeys.get(player.getName().toLowerCase()); + TotpGenerationResult totpDetails = totpKeys.get(player.getName().toLowerCase(Locale.ROOT)); return totpDetails != null && totpAuthenticator.checkCode(player.getName(), totpDetails.getTotpKey(), totpCode); } diff --git a/src/main/java/fr/xephi/authme/security/totp/TotpAuthenticator.java b/src/main/java/fr/xephi/authme/security/totp/TotpAuthenticator.java index e26b136f4..950a6ff75 100644 --- a/src/main/java/fr/xephi/authme/security/totp/TotpAuthenticator.java +++ b/src/main/java/fr/xephi/authme/security/totp/TotpAuthenticator.java @@ -15,6 +15,8 @@ import org.bukkit.entity.Player; import javax.inject.Inject; +import java.util.Locale; + import static fr.xephi.authme.util.Utils.MILLIS_PER_MINUTE; /** @@ -54,7 +56,7 @@ public class TotpAuthenticator implements HasCleanup { * @return true if code is valid, false otherwise */ public boolean checkCode(String playerName, String totpKey, String inputCode) { - String nameLower = playerName.toLowerCase(); + String nameLower = playerName.toLowerCase(Locale.ROOT); Integer totpCode = Ints.tryParse(inputCode); if (totpCode != null && !usedCodes.contains(nameLower, totpCode) && authenticator.authorize(totpKey, totpCode)) { diff --git a/src/main/java/fr/xephi/authme/service/AntiBotService.java b/src/main/java/fr/xephi/authme/service/AntiBotService.java index fbc19e8ba..c5fb136d7 100644 --- a/src/main/java/fr/xephi/authme/service/AntiBotService.java +++ b/src/main/java/fr/xephi/authme/service/AntiBotService.java @@ -11,6 +11,7 @@ import fr.xephi.authme.util.AtomicIntervalCounter; import org.bukkit.scheduler.BukkitTask; import javax.inject.Inject; +import java.util.Locale; import java.util.concurrent.CopyOnWriteArrayList; import static fr.xephi.authme.service.BukkitService.TICKS_PER_MINUTE; @@ -176,7 +177,7 @@ public class AntiBotService implements SettingsDependent { * @return true if the given name has been kicked because of Antibot */ public boolean wasPlayerKicked(String name) { - return antibotKicked.contains(name.toLowerCase()); + return antibotKicked.contains(name.toLowerCase(Locale.ROOT)); } /** @@ -186,7 +187,7 @@ public class AntiBotService implements SettingsDependent { * @param name the name to add */ public void addPlayerKick(String name) { - antibotKicked.addIfAbsent(name.toLowerCase()); + antibotKicked.addIfAbsent(name.toLowerCase(Locale.ROOT)); } public enum AntiBotStatus { diff --git a/src/main/java/fr/xephi/authme/service/BackupService.java b/src/main/java/fr/xephi/authme/service/BackupService.java index 2e72a7b0c..291581b3a 100644 --- a/src/main/java/fr/xephi/authme/service/BackupService.java +++ b/src/main/java/fr/xephi/authme/service/BackupService.java @@ -18,6 +18,7 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.util.Locale; import static fr.xephi.authme.util.Utils.logAndSendMessage; import static fr.xephi.authme.util.Utils.logAndSendWarning; @@ -151,7 +152,7 @@ public class BackupService { * @return True if the path is correct, false if it is incorrect or the OS is not Windows */ private boolean useWindowsCommand(String windowsPath) { - String isWin = System.getProperty("os.name").toLowerCase(); + String isWin = System.getProperty("os.name").toLowerCase(Locale.ROOT); if (isWin.contains("win")) { if (new File(windowsPath + "\\bin\\mysqldump.exe").exists()) { return true; diff --git a/src/main/java/fr/xephi/authme/service/PasswordRecoveryService.java b/src/main/java/fr/xephi/authme/service/PasswordRecoveryService.java index 20a78d7f4..78c5ee62d 100644 --- a/src/main/java/fr/xephi/authme/service/PasswordRecoveryService.java +++ b/src/main/java/fr/xephi/authme/service/PasswordRecoveryService.java @@ -20,6 +20,7 @@ import org.bukkit.entity.Player; import javax.annotation.PostConstruct; import javax.inject.Inject; +import java.util.Locale; import java.util.concurrent.TimeUnit; import static fr.xephi.authme.settings.properties.EmailSettings.RECOVERY_PASSWORD_LENGTH; @@ -76,7 +77,7 @@ public class PasswordRecoveryService implements Reloadable, HasCleanup { boolean couldSendMail = emailService.sendRecoveryCode(player.getName(), email, recoveryCode); if (couldSendMail) { commonService.send(player, MessageKey.RECOVERY_CODE_SENT); - emailCooldown.add(player.getName().toLowerCase()); + emailCooldown.add(player.getName().toLowerCase(Locale.ROOT)); } else { commonService.send(player, MessageKey.EMAIL_SEND_FAILURE); } @@ -104,7 +105,7 @@ public class PasswordRecoveryService implements Reloadable, HasCleanup { boolean couldSendMail = emailService.sendPasswordMail(name, email, thePass); if (couldSendMail) { commonService.send(player, MessageKey.RECOVERY_EMAIL_SENT_MESSAGE); - emailCooldown.add(player.getName().toLowerCase()); + emailCooldown.add(player.getName().toLowerCase(Locale.ROOT)); } else { commonService.send(player, MessageKey.EMAIL_SEND_FAILURE); } @@ -141,7 +142,7 @@ public class PasswordRecoveryService implements Reloadable, HasCleanup { * @return True if the player is not on cooldown. */ private boolean checkEmailCooldown(Player player) { - Duration waitDuration = emailCooldown.getExpiration(player.getName().toLowerCase()); + Duration waitDuration = emailCooldown.getExpiration(player.getName().toLowerCase(Locale.ROOT)); if (waitDuration.getDuration() > 0) { String durationText = messages.formatDuration(waitDuration); messages.send(player, MessageKey.EMAIL_COOLDOWN_ERROR, durationText); diff --git a/src/main/java/fr/xephi/authme/service/ValidationService.java b/src/main/java/fr/xephi/authme/service/ValidationService.java index 183a3b4a6..536d2111e 100644 --- a/src/main/java/fr/xephi/authme/service/ValidationService.java +++ b/src/main/java/fr/xephi/authme/service/ValidationService.java @@ -25,6 +25,7 @@ import javax.annotation.PostConstruct; import javax.inject.Inject; import java.util.Collection; import java.util.List; +import java.util.Locale; import java.util.Set; import java.util.regex.Pattern; @@ -69,7 +70,7 @@ public class ValidationService implements Reloadable { * @return the validation result */ public ValidationResult validatePassword(String password, String username) { - String passLow = password.toLowerCase(); + String passLow = password.toLowerCase(Locale.ROOT); if (!passwordRegex.matcher(passLow).matches()) { return new ValidationResult(MessageKey.PASSWORD_CHARACTERS_ERROR, passwordRegex.pattern()); } else if (passLow.equalsIgnoreCase(username)) { @@ -139,7 +140,7 @@ public class ValidationService implements Reloadable { * @return true if unrestricted, false otherwise */ public boolean isUnrestricted(String name) { - return settings.getProperty(RestrictionSettings.UNRESTRICTED_NAMES).contains(name.toLowerCase()); + return settings.getProperty(RestrictionSettings.UNRESTRICTED_NAMES).contains(name.toLowerCase(Locale.ROOT)); } /** @@ -149,7 +150,7 @@ public class ValidationService implements Reloadable { * @return true if the player may join, false if the player does not satisfy the name restrictions */ public boolean fulfillsNameRestrictions(Player player) { - Collection restrictions = restrictedNames.get(player.getName().toLowerCase()); + Collection restrictions = restrictedNames.get(player.getName().toLowerCase(Locale.ROOT)); if (Utils.isCollectionEmpty(restrictions)) { return true; } @@ -212,7 +213,7 @@ public class ValidationService implements Reloadable { for (String restriction : configuredRestrictions) { if (isInsideString(';', restriction)) { String[] data = restriction.split(";"); - restrictions.put(data[0].toLowerCase(), data[1]); + restrictions.put(data[0].toLowerCase(Locale.ROOT), data[1]); } else { logger.warning("Restricted user rule must have a ';' separating name from restriction," + " but found: '" + restriction + "'"); diff --git a/src/main/java/fr/xephi/authme/service/bungeecord/BungeeSender.java b/src/main/java/fr/xephi/authme/service/bungeecord/BungeeSender.java index d4a9f7ef1..3d43605bb 100644 --- a/src/main/java/fr/xephi/authme/service/bungeecord/BungeeSender.java +++ b/src/main/java/fr/xephi/authme/service/bungeecord/BungeeSender.java @@ -13,6 +13,7 @@ import org.bukkit.entity.Player; import org.bukkit.plugin.messaging.Messenger; import javax.inject.Inject; +import java.util.Locale; public class BungeeSender implements SettingsDependent { @@ -103,9 +104,9 @@ public class BungeeSender implements SettingsDependent { return; } if (type.isBroadcast()) { - sendForwardedBungeecordMessage(player, "AuthMe.v2.Broadcast", type.getId(), player.getName().toLowerCase()); + sendForwardedBungeecordMessage(player, "AuthMe.v2.Broadcast", type.getId(), player.getName().toLowerCase(Locale.ROOT)); } else { - sendBungeecordMessage(player, "AuthMe.v2", type.getId(), player.getName().toLowerCase()); + sendBungeecordMessage(player, "AuthMe.v2", type.getId(), player.getName().toLowerCase(Locale.ROOT)); } } diff --git a/src/main/java/fr/xephi/authme/settings/SpawnLoader.java b/src/main/java/fr/xephi/authme/settings/SpawnLoader.java index 2103f9bd1..6a8b7fa72 100644 --- a/src/main/java/fr/xephi/authme/settings/SpawnLoader.java +++ b/src/main/java/fr/xephi/authme/settings/SpawnLoader.java @@ -19,6 +19,7 @@ import org.bukkit.entity.Player; import javax.inject.Inject; import java.io.File; import java.io.IOException; +import java.util.Locale; /** * Manager for spawn points. It loads spawn definitions from AuthMe and third-party plugins @@ -177,7 +178,7 @@ public class SpawnLoader implements Reloadable { World world = player.getWorld(); Location spawnLoc = null; for (String priority : spawnPriority) { - switch (priority.toLowerCase().trim()) { + switch (priority.toLowerCase(Locale.ROOT).trim()) { case "default": if (world.getSpawnLocation() != null) { if (!isValidSpawnPoint(world.getSpawnLocation())) { diff --git a/src/main/java/fr/xephi/authme/task/purge/PurgeExecutor.java b/src/main/java/fr/xephi/authme/task/purge/PurgeExecutor.java index 399ff3985..ea0096042 100644 --- a/src/main/java/fr/xephi/authme/task/purge/PurgeExecutor.java +++ b/src/main/java/fr/xephi/authme/task/purge/PurgeExecutor.java @@ -15,6 +15,7 @@ import org.bukkit.Server; import javax.inject.Inject; import java.io.File; import java.util.Collection; +import java.util.Locale; import static fr.xephi.authme.util.FileUtils.makePath; @@ -80,7 +81,7 @@ public class PurgeExecutor { } for (String file : dataFolder.list()) { - if (cleared.contains(file.toLowerCase())) { + if (cleared.contains(file.toLowerCase(Locale.ROOT))) { File playerFile = new File(dataFolder, file); if (playerFile.exists() && playerFile.delete()) { i++; @@ -137,7 +138,7 @@ public class PurgeExecutor { if (name.equals(file)) { continue; } - if (cleared.contains(name.toLowerCase())) { + if (cleared.contains(name.toLowerCase(Locale.ROOT))) { File dataFile = new File(dataFolder, file); if (dataFile.exists() && dataFile.delete()) { i++; diff --git a/src/main/java/fr/xephi/authme/task/purge/PurgeTask.java b/src/main/java/fr/xephi/authme/task/purge/PurgeTask.java index f29d6f71d..5c4a8707f 100644 --- a/src/main/java/fr/xephi/authme/task/purge/PurgeTask.java +++ b/src/main/java/fr/xephi/authme/task/purge/PurgeTask.java @@ -12,6 +12,7 @@ import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitRunnable; import java.util.HashSet; +import java.util.Locale; import java.util.Set; import java.util.UUID; @@ -74,7 +75,7 @@ class PurgeTask extends BukkitRunnable { } OfflinePlayer offlinePlayer = offlinePlayers[nextPosition]; - if (offlinePlayer.getName() != null && toPurge.remove(offlinePlayer.getName().toLowerCase())) { + if (offlinePlayer.getName() != null && toPurge.remove(offlinePlayer.getName().toLowerCase(Locale.ROOT))) { if (!permissionsManager.loadUserData(offlinePlayer)) { logger.warning("Unable to check if the user " + offlinePlayer.getName() + " can be purged!"); continue; diff --git a/src/test/java/fr/xephi/authme/api/v3/AuthMeApiTest.java b/src/test/java/fr/xephi/authme/api/v3/AuthMeApiTest.java index b3fd01581..b52f7908b 100644 --- a/src/test/java/fr/xephi/authme/api/v3/AuthMeApiTest.java +++ b/src/test/java/fr/xephi/authme/api/v3/AuthMeApiTest.java @@ -28,6 +28,7 @@ import java.time.Instant; import java.util.Arrays; import java.util.Date; import java.util.List; +import java.util.Locale; import java.util.Optional; import java.util.stream.Collectors; @@ -457,7 +458,7 @@ public class AuthMeApiTest { String name = "Marco"; String password = "myP4ss"; HashedPassword hashedPassword = new HashedPassword("0395872SLKDFJOWEIUTEJSD"); - given(passwordSecurity.computeHash(password, name.toLowerCase())).willReturn(hashedPassword); + given(passwordSecurity.computeHash(password, name.toLowerCase(Locale.ROOT))).willReturn(hashedPassword); given(dataSource.saveAuth(any(PlayerAuth.class))).willReturn(true); // when @@ -465,10 +466,10 @@ public class AuthMeApiTest { // then assertThat(result, equalTo(true)); - verify(passwordSecurity).computeHash(password, name.toLowerCase()); + verify(passwordSecurity).computeHash(password, name.toLowerCase(Locale.ROOT)); ArgumentCaptor authCaptor = ArgumentCaptor.forClass(PlayerAuth.class); verify(dataSource).saveAuth(authCaptor.capture()); - assertThat(authCaptor.getValue().getNickname(), equalTo(name.toLowerCase())); + assertThat(authCaptor.getValue().getNickname(), equalTo(name.toLowerCase(Locale.ROOT))); assertThat(authCaptor.getValue().getRealName(), equalTo(name)); assertThat(authCaptor.getValue().getPassword(), equalTo(hashedPassword)); } diff --git a/src/test/java/fr/xephi/authme/command/CommandInitializerTest.java b/src/test/java/fr/xephi/authme/command/CommandInitializerTest.java index 133d01940..964192f30 100644 --- a/src/test/java/fr/xephi/authme/command/CommandInitializerTest.java +++ b/src/test/java/fr/xephi/authme/command/CommandInitializerTest.java @@ -9,6 +9,7 @@ import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Set; import java.util.function.BiConsumer; @@ -90,7 +91,7 @@ public class CommandInitializerTest { @Override public void accept(CommandDescription command, Integer depth) { for (String label : command.getLabels()) { - if (!label.equals(label.toLowerCase())) { + if (!label.equals(label.toLowerCase(Locale.ROOT))) { fail("Label '" + label + "' should be lowercase"); } else if (invalidPattern.matcher(label).matches()) { fail("Label '" + label + "' has whitespace"); 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 43c1c9067..22533acde 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 @@ -17,6 +17,7 @@ import org.mockito.junit.MockitoJUnitRunner; import java.util.Collections; import java.util.HashSet; +import java.util.Locale; import java.util.Map; import java.util.Set; @@ -129,7 +130,7 @@ public class ConverterCommandTest { setBukkitServiceToRunTaskAsynchronously(bukkitService); // when - command.executeCommand(sender, Collections.singletonList(converterName.toUpperCase())); + command.executeCommand(sender, Collections.singletonList(converterName.toUpperCase(Locale.ROOT))); // then verify(converter).execute(sender); diff --git a/src/test/java/fr/xephi/authme/command/executable/authme/PurgeBannedPlayersCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/authme/PurgeBannedPlayersCommandTest.java index 199044cb2..7c675bc07 100644 --- a/src/test/java/fr/xephi/authme/command/executable/authme/PurgeBannedPlayersCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/authme/PurgeBannedPlayersCommandTest.java @@ -12,6 +12,7 @@ import org.mockito.junit.MockitoJUnitRunner; import java.util.Collections; import java.util.HashSet; +import java.util.Locale; import java.util.Set; import static com.google.common.collect.Sets.newHashSet; @@ -67,7 +68,7 @@ public class PurgeBannedPlayersCommandTest { private static Set asLowerCaseSet(String... items) { Set result = new HashSet<>(items.length); for (String item : items) { - result.add(item.toLowerCase()); + result.add(item.toLowerCase(Locale.ROOT)); } return result; } diff --git a/src/test/java/fr/xephi/authme/command/executable/authme/PurgePlayerCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/authme/PurgePlayerCommandTest.java index 846c4cabb..cf48d2a39 100644 --- a/src/test/java/fr/xephi/authme/command/executable/authme/PurgePlayerCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/authme/PurgePlayerCommandTest.java @@ -11,6 +11,8 @@ import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; +import java.util.Locale; + import static fr.xephi.authme.service.BukkitServiceTestHelper.setBukkitServiceToRunTaskAsynchronously; import static fr.xephi.authme.service.BukkitServiceTestHelper.setBukkitServiceToRunTaskOptionallyAsync; import static java.util.Arrays.asList; @@ -71,7 +73,7 @@ public class PurgePlayerCommandTest { // then verify(dataSource).isAuthAvailable(name); - verify(purgeExecutor).executePurge(singletonList(player), singletonList(name.toLowerCase())); + verify(purgeExecutor).executePurge(singletonList(player), singletonList(name.toLowerCase(Locale.ROOT))); } @Test @@ -87,6 +89,6 @@ public class PurgePlayerCommandTest { command.executeCommand(sender, asList(name, "force")); // then - verify(purgeExecutor).executePurge(singletonList(player), singletonList(name.toLowerCase())); + verify(purgeExecutor).executePurge(singletonList(player), singletonList(name.toLowerCase(Locale.ROOT))); } } 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 92492b99f..07808fa58 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 @@ -21,6 +21,7 @@ import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; import java.util.Arrays; +import java.util.Locale; import static fr.xephi.authme.service.BukkitServiceTestHelper.setBukkitServiceToRunTaskOptionallyAsync; import static fr.xephi.authme.service.BukkitServiceTestHelper.setBukkitServiceToScheduleSyncTaskFromOptionallyAsyncTask; @@ -179,7 +180,7 @@ public class RegisterAdminCommandTest { private void assertAuthHasInfo(PlayerAuth auth, String name, HashedPassword hashedPassword) { assertThat(auth.getRealName(), equalTo(name)); - assertThat(auth.getNickname(), equalTo(name.toLowerCase())); + assertThat(auth.getNickname(), equalTo(name.toLowerCase(Locale.ROOT))); assertThat(auth.getPassword(), equalTo(hashedPassword)); } } 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 e2c63a602..82e39d411 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 @@ -16,6 +16,7 @@ import org.mockito.junit.MockitoJUnitRunner; import java.util.Arrays; import java.util.List; +import java.util.Locale; import static com.google.common.base.Preconditions.checkArgument; import static java.util.Collections.emptyList; @@ -125,7 +126,7 @@ public class DebugCommandTest { CommandSender sender = mock(CommandSender.class); given(permissionsManager.hasPermission(sender, section.getRequiredPermission())).willReturn(true); - List arguments = Arrays.asList(section.getName().toUpperCase(), "test", "toast"); + List arguments = Arrays.asList(section.getName().toUpperCase(Locale.ROOT), "test", "toast"); // when command.executeCommand(sender, arguments); @@ -144,7 +145,7 @@ public class DebugCommandTest { CommandSender sender = mock(CommandSender.class); given(permissionsManager.hasPermission(sender, section.getRequiredPermission())).willReturn(false); - List arguments = Arrays.asList(section.getName().toUpperCase(), "test"); + List arguments = Arrays.asList(section.getName().toUpperCase(Locale.ROOT), "test"); // when command.executeCommand(sender, arguments); 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 4e629d6da..06ce4ee5b 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 @@ -22,6 +22,7 @@ import org.junit.runner.RunWith; import org.mockito.Mock; import java.util.Collections; +import java.util.Locale; import static fr.xephi.authme.service.BukkitServiceTestHelper.setBukkitServiceToRunTaskAsynchronously; import static org.hamcrest.Matchers.equalTo; @@ -187,7 +188,7 @@ public class RecoverEmailCommandTest { setBukkitServiceToRunTaskAsynchronously(bukkitService); // when - command.executeCommand(sender, Collections.singletonList(email.toUpperCase())); + command.executeCommand(sender, Collections.singletonList(email.toUpperCase(Locale.ROOT))); // then verify(emailService).hasAllInformation(); 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 99ec921c6..8852387fa 100644 --- a/src/test/java/fr/xephi/authme/command/help/HelpProviderTest.java +++ b/src/test/java/fr/xephi/authme/command/help/HelpProviderTest.java @@ -23,6 +23,7 @@ import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.List; +import java.util.Locale; import java.util.stream.Collectors; import static fr.xephi.authme.command.TestCommandsUtil.getCommandWithLabel; @@ -446,19 +447,19 @@ public class HelpProviderTest { given(helpMessagesService.buildLocalizedDescription(any(CommandDescription.class))) .willAnswer(new ReturnsArgumentAt(0)); for (HelpMessage key : HelpMessage.values()) { - String text = key.name().replace("_", " ").toLowerCase(); + String text = key.name().replace("_", " ").toLowerCase(Locale.ROOT); given(helpMessagesService.getMessage(key)) - .willReturn(text.substring(0, 1).toUpperCase() + text.substring(1)); + .willReturn(text.substring(0, 1).toUpperCase(Locale.ROOT) + text.substring(1)); } for (DefaultPermission permission : DefaultPermission.values()) { - String text = permission.name().replace("_", " ").toLowerCase(); + String text = permission.name().replace("_", " ").toLowerCase(Locale.ROOT); given(helpMessagesService.getMessage(permission)) - .willReturn(text.substring(0, 1).toUpperCase() + text.substring(1)); + .willReturn(text.substring(0, 1).toUpperCase(Locale.ROOT) + text.substring(1)); } for (HelpSection section : HelpSection.values()) { - String text = section.name().replace("_", " ").toLowerCase(); + String text = section.name().replace("_", " ").toLowerCase(Locale.ROOT); given(helpMessagesService.getMessage(section)) - .willReturn(text.substring(0, 1).toUpperCase() + text.substring(1)); + .willReturn(text.substring(0, 1).toUpperCase(Locale.ROOT) + text.substring(1)); } } 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 e5c2c63f1..319763458 100644 --- a/src/test/java/fr/xephi/authme/data/captcha/LoginCaptchaManagerTest.java +++ b/src/test/java/fr/xephi/authme/data/captcha/LoginCaptchaManagerTest.java @@ -7,6 +7,8 @@ import fr.xephi.authme.util.expiring.TimedCounter; import org.bukkit.entity.Player; import org.junit.Test; +import java.util.Locale; + import static fr.xephi.authme.AuthMeMatchers.stringWithLength; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.not; @@ -34,7 +36,7 @@ public class LoginCaptchaManagerTest { // then assertThat(manager.isCaptchaRequired(player), equalTo(false)); manager.increaseLoginFailureCount(player); - assertThat(manager.isCaptchaRequired(player.toUpperCase()), equalTo(true)); + assertThat(manager.isCaptchaRequired(player.toUpperCase(Locale.ROOT)), equalTo(true)); assertThat(manager.isCaptchaRequired("otherPlayer"), equalTo(false)); } @@ -167,6 +169,6 @@ public class LoginCaptchaManagerTest { private static void assertHasCount(LoginCaptchaManager manager, String player, Integer count) { TimedCounter playerCounts = ReflectionTestUtils .getFieldValue(LoginCaptchaManager.class, manager, "playerCounts"); - assertThat(playerCounts.get(player.toLowerCase()), equalTo(count)); + assertThat(playerCounts.get(player.toLowerCase(Locale.ROOT)), equalTo(count)); } } diff --git a/src/test/java/fr/xephi/authme/security/PasswordSecurityTest.java b/src/test/java/fr/xephi/authme/security/PasswordSecurityTest.java index 520ae8ddc..aa3165e76 100644 --- a/src/test/java/fr/xephi/authme/security/PasswordSecurityTest.java +++ b/src/test/java/fr/xephi/authme/security/PasswordSecurityTest.java @@ -27,6 +27,7 @@ import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; import java.util.Collections; +import java.util.Locale; import java.util.Set; import static com.google.common.collect.Sets.newHashSet; @@ -118,7 +119,7 @@ public class PasswordSecurityTest { HashedPassword password = new HashedPassword("$TEST$10$SOME_HASH", null); String playerName = "Tester"; // Calls to EncryptionMethod are always with the lower-case version of the name - String playerLowerCase = playerName.toLowerCase(); + String playerLowerCase = playerName.toLowerCase(Locale.ROOT); String clearTextPass = "myPassTest"; given(dataSource.getPassword(playerName)).willReturn(password); @@ -139,7 +140,7 @@ public class PasswordSecurityTest { // given HashedPassword password = new HashedPassword("$TEST$10$SOME_HASH", null); String playerName = "My_PLayer"; - String playerLowerCase = playerName.toLowerCase(); + String playerLowerCase = playerName.toLowerCase(Locale.ROOT); String clearTextPass = "passw0Rd1"; given(dataSource.getPassword(playerName)).willReturn(password); @@ -178,7 +179,7 @@ public class PasswordSecurityTest { HashedPassword password = new HashedPassword("$2y$10$2e6d2193f43501c926e25elvWlPmWczmrfrnbZV0dUZGITjYjnkkW"); String playerName = "somePlayer"; - String playerLowerCase = playerName.toLowerCase(); + String playerLowerCase = playerName.toLowerCase(Locale.ROOT); String clearTextPass = "Test"; // MD5 hash for "Test" HashedPassword newPassword = new HashedPassword("0cbc6611f5540bd0809a388dc95a615b"); @@ -230,7 +231,7 @@ public class PasswordSecurityTest { // given String password = "MyP@ssword"; String username = "theUserInTest"; - String usernameLowerCase = username.toLowerCase(); + String usernameLowerCase = username.toLowerCase(Locale.ROOT); HashedPassword hashedPassword = new HashedPassword("$T$est#Hash", "__someSalt__"); given(method.computeHash(password, usernameLowerCase)).willReturn(hashedPassword); given(settings.getProperty(SecuritySettings.PASSWORD_HASH)).willReturn(HashAlgorithm.JOOMLA); 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 b42cd9268..6a96425fc 100644 --- a/src/test/java/fr/xephi/authme/security/crypts/AbstractEncryptionMethodTest.java +++ b/src/test/java/fr/xephi/authme/security/crypts/AbstractEncryptionMethodTest.java @@ -8,6 +8,7 @@ import org.junit.BeforeClass; import org.junit.Test; import java.util.List; +import java.util.Locale; import java.util.Map; import static org.hamcrest.Matchers.equalTo; @@ -154,13 +155,13 @@ public abstract class AbstractEncryptionMethodTest { method.comparePassword(password, hashedPassword, USERNAME)); assumeThat(SKIP_LONG_TESTS, equalTo(false)); - if (!password.equals(password.toLowerCase())) { + if (!password.equals(password.toLowerCase(Locale.ROOT))) { assertFalse("Lower-case of '" + password + "' should not match generated hash '" + hash + "'", - method.comparePassword(password.toLowerCase(), hashedPassword, USERNAME)); + method.comparePassword(password.toLowerCase(Locale.ROOT), hashedPassword, USERNAME)); } - if (!password.equals(password.toUpperCase())) { + if (!password.equals(password.toUpperCase(Locale.ROOT))) { assertFalse("Upper-case of '" + password + "' should not match generated hash '" + hash + "'", - method.comparePassword(password.toUpperCase(), hashedPassword, USERNAME)); + method.comparePassword(password.toUpperCase(Locale.ROOT), hashedPassword, USERNAME)); } } } diff --git a/src/test/java/fr/xephi/authme/service/MigrationServiceTest.java b/src/test/java/fr/xephi/authme/service/MigrationServiceTest.java index e1579710c..ec989a042 100644 --- a/src/test/java/fr/xephi/authme/service/MigrationServiceTest.java +++ b/src/test/java/fr/xephi/authme/service/MigrationServiceTest.java @@ -15,6 +15,7 @@ import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; import java.util.Arrays; +import java.util.Locale; import static fr.xephi.authme.AuthMeMatchers.equalToHash; import static org.hamcrest.Matchers.equalToIgnoringCase; @@ -118,7 +119,7 @@ public class MigrationServiceTest { private static void setSha256MockToUppercase(Sha256 sha256) { given(sha256.computeHash(anyString(), anyString())).willAnswer(invocation -> { String plainPassword = invocation.getArgument(0); - return new HashedPassword(plainPassword.toUpperCase(), null); + return new HashedPassword(plainPassword.toUpperCase(Locale.ROOT), null); }); } } diff --git a/src/test/java/tools/docs/hashmethods/HashAlgorithmsDescriptionTask.java b/src/test/java/tools/docs/hashmethods/HashAlgorithmsDescriptionTask.java index b21d7fda3..2fd234158 100644 --- a/src/test/java/tools/docs/hashmethods/HashAlgorithmsDescriptionTask.java +++ b/src/test/java/tools/docs/hashmethods/HashAlgorithmsDescriptionTask.java @@ -7,6 +7,7 @@ import tools.utils.TagValue.NestedTagValue; import tools.utils.TagValueHolder; import tools.utils.ToolsConstants; +import java.util.Locale; import java.util.Map; /** @@ -83,7 +84,7 @@ public class HashAlgorithmsDescriptionTask implements AutoToolTask { // Get the enum name and replace something like "DO_NOT_USE" to "Do not use" String enumName = value.toString().replace("_", " "); return enumName.length() > 2 - ? enumName.substring(0, 1) + enumName.substring(1).toLowerCase() + ? enumName.substring(0, 1) + enumName.substring(1).toLowerCase(Locale.ROOT) : enumName; } From 63780e3f7c43a29e4831e44f591fbe76f3a00008 Mon Sep 17 00:00:00 2001 From: ljacqu Date: Sun, 21 Aug 2022 01:12:57 +0200 Subject: [PATCH 61/97] Add Checkstyle rule to disallow toLowerCase() and toUpperCase() without Locale (#2606) --- .checkstyle.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.checkstyle.xml b/.checkstyle.xml index dc14b095e..0d4cb9a25 100644 --- a/.checkstyle.xml +++ b/.checkstyle.xml @@ -192,6 +192,12 @@ + + + + + + From 0d29c18ab40aea0bb33dda4929dbd5cfc7e24e84 Mon Sep 17 00:00:00 2001 From: ChanceSD <5256215+ChanceSD@users.noreply.github.com> Date: Fri, 2 Sep 2022 12:54:22 +0100 Subject: [PATCH 62/97] Fix automatic antibot (#2611) --- src/main/java/fr/xephi/authme/service/AntiBotService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/fr/xephi/authme/service/AntiBotService.java b/src/main/java/fr/xephi/authme/service/AntiBotService.java index c5fb136d7..abe987b70 100644 --- a/src/main/java/fr/xephi/authme/service/AntiBotService.java +++ b/src/main/java/fr/xephi/authme/service/AntiBotService.java @@ -56,7 +56,7 @@ public class AntiBotService implements SettingsDependent { duration = settings.getProperty(ProtectionSettings.ANTIBOT_DURATION); int sensibility = settings.getProperty(ProtectionSettings.ANTIBOT_SENSIBILITY); int interval = settings.getProperty(ProtectionSettings.ANTIBOT_INTERVAL); - flaggedCounter = new AtomicIntervalCounter(sensibility, interval); + flaggedCounter = new AtomicIntervalCounter(sensibility, interval * 1000); // Stop existing protection stopProtection(); From 51760c4a8cec2bf7fa3ad319fa301aca611a9fba Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Wed, 7 Sep 2022 22:09:29 +0200 Subject: [PATCH 63/97] Change the essentialsx repository --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 5dd647092..7c86b148a 100644 --- a/pom.xml +++ b/pom.xml @@ -533,8 +533,8 @@ - enderzone-repo - https://ci.ender.zone/plugin/repository/everything/ + essentialsx-repo + https://repo.essentialsx.net/releases/ true From 50a1f9de98b3b2188dd77cd71f7b22ea6d0c50e7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 7 Sep 2022 22:10:20 +0200 Subject: [PATCH 64/97] Bump EssentialsX from 2.19.6 to 2.19.7 (#2608) Bumps [EssentialsX](https://github.com/EssentialsX/Essentials) from 2.19.6 to 2.19.7. - [Release notes](https://github.com/EssentialsX/Essentials/releases) - [Commits](https://github.com/EssentialsX/Essentials/compare/2.19.6...2.19.7) --- updated-dependencies: - dependency-name: net.essentialsx:EssentialsX dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7c86b148a..0b57dd698 100644 --- a/pom.xml +++ b/pom.xml @@ -929,7 +929,7 @@ net.essentialsx EssentialsX - 2.19.6 + 2.19.7 provided From 37b8728197e6f6f0a81b3a1cae16bfdfe13de8d1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 7 Sep 2022 22:10:30 +0200 Subject: [PATCH 65/97] Bump postgresql from 42.4.2 to 42.5.0 (#2609) Bumps [postgresql](https://github.com/pgjdbc/pgjdbc) from 42.4.2 to 42.5.0. - [Release notes](https://github.com/pgjdbc/pgjdbc/releases) - [Changelog](https://github.com/pgjdbc/pgjdbc/blob/master/CHANGELOG.md) - [Commits](https://github.com/pgjdbc/pgjdbc/compare/REL42.4.2...REL42.5.0) --- updated-dependencies: - dependency-name: org.postgresql:postgresql dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0b57dd698..8198c4c76 100644 --- a/pom.xml +++ b/pom.xml @@ -1001,7 +1001,7 @@ org.postgresql postgresql - 42.4.2 + 42.5.0 true From dca829650c120a47a5910d020918d3a0d955b430 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 7 Sep 2022 22:10:37 +0200 Subject: [PATCH 66/97] Bump sqlite-jdbc from 3.39.2.0 to 3.39.2.1 (#2610) Bumps [sqlite-jdbc](https://github.com/xerial/sqlite-jdbc) from 3.39.2.0 to 3.39.2.1. - [Release notes](https://github.com/xerial/sqlite-jdbc/releases) - [Changelog](https://github.com/xerial/sqlite-jdbc/blob/master/CHANGELOG) - [Commits](https://github.com/xerial/sqlite-jdbc/compare/3.39.2.0...3.39.2.1) --- updated-dependencies: - dependency-name: org.xerial:sqlite-jdbc dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8198c4c76..d19e038f5 100644 --- a/pom.xml +++ b/pom.xml @@ -1052,7 +1052,7 @@ org.xerial sqlite-jdbc - 3.39.2.0 + 3.39.2.1 test From 3f5353a3289048b1af003ddd2d8e21cfcbf9f33b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 7 Sep 2022 22:10:46 +0200 Subject: [PATCH 67/97] Bump checker-qual from 3.24.0 to 3.25.0 (#2612) Bumps [checker-qual](https://github.com/typetools/checker-framework) from 3.24.0 to 3.25.0. - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.24.0...checker-framework-3.25.0) --- updated-dependencies: - dependency-name: org.checkerframework:checker-qual dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d19e038f5..4b5b82511 100644 --- a/pom.xml +++ b/pom.xml @@ -1044,7 +1044,7 @@ org.checkerframework checker-qual - 3.24.0 + 3.25.0 test From fefeead3234fda078daa8d3118c942d252a55ce1 Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Sun, 9 Oct 2022 22:03:09 +0200 Subject: [PATCH 68/97] Fix duplicated repository in pom.xml --- pom.xml | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/pom.xml b/pom.xml index 4b5b82511..718e018cc 100644 --- a/pom.xml +++ b/pom.xml @@ -586,17 +586,6 @@ true - - - essentialsx-repo - https://repo.essentialsx.net/releases/ - - true - - - false - - From 683c897c0f00e5f27a6133d21320f396081b7569 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 9 Oct 2022 22:03:47 +0200 Subject: [PATCH 69/97] Bump mockito-core from 4.7.0 to 4.8.0 (#2613) Bumps [mockito-core](https://github.com/mockito/mockito) from 4.7.0 to 4.8.0. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v4.7.0...v4.8.0) --- updated-dependencies: - dependency-name: org.mockito:mockito-core dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 718e018cc..824a7076b 100644 --- a/pom.xml +++ b/pom.xml @@ -1020,7 +1020,7 @@ org.mockito mockito-core test - 4.7.0 + 4.8.0 hamcrest-core From a865f9bc2da0b1a9f59bd55c23666f9d8ea5626a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 9 Oct 2022 22:03:57 +0200 Subject: [PATCH 70/97] Bump sqlite-jdbc from 3.39.2.1 to 3.39.3.0 (#2615) Bumps [sqlite-jdbc](https://github.com/xerial/sqlite-jdbc) from 3.39.2.1 to 3.39.3.0. - [Release notes](https://github.com/xerial/sqlite-jdbc/releases) - [Changelog](https://github.com/xerial/sqlite-jdbc/blob/master/CHANGELOG) - [Commits](https://github.com/xerial/sqlite-jdbc/compare/3.39.2.1...3.39.3.0) --- updated-dependencies: - dependency-name: org.xerial:sqlite-jdbc dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 824a7076b..f321e704f 100644 --- a/pom.xml +++ b/pom.xml @@ -1041,7 +1041,7 @@ org.xerial sqlite-jdbc - 3.39.2.1 + 3.39.3.0 test From 12978a82d1f22c990f7e8e226023f2854e6f5d60 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 9 Oct 2022 22:04:07 +0200 Subject: [PATCH 71/97] Bump maven-shade-plugin from 3.3.0 to 3.4.0 (#2618) Bumps [maven-shade-plugin](https://github.com/apache/maven-shade-plugin) from 3.3.0 to 3.4.0. - [Release notes](https://github.com/apache/maven-shade-plugin/releases) - [Commits](https://github.com/apache/maven-shade-plugin/compare/maven-shade-plugin-3.3.0...maven-shade-plugin-3.4.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-shade-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f321e704f..118e2d382 100644 --- a/pom.xml +++ b/pom.xml @@ -282,7 +282,7 @@ org.apache.maven.plugins maven-shade-plugin - 3.3.0 + 3.4.0 shaded-jar From 1492d8d4a18d94aea32d31907c779eb992674f05 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 9 Oct 2022 22:04:15 +0200 Subject: [PATCH 72/97] Bump maven-jar-plugin from 3.2.2 to 3.3.0 (#2620) Bumps [maven-jar-plugin](https://github.com/apache/maven-jar-plugin) from 3.2.2 to 3.3.0. - [Release notes](https://github.com/apache/maven-jar-plugin/releases) - [Commits](https://github.com/apache/maven-jar-plugin/compare/maven-jar-plugin-3.2.2...maven-jar-plugin-3.3.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-jar-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 118e2d382..1831e6887 100644 --- a/pom.xml +++ b/pom.xml @@ -241,7 +241,7 @@ org.apache.maven.plugins maven-jar-plugin - 3.2.2 + 3.3.0 From 681689bd5caf1d4c2bf345c21ecaa8e3dc4d95d0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 9 Oct 2022 22:04:24 +0200 Subject: [PATCH 73/97] Bump mariadb-java-client from 3.0.7 to 3.0.8 (#2621) Bumps [mariadb-java-client](https://github.com/mariadb-corporation/mariadb-connector-j) from 3.0.7 to 3.0.8. - [Release notes](https://github.com/mariadb-corporation/mariadb-connector-j/releases) - [Changelog](https://github.com/mariadb-corporation/mariadb-connector-j/blob/master/CHANGELOG.md) - [Commits](https://github.com/mariadb-corporation/mariadb-connector-j/compare/3.0.7...3.0.8) --- updated-dependencies: - dependency-name: org.mariadb.jdbc:mariadb-java-client dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1831e6887..9c7109668 100644 --- a/pom.xml +++ b/pom.xml @@ -685,7 +685,7 @@ org.mariadb.jdbc mariadb-java-client - 3.0.7 + 3.0.8 true From 0c83c6d9d86052d5fafc8b10e2b9626bbdb67bb9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 9 Oct 2022 22:04:41 +0200 Subject: [PATCH 74/97] Bump checker-qual from 3.25.0 to 3.26.0 (#2626) Bumps [checker-qual](https://github.com/typetools/checker-framework) from 3.25.0 to 3.26.0. - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/docs/CHANGELOG.md) - [Commits](https://github.com/typetools/checker-framework/compare/checker-framework-3.25.0...checker-framework-3.26.0) --- updated-dependencies: - dependency-name: org.checkerframework:checker-qual dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 9c7109668..b50426954 100644 --- a/pom.xml +++ b/pom.xml @@ -1033,7 +1033,7 @@ org.checkerframework checker-qual - 3.25.0 + 3.26.0 test From ddca37ab732bd646526d03079073215d7d1a1e94 Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Sun, 9 Oct 2022 23:39:39 +0200 Subject: [PATCH 75/97] Require Java 11 compiler (JRE 1.8 compatible) --- README.md | 6 +++--- pom.xml | 15 +++++++++++---- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 7bd5a0350..9f57cf406 100644 --- a/README.md +++ b/README.md @@ -116,16 +116,16 @@ You can also create your own translation file and, if you want, you can share it ## Requirements ##### Compiling requirements: ->- JDK 8 (JDK 17 is recommended) +>- JDK 11 (JDK 17 is recommended) >- Maven >- Git/Github (Optional) ##### How to compile the project: ->- Clone the project with Git/Github +>- Clone the project with Git/GitHub >- Execute command "mvn clean package" ##### Running requirements: ->- Java 8 (Java 11 is recommended) +>- 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) diff --git a/pom.xml b/pom.xml index 718e018cc..d22800c67 100644 --- a/pom.xml +++ b/pom.xml @@ -60,8 +60,11 @@ UTF-8 UTF-8 - 1.8 - 3.6.0 + 1.8 + 1.8 + 8 + 11 + 3.6.3 1.19-R0.1-SNAPSHOT @@ -173,6 +176,9 @@ ${maven.minimumVersion} + + [11,) + true @@ -197,8 +203,9 @@ maven-compiler-plugin 3.10.1 - ${java.version} - ${java.version} + ${java.source} + ${java.target} + ${java.apiVersion}
From 87c60a5b44e9cd8a476a4539208f7b7acd1c88f5 Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Thu, 27 Oct 2022 01:47:32 +0200 Subject: [PATCH 76/97] Update github workflow --- .github/workflows/maven.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 0e1946805..46d58c20b 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -10,7 +10,7 @@ jobs: build_and_test: strategy: matrix: - jdkversion: [8, 11, 17] + jdkversion: [11] runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 From 569b8ba2d390114bf974598e4ab8dc78eea2558b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 27 Oct 2022 01:48:10 +0200 Subject: [PATCH 77/97] Bump mockito-core from 4.8.0 to 4.8.1 (#2632) Bumps [mockito-core](https://github.com/mockito/mockito) from 4.8.0 to 4.8.1. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v4.8.0...v4.8.1) --- updated-dependencies: - dependency-name: org.mockito:mockito-core dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 00acb96fd..d498b224c 100644 --- a/pom.xml +++ b/pom.xml @@ -1027,7 +1027,7 @@ org.mockito mockito-core test - 4.8.0 + 4.8.1 hamcrest-core From d7437bd2b16fbc063403f747db56a6d7f59e39bd Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Thu, 27 Oct 2022 02:08:02 +0200 Subject: [PATCH 78/97] Bump log4j dependency (keep in sync with 1.12.2) --- pom.xml | 14 +++++++------- .../fr/xephi/authme/output/Log4JFilterTest.java | 11 +++++++---- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/pom.xml b/pom.xml index 00acb96fd..e26d38b62 100644 --- a/pom.xml +++ b/pom.xml @@ -67,7 +67,7 @@ 3.6.3 - 1.19-R0.1-SNAPSHOT + 1.19.2-R0.1-SNAPSHOT AuthMe @@ -649,7 +649,7 @@ org.apache.logging.log4j log4j-core - 2.5 + 2.8.1 provided @@ -657,7 +657,7 @@ com.zaxxer HikariCP - 4.0.3 + 4.0.3 true @@ -670,7 +670,7 @@ org.slf4j slf4j-simple - 1.7.36 + 1.7.36 true @@ -684,9 +684,9 @@ - mysql - mysql-connector-java - 8.0.30 + com.mysql + mysql-connector-j + 8.0.31 true diff --git a/src/test/java/fr/xephi/authme/output/Log4JFilterTest.java b/src/test/java/fr/xephi/authme/output/Log4JFilterTest.java index b9977de8e..91228c5fc 100644 --- a/src/test/java/fr/xephi/authme/output/Log4JFilterTest.java +++ b/src/test/java/fr/xephi/authme/output/Log4JFilterTest.java @@ -4,8 +4,11 @@ import static org.hamcrest.Matchers.equalTo; import static org.junit.Assert.assertThat; import static org.mockito.Mockito.when; +import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.Marker; import org.apache.logging.log4j.core.Filter.Result; import org.apache.logging.log4j.core.LogEvent; +import org.apache.logging.log4j.core.Logger; import org.apache.logging.log4j.message.Message; import org.junit.Test; import org.mockito.Mockito; @@ -134,7 +137,7 @@ public class Log4JFilterTest { @Test public void shouldFilterSensitiveObjectMessage() { // given / when - Result result = log4JFilter.filter(null, null, null, SENSITIVE_COMMAND, new Exception()); + Result result = log4JFilter.filter(null, null, null, (Object) SENSITIVE_COMMAND, new Exception()); // then assertThat(result, equalTo(Result.DENY)); @@ -152,7 +155,7 @@ public class Log4JFilterTest { @Test public void shouldNotFilterIrrelevantMessage() { // given / when - Result result = log4JFilter.filter(null, null, null, OTHER_COMMAND, new Exception()); + Result result = log4JFilter.filter(null, null, null, (Object) OTHER_COMMAND, new Exception()); // then assertThat(result, equalTo(Result.NEUTRAL)); @@ -161,7 +164,7 @@ public class Log4JFilterTest { @Test public void shouldNotFilterNonSensitiveCommand() { // given / when - Result result = log4JFilter.filter(null, null, null, NORMAL_COMMAND, new Exception()); + Result result = log4JFilter.filter(null, null, null, (Object) NORMAL_COMMAND, new Exception()); // then assertThat(result, equalTo(Result.NEUTRAL)); @@ -209,7 +212,7 @@ public class Log4JFilterTest { @Test public void shouldNotFilterNullMessage() { // given / when - Result result = log4JFilter.filter(null, null, null, null, new Exception()); + Result result = log4JFilter.filter(null, null, null, (Object) null, new Exception()); // then assertThat(result, equalTo(Result.NEUTRAL)); From ca6e301d46ed30e578b5db9b18f8c711436adfbf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 28 Oct 2022 03:05:07 +0000 Subject: [PATCH 79/97] Bump maven-shade-plugin from 3.4.0 to 3.4.1 Bumps [maven-shade-plugin](https://github.com/apache/maven-shade-plugin) from 3.4.0 to 3.4.1. - [Release notes](https://github.com/apache/maven-shade-plugin/releases) - [Commits](https://github.com/apache/maven-shade-plugin/compare/maven-shade-plugin-3.4.0...maven-shade-plugin-3.4.1) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-shade-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 581affd15..f78e74caf 100644 --- a/pom.xml +++ b/pom.xml @@ -289,7 +289,7 @@ org.apache.maven.plugins maven-shade-plugin - 3.4.0 + 3.4.1 shaded-jar From 779e62674eabff10ec0ec335968223cee3e1fa5c Mon Sep 17 00:00:00 2001 From: ljacqu Date: Fri, 30 Dec 2022 08:27:51 +0100 Subject: [PATCH 80/97] #2661 Remove mocks of InetAddress (which is a sealed class in JDK 19) - Remove mocks of InetAddress in favor of using real InetAddress instances. This fixes test issues under JDK 19, where InetAddress has been changed to a sealed class --- .../authme/service/ValidationService.java | 9 +++++- src/test/java/fr/xephi/authme/TestHelper.java | 15 +++++---- .../executable/authme/GetIpCommandTest.java | 2 +- .../xephi/authme/data/TempbanManagerTest.java | 6 ++-- .../process/login/AsynchronousLoginTest.java | 16 +++++----- .../process/register/AsyncRegisterTest.java | 4 +-- .../executors/EmailRegisterExecutorTest.java | 2 +- .../PasswordRegisterExecutorTest.java | 2 +- .../PlayerAuthBuilderHelperTest.java | 2 +- .../service/PasswordRecoveryServiceTest.java | 10 +++--- .../authme/service/SessionServiceTest.java | 2 +- .../authme/service/ValidationServiceTest.java | 32 ++++++++++++------- .../WelcomeMessageConfigurationTest.java | 2 +- .../commandconfig/CommandManagerTest.java | 2 +- .../fr/xephi/authme/util/PlayerUtilsTest.java | 2 +- 15 files changed, 63 insertions(+), 45 deletions(-) diff --git a/src/main/java/fr/xephi/authme/service/ValidationService.java b/src/main/java/fr/xephi/authme/service/ValidationService.java index 536d2111e..2b4e72f8f 100644 --- a/src/main/java/fr/xephi/authme/service/ValidationService.java +++ b/src/main/java/fr/xephi/authme/service/ValidationService.java @@ -1,6 +1,7 @@ package fr.xephi.authme.service; import ch.jalu.configme.properties.Property; +import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.HashMultimap; import com.google.common.collect.Multimap; import fr.xephi.authme.ConsoleLogger; @@ -23,6 +24,7 @@ import org.bukkit.entity.Player; import javax.annotation.PostConstruct; import javax.inject.Inject; +import java.net.InetSocketAddress; import java.util.Collection; import java.util.List; import java.util.Locale; @@ -156,7 +158,7 @@ public class ValidationService implements Reloadable { } String ip = PlayerUtils.getPlayerIp(player); - String domain = player.getAddress().getHostName(); + String domain = getHostName(player.getAddress()); for (String restriction : restrictions) { if (restriction.startsWith("regex:")) { restriction = restriction.replace("regex:", ""); @@ -173,6 +175,11 @@ public class ValidationService implements Reloadable { return false; } + @VisibleForTesting + protected String getHostName(InetSocketAddress inetSocketAddr) { + return inetSocketAddr.getHostName(); + } + /** * Verifies whether the given value is allowed according to the given whitelist and blacklist settings. * Whitelist has precedence over blacklist: if a whitelist is set, the value is rejected if not present diff --git a/src/test/java/fr/xephi/authme/TestHelper.java b/src/test/java/fr/xephi/authme/TestHelper.java index baab8ca67..ad50c5119 100644 --- a/src/test/java/fr/xephi/authme/TestHelper.java +++ b/src/test/java/fr/xephi/authme/TestHelper.java @@ -11,13 +11,13 @@ import java.net.InetSocketAddress; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; +import java.net.UnknownHostException; import java.nio.file.Path; import java.nio.file.Paths; import java.util.logging.Logger; import static org.mockito.ArgumentMatchers.any; import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.mock; /** * AuthMe test utilities. @@ -98,11 +98,14 @@ public final class TestHelper { * @param player the player mock * @param ip the ip address it should return */ - public static void mockPlayerIp(Player player, String ip) { - InetAddress inetAddress = mock(InetAddress.class); - given(inetAddress.getHostAddress()).willReturn(ip); - InetSocketAddress inetSocketAddress = new InetSocketAddress(inetAddress, 8093); - given(player.getAddress()).willReturn(inetSocketAddress); + public static void mockIpAddressToPlayer(Player player, String ip) { + try { + InetAddress inetAddress = InetAddress.getByName(ip); + InetSocketAddress inetSocketAddress = new InetSocketAddress(inetAddress, 8093); + given(player.getAddress()).willReturn(inetSocketAddress); + } catch (UnknownHostException e) { + throw new IllegalStateException("Invalid IP address: " + ip, e); + } } /** diff --git a/src/test/java/fr/xephi/authme/command/executable/authme/GetIpCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/authme/GetIpCommandTest.java index 758bc5f34..8fe65e90b 100644 --- a/src/test/java/fr/xephi/authme/command/executable/authme/GetIpCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/authme/GetIpCommandTest.java @@ -100,7 +100,7 @@ public class GetIpCommandTest { private static Player mockPlayer(String name, String ip) { Player player = mock(Player.class); given(player.getName()).willReturn(name); - TestHelper.mockPlayerIp(player, ip); + TestHelper.mockIpAddressToPlayer(player, ip); return player; } } diff --git a/src/test/java/fr/xephi/authme/data/TempbanManagerTest.java b/src/test/java/fr/xephi/authme/data/TempbanManagerTest.java index 5c5264bdc..a186920a5 100644 --- a/src/test/java/fr/xephi/authme/data/TempbanManagerTest.java +++ b/src/test/java/fr/xephi/authme/data/TempbanManagerTest.java @@ -147,7 +147,7 @@ public class TempbanManagerTest { // given Player player = mock(Player.class); String ip = "123.45.67.89"; - TestHelper.mockPlayerIp(player, ip); + TestHelper.mockIpAddressToPlayer(player, ip); String banReason = "IP ban too many logins"; given(messages.retrieveSingle(player, MessageKey.TEMPBAN_MAX_LOGINS)).willReturn(banReason); Settings settings = mockSettings(2, 100, ""); @@ -175,7 +175,7 @@ public class TempbanManagerTest { Player player = mock(Player.class); given(player.getName()).willReturn("Bob"); String ip = "143.45.77.89"; - TestHelper.mockPlayerIp(player, ip); + TestHelper.mockIpAddressToPlayer(player, ip); String banCommand = "banip %ip% 15d IP ban too many logins"; Settings settings = mockSettings(2, 100, banCommand); TempbanManager manager = new TempbanManager(bukkitService, messages, settings); @@ -193,7 +193,7 @@ public class TempbanManagerTest { // given Player player = mock(Player.class); String ip = "22.44.66.88"; - TestHelper.mockPlayerIp(player, ip); + TestHelper.mockIpAddressToPlayer(player, ip); String banReason = "kick msg"; given(messages.retrieveSingle(player, MessageKey.TEMPBAN_MAX_LOGINS)).willReturn(banReason); Settings settings = mockSettings(10, 60, ""); 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 40e3076e1..673282a47 100644 --- a/src/test/java/fr/xephi/authme/process/login/AsynchronousLoginTest.java +++ b/src/test/java/fr/xephi/authme/process/login/AsynchronousLoginTest.java @@ -125,7 +125,7 @@ public class AsynchronousLoginTest { String name = "oscar"; String ip = "1.1.1.245"; Player player = mockPlayer(name); - TestHelper.mockPlayerIp(player, ip); + TestHelper.mockIpAddressToPlayer(player, ip); given(playerCache.isAuthenticated(name)).willReturn(false); PlayerAuth auth = PlayerAuth.builder().name(name).build(); given(dataSource.getAuth(name)).willReturn(auth); @@ -148,7 +148,7 @@ public class AsynchronousLoginTest { String name = "oscar"; String ip = "1.1.1.245"; Player player = mockPlayer(name); - TestHelper.mockPlayerIp(player, ip); + TestHelper.mockIpAddressToPlayer(player, ip); given(playerCache.isAuthenticated(name)).willReturn(false); PlayerAuth auth = PlayerAuth.builder().name(name).build(); given(dataSource.getAuth(name)).willReturn(auth); @@ -243,26 +243,26 @@ public class AsynchronousLoginTest { private void mockOnlinePlayersInBukkitService() { // 1.1.1.1: albania (online), brazil (offline) Player playerA = mockPlayer("albania"); - TestHelper.mockPlayerIp(playerA, "1.1.1.1"); + TestHelper.mockIpAddressToPlayer(playerA, "1.1.1.1"); given(dataSource.isLogged(playerA.getName())).willReturn(true); Player playerB = mockPlayer("brazil"); - TestHelper.mockPlayerIp(playerB, "1.1.1.1"); + TestHelper.mockIpAddressToPlayer(playerB, "1.1.1.1"); given(dataSource.isLogged(playerB.getName())).willReturn(false); // 2.2.2.2: congo (online), denmark (offline), ecuador (online) Player playerC = mockPlayer("congo"); - TestHelper.mockPlayerIp(playerC, "2.2.2.2"); + TestHelper.mockIpAddressToPlayer(playerC, "2.2.2.2"); given(dataSource.isLogged(playerC.getName())).willReturn(true); Player playerD = mockPlayer("denmark"); - TestHelper.mockPlayerIp(playerD, "2.2.2.2"); + TestHelper.mockIpAddressToPlayer(playerD, "2.2.2.2"); given(dataSource.isLogged(playerD.getName())).willReturn(false); Player playerE = mockPlayer("ecuador"); - TestHelper.mockPlayerIp(playerE, "2.2.2.2"); + TestHelper.mockIpAddressToPlayer(playerE, "2.2.2.2"); given(dataSource.isLogged(playerE.getName())).willReturn(true); // 3.3.3.3: france (offline) Player playerF = mockPlayer("france"); - TestHelper.mockPlayerIp(playerF, "3.3.3.3"); + TestHelper.mockIpAddressToPlayer(playerF, "3.3.3.3"); List onlinePlayers = Arrays.asList(playerA, playerB, playerC, playerD, playerE, playerF); given(bukkitService.getOnlinePlayers()).willReturn(onlinePlayers); diff --git a/src/test/java/fr/xephi/authme/process/register/AsyncRegisterTest.java b/src/test/java/fr/xephi/authme/process/register/AsyncRegisterTest.java index c61ed7f59..00e8be240 100644 --- a/src/test/java/fr/xephi/authme/process/register/AsyncRegisterTest.java +++ b/src/test/java/fr/xephi/authme/process/register/AsyncRegisterTest.java @@ -111,7 +111,7 @@ public class AsyncRegisterTest { // given String name = "edbert"; Player player = mockPlayerWithName(name); - TestHelper.mockPlayerIp(player, "33.44.55.66"); + TestHelper.mockIpAddressToPlayer(player, "33.44.55.66"); given(playerCache.isAuthenticated(name)).willReturn(false); given(commonService.getProperty(RegistrationSettings.IS_ENABLED)).willReturn(true); given(dataSource.isAuthAvailable(name)).willReturn(false); @@ -136,7 +136,7 @@ public class AsyncRegisterTest { // given String name = "edbert"; Player player = mockPlayerWithName(name); - TestHelper.mockPlayerIp(player, "33.44.55.66"); + TestHelper.mockIpAddressToPlayer(player, "33.44.55.66"); given(playerCache.isAuthenticated(name)).willReturn(false); given(commonService.getProperty(RegistrationSettings.IS_ENABLED)).willReturn(true); given(commonService.getProperty(RestrictionSettings.MAX_REGISTRATION_PER_IP)).willReturn(0); 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 c76c0fb36..a52b0075d 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 @@ -110,7 +110,7 @@ public class EmailRegisterExecutorTest { given(passwordSecurity.computeHash(anyString(), anyString())).willAnswer( invocation -> new HashedPassword(invocation.getArgument(0))); Player player = mock(Player.class); - TestHelper.mockPlayerIp(player, "123.45.67.89"); + TestHelper.mockIpAddressToPlayer(player, "123.45.67.89"); given(player.getName()).willReturn("Veronica"); EmailRegisterParams params = EmailRegisterParams.of(player, "test@example.com"); 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 6b41f2c1a..7e2e5fd01 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 @@ -97,7 +97,7 @@ public class PasswordRegisterExecutorTest { given(passwordSecurity.computeHash(anyString(), anyString())).willAnswer( invocation -> new HashedPassword(invocation.getArgument(0))); Player player = mockPlayerWithName("S1m0N"); - TestHelper.mockPlayerIp(player, "123.45.67.89"); + TestHelper.mockIpAddressToPlayer(player, "123.45.67.89"); PasswordRegisterParams params = PasswordRegisterParams.of(player, "pass", "mail@example.org"); // when 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 607ba8a43..cbe460dfb 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 @@ -25,7 +25,7 @@ public class PlayerAuthBuilderHelperTest { Player player = mock(Player.class); given(player.getName()).willReturn("Noah"); String ip = "192.168.34.47"; - TestHelper.mockPlayerIp(player, ip); + TestHelper.mockIpAddressToPlayer(player, ip); HashedPassword hashedPassword = new HashedPassword("myHash0001"); String email = "test@example.org"; diff --git a/src/test/java/fr/xephi/authme/service/PasswordRecoveryServiceTest.java b/src/test/java/fr/xephi/authme/service/PasswordRecoveryServiceTest.java index f0fc9b87c..bf3dd083f 100644 --- a/src/test/java/fr/xephi/authme/service/PasswordRecoveryServiceTest.java +++ b/src/test/java/fr/xephi/authme/service/PasswordRecoveryServiceTest.java @@ -78,15 +78,15 @@ public class PasswordRecoveryServiceTest { public void shouldKeepTrackOfSuccessfulRecoversByIp() { // given Player bobby = mock(Player.class); - TestHelper.mockPlayerIp(bobby, "192.168.8.8"); + TestHelper.mockIpAddressToPlayer(bobby, "192.168.8.8"); given(bobby.getName()).willReturn("bobby"); Player bobby2 = mock(Player.class); - TestHelper.mockPlayerIp(bobby2, "127.0.0.1"); + TestHelper.mockIpAddressToPlayer(bobby2, "127.0.0.1"); given(bobby2.getName()).willReturn("bobby"); Player other = mock(Player.class); - TestHelper.mockPlayerIp(other, "192.168.8.8"); + TestHelper.mockIpAddressToPlayer(other, "192.168.8.8"); given(other.getName()).willReturn("other"); // when @@ -102,12 +102,12 @@ public class PasswordRecoveryServiceTest { public void shouldRemovePlayerFromSuccessfulRecovers() { // given Player bobby = mock(Player.class); - TestHelper.mockPlayerIp(bobby, "192.168.8.8"); + TestHelper.mockIpAddressToPlayer(bobby, "192.168.8.8"); given(bobby.getName()).willReturn("bobby"); recoveryService.addSuccessfulRecovery(bobby); Player other = mock(Player.class); - TestHelper.mockPlayerIp(other, "8.8.8.8"); + TestHelper.mockIpAddressToPlayer(other, "8.8.8.8"); given(other.getName()).willReturn("other"); recoveryService.addSuccessfulRecovery(other); diff --git a/src/test/java/fr/xephi/authme/service/SessionServiceTest.java b/src/test/java/fr/xephi/authme/service/SessionServiceTest.java index ac2d64349..7153f1498 100644 --- a/src/test/java/fr/xephi/authme/service/SessionServiceTest.java +++ b/src/test/java/fr/xephi/authme/service/SessionServiceTest.java @@ -240,7 +240,7 @@ public class SessionServiceTest { private static Player mockPlayerWithNameAndIp(String name, String ip) { Player player = mock(Player.class); given(player.getName()).willReturn(name); - TestHelper.mockPlayerIp(player, ip); + TestHelper.mockIpAddressToPlayer(player, ip); return player; } } diff --git a/src/test/java/fr/xephi/authme/service/ValidationServiceTest.java b/src/test/java/fr/xephi/authme/service/ValidationServiceTest.java index dafc8c3dc..da8f16326 100644 --- a/src/test/java/fr/xephi/authme/service/ValidationServiceTest.java +++ b/src/test/java/fr/xephi/authme/service/ValidationServiceTest.java @@ -21,7 +21,9 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; import org.mockito.Mock; +import org.mockito.Mockito; +import java.net.InetSocketAddress; import java.util.Collections; import java.util.logging.Logger; @@ -30,7 +32,9 @@ 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.mockito.ArgumentMatchers.any; import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.willReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoInteractions; @@ -358,18 +362,23 @@ public class ValidationServiceTest { Player gabriel2 = mockPlayer("Gabriel", "93.23.33.34"); Player emanuel = mockPlayer("emanuel", "94.65.24.10"); Player emanuel2 = mockPlayer("emanuel", "94.65.60.10"); - Player imyourisp = mockPlayer("imyourisp", "bazinga.yourisp.net"); + Player imYourIsp = mockPlayer("imyourisp", "65.65.65.65"); Player notRestricted = mockPlayer("notRestricted", "0.0.0.0"); + ValidationService validationServiceSpy = Mockito.spy(validationService); + willReturn("bogus.tld").given(validationServiceSpy).getHostName(any(InetSocketAddress.class)); + InetSocketAddress imYourIspSocketAddr = imYourIsp.getAddress(); + willReturn("bazinga.yourisp.net").given(validationServiceSpy).getHostName(imYourIspSocketAddr); + // when - boolean isBobbyAdmitted = validationService.fulfillsNameRestrictions(bobby); - boolean isTamaraAdmitted = validationService.fulfillsNameRestrictions(tamara); - boolean isGabrielAdmitted = validationService.fulfillsNameRestrictions(gabriel); - boolean isGabriel2Admitted = validationService.fulfillsNameRestrictions(gabriel2); - boolean isEmanuelAdmitted = validationService.fulfillsNameRestrictions(emanuel); - boolean isEmanuel2Admitted = validationService.fulfillsNameRestrictions(emanuel2); - boolean isImyourispAdmitted = validationService.fulfillsNameRestrictions(imyourisp); - boolean isNotRestrictedAdmitted = validationService.fulfillsNameRestrictions(notRestricted); + boolean isBobbyAdmitted = validationServiceSpy.fulfillsNameRestrictions(bobby); + boolean isTamaraAdmitted = validationServiceSpy.fulfillsNameRestrictions(tamara); + boolean isGabrielAdmitted = validationServiceSpy.fulfillsNameRestrictions(gabriel); + boolean isGabriel2Admitted = validationServiceSpy.fulfillsNameRestrictions(gabriel2); + boolean isEmanuelAdmitted = validationServiceSpy.fulfillsNameRestrictions(emanuel); + boolean isEmanuel2Admitted = validationServiceSpy.fulfillsNameRestrictions(emanuel2); + boolean isImYourIspAdmitted = validationServiceSpy.fulfillsNameRestrictions(imYourIsp); + boolean isNotRestrictedAdmitted = validationServiceSpy.fulfillsNameRestrictions(notRestricted); // then assertThat(isBobbyAdmitted, equalTo(true)); @@ -378,7 +387,7 @@ public class ValidationServiceTest { assertThat(isGabriel2Admitted, equalTo(false)); assertThat(isEmanuelAdmitted, equalTo(true)); assertThat(isEmanuel2Admitted, equalTo(false)); - assertThat(isImyourispAdmitted, equalTo(true)); + assertThat(isImYourIspAdmitted, equalTo(true)); assertThat(isNotRestrictedAdmitted, equalTo(true)); } @@ -402,8 +411,7 @@ public class ValidationServiceTest { private static Player mockPlayer(String name, String ip) { Player player = mock(Player.class); given(player.getName()).willReturn(name); - TestHelper.mockPlayerIp(player, ip); - given(player.getAddress().getHostName()).willReturn("--"); + TestHelper.mockIpAddressToPlayer(player, ip); return player; } diff --git a/src/test/java/fr/xephi/authme/settings/WelcomeMessageConfigurationTest.java b/src/test/java/fr/xephi/authme/settings/WelcomeMessageConfigurationTest.java index 0be553d7b..3415a9507 100644 --- a/src/test/java/fr/xephi/authme/settings/WelcomeMessageConfigurationTest.java +++ b/src/test/java/fr/xephi/authme/settings/WelcomeMessageConfigurationTest.java @@ -92,7 +92,7 @@ public class WelcomeMessageConfigurationTest { Player player = mock(Player.class); given(player.getName()).willReturn("Bobby"); - TestHelper.mockPlayerIp(player, "123.45.66.77"); + TestHelper.mockIpAddressToPlayer(player, "123.45.66.77"); given(geoIpService.getCountryName("123.45.66.77")).willReturn("Syldavia"); given(service.getProperty(PluginSettings.SERVER_NAME)).willReturn("CrazyServer"); diff --git a/src/test/java/fr/xephi/authme/settings/commandconfig/CommandManagerTest.java b/src/test/java/fr/xephi/authme/settings/commandconfig/CommandManagerTest.java index a42a83a37..2a586c576 100644 --- a/src/test/java/fr/xephi/authme/settings/commandconfig/CommandManagerTest.java +++ b/src/test/java/fr/xephi/authme/settings/commandconfig/CommandManagerTest.java @@ -313,7 +313,7 @@ public class CommandManagerTest { given(player.getName()).willReturn("Bobby"); given(player.getDisplayName()).willReturn("bob"); String ip = "127.0.0.3"; - TestHelper.mockPlayerIp(player, ip); + TestHelper.mockIpAddressToPlayer(player, ip); given(geoIpService.getCountryName(ip)).willReturn("Syldavia"); return player; } diff --git a/src/test/java/fr/xephi/authme/util/PlayerUtilsTest.java b/src/test/java/fr/xephi/authme/util/PlayerUtilsTest.java index 124011c79..69d7b1f0d 100644 --- a/src/test/java/fr/xephi/authme/util/PlayerUtilsTest.java +++ b/src/test/java/fr/xephi/authme/util/PlayerUtilsTest.java @@ -25,7 +25,7 @@ public class PlayerUtilsTest { // given Player player = mock(Player.class); String ip = "124.86.248.62"; - TestHelper.mockPlayerIp(player, ip); + TestHelper.mockIpAddressToPlayer(player, ip); // when String result = PlayerUtils.getPlayerIp(player); From 9fd532d798850de56d6455df2002547876790ac2 Mon Sep 17 00:00:00 2001 From: ljacqu Date: Fri, 30 Dec 2022 08:44:29 +0100 Subject: [PATCH 81/97] Minor: Rename StringUtils#isEmpty to #isBlank - Better fits the naming used by other tools and also the JDK (String#isBlank as of JDK 11) --- .../authme/command/CommandDescription.java | 4 +-- .../xephi/authme/command/CommandHandler.java | 2 +- .../authme/debug/PlayerAuthViewer.java | 2 +- .../xephi/authme/listener/OnJoinVerifier.java | 2 +- .../fr/xephi/authme/mail/SendMailSsl.java | 4 +-- .../authme/permission/PermissionsManager.java | 2 +- .../authme/service/JoinMessageService.java | 2 +- .../settings/SettingsMigrationService.java | 2 +- .../fr/xephi/authme/settings/SpawnLoader.java | 4 +-- .../fr/xephi/authme/util/StringUtils.java | 28 ++++++++----------- src/main/java/fr/xephi/authme/util/Utils.java | 2 +- .../command/CommandInitializerTest.java | 4 +-- .../authme/ConverterCommandTest.java | 2 +- ...pMessageAndHelpSectionConsistencyTest.java | 4 +-- .../xephi/authme/message/MessageKeyTest.java | 2 +- .../message/MessagesFileConsistencyTest.java | 2 +- .../message/YamlTextFileCheckerTest.java | 2 +- .../HashAlgorithmIntegrationTest.java | 4 +-- .../fr/xephi/authme/util/StringUtilsTest.java | 12 ++++---- .../tools/messages/VerifyMessagesTask.java | 2 +- 20 files changed, 42 insertions(+), 46 deletions(-) diff --git a/src/main/java/fr/xephi/authme/command/CommandDescription.java b/src/main/java/fr/xephi/authme/command/CommandDescription.java index e195c4752..040894f95 100644 --- a/src/main/java/fr/xephi/authme/command/CommandDescription.java +++ b/src/main/java/fr/xephi/authme/command/CommandDescription.java @@ -226,8 +226,8 @@ public class CommandDescription { */ public CommandDescription build() { checkArgument(!Utils.isCollectionEmpty(labels), "Labels may not be empty"); - checkArgument(!StringUtils.isEmpty(description), "Description may not be empty"); - checkArgument(!StringUtils.isEmpty(detailedDescription), "Detailed description may not be empty"); + checkArgument(!StringUtils.isBlank(description), "Description may not be empty"); + checkArgument(!StringUtils.isBlank(detailedDescription), "Detailed description may not be empty"); checkArgument(executableCommand != null, "Executable command must be set"); // parents and permissions may be null; arguments may be empty diff --git a/src/main/java/fr/xephi/authme/command/CommandHandler.java b/src/main/java/fr/xephi/authme/command/CommandHandler.java index 27445e02e..08629c6f5 100644 --- a/src/main/java/fr/xephi/authme/command/CommandHandler.java +++ b/src/main/java/fr/xephi/authme/command/CommandHandler.java @@ -131,7 +131,7 @@ public class CommandHandler { private static List skipEmptyArguments(String[] args) { List cleanArguments = new ArrayList<>(); for (String argument : args) { - if (!StringUtils.isEmpty(argument)) { + if (!StringUtils.isBlank(argument)) { cleanArguments.add(argument); } } diff --git a/src/main/java/fr/xephi/authme/command/executable/authme/debug/PlayerAuthViewer.java b/src/main/java/fr/xephi/authme/command/executable/authme/debug/PlayerAuthViewer.java index ae314e098..99115cfe2 100644 --- a/src/main/java/fr/xephi/authme/command/executable/authme/debug/PlayerAuthViewer.java +++ b/src/main/java/fr/xephi/authme/command/executable/authme/debug/PlayerAuthViewer.java @@ -89,7 +89,7 @@ class PlayerAuthViewer implements DebugSection { * or empty string if the string is null or empty */ private static String safeSubstring(String str, int length) { - if (StringUtils.isEmpty(str)) { + if (StringUtils.isBlank(str)) { return ""; } else if (str.length() < length) { return str.substring(0, str.length() / 2) + "..."; diff --git a/src/main/java/fr/xephi/authme/listener/OnJoinVerifier.java b/src/main/java/fr/xephi/authme/listener/OnJoinVerifier.java index 9ceccbaf7..b125bf0a8 100644 --- a/src/main/java/fr/xephi/authme/listener/OnJoinVerifier.java +++ b/src/main/java/fr/xephi/authme/listener/OnJoinVerifier.java @@ -160,7 +160,7 @@ public class OnJoinVerifier implements Reloadable { if (auth != null && settings.getProperty(RegistrationSettings.PREVENT_OTHER_CASE)) { String realName = auth.getRealName(); // might be null or "Player" - if (StringUtils.isEmpty(realName) || "Player".equals(realName)) { + if (StringUtils.isBlank(realName) || "Player".equals(realName)) { dataSource.updateRealName(connectingName.toLowerCase(Locale.ROOT), connectingName); } else if (!realName.equals(connectingName)) { throw new FailedVerificationException(MessageKey.INVALID_NAME_CASE, realName, connectingName); diff --git a/src/main/java/fr/xephi/authme/mail/SendMailSsl.java b/src/main/java/fr/xephi/authme/mail/SendMailSsl.java index 8c7e1bfff..b7e9fd41f 100644 --- a/src/main/java/fr/xephi/authme/mail/SendMailSsl.java +++ b/src/main/java/fr/xephi/authme/mail/SendMailSsl.java @@ -51,11 +51,11 @@ public class SendMailSsl { * @throws EmailException if the mail is invalid */ public HtmlEmail initializeMail(String emailAddress) throws EmailException { - String senderMail = StringUtils.isEmpty(settings.getProperty(EmailSettings.MAIL_ADDRESS)) + String senderMail = StringUtils.isBlank(settings.getProperty(EmailSettings.MAIL_ADDRESS)) ? settings.getProperty(EmailSettings.MAIL_ACCOUNT) : settings.getProperty(EmailSettings.MAIL_ADDRESS); - String senderName = StringUtils.isEmpty(settings.getProperty(EmailSettings.MAIL_SENDER_NAME)) + String senderName = StringUtils.isBlank(settings.getProperty(EmailSettings.MAIL_SENDER_NAME)) ? senderMail : settings.getProperty(EmailSettings.MAIL_SENDER_NAME); String mailPassword = settings.getProperty(EmailSettings.MAIL_PASSWORD); diff --git a/src/main/java/fr/xephi/authme/permission/PermissionsManager.java b/src/main/java/fr/xephi/authme/permission/PermissionsManager.java index 113393d25..7399d0ca0 100644 --- a/src/main/java/fr/xephi/authme/permission/PermissionsManager.java +++ b/src/main/java/fr/xephi/authme/permission/PermissionsManager.java @@ -324,7 +324,7 @@ public class PermissionsManager implements Reloadable { * False is also returned if this feature isn't supported for the current permissions system. */ public boolean addGroup(OfflinePlayer player, UserGroup groupName) { - if (!isEnabled() || StringUtils.isEmpty(groupName.getGroupName())) { + if (!isEnabled() || StringUtils.isBlank(groupName.getGroupName())) { return false; } return handler.addToGroup(player, groupName); diff --git a/src/main/java/fr/xephi/authme/service/JoinMessageService.java b/src/main/java/fr/xephi/authme/service/JoinMessageService.java index 29f2caa04..d4c5b4c67 100644 --- a/src/main/java/fr/xephi/authme/service/JoinMessageService.java +++ b/src/main/java/fr/xephi/authme/service/JoinMessageService.java @@ -38,7 +38,7 @@ public class JoinMessageService { */ public void sendMessage(String playerName) { String joinMessage = joinMessages.remove(playerName); - if (!StringUtils.isEmpty(joinMessage)) { + if (!StringUtils.isBlank(joinMessage)) { bukkitService.broadcastMessage(joinMessage); } } diff --git a/src/main/java/fr/xephi/authme/settings/SettingsMigrationService.java b/src/main/java/fr/xephi/authme/settings/SettingsMigrationService.java index 2152baf5c..fe035a8b2 100644 --- a/src/main/java/fr/xephi/authme/settings/SettingsMigrationService.java +++ b/src/main/java/fr/xephi/authme/settings/SettingsMigrationService.java @@ -114,7 +114,7 @@ public class SettingsMigrationService extends PlainMigrationService { // Old other accounts // -------- public boolean hasOldOtherAccountsCommand() { - return !StringUtils.isEmpty(oldOtherAccountsCommand); + return !StringUtils.isBlank(oldOtherAccountsCommand); } public String getOldOtherAccountsCommand() { diff --git a/src/main/java/fr/xephi/authme/settings/SpawnLoader.java b/src/main/java/fr/xephi/authme/settings/SpawnLoader.java index 6a8b7fa72..47e9711de 100644 --- a/src/main/java/fr/xephi/authme/settings/SpawnLoader.java +++ b/src/main/java/fr/xephi/authme/settings/SpawnLoader.java @@ -293,7 +293,7 @@ public class SpawnLoader implements Reloadable { String prefix = pathPrefix + "."; String worldName = configuration.getString(prefix + "world"); World world = Bukkit.getWorld(worldName); - if (!StringUtils.isEmpty(worldName) && world != null) { + if (!StringUtils.isBlank(worldName) && world != null) { return new Location(world, configuration.getDouble(prefix + "x"), configuration.getDouble(prefix + "y"), configuration.getDouble(prefix + "z"), getFloat(configuration, prefix + "yaw"), getFloat(configuration, prefix + "pitch")); @@ -315,7 +315,7 @@ public class SpawnLoader implements Reloadable { String prefix = pathPrefix + "."; String worldName = configuration.getString(prefix + "World"); World world = Bukkit.getWorld(worldName); - if (!StringUtils.isEmpty(worldName) && world != null) { + if (!StringUtils.isBlank(worldName) && world != null) { return new Location(world, configuration.getDouble(prefix + "X"), configuration.getDouble(prefix + "Y"), configuration.getDouble(prefix + "Z"), getFloat(configuration, prefix + "Yaw"), getFloat(configuration, prefix + "Pitch")); diff --git a/src/main/java/fr/xephi/authme/util/StringUtils.java b/src/main/java/fr/xephi/authme/util/StringUtils.java index 5c8613005..8a8636786 100644 --- a/src/main/java/fr/xephi/authme/util/StringUtils.java +++ b/src/main/java/fr/xephi/authme/util/StringUtils.java @@ -14,12 +14,11 @@ public final class StringUtils { } /** - * Get the difference of two strings. + * Calculates the difference of two strings. * - * @param first First string - * @param second Second string - * - * @return The difference value + * @param first first string + * @param second second string + * @return the difference value */ public static double getDifference(String first, String second) { // Make sure the strings are valid. @@ -35,12 +34,11 @@ public final class StringUtils { } /** - * Return whether the given string contains any of the provided elements. + * Returns whether the given string contains any of the provided elements. * - * @param str The string to analyze - * @param pieces The items to check the string for - * - * @return True if the string contains at least one of the items + * @param str the string to analyze + * @param pieces the items to check the string for + * @return true if the string contains at least one of the items */ public static boolean containsAny(String str, Iterable pieces) { if (str == null) { @@ -58,21 +56,19 @@ public final class StringUtils { * Null-safe method for checking whether a string is empty. Note that the string * is trimmed, so this method also considers a string with whitespace as empty. * - * @param str The string to verify - * - * @return True if the string is empty, false otherwise + * @param str the string to verify + * @return true if the string is empty, false otherwise */ - public static boolean isEmpty(String str) { + public static boolean isBlank(String str) { return str == null || str.trim().isEmpty(); } /** - * Check that the given needle is in the middle of the haystack, i.e. that the haystack + * Checks that the given needle is in the middle of the haystack, i.e. that the haystack * contains the needle and that it is not at the very start or end. * * @param needle the needle to search for * @param haystack the haystack to search in - * * @return true if the needle is in the middle of the word, false otherwise */ // Note ljacqu 20170314: `needle` is restricted to char type intentionally because something like diff --git a/src/main/java/fr/xephi/authme/util/Utils.java b/src/main/java/fr/xephi/authme/util/Utils.java index 74c3088e3..4165b0078 100644 --- a/src/main/java/fr/xephi/authme/util/Utils.java +++ b/src/main/java/fr/xephi/authme/util/Utils.java @@ -105,6 +105,6 @@ public final class Utils { * @return true if the email is empty */ public static boolean isEmailEmpty(String email) { - return StringUtils.isEmpty(email) || "your@email.com".equalsIgnoreCase(email); + return StringUtils.isBlank(email) || "your@email.com".equalsIgnoreCase(email); } } diff --git a/src/test/java/fr/xephi/authme/command/CommandInitializerTest.java b/src/test/java/fr/xephi/authme/command/CommandInitializerTest.java index 964192f30..5cac2462a 100644 --- a/src/test/java/fr/xephi/authme/command/CommandInitializerTest.java +++ b/src/test/java/fr/xephi/authme/command/CommandInitializerTest.java @@ -138,11 +138,11 @@ public class CommandInitializerTest { String forCommandText = " for command with labels '" + command.getLabels() + "'"; assertThat("has description" + forCommandText, - StringUtils.isEmpty(command.getDescription()), equalTo(false)); + StringUtils.isBlank(command.getDescription()), equalTo(false)); assertThat("short description doesn't end in '.'" + forCommandText, command.getDescription().endsWith("."), equalTo(false)); assertThat("has detailed description" + forCommandText, - StringUtils.isEmpty(command.getDetailedDescription()), equalTo(false)); + StringUtils.isBlank(command.getDetailedDescription()), equalTo(false)); assertThat("detailed description ends in '.'" + forCommandText, command.getDetailedDescription().endsWith("."), equalTo(true)); } 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 22533acde..cad80f9f0 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 @@ -93,7 +93,7 @@ public class ConverterCommandTest { // when / then for (Map.Entry> entry : ConverterCommand.CONVERTERS.entrySet()) { assertThat("Name is not null or empty", - StringUtils.isEmpty(entry.getKey()), equalTo(false)); + StringUtils.isBlank(entry.getKey()), equalTo(false)); assertThat("Converter class is unique for each entry", classes.add(entry.getValue()), equalTo(true)); 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 c0841139f..02a42ba99 100644 --- a/src/test/java/fr/xephi/authme/command/help/HelpMessageAndHelpSectionConsistencyTest.java +++ b/src/test/java/fr/xephi/authme/command/help/HelpMessageAndHelpSectionConsistencyTest.java @@ -23,14 +23,14 @@ public class HelpMessageAndHelpSectionConsistencyTest { // when / then for (HelpMessage message : HelpMessage.values()) { assertThat("Key for message '" + message + "' is empty", - StringUtils.isEmpty(message.getKey()), equalTo(false)); + StringUtils.isBlank(message.getKey()), equalTo(false)); if (!keys.add(message.getKey())) { fail("Key for message '" + message + "' is already used elsewhere"); } } for (HelpSection section : HelpSection.values()) { assertThat("Key for section '" + section + "' is empty", - StringUtils.isEmpty(section.getKey()), equalTo(false)); + StringUtils.isBlank(section.getKey()), equalTo(false)); if (!keys.add(section.getKey())) { fail("Key for section '" + section + "' is already used elsewhere"); } diff --git a/src/test/java/fr/xephi/authme/message/MessageKeyTest.java b/src/test/java/fr/xephi/authme/message/MessageKeyTest.java index b28116341..c60305d68 100644 --- a/src/test/java/fr/xephi/authme/message/MessageKeyTest.java +++ b/src/test/java/fr/xephi/authme/message/MessageKeyTest.java @@ -27,7 +27,7 @@ public class MessageKeyTest { String key = messageKey.getKey(); if (!keys.add(key)) { fail("Found key '" + messageKey.getKey() + "' twice!"); - } else if (StringUtils.isEmpty(key)) { + } else if (StringUtils.isBlank(key)) { fail("Key for message key '" + messageKey + "' is empty"); } } diff --git a/src/test/java/fr/xephi/authme/message/MessagesFileConsistencyTest.java b/src/test/java/fr/xephi/authme/message/MessagesFileConsistencyTest.java index 1679e9ac3..5243528fc 100644 --- a/src/test/java/fr/xephi/authme/message/MessagesFileConsistencyTest.java +++ b/src/test/java/fr/xephi/authme/message/MessagesFileConsistencyTest.java @@ -40,7 +40,7 @@ public class MessagesFileConsistencyTest { final String key = messageKey.getKey(); final String message = reader.getString(key); - if (StringUtils.isEmpty(message)) { + if (StringUtils.isBlank(message)) { errors.add("Messages file should have message for key '" + key + "'"); return; } diff --git a/src/test/java/fr/xephi/authme/message/YamlTextFileCheckerTest.java b/src/test/java/fr/xephi/authme/message/YamlTextFileCheckerTest.java index 98a87e757..59c7b1b5a 100644 --- a/src/test/java/fr/xephi/authme/message/YamlTextFileCheckerTest.java +++ b/src/test/java/fr/xephi/authme/message/YamlTextFileCheckerTest.java @@ -81,7 +81,7 @@ public class YamlTextFileCheckerTest { private void checkFile(File file, String mandatoryKey, List errors) { try { PropertyReader reader = new YamlFileReader(file); - if (StringUtils.isEmpty(reader.getString(mandatoryKey))) { + if (StringUtils.isBlank(reader.getString(mandatoryKey))) { errors.add("Message for '" + mandatoryKey + "' is empty"); } } catch (Exception e) { diff --git a/src/test/java/fr/xephi/authme/security/HashAlgorithmIntegrationTest.java b/src/test/java/fr/xephi/authme/security/HashAlgorithmIntegrationTest.java index e59dae647..8ebcbda1e 100644 --- a/src/test/java/fr/xephi/authme/security/HashAlgorithmIntegrationTest.java +++ b/src/test/java/fr/xephi/authme/security/HashAlgorithmIntegrationTest.java @@ -74,9 +74,9 @@ public class HashAlgorithmIntegrationTest { } HashedPassword hashedPassword = method.computeHash("pwd", "name"); assertThat("Salt should not be null if method.hasSeparateSalt(), and vice versa. Method: '" - + method + "'", StringUtils.isEmpty(hashedPassword.getSalt()), equalTo(!method.hasSeparateSalt())); + + method + "'", StringUtils.isBlank(hashedPassword.getSalt()), equalTo(!method.hasSeparateSalt())); assertThat("Hash should not be empty for method '" + method + "'", - StringUtils.isEmpty(hashedPassword.getHash()), equalTo(false)); + StringUtils.isBlank(hashedPassword.getHash()), equalTo(false)); } } } diff --git a/src/test/java/fr/xephi/authme/util/StringUtilsTest.java b/src/test/java/fr/xephi/authme/util/StringUtilsTest.java index 39a3eb934..fcd000d95 100644 --- a/src/test/java/fr/xephi/authme/util/StringUtilsTest.java +++ b/src/test/java/fr/xephi/authme/util/StringUtilsTest.java @@ -49,15 +49,15 @@ public class StringUtilsTest { } @Test - public void shouldCheckIsEmptyUtil() { + public void shouldCheckIfIsBlankString() { // Should be true for null/empty/whitespace - assertTrue(StringUtils.isEmpty(null)); - assertTrue(StringUtils.isEmpty("")); - assertTrue(StringUtils.isEmpty(" \t")); + assertTrue(StringUtils.isBlank(null)); + assertTrue(StringUtils.isBlank("")); + assertTrue(StringUtils.isBlank(" \t")); // Should be false if string has content - assertFalse(StringUtils.isEmpty("P")); - assertFalse(StringUtils.isEmpty(" test")); + assertFalse(StringUtils.isBlank("P")); + assertFalse(StringUtils.isBlank(" test")); } @Test diff --git a/src/test/java/tools/messages/VerifyMessagesTask.java b/src/test/java/tools/messages/VerifyMessagesTask.java index 5b8407c7e..04e17bba9 100644 --- a/src/test/java/tools/messages/VerifyMessagesTask.java +++ b/src/test/java/tools/messages/VerifyMessagesTask.java @@ -44,7 +44,7 @@ public final class VerifyMessagesTask implements ToolTask { boolean addMissingKeys = "y".equalsIgnoreCase(scanner.nextLine()); List messageFiles; - if (StringUtils.isEmpty(inputFile)) { + if (StringUtils.isBlank(inputFile)) { messageFiles = getMessagesFiles(); } else { File customFile = new File(MAIN_RESOURCES_ROOT, MessagePathHelper.createMessageFilePath(inputFile)); From c4d1c41059c8e120f12b7ac978f089bf61e47c84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8C=AB=E5=8F=88=E3=81=8A=E3=81=AB=E3=81=8E=E3=82=8A?= Date: Wed, 3 May 2023 13:37:12 +0800 Subject: [PATCH 82/97] Update messages_zhtw.yml --- src/main/resources/messages/messages_zhtw.yml | 172 +++++++++--------- 1 file changed, 86 insertions(+), 86 deletions(-) diff --git a/src/main/resources/messages/messages_zhtw.yml b/src/main/resources/messages/messages_zhtw.yml index db18e4ad0..104839adb 100644 --- a/src/main/resources/messages/messages_zhtw.yml +++ b/src/main/resources/messages/messages_zhtw.yml @@ -7,132 +7,132 @@ # Registration registration: - disabled: '&b【AuthMe】&6已關閉註冊功能' - name_taken: '&b【AuthMe】&6這個帳號已經被註冊過了!' + disabled: '&b【AuthMe】&6已關閉註冊功能。' + name_taken: '&b【AuthMe】&6這個帳號已經被註冊過了!' register_request: '&b【AuthMe】&6請使用 "&c/register <密碼> <確認密碼>" 來註冊。' command_usage: '&b【AuthMe】&6用法: &c"/register <密碼> <確認密碼>"' - reg_only: '&b【AuthMe】&6請到下列網站 :「 https://example.tw 」 進行註冊' - success: '&b【AuthMe】&6您已成功註冊' - kicked_admin_registered: '&b【AuthMe】&6管理員已協助您註冊,請重新登入' + reg_only: '&b【AuthMe】&6請到下列網站:「 https://example.tw 」進行註冊。' + success: '&b【AuthMe】&6您已成功註冊!' + kicked_admin_registered: '&b【AuthMe】&6管理員已協助您註冊,請重新登入。' # Password errors on registration password: - match_error: '&b【AuthMe】&6兩次輸入的密碼不一致!' - name_in_password: '&b【AuthMe】&6您不可以用您的 ID (遊戲名稱) 來當作密碼 !' - unsafe_password: '&b【AuthMe】&6您不可以使用這個不安全的密碼' - forbidden_characters: '&b【AuthMe】&c密碼包含非法字符. 可使用: %valid_chars' + match_error: '&b【AuthMe】&6兩次輸入的密碼不一致!' + name_in_password: '&b【AuthMe】&6您不可以用您的 ID (遊戲名稱) 來當作密碼!' + unsafe_password: '&b【AuthMe】&6您不可以使用這個不安全的密碼!' + forbidden_characters: '&b【AuthMe】&c密碼包含非法字符,可使用:%valid_chars' wrong_length: '&b【AuthMe】&6您的密碼 超過最大字數 / 小於最小字數' # Login login: command_usage: '&b【AuthMe】&6用法: &c"/login <密碼>"' - wrong_password: '&b【AuthMe】&6密碼錯誤!' - success: '&b【AuthMe】&6密碼正確,您已成功登入!' + wrong_password: '&b【AuthMe】&6密碼錯誤!' + success: '&b【AuthMe】&6密碼正確,您已成功登入!' login_request: '&b【AuthMe】&6請使用 &c"/login <密碼>" &6來登入。' - timeout_error: '&b【AuthMe】&6超過登入時間,請稍後再試一次' + timeout_error: '&b【AuthMe】&6超過登入時間,請稍後再試一次。' # Errors error: - denied_command: '&b【AuthMe】&c使用指令之前必須通過驗證!' - denied_chat: '&b【AuthMe】&c說話之前必須通過驗證!' - unregistered_user: '&b【AuthMe】&6這個帳號還沒有註冊過' - not_logged_in: '&b【AuthMe】&6您還沒有登入!' + denied_command: '&b【AuthMe】&c使用指令之前必須通過驗證!' + denied_chat: '&b【AuthMe】&c說話之前必須通過驗證!' + unregistered_user: '&b【AuthMe】&6這個帳號還沒有註冊過。' + not_logged_in: '&b【AuthMe】&6您還沒有登入!' no_permission: '&b【AuthMe】&6您沒有使用該指令的權限。' unexpected_error: '&b【AuthMe】&6發生錯誤,請聯繫管理員' - max_registration: '&b【AuthMe】&6您的 IP 位置所註冊的帳號數量已經達到最大。' - logged_in: '&b【AuthMe】&6您已經登入了!' - kick_for_vip: '&b【AuthMe】&6您已經被請出。&c原因 : 有 VIP 玩家登入伺服器' - # TODO kick_unresolved_hostname: '&cAn error occurred: unresolved player hostname!' - tempban_max_logins: '&b【AuthMe】&c您已被暫時封鎖IP位置,因為您登入失敗太多次.' + max_registration: '&b【AuthMe】&6您的 IP 位置所註冊的帳號數量已經達到最大限制。' + logged_in: '&b【AuthMe】&6您已經登入了!' + kick_for_vip: '&b【AuthMe】&6您已經被請出。&c原因:有 VIP 玩家登入伺服器' + kick_unresolved_hostname: '&b【AuthMe】&6無法解析玩家主機名稱。' + tempban_max_logins: '&b【AuthMe】&c您已被暫時封鎖IP位置,因為您登入失敗太多次。' # AntiBot antibot: kick_antibot: '&b【AuthMe】&cAntiBotMod 正在啟用中,請稍後再嘗試登入吧!' - auto_enabled: '&b【AuthMe】&6AntiBotMod 已自動啟用!' - auto_disabled: '&b【AuthMe】&6AntiBotMod 將會於 &c%m &6分鐘後自動關閉' + auto_enabled: '&b【AuthMe】&6AntiBotMod 已自動啟用!' + auto_disabled: '&b【AuthMe】&6AntiBotMod 將於 &c%m &6分鐘後自動關閉' # Unregister unregister: success: '&b【AuthMe】&6您已經成功註銷。' - command_usage: '&b【AuthMe】&6用法: &c"/unregister <密碼>"' + command_usage: '&b【AuthMe】&6用法:&c"/unregister <密碼>"' # Other messages misc: - account_not_activated: '&b【AuthMe】&6您的帳號還沒有經過驗證! 檢查看看您的電子信箱 (Email) 吧!' - password_changed: '&b【AuthMe】&6密碼變更成功!' - logout: '&b【AuthMe】&6您已成功登出' - reload: '&b【AuthMe】&6已重新讀取設定檔及資料庫' - usage_change_password: '&b【AuthMe】&6用法: &c"/changepassword <舊密碼> <新密碼>"' - accounts_owned_self: '&b【AuthMe】&6您擁有 %count 個帳號:' - accounts_owned_other: '&b【AuthMe】&6玩家 %name 擁有 %count 個帳號:' + account_not_activated: '&b【AuthMe】&6您的帳號還沒有經過驗證!檢查看看您的電子郵件 (Email) 吧!' + password_changed: '&b【AuthMe】&6密碼變更成功!' + logout: '&b【AuthMe】&6您已成功登出。' + reload: '&b【AuthMe】&6已重新讀取設定檔及資料庫。' + usage_change_password: '&b【AuthMe】&6用法:&c"/changepassword <舊密碼> <新密碼>"' + accounts_owned_self: '&b【AuthMe】&6您擁有 %count 個帳號:' + accounts_owned_other: '&b【AuthMe】&6玩家 %name 擁有 %count 個帳號:' # Session messages session: - valid_session: '&b【AuthMe】&6您已經成功登入!' - invalid_session: '&b【AuthMe】&6Session驗證不相符!' + valid_session: '&b【AuthMe】&6您已經成功登入!' + invalid_session: '&b【AuthMe】&6Session驗證不相符!' # Error messages when joining on_join_validation: - same_ip_online: '&b【AuthMe】&6同樣IP玩家在線上!' - same_nick_online: '&b【AuthMe】&6有同樣帳號的玩家在線上!' - name_length: '&b【AuthMe】&6您的暱稱 太長 / 太短 了!' + same_ip_online: '&b【AuthMe】&6相同IP玩家在線上!' + same_nick_online: '&b【AuthMe】&6有同樣帳號的玩家在線上!' + name_length: '&b【AuthMe】&6您的暱稱 太長 / 太短 了!' characters_in_name: '&b【AuthMe】&6暱稱裡能使用的字符為: %valid_chars' - kick_full_server: '&b【AuthMe】&6伺服器已經滿了,請等等再試一次' - country_banned: '&b【AuthMe】&6您所在的地區無法進入此伺服器' + kick_full_server: '&b【AuthMe】&6伺服器已經滿了,請等等再試一次。' + country_banned: '&b【AuthMe】&6您所在的地區無法進入此伺服器。' not_owner_error: '&b【AuthMe】&4警告!&c您並不是此帳戶持有人,請立即登出。' invalid_name_case: '&b【AuthMe】&4警告!&c您應該使用「%valid」而並非「%invalid」登入遊戲。' - # TODO quick_command: 'You used a command too fast! Please, join the server again and wait more before using any command.' + quick_command: '&b【AuthMe】&4指令使用過快,請加入伺服器後稍等一下再使用指令。' # Email email: - add_email_request: '&b【AuthMe】&6請使用 &c"/email add <您的Email> <再次輸入您的Email>" &6來添加 Email' - usage_email_add: '&b【AuthMe】&6用法: &c"/email add <您的Email> <重複Email>"' - usage_email_change: '&b【AuthMe】&6用法: &c"/email change <舊的Email> <新的Email>"' - new_email_invalid: '&b【AuthMe】&6新的Email無效!' - old_email_invalid: '&b【AuthMe】&6舊的Email無效!' - invalid: '&b【AuthMe】&6無效的Email!' - added: '&b【AuthMe】&6已添加Email!' - # TODO add_not_allowed: '&cAdding email was not allowed' - request_confirmation: '&b【AuthMe】&6請驗證您的Email!' - changed: '&b【AuthMe】&6Email已變更!' - # TODO change_not_allowed: '&cChanging email was not allowed' - email_show: '&b【AuthMe】&2目前的電子郵件: &f%email' - no_email_for_account: '&b【AuthMe】&2您目前沒有設置電子郵件.' - already_used: '&b【AuthMe】&4這個電郵地址已被使用。' - incomplete_settings: '&b【AuthMe】&4因為電子郵件設定無完整導致無法傳送,請聯絡管理員.' - send_failure: '&b【AuthMe】&4無法傳送電子郵件,請聯絡管理員.' - change_password_expired: '&b【AuthMe】&6您現在不能使用這個指令變更密碼了.' - email_cooldown_error: '&b【AuthMe】&c電子郵件已經寄出了. 您只能在 %time 後才能傳送.' + add_email_request: '&b【AuthMe】&6請使用 &c"/email add <電子郵件> <再次輸入電子郵件>" &6來新增電子郵件' + usage_email_add: '&b【AuthMe】&6用法: &c"/email add <電子郵件> <再次輸入電子郵件>"' + usage_email_change: '&b【AuthMe】&6用法: &c"/email change <舊的電子郵件> <新的電子郵件>"' + new_email_invalid: '&b【AuthMe】&6新的電子郵件無效!' + old_email_invalid: '&b【AuthMe】&6舊的電子郵件無效!' + invalid: '&b【AuthMe】&6無效的電子郵件!' + added: '&b【AuthMe】&6已新增電子郵件!' + add_not_allowed: '&b【AuthMe】&c不允許新增電子郵件' + request_confirmation: '&b【AuthMe】&6請驗證您的電子郵件!' + changed: '&b【AuthMe】&6電子郵件已變更!' + change_not_allowed: '&b【AuthMe】&c不允許變更電子郵件' + email_show: '&b【AuthMe】&2目前的電子郵件:&f%email' + no_email_for_account: '&b【AuthMe】&2您目前沒有設定電子郵件。' + already_used: '&b【AuthMe】&4這個電子郵件已被使用。' + incomplete_settings: '&b【AuthMe】&4因為電子郵件設定不完整導致無法傳送,請聯絡管理員。' + send_failure: '&b【AuthMe】&4無法傳送電子郵件,請聯絡管理員。' + change_password_expired: '&b【AuthMe】&6您現在不能使用這個指令變更密碼了。' + email_cooldown_error: '&b【AuthMe】&c電子郵件已經寄出了,您只能在 %time 後才能傳送。' # Password recovery by email recovery: - forgot_password_hint: '&b【AuthMe】&6忘記密碼了嗎? 使用 &c"/email recovery <您的Email>"' - command_usage: '&b【AuthMe】&6用法: &c"/email recovery <您的Email>"' - email_sent: '&b【AuthMe】&6已經送出重設密碼要求至您的Email , 請查收。' + forgot_password_hint: '&b【AuthMe】&6忘記密碼了嗎?使用 &c"/email recovery <電子郵件>"' + command_usage: '&b【AuthMe】&6用法: &c"/email recovery <電子郵件>"' + email_sent: '&b【AuthMe】&6已經送出重設密碼要求至您的電子郵件,請查收。' code: - code_sent: '&b【AuthMe】&6忘記密碼的恢復密碼電子郵件已傳送至您的信箱中.' - incorrect: '&b【AuthMe】&6恢復密碼錯誤! 您剩餘 %count 次嘗試機會.' - tries_exceeded: '&b【AuthMe】&6恢復密碼過多次數錯誤. 使用 "/email recovery [email]" 取得新的恢復密碼.' - correct: '&b【AuthMe】&6恢復密碼正確!' - change_password: '&b【AuthMe】&6請使用 "/email setpassword <新密碼>" 變更您的密碼.' + code_sent: '&b【AuthMe】&6忘記密碼的恢復密碼電子郵件已傳送至您的信箱中。' + incorrect: '&b【AuthMe】&6恢復密碼錯誤!您剩餘 %count 次嘗試機會。' + tries_exceeded: '&b【AuthMe】&6恢復密碼過多次數錯誤。使用 "/email recovery [電子郵件]" 取得新的恢復密碼。' + correct: '&b【AuthMe】&6恢復密碼正確!' + change_password: '&b【AuthMe】&6請使用 "/email setpassword <新密碼>" 變更您的密碼。' # Captcha captcha: - usage_captcha: '&b【AuthMe】&6請用 &c"/captcha %captcha_code" &6來輸入您的驗證碼.' - wrong_captcha: '&b【AuthMe】&6錯誤的驗證碼,請使用 "/captcha %captcha_code" 再試一次.' - valid_captcha: '&b【AuthMe】&6驗證碼無效!' - # TODO captcha_for_registration: 'To register you have to solve a captcha first, please use the command: /captcha %captcha_code' - # TODO register_captcha_valid: '&2Valid captcha! You may now register with /register' + usage_captcha: '&b【AuthMe】&6請用 &c"/captcha %captcha_code" &6來輸入您的驗證碼。' + wrong_captcha: '&b【AuthMe】&6錯誤的驗證碼,請使用 "/captcha %captcha_code" 再試一次。' + valid_captcha: '&b【AuthMe】&6驗證碼無效。' + captcha_for_registration: '&b【AuthMe】&6註冊前必須先提供驗證碼,使用 /captcha %captcha_code 來驗證。' + register_captcha_valid: '&b【AuthMe】&2驗證已通過,現在可以使用 /register 來進行註冊了。' # Verification code verification: - code_required: '&b【AuthMe】&3敏感指令,需要電子郵件驗證後才能執行,請檢查電子郵件.' - command_usage: '&b【AuthMe】&c用法: /verification <驗證碼>' + code_required: '&b【AuthMe】&3敏感指令,需要電子郵件驗證後才能執行,請檢查電子郵件。' + command_usage: '&b【AuthMe】&c用法:/verification <驗證碼>' incorrect_code: '&b【AuthMe】&c驗證碼錯誤,請在聊天室使用 "/verification <驗證碼>" 電子郵件收到的驗證碼' - success: '&b【AuthMe】&2身分已驗證,您現在可以使用所有指令!' - already_verified: '&b【AuthMe】&2您已經可以使用所有指令!' - code_expired: '&b【AuthMe】&3驗證碼已過期,請使用其他敏感指令來取得新的驗證碼!' - email_needed: '&b【AuthMe】&3若需要身分驗證,請先添加電子郵件!!' + success: '&b【AuthMe】&2身分已驗證,您現在可以使用所有指令!' + already_verified: '&b【AuthMe】&2您已經可以使用所有指令!' + code_expired: '&b【AuthMe】&3驗證碼已過期,請使用其他敏感指令來取得新的驗證碼!' + email_needed: '&b【AuthMe】&3若需要身分驗證,請先新增電子郵件!' # Time units time: @@ -147,13 +147,13 @@ time: # Two-factor authentication two_factor: - code_created: '&b【AuthMe - 兩步驗證碼】&b您的登入金鑰為&9「%c%code&9」&b,掃描連結為:&c %url' - # TODO confirmation_required: 'Please confirm your code with /2fa confirm ' - # TODO code_required: 'Please submit your two-factor authentication code with /2fa code ' - # TODO already_enabled: 'Two-factor authentication is already enabled for your account!' - # TODO enable_error_no_code: 'No 2fa key has been generated for you or it has expired. Please run /2fa add' - # TODO enable_success: 'Successfully enabled two-factor authentication for your account' - # TODO enable_error_wrong_code: 'Wrong code or code has expired. Please run /2fa add' - # TODO not_enabled_error: 'Two-factor authentication is not enabled for your account. Run /2fa add' - # TODO removed_success: 'Successfully removed two-factor auth from your account' - # TODO invalid_code: 'Invalid code!' + code_created: '&b【AuthMe】&b您的登入金鑰為&9「%c%code&9」&b,掃描連結為:&c %url' + confirmation_required: '&b【AuthMe】&6請使用 /2fa confirm <驗證碼> 來確認雙重驗證。' + code_required: '&b【AuthMe】&c請使用 /2fa code <驗證碼> 來完成驗證。' + already_enabled: '&b【AuthMe】&c雙重驗證已經開啟。' + enable_error_no_code: '&b【AuthMe】&6雙重驗證代碼不存在或失效,使用 /2fa add 來新增。' + enable_success: '&b【AuthMe】&6雙重驗證已開啟!' + enable_error_wrong_code: '&b【AuthMe】&6雙重驗證代碼錯誤或失效,使用 /2fa add 來新增。' + not_enabled_error: '&b【AuthMe】&6雙重驗證尚未開啟,使用 /2fa add 來開啟。' + removed_success: '&b【AuthMe】&6雙重驗證已成功移除!' + invalid_code: '&b【AuthMe】&c驗證碼錯誤。' From db04fd2a5b80e47664ceae38a2e6587160230787 Mon Sep 17 00:00:00 2001 From: ljacqu Date: Tue, 20 Jun 2023 17:03:06 +0200 Subject: [PATCH 83/97] Avoid setting field with reflection on a JDK class - fails on newer JDK versions --- .../fr/xephi/authme/util/ExceptionUtilsTest.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/test/java/fr/xephi/authme/util/ExceptionUtilsTest.java b/src/test/java/fr/xephi/authme/util/ExceptionUtilsTest.java index e6931b082..b42fa97f7 100644 --- a/src/test/java/fr/xephi/authme/util/ExceptionUtilsTest.java +++ b/src/test/java/fr/xephi/authme/util/ExceptionUtilsTest.java @@ -40,10 +40,10 @@ public class ExceptionUtilsTest { @Test public void shouldHandleCircularCausesGracefully() { // given - IllegalStateException ise = new IllegalStateException(); - UnsupportedOperationException uoe = new UnsupportedOperationException(ise); + ExceptionWithSettableCause exceptionWithSettableCause = new ExceptionWithSettableCause(); + UnsupportedOperationException uoe = new UnsupportedOperationException(exceptionWithSettableCause); ReflectiveOperationException roe = new ReflectiveOperationException(uoe); - ReflectionTestUtils.setField(Throwable.class, ise, "cause", roe); + exceptionWithSettableCause.cause = roe; // when NullPointerException resultNpe = ExceptionUtils.findThrowableInCause(NullPointerException.class, uoe); @@ -65,4 +65,14 @@ public class ExceptionUtilsTest { // then assertThat(result, equalTo("[MalformedURLException]: Unrecognized URL format")); } + + private static final class ExceptionWithSettableCause extends Exception { + + Exception cause; + + @Override + public synchronized Throwable getCause() { + return cause; + } + } } From df6931d4b1c6526acbb79df712dfb65960dd0702 Mon Sep 17 00:00:00 2001 From: Ramune Date: Wed, 21 Jun 2023 19:00:21 +0900 Subject: [PATCH 84/97] Add Japanese (#2719) --- src/main/resources/messages/help_ja.yml | 45 ++++++ src/main/resources/messages/messages_ja.yml | 156 ++++++++++++++++++++ 2 files changed, 201 insertions(+) create mode 100644 src/main/resources/messages/help_ja.yml create mode 100644 src/main/resources/messages/messages_ja.yml diff --git a/src/main/resources/messages/help_ja.yml b/src/main/resources/messages/help_ja.yml new file mode 100644 index 000000000..830275e45 --- /dev/null +++ b/src/main/resources/messages/help_ja.yml @@ -0,0 +1,45 @@ +# Translation config for the AuthMe help, e.g. when /authme help or /authme help register is called + +# ------------------------------------------------------- +# List of texts used in the help section +common: + header: '==========[ AuthMeReloaded ヘルプ ]==========' + optional: 'オプション' + hasPermission: '権限を持っています' + noPermission: '権限がありません' + default: 'デフォルト' + result: '結果' + defaultPermissions: + notAllowed: '権限がありません' + opOnly: 'OPのみ' + allowed: '全員に許可' + +# ------------------------------------------------------- +# Titles of the individual help sections +# Set the translation text to empty text to disable the section, e.g. to hide alternatives: +# alternatives: '' +section: + command: 'コマンド' + description: '簡単な説明' + detailedDescription: '詳細な説明' + arguments: '引数' + permissions: '権限' + alternatives: '代替' + children: 'コマンド' + +# ------------------------------------------------------- +# You can translate the data for all commands using the below pattern. +# For example to translate /authme reload, create a section "authme.reload", or "login" for /login +# If the command has arguments, you can use arg1 as below to translate the first argument, and so forth +# Translations don't need to be complete; any missing section will be taken from the default silently +# Important: Put main commands like "authme" before their children (e.g. "authme.reload") +commands: + authme.register: + description: 'プレイヤーを登録します' + detailedDescription: '指定されたプレイヤーを指定されたパスワードで登録します。' + arg1: + label: 'プレイヤー名' + description: 'プレイヤー名' + arg2: + label: 'パスワード' + description: 'パスワード' diff --git a/src/main/resources/messages/messages_ja.yml b/src/main/resources/messages/messages_ja.yml new file mode 100644 index 000000000..409f8c80f --- /dev/null +++ b/src/main/resources/messages/messages_ja.yml @@ -0,0 +1,156 @@ +# List of global tags: +# %nl% - Goes to new line. +# %username% - Replaces the username of the player receiving the message. +# %displayname% - Replaces the nickname (and colors) of the player receiving the message. + +# Registration +registration: + register_request: '&3サーバーに登録するには、次のコマンドを使用してください: /register <パスワード> <パスワードの確認>' + command_usage: '&c使用方法: /register <パスワード> <パスワードの確認>' + reg_only: '&4登録済みのユーザーのみサーバーに参加できます! 自分自身を登録するには、http://example.com にアクセスしてください!' + kicked_admin_registered: '管理者があなたを登録しました。再度ログインしてください。' + success: '&2登録が完了しました!' + disabled: '&cゲーム内での登録は無効になっています!' + name_taken: '&cこのユーザー名はすでに登録されています!' + +# Password errors on registration +password: + match_error: '&cパスワードが一致しません。もう一度確認してください!' + name_in_password: '&cパスワードには自分の名前を使用することはできません。別のパスワードを選択してください...' + unsafe_password: '&c選択したパスワードは安全ではありません。別のパスワードを選択してください...' + forbidden_characters: '&4パスワードに不正な文字が含まれています。許可されている文字: %valid_chars' + wrong_length: '&cパスワードが短すぎるか長すぎます!別のパスワードを試してください!' + +# Login +login: + command_usage: '&c使用方法: /login <パスワード>' + wrong_password: '&cパスワードが間違っています!' + success: '&2ログインが成功しました!' + login_request: '&c次のコマンドを使用してログインしてください: /login <パスワード>' + timeout_error: '&4ログインのタイムアウトが発生しました。サーバーからキックされました。もう一度試してください!' + +# Errors +error: + unregistered_user: '&cこのユーザーは登録されていません!' + denied_command: '&cこのコマンドを使用するには認証が必要です!' + denied_chat: '&cチャットするには認証が必要です!' + not_logged_in: '&cログインしていません!' + tempban_max_logins: '&cログインに失敗した回数が多すぎるため、一時的にアクセスが制限されています。' + max_registration: '&c接続ごとの登録数が最大値を超えています(%reg_count/%max_acc %reg_names)!' + no_permission: '&4この操作を実行する権限がありません!' + unexpected_error: '&4予期しないエラーが発生しました。管理者に連絡してください!' + kick_for_vip: '&3VIPプレイヤーがサーバーが満員の状態で参加しました!' + logged_in: '&cすでにログイン済みです!' + kick_unresolved_hostname: '&cエラーが発生しました:解決できないプレイヤーのホスト名!' + +# AntiBot +antibot: + kick_antibot: 'AntiBot保護モードが有効です!サーバーに参加するまでにしばらくお待ちください。' + auto_enabled: '&4[AntiBotService] 接続数が非常に多いため、AntiBotが有効になりました!' + auto_disabled: '&2[AntiBotService] %m 分後にAntiBotが無効になりました!' + +unregister: + success: '&c登録が正常に解除されました!' + command_usage: '&c使用方法: /unregister <パスワード>' + +# Other messages +misc: + accounts_owned_self: '所持しているアカウント数:%count 個' + accounts_owned_other: 'プレイヤー %name のアカウント数:%count 個' + account_not_activated: '&cアカウントはまだ有効化されていません。メールを確認してください!' + password_changed: '&2パスワードが正常に変更されました!' + logout: '&2正常にログアウトしました!' + reload: '&2設定とデータベースが正常に再読み込みされました!' + usage_change_password: '&c使用方法: /changepassword <旧パスワード> <新パスワード>' + +# Session messages +session: + invalid_session: '&cIPアドレスが変更され、セッションのデータが期限切れです!' + valid_session: '&2セッションの再接続によるログインです。' + +# Error messages when joining +on_join_validation: + name_length: '&4ユーザー名が短すぎるか長すぎます!' + characters_in_name: '&4ユーザー名に無効な文字が含まれています。許可される文字:%valid_chars' + country_banned: '&4このサーバーへのアクセスは、お使いの国から制限されています!' + not_owner_error: 'このアカウントの所有者ではありません。別の名前を選択してください!' + kick_full_server: '&4サーバーが満員です。後でもう一度お試しください!' + same_nick_online: '&4同じユーザー名のプレイヤーが既にサーバーでプレイしています!' + invalid_name_case: '正しいユーザー名は %valid です。%invalid ではなく、このユーザー名で参加してください。' + same_ip_online: '同じIPアドレスを持つプレイヤーが既にゲーム内にいます!' + quick_command: 'コマンドを速すぎる速度で使用しました!もう一度サーバーに参加してから、コマンドを使用する前にしばらくお待ちください。' + +# Email +email: + usage_email_add: '&c使用方法:/email add <メールアドレス> <メールアドレスの確認>' + usage_email_change: '&c使用方法:/email change <古いメールアドレス> <新しいメールアドレス>' + new_email_invalid: '&c無効な新しいメールアドレスです。もう一度やり直してください!' + old_email_invalid: '&c無効な古いメールアドレスです。もう一度やり直してください!' + invalid: '&c無効なメールアドレスです。もう一度やり直してください!' + added: '&2メールアドレスがアカウントに正常に追加されました!' + request_confirmation: '&cメールアドレスを確認してください!' + changed: '&2メールアドレスが正しく変更されました!' + email_show: '&2現在のメールアドレスは:%email' + incomplete_settings: 'エラー:メールの送信に必要なすべての設定が設定されていません。管理者に連絡してください。' + already_used: '&4そのメールアドレスは既に使用されています' + send_failure: 'メールを送信できませんでした。管理者に連絡してください。' + no_email_for_account: '&2現在、このアカウントに関連付けられたメールアドレスはありません。' + add_email_request: '&3コマンド「/email add <あなたのメールアドレス> <確認用メールアドレス>」を使用して、アカウントにメールアドレスを追加してください。' + change_password_expired: 'このコマンドを使用してパスワードを変更することはできません。' + email_cooldown_error: '&c最近すでにメールが送信されています。新しいメールを送信する前に、%time 待つ必要があります。' + add_not_allowed: '&cメールアドレスの追加は許可されていません。' + change_not_allowed: '&cメールアドレスの変更は許可されていません。' + +# Password recovery by email +recovery: + forgot_password_hint: '&3パスワードを忘れましたか?次のコマンドを使用してください:/email recovery <あなたのメールアドレス>' + command_usage: '&c使用方法:/email recovery <メールアドレス>' + email_sent: '&2パスワードの回復メールが正常に送信されました!メールの受信トレイを確認してください!' + code: + code_sent: 'パスワードをリセットするための回復コードがメールで送信されました。' + incorrect: '回復コードが正しくありません!残りの試行回数:%count' + tries_exceeded: '回復コードの入力試行回数が上限を超えました。新しいコードを生成するには、"/email recovery [メールアドレス]" を実行してください。' + correct: '回復コードが正しく入力されました!' + change_password: '即座にパスワードを変更するには、コマンド「/email setpassword <新しいパスワード>」を使用してください。' + +# Captcha +captcha: + usage_captcha: '&3ログインするには、Captchaコードを解決する必要があります。次のコマンドを使用してください:/captcha %captcha_code' + wrong_captcha: '&cCaptchaコードが間違っています。チャットに「/captcha %captcha_code」と入力してください!' + valid_captcha: '&2Captchaコードが正しく解決されました!' + captcha_for_registration: '登録するには、まずCaptchaを解決する必要があります。次のコマンドを使用してください:/captcha %captcha_code' + register_captcha_valid: '&2有効なCaptchaです!/register を使用して登録できます' + +# Verification code +verification: + code_required: '&3このコマンドはセンシティブな操作であり、メールの認証が必要です!受信トレイを確認し、メールの指示に従ってください。' + command_usage: '&c使用方法:/verification <コード>' + incorrect_code: '&cコードが正しくありません。メールで受け取ったコードを使用して、「/verification <コード>」とチャットに入力してください。' + success: '&2身元が確認されました!現在のセッション内ですべてのコマンドを実行できます!' + already_verified: '&2現在のセッションでは、既にすべてのセンシティブなコマンドを実行できます!' + code_expired: '&3コードの有効期限が切れています!新しいコードを取得するには、別のセンシティブなコマンドを実行してください!' + email_needed: '&3アカウントにはメールアドレスのリンクが必要です。身元を確認するためにはメールアドレスを関連付けてください!' + +# Two-factor authentication +two_factor: + code_created: '&2秘密コードは %code です。こちらからスキャンできます:%url' + confirmation_required: 'コードを確認するには、/2fa confirm <コード> を使用してください' + code_required: '二要素認証コードを提出するには、/2fa code <コード> を使用してください' + already_enabled: 'アカウントで既に二要素認証が有効になっています!' + enable_error_no_code: '2要素認証キーが生成されていないか、期限が切れています。/2fa add を実行してください' + enable_success: 'アカウントでの二要素認証が正常に有効になりました' + enable_error_wrong_code: 'コードが間違っているか、期限が切れています。/2fa add を実行してください' + not_enabled_error: 'アカウントでは二要素認証が有効になっていません。/2fa add を実行してください' + removed_success: 'アカウントから二要素認証が正常に削除されました' + invalid_code: '無効なコードです!' + +# Time units +time: + second: '秒' + seconds: '秒' + minute: '分' + minutes: '分' + hour: '時間' + hours: '時間' + day: '日' + days: '日' From f24d6c5b5fd9ffc2fd86d1ca5dfdf662a188bf66 Mon Sep 17 00:00:00 2001 From: ljacqu Date: Wed, 21 Jun 2023 12:12:34 +0200 Subject: [PATCH 85/97] Update translation doc page, add comment for missing entries, fix verifyMessages task --- docs/translations.md | 13 ++++---- .../updater/MigraterYamlFileResource.java | 8 +++++ src/main/resources/messages/messages_si.yml | 30 +++++++++---------- .../TranslationPageGenerator.java | 1 + 4 files changed, 31 insertions(+), 21 deletions(-) diff --git a/docs/translations.md b/docs/translations.md index 7cf499d75..fc8251e64 100644 --- a/docs/translations.md +++ b/docs/translations.md @@ -1,5 +1,5 @@ - + # AuthMe Translations The following translations are available in AuthMe. Set `messagesLanguage` to the language code @@ -22,10 +22,11 @@ Code | Language | Translated |   [hu](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_hu.yml) | Hungarian | 99% | 99 [id](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_id.yml) | Indonesian | 93% | 93 [it](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_it.yml) | Italian | 100% | 100 +[ja](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_ja.yml) | Japanese | 100% | 100 [ko](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_ko.yml) | Korean | 99% | 99 -[lt](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_lt.yml) | Lithuanian | 36% | 36 +[lt](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_lt.yml) | Lithuanian | 100% | 100 [nl](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_nl.yml) | Dutch | 100% | 100 -[pl](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_pl.yml) | Polish | 99% | 99 +[pl](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_pl.yml) | Polish | 100% | 100 [pt](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_pt.yml) | Portuguese | 100% | 100 [ro](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_ro.yml) | Romanian | 100% | 100 [ru](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_ru.yml) | Russian | 100% | 100 @@ -34,13 +35,13 @@ Code | Language | Translated |   [sr](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_sr.yml) | Serbian | 99% | 99 [tr](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_tr.yml) | Turkish | 100% | 100 [uk](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_uk.yml) | Ukrainian | 100% | 100 -[vn](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_vn.yml) | Vietnamese | 77% | 77 +[vn](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_vn.yml) | Vietnamese | 100% | 100 [zhcn](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_zhcn.yml) | Chinese (China) | 100% | 100 [zhhk](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_zhhk.yml) | Chinese (Hong Kong) | 99% | 99 [zhmc](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_zhmc.yml) | Chinese (Macau) | 64% | 64 -[zhtw](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_zhtw.yml) | Chinese (Taiwan) | 86% | 86 +[zhtw](https://github.com/AuthMe/AuthMeReloaded/blob/master/src/main/resources/messages/messages_zhtw.yml) | Chinese (Taiwan) | 100% | 100 --- -This page was automatically generated on the [AuthMe/AuthMeReloaded repository](https://github.com/AuthMe/AuthMeReloaded/tree/master/docs/) on Sun Apr 04 21:31:44 CEST 2021 +This page was automatically generated on the [AuthMe/AuthMeReloaded repository](https://github.com/AuthMe/AuthMeReloaded/tree/master/docs/) on Wed Jun 21 12:14:29 CEST 2023 diff --git a/src/main/java/fr/xephi/authme/message/updater/MigraterYamlFileResource.java b/src/main/java/fr/xephi/authme/message/updater/MigraterYamlFileResource.java index c8b6755bf..b0122215b 100644 --- a/src/main/java/fr/xephi/authme/message/updater/MigraterYamlFileResource.java +++ b/src/main/java/fr/xephi/authme/message/updater/MigraterYamlFileResource.java @@ -36,4 +36,12 @@ public class MigraterYamlFileResource extends YamlFileResource { } return singleQuoteYaml; } + + // Because we set the YAML object to put strings in single quotes, this method by default uses that YAML object + // and also puts all paths as single quotes. Override to just always return the same string since we know those + // are only message names (so never any conflicting strings like "true" or "0"). + @Override + protected String escapePathElementIfNeeded(String path) { + return path; + } } diff --git a/src/main/resources/messages/messages_si.yml b/src/main/resources/messages/messages_si.yml index db922a6bc..74bbfe689 100644 --- a/src/main/resources/messages/messages_si.yml +++ b/src/main/resources/messages/messages_si.yml @@ -5,13 +5,13 @@ # Registration registration: + disabled: '&cRegistracija v igri je onemogočena!' + name_taken: '&cTo uporabniško ime ste ze registrirali!' register_request: '&3Registrirajte se z ukazom "/register "' command_usage: '&cUporaba: /register ' reg_only: '&4Samo registrirani uporabniki se lahko povezejo! Obiscite http://example.com , da se registrirate!' - kicked_admin_registered: 'Administrator vas je registriral; prosimo, da se prijavite.' success: '&2Uspešno registriran!' - disabled: '&cRegistracija v igri je onemogočena!' - name_taken: '&cTo uporabniško ime ste ze registrirali!' + kicked_admin_registered: 'Administrator vas je registriral; prosimo, da se prijavite.' # Password errors on registration password: @@ -40,6 +40,7 @@ error: max_registration: '&cPresegli ste največjo stevilo registracij (%reg_count/%max_acc %reg_names) za vašo povezavo!' logged_in: '&cSte že povezani!' kick_for_vip: '&3VIP igralec se je pridruzil serverju, ko je bil poln!' + # TODO kick_unresolved_hostname: '&cAn error occurred: unresolved player hostname!' tempban_max_logins: '&cBil si začasno izločen zaradi preveč neuspešnih prijav.' # AntiBot @@ -131,6 +132,17 @@ verification: code_expired: '&3Your code has expired! Execute another sensitive command to get a new code!' email_needed: '&3To verify your identity you need to link an email address with your account!' +# Time units +time: + second: 'sekunda' + seconds: 'sekund' + minute: 'minuta' + minutes: 'minut' + hour: 'ur' + hours: 'ure' + day: 'dan' + days: 'dni' + # Two-factor authentication two_factor: code_created: '&2Vasa skrivna koda je %code. Lahko je skenirate tu %url!' @@ -143,15 +155,3 @@ two_factor: not_enabled_error: 'Dvo stopična prijava ni vključena za vaš račun. Uporabite /2fa add' removed_success: 'Usprešno ste odstranili dvo stopično prijavo za vaš račun.' invalid_code: 'Nepravilna koda!' - -# Time units -time: - second: 'sekunda' - seconds: 'sekund' - minute: 'minuta' - minutes: 'minut' - hour: 'ur' - hours: 'ure' - day: 'dan' - days: 'dni' - \ No newline at end of file diff --git a/src/test/java/tools/docs/translations/TranslationPageGenerator.java b/src/test/java/tools/docs/translations/TranslationPageGenerator.java index 8997765f7..f55cfd76e 100644 --- a/src/test/java/tools/docs/translations/TranslationPageGenerator.java +++ b/src/test/java/tools/docs/translations/TranslationPageGenerator.java @@ -121,6 +121,7 @@ public class TranslationPageGenerator implements AutoToolTask { .put("hu", "Hungarian") .put("id", "Indonesian") .put("it", "Italian") + .put("ja", "Japanese") .put("ko", "Korean") .put("lt", "Lithuanian") .put("nl", "Dutch") From 642ff72ee05eac5e909f14d0165c2ab0e4fc20d6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 16 Jul 2023 19:22:03 +0200 Subject: [PATCH 86/97] Bump postgresql from 42.5.0 to 42.6.0 (#2711) Bumps [postgresql](https://github.com/pgjdbc/pgjdbc) from 42.5.0 to 42.6.0. - [Release notes](https://github.com/pgjdbc/pgjdbc/releases) - [Changelog](https://github.com/pgjdbc/pgjdbc/blob/master/CHANGELOG.md) - [Commits](https://github.com/pgjdbc/pgjdbc/compare/REL42.5.0...REL42.6.0) --- updated-dependencies: - dependency-name: org.postgresql:postgresql dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f78e74caf..5a1666f50 100644 --- a/pom.xml +++ b/pom.xml @@ -997,7 +997,7 @@ org.postgresql postgresql - 42.5.0 + 42.6.0 true From b6bf9dabccef11d77e580ada8951f11a9406545c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 16 Jul 2023 19:22:13 +0200 Subject: [PATCH 87/97] Bump sqlite-jdbc from 3.39.3.0 to 3.42.0.0 (#2712) Bumps [sqlite-jdbc](https://github.com/xerial/sqlite-jdbc) from 3.39.3.0 to 3.42.0.0. - [Release notes](https://github.com/xerial/sqlite-jdbc/releases) - [Changelog](https://github.com/xerial/sqlite-jdbc/blob/master/CHANGELOG) - [Commits](https://github.com/xerial/sqlite-jdbc/compare/3.39.3.0...3.42.0.0) --- updated-dependencies: - dependency-name: org.xerial:sqlite-jdbc dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5a1666f50..374253367 100644 --- a/pom.xml +++ b/pom.xml @@ -1048,7 +1048,7 @@ org.xerial sqlite-jdbc - 3.39.3.0 + 3.42.0.0 test From 974e6780a58bdd8e3fb7e60e51540fea0ee96b09 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 16 Jul 2023 19:22:23 +0200 Subject: [PATCH 88/97] Bump EssentialsX from 2.19.7 to 2.20.0 (#2713) Bumps [EssentialsX](https://github.com/EssentialsX/Essentials) from 2.19.7 to 2.20.0. - [Release notes](https://github.com/EssentialsX/Essentials/releases) - [Commits](https://github.com/EssentialsX/Essentials/compare/2.19.7...2.20.0) --- updated-dependencies: - dependency-name: net.essentialsx:EssentialsX dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 374253367..c11f5a738 100644 --- a/pom.xml +++ b/pom.xml @@ -925,7 +925,7 @@ net.essentialsx EssentialsX - 2.19.7 + 2.20.0 provided From abcd2640bb5325332acc9ef51179ce3f28adc58e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 16 Jul 2023 19:22:43 +0200 Subject: [PATCH 89/97] Bump mysql-connector-j from 8.0.31 to 8.0.33 (#2717) Bumps [mysql-connector-j](https://github.com/mysql/mysql-connector-j) from 8.0.31 to 8.0.33. - [Changelog](https://github.com/mysql/mysql-connector-j/blob/release/8.0/CHANGES) - [Commits](https://github.com/mysql/mysql-connector-j/compare/8.0.31...8.0.33) --- updated-dependencies: - dependency-name: com.mysql:mysql-connector-j dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c11f5a738..b4f914698 100644 --- a/pom.xml +++ b/pom.xml @@ -686,7 +686,7 @@ com.mysql mysql-connector-j - 8.0.31 + 8.0.33 true From e11f36412f09dabc8987eca1419f674bc34c6d4b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 16 Jul 2023 19:22:56 +0200 Subject: [PATCH 90/97] Bump mariadb-java-client from 3.0.8 to 3.1.4 (#2718) Bumps [mariadb-java-client](https://github.com/mariadb-corporation/mariadb-connector-j) from 3.0.8 to 3.1.4. - [Release notes](https://github.com/mariadb-corporation/mariadb-connector-j/releases) - [Changelog](https://github.com/mariadb-corporation/mariadb-connector-j/blob/master/CHANGELOG.md) - [Commits](https://github.com/mariadb-corporation/mariadb-connector-j/compare/3.0.8...3.1.4) --- updated-dependencies: - dependency-name: org.mariadb.jdbc:mariadb-java-client dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b4f914698..4b96a7d71 100644 --- a/pom.xml +++ b/pom.xml @@ -692,7 +692,7 @@ org.mariadb.jdbc mariadb-java-client - 3.0.8 + 3.1.4 true From 7a76050cc7e1902a7eb7ee83b02ff8d86a2e6ba7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 16 Jul 2023 19:23:27 +0200 Subject: [PATCH 91/97] Bump h2 from 2.1.214 to 2.2.220 (#2726) Bumps [h2](https://github.com/h2database/h2database) from 2.1.214 to 2.2.220. - [Release notes](https://github.com/h2database/h2database/releases) - [Commits](https://github.com/h2database/h2database/compare/version-2.1.214...version-2.2.220) --- updated-dependencies: - dependency-name: com.h2database:h2 dependency-type: direct:development ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4b96a7d71..133ce99a6 100644 --- a/pom.xml +++ b/pom.xml @@ -1054,7 +1054,7 @@ com.h2database h2 - 2.1.214 + 2.2.220 test From 44b255512d73ebb96faf7adc87f3e8a9053cfdd2 Mon Sep 17 00:00:00 2001 From: ljacqu Date: Tue, 25 Jul 2023 21:38:12 +0200 Subject: [PATCH 92/97] Remove myself from plugin authors list - I'm still around :) but don't need my username to be part of the log when a MC server crashes :) --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 133ce99a6..a3f870e80 100644 --- a/pom.xml +++ b/pom.xml @@ -79,7 +79,7 @@ ${project.outputName} ${project.versionCode} ${project.groupId}.${project.artifactId}.${pluginDescription.name} - sgdc3, ljacqu, games647, Hex3l, krusic22 + sgdc3, games647, Hex3l, krusic22 From 7bfb79f4dd37001807b2463a2d522642ea7ffc6c Mon Sep 17 00:00:00 2001 From: Obydux Date: Sun, 30 Jul 2023 17:54:08 +0300 Subject: [PATCH 93/97] Actually finish the Lithuanian translation --- src/main/resources/messages/help_lt.yml | 45 +++++ src/main/resources/messages/messages_lt.yml | 198 ++++++++++---------- 2 files changed, 144 insertions(+), 99 deletions(-) create mode 100644 src/main/resources/messages/help_lt.yml diff --git a/src/main/resources/messages/help_lt.yml b/src/main/resources/messages/help_lt.yml new file mode 100644 index 000000000..ee141497b --- /dev/null +++ b/src/main/resources/messages/help_lt.yml @@ -0,0 +1,45 @@ +# Translation config for the AuthMe help, e.g. when /authme help or /authme help register is called + +# ------------------------------------------------------- +# List of texts used in the help section +common: + header: '==========[ AuthMeReloaded PAGALBA ]==========' + optional: 'Neprivaloma' + hasPermission: 'Jūs turite leidimą' + noPermission: 'Jūs neturite leidimo' + default: 'Numatytas' + result: 'Rezultatas' + defaultPermissions: + notAllowed: 'Nėra leidimo' + opOnly: 'Tik OP' + allowed: 'Visiems leistina' + +# ------------------------------------------------------- +# Titles of the individual help sections +# Set the translation text to empty text to disable the section, e.g. to hide alternatives: +# alternatives: '' +section: + command: 'Komanda' + description: 'Trumpas aprašas' + detailedDescription: 'Detalus aprašas' + arguments: 'Argumentai' + permissions: 'Leidimai' + alternatives: 'Alternatyvos' + children: 'Komandos' + +# ------------------------------------------------------- +# You can translate the data for all commands using the below pattern. +# For example to translate /authme reload, create a section "authme.reload", or "login" for /login +# If the command has arguments, you can use arg1 as below to translate the first argument, and so forth +# Translations don't need to be complete; any missing section will be taken from the default silently +# Important: Put main commands like "authme" before their children (e.g. "authme.reload") +commands: + authme.register: + description: 'Užregistruoti žaidėją' + detailedDescription: 'Užregistruokite nurodytą žaidėją su nurodytu slaptažodžiu.' + arg1: + label: 'žaidėjas' + description: 'Žaidėjo vardas' + arg2: + label: 'slaptažodis' + description: 'Slaptažodis' diff --git a/src/main/resources/messages/messages_lt.yml b/src/main/resources/messages/messages_lt.yml index f8606b01f..7ce7ae510 100644 --- a/src/main/resources/messages/messages_lt.yml +++ b/src/main/resources/messages/messages_lt.yml @@ -5,153 +5,153 @@ # Registration registration: - disabled: '&6Registracija yra isjungta' - name_taken: '&cVartotojo vardas jau uzregistruotas' - register_request: '&ePrasome prisiregistruoti: /register slaptazodis pakartotiSlaptazodi' - command_usage: '&eNaudojimas: /register slaptazodis pakartotiSlaptazodi' - reg_only: '&cTik prisiregistravusiem zaidejams: apsilankykite: http://example.com tam kad uzsiregistruoti.' - success: '&aSekmingai prisiregistravote.' - kicked_admin_registered: 'Administatorius jus uzregistravo. Prisijunkite isnaujo' + disabled: '&6Registracija yra išjungta' + name_taken: '&cVartotojo vardas jau užregistruotas' + register_request: '&ePrašome prisiregistruoti: /register slaptažodis pakartotiSlaptažodį' + command_usage: '&eNaudojimas: /register slaptažodis pakartotiSlaptažodį' + reg_only: '&cTik prisiregistravusiems žaidėjams: apsilankykite: http://example.com tam, kad užsiregistruoti.' + success: '&aSėkmingai prisiregistravote.' + kicked_admin_registered: 'Administatorius Jus užregistravo. Prisijunkite iš naujo' # Password errors on registration password: - match_error: '&cSlaptazodziai nesutampa' - name_in_password: '&cJus negalite naudoti savo varda slaptazodyje' - unsafe_password: '&cSi slaptazodi lengva nulausti, pasirinkite kita slaptazodi' - forbidden_characters: '&4Jusus slaptazodis turi netinkamu simboliu. Leidziami simboliai: %valid_chars' - wrong_length: '&cJusu slaptazodis buvo per ilgas arba per trumpas.' + match_error: '&cSlaptažodžiai nesutampa' + name_in_password: '&cJūs negalite naudoti savo vardo slaptažodyje' + unsafe_password: '&cŠį Slaptažodį lengva nulaužti, pasirinkite kitą slaptažodį' + forbidden_characters: '&4Jūsų slaptažodis turi netinkamų simbolių. Leidžiami simboliai: %valid_chars' + wrong_length: '&cJūsų pasirinktas slaptažodis per ilgas arba per trumpas.' # Login login: - command_usage: '&eKomandos panaudojimas: /login slaptazodis' - wrong_password: '&cNeteisingas slaptazosdis' - success: '&aSekmingai prisijungete' - login_request: '&ePrasome prisijungti: /login slaptazodis' - timeout_error: '&cNespejote prisijungti' + command_usage: '&eKomandos panaudojimas: /login slaptažodis' + wrong_password: '&cNeteisingas Slaptažosdis' + success: '&aSėkmingai prisijungėte' + login_request: '&ePrašome prisijungti: /login slaptažodis' + timeout_error: '&cNespėjote prisijungti' # Errors error: - denied_command: '&cKad galetumete naudoti sia komanda turite buti prisijunge!' - denied_chat: '&cKad galetumete kalbeti jus turite buti prisijunge!' - unregistered_user: '&cVartotojas neprisiregistraves' - not_logged_in: '&cTu neprisijunges!' - no_permission: '&cNera leidimo' - unexpected_error: '&cAtsirado klaida, praneskite adminstratoriui.' - max_registration: '&cJus pasiekete maksimalu registraciju skaiciu.' - logged_in: '&cTu jau prisijunges!' - kick_for_vip: '&cA VIP prisijunge i pilna serveri!' - kick_unresolved_hostname: '&cIvyko klaida: Ivyko klaida su zaidejo adresu!' - tempban_max_logins: '&cJus laikinai uzblokuotas nes kelis kartus neteisingai suvedete salptazodi.' + denied_command: '&cKad galetumėte naudoti šią komandą turite būti prisijungę!' + denied_chat: '&cKad galetumėte kalbėti Jūs turite būti prisijungę!' + unregistered_user: '&cVartotojas neprisiregistravęs' + not_logged_in: '&cJūs neprisijungę!' + no_permission: '&cNėra leidimo' + unexpected_error: '&cAtsirado klaida, praneškite adminstratoriui.' + max_registration: '&cJūs pasiekėte maksimalų registracijų skaičių.' + logged_in: '&cTu jau prisijungęs!' + kick_for_vip: '&cRėmėjas prisijungė į pilną serverį!' + kick_unresolved_hostname: '&cĮvyko klaida su žaidejo adresu!' + tempban_max_logins: '&cJūs laikinai užblokuotas, nes kelis kartus neteisingai suvedėte slaptažodį.' # AntiBot antibot: - kick_antibot: 'AntiBot prevencija ijungta! Palaukite pries prisijungiant.' - auto_enabled: '&4[AntiBotService] AntiBot prevencija pajungta del didelio kiekio prisijungimu!' - auto_disabled: '&2[AntiBotService] AntiBot isjungtas po: %m minutes!' + kick_antibot: 'AntiBot prevencija įjungta! Palaukite prieš prisijungiant.' + auto_enabled: '&4[AntiBotService] AntiBot prevencija pajungta dėl didelio kiekio prisijungimų!' + auto_disabled: '&2[AntiBotService] AntiBot bus išjungtas po %m minučių!' # Unregister unregister: - success: '&aSekmingai issiregistravote!' - command_usage: '&ePanaikinti registracija: "/unregister slaptazodis"' + success: '&aSėkmingai išsiregistravote!' + command_usage: '&ePanaikinti registraciją: "/unregister slaptažodis"' # Other messages misc: - account_not_activated: '&aJusu vartotojas nera patvirtintas, patikrinkite el.pasta.' - password_changed: '&aSlaptazodis pakeistas' - logout: '&aSekmingai atsijungete' - reload: '&aNustatymai ir duomenu baze buvo perkrauta.' - usage_change_password: '&ePanaudojimas: /changepassword senasSlaptazodis naujasSlaptazodis' - accounts_owned_self: 'Jus turite %count paskyra(-s):' - accounts_owned_other: 'Zaidejas %name turi %count paskyra(-s):' + account_not_activated: '&aJūsų vartotojas nėra patvirtintas, pasitikrinkite el.paštą.' + password_changed: '&aSlaptažodis pakeistas' + logout: '&aSėkmingai atsijungėte' + reload: '&aNustatymai ir duomenų bazė buvo perkrauta.' + usage_change_password: '&ePanaudojimas: /changepassword senasSlaptažodis naujasSlaptažodis' + accounts_owned_self: 'Jūs turite %count paskyrą(-s):' + accounts_owned_other: 'Žaidejas %name turi %count paskyrą(-s):' # Session messages session: - valid_session: '&aSesijos prisijungimas' - invalid_session: '&cSesijos laikai nesutampa, prasome palaukti kol secija baigsis.' + valid_session: '&aAutomatinis sesijos prisijungimas' + invalid_session: '&cSesijos laikai nesutampa. Prašome palaukti kol sesija baigsis.' # Error messages when joining on_join_validation: - same_ip_online: 'Zaidejas su tuo paciu ip jau yra zaidime!' - same_nick_online: '&cKazkas situo vardu jau zaidzia.' - name_length: '&cJusu varsdas yra per ilgas arba per trumpas.' - characters_in_name: '&cJusu varde yra neledziamu simboliu, leidziami: %valid_chars' - kick_full_server: '&cServeris yra pilnas, Atsiprasome.' - country_banned: '&4Jusu salis yra uzblokuota siame serveryje!' - not_owner_error: 'Tu neesi sios paskyros savininkas, pasirinkite kita varda!' - invalid_name_case: 'Turetumete prisijungti su vardu: %valid, o ne su: %invalid.' - quick_command: 'Tu panaudojai komanda per greitai! Prisijunkite isnaujo ir siek tiek palaukite pries naudojant komandas.' + same_ip_online: 'Žaidejas su tuo pačiu IP adresu jau yra žaidime!' + same_nick_online: '&cKažkas šituo vardu jau žaidžia.' + name_length: '&cJūsų vardas yra per ilgas arba per trumpas.' + characters_in_name: '&cJūsų varde yra neledziamų simbolių. Leidžiami: %valid_chars' + kick_full_server: '&cServeris yra pilnas, atsiprašome.' + country_banned: '&4Jūsų šalis yra užblokuota šiame serveryje!' + not_owner_error: 'J0s nesate šios paskyros savininkas, pasirinkite kitą vardą!' + invalid_name_case: 'Turėtumėte prisijungti su vardu %valid, o ne su: %invalid.' + quick_command: 'Jūs panaudojote komandą per greitai! Prisijunkite iš naujo ir šiek tiek palaukite prieš naudojant komandas.' # Email email: - add_email_request: '&ePrasau pridekite savo el.pasta : /email add ' - usage_email_add: '&cNaudojimas: /email add ' + add_email_request: '&ePrašome jūsų pridėti savo el.paštą : /email add ' + usage_email_add: '&cNaudojimas: /email add ' usage_email_change: '&cNaudojimas: /email change ' - new_email_invalid: '&cNeteisingas el.pastas, bandykite isnaujo!' - old_email_invalid: '&cNeteisingas senas el.pastas, bandykite isnaujo!' - invalid: '&cNeteisingas el.pastas, bandykite isnaujo!' - added: '&2El.pastas sekmingai pridetas!' - add_not_allowed: '&cNaujo el.pasto pridejimas nera galimas' - request_confirmation: '&cPatvirtinkite savo el.pasta!' - changed: '&2El.pasta pakeistas sekmingai!' - change_not_allowed: '&cEl.pasto keitimas nera galimas' - email_show: '&2Jusu dabartinis el.pasto adresas: &f%email' - no_email_for_account: '&2Siuo metu jus neturite prideja jokio el.pasto adreso.' - already_used: '&4Jis el.pasto adresas jau yra naudojamas' - incomplete_settings: 'Klaidas: Nevisi nustatymai yra nustatyti laisko siuntimui. Susikietite su administratorium.' - send_failure: 'El.pasto laiskas nebuvo issiustas. Susikietite su administratorium.' - change_password_expired: 'Jus nebegalite pakeisti savo slaptazodzio naudojant sia komanda.' - email_cooldown_error: '&cEl.pasto laiskas jau buvo issiustas. Palaukite %time pries siunciant nauja.' + new_email_invalid: '&cNeteisingas el.paštas, bandykite iš naujo!' + old_email_invalid: '&cNeteisingas senas el.paštas, bandykite iš naujo!' + invalid: '&cNeteisingas el.paštas, bandykite iš naujo!' + added: '&2El.paštas sėkmingai pridėtas!' + add_not_allowed: '&cNaujo el.pašto pridejimas nėra galimas' + request_confirmation: '&cPatvirtinkite savo el.paštą!' + changed: '&2El.paštą pakeistas sėkmingai!' + change_not_allowed: '&cEl.pašto keitimas nėra galimas' + email_show: '&2Jūsų dabartinis el.pašto adresas: &f%email' + no_email_for_account: '&2Šiuo metu Jūs neturite pridėję jokio el.pašto adreso.' + already_used: '&4Jis el.pašto adresas jau yra naudojamas' + incomplete_settings: 'Klaida: Ne visi nustatymai yra nustatyti laiško siuntimui. Susikietite su administratoriumi.' + send_failure: 'El.pašto laiškas nebuvo išsiųstas. Susikietite su administratoriumi.' + change_password_expired: 'Jūs nebegalite pakeisti savo slaptažodzio naudojant šią komandą.' + email_cooldown_error: '&cEl.pašto laiškas jau buvo išsiųstas. Palaukite %time prieš šiunčiant naują.' # Password recovery by email recovery: - forgot_password_hint: '&cPamirsote slaptazodi? Rasykite: /email recovery el.pastas' - command_usage: '&cNaudojimas: /email recovery el.pastas' - email_sent: '&2Laiskas i jusu pasto adresa buvo issiustas!' + forgot_password_hint: '&cPamiršote savo slaptažodį? Rašykite: /email recovery el.paštas' + command_usage: '&cNaudojimas: /email recovery el.paštas' + email_sent: '&2Laiškas į Jūsų el.pašto adresą buvo išsiųstas!' code: - code_sent: 'Kodas slaptazodzio atstatymui buvo issiustas i jusu pasta.' - incorrect: 'Kodas neteisingas! jums liko %count bandymai(-as).' - tries_exceeded: 'Jus isnaudojote visus bandymus. Naudokite "/email recovery el.pastas" kad gauti nauja koda.' - correct: 'Kodas ivestas sekmingai!' - change_password: 'Naudokite /email setpassword kad pasikeistumete slaptazodi.' + code_sent: 'Kodas slaptažodžio atstatymui buvo išsiųstas į Jūsų el.paštą.' + incorrect: 'Kodas neteisingas! Jums liko %count bandymai(-as).' + tries_exceeded: 'Jūs išnaudojote visus bandymus. Naudokite "/email recovery el.paštas", kad gauti naują kodą.' + correct: 'Kodas įvestas sėkmingai!' + change_password: 'Naudokite /email setpassword , kad pasikeistumėte slaptažodį.' # Captcha captcha: usage_captcha: '&cPanaudojimas: /captcha %captcha_code' - wrong_captcha: '&cNeteisinga Captcha, naudokite : /captcha %captcha_code' - valid_captcha: '&cJusu captcha Teisinga!' - captcha_for_registration: 'Kad prisiregistruotumete turite ivygdyti captcha, rasykite: /captcha %captcha_code' - register_captcha_valid: '&2Captcha Teisinga! Galite naudoti /register' + wrong_captcha: '&cNeteisinga captcha, naudokite : /captcha %captcha_code' + valid_captcha: '&cJūsų captcha teisinga!' + captcha_for_registration: 'Kad prisiregistruotumėte turite įvygdyti captchą. Rašykite: /captcha %captcha_code' + register_captcha_valid: '&2Captcha teisinga! Galite naudoti /register' # Verification code verification: - code_required: '&3Kad naudotumete sia komanda turi patvirtinti savo pasto adresa! Sekite instrukcijas savo el.paste.' + code_required: '&3Kad naudotumete šią komanda turi patvirtinti savo el.pašto adresą! Sekite instrukcijas savo el.pašte.' command_usage: '&cNaudojimas: /verification ' - incorrect_code: '&cNeteisingas kodas, naudokite "/verification " ivesdami koda gauta savo el.paste' - success: '&2Jusu paskyra patvirtinta! Jus galite naudoti visas komandas!' - already_verified: '&2Jus jau esate patvirtintas ir galite naudoti visas komandas!' - code_expired: '&3Jusu kodo galiojimas baigesi! Panaudokite komanda isnaujo kad gauti nauja koda!' - email_needed: '&3Kad patvirtinti savo paskyra turite prideti el.pasto adresa!' + incorrect_code: '&cNeteisingas kodas, naudokite "/verification " įvesdami kodą gautą savo el.pašte' + success: '&2Jūsų paskyra patvirtinta! Jūs galite naudoti visas komandas!' + already_verified: '&2Jūs jau esate patvirtinę savo paskyrą ir galite naudoti visas komandas!' + code_expired: '&3Jūsų kodo galiojimas baigėsi! Panaudokite komandą iš naujo, kad gautumėte naują kodą!' + email_needed: '&3Kad patvirtinti savo paskyra turite pridėti el.pašto adresą!' # Time units time: - second: 'sekunde' + second: 'sekundę' seconds: 'sekundes' - minute: 'minute' + minute: 'minutę' minutes: 'minutes' - hour: 'valanda' + hour: 'valandą' hours: 'valandas' - day: 'diena' + day: 'dieną' days: 'dienas' # Two-factor authentication two_factor: - code_created: '&2Tavo slaptas kodas yra %code. Ji gali nuskenuoti cia: %url' - confirmation_required: 'Patvirtinkite savo koda su: /2fa confirm ' - code_required: 'Patvirkinkite savo koda su: /2fa code ' - already_enabled: 'Jus jau turite dvieju faktoriu autentifikacija!' - enable_error_no_code: 'Jus neturite dvieju faktoriu autentifikacijos arba ji pasibaige. Rasykite /2fa add' - enable_success: 'Dvieju faktoriu autentifikacija sekmingai ijungta' - enable_error_wrong_code: 'Wrong code or code has expired. Please run /2fa add' - not_enabled_error: 'Two-factor authentication is not enabled for your account. Run /2fa add' - removed_success: 'Successfully removed two-factor auth from your account' + code_created: '&2Jūsų slaptas kodas yra %code. Jį galite nuskenuoti čia: %url' + confirmation_required: 'Patvirtinkite savo kodą su: /2fa confirm ' + code_required: 'Patvirkinkite savo kodą su: /2fa code ' + already_enabled: 'Jūs jau turite dviejų faktorių autentifikaciją!' + enable_error_no_code: 'Jūs neturite dviejų faktorių autentifikacijos arba ji pasibaigė. Rašykite /2fa add' + enable_success: 'Dviejų faktorių autentifikacija sėkmingai įjungta' + enable_error_wrong_code: 'Neteisingas arba pasibaigęs kodas. Rašykite /2fa add' + not_enabled_error: 'Dviejų faktorių autentifikavimas nėra įjungtas ant jūsų paskyros. Rašykite /2fa add' + removed_success: 'Dviejų faktorių autentifikavimas sėkmingai pašalintas iš jūsų paskyros.' invalid_code: 'Neteisingas kodas!' From 550b3a1b6975e88e150f0dcdc686f458d55f0b4f Mon Sep 17 00:00:00 2001 From: Obydux Date: Sun, 30 Jul 2023 18:43:11 +0300 Subject: [PATCH 94/97] Minor spelling mistake --- src/main/resources/messages/messages_lt.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/messages/messages_lt.yml b/src/main/resources/messages/messages_lt.yml index 7ce7ae510..b90ebc737 100644 --- a/src/main/resources/messages/messages_lt.yml +++ b/src/main/resources/messages/messages_lt.yml @@ -124,7 +124,7 @@ captcha: # Verification code verification: - code_required: '&3Kad naudotumete šią komanda turi patvirtinti savo el.pašto adresą! Sekite instrukcijas savo el.pašte.' + code_required: '&3Kad galėtumėte naudoti šią komandą turite patvirtinti savo el.pašto adresą! Sekite instrukcijas savo el.pašte.' command_usage: '&cNaudojimas: /verification ' incorrect_code: '&cNeteisingas kodas, naudokite "/verification " įvesdami kodą gautą savo el.pašte' success: '&2Jūsų paskyra patvirtinta! Jūs galite naudoti visas komandas!' From f098cc0762b40f5312fd58bba76ccaecde47c93a Mon Sep 17 00:00:00 2001 From: ljacqu Date: Wed, 23 Aug 2023 06:30:31 +0200 Subject: [PATCH 95/97] Dependabot: Ignore Mockito 5 updates - Mockito 5 requires Java 11, which we're not yet using --- .github/dependabot.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 240dd9bb0..dbc38fbb4 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -10,3 +10,7 @@ updates: - 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 + versions: ">= 5" + - dependency-name: "org.mockito:mockito-junit-jupiter" # Mockito 5 requires Java 11 + versions: ">= 5" From 80c1c2edacf9d6c5fbe7618e37b94d9dc340fe09 Mon Sep 17 00:00:00 2001 From: ljacqu Date: Wed, 23 Aug 2023 06:33:36 +0200 Subject: [PATCH 96/97] Dependabot: Remove ignore entry for unused dependency - The previous commit specified to ignore mockito-junit-jupiter, which is not used by this project -> remove entry --- .github/dependabot.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index dbc38fbb4..51a5ca898 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -12,5 +12,3 @@ updates: - dependency-name: com.zaxxer:HikariCP - dependency-name: "org.mockito:mockito-core" # Mockito 5 requires Java 11 versions: ">= 5" - - dependency-name: "org.mockito:mockito-junit-jupiter" # Mockito 5 requires Java 11 - versions: ">= 5" From 79309c3c050e222406ccfd8504df7b66a13026c9 Mon Sep 17 00:00:00 2001 From: ljacqu Date: Wed, 23 Aug 2023 06:29:11 +0200 Subject: [PATCH 97/97] Update to ConfigMe 1.4.0 --- pom.xml | 2 +- .../updater/MessageKeyConfigurationData.java | 11 +++-- .../MessageMigraterPropertyReader.java | 8 +-- .../message/updater/MessageUpdater.java | 7 ++- .../updater/MigraterYamlFileResource.java | 49 ++++++++++++------- 5 files changed, 47 insertions(+), 30 deletions(-) diff --git a/pom.xml b/pom.xml index a3f870e80..33861bb50 100644 --- a/pom.xml +++ b/pom.xml @@ -760,7 +760,7 @@ ch.jalu configme - 1.3.0 + 1.4.0 true diff --git a/src/main/java/fr/xephi/authme/message/updater/MessageKeyConfigurationData.java b/src/main/java/fr/xephi/authme/message/updater/MessageKeyConfigurationData.java index cf3c1c782..48cea6aa1 100644 --- a/src/main/java/fr/xephi/authme/message/updater/MessageKeyConfigurationData.java +++ b/src/main/java/fr/xephi/authme/message/updater/MessageKeyConfigurationData.java @@ -5,6 +5,7 @@ import ch.jalu.configme.properties.Property; import ch.jalu.configme.properties.convertresult.PropertyValue; import ch.jalu.configme.resource.PropertyReader; import fr.xephi.authme.message.MessageKey; +import fr.xephi.authme.message.updater.MessageUpdater.MessageKeyProperty; import java.util.List; import java.util.Map; @@ -39,15 +40,19 @@ public class MessageKeyConfigurationData extends ConfigurationDataImpl { } @SuppressWarnings("unchecked") - public List> getAllMessageProperties() { + public List getAllMessageProperties() { return (List) getProperties(); } public String getMessage(MessageKey messageKey) { - return getValue(new MessageUpdater.MessageKeyProperty(messageKey)); + return getValue(new MessageKeyProperty(messageKey)); + } + + public String getMessage(MessageKeyProperty property) { + return (String) getValues().get(property.getPath()); } public void setMessage(MessageKey messageKey, String message) { - setValue(new MessageUpdater.MessageKeyProperty(messageKey), message); + setValue(new MessageKeyProperty(messageKey), message); } } diff --git a/src/main/java/fr/xephi/authme/message/updater/MessageMigraterPropertyReader.java b/src/main/java/fr/xephi/authme/message/updater/MessageMigraterPropertyReader.java index a994df898..1c7e59615 100644 --- a/src/main/java/fr/xephi/authme/message/updater/MessageMigraterPropertyReader.java +++ b/src/main/java/fr/xephi/authme/message/updater/MessageMigraterPropertyReader.java @@ -4,13 +4,13 @@ import ch.jalu.configme.exception.ConfigMeException; import ch.jalu.configme.resource.PropertyReader; import org.yaml.snakeyaml.Yaml; -import java.io.File; -import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -36,8 +36,8 @@ final class MessageMigraterPropertyReader implements PropertyReader { * @param file the file to load * @return the created property reader */ - public static MessageMigraterPropertyReader loadFromFile(File file) { - try (InputStream is = new FileInputStream(file)) { + public static MessageMigraterPropertyReader loadFromFile(Path file) { + try (InputStream is = Files.newInputStream(file)) { return loadFromStream(is); } catch (IOException e) { throw new IllegalStateException("Error while reading file '" + file + "'", e); diff --git a/src/main/java/fr/xephi/authme/message/updater/MessageUpdater.java b/src/main/java/fr/xephi/authme/message/updater/MessageUpdater.java index 77fc996b4..aeca297e8 100644 --- a/src/main/java/fr/xephi/authme/message/updater/MessageUpdater.java +++ b/src/main/java/fr/xephi/authme/message/updater/MessageUpdater.java @@ -2,7 +2,6 @@ package fr.xephi.authme.message.updater; import ch.jalu.configme.configurationdata.ConfigurationData; import ch.jalu.configme.configurationdata.PropertyListBuilder; -import ch.jalu.configme.properties.Property; import ch.jalu.configme.properties.StringProperty; import ch.jalu.configme.properties.convertresult.ConvertErrorRecorder; import ch.jalu.configme.resource.PropertyReader; @@ -10,8 +9,8 @@ import ch.jalu.configme.resource.PropertyResource; import com.google.common.collect.ImmutableMap; import com.google.common.io.Files; import fr.xephi.authme.ConsoleLogger; -import fr.xephi.authme.output.ConsoleLoggerFactory; import fr.xephi.authme.message.MessageKey; +import fr.xephi.authme.output.ConsoleLoggerFactory; import fr.xephi.authme.util.FileUtils; import java.io.File; @@ -102,9 +101,9 @@ public class MessageUpdater { private boolean addMissingKeys(JarMessageSource jarMessageSource, MessageKeyConfigurationData configurationData) { List addedKeys = new ArrayList<>(); - for (Property property : configurationData.getAllMessageProperties()) { + for (MessageKeyProperty property : configurationData.getAllMessageProperties()) { final String key = property.getPath(); - if (configurationData.getValue(property) == null) { + if (configurationData.getMessage(property) == null) { configurationData.setValue(property, jarMessageSource.getMessageFromJar(property)); addedKeys.add(key); } diff --git a/src/main/java/fr/xephi/authme/message/updater/MigraterYamlFileResource.java b/src/main/java/fr/xephi/authme/message/updater/MigraterYamlFileResource.java index b0122215b..94230b9f7 100644 --- a/src/main/java/fr/xephi/authme/message/updater/MigraterYamlFileResource.java +++ b/src/main/java/fr/xephi/authme/message/updater/MigraterYamlFileResource.java @@ -2,8 +2,14 @@ package fr.xephi.authme.message.updater; import ch.jalu.configme.resource.PropertyReader; import ch.jalu.configme.resource.YamlFileResource; +import ch.jalu.configme.resource.yaml.SnakeYamlNodeBuilder; +import ch.jalu.configme.resource.yaml.SnakeYamlNodeBuilderImpl; +import org.jetbrains.annotations.NotNull; import org.yaml.snakeyaml.DumperOptions; import org.yaml.snakeyaml.Yaml; +import org.yaml.snakeyaml.nodes.Node; +import org.yaml.snakeyaml.nodes.ScalarNode; +import org.yaml.snakeyaml.nodes.Tag; import java.io.File; @@ -12,36 +18,43 @@ import java.io.File; */ public class MigraterYamlFileResource extends YamlFileResource { - private Yaml singleQuoteYaml; - public MigraterYamlFileResource(File file) { super(file); } @Override public PropertyReader createReader() { - return MessageMigraterPropertyReader.loadFromFile(getFile()); + return MessageMigraterPropertyReader.loadFromFile(getPath()); } @Override protected Yaml createNewYaml() { - if (singleQuoteYaml == null) { - DumperOptions options = new DumperOptions(); - options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); - options.setAllowUnicode(true); - options.setDefaultScalarStyle(DumperOptions.ScalarStyle.SINGLE_QUOTED); - // Overridden setting: don't split lines - options.setSplitLines(false); - singleQuoteYaml = new Yaml(options); - } - return singleQuoteYaml; + DumperOptions options = new DumperOptions(); + options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); + options.setAllowUnicode(true); + options.setProcessComments(true); + options.setIndent(4); + // Overridden setting: don't split lines + options.setSplitLines(false); + return new Yaml(options); } - // Because we set the YAML object to put strings in single quotes, this method by default uses that YAML object - // and also puts all paths as single quotes. Override to just always return the same string since we know those - // are only message names (so never any conflicting strings like "true" or "0"). @Override - protected String escapePathElementIfNeeded(String path) { - return path; + protected @NotNull SnakeYamlNodeBuilder createNodeBuilder() { + return new MigraterYamlNodeBuilder(); + } + + /** Extended to represent all strings with single quotes in the YAML. */ + private static final class MigraterYamlNodeBuilder extends SnakeYamlNodeBuilderImpl { + + @Override + protected @NotNull Node createStringNode(@NotNull String value) { + return new ScalarNode(Tag.STR, value, null, null, DumperOptions.ScalarStyle.SINGLE_QUOTED); + } + + @Override + public @NotNull Node createKeyNode(@NotNull String key) { + return super.createStringNode(key); // no single quotes + } } }