diff --git a/pom.xml b/pom.xml
index 12d05f0..d59424d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -11,11 +11,11 @@
UTF-8
${project.groupId}.plugin.${project.artifactId}
- 1.1.0
+ 1.1.1
com.artformgames
usersuffix
- 1.2.0
+ 1.3.0
UserSuffix
diff --git a/src/main/java/com/artformgames/plugin/usersuffix/migrator/LuckPermsMigrator.java b/src/main/java/com/artformgames/plugin/usersuffix/migrator/LuckPermsMigrator.java
index 66534dd..df547bd 100644
--- a/src/main/java/com/artformgames/plugin/usersuffix/migrator/LuckPermsMigrator.java
+++ b/src/main/java/com/artformgames/plugin/usersuffix/migrator/LuckPermsMigrator.java
@@ -3,7 +3,6 @@
import cc.carm.lib.easysql.api.SQLQuery;
import com.artformgames.core.ArtCore;
import com.artformgames.core.user.UserKey;
-import com.artformgames.plugin.usersuffix.user.SuffixAccount;
import com.artformgames.plugin.usersuffix.user.SuffixLoader;
import java.sql.ResultSet;
@@ -15,6 +14,10 @@
public class LuckPermsMigrator {
+ public record CachedRecord(UserKey user,
+ String content, String formatColor) {
+ }
+
// REGEX For suffix..
public static final Pattern PATTERN = Pattern.compile("^suffix\\.\\d+\\.(.*)$");
@@ -25,7 +28,7 @@ public class LuckPermsMigrator {
public static int importData(String sourceTable, String usersTable, boolean purge) {
Set indexList = new HashSet<>();
- Set data = new HashSet<>();
+ Set data = new HashSet<>();
try (SQLQuery query = ArtCore.getSQLManager().createQuery().inTable(sourceTable)
.selectColumns("id", "uuid", "permission")
.build().execute()) {
@@ -49,15 +52,18 @@ public static int importData(String sourceTable, String usersTable, boolean purg
String username = getUsername(usersTable, uuid);
if (username == null) continue;
+ UserKey key = importKey(uuid, username);
+ if (key == null) continue;
+
indexList.add(rs.getInt("id"));
- data.add(new MigrateCache(importKey(uuid, username), content, formatColor));
+ data.add(new CachedRecord(key, content, formatColor));
}
} catch (Exception ex) {
ex.printStackTrace();
return -1;
}
- for (MigrateCache cache : data) { // Insert data into the new table
+ for (CachedRecord cache : data) { // Insert data into the new table
SuffixLoader.TABLE.createReplace()
.setColumnNames("user", "content", "color")
.setParams(cache.user().id(), cache.content(), cache.content())
@@ -92,7 +98,11 @@ public static String getUsername(String playersTable, UUID uuid) {
}
public static UserKey importKey(UUID uuid, String username) {
- return ArtCore.getUserManager().getKey(uuid);
+ try {
+ return ArtCore.getUserManager().upsertKey(uuid, username);
+ } catch (Exception e) {
+ return null;
+ }
}
diff --git a/src/main/java/com/artformgames/plugin/usersuffix/migrator/MigrateCache.java b/src/main/java/com/artformgames/plugin/usersuffix/migrator/MigrateCache.java
deleted file mode 100644
index 2b0f794..0000000
--- a/src/main/java/com/artformgames/plugin/usersuffix/migrator/MigrateCache.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package com.artformgames.plugin.usersuffix.migrator;
-
-import com.artformgames.core.user.UserKey;
-import org.checkerframework.checker.units.qual.N;
-import org.jetbrains.annotations.NotNull;
-
-import java.util.UUID;
-
-public record MigrateCache(UserKey user,
- String content, String formatColor) {
-}