mirror of
https://github.com/proxiodev/RedisBungee.git
synced 2024-11-22 20:28:00 +00:00
Enough commits for today!
This commit is contained in:
parent
f2f84fcc13
commit
d82f375506
@ -245,59 +245,42 @@ public class RedisBungee extends Plugin implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerConnect(final PostLoginEvent event) {
|
public void onPlayerConnect(final PostLoginEvent event) {
|
||||||
getProxy().getScheduler().runAsync(this, new Runnable() {
|
Jedis rsc = pool.getResource();
|
||||||
@Override
|
try {
|
||||||
public void run() {
|
rsc.sadd("server:" + configuration.getServerId() + ":usersOnline", event.getPlayer().getName());
|
||||||
if (pool != null) {
|
rsc.hset("player:" + event.getPlayer().getName(), "online", "0");
|
||||||
Jedis rsc = pool.getResource();
|
} finally {
|
||||||
try {
|
pool.returnResource(rsc);
|
||||||
rsc.sadd("server:" + configuration.getServerId() + ":usersOnline", event.getPlayer().getName());
|
}
|
||||||
rsc.hset("player:" + event.getPlayer().getName(), "online", "0");
|
// I used to have a task that eagerly waited for the user to be connected.
|
||||||
} finally {
|
// Well, upon further inspection of BungeeCord's source code, this turned
|
||||||
pool.returnResource(rsc);
|
// out to not be needed at all, since ServerConnectedEvent is called anyway.
|
||||||
}
|
|
||||||
// I used to have a task that eagerly waited for the user to be connected.
|
|
||||||
// Well, upon further inspection of BungeeCord's source code, this turned
|
|
||||||
// out to not be needed at all, since ServerConnectedEvent is called anyway.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerDisconnect(final PlayerDisconnectEvent event) {
|
public void onPlayerDisconnect(final PlayerDisconnectEvent event) {
|
||||||
getProxy().getScheduler().runAsync(this, new Runnable() {
|
if (pool != null) {
|
||||||
@Override
|
Jedis rsc = pool.getResource();
|
||||||
public void run() {
|
try {
|
||||||
if (pool != null) {
|
rsc.srem("server:" + configuration.getServerId() + ":usersOnline", event.getPlayer().getName());
|
||||||
Jedis rsc = pool.getResource();
|
rsc.hset("player:" + event.getPlayer().getName(), "online", String.valueOf(getUnixTimestamp()));
|
||||||
try {
|
rsc.hdel("player:" + event.getPlayer().getName(), "server");
|
||||||
rsc.srem("server:" + configuration.getServerId() + ":usersOnline", event.getPlayer().getName());
|
} finally {
|
||||||
rsc.hset("player:" + event.getPlayer().getName(), "online", String.valueOf(getUnixTimestamp()));
|
pool.returnResource(rsc);
|
||||||
rsc.hdel("player:" + event.getPlayer().getName(), "server");
|
|
||||||
} finally {
|
|
||||||
pool.returnResource(rsc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onServerChange(final ServerConnectedEvent event) {
|
public void onServerChange(final ServerConnectedEvent event) {
|
||||||
getProxy().getScheduler().runAsync(this, new Runnable() {
|
if (pool != null) {
|
||||||
@Override
|
Jedis rsc = pool.getResource();
|
||||||
public void run() {
|
try {
|
||||||
if (pool != null) {
|
rsc.hset("player:" + event.getPlayer().getName(), "server", event.getServer().getInfo().getName());
|
||||||
Jedis rsc = pool.getResource();
|
} finally {
|
||||||
try {
|
pool.returnResource(rsc);
|
||||||
rsc.hset("player:" + event.getPlayer().getName(), "server", event.getServer().getInfo().getName());
|
|
||||||
} finally {
|
|
||||||
pool.returnResource(rsc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
Loading…
Reference in New Issue
Block a user