mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-06-27 19:24:44 +02:00
Replaced playerName fields in PlayerProfile and Users by the Player object
This commit is contained in:
@ -27,7 +27,7 @@ public class GainXp implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
int health = target.getHealth();
|
||||
int damage = baseHealth - health;
|
||||
int damage = baseHealth - health;
|
||||
|
||||
//May avoid negative xp, we don't know what other plugins do with the entity health
|
||||
if (damage <= 0) {
|
||||
|
@ -5,7 +5,7 @@ import org.bukkit.entity.Player;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class ProfileSaveTask implements Runnable {
|
||||
Player player = null;
|
||||
private Player player;
|
||||
|
||||
public ProfileSaveTask(Player player) {
|
||||
this.player = player;
|
||||
@ -14,7 +14,7 @@ public class ProfileSaveTask implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
if (player != null) {
|
||||
Users.getProfileByName(player.getName()).save();
|
||||
Users.getProfile(player).save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,20 +1,22 @@
|
||||
package com.gmail.nossr50.runnables;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class RemoveProfileFromMemoryTask implements Runnable {
|
||||
private String playerName = null;
|
||||
private Player player;
|
||||
|
||||
public RemoveProfileFromMemoryTask(String playerName) {
|
||||
this.playerName = playerName;
|
||||
public RemoveProfileFromMemoryTask(Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
//Check if the profile still exists (stuff like MySQL reconnection removes profiles)
|
||||
if (Users.players.containsKey(playerName.toLowerCase())) {
|
||||
Users.getProfileByName(playerName.toLowerCase()).save(); //We save here so players don't quit/reconnect to cause lag
|
||||
Users.removeUserByName(playerName.toLowerCase());
|
||||
if (Users.getProfiles().containsKey(player)) {
|
||||
Users.getProfile(player).save(); //We save here so players don't quit/reconnect to cause lag
|
||||
Users.removeUser(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,11 +19,11 @@ public class SQLReconnect implements Runnable {
|
||||
if (!Database.isConnected()) {
|
||||
Database.connect();
|
||||
if (Database.isConnected()) {
|
||||
for (PlayerProfile x : Users.players.values()) {
|
||||
for (PlayerProfile x : Users.getProfiles().values()) {
|
||||
x.save(); //Save all profiles
|
||||
}
|
||||
|
||||
Users.players.clear(); //Clear the 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
|
||||
}
|
||||
|
Reference in New Issue
Block a user