2
0
mirror of https://github.com/proxiodev/RedisBungee.git synced 2024-11-23 04:28: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; break;
case SERVER_CHANGE: 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()); }.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() { plugin.getProxy().getScheduler().runAsync(plugin, new Runnable() {
@Override @Override
public void run() { 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; break;

View File

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