mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-06-27 19:24:44 +02:00
Reworked a little Users.java
This commit is contained in:
@ -2,6 +2,7 @@ package com.gmail.nossr50.runnables;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class RemoveProfileFromMemoryTask implements Runnable {
|
||||
@ -13,10 +14,15 @@ public class RemoveProfileFromMemoryTask implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
PlayerProfile playerProfile = Users.getProfile(player);
|
||||
|
||||
//Check if the profile still exists (stuff like MySQL reconnection removes profiles)
|
||||
if (Users.getProfiles().containsKey(player)) {
|
||||
Users.getProfile(player).save(); //We save here so players don't quit/reconnect to cause lag
|
||||
Users.removeUser(player);
|
||||
if (playerProfile != null) {
|
||||
playerProfile.save(); //We save here so players don't quit/reconnect to cause lag
|
||||
|
||||
if (!player.isOnline()) {
|
||||
Users.removeUser(playerProfile);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,13 +19,13 @@ public class SQLReconnect implements Runnable {
|
||||
if (!Database.isConnected()) {
|
||||
Database.connect();
|
||||
if (Database.isConnected()) {
|
||||
for (PlayerProfile x : Users.getProfiles().values()) {
|
||||
x.save(); //Save all profiles
|
||||
for (PlayerProfile playerProfile : Users.getProfiles()) {
|
||||
playerProfile.save(); //Save all profiles
|
||||
}
|
||||
|
||||
Users.getProfiles().clear(); //Clear the profiles
|
||||
for (Player x : plugin.getServer().getOnlinePlayers()) {
|
||||
Users.addUser(x); //Add in new profiles, forcing them to 'load' again from MySQL
|
||||
Users.clearUsers(); //Clear the profiles
|
||||
for (Player player : plugin.getServer().getOnlinePlayers()) {
|
||||
Users.addUser(player); //Add in new profiles, forcing them to 'load' again from MySQL
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user