mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-30 00:56:47 +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 java.util.Properties;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.LoadProperties;
|
import com.gmail.nossr50.config.LoadProperties;
|
||||||
import com.gmail.nossr50.datatypes.DatabaseUpdate;
|
import com.gmail.nossr50.datatypes.DatabaseUpdate;
|
||||||
|
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||||
|
|
||||||
public class Database {
|
public class Database {
|
||||||
|
|
||||||
@ -253,6 +255,16 @@ public class Database {
|
|||||||
public void run() {
|
public void run() {
|
||||||
if (!isConnected()) {
|
if (!isConnected()) {
|
||||||
connect();
|
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);
|
}, 20*60);
|
||||||
|
@ -13,7 +13,10 @@ public class RemoveProfileFromMemoryTask implements Runnable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
Users.getProfile(player.getName()).save(); //We save here so players don't quit/reconnect to cause lag
|
//Check if the profile still exists (stuff like MySQL reconnection removes profiles)
|
||||||
Users.removeUserByName(player.getName());
|
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