2
0
mirror of https://github.com/proxiodev/RedisBungee.git synced 2024-12-23 10:38:01 +00:00

Fix: Player being added into the Redis database if LoginEvent was cancelled..... (#16)

This commit is contained in:
mohammed jasem alaajel 2021-07-22 02:06:36 +04:00 committed by GitHub
parent 49ac1ba9ef
commit 86ebc9c0d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -74,13 +74,6 @@ public class RedisBungeeListener implements Listener {
return null;
}
}
Pipeline pipeline = jedis.pipelined();
plugin.getUuidTranslator().persistInfo(event.getConnection().getName(), event.getConnection().getUniqueId(), pipeline);
RedisUtil.createPlayer(event.getConnection(), pipeline, false);
// We're not publishing, the API says we only publish at PostLoginEvent time.
pipeline.sync();
return null;
} finally {
event.completeIntent(plugin);
@ -94,6 +87,15 @@ public class RedisBungeeListener implements Listener {
plugin.getProxy().getScheduler().runAsync(plugin, new RedisCallable<Void>(plugin) {
@Override
protected Void call(Jedis jedis) {
// this code was moved out from login event due being async..
// and it can be cancelled but it will show as false in redis-bungee
// which will register the player into the redis database.
Pipeline pipeline = jedis.pipelined();
plugin.getUuidTranslator().persistInfo(event.getPlayer().getName(), event.getPlayer().getUniqueId(), pipeline);
RedisUtil.createPlayer(event.getPlayer(), pipeline, false);
pipeline.sync();
// the end of moved code.
jedis.publish("redisbungee-data", RedisBungee.getGson().toJson(new DataManager.DataManagerMessage<>(
event.getPlayer().getUniqueId(), DataManager.DataManagerMessage.Action.JOIN,
new DataManager.LoginPayload(event.getPlayer().getAddress().getAddress()))));