diff --git a/bukkit/src/main/resources/plugin.yml b/bukkit/src/main/resources/plugin.yml index 92c91f94..29108a4e 100644 --- a/bukkit/src/main/resources/plugin.yml +++ b/bukkit/src/main/resources/plugin.yml @@ -11,17 +11,21 @@ description: | website: ${project.url} dev-url: ${project.url} -# Load the plugin as early as possible to inject it for all players -load: STARTUP - # This plugin don't have to be transformed for compatibility with Minecraft >= 1.13 -api-version: 1.13 +api-version: '1.13' softdepend: # We depend either ProtocolLib or ProtocolSupport - ProtocolSupport - ProtocolLib - PlaceholderAPI + # Auth plugins + - AuthMe + - LoginSecurity + - xAuth + - LogIt + - UltraAuth + - CrazyLogin commands: ${project.parent.name}: diff --git a/core/pom.xml b/core/pom.xml index 32616507..dcdd417a 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -22,11 +22,6 @@ false - - central - CentralRepository - https://repo1.maven.org/maven2/ - codemc-repo https://repo.codemc.io/repository/maven-public/ diff --git a/core/src/main/java/com/github/games647/fastlogin/core/AuthStorage.java b/core/src/main/java/com/github/games647/fastlogin/core/AuthStorage.java index f01e5655..7b02d23c 100644 --- a/core/src/main/java/com/github/games647/fastlogin/core/AuthStorage.java +++ b/core/src/main/java/com/github/games647/fastlogin/core/AuthStorage.java @@ -22,12 +22,13 @@ public class AuthStorage { private static final String PREMIUM_TABLE = "premium"; - private static final String LOAD_BY_NAME = "SELECT * FROM " + PREMIUM_TABLE + " WHERE Name=? LIMIT 1"; - private static final String LOAD_BY_UUID = "SELECT * FROM " + PREMIUM_TABLE + " WHERE UUID=? LIMIT 1"; - private static final String INSERT_PROFILE = "INSERT INTO " + PREMIUM_TABLE + " (UUID, Name, Premium, LastIp) " - + "VALUES (?, ?, ?, ?) "; - private static final String UPDATE_PROFILE = "UPDATE " + PREMIUM_TABLE - + " SET UUID=?, Name=?, Premium=?, LastIp=?, LastLogin=CURRENT_TIMESTAMP WHERE UserID=?"; + private static final String LOAD_BY_NAME = "SELECT * FROM `" + PREMIUM_TABLE + "` WHERE `Name`=? LIMIT 1"; + private static final String LOAD_BY_UUID = "SELECT * FROM `" + PREMIUM_TABLE + "` WHERE `UUID`=? LIMIT 1"; + private static final String INSERT_PROFILE = "INSERT INTO `" + PREMIUM_TABLE + + "` (`UUID`, `Name`, `Premium`, `LastIp`) " + "VALUES (?, ?, ?, ?) "; + // limit not necessary here, because it's unique + private static final String UPDATE_PROFILE = "UPDATE `" + PREMIUM_TABLE + + "` SET `UUID`=?, `Name`=?, `Premium`=?, `LastIp`=?, `LastLogin`=CURRENT_TIMESTAMP WHERE `UserID`=?"; private final FastLoginCore core; private final HikariDataSource dataSource; @@ -71,23 +72,24 @@ public class AuthStorage { } public void createTables() throws SQLException { + String createDataStmt = "CREATE TABLE IF NOT EXISTS `" + PREMIUM_TABLE + "` (" + + "`UserID` INTEGER PRIMARY KEY AUTO_INCREMENT, " + + "`UUID` CHAR(36), " + + "`Name` VARCHAR(16) NOT NULL, " + + "`Premium` BOOLEAN NOT NULL, " + + "`LastIp` VARCHAR(255) NOT NULL, " + + "`LastLogin` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, " + //the premium shouldn't steal the cracked account by changing the name + + "UNIQUE (`Name`) " + + ')'; + + if (dataSource.getJdbcUrl().contains("sqlite")) { + createDataStmt = createDataStmt.replace("AUTO_INCREMENT", "AUTOINCREMENT"); + } + + //todo: add uuid index usage try (Connection con = dataSource.getConnection(); Statement createStmt = con.createStatement()) { - String createDataStmt = "CREATE TABLE IF NOT EXISTS " + PREMIUM_TABLE + " (" - + "UserID INTEGER PRIMARY KEY AUTO_INCREMENT, " - + "UUID CHAR(36), " - + "Name VARCHAR(16) NOT NULL, " - + "Premium BOOLEAN NOT NULL, " - + "LastIp VARCHAR(255) NOT NULL, " - + "LastLogin TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, " - //the premium shouldn't steal the cracked account by changing the name - + "UNIQUE (Name) " - + ')'; - - if (dataSource.getJdbcUrl().contains("sqlite")) { - createDataStmt = createDataStmt.replace("AUTO_INCREMENT", "AUTOINCREMENT"); - } - createStmt.executeUpdate(createDataStmt); } }