mirror of
https://github.com/CarmJos/EasyPlugin.git
synced 2026-06-04 08:38:17 +08:00
feat(user): Fixed user interfaces error
This commit is contained in:
+1
-1
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<artifactId>easyplugin-parent</artifactId>
|
||||
<version>1.5.13</version>
|
||||
<version>1.5.14</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<properties>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<artifactId>easyplugin-parent</artifactId>
|
||||
<version>1.5.13</version>
|
||||
<version>1.5.14</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<properties>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>easyplugin-parent</artifactId>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<version>1.5.13</version>
|
||||
<version>1.5.14</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>easyplugin-parent</artifactId>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<version>1.5.13</version>
|
||||
<version>1.5.14</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>easyplugin-parent</artifactId>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<version>1.5.13</version>
|
||||
<version>1.5.14</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<artifactId>easyplugin-parent</artifactId>
|
||||
<version>1.5.13</version>
|
||||
<version>1.5.14</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<properties>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>easyplugin-parent</artifactId>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<version>1.5.13</version>
|
||||
<version>1.5.14</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<artifactId>easyplugin-parent</artifactId>
|
||||
<version>1.5.13</version>
|
||||
<version>1.5.14</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<properties>
|
||||
|
||||
@@ -17,6 +17,11 @@ public abstract class AbstractUserData<K> implements UserData<K> {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull K key() {
|
||||
return key;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dropping true if the data is dropping, false otherwise
|
||||
*/
|
||||
|
||||
@@ -6,11 +6,6 @@ public interface UserData<K> {
|
||||
|
||||
@NotNull K key();
|
||||
|
||||
@Deprecated
|
||||
default @NotNull K getKey() {
|
||||
return key();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dropping true if the data is dropping, false otherwise
|
||||
*/
|
||||
|
||||
@@ -68,7 +68,8 @@ public abstract class UserDataManager<K, U extends AbstractUserData<K>> implemen
|
||||
|
||||
protected abstract void saveData(@NotNull U data) throws Exception;
|
||||
|
||||
public @NotNull Map<K, U> getDataCache() {
|
||||
@Override
|
||||
public @NotNull Map<K, U> cache() {
|
||||
return dataCache;
|
||||
}
|
||||
|
||||
@@ -107,7 +108,7 @@ public abstract class UserDataManager<K, U extends AbstractUserData<K>> implemen
|
||||
@Override
|
||||
public @NotNull CompletableFuture<Boolean> save(@NotNull U user) {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
String identifier = serializeKey(user.getKey());
|
||||
String identifier = serializeKey(user.key());
|
||||
|
||||
try {
|
||||
long s1 = System.currentTimeMillis();
|
||||
@@ -195,12 +196,12 @@ public abstract class UserDataManager<K, U extends AbstractUserData<K>> implemen
|
||||
|
||||
@Override
|
||||
public void saveAll() {
|
||||
if (getDataCache().isEmpty()) return;
|
||||
for (U u : getDataCache().values()) {
|
||||
if (cache().isEmpty()) return;
|
||||
for (U u : cache().values()) {
|
||||
try {
|
||||
saveData(u);
|
||||
} catch (Exception e) {
|
||||
getPlugin().error("保存用户 " + serializeKey(u.getKey()) + " 数据失败,请检查相关配置!");
|
||||
getPlugin().error("保存用户 " + serializeKey(u.key()) + " 数据失败,请检查相关配置!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@@ -209,8 +210,8 @@ public abstract class UserDataManager<K, U extends AbstractUserData<K>> implemen
|
||||
@Override
|
||||
public int unloadAll(boolean save) {
|
||||
if (save) saveAll();
|
||||
int size = getDataCache().size();
|
||||
getDataCache().clear();
|
||||
int size = cache().size();
|
||||
cache().clear();
|
||||
return size;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@ public interface UserDataRegistry<K, U extends UserData<K>> {
|
||||
|
||||
@NotNull Logger getLogger();
|
||||
|
||||
|
||||
@NotNull Map<K, U> cache();
|
||||
|
||||
default String serializeKey(@NotNull K key) {
|
||||
@@ -40,7 +39,6 @@ public interface UserDataRegistry<K, U extends UserData<K>> {
|
||||
return load(key, () -> cache);
|
||||
}
|
||||
|
||||
|
||||
@Unmodifiable
|
||||
default @NotNull Set<U> list() {
|
||||
return ImmutableSet.copyOf(cache().values());
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>easyplugin-parent</artifactId>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<version>1.5.13</version>
|
||||
<version>1.5.14</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
Reference in New Issue
Block a user