Compare commits

..

102 Commits

Author SHA1 Message Date
HaHaWTH 233f0b107a B44 release 2024-03-26 23:54:02 +08:00
HaHaWTH 772103d81d Fix BedrockAutoLogin 2024-03-26 23:52:22 +08:00
DGun Otto 0ad235ccc1 Use JDK17 for workflows 2024-03-26 02:37:36 +08:00
HaHaWTH 61d41c3ac8 Cleanup 2024-03-26 01:07:18 +08:00
HaHaWTH 5ecc6adf8f Use spigot-api 1.20.4 2024-03-26 01:01:18 +08:00
DGun Otto a8e4489ae7 [ci skip] Update README.md 2024-03-26 00:46:43 +08:00
HaHaWTH a7888c0c67 Folia support 2024-03-25 22:50:27 +08:00
HaHaWTH 8932c71173 Fix 2024-03-25 21:37:25 +08:00
HaHaWTH 1f734f4b95 Cleanup javadoc 2024-03-25 20:55:30 +08:00
HaHaWTH fe06f06a11 Fix 2024-03-25 20:26:27 +08:00
HaHaWTH 3a8bd1d826 Revert 2024-03-25 19:53:25 +08:00
HaHaWTH 9f6199b8f2 Revert 2024-03-25 19:35:01 +08:00
HaHaWTH 3bf95f6eba Fix folia compatibility 2024-03-25 18:38:31 +08:00
HaHaWTH 4f88d15f8e Format 2024-03-25 16:36:27 +08:00
HaHaWTH 1c759b2476 Fix async potion effect 2024-03-25 16:31:03 +08:00
HaHaWTH 6f104f0b2e Update html 2024-03-25 15:17:04 +08:00
HaHaWTH 9b4b4634c3 Fix relocation 2024-03-25 14:05:06 +08:00
HaHaWTH 7dc331eb07 Fix tabcomplete 2024-03-25 12:24:53 +08:00
HaHaWTH 059320e5f1 Merge remote-tracking branch 'origin/master' 2024-03-25 12:23:25 +08:00
HaHaWTH 41a97ef3aa Fix tabcomplete 2024-03-25 12:21:44 +08:00
DGun Otto f52f466e53 [ci skip] Update LICENSE 2024-03-25 04:35:26 +08:00
HaHaWTH c2d726e9a6 Format 2024-03-25 03:48:09 +08:00
HaHaWTH 0d77a9745e Fix #57 again 2024-03-25 03:39:05 +08:00
HaHaWTH 48d5add08b Fix #57 2024-03-25 02:50:25 +08:00
HaHaWTH b40df54c9a Fix #57 2024-03-25 02:33:05 +08:00
HaHaWTH 4d65dd2a3a Update 2024-03-24 02:52:05 +08:00
HaHaWTH c5a4dfed03 Bug fix 2024-03-24 02:11:19 +08:00
HaHaWTH e8d74f559d Change default settings 2024-03-24 01:45:55 +08:00
HaHaWTH e2c848a737 Change default settings 2024-03-24 01:44:25 +08:00
HaHaWTH 625276a64f skip javadoc 2024-03-24 01:40:47 +08:00
HaHaWTH bf5b3f8358 Add plugin.yml 2024-03-24 01:37:58 +08:00
HaHaWTH 86a9075d04 Relocation 2024-03-24 01:34:16 +08:00
HaHaWTH 6acc1c0da8 Merge remote-tracking branch 'origin/master' 2024-03-24 01:33:12 +08:00
HaHaWTH 457997a430 Folia support 2024-03-24 01:32:20 +08:00
DGun Otto a3d0238e10 Merge pull request #112 from HaHaWTH/dependabot/maven/org.apache.maven.plugins-maven-compiler-plugin-3.13.0
Bump org.apache.maven.plugins:maven-compiler-plugin from 3.12.1 to 3.13.0
2024-03-19 13:53:13 +08:00
dependabot[bot] 0aed8ff2d7 Bump org.apache.maven.plugins:maven-compiler-plugin
Bumps [org.apache.maven.plugins:maven-compiler-plugin](https://github.com/apache/maven-compiler-plugin) from 3.12.1 to 3.13.0.
- [Release notes](https://github.com/apache/maven-compiler-plugin/releases)
- [Commits](https://github.com/apache/maven-compiler-plugin/compare/maven-compiler-plugin-3.12.1...maven-compiler-plugin-3.13.0)

---
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] <support@github.com>
2024-03-19 04:11:56 +00:00
DGun Otto 6a8f81f871 Merge pull request #111 from HaHaWTH/dependabot/maven/org.postgresql-postgresql-42.7.3
Bump org.postgresql:postgresql from 42.7.2 to 42.7.3
2024-03-16 00:46:37 +08:00
dependabot[bot] 90e3f8e5f2 Bump org.postgresql:postgresql from 42.7.2 to 42.7.3
Bumps [org.postgresql:postgresql](https://github.com/pgjdbc/pgjdbc) from 42.7.2 to 42.7.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.7.2...REL42.7.3)

---
updated-dependencies:
- dependency-name: org.postgresql:postgresql
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-03-15 05:00:47 +00:00
DGun Otto d8a316dddd Merge pull request #110 from HaHaWTH/dependabot/maven/org.xerial-sqlite-jdbc-3.45.2.0
Bump org.xerial:sqlite-jdbc from 3.45.1.0 to 3.45.2.0
2024-03-14 00:53:30 +08:00
dependabot[bot] c4d567186e Bump org.xerial:sqlite-jdbc from 3.45.1.0 to 3.45.2.0
Bumps [org.xerial:sqlite-jdbc](https://github.com/xerial/sqlite-jdbc) from 3.45.1.0 to 3.45.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.45.1.0...3.45.2.0)

---
updated-dependencies:
- dependency-name: org.xerial:sqlite-jdbc
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-03-13 04:23:55 +00:00
HaHaWTH 6ef4f0f3e3 Version b43 2024-03-09 23:41:03 +08:00
DGun Otto bb9c46b147 Revert MySQL dependency update 2024-02-27 13:34:18 +08:00
HaHaWTH 131d2429f9 Merge remote-tracking branch 'origin/master' 2024-02-26 01:30:28 +08:00
HaHaWTH d305fe6679 Commands 2024-02-26 01:30:10 +08:00
DGun Otto 35c801ae63 Merge pull request #109 from HaHaWTH/patch
Patch
2024-02-23 10:18:27 +08:00
DGun Otto b5a46d94de Merge branch 'master' into patch 2024-02-23 00:38:03 +08:00
DGun Otto 5a5992b353 Merge branch 'AuthMe:master' into patch 2024-02-23 00:35:05 +08:00
dependabot[bot] f56a23f4b7 Bump maven-install-plugin from 3.0.1 to 3.1.0 (#2643)
Bumps [maven-install-plugin](https://github.com/apache/maven-install-plugin) from 3.0.1 to 3.1.0.
- [Release notes](https://github.com/apache/maven-install-plugin/releases)
- [Commits](https://github.com/apache/maven-install-plugin/compare/maven-install-plugin-3.0.1...maven-install-plugin-3.1.0)

---
updated-dependencies:
- dependency-name: org.apache.maven.plugins:maven-install-plugin
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-22 11:44:00 +01:00
dependabot[bot] a57382f269 Bump maven-enforcer-plugin from 3.1.0 to 3.2.1 (#2681)
Bumps [maven-enforcer-plugin](https://github.com/apache/maven-enforcer) from 3.1.0 to 3.2.1.
- [Release notes](https://github.com/apache/maven-enforcer/releases)
- [Commits](https://github.com/apache/maven-enforcer/compare/enforcer-3.1.0...enforcer-3.2.1)

---
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] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-22 11:43:48 +01:00
dependabot[bot] 9380efdd3d Bump bcrypt from 0.9.0 to 0.10.2 (#2729)
Bumps [bcrypt](https://github.com/patrickfav/bcrypt) from 0.9.0 to 0.10.2.
- [Release notes](https://github.com/patrickfav/bcrypt/releases)
- [Changelog](https://github.com/patrickfav/bcrypt/blob/main/CHANGELOG)
- [Commits](https://github.com/patrickfav/bcrypt/compare/v0.9.0...v0.10.2)

---
updated-dependencies:
- dependency-name: at.favre.lib:bcrypt
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-22 11:43:17 +01:00
dependabot[bot] ad64370bf1 Bump net.essentialsx:EssentialsX from 2.20.0 to 2.20.1 (#2737)
Bumps [net.essentialsx:EssentialsX](https://github.com/EssentialsX/Essentials) from 2.20.0 to 2.20.1.
- [Release notes](https://github.com/EssentialsX/Essentials/releases)
- [Commits](https://github.com/EssentialsX/Essentials/compare/2.20.0...2.20.1)

---
updated-dependencies:
- dependency-name: net.essentialsx:EssentialsX
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-22 11:43:07 +01:00
dependabot[bot] 54bae76d27 Bump org.jacoco:jacoco-maven-plugin from 0.8.8 to 0.8.11 (#2756)
Bumps [org.jacoco:jacoco-maven-plugin](https://github.com/jacoco/jacoco) from 0.8.8 to 0.8.11.
- [Release notes](https://github.com/jacoco/jacoco/releases)
- [Commits](https://github.com/jacoco/jacoco/compare/v0.8.8...v0.8.11)

---
updated-dependencies:
- dependency-name: org.jacoco:jacoco-maven-plugin
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-22 11:42:54 +01:00
dependabot[bot] 93f1385c7a Bump com.mysql:mysql-connector-j from 8.0.33 to 8.2.0 (#2761)
Bumps [com.mysql:mysql-connector-j](https://github.com/mysql/mysql-connector-j) from 8.0.33 to 8.2.0.
- [Changelog](https://github.com/mysql/mysql-connector-j/blob/release/8.x/CHANGES)
- [Commits](https://github.com/mysql/mysql-connector-j/compare/8.0.33...8.2.0)

---
updated-dependencies:
- dependency-name: com.mysql:mysql-connector-j
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-22 11:42:40 +01:00
dependabot[bot] d5dbc7e5c7 Bump org.checkerframework:checker-qual from 3.26.0 to 3.40.0 (#2764)
Bumps [org.checkerframework:checker-qual](https://github.com/typetools/checker-framework) from 3.26.0 to 3.40.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.26.0...checker-framework-3.40.0)

---
updated-dependencies:
- dependency-name: org.checkerframework:checker-qual
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-22 11:42:17 +01:00
dependabot[bot] 72bbb4ebaa Bump org.mariadb.jdbc:mariadb-java-client from 3.1.4 to 3.3.0 (#2765)
Bumps [org.mariadb.jdbc:mariadb-java-client](https://github.com/mariadb-corporation/mariadb-connector-j) from 3.1.4 to 3.3.0.
- [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.1.4...3.3.0)

---
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] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-22 11:41:57 +01:00
dependabot[bot] caf0d3f8ed Bump org.xerial:sqlite-jdbc from 3.42.0.0 to 3.44.0.0 (#2766)
Bumps [org.xerial:sqlite-jdbc](https://github.com/xerial/sqlite-jdbc) from 3.42.0.0 to 3.44.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.42.0.0...3.44.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] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-22 11:40:56 +01:00
DGun Otto 95726cc7f9 Update PostgreSQL to silence CVE-2024-1597 warning (#2778) 2024-02-22 11:36:18 +01:00
DGun Otto ca7a070e4c [ci skip] Update README 2024-02-22 02:03:48 +08:00
DGun Otto ab1d952070 [ci skip] Remove mcbbs link 2024-02-22 02:00:18 +08:00
DGun Otto 1ce64bbcdf Update PostgreSQL to resolve CVE-2024-1597 2024-02-21 13:24:55 +08:00
DGun Otto 1c38384ac7 Update PostgreSQL to resolve CVE-2024-1597
Bump org.postgresql:postgresql from 42.6.0 to 42.7.2
2024-02-21 13:22:50 +08:00
DGun Otto 90ff68eacd Merge pull request #107 from HaHaWTH/dependabot/maven/org.mariadb.jdbc-mariadb-java-client-3.3.3
Bump org.mariadb.jdbc:mariadb-java-client from 3.1.4 to 3.3.3
2024-02-21 13:14:39 +08:00
DGun Otto f7569f3eb1 Merge pull request #105 from HaHaWTH/dependabot/maven/org.apache.maven.plugins-maven-shade-plugin-3.5.2
Bump org.apache.maven.plugins:maven-shade-plugin from 3.5.1 to 3.5.2
2024-02-21 13:14:03 +08:00
dependabot[bot] 77c289dc13 Bump org.mariadb.jdbc:mariadb-java-client from 3.1.4 to 3.3.3
Bumps [org.mariadb.jdbc:mariadb-java-client](https://github.com/mariadb-corporation/mariadb-connector-j) from 3.1.4 to 3.3.3.
- [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.1.4...3.3.3)

---
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] <support@github.com>
2024-02-21 04:33:40 +00:00
dependabot[bot] cca78be983 Bump org.postgresql:postgresql from 42.6.0 to 42.7.2
Bumps [org.postgresql:postgresql](https://github.com/pgjdbc/pgjdbc) from 42.6.0 to 42.7.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.6.0...REL42.7.2)

---
updated-dependencies:
- dependency-name: org.postgresql:postgresql
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-02-21 04:33:10 +00:00
dependabot[bot] c15575cb54 Bump org.apache.maven.plugins:maven-shade-plugin from 3.5.1 to 3.5.2
Bumps [org.apache.maven.plugins:maven-shade-plugin](https://github.com/apache/maven-shade-plugin) from 3.5.1 to 3.5.2.
- [Release notes](https://github.com/apache/maven-shade-plugin/releases)
- [Commits](https://github.com/apache/maven-shade-plugin/compare/maven-shade-plugin-3.5.1...maven-shade-plugin-3.5.2)

---
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] <support@github.com>
2024-02-21 04:32:53 +00:00
DGun Otto 81dd695999 Remove mirror repo 2024-02-20 21:04:50 +08:00
DGun Otto 3065b98456 ignore slf4j update 2024-02-14 16:24:00 +08:00
HaHaWTH e3c460e614 B42 release 2024-02-03 20:07:32 +08:00
HaHaWTH a1cb16dd3d Javadoc 2024-02-03 19:24:25 +08:00
HaHaWTH e9810c69f4 May fix 2024-02-03 19:07:48 +08:00
HaHaWTH 2b0bee198e May fix 2024-02-03 19:03:15 +08:00
HaHaWTH c31e009860 Ignore failed check 2024-02-01 17:11:50 +08:00
HaHaWTH 2b94776e71 Merge remote-tracking branch 'origin/master' 2024-01-31 21:14:05 +08:00
HaHaWTH fe2b877052 准丞相率三十万大军,择日启程,北伐曹魏! 2024-01-31 21:13:43 +08:00
DGun Otto efad796eb0 Merge pull request #98 from HaHaWTH/dependabot/maven/org.xerial-sqlite-jdbc-3.45.1.0
Bump org.xerial:sqlite-jdbc from 3.45.0.0 to 3.45.1.0
2024-01-31 13:47:02 +08:00
dependabot[bot] fe17b93bde Bump org.xerial:sqlite-jdbc from 3.45.0.0 to 3.45.1.0
Bumps [org.xerial:sqlite-jdbc](https://github.com/xerial/sqlite-jdbc) from 3.45.0.0 to 3.45.1.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.45.0.0...3.45.1.0)

---
updated-dependencies:
- dependency-name: org.xerial:sqlite-jdbc
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-01-31 05:00:09 +00:00
DGun Otto af9aa5c1cb [ci skip] Update README.md 2024-01-31 02:24:12 +08:00
HaHaWTH 5e39bd0bd3 B41 release 2024-01-30 23:01:31 +08:00
HaHaWTH ac5dfcde26 Update version command 2024-01-30 22:57:50 +08:00
HaHaWTH 8aef3ceb06 Patch H2 and Update H2 to 2.2.224 2024-01-30 13:42:10 +08:00
HaHaWTH 5155ab6302 Merge remote-tracking branch 'origin/master' 2024-01-30 01:23:59 +08:00
HaHaWTH cd5a008637 Add SQLiteToH2 converter 2024-01-30 01:21:15 +08:00
DGun Otto 58fe9a7394 [ci skip] Update README.md 2024-01-30 00:16:36 +08:00
HaHaWTH 910ebdd5bf Patch for H2 2024-01-30 00:14:44 +08:00
HaHaWTH 5f89964f49 Fix fakePlayers of Leaves NPE error 2024-01-29 22:52:54 +08:00
HaHaWTH 4f0bc6d12f relocations 2024-01-29 22:37:22 +08:00
HaHaWTH 9346285c08 H2 database support 2024-01-29 22:28:30 +08:00
HaHaWTH 19a4ec3176 H2 database support 2024-01-29 21:35:51 +08:00
HaHaWTH 46f64d8048 H2 database support 2024-01-29 21:34:40 +08:00
HaHaWTH e04608e499 Cleanup 2024-01-29 19:53:52 +08:00
HaHaWTH c402e2ec5a Optimize shulker fix 2024-01-29 19:46:00 +08:00
HaHaWTH 4437be8863 LoginLocFix now can be reloaded 2024-01-29 19:42:25 +08:00
DGun Otto b54c1f8d34 Update README.md 2024-01-21 19:53:18 +08:00
DGun Otto a9402846b5 Update README.md 2024-01-21 19:50:01 +08:00
DGun Otto c37e4b2374 Merge pull request #97 from HaHaWTH/dependabot/maven/org.xerial-sqlite-jdbc-3.45.0.0
Bump org.xerial:sqlite-jdbc from 3.44.1.0 to 3.45.0.0
2024-01-19 23:16:07 +08:00
dependabot[bot] acad03fbbf Bump org.xerial:sqlite-jdbc from 3.44.1.0 to 3.45.0.0
Bumps [org.xerial:sqlite-jdbc](https://github.com/xerial/sqlite-jdbc) from 3.44.1.0 to 3.45.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.44.1.0...3.45.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] <support@github.com>
2024-01-19 04:16:34 +00:00
HaHaWTH 8061645346 Revert changes 2024-01-14 13:56:30 +08:00
HaHaWTH b97840a320 Folia Support 2024-01-14 12:56:20 +08:00
HaHaWTH a5ba77a3d2 Folia Support 2024-01-14 12:53:42 +08:00
HaHaWTH ea383dd0f1 Folia Support 2024-01-14 11:43:25 +08:00
HaHaWTH 885db23fc6 Folia Support(dev) 2024-01-14 11:03:12 +08:00
53 changed files with 1043 additions and 893 deletions
+2
View File
@@ -12,3 +12,5 @@ updates:
- dependency-name: com.zaxxer:HikariCP - dependency-name: com.zaxxer:HikariCP
- dependency-name: "org.mockito:mockito-core" # Mockito 5 requires Java 11 - dependency-name: "org.mockito:mockito-core" # Mockito 5 requires Java 11
versions: ">= 5" versions: ">= 5"
- dependency-name: "org.slf4j:slf4j-simple"
versions: ">= 1.7.36"
+1 -1
View File
@@ -10,7 +10,7 @@ jobs:
Build: Build:
strategy: strategy:
matrix: matrix:
jdkversion: [ 11 ] jdkversion: [ 17 ]
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
+70 -83
View File
@@ -1,23 +1,21 @@
GNU GENERAL PUBLIC LICENSE GNU AFFERO GENERAL PUBLIC LICENSE
Version 3, 29 June 2007 Version 3, 19 November 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed. of this license document, but changing it is not allowed.
Preamble Preamble
The GNU General Public License is a free, copyleft license for The GNU Affero General Public License is a free, copyleft license for
software and other kinds of works. software and other kinds of works, specifically designed to ensure
cooperation with the community in the case of network server software.
The licenses for most software and other practical works are designed The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast, to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to our General Public Licenses are intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the software for all its users.
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you price. Our General Public Licenses are designed to make sure that you
@@ -26,44 +24,34 @@ them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things. free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you Developers that use our General Public Licenses protect your rights
these rights or asking you to surrender the rights. Therefore, you have with two steps: (1) assert copyright on the software, and (2) offer
certain responsibilities if you distribute copies of the software, or if you this License which gives you legal permission to copy, distribute
you modify it: responsibilities to respect the freedom of others. and/or modify the software.
For example, if you distribute copies of such a program, whether A secondary benefit of defending all users' freedom is that
gratis or for a fee, you must pass on to the recipients the same improvements made in alternate versions of the program, if they
freedoms that you received. You must make sure that they, too, receive receive widespread use, become available for other developers to
or can get the source code. And you must show them these terms so they incorporate. Many developers of free software are heartened and
know their rights. encouraged by the resulting cooperation. However, in the case of
software used on network servers, this result may fail to come about.
The GNU General Public License permits making a modified version and
letting the public access it on a server without ever releasing its
source code to the public.
Developers that use the GNU GPL protect your rights with two steps: The GNU Affero General Public License is designed specifically to
(1) assert copyright on the software, and (2) offer you this License ensure that, in such cases, the modified source code becomes available
giving you legal permission to copy, distribute and/or modify it. to the community. It requires the operator of a network server to
provide the source code of the modified version running there to the
users of that server. Therefore, public use of a modified version, on
a publicly accessible server, gives the public access to the source
code of the modified version.
For the developers' and authors' protection, the GPL clearly explains An older license, called the Affero General Public License and
that there is no warranty for this free software. For both users' and published by Affero, was designed to accomplish similar goals. This is
authors' sake, the GPL requires that modified versions be marked as a different license, not a version of the Affero GPL, but Affero has
changed, so that their problems will not be attributed erroneously to released a new version of the Affero GPL which permits relicensing under
authors of previous versions. this license.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and The precise terms and conditions for copying, distribution and
modification follow. modification follow.
@@ -72,7 +60,7 @@ modification follow.
0. Definitions. 0. Definitions.
"This License" refers to version 3 of the GNU General Public License. "This License" refers to version 3 of the GNU Affero General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of "Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks. works, such as semiconductor masks.
@@ -549,35 +537,45 @@ to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program. License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License. 13. Remote Network Interaction; Use with the GNU General Public License.
Notwithstanding any other provision of this License, if you modify the
Program, your modified version must prominently offer all users
interacting with it remotely through a computer network (if your version
supports such interaction) an opportunity to receive the Corresponding
Source of your version by providing access to the Corresponding Source
from a network server at no charge, through some standard or customary
means of facilitating copying of software. This Corresponding Source
shall include the Corresponding Source for any work covered by version 3
of the GNU General Public License that is incorporated pursuant to the
following paragraph.
Notwithstanding any other provision of this License, you have Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single under version 3 of the GNU General Public License into a single
combined work, and to convey the resulting work. The terms of this combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work, License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License, but the work with which it is combined will remain governed by version
section 13, concerning interaction through a network will apply to the 3 of the GNU General Public License.
combination as such.
14. Revised Versions of this License. 14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will the GNU Affero General Public License from time to time. Such new versions
be similar in spirit to the present version, but may differ in detail to will be similar in spirit to the present version, but may differ in detail to
address new problems or concerns. address new problems or concerns.
Each version is given a distinguishing version number. If the Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General Program specifies that a certain numbered version of the GNU Affero General
Public License "or any later version" applies to it, you have the Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published GNU Affero General Public License, you may choose any version ever published
by the Free Software Foundation. by the Free Software Foundation.
If the Program specifies that a proxy can decide which future If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's versions of the GNU Affero General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you public statement of acceptance of a version permanently authorizes you
to choose that version for the Program. to choose that version for the Program.
@@ -631,44 +629,33 @@ to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found. the "copyright" line and a pointer to where the full notice is found.
{one line to give the program's name and a brief idea of what it does.} <one line to give the program's name and a brief idea of what it does.>
Copyright (C) {year} {name of author} Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU Affero General Public License as published
the Free Software Foundation, either version 3 of the License, or by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU Affero General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail. Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short If your software can interact with users remotely through a computer
notice like this when it starts in an interactive mode: network, you should also make sure that it provides a way for users to
get its source. For example, if your program is a web application, its
{project} Copyright (C) {year} {fullname} interface could display a "Source" link that leads users to an archive
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. of the code. There are many ways you could offer source, and different
This is free software, and you are welcome to redistribute it solutions will be better for different programs; see section 13 for the
under certain conditions; type `show c' for details. specific requirements.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school, You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary. if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see For more information on this, and how to apply and follow the GNU AGPL, see
<http://www.gnu.org/licenses/>. <https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
+16 -5
View File
@@ -1,6 +1,6 @@
# AuthMeReReloaded # AuthMeReReloaded
**"A fork of the best authentication plugin for the Bukkit modding API!⭐"** **"A fork of the best authentication plugin for the Bukkit modding API!⭐"**
MCBBS Link: [Click Here](https://www.mcbbs.net/forum.php?mod=viewthread&tid=1471495)
![Graph](https://bstats.org/signatures/bukkit/AuthMeReloaded-Fork.svg) ![Graph](https://bstats.org/signatures/bukkit/AuthMeReloaded-Fork.svg)
<p align="center"> <p align="center">
<img src="https://img.shields.io/github/languages/code-size/HaHaWTH/AuthMeReReloaded.svg" alt="Code size"/> <img src="https://img.shields.io/github/languages/code-size/HaHaWTH/AuthMeReReloaded.svg" alt="Code size"/>
@@ -20,18 +20,29 @@ MCBBS Link: [Click Here](https://www.mcbbs.net/forum.php?mod=viewthread&tid=1471
9. Improved listeners 9. Improved listeners
10. Player login logic improvement to reduce lag 10. Player login logic improvement to reduce lag
11. Automatically purge bot data 11. Automatically purge bot data
12. Folia 12. Folia compatibility (Still WIP)
compatibility [Here](https://github.com/HaHaWTH/AuthMeReReloaded/releases/download/b20/AuthMe-5.6.0-FORK-Folia.jar)
13. Offhand Menu compatibility(Thats amazing) 13. Offhand Menu compatibility(Thats amazing)
14. Automatically fix portal stuck issue 14. Automatically fix portal stuck issue
15. Automatically login for Bedrock players(configurable) 15. Automatically login for Bedrock players(configurable)
16. Fix shulker box crash bug on legacy versions(MC 1.13-) 16. Fix shulker box crash bug on legacy versions(MC 1.13-)
17. More...... 17. **H2 database support**
18. **100% compatibility with original authme and extensions**
19. More......
**Download links:** **Download links:**
[Releases](https://github.com/HaHaWTH/AuthMeReReloaded/releases/latest) [Releases](https://github.com/HaHaWTH/AuthMeReReloaded/releases/latest)
[Actions(Dev builds, use at your own risk!)](https://github.com/HaHaWTH/AuthMeReReloaded/actions/workflows/maven.yml) [Actions(Dev builds, use at your own risk!)](https://github.com/HaHaWTH/AuthMeReReloaded/actions/workflows/maven.yml)
TODO: Implement HAProxy ip forward(Useful for Frp) If you are using FRP(内网穿透) for your server, this plugin may help [HAProxy-Detector](https://github.com/HaHaWTH/HAProxy-Detector)
**Pull Requests and suggestions are welcome!** **Pull Requests and suggestions are welcome!**
<picture>
<source
media="(prefers-color-scheme: dark)"
srcset="
https://api.star-history.com/svg?repos=HaHaWTH/AuthMeReReloaded&type=Date&theme=dark
"
/>
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=HaHaWTH/AuthMeReReloaded&type=Date" />
</picture>
+1 -1
View File
@@ -9,7 +9,7 @@ the generated config.yml file.
```yml ```yml
DataSource: DataSource:
# What type of database do you want to use? # What type of database do you want to use?
# Valid values: SQLITE, MARIADB, MYSQL, POSTGRESQL # Valid values: H2, SQLITE, MARIADB, MYSQL, POSTGRESQL
backend: SQLITE backend: SQLITE
# Enable the database caching system, should be disabled on bungeecord environments # Enable the database caching system, should be disabled on bungeecord environments
# or when a website integration is being used. # or when a website integration is being used.
+78 -16
View File
@@ -67,7 +67,7 @@
<maven.minimumVersion>3.6.3</maven.minimumVersion> <maven.minimumVersion>3.6.3</maven.minimumVersion>
<!-- Dependencies versions --> <!-- Dependencies versions -->
<spigot.version>1.20.2-R0.1-SNAPSHOT</spigot.version> <spigot.version>1.20.4-R0.1-SNAPSHOT</spigot.version>
<!-- Versioning properties --> <!-- Versioning properties -->
<project.outputName>AuthMe</project.outputName> <project.outputName>AuthMe</project.outputName>
@@ -155,6 +155,11 @@
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId> <artifactId>maven-javadoc-plugin</artifactId>
<version>3.4.1</version> <version>3.4.1</version>
<configuration>
<failOnError>false</failOnError>
<failOnWarnings>false</failOnWarnings>
<skip>true</skip>
</configuration>
</plugin> </plugin>
</plugins> </plugins>
</pluginManagement> </pluginManagement>
@@ -164,7 +169,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId> <artifactId>maven-enforcer-plugin</artifactId>
<version>3.1.0</version> <version>3.2.1</version>
<executions> <executions>
<execution> <execution>
<id>enforce-environment</id> <id>enforce-environment</id>
@@ -206,7 +211,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>3.12.1</version> <version>3.13.0</version>
<configuration> <configuration>
<source>${java.source}</source> <source>${java.source}</source>
<target>${java.target}</target> <target>${java.target}</target>
@@ -217,7 +222,7 @@
<plugin> <plugin>
<groupId>org.jacoco</groupId> <groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId> <artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.8</version> <version>0.8.11</version>
<executions> <executions>
<execution> <execution>
<id>pre-unit-test</id> <id>pre-unit-test</id>
@@ -294,7 +299,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId> <artifactId>maven-shade-plugin</artifactId>
<version>3.4.1</version> <version>3.5.2</version>
<executions> <executions>
<execution> <execution>
<id>shaded-jar</id> <id>shaded-jar</id>
@@ -318,7 +323,7 @@
</configuration> </configuration>
</execution> </execution>
<execution> <execution>
<id>shaded-jar-legacy</id> <id>shaded-jar-relocate</id>
<phase>package</phase> <phase>package</phase>
<goals> <goals>
<goal>shade</goal> <goal>shade</goal>
@@ -334,6 +339,10 @@
<pattern>com.google.thirdparty</pattern> <pattern>com.google.thirdparty</pattern>
<shadedPattern>fr.xephi.authme.libs.com.google.thirdparty</shadedPattern> <shadedPattern>fr.xephi.authme.libs.com.google.thirdparty</shadedPattern>
</relocation> </relocation>
<relocation>
<pattern>com.cryptomorin.xseries</pattern>
<shadedPattern>fr.xephi.authme.libs.xseries</shadedPattern>
</relocation>
<relocation> <relocation>
<pattern>com.google.j2objc</pattern> <pattern>com.google.j2objc</pattern>
<shadedPattern>fr.xephi.authme.libs.com.google.j2objc</shadedPattern> <shadedPattern>fr.xephi.authme.libs.com.google.j2objc</shadedPattern>
@@ -346,10 +355,50 @@
<pattern>com.google.gson</pattern> <pattern>com.google.gson</pattern>
<shadedPattern>fr.xephi.authme.libs.com.google.gson</shadedPattern> <shadedPattern>fr.xephi.authme.libs.com.google.gson</shadedPattern>
</relocation> </relocation>
<!-- <relocation>--> <relocation>
<!-- <pattern>com.cryptomorin.xseries</pattern>--> <pattern>org.h2</pattern>
<!-- <shadedPattern>fr.xephi.authme.libs.com.cryptomorin.xseries</shadedPattern>--> <shadedPattern>fr.xephi.authme.libs.org.h2</shadedPattern>
<!-- </relocation>--> </relocation>
<relocation>
<pattern>org.apache.http</pattern>
<shadedPattern>fr.xephi.authme.libs.org.apache.http</shadedPattern>
</relocation>
<relocation>
<pattern>org.apache.commons</pattern>
<shadedPattern>fr.xephi.authme.libs.org.apache.commons</shadedPattern>
</relocation>
<relocation>
<pattern>javax.activation</pattern>
<shadedPattern>fr.xephi.authme.libs.javax.activation</shadedPattern>
</relocation>
<relocation>
<pattern>javax.annotation</pattern>
<shadedPattern>fr.xephi.authme.libs.javax.annotation</shadedPattern>
</relocation>
<relocation>
<pattern>javax.mail</pattern>
<shadedPattern>fr.xephi.authme.libs.javax.mail</shadedPattern>
</relocation>
<relocation>
<pattern>waffle</pattern>
<shadedPattern>fr.xephi.authme.libs.waffle</shadedPattern>
</relocation>
<relocation>
<pattern>com.sun.mail</pattern>
<shadedPattern>fr.xephi.authme.libs.com.sun.mail</shadedPattern>
</relocation>
<relocation>
<pattern>com.sun.jna</pattern>
<shadedPattern>fr.xephi.authme.libs.com.sun.jna</shadedPattern>
</relocation>
<relocation>
<pattern>com.sun.activation</pattern>
<shadedPattern>fr.xephi.authme.libs.com.sun.activation</shadedPattern>
</relocation>
<relocation>
<pattern>com.github.benmanes.caffeine</pattern>
<shadedPattern>fr.xephi.authme.libs.com.github.benmanes.caffeine</shadedPattern>
</relocation>
</relocations> </relocations>
</configuration> </configuration>
</execution> </execution>
@@ -436,6 +485,10 @@
<pattern>org.mariadb.jdbc</pattern> <pattern>org.mariadb.jdbc</pattern>
<shadedPattern>fr.xephi.authme.libs.org.mariadb.jdbc</shadedPattern> <shadedPattern>fr.xephi.authme.libs.org.mariadb.jdbc</shadedPattern>
</relocation> </relocation>
<relocation>
<pattern>com.github.Anon8281.universalScheduler</pattern>
<shadedPattern>fr.xephi.authme.libs.com.github.Anon8281.universalScheduler</shadedPattern>
</relocation>
<relocation> <relocation>
<pattern>com.mysql</pattern> <pattern>com.mysql</pattern>
<shadedPattern>fr.xephi.authme.libs.com.mysql</shadedPattern> <shadedPattern>fr.xephi.authme.libs.com.mysql</shadedPattern>
@@ -484,7 +537,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId> <artifactId>maven-install-plugin</artifactId>
<version>3.0.1</version> <version>3.1.0</version>
</plugin> </plugin>
<!-- Deploy the jars as artifacts into the remote repository --> <!-- Deploy the jars as artifacts into the remote repository -->
<plugin> <plugin>
@@ -656,6 +709,7 @@
<version>2.2.2-SNAPSHOT</version> <version>2.2.2-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- Jalu Injector --> <!-- Jalu Injector -->
<dependency> <dependency>
<groupId>ch.jalu</groupId> <groupId>ch.jalu</groupId>
@@ -750,7 +804,7 @@
<dependency> <dependency>
<groupId>org.mariadb.jdbc</groupId> <groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId> <artifactId>mariadb-java-client</artifactId>
<version>3.1.4</version> <version>3.3.3</version>
<optional>true</optional> <optional>true</optional>
</dependency> </dependency>
@@ -1067,7 +1121,7 @@
<dependency> <dependency>
<groupId>org.postgresql</groupId> <groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId> <artifactId>postgresql</artifactId>
<version>42.6.0</version> <version>42.7.3</version>
<optional>true</optional> <optional>true</optional>
<exclusions> <exclusions>
<exclusion> <exclusion>
@@ -1114,18 +1168,26 @@
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<!-- Universal Scheduler -->
<dependency>
<groupId>com.github.Anon8281</groupId>
<artifactId>UniversalScheduler</artifactId>
<version>0.1.6</version>
<scope>compile</scope>
</dependency>
<!-- JDBC drivers for datasource integration tests --> <!-- JDBC drivers for datasource integration tests -->
<dependency> <dependency>
<groupId>org.xerial</groupId> <groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId> <artifactId>sqlite-jdbc</artifactId>
<version>3.44.1.0</version> <version>3.45.2.0</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.h2database</groupId> <groupId>com.h2database</groupId>
<artifactId>h2</artifactId> <artifactId>h2</artifactId>
<version>2.1.214</version> <version>2.2.224</version>
<scope>test</scope> <scope>compile</scope>
</dependency> </dependency>
</dependencies> </dependencies>
+20 -8
View File
@@ -2,8 +2,11 @@ package fr.xephi.authme;
import ch.jalu.injector.Injector; import ch.jalu.injector.Injector;
import ch.jalu.injector.InjectorBuilder; import ch.jalu.injector.InjectorBuilder;
import com.github.Anon8281.universalScheduler.UniversalScheduler;
import com.github.Anon8281.universalScheduler.scheduling.schedulers.TaskScheduler;
import fr.xephi.authme.api.v3.AuthMeApi; import fr.xephi.authme.api.v3.AuthMeApi;
import fr.xephi.authme.command.CommandHandler; import fr.xephi.authme.command.CommandHandler;
import fr.xephi.authme.command.TabCompleteHandler;
import fr.xephi.authme.datasource.DataSource; import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.initialization.DataFolder; import fr.xephi.authme.initialization.DataFolder;
import fr.xephi.authme.initialization.DataSourceProvider; import fr.xephi.authme.initialization.DataSourceProvider;
@@ -23,6 +26,7 @@ import fr.xephi.authme.listener.PlayerListener111;
import fr.xephi.authme.listener.PlayerListener19; import fr.xephi.authme.listener.PlayerListener19;
import fr.xephi.authme.listener.PlayerListener19Spigot; import fr.xephi.authme.listener.PlayerListener19Spigot;
import fr.xephi.authme.listener.PlayerListenerHigherThan18; import fr.xephi.authme.listener.PlayerListenerHigherThan18;
import fr.xephi.authme.listener.PurgeListener;
import fr.xephi.authme.listener.ServerListener; import fr.xephi.authme.listener.ServerListener;
import fr.xephi.authme.mail.EmailService; import fr.xephi.authme.mail.EmailService;
import fr.xephi.authme.output.ConsoleLoggerFactory; import fr.xephi.authme.output.ConsoleLoggerFactory;
@@ -45,7 +49,6 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitScheduler;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import javax.inject.Inject; import javax.inject.Inject;
@@ -55,6 +58,7 @@ import java.net.HttpURLConnection;
import java.net.URL; import java.net.URL;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.Objects;
import java.util.Scanner; import java.util.Scanner;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.logging.Level; import java.util.logging.Level;
@@ -75,10 +79,11 @@ public class AuthMe extends JavaPlugin {
// Version and build number values // Version and build number values
private static String pluginVersion = "5.6.0-Fork"; private static String pluginVersion = "5.6.0-Fork";
private static final String pluginBuild = "b"; private static final String pluginBuild = "b";
private static String pluginBuildNumber = "40"; private static String pluginBuildNumber = "44";
// Private instances // Private instances
private EmailService emailService; private EmailService emailService;
private CommandHandler commandHandler; private CommandHandler commandHandler;
private static TaskScheduler scheduler;
@Inject @Inject
public static Settings settings; public static Settings settings;
private DataSource database; private DataSource database;
@@ -130,7 +135,12 @@ public class AuthMe extends JavaPlugin {
return pluginBuildNumber; return pluginBuildNumber;
} }
/**
* Get the scheduler
*/
public static TaskScheduler getScheduler() {
return scheduler;
}
/** /**
* Method called when the server enables the plugin. * Method called when the server enables the plugin.
@@ -139,6 +149,7 @@ public class AuthMe extends JavaPlugin {
public void onEnable() { public void onEnable() {
// Load the plugin version data from the plugin description file // Load the plugin version data from the plugin description file
loadPluginInfo(getDescription().getVersion()); loadPluginInfo(getDescription().getVersion());
scheduler = UniversalScheduler.getScheduler(this);
// Set the Logger instance and log file path // Set the Logger instance and log file path
ConsoleLogger.initialize(getLogger(), new File(getDataFolder(), LOG_FILENAME)); ConsoleLogger.initialize(getLogger(), new File(getDataFolder(), LOG_FILENAME));
@@ -197,9 +208,10 @@ public class AuthMe extends JavaPlugin {
"/_/ |_\\__,_/\\__/_/ /_/_/ /_/\\___/ \n" + "/_/ |_\\__,_/\\__/_/ /_/_/ /_/\\___/ \n" +
" "); " ");
} }
// Successful message
//detect server brand with classloader //detect server brand with classloader
checkServerType(); checkServerType();
Objects.requireNonNull(getCommand("register")).setTabCompleter(new TabCompleteHandler());
Objects.requireNonNull(getCommand("login")).setTabCompleter(new TabCompleteHandler());
logger.info("AuthMeReReloaded is enabled successfully!"); logger.info("AuthMeReReloaded is enabled successfully!");
// Purge on start if enabled // Purge on start if enabled
PurgeService purgeService = injector.getSingleton(PurgeService.class); PurgeService purgeService = injector.getSingleton(PurgeService.class);
@@ -246,7 +258,6 @@ public class AuthMe extends JavaPlugin {
injector.register(AuthMe.class, this); injector.register(AuthMe.class, this);
injector.register(Server.class, getServer()); injector.register(Server.class, getServer());
injector.register(PluginManager.class, getServer().getPluginManager()); injector.register(PluginManager.class, getServer().getPluginManager());
injector.register(BukkitScheduler.class, getServer().getScheduler());
injector.provide(DataFolder.class, getDataFolder()); injector.provide(DataFolder.class, getDataFolder());
injector.registerProvider(Settings.class, SettingsProvider.class); injector.registerProvider(Settings.class, SettingsProvider.class);
injector.registerProvider(DataSource.class, DataSourceProvider.class); injector.registerProvider(DataSource.class, DataSourceProvider.class);
@@ -355,6 +366,9 @@ public class AuthMe extends JavaPlugin {
} else if (settings.getProperty(SecuritySettings.ADVANCED_SHULKER_FIX) && isClassLoaded("org.bukkit.event.player.PlayerCommandSendEvent")) { } else if (settings.getProperty(SecuritySettings.ADVANCED_SHULKER_FIX) && isClassLoaded("org.bukkit.event.player.PlayerCommandSendEvent")) {
logger.warning("You are running an 1.13+ minecraft server, advancedShulkerFix won't enable."); logger.warning("You are running an 1.13+ minecraft server, advancedShulkerFix won't enable.");
} }
if (settings.getProperty(SecuritySettings.PURGE_DATA_ON_QUIT)) {
pluginManager.registerEvents(injector.getSingleton(PurgeListener.class), this);
}
} }
/** /**
@@ -426,9 +440,7 @@ public class AuthMe extends JavaPlugin {
} else { } else {
getLogger().log(Level.INFO, "You are running the latest version."); getLogger().log(Level.INFO, "You are running the latest version.");
} }
} catch (IOException e) { } catch (IOException ignored) {
String formattedException = ExceptionUtils.formatException(e);
getLogger().log(Level.WARNING, "Error occurred while checking updates from GitHub. Reason: " + formattedException);
} }
}); });
} }
@@ -84,14 +84,14 @@ public final class CommandUtils {
* @return formatted command syntax incl. arguments * @return formatted command syntax incl. arguments
*/ */
public static String buildSyntax(CommandDescription command, List<String> correctLabels) { public static String buildSyntax(CommandDescription command, List<String> correctLabels) {
String commandSyntax = ChatColor.WHITE + "/" + correctLabels.get(0) + ChatColor.YELLOW; StringBuilder commandSyntax = new StringBuilder(ChatColor.WHITE + "/" + correctLabels.get(0) + ChatColor.YELLOW);
for (int i = 1; i < correctLabels.size(); ++i) { for (int i = 1; i < correctLabels.size(); ++i) {
commandSyntax += " " + correctLabels.get(i); commandSyntax.append(" ").append(correctLabels.get(i));
} }
for (CommandArgumentDescription argument : command.getArguments()) { for (CommandArgumentDescription argument : command.getArguments()) {
commandSyntax += " " + formatArgument(argument); commandSyntax.append(" ").append(formatArgument(argument));
} }
return commandSyntax; return commandSyntax.toString();
} }
/** /**
@@ -0,0 +1,17 @@
package fr.xephi.authme.command;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
public class TabCompleteHandler implements TabCompleter {
@Override
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
return new ArrayList<>();
}
}
@@ -11,6 +11,7 @@ import fr.xephi.authme.datasource.converter.LoginSecurityConverter;
import fr.xephi.authme.datasource.converter.MySqlToSqlite; import fr.xephi.authme.datasource.converter.MySqlToSqlite;
import fr.xephi.authme.datasource.converter.RakamakConverter; import fr.xephi.authme.datasource.converter.RakamakConverter;
import fr.xephi.authme.datasource.converter.RoyalAuthConverter; import fr.xephi.authme.datasource.converter.RoyalAuthConverter;
import fr.xephi.authme.datasource.converter.SqliteToH2;
import fr.xephi.authme.datasource.converter.SqliteToSql; import fr.xephi.authme.datasource.converter.SqliteToSql;
import fr.xephi.authme.datasource.converter.VAuthConverter; import fr.xephi.authme.datasource.converter.VAuthConverter;
import fr.xephi.authme.datasource.converter.XAuthConverter; import fr.xephi.authme.datasource.converter.XAuthConverter;
@@ -89,6 +90,7 @@ public class ConverterCommand implements ExecutableCommand {
.put("vauth", VAuthConverter.class) .put("vauth", VAuthConverter.class)
.put("sqlitetosql", SqliteToSql.class) .put("sqlitetosql", SqliteToSql.class)
.put("mysqltosqlite", MySqlToSqlite.class) .put("mysqltosqlite", MySqlToSqlite.class)
.put("sqlitetoh2", SqliteToH2.class)
.put("loginsecurity", LoginSecurityConverter.class) .put("loginsecurity", LoginSecurityConverter.class)
.build(); .build();
} }
@@ -1,13 +1,12 @@
package fr.xephi.authme.command.executable.authme; package fr.xephi.authme.command.executable.authme;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.command.PlayerCommand; import fr.xephi.authme.command.PlayerCommand;
import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.SpawnLoader; import fr.xephi.authme.settings.SpawnLoader;
import fr.xephi.authme.settings.properties.SecuritySettings; import fr.xephi.authme.settings.properties.SecuritySettings;
import fr.xephi.authme.util.TeleportUtils; import fr.xephi.authme.util.TeleportUtils;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import fr.xephi.authme.AuthMe;
import javax.inject.Inject; import javax.inject.Inject;
import java.util.List; import java.util.List;
@@ -78,7 +78,8 @@ public class RegisterAdminCommand implements ExecutableCommand {
final Player player = bukkitService.getPlayerExact(playerName); final Player player = bukkitService.getPlayerExact(playerName);
if (player != null) { if (player != null) {
bukkitService.scheduleSyncTaskFromOptionallyAsyncTask(() -> bukkitService.scheduleSyncTaskFromOptionallyAsyncTask(() ->
player.kickPlayer(commonService.retrieveSingleMessage(player, MessageKey.KICK_FOR_ADMIN_REGISTER))); // AuthMeReReloaded - Folia compatibility
bukkitService.runTaskIfFolia(player, () -> player.kickPlayer(commonService.retrieveSingleMessage(player, MessageKey.KICK_FOR_ADMIN_REGISTER))));
} }
}); });
} }
@@ -45,34 +45,31 @@ public class SetEmailCommand implements ExecutableCommand {
return; return;
} }
bukkitService.runTaskOptionallyAsync(new Runnable() { bukkitService.runTaskOptionallyAsync(() -> { // AuthMeReReloaded - Folia compatibility
@Override // Validate the user
public void run() { PlayerAuth auth = dataSource.getAuth(playerName);
// Validate the user if (auth == null) {
PlayerAuth auth = dataSource.getAuth(playerName); commonService.send(sender, MessageKey.UNKNOWN_USER);
if (auth == null) { return;
commonService.send(sender, MessageKey.UNKNOWN_USER); } else if (!validationService.isEmailFreeForRegistration(playerEmail, sender)) {
return; commonService.send(sender, MessageKey.EMAIL_ALREADY_USED_ERROR);
} else if (!validationService.isEmailFreeForRegistration(playerEmail, sender)) { return;
commonService.send(sender, MessageKey.EMAIL_ALREADY_USED_ERROR);
return;
}
// Set the email address
auth.setEmail(playerEmail);
if (!dataSource.updateEmail(auth)) {
commonService.send(sender, MessageKey.ERROR);
return;
}
// Update the player cache
if (playerCache.getAuth(playerName) != null) {
playerCache.updatePlayer(auth);
}
// Show a status message
commonService.send(sender, MessageKey.EMAIL_CHANGED_SUCCESS);
} }
// Set the email address
auth.setEmail(playerEmail);
if (!dataSource.updateEmail(auth)) {
commonService.send(sender, MessageKey.ERROR);
return;
}
// Update the player cache
if (playerCache.getAuth(playerName) != null) {
playerCache.updatePlayer(auth);
}
// Show a status message
commonService.send(sender, MessageKey.EMAIL_CHANGED_SUCCESS);
}); });
} }
} }
@@ -3,6 +3,8 @@ package fr.xephi.authme.command.executable.authme;
import fr.xephi.authme.AuthMe; import fr.xephi.authme.AuthMe;
import fr.xephi.authme.command.ExecutableCommand; import fr.xephi.authme.command.ExecutableCommand;
import fr.xephi.authme.service.BukkitService; import fr.xephi.authme.service.BukkitService;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.DatabaseSettings;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@@ -17,6 +19,8 @@ public class VersionCommand implements ExecutableCommand {
@Inject @Inject
private BukkitService bukkitService; private BukkitService bukkitService;
@Inject
private Settings settings;
@Override @Override
public void executeCommand(CommandSender sender, List<String> arguments) { public void executeCommand(CommandSender sender, List<String> arguments) {
@@ -24,6 +28,7 @@ public class VersionCommand implements ExecutableCommand {
sender.sendMessage(ChatColor.GOLD + "==========[ " + AuthMe.getPluginName() + " ABOUT ]=========="); sender.sendMessage(ChatColor.GOLD + "==========[ " + AuthMe.getPluginName() + " ABOUT ]==========");
sender.sendMessage(ChatColor.GOLD + "Version: " + ChatColor.WHITE + AuthMe.getPluginName() sender.sendMessage(ChatColor.GOLD + "Version: " + ChatColor.WHITE + AuthMe.getPluginName()
+ " v" + AuthMe.getPluginVersion() + ChatColor.GRAY + " (build: " + AuthMe.getPluginBuildNumber() + ")"); + " v" + AuthMe.getPluginVersion() + ChatColor.GRAY + " (build: " + AuthMe.getPluginBuildNumber() + ")");
sender.sendMessage(ChatColor.GOLD + "Database Implementation: " + ChatColor.WHITE + settings.getProperty(DatabaseSettings.BACKEND).toString());
sender.sendMessage(ChatColor.GOLD + "Authors:"); sender.sendMessage(ChatColor.GOLD + "Authors:");
Collection<Player> onlinePlayers = bukkitService.getOnlinePlayers(); Collection<Player> onlinePlayers = bukkitService.getOnlinePlayers();
printDeveloper(sender, "Gabriele C.", "sgdc3", "Project manager, Contributor", onlinePlayers); printDeveloper(sender, "Gabriele C.", "sgdc3", "Project manager, Contributor", onlinePlayers);
@@ -103,7 +103,7 @@ public class TempbanManager implements SettingsDependent, HasCleanup {
long newTime = expires.getTime() + (length * MILLIS_PER_MINUTE); long newTime = expires.getTime() + (length * MILLIS_PER_MINUTE);
expires.setTime(newTime); expires.setTime(newTime);
bukkitService.scheduleSyncDelayedTask(() -> { bukkitService.runTask(player,() -> { // AuthMeReReloaded - Folia compatibility
if (customCommand.isEmpty()) { if (customCommand.isEmpty()) {
bukkitService.banIp(ip, reason, expires, "AuthMe"); bukkitService.banIp(ip, reason, expires, "AuthMe");
player.kickPlayer(reason); player.kickPlayer(reason);
@@ -1,8 +1,8 @@
package fr.xephi.authme.data.limbo; package fr.xephi.authme.data.limbo;
import com.github.Anon8281.universalScheduler.scheduling.tasks.MyScheduledTask;
import fr.xephi.authme.task.MessageTask; import fr.xephi.authme.task.MessageTask;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.scheduler.BukkitTask;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
@@ -22,8 +22,10 @@ public class LimboPlayer {
private final Location loc; private final Location loc;
private final float walkSpeed; private final float walkSpeed;
private final float flySpeed; private final float flySpeed;
private BukkitTask timeoutTask = null; private MyScheduledTask timeoutTask = null;
private MessageTask messageTask = null; private MessageTask messageTask = null;
private MyScheduledTask inter;
private LimboPlayerState state = LimboPlayerState.PASSWORD_REQUIRED; private LimboPlayerState state = LimboPlayerState.PASSWORD_REQUIRED;
public LimboPlayer(Location loc, boolean operator, Collection<UserGroup> groups, boolean fly, float walkSpeed, public LimboPlayer(Location loc, boolean operator, Collection<UserGroup> groups, boolean fly, float walkSpeed,
@@ -81,7 +83,7 @@ public class LimboPlayer {
* *
* @return The timeout task associated to the player * @return The timeout task associated to the player
*/ */
public BukkitTask getTimeoutTask() { public MyScheduledTask getTimeoutTask() {
return timeoutTask; return timeoutTask;
} }
@@ -91,7 +93,7 @@ public class LimboPlayer {
* *
* @param timeoutTask The task to set * @param timeoutTask The task to set
*/ */
public void setTimeoutTask(BukkitTask timeoutTask) { public void setTimeoutTask(MyScheduledTask timeoutTask) {
if (this.timeoutTask != null) { if (this.timeoutTask != null) {
this.timeoutTask.cancel(); this.timeoutTask.cancel();
} }
@@ -112,18 +114,19 @@ public class LimboPlayer {
* *
* @param messageTask The message task to set * @param messageTask The message task to set
*/ */
public void setMessageTask(MessageTask messageTask) { public void setMessageTask(MessageTask messageTask, MyScheduledTask inter) {
if (this.messageTask != null) { if (this.messageTask != null && this.inter != null) {
this.messageTask.cancel(); this.inter.cancel();
} }
this.messageTask = messageTask; this.messageTask = messageTask;
this.inter = inter;
} }
/** /**
* Clears all tasks associated to the player. * Clears all tasks associated to the player.
*/ */
public void clearTasks() { public void clearTasks() {
setMessageTask(null); setMessageTask(null, null);
setTimeoutTask(null); setTimeoutTask(null);
} }
@@ -1,5 +1,6 @@
package fr.xephi.authme.data.limbo; package fr.xephi.authme.data.limbo;
import com.github.Anon8281.universalScheduler.scheduling.tasks.MyScheduledTask;
import fr.xephi.authme.data.auth.PlayerCache; import fr.xephi.authme.data.auth.PlayerCache;
import fr.xephi.authme.data.captcha.RegistrationCaptchaManager; import fr.xephi.authme.data.captcha.RegistrationCaptchaManager;
import fr.xephi.authme.message.MessageKey; import fr.xephi.authme.message.MessageKey;
@@ -11,7 +12,6 @@ import fr.xephi.authme.settings.properties.RestrictionSettings;
import fr.xephi.authme.task.MessageTask; import fr.xephi.authme.task.MessageTask;
import fr.xephi.authme.task.TimeoutTask; import fr.xephi.authme.task.TimeoutTask;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitTask;
import javax.inject.Inject; import javax.inject.Inject;
@@ -53,8 +53,8 @@ class LimboPlayerTaskManager {
if (interval > 0) { if (interval > 0) {
String[] joinMessage = messages.retrieveSingle(player, result.messageKey, result.args).split("\n"); String[] joinMessage = messages.retrieveSingle(player, result.messageKey, result.args).split("\n");
MessageTask messageTask = new MessageTask(player, joinMessage); MessageTask messageTask = new MessageTask(player, joinMessage);
bukkitService.runTaskTimer(messageTask, 2 * TICKS_PER_SECOND, interval * TICKS_PER_SECOND); MyScheduledTask task = bukkitService.runTaskTimer(messageTask, 2 * TICKS_PER_SECOND, (long) interval * TICKS_PER_SECOND);
limbo.setMessageTask(messageTask); limbo.setMessageTask(messageTask, task);
} }
} }
@@ -68,7 +68,7 @@ class LimboPlayerTaskManager {
final int timeout = settings.getProperty(RestrictionSettings.TIMEOUT) * TICKS_PER_SECOND; final int timeout = settings.getProperty(RestrictionSettings.TIMEOUT) * TICKS_PER_SECOND;
if (timeout > 0) { if (timeout > 0) {
String message = messages.retrieveSingle(player, MessageKey.LOGIN_TIMEOUT_ERROR); String message = messages.retrieveSingle(player, MessageKey.LOGIN_TIMEOUT_ERROR);
BukkitTask task = bukkitService.runTaskLater(new TimeoutTask(player, message, playerCache), timeout); MyScheduledTask task = bukkitService.runTaskLater(new TimeoutTask(player, message, playerCache), timeout);
limbo.setTimeoutTask(task); limbo.setTimeoutTask(task);
} }
} }
@@ -4,7 +4,7 @@ package fr.xephi.authme.datasource;
* DataSource type. * DataSource type.
*/ */
public enum DataSourceType { public enum DataSourceType {
// H2, H2,
MYSQL, MYSQL,
+420 -406
View File
@@ -1,408 +1,422 @@
//package fr.xephi.authme.datasource; package fr.xephi.authme.datasource;
//
//import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
//import fr.xephi.authme.ConsoleLogger; import fr.xephi.authme.ConsoleLogger;
//import fr.xephi.authme.data.auth.PlayerAuth; import fr.xephi.authme.data.auth.PlayerAuth;
//import fr.xephi.authme.datasource.columnshandler.AuthMeColumnsHandler; import fr.xephi.authme.datasource.columnshandler.AuthMeColumnsHandler;
//import fr.xephi.authme.output.ConsoleLoggerFactory; import fr.xephi.authme.output.ConsoleLoggerFactory;
//import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.Settings;
//import fr.xephi.authme.settings.properties.DatabaseSettings; import fr.xephi.authme.settings.properties.DatabaseSettings;
//
//import java.io.File; import java.io.File;
//import java.sql.Connection; import java.sql.Connection;
//import java.sql.DatabaseMetaData; import java.sql.DatabaseMetaData;
//import java.sql.DriverManager; import java.sql.DriverManager;
//import java.sql.PreparedStatement; import java.sql.PreparedStatement;
//import java.sql.ResultSet; import java.sql.ResultSet;
//import java.sql.SQLException; import java.sql.SQLException;
//import java.sql.Statement; import java.sql.Statement;
//import java.util.ArrayList; import java.util.ArrayList;
//import java.util.Collection; import java.util.Collection;
//import java.util.HashSet; import java.util.HashSet;
//import java.util.List; import java.util.List;
//import java.util.Locale; import java.util.Locale;
//import java.util.Set; import java.util.Set;
//
//import static fr.xephi.authme.datasource.SqlDataSourceUtils.getNullableLong; import static fr.xephi.authme.datasource.SqlDataSourceUtils.getNullableLong;
//import static fr.xephi.authme.datasource.SqlDataSourceUtils.logSqlException; import static fr.xephi.authme.datasource.SqlDataSourceUtils.logSqlException;
//
///** /**
// * H2 data source. * H2 data source.
// */ */
//@SuppressWarnings({"checkstyle:AbbreviationAsWordInName"}) // Justification: Class name cannot be changed anymore @SuppressWarnings({"checkstyle:AbbreviationAsWordInName"}) // Justification: Class name cannot be changed anymore
//public class H2 extends AbstractSqlDataSource { public class H2 extends AbstractSqlDataSource {
//
// private final ConsoleLogger logger = ConsoleLoggerFactory.get(H2.class); private final ConsoleLogger logger = ConsoleLoggerFactory.get(H2.class);
// private final Settings settings; private final Settings settings;
// private final File dataFolder; private final File dataFolder;
// private final String database; private final String database;
// private final String tableName; private final String tableName;
// private final Columns col; private final Columns col;
// private Connection con; private Connection con;
//
// /** /**
// * Constructor for H2. * Constructor for H2.
// * *
// * @param settings The settings instance * @param settings The settings instance
// * @param dataFolder The data folder * @param dataFolder The data folder
// * @throws SQLException when initialization of a SQL datasource failed * @throws SQLException when initialization of a SQL datasource failed
// */ */
// public H2(Settings settings, File dataFolder) throws SQLException { public H2(Settings settings, File dataFolder) throws SQLException {
// this.settings = settings; this.settings = settings;
// this.dataFolder = dataFolder; this.dataFolder = dataFolder;
// this.database = settings.getProperty(DatabaseSettings.MYSQL_DATABASE); this.database = settings.getProperty(DatabaseSettings.MYSQL_DATABASE);
// this.tableName = settings.getProperty(DatabaseSettings.MYSQL_TABLE); this.tableName = settings.getProperty(DatabaseSettings.MYSQL_TABLE);
// this.col = new Columns(settings); this.col = new Columns(settings);
//
// try { try {
// this.connect(); this.connect();
// this.setup(); this.setup();
// } catch (Exception ex) { } catch (Exception ex) {
// logger.logException("Error during H2 initialization:", ex); logger.logException("Error during H2 initialization:", ex);
// throw ex; throw ex;
// } }
// } }
//
// @VisibleForTesting @VisibleForTesting
// H2(Settings settings, File dataFolder, Connection connection) { H2(Settings settings, File dataFolder, Connection connection) {
// this.settings = settings; this.settings = settings;
// this.dataFolder = dataFolder; this.dataFolder = dataFolder;
// this.database = settings.getProperty(DatabaseSettings.MYSQL_DATABASE); this.database = settings.getProperty(DatabaseSettings.MYSQL_DATABASE);
// this.tableName = settings.getProperty(DatabaseSettings.MYSQL_TABLE); this.tableName = settings.getProperty(DatabaseSettings.MYSQL_TABLE);
// this.col = new Columns(settings); this.col = new Columns(settings);
// this.con = connection; this.con = connection;
// this.columnsHandler = AuthMeColumnsHandler.createForSqlite(con, settings); this.columnsHandler = AuthMeColumnsHandler.createForH2(con, settings);
// } }
//
// /** /**
// * Initializes the connection to the H2 database. * Initializes the connection to the H2 database.
// * *
// * @throws SQLException when an SQL error occurs while connecting * @throws SQLException when an SQL error occurs while connecting
// */ */
// protected void connect() throws SQLException { protected void connect() throws SQLException {
// try { try {
// Class.forName("org.h2.Driver"); Class.forName("org.h2.Driver");
// } catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
// throw new IllegalStateException("Failed to load H2 JDBC class", e); throw new IllegalStateException("Failed to load H2 JDBC class", e);
// } }
//
// logger.debug("H2 driver loaded"); logger.debug("H2 driver loaded");
// this.con = DriverManager.getConnection(this.getJdbcUrl(this.dataFolder.getAbsolutePath(), "", this.database)); this.con = DriverManager.getConnection(this.getJdbcUrl(this.dataFolder.getAbsolutePath(), "", this.database));
// this.columnsHandler = AuthMeColumnsHandler.createForSqlite(con, settings); this.columnsHandler = AuthMeColumnsHandler.createForSqlite(con, settings);
// } }
//
// /** /**
// * Creates the table if necessary, or adds any missing columns to the table. * Creates the table if necessary, or adds any missing columns to the table.
// * *
// * @throws SQLException when an SQL error occurs while initializing the database * @throws SQLException when an SQL error occurs while initializing the database
// */ */
// @VisibleForTesting @VisibleForTesting
// @SuppressWarnings("checkstyle:CyclomaticComplexity") @SuppressWarnings("checkstyle:CyclomaticComplexity")
// protected void setup() throws SQLException { protected void setup() throws SQLException {
// try (Statement st = con.createStatement()) { try (Statement st = con.createStatement()) {
// // Note: cannot add unique fields later on in SQLite, so we add it on initialization // Note: cannot add unique fields later on in SQLite, so we add it on initialization
// st.executeUpdate("CREATE TABLE IF NOT EXISTS " + tableName + " (" st.executeUpdate("CREATE TABLE IF NOT EXISTS " + tableName + " ("
// + col.ID + " INTEGER AUTO_INCREMENT, " + col.ID + " INTEGER AUTO_INCREMENT, "
// + col.NAME + " VARCHAR(255) NOT NULL UNIQUE, " + col.NAME + " VARCHAR(255) NOT NULL UNIQUE, "
// + "CONSTRAINT table_const_prim PRIMARY KEY (" + col.ID + "));"); + "CONSTRAINT table_const_prim PRIMARY KEY (" + col.ID + "));");
//
// DatabaseMetaData md = con.getMetaData(); DatabaseMetaData md = con.getMetaData();
//
// if (isColumnMissing(md, col.REAL_NAME)) { if (isColumnMissing(md, col.REAL_NAME)) {
// st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN IF NOT EXISTS "
// + col.REAL_NAME + " VARCHAR(255) NOT NULL DEFAULT 'Player';"); + col.REAL_NAME + " VARCHAR(255) NOT NULL DEFAULT 'Player';");
// } }
//
// if (isColumnMissing(md, col.PASSWORD)) { if (isColumnMissing(md, col.PASSWORD)) {
// st.executeUpdate("ALTER TABLE " + tableName st.executeUpdate("ALTER TABLE " + tableName
// + " ADD COLUMN " + col.PASSWORD + " VARCHAR(255) NOT NULL DEFAULT '';"); + " ADD COLUMN IF NOT EXISTS " + col.PASSWORD + " VARCHAR(255) NOT NULL DEFAULT '';");
// } }
//
// if (!col.SALT.isEmpty() && isColumnMissing(md, col.SALT)) { if (!col.SALT.isEmpty() && isColumnMissing(md, col.SALT)) {
// st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + col.SALT + " VARCHAR(255);"); st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN IF NOT EXISTS " + col.SALT + " VARCHAR(255);");
// } }
//
// if (isColumnMissing(md, col.LAST_IP)) { if (isColumnMissing(md, col.LAST_IP)) {
// st.executeUpdate("ALTER TABLE " + tableName st.executeUpdate("ALTER TABLE " + tableName
// + " ADD COLUMN " + col.LAST_IP + " VARCHAR(40);"); + " ADD COLUMN IF NOT EXISTS " + col.LAST_IP + " VARCHAR(40);");
// } }
//
// if (isColumnMissing(md, col.LAST_LOGIN)) { if (isColumnMissing(md, col.LAST_LOGIN)) {
// st.executeUpdate("ALTER TABLE " + tableName st.executeUpdate("ALTER TABLE " + tableName
// + " ADD COLUMN " + col.LAST_LOGIN + " TIMESTAMP;"); + " ADD COLUMN IF NOT EXISTS " + col.LAST_LOGIN + " BIGINT;");
// } }
//
// if (isColumnMissing(md, col.REGISTRATION_IP)) { if (isColumnMissing(md, col.REGISTRATION_IP)) {
// st.executeUpdate("ALTER TABLE " + tableName st.executeUpdate("ALTER TABLE " + tableName
// + " ADD COLUMN " + col.REGISTRATION_IP + " VARCHAR(40);"); + " ADD COLUMN IF NOT EXISTS " + col.REGISTRATION_IP + " VARCHAR(40);");
// } }
//
// if (isColumnMissing(md, col.REGISTRATION_DATE)) { if (isColumnMissing(md, col.REGISTRATION_DATE)) {
// addRegistrationDateColumn(st); addRegistrationDateColumn(st);
// } }
//
// if (isColumnMissing(md, col.LASTLOC_X)) { if (isColumnMissing(md, col.LASTLOC_X)) {
// st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + col.LASTLOC_X st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN IF NOT EXISTS " + col.LASTLOC_X
// + " DOUBLE NOT NULL DEFAULT '0.0';"); + " DOUBLE NOT NULL DEFAULT '0.0';");
// st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + col.LASTLOC_Y st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN IF NOT EXISTS " + col.LASTLOC_Y
// + " DOUBLE NOT NULL DEFAULT '0.0';"); + " DOUBLE NOT NULL DEFAULT '0.0';");
// st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + col.LASTLOC_Z st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN IF NOT EXISTS " + col.LASTLOC_Z
// + " DOUBLE NOT NULL DEFAULT '0.0';"); + " DOUBLE NOT NULL DEFAULT '0.0';");
// } }
//
// if (isColumnMissing(md, col.LASTLOC_WORLD)) { if (isColumnMissing(md, col.LASTLOC_WORLD)) {
// st.executeUpdate("ALTER TABLE " + tableName st.executeUpdate("ALTER TABLE " + tableName
// + " ADD COLUMN " + col.LASTLOC_WORLD + " VARCHAR(255) NOT NULL DEFAULT 'world';"); + " ADD COLUMN IF NOT EXISTS " + col.LASTLOC_WORLD + " VARCHAR(255) NOT NULL DEFAULT 'world';");
// } }
//
// if (isColumnMissing(md, col.LASTLOC_YAW)) { if (isColumnMissing(md, col.LASTLOC_YAW)) {
// st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN IF NOT EXISTS "
// + col.LASTLOC_YAW + " FLOAT;"); + col.LASTLOC_YAW + " FLOAT;");
// } }
//
// if (isColumnMissing(md, col.LASTLOC_PITCH)) { if (isColumnMissing(md, col.LASTLOC_PITCH)) {
// st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN IF NOT EXISTS "
// + col.LASTLOC_PITCH + " FLOAT;"); + col.LASTLOC_PITCH + " FLOAT;");
// } }
//
// if (isColumnMissing(md, col.EMAIL)) { if (isColumnMissing(md, col.EMAIL)) {
// st.executeUpdate("ALTER TABLE " + tableName st.executeUpdate("ALTER TABLE " + tableName
// + " ADD COLUMN " + col.EMAIL + " VARCHAR(255);"); + " ADD COLUMN IF NOT EXISTS " + col.EMAIL + " VARCHAR_IGNORECASE(255);");
// } }
//
// if (isColumnMissing(md, col.IS_LOGGED)) { if (isColumnMissing(md, col.IS_LOGGED)) {
// st.executeUpdate("ALTER TABLE " + tableName st.executeUpdate("ALTER TABLE " + tableName
// + " ADD COLUMN " + col.IS_LOGGED + " INT NOT NULL DEFAULT '0';"); + " ADD COLUMN IF NOT EXISTS " + col.IS_LOGGED + " INT NOT NULL DEFAULT '0';");
// } }
//
// if (isColumnMissing(md, col.HAS_SESSION)) { if (isColumnMissing(md, col.HAS_SESSION)) {
// st.executeUpdate("ALTER TABLE " + tableName st.executeUpdate("ALTER TABLE " + tableName
// + " ADD COLUMN " + col.HAS_SESSION + " INT NOT NULL DEFAULT '0';"); + " ADD COLUMN IF NOT EXISTS " + col.HAS_SESSION + " INT NOT NULL DEFAULT '0';");
// } }
//
// if (isColumnMissing(md, col.TOTP_KEY)) { if (isColumnMissing(md, col.TOTP_KEY)) {
// st.executeUpdate("ALTER TABLE " + tableName st.executeUpdate("ALTER TABLE " + tableName
// + " ADD COLUMN " + col.TOTP_KEY + " VARCHAR(32);"); + " ADD COLUMN IF NOT EXISTS " + col.TOTP_KEY + " VARCHAR(32);");
// } }
//
// if (!col.PLAYER_UUID.isEmpty() && isColumnMissing(md, col.PLAYER_UUID)) { if (!col.PLAYER_UUID.isEmpty() && isColumnMissing(md, col.PLAYER_UUID)) {
// st.executeUpdate("ALTER TABLE " + tableName st.executeUpdate("ALTER TABLE " + tableName
// + " ADD COLUMN " + col.PLAYER_UUID + " VARCHAR(36)"); + " ADD COLUMN IF NOT EXISTS " + col.PLAYER_UUID + " VARCHAR(36)");
}
}
logger.info("H2 Setup finished");
}
/**
* Checks if a column is missing in the specified table.
* @param columnName the name of the column to look for
* @return true if the column is missing, false if it exists
* @throws SQLException if an error occurs while executing SQL or accessing the result set
* @deprecated Not work in H2, it always returns true
*/
@Deprecated
private boolean isColumnMissing(DatabaseMetaData metaData, String columnName) throws SQLException {
String query = "SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = ? AND COLUMN_NAME = ?";
// try (PreparedStatement preparedStatement = con.prepareStatement(query)) {
// preparedStatement.setString(1, tableName);
// preparedStatement.setString(2, columnName.toUpperCase());
// try (ResultSet rs = preparedStatement.executeQuery()) {
// return !rs.next();
// } // }
// } // }
// logger.info("H2 Setup finished"); return true;
// } }
//
//
// private boolean isColumnMissing(DatabaseMetaData metaData, String columnName) throws SQLException { @Override
// try (ResultSet rs = metaData.getColumns(null, null, tableName, columnName)) { public void reload() {
// return !rs.next(); close(con);
// } try {
// } this.connect();
// this.setup();
// @Override } catch (SQLException ex) {
// public void reload() { logger.logException("Error while reloading H2:", ex);
// close(con); }
// try { }
// this.connect();
// this.setup(); @Override
// } catch (SQLException ex) { public PlayerAuth getAuth(String user) {
// logger.logException("Error while reloading H2:", ex); String sql = "SELECT * FROM " + tableName + " WHERE LOWER(" + col.NAME + ")=LOWER(?);";
// } try (PreparedStatement pst = con.prepareStatement(sql)) {
// } pst.setString(1, user);
// try (ResultSet rs = pst.executeQuery()) {
// @Override if (rs.next()) {
// public PlayerAuth getAuth(String user) { return buildAuthFromResultSet(rs);
// String sql = "SELECT * FROM " + tableName + " WHERE LOWER(" + col.NAME + ")=LOWER(?);"; }
// try (PreparedStatement pst = con.prepareStatement(sql)) { }
// pst.setString(1, user); } catch (SQLException ex) {
// try (ResultSet rs = pst.executeQuery()) { logSqlException(ex);
// if (rs.next()) { }
// return buildAuthFromResultSet(rs); return null;
// } }
// }
// } catch (SQLException ex) { @Override
// logSqlException(ex); public Set<String> getRecordsToPurge(long until) {
// } Set<String> list = new HashSet<>();
// return null; String select = "SELECT " + col.NAME + " FROM " + tableName + " WHERE MAX("
// } + " COALESCE(" + col.LAST_LOGIN + ", 0),"
// + " COALESCE(" + col.REGISTRATION_DATE + ", 0)"
// @Override + ") < ?;";
// public Set<String> getRecordsToPurge(long until) { try (PreparedStatement selectPst = con.prepareStatement(select)) {
// Set<String> list = new HashSet<>(); selectPst.setLong(1, until);
// String select = "SELECT " + col.NAME + " FROM " + tableName + " WHERE MAX(" try (ResultSet rs = selectPst.executeQuery()) {
// + " COALESCE(" + col.LAST_LOGIN + ", 0)," while (rs.next()) {
// + " COALESCE(" + col.REGISTRATION_DATE + ", 0)" list.add(rs.getString(col.NAME));
// + ") < ?;"; }
// try (PreparedStatement selectPst = con.prepareStatement(select)) { }
// selectPst.setLong(1, until); } catch (SQLException ex) {
// try (ResultSet rs = selectPst.executeQuery()) { logSqlException(ex);
// while (rs.next()) { }
// list.add(rs.getString(col.NAME));
// } return list;
// } }
// } catch (SQLException ex) {
// logSqlException(ex); @Override
// } public void purgeRecords(Collection<String> toPurge) {
// String delete = "DELETE FROM " + tableName + " WHERE " + col.NAME + "=?;";
// return list; try (PreparedStatement deletePst = con.prepareStatement(delete)) {
// } for (String name : toPurge) {
// deletePst.setString(1, name.toLowerCase(Locale.ROOT));
// @Override deletePst.executeUpdate();
// public void purgeRecords(Collection<String> toPurge) { }
// String delete = "DELETE FROM " + tableName + " WHERE " + col.NAME + "=?;"; } catch (SQLException ex) {
// try (PreparedStatement deletePst = con.prepareStatement(delete)) { logSqlException(ex);
// for (String name : toPurge) { }
// deletePst.setString(1, name.toLowerCase(Locale.ROOT)); }
// deletePst.executeUpdate();
// } @Override
// } catch (SQLException ex) { public boolean removeAuth(String user) {
// logSqlException(ex); String sql = "DELETE FROM " + tableName + " WHERE " + col.NAME + "=?;";
// } try (PreparedStatement pst = con.prepareStatement(sql)) {
// } pst.setString(1, user.toLowerCase(Locale.ROOT));
// pst.executeUpdate();
// @Override return true;
// public boolean removeAuth(String user) { } catch (SQLException ex) {
// String sql = "DELETE FROM " + tableName + " WHERE " + col.NAME + "=?;"; logSqlException(ex);
// try (PreparedStatement pst = con.prepareStatement(sql)) { }
// pst.setString(1, user.toLowerCase(Locale.ROOT)); return false;
// pst.executeUpdate(); }
// return true;
// } catch (SQLException ex) { @Override
// logSqlException(ex); public void closeConnection() {
// } try {
// return false; if (con != null && !con.isClosed()) {
// } con.close();
// }
// @Override } catch (SQLException ex) {
// public void closeConnection() { logSqlException(ex);
// try { }
// if (con != null && !con.isClosed()) { }
// con.close();
// } @Override
// } catch (SQLException ex) { public DataSourceType getType() {
// logSqlException(ex); return DataSourceType.H2;
// } }
// }
// @Override
// @Override public List<PlayerAuth> getAllAuths() {
// public DataSourceType getType() { List<PlayerAuth> auths = new ArrayList<>();
// return DataSourceType.H2; String sql = "SELECT * FROM " + tableName + ";";
// } try (PreparedStatement pst = con.prepareStatement(sql); ResultSet rs = pst.executeQuery()) {
// while (rs.next()) {
// @Override PlayerAuth auth = buildAuthFromResultSet(rs);
// public List<PlayerAuth> getAllAuths() { auths.add(auth);
// List<PlayerAuth> auths = new ArrayList<>(); }
// String sql = "SELECT * FROM " + tableName + ";"; } catch (SQLException ex) {
// try (PreparedStatement pst = con.prepareStatement(sql); ResultSet rs = pst.executeQuery()) { logSqlException(ex);
// while (rs.next()) { }
// PlayerAuth auth = buildAuthFromResultSet(rs); return auths;
// auths.add(auth); }
// }
// } catch (SQLException ex) { @Override
// logSqlException(ex); public List<String> getLoggedPlayersWithEmptyMail() {
// } List<String> players = new ArrayList<>();
// return auths; String sql = "SELECT " + col.REAL_NAME + " FROM " + tableName + " WHERE " + col.IS_LOGGED + " = 1"
// } + " AND (" + col.EMAIL + " = 'your@email.com' OR " + col.EMAIL + " IS NULL);";
// try (Statement st = con.createStatement(); ResultSet rs = st.executeQuery(sql)) {
// @Override while (rs.next()) {
// public List<String> getLoggedPlayersWithEmptyMail() { players.add(rs.getString(1));
// List<String> players = new ArrayList<>(); }
// String sql = "SELECT " + col.REAL_NAME + " FROM " + tableName + " WHERE " + col.IS_LOGGED + " = 1" } catch (SQLException ex) {
// + " AND (" + col.EMAIL + " = 'your@email.com' OR " + col.EMAIL + " IS NULL);"; logSqlException(ex);
// try (Statement st = con.createStatement(); ResultSet rs = st.executeQuery(sql)) { }
// while (rs.next()) { return players;
// players.add(rs.getString(1)); }
// }
// } catch (SQLException ex) { @Override
// logSqlException(ex); public List<PlayerAuth> getRecentlyLoggedInPlayers() {
// } List<PlayerAuth> players = new ArrayList<>();
// return players; String sql = "SELECT * FROM " + tableName + " ORDER BY " + col.LAST_LOGIN + " DESC LIMIT 10;";
// } try (Statement st = con.createStatement(); ResultSet rs = st.executeQuery(sql)) {
// while (rs.next()) {
// @Override players.add(buildAuthFromResultSet(rs));
// public List<PlayerAuth> getRecentlyLoggedInPlayers() { }
// List<PlayerAuth> players = new ArrayList<>(); } catch (SQLException e) {
// String sql = "SELECT * FROM " + tableName + " ORDER BY " + col.LAST_LOGIN + " DESC LIMIT 10;"; logSqlException(e);
// try (Statement st = con.createStatement(); ResultSet rs = st.executeQuery(sql)) { }
// while (rs.next()) { return players;
// players.add(buildAuthFromResultSet(rs)); }
// }
// } catch (SQLException e) {
// logSqlException(e); @Override
// } public boolean setTotpKey(String user, String totpKey) {
// return players; 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(Locale.ROOT));
// @Override pst.executeUpdate();
// public boolean setTotpKey(String user, String totpKey) { return true;
// String sql = "UPDATE " + tableName + " SET " + col.TOTP_KEY + " = ? WHERE " + col.NAME + " = ?"; } catch (SQLException e) {
// try (PreparedStatement pst = con.prepareStatement(sql)) { logSqlException(e);
// pst.setString(1, totpKey); }
// pst.setString(2, user.toLowerCase(Locale.ROOT)); return false;
// pst.executeUpdate(); }
// return true;
// } catch (SQLException e) { private PlayerAuth buildAuthFromResultSet(ResultSet row) throws SQLException {
// logSqlException(e); String salt = !col.SALT.isEmpty() ? row.getString(col.SALT) : null;
// }
// return false; return PlayerAuth.builder()
// } .name(row.getString(col.NAME))
// .email(row.getString(col.EMAIL))
// private PlayerAuth buildAuthFromResultSet(ResultSet row) throws SQLException { .realName(row.getString(col.REAL_NAME))
// String salt = !col.SALT.isEmpty() ? row.getString(col.SALT) : null; .password(row.getString(col.PASSWORD), salt)
// .totpKey(row.getString(col.TOTP_KEY))
// return PlayerAuth.builder() .lastLogin(getNullableLong(row, col.LAST_LOGIN))
// .name(row.getString(col.NAME)) .lastIp(row.getString(col.LAST_IP))
// .email(row.getString(col.EMAIL)) .registrationDate(row.getLong(col.REGISTRATION_DATE))
// .realName(row.getString(col.REAL_NAME)) .registrationIp(row.getString(col.REGISTRATION_IP))
// .password(row.getString(col.PASSWORD), salt) .locX(row.getDouble(col.LASTLOC_X))
// .totpKey(row.getString(col.TOTP_KEY)) .locY(row.getDouble(col.LASTLOC_Y))
// .lastLogin(getNullableLong(row, col.LAST_LOGIN)) .locZ(row.getDouble(col.LASTLOC_Z))
// .lastIp(row.getString(col.LAST_IP)) .locWorld(row.getString(col.LASTLOC_WORLD))
// .registrationDate(row.getLong(col.REGISTRATION_DATE)) .locYaw(row.getFloat(col.LASTLOC_YAW))
// .registrationIp(row.getString(col.REGISTRATION_IP)) .locPitch(row.getFloat(col.LASTLOC_PITCH))
// .locX(row.getDouble(col.LASTLOC_X)) .build();
// .locY(row.getDouble(col.LASTLOC_Y)) }
// .locZ(row.getDouble(col.LASTLOC_Z))
// .locWorld(row.getString(col.LASTLOC_WORLD)) /**
// .locYaw(row.getFloat(col.LASTLOC_YAW)) * Creates the column for registration date and sets all entries to the current timestamp.
// .locPitch(row.getFloat(col.LASTLOC_PITCH)) * We do so in order to avoid issues with purging, where entries with 0 / NULL might get
// .build(); * purged immediately on startup otherwise.
// } *
// * @param st Statement object to the database
// /** */
// * Creates the column for registration date and sets all entries to the current timestamp. private void addRegistrationDateColumn(Statement st) throws SQLException {
// * We do so in order to avoid issues with purging, where entries with 0 / NULL might get int affect = st.executeUpdate("ALTER TABLE " + tableName
// * purged immediately on startup otherwise. + " ADD COLUMN IF NOT EXISTS " + col.REGISTRATION_DATE + " BIGINT NOT NULL DEFAULT '0';");
// * if (affect > 0) {
// * @param st Statement object to the database long currentTimestamp = System.currentTimeMillis();
// */ int updatedRows = st.executeUpdate(String.format("UPDATE %s SET %s = %d;",
// private void addRegistrationDateColumn(Statement st) throws SQLException { tableName, col.REGISTRATION_DATE, currentTimestamp));
// st.executeUpdate("ALTER TABLE " + tableName logger.info("Created column '" + col.REGISTRATION_DATE + "' and set the current timestamp, "
// + " ADD COLUMN " + col.REGISTRATION_DATE + " TIMESTAMP NOT NULL DEFAULT '0';"); + currentTimestamp + ", to all " + updatedRows + " rows");
// }
// // Use the timestamp from Java to avoid timezone issues in case JVM and database are out of sync }
// long currentTimestamp = System.currentTimeMillis();
// int updatedRows = st.executeUpdate(String.format("UPDATE %s SET %s = %d;", @Override
// tableName, col.REGISTRATION_DATE, currentTimestamp)); String getJdbcUrl(String dataPath, String ignored, String database) {
// logger.info("Created column '" + col.REGISTRATION_DATE + "' and set the current timestamp, " return "jdbc:h2:" + dataPath + File.separator + database;
// + currentTimestamp + ", to all " + updatedRows + " rows"); }
// }
// private static void close(Connection con) {
// @Override if (con != null) {
// String getJdbcUrl(String dataPath, String ignored, String database) { try {
// return "jdbc:h2:" + dataPath + File.separator + database + ".db"; con.close();
// } } catch (SQLException ex) {
// logSqlException(ex);
// private static void close(Connection con) { }
// if (con != null) { }
// try { }
// con.close(); }
// } catch (SQLException ex) {
// logSqlException(ex);
// }
// }
// }
//}
//
@@ -51,6 +51,26 @@ public final class AuthMeColumnsHandler {
return new AuthMeColumnsHandler(sqlColHandler); return new AuthMeColumnsHandler(sqlColHandler);
} }
/**
* Creates a column handler for H2.
*
* @param connection the connection to the database
* @param settings plugin settings
* @return created column handler
*/
public static AuthMeColumnsHandler createForH2(Connection connection, Settings settings) {
ColumnContext columnContext = new ColumnContext(settings, false);
String tableName = settings.getProperty(DatabaseSettings.MYSQL_TABLE);
String nameColumn = settings.getProperty(DatabaseSettings.MYSQL_COL_NAME);
SqlColumnsHandler<ColumnContext, String> sqlColHandler = new SqlColumnsHandler<>(
forSingleConnection(connection, tableName, nameColumn, columnContext)
.setPredicateSqlGenerator(new PredicateSqlGenerator<>(columnContext, false))
);
return new AuthMeColumnsHandler(sqlColHandler);
}
/** /**
* Creates a column handler for MySQL. * Creates a column handler for MySQL.
* *
@@ -0,0 +1,33 @@
package fr.xephi.authme.datasource.converter;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.datasource.DataSourceType;
import fr.xephi.authme.datasource.SQLite;
import fr.xephi.authme.initialization.DataFolder;
import fr.xephi.authme.settings.Settings;
import javax.inject.Inject;
import java.io.File;
import java.sql.SQLException;
/**
* Converts SQLite to H2
*
*/
public class SqliteToH2 extends AbstractDataSourceConverter<SQLite>{
private final Settings settings;
private final File dataFolder;
@Inject
SqliteToH2(Settings settings, DataSource dataSource, @DataFolder File dataFolder) {
super(dataSource, DataSourceType.H2);
this.settings = settings;
this.dataFolder = dataFolder;
}
@Override
protected SQLite getSource() throws SQLException {
return new SQLite(settings, dataFolder);
}
}
@@ -5,6 +5,7 @@ import fr.xephi.authme.data.auth.PlayerCache;
import fr.xephi.authme.datasource.CacheDataSource; import fr.xephi.authme.datasource.CacheDataSource;
import fr.xephi.authme.datasource.DataSource; import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.datasource.DataSourceType; import fr.xephi.authme.datasource.DataSourceType;
import fr.xephi.authme.datasource.H2;
import fr.xephi.authme.datasource.MariaDB; import fr.xephi.authme.datasource.MariaDB;
import fr.xephi.authme.datasource.MySQL; import fr.xephi.authme.datasource.MySQL;
import fr.xephi.authme.datasource.PostgreSqlDataSource; import fr.xephi.authme.datasource.PostgreSqlDataSource;
@@ -76,9 +77,9 @@ public class DataSourceProvider implements Provider<DataSource> {
case SQLITE: case SQLITE:
dataSource = new SQLite(settings, dataFolder); dataSource = new SQLite(settings, dataFolder);
break; break;
// case H2: case H2:
// dataSource = new H2(settings, dataFolder); dataSource = new H2(settings, dataFolder);
// break; break;
default: default:
throw new UnsupportedOperationException("Unknown data source type '" + dataSourceType + "'"); throw new UnsupportedOperationException("Unknown data source type '" + dataSourceType + "'");
} }
@@ -1,5 +1,6 @@
package fr.xephi.authme.initialization; package fr.xephi.authme.initialization;
import com.github.Anon8281.universalScheduler.UniversalRunnable;
import fr.xephi.authme.AuthMe; import fr.xephi.authme.AuthMe;
import fr.xephi.authme.ConsoleLogger; import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.datasource.DataSource; import fr.xephi.authme.datasource.DataSource;
@@ -18,7 +19,6 @@ import org.bstats.bukkit.Metrics;
import org.bstats.charts.SimplePie; import org.bstats.charts.SimplePie;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import javax.inject.Inject; import javax.inject.Inject;
import java.util.List; import java.util.List;
@@ -96,7 +96,7 @@ public class OnStartupTasks {
if (!settings.getProperty(RECALL_PLAYERS)) { if (!settings.getProperty(RECALL_PLAYERS)) {
return; return;
} }
bukkitService.runTaskTimerAsynchronously(new BukkitRunnable() { bukkitService.runTaskTimerAsynchronously(new UniversalRunnable() {
@Override @Override
public void run() { public void run() {
List<String> loggedPlayersWithEmptyMail = dataSource.getLoggedPlayersWithEmptyMail(); List<String> loggedPlayersWithEmptyMail = dataSource.getLoggedPlayersWithEmptyMail();
@@ -1,15 +1,9 @@
package fr.xephi.authme.initialization; package fr.xephi.authme.initialization;
import com.google.common.annotations.VisibleForTesting; import com.github.Anon8281.universalScheduler.scheduling.schedulers.TaskScheduler;
import fr.xephi.authme.AuthMe; import fr.xephi.authme.AuthMe;
import fr.xephi.authme.datasource.DataSource; import fr.xephi.authme.datasource.DataSource;
import org.bukkit.scheduler.BukkitScheduler;
import org.bukkit.scheduler.BukkitWorker;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
/** /**
@@ -18,7 +12,7 @@ import java.util.logging.Logger;
*/ */
public class TaskCloser implements Runnable { public class TaskCloser implements Runnable {
private final BukkitScheduler scheduler; private final TaskScheduler scheduler;
private final Logger logger; private final Logger logger;
private final AuthMe plugin; private final AuthMe plugin;
private final DataSource dataSource; private final DataSource dataSource;
@@ -30,7 +24,7 @@ public class TaskCloser implements Runnable {
* @param dataSource the data source (nullable) * @param dataSource the data source (nullable)
*/ */
public TaskCloser(AuthMe plugin, DataSource dataSource) { public TaskCloser(AuthMe plugin, DataSource dataSource) {
this.scheduler = plugin.getServer().getScheduler(); this.scheduler = AuthMe.getScheduler();
this.logger = plugin.getLogger(); this.logger = plugin.getLogger();
this.plugin = plugin; this.plugin = plugin;
this.dataSource = dataSource; this.dataSource = dataSource;
@@ -38,58 +32,9 @@ public class TaskCloser implements Runnable {
@Override @Override
public void run() { public void run() {
List<Integer> pendingTasks = getPendingTasks(); scheduler.cancelTasks();
logger.log(Level.INFO, "Waiting for {0} tasks to finish", pendingTasks.size());
int progress = 0;
//one minute + some time checking the running state
int tries = 60;
while (!pendingTasks.isEmpty()) {
if (tries <= 0) {
logger.log(Level.INFO, "Async tasks times out after to many tries {0}", pendingTasks);
break;
}
try {
sleep();
} catch (InterruptedException ignored) {
Thread.currentThread().interrupt();
break;
}
for (Iterator<Integer> iterator = pendingTasks.iterator(); iterator.hasNext(); ) {
int taskId = iterator.next();
if (!scheduler.isCurrentlyRunning(taskId)) {
iterator.remove();
progress++;
logger.log(Level.INFO, "Progress: {0} / {1}", new Object[]{progress, pendingTasks.size()});
}
}
tries--;
}
if (dataSource != null) { if (dataSource != null) {
dataSource.closeConnection(); dataSource.closeConnection();
} }
} }
/** Makes the current thread sleep for one second. */
@VisibleForTesting
void sleep() throws InterruptedException {
Thread.sleep(1000);
}
private List<Integer> getPendingTasks() {
List<Integer> pendingTasks = new ArrayList<>();
//returns only the async tasks
for (BukkitWorker pendingTask : scheduler.getActiveWorkers()) {
if (pendingTask.getOwner().equals(plugin)
//it's not a periodic task
&& !scheduler.isQueued(pendingTask.getTaskId())) {
pendingTasks.add(pendingTask.getTaskId());
}
}
return pendingTasks;
}
} }
@@ -1,8 +1,6 @@
package fr.xephi.authme.listener; package fr.xephi.authme.listener;
import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
@@ -15,11 +13,7 @@ public class AdvancedShulkerFixListener implements Listener {
public void onDispenserActivate(BlockDispenseEvent event) { public void onDispenserActivate(BlockDispenseEvent event) {
Block block = event.getBlock(); Block block = event.getBlock();
if (block.getRelative(BlockFace.DOWN).getType().equals(Material.AIR) && block.getY() == 0) { if (block.getY() <= 0 || block.getY() >= block.getWorld().getMaxHeight() - 1) {
event.setCancelled(true);
return;
}
if (block.getRelative(BlockFace.UP).getType().equals(Material.AIR) && block.getY() == block.getWorld().getMaxHeight() - 1) {
event.setCancelled(true); event.setCancelled(true);
} }
} }
@@ -3,7 +3,6 @@ package fr.xephi.authme.listener;
import fr.xephi.authme.AuthMe; import fr.xephi.authme.AuthMe;
import fr.xephi.authme.api.v3.AuthMeApi; import fr.xephi.authme.api.v3.AuthMeApi;
import fr.xephi.authme.events.RestoreSessionEvent;
import fr.xephi.authme.message.MessageKey; import fr.xephi.authme.message.MessageKey;
import fr.xephi.authme.message.Messages; import fr.xephi.authme.message.Messages;
import fr.xephi.authme.service.BukkitService; import fr.xephi.authme.service.BukkitService;
@@ -40,7 +39,7 @@ public class BedrockAutoLoginListener implements Listener {
return settings.getProperty(HooksSettings.HOOK_FLOODGATE_PLAYER) && settings.getProperty(SecuritySettings.FORCE_LOGIN_BEDROCK) && org.geysermc.floodgate.api.FloodgateApi.getInstance().isFloodgateId(uuid) && getServer().getPluginManager().getPlugin("floodgate") != null; return settings.getProperty(HooksSettings.HOOK_FLOODGATE_PLAYER) && settings.getProperty(SecuritySettings.FORCE_LOGIN_BEDROCK) && org.geysermc.floodgate.api.FloodgateApi.getInstance().isFloodgateId(uuid) && getServer().getPluginManager().getPlugin("floodgate") != null;
} }
@EventHandler(priority = EventPriority.LOWEST) @EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerJoin(PlayerJoinEvent event) { public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
String name = event.getPlayer().getName(); String name = event.getPlayer().getName();
@@ -50,13 +49,4 @@ public class BedrockAutoLoginListener implements Listener {
messages.send(player, MessageKey.BEDROCK_AUTO_LOGGED_IN); messages.send(player, MessageKey.BEDROCK_AUTO_LOGGED_IN);
} }
} }
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerAuthMeSessionRestore(RestoreSessionEvent event) {
Player player = event.getPlayer();
UUID uuid = player.getUniqueId();
if (isBedrockPlayer(uuid)) {
event.setCancelled(true);
}
}
} }
@@ -25,13 +25,11 @@ import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerLoginEvent; import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import javax.inject.Inject; import javax.inject.Inject;
import java.io.File;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
import java.util.UUID; import java.util.UUID;
@@ -76,6 +74,7 @@ public class GuiCaptchaHandler implements Listener {
String randomString = ""; String randomString = "";
Random randomItemSet = new Random(); Random randomItemSet = new Random();
Random howManyRandom = new Random(); Random howManyRandom = new Random();
private Material captchaMaterial = getRandomMaterial();
private boolean isPacketListenersActive = false; private boolean isPacketListenersActive = false;
@@ -108,11 +107,11 @@ public class GuiCaptchaHandler implements Listener {
if (event.getWhoClicked() instanceof Player) { if (event.getWhoClicked() instanceof Player) {
Player player = (Player) event.getWhoClicked(); Player player = (Player) event.getWhoClicked();
ItemStack currentItem = event.getCurrentItem(); ItemStack currentItem = event.getCurrentItem();
if (!authmeApi.isRegistered(player.getName()) && !closeReasonMap.containsKey(player)) { if (!authmeApi.isRegistered(player.getName())) {
if (isBedrockPlayer(player.getUniqueId())) { if (isBedrockPlayer(player.getUniqueId())) {
return; return;
} }
if (currentItem != null && currentItem.getType().equals(Material.REDSTONE_BLOCK)) { if (currentItem != null && currentItem.getType().equals(captchaMaterial)) {
event.setCancelled(true); event.setCancelled(true);
if (!closeReasonMap.containsKey(player)) { if (!closeReasonMap.containsKey(player)) {
closeReasonMap.put(player, "verified"); closeReasonMap.put(player, "verified");
@@ -164,87 +163,82 @@ public class GuiCaptchaHandler implements Listener {
messages.send(playerunreg, MessageKey.GUI_CAPTCHA_VERIFIED_AUTO_BEDROCK); messages.send(playerunreg, MessageKey.GUI_CAPTCHA_VERIFIED_AUTO_BEDROCK);
return; return;
} }
randomString = sb.toString();
bukkitService.runTaskAsynchronously(() -> { Random random_blockpos = new Random();
bukkitService.runTask(() -> { AtomicInteger random_num = new AtomicInteger(random_blockpos.nextInt(27));
randomString = sb.toString(); Inventory menu = Bukkit.createInventory(playerunreg, 27, messages.retrieveSingle(playerunreg, MessageKey.GUI_CAPTCHA_WINDOW_NAME, randomString));
Random random_blockpos = new Random(); ItemStack item = new ItemStack(captchaMaterial);
AtomicInteger random_num = new AtomicInteger(random_blockpos.nextInt(26)); ItemMeta meta = item.getItemMeta();
Inventory menu = Bukkit.createInventory(playerunreg, 27, messages.retrieveSingle(playerunreg, MessageKey.GUI_CAPTCHA_WINDOW_NAME, randomString)); try {
ItemStack item = new ItemStack(Material.REDSTONE_BLOCK); if (meta != null) {
ItemMeta meta = item.getItemMeta(); meta.setDisplayName(messages.retrieveSingle(playerunreg, MessageKey.GUI_CAPTCHA_CLICKABLE_NAME, randomString));
try { item.setItemMeta(meta);
if (meta != null) { }
meta.setDisplayName(messages.retrieveSingle(playerunreg, MessageKey.GUI_CAPTCHA_CLICKABLE_NAME, randomString)); } catch (NullPointerException e) {
item.setItemMeta(meta); getLogger().log(Level.WARNING, "Unexpected error occurred while setting item meta.");
} }
} catch (NullPointerException e) { windowPacketListener = new PacketAdapter(this.plugin, ListenerPriority.HIGHEST, PacketType.Play.Client.CLOSE_WINDOW) {
getLogger().log(Level.WARNING, "Unexpected error occurred while setting item meta."); @Override
} public void onPacketReceiving(PacketEvent event) {
windowPacketListener = new PacketAdapter(this.plugin, ListenerPriority.HIGHEST, PacketType.Play.Client.CLOSE_WINDOW) { Player packetPlayer = event.getPlayer();
@Override if (!closeReasonMap.containsKey(packetPlayer) && !authmeApi.isRegistered(packetPlayer.getName())) {
public void onPacketReceiving(PacketEvent event) { if (timesLeft <= 0) {
Player packetPlayer = event.getPlayer();
if (!closeReasonMap.containsKey(packetPlayer) && !authmeApi.isRegistered(packetPlayer.getName())) {
if (timesLeft <= 0) {
bukkitService.runTask(() -> {
packetPlayer.kickPlayer(service.retrieveSingleMessage(packetPlayer, MessageKey.GUI_CAPTCHA_KICK_FAILED));
});
timesLeft = 3;
} else {
--timesLeft;
if (timesLeft <= 0) {
bukkitService.runTask(() -> {
packetPlayer.kickPlayer(service.retrieveSingleMessage(packetPlayer, MessageKey.GUI_CAPTCHA_KICK_FAILED));
});
timesLeft = 3;
return;
}
messages.send(packetPlayer, MessageKey.GUI_CAPTCHA_RETRY_MESSAGE, String.valueOf(timesLeft));
event.setCancelled(true);
random_num.set(random_blockpos.nextInt(26));
bukkitService.runTask(() -> {
menu.clear();
menu.setItem(random_num.get(), item);
packetPlayer.openInventory(menu);
});
}
}
}
};
chatPacketListener = new PacketAdapter(this.plugin, ListenerPriority.HIGHEST, PacketType.Play.Client.CHAT) {
@Override
public void onPacketReceiving(PacketEvent event) {
Player packetPlayer = event.getPlayer();
if (!closeReasonMap.containsKey(packetPlayer) && !authmeApi.isRegistered(packetPlayer.getName())) {
messages.send(packetPlayer, MessageKey.GUI_CAPTCHA_DENIED_MESSAGE);
event.setCancelled(true);
}
}
};
initializePacketListeners();
//Open captcha inventory
menu.setItem(random_num.get(), item);
playerunreg.openInventory(menu);
if (settings.getProperty(SecuritySettings.GUI_CAPTCHA_TIMEOUT) > 0) {
long timeOut = settings.getProperty(SecuritySettings.GUI_CAPTCHA_TIMEOUT);
if (settings.getProperty(SecuritySettings.GUI_CAPTCHA_TIMEOUT) > settings.getProperty(RestrictionSettings.TIMEOUT)) {
bukkitService.runTask(() -> { bukkitService.runTask(() -> {
getLogger().warning("AuthMe detected that your GUI captcha timeout seconds(" + settings.getProperty(SecuritySettings.GUI_CAPTCHA_TIMEOUT) + ") is bigger than the Login timeout seconds(" + packetPlayer.kickPlayer(service.retrieveSingleMessage(packetPlayer, MessageKey.GUI_CAPTCHA_KICK_FAILED));
settings.getProperty(RestrictionSettings.TIMEOUT) + "). To prevent issues, we will let the GUI captcha follow the Login timeout seconds, please check and modify your config.");
}); });
timeOut = settings.getProperty(RestrictionSettings.TIMEOUT); timesLeft = 3;
} } else {
long finalTimeOut = timeOut; --timesLeft;
bukkitService.runTaskLater(() -> { if (timesLeft <= 0) {
if (!closeReasonMap.containsKey(playerunreg) && !authmeApi.isRegistered(playerunreg.getName())) { bukkitService.runTask(() -> {
playerunreg.kickPlayer(service.retrieveSingleMessage(playerunreg, MessageKey.GUI_CAPTCHA_KICK_TIMEOUT)); packetPlayer.kickPlayer(service.retrieveSingleMessage(packetPlayer, MessageKey.GUI_CAPTCHA_KICK_FAILED));
timesLeft = 3; // Reset the attempt counter });
timesLeft = 3;
return;
} }
}, finalTimeOut * 20L); messages.send(packetPlayer, MessageKey.GUI_CAPTCHA_RETRY_MESSAGE, String.valueOf(timesLeft));
event.setCancelled(true);
random_num.set(random_blockpos.nextInt(26));
bukkitService.runTask(() -> {
menu.clear();
menu.setItem(random_num.get(), item);
packetPlayer.openInventory(menu);
});
}
} }
}); }
}); };
chatPacketListener = new PacketAdapter(this.plugin, ListenerPriority.HIGHEST, PacketType.Play.Client.CHAT) {
@Override
public void onPacketReceiving(PacketEvent event) {
Player packetPlayer = event.getPlayer();
if (!closeReasonMap.containsKey(packetPlayer) && !authmeApi.isRegistered(packetPlayer.getName())) {
messages.send(packetPlayer, MessageKey.GUI_CAPTCHA_DENIED_MESSAGE);
event.setCancelled(true);
}
}
};
initializePacketListeners();
//Open captcha inventory
menu.setItem(random_num.get(), item);
playerunreg.openInventory(menu);
if (settings.getProperty(SecuritySettings.GUI_CAPTCHA_TIMEOUT) > 0) {
long timeOut = settings.getProperty(SecuritySettings.GUI_CAPTCHA_TIMEOUT);
if (settings.getProperty(SecuritySettings.GUI_CAPTCHA_TIMEOUT) > settings.getProperty(RestrictionSettings.TIMEOUT)) {
bukkitService.runTask(() -> {
getLogger().warning("AuthMe detected that your GUI captcha timeout seconds(" + settings.getProperty(SecuritySettings.GUI_CAPTCHA_TIMEOUT) + ") is bigger than the Login timeout seconds(" +
settings.getProperty(RestrictionSettings.TIMEOUT) + "). To prevent issues, we will let the GUI captcha follow the Login timeout seconds, please check and modify your config.");
});
timeOut = settings.getProperty(RestrictionSettings.TIMEOUT);
}
long finalTimeOut = timeOut;
bukkitService.runTaskLater(() -> {
if (!closeReasonMap.containsKey(playerunreg) && !authmeApi.isRegistered(playerunreg.getName())) {
playerunreg.kickPlayer(service.retrieveSingleMessage(playerunreg, MessageKey.GUI_CAPTCHA_KICK_TIMEOUT));
timesLeft = 3; // Reset the attempt counter
}
}, finalTimeOut * 20L);
}
} }
} }
@@ -257,65 +251,10 @@ public class GuiCaptchaHandler implements Listener {
} }
} }
private Material getRandomMaterial() {
private void deletePlayerData(UUID playerUUID) { Material[] allMaterials = Material.values();
// 获取服务器的存储文件夹路径 Random random = new Random();
File serverFolder = Bukkit.getServer().getWorldContainer(); return allMaterials[random.nextInt(allMaterials.length)];
String worldFolderName = settings.getProperty(SecuritySettings.DELETE_PLAYER_DATA_WORLD);
// 构建playerdata文件夹路径
File playerDataFolder = new File(serverFolder, File.separator + worldFolderName + File.separator + "playerdata");
// 构建玩家数据文件路径
File playerDataFile = new File(playerDataFolder, File.separator + playerUUID + ".dat");
// 删除玩家数据文件
if (playerDataFile.exists()) {
playerDataFile.delete();
}
}
private void deletePlayerStats(UUID playerUUID) {
// 获取服务器的存储文件夹路径
File serverFolder = Bukkit.getServer().getWorldContainer();
String worldFolderName = settings.getProperty(SecuritySettings.DELETE_PLAYER_DATA_WORLD);
// 构建stats文件夹路径
File statsFolder = new File(serverFolder, File.separator + worldFolderName + File.separator + "stats");
// 构建玩家统计数据文件路径
File statsFile = new File(statsFolder, File.separator + playerUUID + ".json");
// 删除玩家统计数据文件
if (statsFile.exists()) {
statsFile.delete();
}
}
private void deleteAuthMePlayerData(UUID playerUUID) {
File pluginFolder = plugin.getDataFolder();
File path = new File(pluginFolder, File.separator + "playerdata" + File.separator + playerUUID);
File dataFile = new File(path, File.separator + "data.json");
if (dataFile.exists()) {
dataFile.delete();
path.delete();
}
}
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event) {
Player player = event.getPlayer();
String name = player.getName();
UUID playerUUID = event.getPlayer().getUniqueId();
if (!authmeApi.isRegistered(name)) {
if (settings.getProperty(SecuritySettings.DELETE_UNVERIFIED_PLAYER_DATA) && !closeReasonMap.containsKey(player)) {
bukkitService.runTaskLater(() -> {
if (!player.isOnline()) {
deletePlayerData(playerUUID);
deletePlayerStats(playerUUID);
deleteAuthMePlayerData(playerUUID);
}
}, 100L);
return;
}
closeReasonMap.remove(player);
}
} }
} }
@@ -36,9 +36,6 @@ public class LoginLocationFixListener implements Listener {
private static Material materialPortal = Material.matchMaterial("PORTAL"); private static Material materialPortal = Material.matchMaterial("PORTAL");
private static boolean isAvailable; // false: unchecked/method not available true: method is available private static boolean isAvailable; // false: unchecked/method not available true: method is available
private final boolean isSmartAsyncTeleport = AuthMe.settings.getProperty(SecuritySettings.SMART_ASYNC_TELEPORT);
private final boolean isFixPortalStuck = AuthMe.settings.getProperty(SecuritySettings.LOGIN_LOC_FIX_SUB_PORTAL);
private final boolean isFixGroundStuck = AuthMe.settings.getProperty(SecuritySettings.LOGIN_LOC_FIX_SUB_UNDERGROUND);
BlockFace[] faces = {BlockFace.WEST, BlockFace.EAST, BlockFace.NORTH, BlockFace.SOUTH, BlockFace.SOUTH_EAST, BlockFace.SOUTH_WEST, BlockFace.NORTH_EAST, BlockFace.NORTH_WEST}; BlockFace[] faces = {BlockFace.WEST, BlockFace.EAST, BlockFace.NORTH, BlockFace.SOUTH, BlockFace.SOUTH_EAST, BlockFace.SOUTH_WEST, BlockFace.NORTH_EAST, BlockFace.NORTH_WEST};
static { static {
@@ -70,7 +67,7 @@ public class LoginLocationFixListener implements Listener {
public void onPlayerJoin(PlayerJoinEvent event) { public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
Location JoinLocation = player.getLocation(); Location JoinLocation = player.getLocation();
if (isFixPortalStuck) { if (settings.getProperty(SecuritySettings.LOGIN_LOC_FIX_SUB_PORTAL)) {
if (!JoinLocation.getBlock().getType().equals(materialPortal) && !JoinLocation.getBlock().getRelative(BlockFace.UP).getType().equals(materialPortal)) { if (!JoinLocation.getBlock().getType().equals(materialPortal) && !JoinLocation.getBlock().getRelative(BlockFace.UP).getType().equals(materialPortal)) {
return; return;
} }
@@ -78,7 +75,7 @@ public class LoginLocationFixListener implements Listener {
boolean solved = false; boolean solved = false;
for (BlockFace face : faces) { for (BlockFace face : faces) {
if (JoinBlock.getRelative(face).getType().equals(Material.AIR) && JoinBlock.getRelative(face).getRelative(BlockFace.UP).getType().equals(Material.AIR)) { if (JoinBlock.getRelative(face).getType().equals(Material.AIR) && JoinBlock.getRelative(face).getRelative(BlockFace.UP).getType().equals(Material.AIR)) {
if (isSmartAsyncTeleport) { if (settings.getProperty(SecuritySettings.SMART_ASYNC_TELEPORT)) {
TeleportUtils.teleport(player, JoinBlock.getRelative(face).getLocation().add(0.5, 0.1, 0.5)); TeleportUtils.teleport(player, JoinBlock.getRelative(face).getLocation().add(0.5, 0.1, 0.5));
} else { } else {
player.teleport(JoinBlock.getRelative(face).getLocation().add(0.5, 0.1, 0.5)); player.teleport(JoinBlock.getRelative(face).getLocation().add(0.5, 0.1, 0.5));
@@ -93,7 +90,7 @@ public class LoginLocationFixListener implements Listener {
} }
messages.send(player, MessageKey.LOCATION_FIX_PORTAL); messages.send(player, MessageKey.LOCATION_FIX_PORTAL);
} }
if (isFixGroundStuck) { if (settings.getProperty(SecuritySettings.LOGIN_LOC_FIX_SUB_UNDERGROUND)) {
Material UpType = JoinLocation.getBlock().getRelative(BlockFace.UP).getType(); Material UpType = JoinLocation.getBlock().getRelative(BlockFace.UP).getType();
World world = player.getWorld(); World world = player.getWorld();
int MaxHeight = world.getMaxHeight(); int MaxHeight = world.getMaxHeight();
@@ -110,7 +107,7 @@ public class LoginLocationFixListener implements Listener {
if (JoinBlock.getRelative(BlockFace.DOWN).getType().equals(Material.LAVA)) { if (JoinBlock.getRelative(BlockFace.DOWN).getType().equals(Material.LAVA)) {
JoinBlock.getRelative(BlockFace.DOWN).setType(Material.DIRT); JoinBlock.getRelative(BlockFace.DOWN).setType(Material.DIRT);
} }
if (isSmartAsyncTeleport) { if (settings.getProperty(SecuritySettings.SMART_ASYNC_TELEPORT)) {
TeleportUtils.teleport(player, JoinBlock.getLocation().add(0.5, 0.1, 0.5)); TeleportUtils.teleport(player, JoinBlock.getLocation().add(0.5, 0.1, 0.5));
} else { } else {
player.teleport(JoinBlock.getLocation().add(0.5, 0.1, 0.5)); player.teleport(JoinBlock.getLocation().add(0.5, 0.1, 0.5));
@@ -119,7 +116,7 @@ public class LoginLocationFixListener implements Listener {
break; break;
} }
if (i == MaxHeight) { if (i == MaxHeight) {
if (isSmartAsyncTeleport) { if (settings.getProperty(SecuritySettings.SMART_ASYNC_TELEPORT)) {
TeleportUtils.teleport(player, JoinBlock.getLocation().add(0.5, 1.1, 0.5)); TeleportUtils.teleport(player, JoinBlock.getLocation().add(0.5, 1.1, 0.5));
} else { } else {
player.teleport(JoinBlock.getLocation().add(0.5, 1.1, 0.5)); player.teleport(JoinBlock.getLocation().add(0.5, 1.1, 0.5));
@@ -139,7 +139,8 @@ public class OnJoinVerifier implements Reloadable {
} }
Player nonVipPlayer = generateKickPlayer(onlinePlayers); Player nonVipPlayer = generateKickPlayer(onlinePlayers);
if (nonVipPlayer != null) { if (nonVipPlayer != null) {
nonVipPlayer.kickPlayer(messages.retrieveSingle(player, MessageKey.KICK_FOR_VIP)); // AuthMeReReloaded - Folia compatibility
bukkitService.runTaskIfFolia(nonVipPlayer, () -> nonVipPlayer.kickPlayer(messages.retrieveSingle(player, MessageKey.KICK_FOR_VIP)));
event.allow(); event.allow();
return false; return false;
} else { } else {
@@ -1,6 +1,5 @@
package fr.xephi.authme.listener; package fr.xephi.authme.listener;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.api.v3.AuthMeApi; import fr.xephi.authme.api.v3.AuthMeApi;
import fr.xephi.authme.data.QuickCommandsProtectionManager; import fr.xephi.authme.data.QuickCommandsProtectionManager;
import fr.xephi.authme.data.auth.PlayerAuth; import fr.xephi.authme.data.auth.PlayerAuth;
@@ -22,7 +21,6 @@ import fr.xephi.authme.settings.properties.RegistrationSettings;
import fr.xephi.authme.settings.properties.RestrictionSettings; import fr.xephi.authme.settings.properties.RestrictionSettings;
import fr.xephi.authme.settings.properties.SecuritySettings; import fr.xephi.authme.settings.properties.SecuritySettings;
import fr.xephi.authme.util.TeleportUtils; import fr.xephi.authme.util.TeleportUtils;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.HumanEntity; import org.bukkit.entity.HumanEntity;
@@ -32,7 +30,6 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.block.SignChangeEvent; import org.bukkit.event.block.SignChangeEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
//import org.bukkit.event.entity.EntityPickupItemEvent;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryOpenEvent; import org.bukkit.event.inventory.InventoryOpenEvent;
import org.bukkit.event.player.AsyncPlayerChatEvent; import org.bukkit.event.player.AsyncPlayerChatEvent;
@@ -54,17 +51,15 @@ import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerRespawnEvent; import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.event.player.PlayerShearEntityEvent; import org.bukkit.event.player.PlayerShearEntityEvent;
//import org.bukkit.event.player.PlayerSwapHandItemsEvent;
import org.bukkit.inventory.InventoryView; import org.bukkit.inventory.InventoryView;
import static org.bukkit.Bukkit.getServer;
import javax.inject.Inject; import javax.inject.Inject;
import java.util.Locale; import java.util.Locale;
import java.util.Set; import java.util.Set;
import static fr.xephi.authme.settings.properties.RestrictionSettings.ALLOWED_MOVEMENT_RADIUS; import static fr.xephi.authme.settings.properties.RestrictionSettings.ALLOWED_MOVEMENT_RADIUS;
import static fr.xephi.authme.settings.properties.RestrictionSettings.ALLOW_UNAUTHED_MOVEMENT; import static fr.xephi.authme.settings.properties.RestrictionSettings.ALLOW_UNAUTHED_MOVEMENT;
import static org.bukkit.Bukkit.getServer;
/** /**
* Listener class for player events. * Listener class for player events.
@@ -325,7 +320,8 @@ public class PlayerListener implements Listener{
final Player player = event.getPlayer(); final Player player = event.getPlayer();
if (!quickCommandsProtectionManager.isAllowed(player.getName())) { if (!quickCommandsProtectionManager.isAllowed(player.getName())) {
event.setCancelled(true); event.setCancelled(true);
player.kickPlayer(messages.retrieveSingle(player, MessageKey.QUICK_COMMAND_PROTECTION_KICK)); bukkitService.runTaskIfFolia(player, () -> player.kickPlayer(messages.retrieveSingle(player, MessageKey.QUICK_COMMAND_PROTECTION_KICK)));
// AuthMeReReloaded - Folia compatibility
return; return;
} }
if (listenerService.shouldCancelEvent(player)) { if (listenerService.shouldCancelEvent(player)) {
@@ -0,0 +1,85 @@
package fr.xephi.authme.listener;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.api.v3.AuthMeApi;
import fr.xephi.authme.service.BukkitService;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.SecuritySettings;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerQuitEvent;
import javax.inject.Inject;
import java.io.File;
import java.util.UUID;
public class PurgeListener implements Listener {
private final AuthMeApi authmeApi = AuthMeApi.getInstance();
@Inject
private Settings settings;
@Inject
private BukkitService bukkitService;
@Inject
private AuthMe plugin;
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event) {
Player player = event.getPlayer();
String name = player.getName();
UUID playerUUID = event.getPlayer().getUniqueId();
if (!authmeApi.isRegistered(name)) {
if (settings.getProperty(SecuritySettings.PURGE_DATA_ON_QUIT)) {
bukkitService.runTaskLater(() -> {
if (!player.isOnline()) {
deletePlayerData(playerUUID);
deletePlayerStats(playerUUID);
deleteAuthMePlayerData(playerUUID);
}
}, 100L);
}
}
}
private void deletePlayerData(UUID playerUUID) {
// 获取服务器的存储文件夹路径
File serverFolder = Bukkit.getServer().getWorldContainer();
String worldFolderName = settings.getProperty(SecuritySettings.DELETE_PLAYER_DATA_WORLD);
// 构建playerdata文件夹路径
File playerDataFolder = new File(serverFolder, File.separator + worldFolderName + File.separator + "playerdata");
// 构建玩家数据文件路径
File playerDataFile = new File(playerDataFolder, File.separator + playerUUID + ".dat");
// 删除玩家数据文件
if (playerDataFile.exists()) {
playerDataFile.delete();
}
}
private void deleteAuthMePlayerData(UUID playerUUID) {
File pluginFolder = plugin.getDataFolder();
File path = new File(pluginFolder, File.separator + "playerdata" + File.separator + playerUUID);
File dataFile = new File(path, File.separator + "data.json");
if (dataFile.exists()) {
dataFile.delete();
path.delete();
}
}
private void deletePlayerStats(UUID playerUUID) {
// 获取服务器的存储文件夹路径
File serverFolder = Bukkit.getServer().getWorldContainer();
String worldFolderName = settings.getProperty(SecuritySettings.DELETE_PLAYER_DATA_WORLD);
// 构建stats文件夹路径
File statsFolder = new File(serverFolder, File.separator + worldFolderName + File.separator + "stats");
// 构建玩家统计数据文件路径
File statsFile = new File(statsFolder, File.separator + playerUUID + ".json");
// 删除玩家统计数据文件
if (statsFile.exists()) {
statsFile.delete();
}
}
}
@@ -34,7 +34,6 @@ import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import java.lang.reflect.InvocationTargetException;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
@@ -189,7 +189,9 @@ public class AsynchronousJoin implements AsynchronousProcess {
if (service.getProperty(RegistrationSettings.APPLY_BLIND_EFFECT)) { if (service.getProperty(RegistrationSettings.APPLY_BLIND_EFFECT)) {
// Allow infinite blindness effect // Allow infinite blindness effect
int blindTimeOut = (registrationTimeout <= 0) ? 99999 : registrationTimeout; int blindTimeOut = (registrationTimeout <= 0) ? 99999 : registrationTimeout;
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, blindTimeOut, 2));
// AuthMeReReloaded - Fix potion apply on Folia
bukkitService.runTaskIfFolia(player,() -> player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, blindTimeOut, 2)));
} }
commandManager.runCommandsOnJoin(player); commandManager.runCommandsOnJoin(player);
}); });
@@ -86,6 +86,13 @@ public class ProcessSyncPlayerLogin implements SynchronousProcess {
} }
final PlayerAuth auth = playerCache.getAuth(name); final PlayerAuth auth = playerCache.getAuth(name);
// AuthMeReReloaded start - Fix #57
if (isFirstLogin) {
auth.setQuitLocation(player.getLocation());
}
// AuthMeReReloaded end - Fix #57
teleportationService.teleportOnLogin(player, auth, limbo); teleportationService.teleportOnLogin(player, auth, limbo);
// We can now display the join message (if delayed) // We can now display the join message (if delayed)
@@ -1,5 +1,6 @@
package fr.xephi.authme.service; package fr.xephi.authme.service;
import com.github.Anon8281.universalScheduler.scheduling.tasks.MyScheduledTask;
import fr.xephi.authme.initialization.SettingsDependent; import fr.xephi.authme.initialization.SettingsDependent;
import fr.xephi.authme.message.MessageKey; import fr.xephi.authme.message.MessageKey;
import fr.xephi.authme.message.Messages; import fr.xephi.authme.message.Messages;
@@ -8,7 +9,6 @@ import fr.xephi.authme.permission.PermissionsManager;
import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.ProtectionSettings; import fr.xephi.authme.settings.properties.ProtectionSettings;
import fr.xephi.authme.util.AtomicIntervalCounter; import fr.xephi.authme.util.AtomicIntervalCounter;
import org.bukkit.scheduler.BukkitTask;
import javax.inject.Inject; import javax.inject.Inject;
import java.util.Locale; import java.util.Locale;
@@ -32,7 +32,7 @@ public class AntiBotService implements SettingsDependent {
// Service status // Service status
private AntiBotStatus antiBotStatus; private AntiBotStatus antiBotStatus;
private boolean startup; private boolean startup;
private BukkitTask disableTask; private MyScheduledTask disableTask;
private AtomicIntervalCounter flaggedCounter; private AtomicIntervalCounter flaggedCounter;
@Inject @Inject
@@ -94,6 +94,9 @@ public class BackupService {
case SQLITE: case SQLITE:
String dbName = settings.getProperty(DatabaseSettings.MYSQL_DATABASE); String dbName = settings.getProperty(DatabaseSettings.MYSQL_DATABASE);
return performFileBackup(dbName + ".db"); return performFileBackup(dbName + ".db");
case H2:
String h2dbName = settings.getProperty(DatabaseSettings.MYSQL_DATABASE);
return performFileBackup(h2dbName + ".mv.db");
default: default:
logger.warning("Unknown data source type '" + dataSourceType + "' for backup"); logger.warning("Unknown data source type '" + dataSourceType + "' for backup");
} }
@@ -1,20 +1,23 @@
package fr.xephi.authme.service; package fr.xephi.authme.service;
import com.github.Anon8281.universalScheduler.UniversalRunnable;
import com.github.Anon8281.universalScheduler.scheduling.tasks.MyScheduledTask;
import fr.xephi.authme.AuthMe; import fr.xephi.authme.AuthMe;
import fr.xephi.authme.initialization.SettingsDependent; import fr.xephi.authme.initialization.SettingsDependent;
import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.PluginSettings; import fr.xephi.authme.settings.properties.PluginSettings;
import fr.xephi.authme.util.Utils;
import org.bukkit.BanEntry; import org.bukkit.BanEntry;
import org.bukkit.BanList; import org.bukkit.BanList;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
import javax.inject.Inject; import javax.inject.Inject;
import java.util.Collection; import java.util.Collection;
@@ -23,6 +26,8 @@ import java.util.Optional;
import java.util.Set; import java.util.Set;
import java.util.function.Function; import java.util.function.Function;
import static fr.xephi.authme.AuthMe.getScheduler;
/** /**
* Service for operations requiring the Bukkit API, such as for scheduling. * Service for operations requiring the Bukkit API, such as for scheduling.
*/ */
@@ -32,7 +37,8 @@ public class BukkitService implements SettingsDependent {
public static final int TICKS_PER_SECOND = 20; public static final int TICKS_PER_SECOND = 20;
/** Number of ticks per minute. */ /** Number of ticks per minute. */
public static final int TICKS_PER_MINUTE = 60 * TICKS_PER_SECOND; public static final int TICKS_PER_MINUTE = 60 * TICKS_PER_SECOND;
/** Whether the server is running Folia. */
private static final boolean IS_FOLIA = Utils.isClassLoaded("io.papermc.paper.threadedregions.RegionizedServer");
private final AuthMe authMe; private final AuthMe authMe;
private boolean useAsyncTasks; private boolean useAsyncTasks;
@@ -48,10 +54,9 @@ public class BukkitService implements SettingsDependent {
* This task will be executed by the main server thread. * This task will be executed by the main server thread.
* *
* @param task Task to be executed * @param task Task to be executed
* @return Task id number (-1 if scheduling failed)
*/ */
public int scheduleSyncDelayedTask(Runnable task) { public void scheduleSyncDelayedTask(Runnable task) {
return Bukkit.getScheduler().scheduleSyncDelayedTask(authMe, task); getScheduler().runTask(task);
} }
/** /**
@@ -59,12 +64,11 @@ public class BukkitService implements SettingsDependent {
* <p> * <p>
* This task will be executed by the main server thread. * This task will be executed by the main server thread.
* *
* @param task Task to be executed * @param task Task to be executed
* @param delay Delay in server ticks before executing task * @param delay Delay in server ticks before executing task
* @return Task id number (-1 if scheduling failed)
*/ */
public int scheduleSyncDelayedTask(Runnable task, long delay) { public void scheduleSyncDelayedTask(Runnable task, long delay) {
return Bukkit.getScheduler().scheduleSyncDelayedTask(authMe, task, delay); getScheduler().runTaskLater(task, delay);
} }
/** /**
@@ -76,7 +80,7 @@ public class BukkitService implements SettingsDependent {
*/ */
public void scheduleSyncTaskFromOptionallyAsyncTask(Runnable task) { public void scheduleSyncTaskFromOptionallyAsyncTask(Runnable task) {
if (Bukkit.isPrimaryThread()) { if (Bukkit.isPrimaryThread()) {
task.run(); runTask(task);
} else { } else {
scheduleSyncDelayedTask(task); scheduleSyncDelayedTask(task);
} }
@@ -86,26 +90,71 @@ public class BukkitService implements SettingsDependent {
* Returns a task that will run on the next server tick. * Returns a task that will run on the next server tick.
* *
* @param task the task to be run * @param task the task to be run
* @return a BukkitTask that contains the id number
* @throws IllegalArgumentException if plugin is null * @throws IllegalArgumentException if plugin is null
* @throws IllegalArgumentException if task is null * @throws IllegalArgumentException if task is null
*/ */
public BukkitTask runTask(Runnable task) { public void runTask(Runnable task) {
return Bukkit.getScheduler().runTask(authMe, task); getScheduler().runTask(task);
} }
public void runTask(Entity entity, Runnable task) {
getScheduler().runTask(entity, task);
}
public void runTask(Location location, Runnable task) {
getScheduler().runTask(location, task);
}
/**
* Runs the task synchronously if we are running Folia, else do nothing but run it.
* @param task the task to be run
*/
public void runTaskIfFolia(Runnable task) {
if (IS_FOLIA) {
runTask(task);
} else {
task.run();
}
}
/**
* Runs the task synchronously if we are running Folia, else do nothing but run it.
* @param task the task to be run
*/
public void runTaskIfFolia(Entity entity, Runnable task) {
if (IS_FOLIA) {
runTask(entity, task);
} else {
task.run();
}
}
/**
* Runs the task synchronously if we are running Folia, else do nothing but run it.
* @param task the task to be run
*/
public void runTaskIfFolia(Location location, Runnable task) {
if (IS_FOLIA) {
runTask(location, task);
} else {
task.run();
}
}
/** /**
* Returns a task that will run after the specified number of server * Returns a task that will run after the specified number of server
* ticks. * ticks.
* *
* @param task the task to be run * @param task the task to be run
* @param delay the ticks to wait before running the task * @param delay the ticks to wait before running the task
* @return a BukkitTask that contains the id number * @return a BukkitTask that contains the id number
* @throws IllegalArgumentException if plugin is null * @throws IllegalArgumentException if plugin is null
* @throws IllegalArgumentException if task is null * @throws IllegalArgumentException if task is null
*/ */
public BukkitTask runTaskLater(Runnable task, long delay) { public MyScheduledTask runTaskLater(Runnable task, long delay) {
return Bukkit.getScheduler().runTaskLater(authMe, task, delay); return getScheduler().runTaskLater(task, delay);
} }
/** /**
@@ -118,7 +167,7 @@ public class BukkitService implements SettingsDependent {
if (useAsyncTasks) { if (useAsyncTasks) {
runTaskAsynchronously(task); runTaskAsynchronously(task);
} else { } else {
task.run(); runTask(task);
} }
} }
@@ -129,12 +178,11 @@ public class BukkitService implements SettingsDependent {
* Returns a task that will run asynchronously. * Returns a task that will run asynchronously.
* *
* @param task the task to be run * @param task the task to be run
* @return a BukkitTask that contains the id number
* @throws IllegalArgumentException if plugin is null * @throws IllegalArgumentException if plugin is null
* @throws IllegalArgumentException if task is null * @throws IllegalArgumentException if task is null
*/ */
public BukkitTask runTaskAsynchronously(Runnable task) { public void runTaskAsynchronously(Runnable task) {
return Bukkit.getScheduler().runTaskAsynchronously(authMe, task); getScheduler().runTaskAsynchronously(task);
} }
/** /**
@@ -152,7 +200,7 @@ public class BukkitService implements SettingsDependent {
* @throws IllegalArgumentException if task is null * @throws IllegalArgumentException if task is null
* @throws IllegalStateException if this was already scheduled * @throws IllegalStateException if this was already scheduled
*/ */
public BukkitTask runTaskTimerAsynchronously(BukkitRunnable task, long delay, long period) { public MyScheduledTask runTaskTimerAsynchronously(UniversalRunnable task, long delay, long period) {
return task.runTaskTimerAsynchronously(authMe, delay, period); return task.runTaskTimerAsynchronously(authMe, delay, period);
} }
@@ -160,14 +208,14 @@ public class BukkitService implements SettingsDependent {
* Schedules the given task to repeatedly run until cancelled, starting after the * Schedules the given task to repeatedly run until cancelled, starting after the
* specified number of server ticks. * specified number of server ticks.
* *
* @param task the task to schedule * @param task the task to schedule
* @param delay the ticks to wait before running the task * @param delay the ticks to wait before running the task
* @param period the ticks to wait between runs * @param period the ticks to wait between runs
* @return a BukkitTask that contains the id number * @return a BukkitTask that contains the id number
* @throws IllegalArgumentException if plugin is null * @throws IllegalArgumentException if plugin is null
* @throws IllegalStateException if this was already scheduled * @throws IllegalStateException if this was already scheduled
*/ */
public BukkitTask runTaskTimer(BukkitRunnable task, long delay, long period) { public MyScheduledTask runTaskTimer(UniversalRunnable task, long delay, long period) {
return task.runTaskTimer(authMe, delay, period); return task.runTaskTimer(authMe, delay, period);
} }
@@ -1,9 +1,6 @@
package fr.xephi.authme.service; package fr.xephi.authme.service;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import com.google.common.hash.HashCode;
import com.google.common.hash.HashFunction;
import com.google.common.hash.Hashing;
import com.maxmind.db.GeoIp2Provider; import com.maxmind.db.GeoIp2Provider;
import com.maxmind.db.Reader; import com.maxmind.db.Reader;
import com.maxmind.db.Reader.FileMode; import com.maxmind.db.Reader.FileMode;
@@ -13,32 +10,16 @@ import com.maxmind.db.model.CountryResponse;
import fr.xephi.authme.ConsoleLogger; import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.initialization.DataFolder; import fr.xephi.authme.initialization.DataFolder;
import fr.xephi.authme.output.ConsoleLoggerFactory; import fr.xephi.authme.output.ConsoleLoggerFactory;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.ProtectionSettings;
import fr.xephi.authme.util.FileUtils;
import fr.xephi.authme.util.InternetProtocolUtils; import fr.xephi.authme.util.InternetProtocolUtils;
import javax.inject.Inject; import javax.inject.Inject;
import java.io.BufferedInputStream;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.URL;
import java.net.UnknownHostException; import java.net.UnknownHostException;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.nio.file.attribute.FileTime;
import java.time.Duration;
import java.time.Instant;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Base64;
import java.util.Objects;
import java.util.Optional; import java.util.Optional;
import java.util.zip.GZIPInputStream;
public class GeoIpService { public class GeoIpService {
@@ -142,8 +142,9 @@ public class TeleportationService implements Reloadable {
logger.debug("Teleporting `{0}` to spawn because of 'force-spawn after login'", player.getName()); logger.debug("Teleporting `{0}` to spawn because of 'force-spawn after login'", player.getName());
teleportToSpawn(player, true); teleportToSpawn(player, true);
} else if (settings.getProperty(TELEPORT_UNAUTHED_TO_SPAWN)) { } else if (settings.getProperty(TELEPORT_UNAUTHED_TO_SPAWN)) {
if (settings.getProperty(RestrictionSettings.SAVE_QUIT_LOCATION) && auth.getQuitLocY() != 0) { if (settings.getProperty(RestrictionSettings.SAVE_QUIT_LOCATION)) {
Location location = buildLocationFromAuth(player, auth); Location location = buildLocationFromAuth(player, auth);
if (location.equals(player.getLocation())) return;
logger.debug("Teleporting `{0}` after login, based on the player auth", player.getName()); logger.debug("Teleporting `{0}` after login, based on the player auth", player.getName());
teleportBackFromSpawn(player, location); teleportBackFromSpawn(player, location);
} else if (limbo != null && limbo.getLocation() != null) { } else if (limbo != null && limbo.getLocation() != null) {
@@ -22,19 +22,16 @@ import fr.xephi.authme.util.Utils;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.io.DataInputStream;
import java.net.HttpURLConnection;
import java.net.ProtocolException;
import java.net.URL;
import java.util.Arrays;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import javax.inject.Inject; import javax.inject.Inject;
import java.io.DataInputStream;
import java.net.HttpURLConnection;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.net.URL;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Set; import java.util.Set;
import java.util.concurrent.TimeoutException;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import static fr.xephi.authme.util.StringUtils.isInsideString; import static fr.xephi.authme.util.StringUtils.isInsideString;
@@ -10,7 +10,7 @@ import static ch.jalu.configme.properties.PropertyInitializer.newProperty;
public final class DatabaseSettings implements SettingsHolder { public final class DatabaseSettings implements SettingsHolder {
@Comment({"What type of database do you want to use?", @Comment({"What type of database do you want to use?",
"Valid values: SQLITE, MARIADB, MYSQL, POSTGRESQL"}) "Valid values: H2, SQLITE, MARIADB, MYSQL, POSTGRESQL"})
public static final Property<DataSourceType> BACKEND = public static final Property<DataSourceType> BACKEND =
newProperty(DataSourceType.class, "DataSource.backend", DataSourceType.SQLITE); newProperty(DataSourceType.class, "DataSource.backend", DataSourceType.SQLITE);
@@ -4,8 +4,6 @@ import ch.jalu.configme.Comment;
import ch.jalu.configme.SettingsHolder; import ch.jalu.configme.SettingsHolder;
import ch.jalu.configme.properties.Property; import ch.jalu.configme.properties.Property;
import java.util.Collections;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
@@ -27,10 +27,18 @@ public final class SecuritySettings implements SettingsHolder {
newListProperty("3rdPartyFeature.features.captcha.whiteList"); newListProperty("3rdPartyFeature.features.captcha.whiteList");
@Comment({"Should we let Bedrock players login automatically?", @Comment({"Should we let Bedrock players login automatically?",
"(Requires hookFloodgate to be true & floodgate loaded)"}) "(Requires hookFloodgate to be true & floodgate loaded)",
"(**THIS IS SAFE DO NOT WORRY**)"})
public static final Property<Boolean> FORCE_LOGIN_BEDROCK = public static final Property<Boolean> FORCE_LOGIN_BEDROCK =
newProperty("3rdPartyFeature.features.bedrockAutoLogin", false); newProperty("3rdPartyFeature.features.bedrockAutoLogin", false);
@Comment("Should we purge data on non-registered players quit?")
public static final Property<Boolean> PURGE_DATA_ON_QUIT =
newProperty("3rdPartyFeature.features.purgeData.purgeOnQuit", false);
@Comment("Which world's player data should be deleted?(Enter the world *FOLDER* name where your players first logged in)")
public static final Property<String> DELETE_PLAYER_DATA_WORLD =
newProperty("3rdPartyFeature.features.purgeData.purgeWorldFolderName", "world");
@Comment("Enable the new feature to prevent ghost players?") @Comment("Enable the new feature to prevent ghost players?")
public static final Property<Boolean> ANTI_GHOST_PLAYERS = public static final Property<Boolean> ANTI_GHOST_PLAYERS =
newProperty("3rdPartyFeature.fixes.antiGhostPlayer", false); newProperty("3rdPartyFeature.fixes.antiGhostPlayer", false);
@@ -43,7 +51,7 @@ public final class SecuritySettings implements SettingsHolder {
@Comment({"Choose the best teleport method by server brand?", @Comment({"Choose the best teleport method by server brand?",
"(Enable this if you are using Paper)"}) "(Enable this if you are using Paper)"})
public static final Property<Boolean> SMART_ASYNC_TELEPORT = public static final Property<Boolean> SMART_ASYNC_TELEPORT =
newProperty("3rdPartyFeature.optimizes.smartAsyncTeleport", false); newProperty("3rdPartyFeature.optimizes.smartAsyncTeleport", true);
@Comment("Send a GUI captcha to unregistered players?(Requires ProtocolLib)") @Comment("Send a GUI captcha to unregistered players?(Requires ProtocolLib)")
public static final Property<Boolean> GUI_CAPTCHA = public static final Property<Boolean> GUI_CAPTCHA =
@@ -59,14 +67,6 @@ public final class SecuritySettings implements SettingsHolder {
public static final Property<Boolean> GUI_CAPTCHA_BE_COMPATIBILITY = public static final Property<Boolean> GUI_CAPTCHA_BE_COMPATIBILITY =
newProperty("3rdPartyFeature.features.captcha.ignoreBedrock", false); newProperty("3rdPartyFeature.features.captcha.ignoreBedrock", false);
@Comment("Should we delete player data and stats when they didn't finish the captcha?")
public static final Property<Boolean> DELETE_UNVERIFIED_PLAYER_DATA =
newProperty("3rdPartyFeature.features.captcha.purgePlayerData", false);
@Comment("Which world's player data should be deleted?(Enter the world *FOLDER* name where your players first logged in)")
public static final Property<String> DELETE_PLAYER_DATA_WORLD =
newProperty("3rdPartyFeature.features.captcha.purgeWorldFolderName", "world");
@Comment("Should we fix the location when players logged in the portal?") @Comment("Should we fix the location when players logged in the portal?")
public static final Property<Boolean> LOGIN_LOC_FIX_SUB_PORTAL = public static final Property<Boolean> LOGIN_LOC_FIX_SUB_PORTAL =
newProperty("3rdPartyFeature.fixes.loginLocationFix.fixPortalStuck", false); newProperty("3rdPartyFeature.fixes.loginLocationFix.fixPortalStuck", false);
@@ -1,15 +1,15 @@
package fr.xephi.authme.task; package fr.xephi.authme.task;
import ch.jalu.injector.factory.SingletonStore; import ch.jalu.injector.factory.SingletonStore;
import com.github.Anon8281.universalScheduler.UniversalRunnable;
import fr.xephi.authme.initialization.HasCleanup; import fr.xephi.authme.initialization.HasCleanup;
import org.bukkit.scheduler.BukkitRunnable;
import javax.inject.Inject; import javax.inject.Inject;
/** /**
* Task run periodically to invoke the cleanup task on services. * Task run periodically to invoke the cleanup task on services.
*/ */
public class CleanupTask extends BukkitRunnable { public class CleanupTask extends UniversalRunnable {
@Inject @Inject
private SingletonStore<HasCleanup> hasCleanupStore; private SingletonStore<HasCleanup> hasCleanupStore;
@@ -1,12 +1,12 @@
package fr.xephi.authme.task; package fr.xephi.authme.task;
import com.github.Anon8281.universalScheduler.UniversalRunnable;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
/** /**
* Message shown to a player in a regular interval as long as he is not logged in. * Message shown to a player in a regular interval as long as he is not logged in.
*/ */
public class MessageTask extends BukkitRunnable { public class MessageTask extends UniversalRunnable {
private final Player player; private final Player player;
private final String[] message; private final String[] message;
@@ -1,5 +1,6 @@
package fr.xephi.authme.task.purge; package fr.xephi.authme.task.purge;
import com.github.Anon8281.universalScheduler.UniversalRunnable;
import fr.xephi.authme.ConsoleLogger; import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.output.ConsoleLoggerFactory; import fr.xephi.authme.output.ConsoleLoggerFactory;
import fr.xephi.authme.permission.PermissionsManager; import fr.xephi.authme.permission.PermissionsManager;
@@ -9,14 +10,13 @@ import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.HashSet; import java.util.HashSet;
import java.util.Locale; import java.util.Locale;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
class PurgeTask extends BukkitRunnable { class PurgeTask extends UniversalRunnable {
//how many players we should check for each tick //how many players we should check for each tick
private static final int INTERVAL_CHECK = 5; private static final int INTERVAL_CHECK = 5;
@@ -28,7 +28,7 @@ public final class PlayerUtils {
* @return True if the player is an NPC, false otherwise * @return True if the player is an NPC, false otherwise
*/ */
public static boolean isNpc(Player player) { public static boolean isNpc(Player player) {
return player.hasMetadata("NPC"); return player.hasMetadata("NPC") || player.getAddress() == null;
} }
} }
+2 -2
View File
@@ -102,9 +102,9 @@
<tbody> <tbody>
<tr> <tr>
<td> <td>
<p style="color:#b0adc5;">© 2023 HomoCraft. All rights reserved.</p> <p style="color:#b0adc5;">© 2024 HomoCraft. All rights reserved.</p>
<a href="1919810.com" target="_blank" <a href="1919810.com" target="_blank"
style="text-decoration: none; font-size: 16px">wdsj.io</a> style="text-decoration: none; font-size: 16px">wdsj.in</a>
</td> </td>
</tr> </tr>
</tbody> </tbody>
+2 -2
View File
@@ -108,9 +108,9 @@
<tbody> <tbody>
<tr> <tr>
<td> <td>
<p style="color:#b0adc5;">© 2023 HomoCraft. All rights reserved.</p> <p style="color:#b0adc5;">© 2024 HomoCraft. All rights reserved.</p>
<a href="1919810.com" target="_blank" <a href="1919810.com" target="_blank"
style="text-decoration: none; font-size: 16px">wdsj.io</a> style="text-decoration: none; font-size: 16px">wdsj.in</a>
</td> </td>
</tr> </tr>
</tbody> </tbody>
+2 -1
View File
@@ -3,7 +3,8 @@ authors: [${pluginDescription.authors}]
website: http://github.com/HaHaWTH/AuthMeReReloaded/ website: http://github.com/HaHaWTH/AuthMeReReloaded/
description: A fork of AuthMeReloaded that contains bug fixes description: A fork of AuthMeReloaded that contains bug fixes
main: ${pluginDescription.main} main: ${pluginDescription.main}
version: 5.6.0-FORK-b40 folia-supported: true
version: 5.6.0-FORK-b44
api-version: 1.13 api-version: 1.13
softdepend: softdepend:
- Vault - Vault
+2 -2
View File
@@ -101,9 +101,9 @@
<tbody> <tbody>
<tr> <tr>
<td> <td>
<p style="color:#b0adc5;">© 2023 HomoCraft. All rights reserved.</p> <p style="color:#b0adc5;">© 2024 HomoCraft. All rights reserved.</p>
<a href="1919810.com" target="_blank" <a href="1919810.com" target="_blank"
style="text-decoration: none; font-size: 16px">wdsj.io</a> style="text-decoration: none; font-size: 16px">wdsj.in</a>
</td> </td>
</tr> </tr>
</tbody> </tbody>
+2 -2
View File
@@ -99,9 +99,9 @@
<tbody> <tbody>
<tr> <tr>
<td> <td>
<p style="color:#b0adc5;">© 2023 HomoCraft. All rights reserved.</p> <p style="color:#b0adc5;">© 2024 HomoCraft. All rights reserved.</p>
<a href="1919810.com" target="_blank" <a href="1919810.com" target="_blank"
style="text-decoration: none; font-size: 16px">wdsj.io</a> style="text-decoration: none; font-size: 16px">wdsj.in</a>
</td> </td>
</tr> </tr>
</tbody> </tbody>
@@ -101,9 +101,9 @@
<tbody> <tbody>
<tr> <tr>
<td> <td>
<p style="color:#b0adc5;">© 2023 HomoCraft. All rights reserved.</p> <p style="color:#b0adc5;">© 2024 HomoCraft. All rights reserved.</p>
<a href="1919810.com" target="_blank" <a href="1919810.com" target="_blank"
style="text-decoration: none; font-size: 16px">wdsj.io</a> style="text-decoration: none; font-size: 16px">wdsj.in</a>
</td> </td>
</tr> </tr>
</tbody> </tbody>