2
0
mirror of https://github.com/proxiodev/RedisBungee.git synced 2025-04-20 01:27:07 +00:00

fix bug that player being added into the redis database if login event was cancelled

This commit is contained in:
mohammed jasem alaajel 2021-07-22 00:29:36 +04:00
parent 49ac1ba9ef
commit be3f437785

View File

@ -74,13 +74,6 @@ public class RedisBungeeListener implements Listener {
return null; 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; return null;
} finally { } finally {
event.completeIntent(plugin); event.completeIntent(plugin);
@ -94,6 +87,15 @@ public class RedisBungeeListener implements Listener {
plugin.getProxy().getScheduler().runAsync(plugin, new RedisCallable<Void>(plugin) { plugin.getProxy().getScheduler().runAsync(plugin, new RedisCallable<Void>(plugin) {
@Override @Override
protected Void call(Jedis jedis) { protected Void call(Jedis jedis) {
// this code was moved out from login event due being async..
// and it can be canceld 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<>( jedis.publish("redisbungee-data", RedisBungee.getGson().toJson(new DataManager.DataManagerMessage<>(
event.getPlayer().getUniqueId(), DataManager.DataManagerMessage.Action.JOIN, event.getPlayer().getUniqueId(), DataManager.DataManagerMessage.Action.JOIN,
new DataManager.LoginPayload(event.getPlayer().getAddress().getAddress())))); new DataManager.LoginPayload(event.getPlayer().getAddress().getAddress()))));