9
0
mirror of https://github.com/WiIIiam278/HuskSync.git synced 2025-12-28 19:19:13 +00:00

Fix inventory clearing on world save

This commit is contained in:
William
2022-06-08 11:17:53 +01:00
parent 3cd144088d
commit 633847a254
3 changed files with 12 additions and 5 deletions

View File

@@ -145,6 +145,10 @@ public final class HuskSyncBukkit extends JavaPlugin {
getLogger().info("Saving data for remaining online players...");
for (Player player : Bukkit.getOnlinePlayers()) {
PlayerSetter.updatePlayerData(player, false);
// Clear player inventory and ender chest
player.getInventory().clear();
player.getEnderChest().clear();
}
getLogger().info("Data save complete!");
}

View File

@@ -39,7 +39,14 @@ public class BukkitEventListener implements Listener {
return; // If the plugin has not been initialized correctly
// Update the player's data
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> PlayerSetter.updatePlayerData(player, true));
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
// Update data to proxy
PlayerSetter.updatePlayerData(player, true);
// Clear player inventory and ender chest
player.getInventory().clear();
player.getEnderChest().clear();
});
}
@EventHandler(priority = EventPriority.LOWEST)

View File

@@ -108,10 +108,6 @@ public class PlayerSetter {
} catch (IOException e) {
plugin.getLogger().log(Level.SEVERE, "Failed to send a PlayerData update to the proxy", e);
}
// Clear player inventory and ender chest
player.getInventory().clear();
player.getEnderChest().clear();
}
/**