@EventHandler(priority = EventPriority.MONITOR)
public void playerPreLoginCacheInv(AsyncPlayerPreLoginEvent event) {
UUID uuid = event.getUniqueId();
if (uuid != null) {
plugin.getLogger().log(Level.FINER, "Preparing to pre-load player data: {0}", uuid);
} else {
return;
}
if (st == null){ // Small race condition if someone logs on as soon as the server starts.
event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_OTHER, "Please try to log in again in a moment, server is not ready to accept log-ins.");
plugin.getLogger().log(Level.INFO, "Player {0} logged on before async process was ready, skipping.", uuid);
return;
}
// caching disabled due to fail
Future<ByteArrayInputStream> soondata = db.loadPlayerDataAsync(uuid, st.getInvIdentifier(uuid), true); // wedon't use the data, but know that it caches behind the scenes.
try {
ByteArrayInputStream after = soondata.get(); // I want to _INTENTIONALLY_ delay accepting the user's login until I know for sure I've got the data loaded asynchronously.
if (after == null) {
plugin.getLogger().log(Level.INFO, "Pre-load for player data {0} came back empty. New player? Error?", uuid);
} else {
plugin.getLogger().log(Level.FINER, "Pre-load for player data {0} complete.", uuid);
}
} catch (InterruptedException | ExecutionException e) {
plugin.getLogger().log(Level.SEVERE, "Failed to pre-load player data: {0}", uuid);
e.printStackTrace();
}
// We do this so it fetches the cache, then when called for real
// by our CustomWorldNBTStorage class it doesn't have to wait and server won't lock.
}
BetterShardsListener.java 文件源码
java
阅读 23
收藏 0
点赞 0
评论 0
项目:BetterShards
作者:
评论列表
文章目录