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

Expose previous server. Closes #11, #12

This commit is contained in:
Tux 2014-12-07 16:15:39 -05:00
parent 47fc9792b0
commit 62eacc5816
2 changed files with 11 additions and 4 deletions

View File

@ -263,13 +263,14 @@ public class DataManager implements Listener {
});
break;
case SERVER_CHANGE:
final DataManagerMessage<ServerChangePayload> message3 = RedisBungee.getGson().fromJson(jsonObject, new TypeToken<DataManagerMessage<ServerChangePayload>>() {
final DataManagerMessage<ServerChangePayload> message3 = RedisBungee.getGson().fromJson(jsonObject, new TypeToken<DataManagerMessage<ServerChangePayload>>()
{
}.getType());
serverCache.put(message3.getTarget(), message3.getPayload().getServer());
final String oldServer = serverCache.put(message3.getTarget(), message3.getPayload().getServer());
plugin.getProxy().getScheduler().runAsync(plugin, new Runnable() {
@Override
public void run() {
plugin.getProxy().getPluginManager().callEvent(new PlayerChangedServerNetworkEvent(message3.getTarget(), message3.getPayload().getServer()));
plugin.getProxy().getPluginManager().callEvent(new PlayerChangedServerNetworkEvent(message3.getTarget(), oldServer, message3.getPayload().getServer()));
}
});
break;

View File

@ -23,10 +23,12 @@ import java.util.UUID;
@ToString
public class PlayerChangedServerNetworkEvent extends Event {
private final UUID uuid;
private final String previousServer;
private final String server;
public PlayerChangedServerNetworkEvent(UUID uuid, String server) {
public PlayerChangedServerNetworkEvent(UUID uuid, String previousServer, String server) {
this.uuid = uuid;
this.previousServer = previousServer;
this.server = server;
}
@ -37,4 +39,8 @@ public class PlayerChangedServerNetworkEvent extends Event {
public String getServer() {
return server;
}
public String getPreviousServer() {
return previousServer;
}
}