Save on Bungee server switch, fixes #1906

This commit is contained in:
PikaMug 2022-03-27 03:01:57 -04:00
parent 83c720c021
commit 34eb2e458a

View File

@ -21,10 +21,23 @@ public class BungeePlayerListener implements Listener {
}
@EventHandler
public void onPlayerLogin(ServerSwitchEvent evt) {
public void onPlayerLoginOrSwitch(ServerSwitchEvent evt) {
if (evt.getFrom() != null) {
final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
final DataOutputStream dataOutputStream = new DataOutputStream(byteArrayOutputStream);
try {
System.out.println("Saved player data");
dataOutputStream.writeUTF("SaveData:" + evt.getPlayer().getUniqueId());
} catch (IOException e) {
e.printStackTrace();
}
dispatchMessage(byteArrayOutputStream.toByteArray());
}
final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
final DataOutputStream dataOutputStream = new DataOutputStream(byteArrayOutputStream);
try {
System.out.println("Loaded player data");
dataOutputStream.writeUTF("LoadData:" + evt.getPlayer().getUniqueId());
} catch (IOException e) {
e.printStackTrace();
@ -37,6 +50,7 @@ public class BungeePlayerListener implements Listener {
final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
final DataOutputStream dataOutputStream = new DataOutputStream(byteArrayOutputStream);
try {
System.out.println("Saved player data");
dataOutputStream.writeUTF("SaveData:" + evt.getPlayer().getUniqueId());
} catch (IOException e) {
e.printStackTrace();