Changed MySQL to not save everything at once

This commit is contained in:
nossr50 2012-04-29 12:02:24 -07:00
parent 51c45e86ce
commit 96e6270520
4 changed files with 29 additions and 2 deletions

View File

@ -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

View File

@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.gmail.nossr50.mcMMO</groupId>
<artifactId>mcMMO</artifactId>
<version>1.3.06</version>
<version>1.3.07-dev</version>
<name>mcMMO</name>
<url>https://github.com/mcMMO-Dev/mcMMO</url>
<issueManagement>

View File

@ -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();
}
}
}

View File

@ -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++;
}
}
}