mirror of
https://github.com/CarmJos/UltraDepository.git
synced 2026-06-05 00:58:22 +08:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| afd62a493d |
@@ -15,7 +15,7 @@
|
|||||||
<groupId>cc.carm.plugin</groupId>
|
<groupId>cc.carm.plugin</groupId>
|
||||||
<artifactId>ultradepository</artifactId>
|
<artifactId>ultradepository</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<version>1.3.2</version>
|
<version>1.3.3</version>
|
||||||
|
|
||||||
<name>UltraDepository</name>
|
<name>UltraDepository</name>
|
||||||
<description>超级仓库插件,支持设定不同物品的存储仓库。</description>
|
<description>超级仓库插件,支持设定不同物品的存储仓库。</description>
|
||||||
|
|||||||
@@ -60,9 +60,6 @@ public class UltraDepository extends EasyPlugin {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
log("加载用户系统...");
|
|
||||||
userManager = new UserManager();
|
|
||||||
|
|
||||||
log("加载经济系统...");
|
log("加载经济系统...");
|
||||||
if (Bukkit.getPluginManager().getPlugin("Vault") != null) {
|
if (Bukkit.getPluginManager().getPlugin("Vault") != null) {
|
||||||
economyManager = new EconomyManager();
|
economyManager = new EconomyManager();
|
||||||
@@ -76,11 +73,15 @@ public class UltraDepository extends EasyPlugin {
|
|||||||
log("加载仓库管理器...");
|
log("加载仓库管理器...");
|
||||||
depositoryManager = new DepositoryManager();
|
depositoryManager = new DepositoryManager();
|
||||||
getDepositoryManager().loadDepositories();
|
getDepositoryManager().loadDepositories();
|
||||||
GUI.initialize(this);
|
|
||||||
|
log("加载用户系统...");
|
||||||
|
userManager = new UserManager();
|
||||||
|
|
||||||
|
|
||||||
log("注册监听器...");
|
log("注册监听器...");
|
||||||
regListener(new UserListener());
|
regListener(new UserListener());
|
||||||
regListener(new CollectListener());
|
regListener(new CollectListener());
|
||||||
|
GUI.initialize(this);
|
||||||
|
|
||||||
log("注册指令...");
|
log("注册指令...");
|
||||||
registerCommand("UltraDepository", new DepositoryCommand());
|
registerCommand("UltraDepository", new DepositoryCommand());
|
||||||
@@ -107,6 +108,9 @@ public class UltraDepository extends EasyPlugin {
|
|||||||
else return plugin.getDescription().getVersion();
|
else return plugin.getDescription().getVersion();
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getUserManager().loadPlayersData();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,6 +127,7 @@ public class UltraDepository extends EasyPlugin {
|
|||||||
|
|
||||||
log("卸载监听器...");
|
log("卸载监听器...");
|
||||||
Bukkit.getServicesManager().unregisterAll(this);
|
Bukkit.getServicesManager().unregisterAll(this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DataStorage getStorage() {
|
public static DataStorage getStorage() {
|
||||||
|
|||||||
@@ -20,15 +20,13 @@ public class UserListener implements Listener {
|
|||||||
if (event.getLoginResult() != AsyncPlayerPreLoginEvent.Result.ALLOWED) {
|
if (event.getLoginResult() != AsyncPlayerPreLoginEvent.Result.ALLOWED) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
UUID uuid = event.getUniqueId();
|
UltraDepository.getUserManager().loadDataCache(event.getUniqueId());
|
||||||
UltraDepository.getUserManager().getDataCache()
|
|
||||||
.put(uuid, UltraDepository.getUserManager().loadData(uuid));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onPreLoginMonitor(AsyncPlayerPreLoginEvent event) {
|
public void onPreLoginMonitor(AsyncPlayerPreLoginEvent event) {
|
||||||
if (event.getLoginResult() != AsyncPlayerPreLoginEvent.Result.ALLOWED) {
|
if (event.getLoginResult() != AsyncPlayerPreLoginEvent.Result.ALLOWED) {
|
||||||
UltraDepository.getUserManager().getDataCache().remove(event.getUniqueId());
|
UltraDepository.getUserManager().removeDataCache(event.getUniqueId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import cc.carm.plugin.ultradepository.UltraDepository;
|
|||||||
import cc.carm.plugin.ultradepository.data.UserData;
|
import cc.carm.plugin.ultradepository.data.UserData;
|
||||||
import cc.carm.plugin.ultradepository.storage.DataStorage;
|
import cc.carm.plugin.ultradepository.storage.DataStorage;
|
||||||
import cc.carm.plugin.ultradepository.util.DateIntUtil;
|
import cc.carm.plugin.ultradepository.util.DateIntUtil;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
@@ -20,6 +21,27 @@ public class UserManager {
|
|||||||
return dataCache;
|
return dataCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void loadPlayersData() {
|
||||||
|
if (Bukkit.getOnlinePlayers().size() < 1) return;
|
||||||
|
|
||||||
|
UltraDepository.getInstance().log("加载当前在线玩家数据...");
|
||||||
|
// 用于热加载时重载玩家数据。
|
||||||
|
Bukkit.getOnlinePlayers().forEach(player -> loadDataCache(player.getUniqueId()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public @NotNull UserData loadDataCache(@NotNull UUID userUUID) {
|
||||||
|
UserData data = loadData(userUUID);
|
||||||
|
UltraDepository.getUserManager().getDataCache().put(userUUID, data);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean removeDataCache(@NotNull UUID userUUID) {
|
||||||
|
boolean contains = getDataCache().containsKey(userUUID);
|
||||||
|
getDataCache().remove(userUUID);
|
||||||
|
return contains;
|
||||||
|
}
|
||||||
|
|
||||||
public @Nullable UserData getData(@NotNull UUID userUUID) {
|
public @Nullable UserData getData(@NotNull UUID userUUID) {
|
||||||
return getDataCache().get(userUUID);
|
return getDataCache().get(userUUID);
|
||||||
}
|
}
|
||||||
@@ -56,7 +78,7 @@ public class UserManager {
|
|||||||
UserData data = getData(uuid);
|
UserData data = getData(uuid);
|
||||||
if (data == null) return;
|
if (data == null) return;
|
||||||
if (save) saveData(data);
|
if (save) saveData(data);
|
||||||
dataCache.remove(uuid);
|
removeDataCache(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveData(UserData data) {
|
public void saveData(UserData data) {
|
||||||
|
|||||||
Reference in New Issue
Block a user