From 96e627052040710ba3a3aa8c4f118796aeafd56b Mon Sep 17 00:00:00 2001 From: nossr50 Date: Sun, 29 Apr 2012 12:02:24 -0700 Subject: [PATCH] Changed MySQL to not save everything at once --- Changelog.txt | 3 +++ pom.xml | 2 +- .../nossr50/runnables/ProfileSaveTask.java | 21 +++++++++++++++++++ .../gmail/nossr50/runnables/SaveTimer.java | 5 ++++- 4 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/gmail/nossr50/runnables/ProfileSaveTask.java diff --git a/Changelog.txt b/Changelog.txt index d9bbc3b69..e8de24bdd 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -7,6 +7,9 @@ Key: ! Change - Removal +Version 1.3.07 + ! Changed MySQL to save player information 50ms apart from each other to reduce the load on the MySQL server + Version 1.3.06 + Added Iron Golem XP for aggressive golems + Added permissions check to skill functions diff --git a/pom.xml b/pom.xml index b832e4dbb..89b18b40e 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 1.3.06 + 1.3.07-dev mcMMO https://github.com/mcMMO-Dev/mcMMO diff --git a/src/main/java/com/gmail/nossr50/runnables/ProfileSaveTask.java b/src/main/java/com/gmail/nossr50/runnables/ProfileSaveTask.java new file mode 100644 index 000000000..ed240cdb1 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/runnables/ProfileSaveTask.java @@ -0,0 +1,21 @@ +package com.gmail.nossr50.runnables; + +import org.bukkit.entity.Player; + +import com.gmail.nossr50.util.Users; + +public class ProfileSaveTask implements Runnable { + + Player player = null; + + public ProfileSaveTask(Player player) { + this.player = player; + } + + @Override + public void run() { + if(player != null) { + Users.getProfileByName(player.getName()).save(); + } + } +} diff --git a/src/main/java/com/gmail/nossr50/runnables/SaveTimer.java b/src/main/java/com/gmail/nossr50/runnables/SaveTimer.java index 8a211dcaf..54445041d 100644 --- a/src/main/java/com/gmail/nossr50/runnables/SaveTimer.java +++ b/src/main/java/com/gmail/nossr50/runnables/SaveTimer.java @@ -1,5 +1,6 @@ package com.gmail.nossr50.runnables; +import org.bukkit.Bukkit; import org.bukkit.entity.Player; import com.gmail.nossr50.mcMMO; @@ -15,8 +16,10 @@ public class SaveTimer implements Runnable { @Override public void run() { //All player data will be saved periodically through this + int count = 1; for (Player player : plugin.getServer().getOnlinePlayers()) { - Users.getProfile(player).save(); + Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new ProfileSaveTask(player), count); + count++; } } }