Compare commits
38 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 23306d1f5c | |||
| fc546ac87a | |||
| 764b2788ae | |||
| d1fc832d2d | |||
| c170c70639 | |||
| 8db8d0f6da | |||
| 6b5e0b82ba | |||
| 265ea66894 | |||
| b1b4bb0a79 | |||
| fa7ce8bfb4 | |||
| 78369644c7 | |||
| 22b8b6bf64 | |||
| fcec8e41a2 | |||
| ee24cabbed | |||
| eed1c5aedc | |||
| 1f88b3bc12 | |||
| 5cd8791fee | |||
| 787e04488b | |||
| 2accd9592c | |||
| 66bfbbbdb1 | |||
| cb195fd1ca | |||
| a1ef28095f | |||
| 77b40cc1e8 | |||
| 4c52484fd7 | |||
| 5b72708167 | |||
| b69e931c44 | |||
| 213b1c2702 | |||
| 0fef595229 | |||
| 791d1f1872 | |||
| ef92c776af | |||
| 66cf0143f6 | |||
| 3ff3b0d294 | |||
| b9ecb58760 | |||
| a8e55b4ae3 | |||
| 657e51f2cc | |||
| ff16f91311 | |||
| d05d4971b5 | |||
| 5f58e92666 |
@@ -21,3 +21,8 @@ jobs:
|
|||||||
cache: 'maven'
|
cache: 'maven'
|
||||||
- name: Build
|
- name: Build
|
||||||
run: mvn -V -B clean package --file pom.xml
|
run: mvn -V -B clean package --file pom.xml
|
||||||
|
- name: Upload Artifacts
|
||||||
|
uses: actions/upload-artifact@v3.1.2
|
||||||
|
with:
|
||||||
|
name: Download
|
||||||
|
path: ./target/AuthMe-5.6.0-FORK-Spigot-Universal.jar
|
||||||
|
|||||||
@@ -19,8 +19,14 @@ 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 compatibility [Here](https://github.com/HaHaWTH/AuthMeReReloaded/releases/download/b20/AuthMe-5.6.0-FORK-Folia.jar)
|
12. Folia
|
||||||
|
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. More......
|
15. More......
|
||||||
|
|
||||||
|
**Download links:**
|
||||||
|
[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)
|
||||||
|
|
||||||
**Pull Requests and suggestions are welcome!**
|
**Pull Requests and suggestions are welcome!**
|
||||||
|
|||||||
@@ -598,6 +598,11 @@
|
|||||||
<enabled>true</enabled>
|
<enabled>true</enabled>
|
||||||
</snapshots>
|
</snapshots>
|
||||||
</repository>
|
</repository>
|
||||||
|
<!-- FoliaLib -->
|
||||||
|
<repository>
|
||||||
|
<id>devmart-other</id>
|
||||||
|
<url>https://nexuslite.gcnt.net/repos/other/</url>
|
||||||
|
</repository>
|
||||||
<repository>
|
<repository>
|
||||||
<id>opencollab-snapshot</id>
|
<id>opencollab-snapshot</id>
|
||||||
<url>https://repo.opencollab.dev/maven-snapshots/</url>
|
<url>https://repo.opencollab.dev/maven-snapshots/</url>
|
||||||
@@ -1076,13 +1081,13 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.xerial</groupId>
|
<groupId>org.xerial</groupId>
|
||||||
<artifactId>sqlite-jdbc</artifactId>
|
<artifactId>sqlite-jdbc</artifactId>
|
||||||
<version>3.43.2.2</version>
|
<version>3.44.0.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.2.224</version>
|
<version>2.1.214</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ 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 = "32";
|
private static String pluginBuildNumber = "34";
|
||||||
// Private instances
|
// Private instances
|
||||||
private EmailService emailService;
|
private EmailService emailService;
|
||||||
private CommandHandler commandHandler;
|
private CommandHandler commandHandler;
|
||||||
@@ -176,7 +176,6 @@ public class AuthMe extends JavaPlugin {
|
|||||||
cleanupTask.runTaskTimerAsynchronously(this, CLEANUP_INTERVAL, CLEANUP_INTERVAL);
|
cleanupTask.runTaskTimerAsynchronously(this, CLEANUP_INTERVAL, CLEANUP_INTERVAL);
|
||||||
// Do a backup on start
|
// Do a backup on start
|
||||||
backupService.doBackup(BackupService.BackupCause.START);
|
backupService.doBackup(BackupService.BackupCause.START);
|
||||||
|
|
||||||
// Set up Metrics
|
// Set up Metrics
|
||||||
OnStartupTasks.sendMetrics(this, settings);
|
OnStartupTasks.sendMetrics(this, settings);
|
||||||
if(settings.getProperty(SecuritySettings.SHOW_STARTUP_BANNER)) {
|
if(settings.getProperty(SecuritySettings.SHOW_STARTUP_BANNER)) {
|
||||||
@@ -396,7 +395,7 @@ public class AuthMe extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static final String owner = "HaHaWTH";
|
private static final String owner = "HaHaWTH";
|
||||||
private static final String owner_gitee = "Shixuehan114514";
|
// private static final String owner_gitee = "Shixuehan114514";
|
||||||
private static final String repo = "AuthMeReReloaded";
|
private static final String repo = "AuthMeReReloaded";
|
||||||
|
|
||||||
private void checkForUpdates() {
|
private void checkForUpdates() {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ package fr.xephi.authme.datasource;
|
|||||||
* DataSource type.
|
* DataSource type.
|
||||||
*/
|
*/
|
||||||
public enum DataSourceType {
|
public enum DataSourceType {
|
||||||
|
// H2,
|
||||||
|
|
||||||
MYSQL,
|
MYSQL,
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,408 @@
|
|||||||
|
//package fr.xephi.authme.datasource;
|
||||||
|
//
|
||||||
|
//import com.google.common.annotations.VisibleForTesting;
|
||||||
|
//import fr.xephi.authme.ConsoleLogger;
|
||||||
|
//import fr.xephi.authme.data.auth.PlayerAuth;
|
||||||
|
//import fr.xephi.authme.datasource.columnshandler.AuthMeColumnsHandler;
|
||||||
|
//import fr.xephi.authme.output.ConsoleLoggerFactory;
|
||||||
|
//import fr.xephi.authme.settings.Settings;
|
||||||
|
//import fr.xephi.authme.settings.properties.DatabaseSettings;
|
||||||
|
//
|
||||||
|
//import java.io.File;
|
||||||
|
//import java.sql.Connection;
|
||||||
|
//import java.sql.DatabaseMetaData;
|
||||||
|
//import java.sql.DriverManager;
|
||||||
|
//import java.sql.PreparedStatement;
|
||||||
|
//import java.sql.ResultSet;
|
||||||
|
//import java.sql.SQLException;
|
||||||
|
//import java.sql.Statement;
|
||||||
|
//import java.util.ArrayList;
|
||||||
|
//import java.util.Collection;
|
||||||
|
//import java.util.HashSet;
|
||||||
|
//import java.util.List;
|
||||||
|
//import java.util.Locale;
|
||||||
|
//import java.util.Set;
|
||||||
|
//
|
||||||
|
//import static fr.xephi.authme.datasource.SqlDataSourceUtils.getNullableLong;
|
||||||
|
//import static fr.xephi.authme.datasource.SqlDataSourceUtils.logSqlException;
|
||||||
|
//
|
||||||
|
///**
|
||||||
|
// * H2 data source.
|
||||||
|
// */
|
||||||
|
//@SuppressWarnings({"checkstyle:AbbreviationAsWordInName"}) // Justification: Class name cannot be changed anymore
|
||||||
|
//public class H2 extends AbstractSqlDataSource {
|
||||||
|
//
|
||||||
|
// private final ConsoleLogger logger = ConsoleLoggerFactory.get(H2.class);
|
||||||
|
// private final Settings settings;
|
||||||
|
// private final File dataFolder;
|
||||||
|
// private final String database;
|
||||||
|
// private final String tableName;
|
||||||
|
// private final Columns col;
|
||||||
|
// private Connection con;
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * Constructor for H2.
|
||||||
|
// *
|
||||||
|
// * @param settings The settings instance
|
||||||
|
// * @param dataFolder The data folder
|
||||||
|
// * @throws SQLException when initialization of a SQL datasource failed
|
||||||
|
// */
|
||||||
|
// public H2(Settings settings, File dataFolder) throws SQLException {
|
||||||
|
// this.settings = settings;
|
||||||
|
// this.dataFolder = dataFolder;
|
||||||
|
// this.database = settings.getProperty(DatabaseSettings.MYSQL_DATABASE);
|
||||||
|
// this.tableName = settings.getProperty(DatabaseSettings.MYSQL_TABLE);
|
||||||
|
// this.col = new Columns(settings);
|
||||||
|
//
|
||||||
|
// try {
|
||||||
|
// this.connect();
|
||||||
|
// this.setup();
|
||||||
|
// } catch (Exception ex) {
|
||||||
|
// logger.logException("Error during H2 initialization:", ex);
|
||||||
|
// throw ex;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @VisibleForTesting
|
||||||
|
// H2(Settings settings, File dataFolder, Connection connection) {
|
||||||
|
// this.settings = settings;
|
||||||
|
// this.dataFolder = dataFolder;
|
||||||
|
// this.database = settings.getProperty(DatabaseSettings.MYSQL_DATABASE);
|
||||||
|
// this.tableName = settings.getProperty(DatabaseSettings.MYSQL_TABLE);
|
||||||
|
// this.col = new Columns(settings);
|
||||||
|
// this.con = connection;
|
||||||
|
// this.columnsHandler = AuthMeColumnsHandler.createForSqlite(con, settings);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * Initializes the connection to the H2 database.
|
||||||
|
// *
|
||||||
|
// * @throws SQLException when an SQL error occurs while connecting
|
||||||
|
// */
|
||||||
|
// protected void connect() throws SQLException {
|
||||||
|
// try {
|
||||||
|
// Class.forName("org.h2.Driver");
|
||||||
|
// } catch (ClassNotFoundException e) {
|
||||||
|
// throw new IllegalStateException("Failed to load H2 JDBC class", e);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// logger.debug("H2 driver loaded");
|
||||||
|
// this.con = DriverManager.getConnection(this.getJdbcUrl(this.dataFolder.getAbsolutePath(), "", this.database));
|
||||||
|
// this.columnsHandler = AuthMeColumnsHandler.createForSqlite(con, settings);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * Creates the table if necessary, or adds any missing columns to the table.
|
||||||
|
// *
|
||||||
|
// * @throws SQLException when an SQL error occurs while initializing the database
|
||||||
|
// */
|
||||||
|
// @VisibleForTesting
|
||||||
|
// @SuppressWarnings("checkstyle:CyclomaticComplexity")
|
||||||
|
// protected void setup() throws SQLException {
|
||||||
|
// try (Statement st = con.createStatement()) {
|
||||||
|
// // Note: cannot add unique fields later on in SQLite, so we add it on initialization
|
||||||
|
// st.executeUpdate("CREATE TABLE IF NOT EXISTS " + tableName + " ("
|
||||||
|
// + col.ID + " INTEGER AUTO_INCREMENT, "
|
||||||
|
// + col.NAME + " VARCHAR(255) NOT NULL UNIQUE, "
|
||||||
|
// + "CONSTRAINT table_const_prim PRIMARY KEY (" + col.ID + "));");
|
||||||
|
//
|
||||||
|
// DatabaseMetaData md = con.getMetaData();
|
||||||
|
//
|
||||||
|
// if (isColumnMissing(md, col.REAL_NAME)) {
|
||||||
|
// st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN "
|
||||||
|
// + col.REAL_NAME + " VARCHAR(255) NOT NULL DEFAULT 'Player';");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (isColumnMissing(md, col.PASSWORD)) {
|
||||||
|
// st.executeUpdate("ALTER TABLE " + tableName
|
||||||
|
// + " ADD COLUMN " + col.PASSWORD + " VARCHAR(255) NOT NULL DEFAULT '';");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (!col.SALT.isEmpty() && isColumnMissing(md, col.SALT)) {
|
||||||
|
// st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + col.SALT + " VARCHAR(255);");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (isColumnMissing(md, col.LAST_IP)) {
|
||||||
|
// st.executeUpdate("ALTER TABLE " + tableName
|
||||||
|
// + " ADD COLUMN " + col.LAST_IP + " VARCHAR(40);");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (isColumnMissing(md, col.LAST_LOGIN)) {
|
||||||
|
// st.executeUpdate("ALTER TABLE " + tableName
|
||||||
|
// + " ADD COLUMN " + col.LAST_LOGIN + " TIMESTAMP;");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (isColumnMissing(md, col.REGISTRATION_IP)) {
|
||||||
|
// st.executeUpdate("ALTER TABLE " + tableName
|
||||||
|
// + " ADD COLUMN " + col.REGISTRATION_IP + " VARCHAR(40);");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (isColumnMissing(md, col.REGISTRATION_DATE)) {
|
||||||
|
// addRegistrationDateColumn(st);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (isColumnMissing(md, col.LASTLOC_X)) {
|
||||||
|
// st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + col.LASTLOC_X
|
||||||
|
// + " DOUBLE NOT NULL DEFAULT '0.0';");
|
||||||
|
// st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + col.LASTLOC_Y
|
||||||
|
// + " DOUBLE NOT NULL DEFAULT '0.0';");
|
||||||
|
// st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + col.LASTLOC_Z
|
||||||
|
// + " DOUBLE NOT NULL DEFAULT '0.0';");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (isColumnMissing(md, col.LASTLOC_WORLD)) {
|
||||||
|
// st.executeUpdate("ALTER TABLE " + tableName
|
||||||
|
// + " ADD COLUMN " + col.LASTLOC_WORLD + " VARCHAR(255) NOT NULL DEFAULT 'world';");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (isColumnMissing(md, col.LASTLOC_YAW)) {
|
||||||
|
// st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN "
|
||||||
|
// + col.LASTLOC_YAW + " FLOAT;");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (isColumnMissing(md, col.LASTLOC_PITCH)) {
|
||||||
|
// st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN "
|
||||||
|
// + col.LASTLOC_PITCH + " FLOAT;");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (isColumnMissing(md, col.EMAIL)) {
|
||||||
|
// st.executeUpdate("ALTER TABLE " + tableName
|
||||||
|
// + " ADD COLUMN " + col.EMAIL + " VARCHAR(255);");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (isColumnMissing(md, col.IS_LOGGED)) {
|
||||||
|
// st.executeUpdate("ALTER TABLE " + tableName
|
||||||
|
// + " ADD COLUMN " + col.IS_LOGGED + " INT NOT NULL DEFAULT '0';");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (isColumnMissing(md, col.HAS_SESSION)) {
|
||||||
|
// st.executeUpdate("ALTER TABLE " + tableName
|
||||||
|
// + " ADD COLUMN " + col.HAS_SESSION + " INT NOT NULL DEFAULT '0';");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (isColumnMissing(md, col.TOTP_KEY)) {
|
||||||
|
// st.executeUpdate("ALTER TABLE " + tableName
|
||||||
|
// + " ADD COLUMN " + col.TOTP_KEY + " VARCHAR(32);");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (!col.PLAYER_UUID.isEmpty() && isColumnMissing(md, col.PLAYER_UUID)) {
|
||||||
|
// st.executeUpdate("ALTER TABLE " + tableName
|
||||||
|
// + " ADD COLUMN " + col.PLAYER_UUID + " VARCHAR(36)");
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// logger.info("H2 Setup finished");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// private boolean isColumnMissing(DatabaseMetaData metaData, String columnName) throws SQLException {
|
||||||
|
// try (ResultSet rs = metaData.getColumns(null, null, tableName, columnName)) {
|
||||||
|
// return !rs.next();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public void reload() {
|
||||||
|
// close(con);
|
||||||
|
// try {
|
||||||
|
// this.connect();
|
||||||
|
// this.setup();
|
||||||
|
// } catch (SQLException ex) {
|
||||||
|
// logger.logException("Error while reloading H2:", ex);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public PlayerAuth getAuth(String user) {
|
||||||
|
// 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()) {
|
||||||
|
// if (rs.next()) {
|
||||||
|
// return buildAuthFromResultSet(rs);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// } catch (SQLException ex) {
|
||||||
|
// logSqlException(ex);
|
||||||
|
// }
|
||||||
|
// return null;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public Set<String> getRecordsToPurge(long until) {
|
||||||
|
// Set<String> list = new HashSet<>();
|
||||||
|
// String select = "SELECT " + col.NAME + " FROM " + tableName + " WHERE MAX("
|
||||||
|
// + " COALESCE(" + col.LAST_LOGIN + ", 0),"
|
||||||
|
// + " COALESCE(" + col.REGISTRATION_DATE + ", 0)"
|
||||||
|
// + ") < ?;";
|
||||||
|
// try (PreparedStatement selectPst = con.prepareStatement(select)) {
|
||||||
|
// selectPst.setLong(1, until);
|
||||||
|
// try (ResultSet rs = selectPst.executeQuery()) {
|
||||||
|
// while (rs.next()) {
|
||||||
|
// list.add(rs.getString(col.NAME));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// } catch (SQLException ex) {
|
||||||
|
// logSqlException(ex);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return list;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public void purgeRecords(Collection<String> toPurge) {
|
||||||
|
// String delete = "DELETE FROM " + tableName + " WHERE " + col.NAME + "=?;";
|
||||||
|
// try (PreparedStatement deletePst = con.prepareStatement(delete)) {
|
||||||
|
// for (String name : toPurge) {
|
||||||
|
// deletePst.setString(1, name.toLowerCase(Locale.ROOT));
|
||||||
|
// deletePst.executeUpdate();
|
||||||
|
// }
|
||||||
|
// } catch (SQLException ex) {
|
||||||
|
// logSqlException(ex);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public boolean removeAuth(String user) {
|
||||||
|
// String sql = "DELETE FROM " + tableName + " WHERE " + col.NAME + "=?;";
|
||||||
|
// try (PreparedStatement pst = con.prepareStatement(sql)) {
|
||||||
|
// pst.setString(1, user.toLowerCase(Locale.ROOT));
|
||||||
|
// pst.executeUpdate();
|
||||||
|
// return true;
|
||||||
|
// } catch (SQLException ex) {
|
||||||
|
// logSqlException(ex);
|
||||||
|
// }
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public void closeConnection() {
|
||||||
|
// try {
|
||||||
|
// if (con != null && !con.isClosed()) {
|
||||||
|
// con.close();
|
||||||
|
// }
|
||||||
|
// } catch (SQLException ex) {
|
||||||
|
// logSqlException(ex);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public DataSourceType getType() {
|
||||||
|
// return DataSourceType.H2;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public List<PlayerAuth> getAllAuths() {
|
||||||
|
// List<PlayerAuth> auths = new ArrayList<>();
|
||||||
|
// String sql = "SELECT * FROM " + tableName + ";";
|
||||||
|
// try (PreparedStatement pst = con.prepareStatement(sql); ResultSet rs = pst.executeQuery()) {
|
||||||
|
// while (rs.next()) {
|
||||||
|
// PlayerAuth auth = buildAuthFromResultSet(rs);
|
||||||
|
// auths.add(auth);
|
||||||
|
// }
|
||||||
|
// } catch (SQLException ex) {
|
||||||
|
// logSqlException(ex);
|
||||||
|
// }
|
||||||
|
// return auths;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public List<String> getLoggedPlayersWithEmptyMail() {
|
||||||
|
// List<String> players = new ArrayList<>();
|
||||||
|
// 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)) {
|
||||||
|
// while (rs.next()) {
|
||||||
|
// players.add(rs.getString(1));
|
||||||
|
// }
|
||||||
|
// } catch (SQLException ex) {
|
||||||
|
// logSqlException(ex);
|
||||||
|
// }
|
||||||
|
// return players;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public List<PlayerAuth> getRecentlyLoggedInPlayers() {
|
||||||
|
// List<PlayerAuth> players = new ArrayList<>();
|
||||||
|
// 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()) {
|
||||||
|
// players.add(buildAuthFromResultSet(rs));
|
||||||
|
// }
|
||||||
|
// } catch (SQLException e) {
|
||||||
|
// logSqlException(e);
|
||||||
|
// }
|
||||||
|
// return players;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public boolean setTotpKey(String user, String totpKey) {
|
||||||
|
// 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));
|
||||||
|
// pst.executeUpdate();
|
||||||
|
// return true;
|
||||||
|
// } catch (SQLException e) {
|
||||||
|
// logSqlException(e);
|
||||||
|
// }
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// private PlayerAuth buildAuthFromResultSet(ResultSet row) throws SQLException {
|
||||||
|
// String salt = !col.SALT.isEmpty() ? row.getString(col.SALT) : null;
|
||||||
|
//
|
||||||
|
// return PlayerAuth.builder()
|
||||||
|
// .name(row.getString(col.NAME))
|
||||||
|
// .email(row.getString(col.EMAIL))
|
||||||
|
// .realName(row.getString(col.REAL_NAME))
|
||||||
|
// .password(row.getString(col.PASSWORD), salt)
|
||||||
|
// .totpKey(row.getString(col.TOTP_KEY))
|
||||||
|
// .lastLogin(getNullableLong(row, col.LAST_LOGIN))
|
||||||
|
// .lastIp(row.getString(col.LAST_IP))
|
||||||
|
// .registrationDate(row.getLong(col.REGISTRATION_DATE))
|
||||||
|
// .registrationIp(row.getString(col.REGISTRATION_IP))
|
||||||
|
// .locX(row.getDouble(col.LASTLOC_X))
|
||||||
|
// .locY(row.getDouble(col.LASTLOC_Y))
|
||||||
|
// .locZ(row.getDouble(col.LASTLOC_Z))
|
||||||
|
// .locWorld(row.getString(col.LASTLOC_WORLD))
|
||||||
|
// .locYaw(row.getFloat(col.LASTLOC_YAW))
|
||||||
|
// .locPitch(row.getFloat(col.LASTLOC_PITCH))
|
||||||
|
// .build();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * Creates the column for registration date and sets all entries to the current timestamp.
|
||||||
|
// * We do so in order to avoid issues with purging, where entries with 0 / NULL might get
|
||||||
|
// * purged immediately on startup otherwise.
|
||||||
|
// *
|
||||||
|
// * @param st Statement object to the database
|
||||||
|
// */
|
||||||
|
// private void addRegistrationDateColumn(Statement st) throws SQLException {
|
||||||
|
// st.executeUpdate("ALTER TABLE " + tableName
|
||||||
|
// + " ADD COLUMN " + col.REGISTRATION_DATE + " TIMESTAMP NOT NULL DEFAULT '0';");
|
||||||
|
//
|
||||||
|
// // 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;",
|
||||||
|
// tableName, col.REGISTRATION_DATE, currentTimestamp));
|
||||||
|
// logger.info("Created column '" + col.REGISTRATION_DATE + "' and set the current timestamp, "
|
||||||
|
// + currentTimestamp + ", to all " + updatedRows + " rows");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// String getJdbcUrl(String dataPath, String ignored, String database) {
|
||||||
|
// return "jdbc:h2:" + dataPath + File.separator + database + ".db";
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// private static void close(Connection con) {
|
||||||
|
// if (con != null) {
|
||||||
|
// try {
|
||||||
|
// con.close();
|
||||||
|
// } catch (SQLException ex) {
|
||||||
|
// logSqlException(ex);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
//
|
||||||
@@ -76,6 +76,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:
|
||||||
|
// dataSource = new H2(settings, dataFolder);
|
||||||
|
// break;
|
||||||
default:
|
default:
|
||||||
throw new UnsupportedOperationException("Unknown data source type '" + dataSourceType + "'");
|
throw new UnsupportedOperationException("Unknown data source type '" + dataSourceType + "'");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import fr.xephi.authme.api.v3.AuthMeApi;
|
|||||||
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;
|
||||||
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.settings.properties.HooksSettings;
|
import fr.xephi.authme.settings.properties.HooksSettings;
|
||||||
import fr.xephi.authme.settings.properties.SecuritySettings;
|
import fr.xephi.authme.settings.properties.SecuritySettings;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@@ -28,15 +29,17 @@ public class BedrockAutoLoginListener implements Listener {
|
|||||||
@Inject
|
@Inject
|
||||||
private Messages messages;
|
private Messages messages;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private Settings settings;
|
||||||
|
|
||||||
public BedrockAutoLoginListener() {
|
public BedrockAutoLoginListener() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isBedrockPlayer(UUID uuid) {
|
private boolean isBedrockPlayer(UUID uuid) {
|
||||||
return AuthMe.settings.getProperty(HooksSettings.HOOK_FLOODGATE_PLAYER) && AuthMe.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.HIGHEST)
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
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();
|
||||||
@@ -46,15 +49,4 @@ public class BedrockAutoLoginListener implements Listener {
|
|||||||
messages.send(player, MessageKey.BEDROCK_AUTO_LOGGED_IN);
|
messages.send(player, MessageKey.BEDROCK_AUTO_LOGGED_IN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* prevent sending duplicate messages */
|
|
||||||
// @EventHandler(priority = EventPriority.HIGHEST)
|
|
||||||
// public void onPlayerRestoreSession(RestoreSessionEvent event) {
|
|
||||||
// Player player = event.getPlayer();
|
|
||||||
// String name = event.getPlayer().getName();
|
|
||||||
// UUID uuid = event.getPlayer().getUniqueId();
|
|
||||||
// if (isBedrockPlayer(uuid) && !authmeApi.isAuthenticated(player) && authmeApi.isRegistered(name)) {
|
|
||||||
// event.setCancelled(true);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ 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;
|
||||||
import fr.xephi.authme.service.CommonService;
|
import fr.xephi.authme.service.CommonService;
|
||||||
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.settings.properties.HooksSettings;
|
import fr.xephi.authme.settings.properties.HooksSettings;
|
||||||
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;
|
||||||
@@ -29,12 +30,14 @@ import org.bukkit.inventory.meta.ItemMeta;
|
|||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import static fr.xephi.authme.util.PlayerUtils.getPlayerIp;
|
||||||
import static fr.xephi.authme.util.PlayerUtils.isNpc;
|
import static fr.xephi.authme.util.PlayerUtils.isNpc;
|
||||||
import static org.bukkit.Bukkit.getLogger;
|
import static org.bukkit.Bukkit.getLogger;
|
||||||
import static org.bukkit.Bukkit.getServer;
|
import static org.bukkit.Bukkit.getServer;
|
||||||
@@ -51,34 +54,46 @@ public class GuiCaptchaHandler implements Listener {
|
|||||||
@Inject
|
@Inject
|
||||||
private CommonService service;
|
private CommonService service;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private Settings settings;
|
||||||
|
|
||||||
|
|
||||||
private PacketAdapter chatPacketListener;
|
private PacketAdapter chatPacketListener;
|
||||||
private PacketAdapter windowPacketListener;
|
private PacketAdapter windowPacketListener;
|
||||||
|
|
||||||
//define timesLeft
|
//define timesLeft
|
||||||
private int timesLeft = 3;
|
private int timesLeft = 3;
|
||||||
//Use ConcurrentHashMap to store player and their close reason
|
//Use ConcurrentHashMap to store player and their close reason
|
||||||
/* We used many async tasks so there is concurrent**/
|
/* We used many async tasks so there is concurrent**/
|
||||||
public static ConcurrentHashMap<Player, String> closeReasonMap = new ConcurrentHashMap<>();
|
public static HashMap<Player, String> closeReasonMap = new HashMap<>();
|
||||||
//define randomStringSet
|
//define randomStringSet
|
||||||
String randomSet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz!@#%&*()_+";
|
String randomSet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz!@#%&*()_+";
|
||||||
String randomString = "";
|
String randomString = "";
|
||||||
Random randomItemSet = new Random();
|
Random randomItemSet = new Random();
|
||||||
Random howManyRandom = new Random();
|
Random howManyRandom = new Random();
|
||||||
|
private boolean isPacketListenersActive = false;
|
||||||
|
|
||||||
|
int howLongIsRandomString;
|
||||||
int howLongIsRandomString = (howManyRandom.nextInt(3) + 1);
|
|
||||||
|
|
||||||
public GuiCaptchaHandler() {
|
public GuiCaptchaHandler() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected List<String> whiteList = AuthMe.settings.getProperty(SecuritySettings.GUI_CAPTCHA_COUNTRY_WHITELIST);
|
||||||
|
|
||||||
private boolean isBedrockPlayer(UUID uuid) {
|
private boolean isBedrockPlayer(UUID uuid) {
|
||||||
return AuthMe.settings.getProperty(HooksSettings.HOOK_FLOODGATE_PLAYER) && AuthMe.settings.getProperty(SecuritySettings.GUI_CAPTCHA_BE_COMPATIBILITY) && org.geysermc.floodgate.api.FloodgateApi.getInstance().isFloodgateId(uuid) && getServer().getPluginManager().getPlugin("floodgate") != null;
|
return settings.getProperty(HooksSettings.HOOK_FLOODGATE_PLAYER) && settings.getProperty(SecuritySettings.GUI_CAPTCHA_BE_COMPATIBILITY) && org.geysermc.floodgate.api.FloodgateApi.getInstance().isFloodgateId(uuid) && getServer().getPluginManager().getPlugin("floodgate") != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removePacketListeners() {
|
|
||||||
ProtocolLibrary.getProtocolManager().removePacketListener(windowPacketListener);
|
private void addPacketListeners() {
|
||||||
ProtocolLibrary.getProtocolManager().removePacketListener(chatPacketListener);
|
if (!isPacketListenersActive) {
|
||||||
|
ProtocolLibrary.getProtocolManager().addPacketListener(windowPacketListener);
|
||||||
|
ProtocolLibrary.getProtocolManager().addPacketListener(chatPacketListener);
|
||||||
|
isPacketListenersActive = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onInventoryClick(InventoryClickEvent event) {
|
public void onInventoryClick(InventoryClickEvent event) {
|
||||||
if (event.getWhoClicked() instanceof Player) {
|
if (event.getWhoClicked() instanceof Player) {
|
||||||
@@ -104,6 +119,12 @@ public class GuiCaptchaHandler implements Listener {
|
|||||||
Player playerunreg = event.getPlayer();
|
Player playerunreg = event.getPlayer();
|
||||||
String name = playerunreg.getName();
|
String name = playerunreg.getName();
|
||||||
if (!authmeApi.isRegistered(name) && !isNpc(playerunreg)) {
|
if (!authmeApi.isRegistered(name) && !isNpc(playerunreg)) {
|
||||||
|
if (!whiteList.isEmpty()) {
|
||||||
|
String ip = getPlayerIp(playerunreg);
|
||||||
|
if (whiteList.contains(authmeApi.getCountryCode(ip)) && ip != null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (isBedrockPlayer(playerunreg.getUniqueId())) {
|
if (isBedrockPlayer(playerunreg.getUniqueId())) {
|
||||||
closeReasonMap.put(playerunreg, "verified");
|
closeReasonMap.put(playerunreg, "verified");
|
||||||
messages.send(playerunreg, MessageKey.GUI_CAPTCHA_VERIFIED_AUTO_BEDROCK);
|
messages.send(playerunreg, MessageKey.GUI_CAPTCHA_VERIFIED_AUTO_BEDROCK);
|
||||||
@@ -122,7 +143,6 @@ public class GuiCaptchaHandler implements Listener {
|
|||||||
// 将字符追加到字符串生成器
|
// 将字符追加到字符串生成器
|
||||||
sb.append(randomChar);
|
sb.append(randomChar);
|
||||||
}
|
}
|
||||||
|
|
||||||
bukkitService.runTask(() -> {
|
bukkitService.runTask(() -> {
|
||||||
randomString = sb.toString();
|
randomString = sb.toString();
|
||||||
Random random_blockpos = new Random();
|
Random random_blockpos = new Random();
|
||||||
@@ -138,16 +158,57 @@ public class GuiCaptchaHandler implements Listener {
|
|||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
getLogger().log(Level.WARNING, "Unexpected error occurred while setting item meta.");
|
getLogger().log(Level.WARNING, "Unexpected error occurred while setting item meta.");
|
||||||
}
|
}
|
||||||
|
windowPacketListener = new PacketAdapter(this.plugin, ListenerPriority.HIGHEST, PacketType.Play.Client.CLOSE_WINDOW) {
|
||||||
|
@Override
|
||||||
|
public void onPacketReceiving(PacketEvent event) {
|
||||||
|
if (!closeReasonMap.containsKey(playerunreg) && !authmeApi.isRegistered(playerunreg.getName())) {
|
||||||
|
if (timesLeft <= 0) {
|
||||||
|
bukkitService.runTask(() -> {
|
||||||
|
playerunreg.kickPlayer(service.retrieveSingleMessage(playerunreg, MessageKey.GUI_CAPTCHA_KICK_FAILED));
|
||||||
|
});
|
||||||
|
timesLeft = 3;
|
||||||
|
} else {
|
||||||
|
--timesLeft;
|
||||||
|
if (timesLeft <= 0) {
|
||||||
|
bukkitService.runTask(() -> {
|
||||||
|
playerunreg.kickPlayer(service.retrieveSingleMessage(playerunreg, MessageKey.GUI_CAPTCHA_KICK_FAILED));
|
||||||
|
});
|
||||||
|
timesLeft = 3;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
messages.send(playerunreg, 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);
|
||||||
|
playerunreg.openInventory(menu);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
chatPacketListener = new PacketAdapter(this.plugin, ListenerPriority.HIGHEST, PacketType.Play.Client.CHAT) {
|
||||||
|
@Override
|
||||||
|
public void onPacketReceiving(PacketEvent event) {
|
||||||
|
if (!closeReasonMap.containsKey(playerunreg) && !authmeApi.isRegistered(playerunreg.getName())) {
|
||||||
|
messages.send(playerunreg, MessageKey.GUI_CAPTCHA_DENIED_MESSAGE);
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
addPacketListeners();
|
||||||
|
//Open captcha inventory
|
||||||
menu.setItem(random_num.get(), item);
|
menu.setItem(random_num.get(), item);
|
||||||
playerunreg.openInventory(menu);
|
playerunreg.openInventory(menu);
|
||||||
if (AuthMe.settings.getProperty(SecuritySettings.GUI_CAPTCHA_TIMEOUT) > 0) {
|
if (settings.getProperty(SecuritySettings.GUI_CAPTCHA_TIMEOUT) > 0) {
|
||||||
long timeOut = AuthMe.settings.getProperty(SecuritySettings.GUI_CAPTCHA_TIMEOUT);
|
long timeOut = settings.getProperty(SecuritySettings.GUI_CAPTCHA_TIMEOUT);
|
||||||
if (AuthMe.settings.getProperty(SecuritySettings.GUI_CAPTCHA_TIMEOUT) > AuthMe.settings.getProperty(RestrictionSettings.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(" + AuthMe.settings.getProperty(SecuritySettings.GUI_CAPTCHA_TIMEOUT) + ") is bigger than the Login timeout seconds(" +
|
getLogger().warning("AuthMe detected that your GUI captcha timeout seconds(" + settings.getProperty(SecuritySettings.GUI_CAPTCHA_TIMEOUT) + ") is bigger than the Login timeout seconds(" +
|
||||||
AuthMe.settings.getProperty(RestrictionSettings.TIMEOUT) + "). To prevent issues, we will let the GUI captcha follow the Login timeout seconds, please check and modify your config.");
|
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 = AuthMe.settings.getProperty(RestrictionSettings.TIMEOUT);
|
timeOut = settings.getProperty(RestrictionSettings.TIMEOUT);
|
||||||
}
|
}
|
||||||
long finalTimeOut = timeOut;
|
long finalTimeOut = timeOut;
|
||||||
bukkitService.runTask(() -> {
|
bukkitService.runTask(() -> {
|
||||||
@@ -159,61 +220,16 @@ public class GuiCaptchaHandler implements Listener {
|
|||||||
}, finalTimeOut * 20L);
|
}, finalTimeOut * 20L);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
bukkitService.runTask(() -> {
|
|
||||||
windowPacketListener = new PacketAdapter(this.plugin, ListenerPriority.HIGHEST, PacketType.Play.Client.CLOSE_WINDOW) {
|
|
||||||
@Override
|
|
||||||
public void onPacketReceiving(PacketEvent event) {
|
|
||||||
if (event.getPlayer() == playerunreg && !closeReasonMap.containsKey(playerunreg) && !authmeApi.isRegistered(playerunreg.getName())) {
|
|
||||||
if (timesLeft <= 0) {
|
|
||||||
bukkitService.runTask(() -> {
|
|
||||||
playerunreg.kickPlayer(service.retrieveSingleMessage(playerunreg, MessageKey.GUI_CAPTCHA_KICK_FAILED));
|
|
||||||
});
|
|
||||||
timesLeft = 3;
|
|
||||||
} else {
|
|
||||||
--timesLeft;
|
|
||||||
if (timesLeft <= 0) {
|
|
||||||
bukkitService.runTask(() -> {
|
|
||||||
playerunreg.kickPlayer(service.retrieveSingleMessage(playerunreg, MessageKey.GUI_CAPTCHA_KICK_FAILED));
|
|
||||||
});
|
|
||||||
timesLeft = 3;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
messages.send(playerunreg, 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);
|
|
||||||
playerunreg.openInventory(menu);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
ProtocolLibrary.getProtocolManager().addPacketListener(windowPacketListener);
|
|
||||||
});
|
|
||||||
bukkitService.runTask(() -> {
|
|
||||||
chatPacketListener = new PacketAdapter(this.plugin, ListenerPriority.HIGHEST, PacketType.Play.Client.CHAT) {
|
|
||||||
@Override
|
|
||||||
public void onPacketReceiving(PacketEvent event) {
|
|
||||||
if (event.getPlayer() == playerunreg && !closeReasonMap.containsKey(playerunreg) && !authmeApi.isRegistered(playerunreg.getName())) {
|
|
||||||
messages.send(playerunreg, MessageKey.GUI_CAPTCHA_DENIED_MESSAGE);
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
ProtocolLibrary.getProtocolManager().addPacketListener(chatPacketListener);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void deletePlayerData(UUID playerUUID) {
|
private void deletePlayerData(UUID playerUUID) {
|
||||||
// 获取服务器的存储文件夹路径
|
// 获取服务器的存储文件夹路径
|
||||||
File serverFolder = Bukkit.getServer().getWorldContainer();
|
File serverFolder = Bukkit.getServer().getWorldContainer();
|
||||||
String worldFolderName = AuthMe.settings.getProperty(SecuritySettings.DELETE_PLAYER_DATA_WORLD);
|
String worldFolderName = settings.getProperty(SecuritySettings.DELETE_PLAYER_DATA_WORLD);
|
||||||
// 构建playerdata文件夹路径
|
// 构建playerdata文件夹路径
|
||||||
File playerDataFolder = new File(serverFolder, File.separator + worldFolderName + File.separator + "playerdata");
|
File playerDataFolder = new File(serverFolder, File.separator + worldFolderName + File.separator + "playerdata");
|
||||||
|
|
||||||
@@ -228,7 +244,7 @@ public class GuiCaptchaHandler implements Listener {
|
|||||||
private void deletePlayerStats(UUID playerUUID) {
|
private void deletePlayerStats(UUID playerUUID) {
|
||||||
// 获取服务器的存储文件夹路径
|
// 获取服务器的存储文件夹路径
|
||||||
File serverFolder = Bukkit.getServer().getWorldContainer();
|
File serverFolder = Bukkit.getServer().getWorldContainer();
|
||||||
String worldFolderName = AuthMe.settings.getProperty(SecuritySettings.DELETE_PLAYER_DATA_WORLD);
|
String worldFolderName = settings.getProperty(SecuritySettings.DELETE_PLAYER_DATA_WORLD);
|
||||||
// 构建stats文件夹路径
|
// 构建stats文件夹路径
|
||||||
File statsFolder = new File(serverFolder, File.separator + worldFolderName + File.separator + "stats");
|
File statsFolder = new File(serverFolder, File.separator + worldFolderName + File.separator + "stats");
|
||||||
// 构建玩家统计数据文件路径
|
// 构建玩家统计数据文件路径
|
||||||
@@ -255,8 +271,7 @@ public class GuiCaptchaHandler implements Listener {
|
|||||||
String name = player.getName();
|
String name = player.getName();
|
||||||
UUID playerUUID = event.getPlayer().getUniqueId();
|
UUID playerUUID = event.getPlayer().getUniqueId();
|
||||||
if (!authmeApi.isRegistered(name)) {
|
if (!authmeApi.isRegistered(name)) {
|
||||||
if (AuthMe.settings.getProperty(SecuritySettings.DELETE_UNVERIFIED_PLAYER_DATA) && !closeReasonMap.containsKey(player)) {
|
if (settings.getProperty(SecuritySettings.DELETE_UNVERIFIED_PLAYER_DATA) && !closeReasonMap.containsKey(player)) {
|
||||||
closeReasonMap.remove(player);
|
|
||||||
bukkitService.runTaskLater(() -> {
|
bukkitService.runTaskLater(() -> {
|
||||||
if (!player.isOnline()) {
|
if (!player.isOnline()) {
|
||||||
deletePlayerData(playerUUID);
|
deletePlayerData(playerUUID);
|
||||||
@@ -264,10 +279,8 @@ public class GuiCaptchaHandler implements Listener {
|
|||||||
deleteAuthMePlayerData(playerUUID);
|
deleteAuthMePlayerData(playerUUID);
|
||||||
}
|
}
|
||||||
}, 100L);
|
}, 100L);
|
||||||
removePacketListeners();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
removePacketListeners();
|
|
||||||
closeReasonMap.remove(player);
|
closeReasonMap.remove(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,7 @@
|
|||||||
package fr.xephi.authme.listener;
|
package fr.xephi.authme.listener;
|
||||||
|
|
||||||
import fr.xephi.authme.data.QuickCommandsProtectionManager;
|
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
|
||||||
import fr.xephi.authme.message.Messages;
|
|
||||||
import fr.xephi.authme.permission.PermissionsManager;
|
|
||||||
import fr.xephi.authme.process.Management;
|
|
||||||
import fr.xephi.authme.service.AntiBotService;
|
|
||||||
import fr.xephi.authme.service.BukkitService;
|
|
||||||
import fr.xephi.authme.service.JoinMessageService;
|
|
||||||
import fr.xephi.authme.service.TeleportationService;
|
|
||||||
import fr.xephi.authme.service.ValidationService;
|
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.settings.SpawnLoader;
|
import fr.xephi.authme.settings.properties.PluginSettings;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@@ -26,18 +16,26 @@ public class PlayerListenerHigherThan18 implements Listener {
|
|||||||
@Inject
|
@Inject
|
||||||
private ListenerService listenerService;
|
private ListenerService listenerService;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private Settings settings;
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||||
public void onPlayerPickupItem(EntityPickupItemEvent event) {
|
public void onPlayerPickupItem(EntityPickupItemEvent event) {
|
||||||
if (listenerService.shouldCancelEvent(event)) {
|
if (listenerService.shouldCancelEvent(event)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
public void onSwitchHand(PlayerSwapHandItemsEvent event) {
|
public void onSwitchHand(PlayerSwapHandItemsEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if (!player.isSneaking() || !player.hasPermission("keybindings.use"))
|
if ((!player.isSneaking() || !player.hasPermission("keybindings.use")) &&
|
||||||
|
settings.getProperty(PluginSettings.MENU_UNREGISTER_COMPATIBILITY)) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
Bukkit.dispatchCommand(event.getPlayer(), "help");
|
if (settings.getProperty(PluginSettings.MENU_UNREGISTER_COMPATIBILITY)) {
|
||||||
|
Bukkit.dispatchCommand(event.getPlayer(), "help");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,13 @@ import fr.xephi.authme.output.LogLevel;
|
|||||||
import static ch.jalu.configme.properties.PropertyInitializer.newProperty;
|
import static ch.jalu.configme.properties.PropertyInitializer.newProperty;
|
||||||
|
|
||||||
public final class PluginSettings implements SettingsHolder {
|
public final class PluginSettings implements SettingsHolder {
|
||||||
|
@Comment({
|
||||||
|
"Should we execute /help command when unregistered players press Shift+F?",
|
||||||
|
"This keeps compatibility with some menu plugins",
|
||||||
|
"If you are using TrMenu, don't enable this because TrMenu already implemented this."
|
||||||
|
})
|
||||||
|
public static final Property<Boolean> MENU_UNREGISTER_COMPATIBILITY =
|
||||||
|
newProperty("3rdPartyFeature.compatibility.menuPlugins", true);
|
||||||
|
|
||||||
@Comment({
|
@Comment({
|
||||||
"Do you want to enable the session feature?",
|
"Do you want to enable the session feature?",
|
||||||
|
|||||||
@@ -6,8 +6,10 @@ import ch.jalu.configme.properties.Property;
|
|||||||
import fr.xephi.authme.security.HashAlgorithm;
|
import fr.xephi.authme.security.HashAlgorithm;
|
||||||
import fr.xephi.authme.settings.EnumSetProperty;
|
import fr.xephi.authme.settings.EnumSetProperty;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static ch.jalu.configme.properties.PropertyInitializer.newListProperty;
|
||||||
import static ch.jalu.configme.properties.PropertyInitializer.newLowercaseStringSetProperty;
|
import static ch.jalu.configme.properties.PropertyInitializer.newLowercaseStringSetProperty;
|
||||||
import static ch.jalu.configme.properties.PropertyInitializer.newProperty;
|
import static ch.jalu.configme.properties.PropertyInitializer.newProperty;
|
||||||
|
|
||||||
@@ -19,6 +21,11 @@ public final class SecuritySettings implements SettingsHolder {
|
|||||||
public static final Property<Boolean> STOP_SERVER_ON_PROBLEM =
|
public static final Property<Boolean> STOP_SERVER_ON_PROBLEM =
|
||||||
newProperty("Security.SQLProblem.stopServer", false);
|
newProperty("Security.SQLProblem.stopServer", false);
|
||||||
|
|
||||||
|
@Comment({"Should send GUI captcha by country code whitelist?",
|
||||||
|
"If the country of the player is in this list, the captcha won't be sent."})
|
||||||
|
public static final Property<List<String>> GUI_CAPTCHA_COUNTRY_WHITELIST =
|
||||||
|
newListProperty("3rdPartyFeature.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)"})
|
||||||
public static final Property<Boolean> FORCE_LOGIN_BEDROCK = newProperty("3rdPartyFeature.features.bedrockAutoLogin", false);
|
public static final Property<Boolean> FORCE_LOGIN_BEDROCK = newProperty("3rdPartyFeature.features.bedrockAutoLogin", false);
|
||||||
|
|||||||
@@ -5,22 +5,6 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
//
|
|
||||||
//public class TeleportUtils {
|
|
||||||
// public static void teleport(Player player, Location location) {
|
|
||||||
// try {
|
|
||||||
// Class<?> paperClass = Class.forName("com.destroystokyo.paper.PaperConfig");
|
|
||||||
// // Paper API is loaded, use teleportAsync
|
|
||||||
// Method teleportAsyncMethod = player.getClass().getMethod("teleportAsync", Location.class);
|
|
||||||
// teleportAsyncMethod.setAccessible(true);
|
|
||||||
// teleportAsyncMethod.invoke(player, location);
|
|
||||||
// } catch (ClassNotFoundException | InvocationTargetException | NoSuchMethodException | IllegalAccessException e) {
|
|
||||||
// // Paper API is not loaded, use normal teleport
|
|
||||||
// player.teleport(location);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
public class TeleportUtils {
|
public class TeleportUtils {
|
||||||
private static Method teleportAsyncMethod;
|
private static Method teleportAsyncMethod;
|
||||||
|
|
||||||
|
|||||||
@@ -103,7 +103,8 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<p style="color:#b0adc5;">© 2023 HomoCraft. All rights reserved.</p>
|
<p style="color:#b0adc5;">© 2023 HomoCraft. All rights reserved.</p>
|
||||||
<a href="1919810.com" target="_blank" style="text-decoration: none; font-size: 16px">homomc.cc</a>
|
<a href="1919810.com" target="_blank"
|
||||||
|
style="text-decoration: none; font-size: 16px">wdsj.io</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
@@ -109,7 +109,8 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<p style="color:#b0adc5;">© 2023 HomoCraft. All rights reserved.</p>
|
<p style="color:#b0adc5;">© 2023 HomoCraft. All rights reserved.</p>
|
||||||
<a href="1919810.com" target="_blank" style="text-decoration: none; font-size: 16px">homomc.cc</a>
|
<a href="1919810.com" target="_blank"
|
||||||
|
style="text-decoration: none; font-size: 16px">wdsj.io</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ 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-b32
|
version: 5.6.0-FORK-b34
|
||||||
api-version: 1.13
|
api-version: 1.13
|
||||||
softdepend:
|
softdepend:
|
||||||
- Vault
|
- Vault
|
||||||
|
|||||||
@@ -102,7 +102,8 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<p style="color:#b0adc5;">© 2023 HomoCraft. All rights reserved.</p>
|
<p style="color:#b0adc5;">© 2023 HomoCraft. All rights reserved.</p>
|
||||||
<a href="191980.com" target="_blank" style="text-decoration: none; font-size: 16px">homomc.cc</a>
|
<a href="1919810.com" target="_blank"
|
||||||
|
style="text-decoration: none; font-size: 16px">wdsj.io</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
@@ -100,7 +100,8 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<p style="color:#b0adc5;">© 2023 HomoCraft. All rights reserved.</p>
|
<p style="color:#b0adc5;">© 2023 HomoCraft. All rights reserved.</p>
|
||||||
<a href="1919810.com" target="_blank" style="text-decoration: none; font-size: 16px">homomc.cc</a>
|
<a href="1919810.com" target="_blank"
|
||||||
|
style="text-decoration: none; font-size: 16px">wdsj.io</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
@@ -102,7 +102,8 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<p style="color:#b0adc5;">© 2023 HomoCraft. All rights reserved.</p>
|
<p style="color:#b0adc5;">© 2023 HomoCraft. All rights reserved.</p>
|
||||||
<a href="1919810.com" target="_blank" style="text-decoration: none; font-size: 16px">homomc.cc</a>
|
<a href="1919810.com" target="_blank"
|
||||||
|
style="text-decoration: none; font-size: 16px">wdsj.io</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
Reference in New Issue
Block a user