mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 15:16:45 +01:00
Made MySQL reload all profiles on reconnect, modified
RemoveProfileFromMemoryTask
This commit is contained in:
parent
631b2342b9
commit
d1f13ddec0
@ -10,9 +10,11 @@ import java.util.ArrayList;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.datatypes.DatabaseUpdate;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
|
||||
public class Database {
|
||||
|
||||
@ -253,6 +255,16 @@ public class Database {
|
||||
public void run() {
|
||||
if (!isConnected()) {
|
||||
connect();
|
||||
if(isConnected()) {
|
||||
//Save/Remove all profiles
|
||||
for(PlayerProfile x : Users.players.values()) {
|
||||
x.save();
|
||||
}
|
||||
Users.players.clear(); //Clear the profiles
|
||||
for(Player x : Bukkit.getOnlinePlayers()) {
|
||||
Users.addUser(x); //Add in new profiles, forcing them to 'load' again from MySQL
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 20*60);
|
||||
|
@ -13,7 +13,10 @@ public class RemoveProfileFromMemoryTask implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
//Check if the profile still exists (stuff like MySQL reconnection removes profiles)
|
||||
if(Users.players.containsKey(player.getName().toLowerCase())) {
|
||||
Users.getProfile(player.getName()).save(); //We save here so players don't quit/reconnect to cause lag
|
||||
Users.removeUserByName(player.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user