From 74a170e66ccf0bcb88007f2b604aa457f3234633 Mon Sep 17 00:00:00 2001 From: Jules Date: Sun, 18 Jun 2023 16:51:08 +0200 Subject: [PATCH] !Use of newest methods of ML for data saving --- .../main/java/net/Indyuce/mmocore/MMOCore.java | 15 +-------------- .../command/rpg/admin/ExportDataTreeNode.java | 2 +- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/MMOCore.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/MMOCore.java index 103362ea..d1ec3e6e 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/MMOCore.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/MMOCore.java @@ -275,25 +275,12 @@ public class MMOCore extends JavaPlugin { @Override public void onDisable() { - // Executes all the pending asynchronous task (like saving the playerData) - Bukkit.getScheduler().getPendingTasks().forEach(worker -> { - if (worker.getOwner().equals(this)) { - ((Runnable) worker).run(); - } - }); - - // Save player data - for (PlayerData data : PlayerData.getAll()) - if (data.isSynchronized()) { - data.close(); - dataProvider.getDataManager().getDataHandler().saveData(data, true); - } - // Save guild info for (Guild guild : dataProvider.getGuildManager().getAll()) dataProvider.getGuildManager().save(guild); // Close MySQL data provider (memory leaks) + playerDataManager.saveAll(false); playerDataManager.getDataHandler().close(); // Reset active blocks diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/command/rpg/admin/ExportDataTreeNode.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/command/rpg/admin/ExportDataTreeNode.java index 250962cd..f5b36328 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/command/rpg/admin/ExportDataTreeNode.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/command/rpg/admin/ExportDataTreeNode.java @@ -92,7 +92,7 @@ public class ExportDataTreeNode extends CommandTreeNode { MMOCore.plugin.dataProvider.getDataManager().getDataHandler().loadData(offlinePlayerData); // Player data is loaded, now it gets saved through SQL - sqlHandler.saveData(offlinePlayerData, true); + sqlHandler.saveData(offlinePlayerData, false); } catch (RuntimeException exception) { errorCount++; exception.printStackTrace();