Merge branch '5.5.0' of https://github.com/AuthMe/AuthMeReloaded
This commit is contained in:
@@ -59,49 +59,11 @@ final class MySqlMigrater {
|
||||
columnType = rs.getInt("DATA_TYPE");
|
||||
}
|
||||
|
||||
if (columnType == Types.TIMESTAMP) {
|
||||
migrateLastLoginColumnFromTimestamp(st, tableName, col);
|
||||
} else if (columnType == Types.INTEGER) {
|
||||
if (columnType == Types.INTEGER) {
|
||||
migrateLastLoginColumnFromInt(st, tableName, col);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs conversion of lastlogin column from timestamp type to bigint.
|
||||
*
|
||||
* @param st Statement object to the database
|
||||
* @param tableName the table name
|
||||
* @param col the column names configuration
|
||||
* @see <a href="https://github.com/AuthMe/AuthMeReloaded/issues/477">#477</a>
|
||||
*/
|
||||
private static void migrateLastLoginColumnFromTimestamp(Statement st, String tableName,
|
||||
Columns col) throws SQLException {
|
||||
ConsoleLogger.info("Migrating lastlogin column from timestamp to bigint");
|
||||
final String lastLoginOld = col.LAST_LOGIN + "_old";
|
||||
|
||||
// Rename lastlogin to lastlogin_old
|
||||
String sql = String.format("ALTER TABLE %s CHANGE COLUMN %s %s BIGINT",
|
||||
tableName, col.LAST_LOGIN, lastLoginOld);
|
||||
st.execute(sql);
|
||||
|
||||
// Create lastlogin column
|
||||
sql = String.format("ALTER TABLE %s ADD COLUMN %s "
|
||||
+ "BIGINT NOT NULL DEFAULT 0 AFTER %s",
|
||||
tableName, col.LAST_LOGIN, col.LAST_IP);
|
||||
st.execute(sql);
|
||||
|
||||
// Set values of lastlogin based on lastlogin_old
|
||||
sql = String.format("UPDATE %s SET %s = UNIX_TIMESTAMP(%s) * 1000",
|
||||
tableName, col.LAST_LOGIN, lastLoginOld);
|
||||
st.execute(sql);
|
||||
|
||||
// Drop lastlogin_old
|
||||
sql = String.format("ALTER TABLE %s DROP COLUMN %s",
|
||||
tableName, lastLoginOld);
|
||||
st.execute(sql);
|
||||
ConsoleLogger.info("Finished migration of lastlogin (timestamp to bigint)");
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs conversion of lastlogin column from int to bigint.
|
||||
*
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package fr.xephi.authme.permission.handlers;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import fr.xephi.authme.permission.PermissionNode;
|
||||
import fr.xephi.authme.permission.PermissionsSystemType;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
@@ -8,6 +9,7 @@ import org.bukkit.Server;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -24,7 +26,15 @@ public class VaultHandler implements PermissionHandler {
|
||||
this.vaultProvider = getVaultPermission(server);
|
||||
}
|
||||
|
||||
private static Permission getVaultPermission(Server server) throws PermissionHandlerException {
|
||||
/**
|
||||
* Returns the Vault Permission interface.
|
||||
*
|
||||
* @param server the bukkit server instance
|
||||
* @return the vault permission instance
|
||||
* @throws PermissionHandlerException if the vault permission instance cannot be retrieved
|
||||
*/
|
||||
@VisibleForTesting
|
||||
Permission getVaultPermission(Server server) throws PermissionHandlerException {
|
||||
// Get the permissions provider service
|
||||
RegisteredServiceProvider<Permission> permissionProvider = server
|
||||
.getServicesManager().getRegistration(Permission.class);
|
||||
@@ -76,7 +86,8 @@ public class VaultHandler implements PermissionHandler {
|
||||
|
||||
@Override
|
||||
public List<String> getGroups(OfflinePlayer player) {
|
||||
return Arrays.asList(vaultProvider.getPlayerGroups(null, player));
|
||||
String[] groups = vaultProvider.getPlayerGroups(null, player);
|
||||
return groups == null ? Collections.emptyList() : Arrays.asList(groups);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user