Skip to content

Commit

Permalink
Fix inventory clearing on world save
Browse files Browse the repository at this point in the history
  • Loading branch information
WiIIiam278 committed Jun 8, 2022
1 parent 3cd1440 commit 633847a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ public void onDisable() {
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!");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,14 @@ public void onPlayerQuit(PlayerQuitEvent event) {
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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,6 @@ public static void updatePlayerData(Player player, boolean bounceBack) {
} 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();
}

/**
Expand Down

0 comments on commit 633847a

Please sign in to comment.