2012-04-26 03:21:35 +02:00
|
|
|
package com.gmail.nossr50.runnables;
|
|
|
|
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
|
|
|
import com.gmail.nossr50.mcMMO;
|
|
|
|
import com.gmail.nossr50.datatypes.PlayerProfile;
|
2012-04-27 11:47:11 +02:00
|
|
|
import com.gmail.nossr50.util.Database;
|
|
|
|
import com.gmail.nossr50.util.Users;
|
2012-04-26 03:21:35 +02:00
|
|
|
|
|
|
|
public class SQLReconnect implements Runnable {
|
|
|
|
private final mcMMO plugin;
|
|
|
|
|
|
|
|
public SQLReconnect(mcMMO plugin) {
|
|
|
|
this.plugin = plugin;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void run() {
|
2012-05-01 07:52:38 +02:00
|
|
|
if (!Database.isConnected()) {
|
2012-04-26 03:21:35 +02:00
|
|
|
Database.connect();
|
|
|
|
if (Database.isConnected()) {
|
|
|
|
for (PlayerProfile x : Users.players.values()) {
|
|
|
|
x.save(); //Save all profiles
|
|
|
|
}
|
|
|
|
|
|
|
|
Users.players.clear(); //Clear the profiles
|
|
|
|
for (Player x : plugin.getServer().getOnlinePlayers()) {
|
|
|
|
Users.addUser(x); //Add in new profiles, forcing them to 'load' again from MySQL
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|