mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 23:26:45 +01:00
Made things cleaner
This commit is contained in:
parent
76afd5a7ca
commit
b8e9269488
@ -26,7 +26,7 @@ public class MmoupdateCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sender.sendMessage(ChatColor.GRAY + "Starting conversion..."); //TODO: Needs more locale.
|
sender.sendMessage(ChatColor.GRAY + "Starting conversion..."); //TODO: Needs more locale.
|
||||||
Users.clearUsers();
|
Users.clearAll();
|
||||||
convertToMySQL();
|
convertToMySQL();
|
||||||
|
|
||||||
for (Player x : plugin.getServer().getOnlinePlayers()) {
|
for (Player x : plugin.getServer().getOnlinePlayers()) {
|
||||||
|
@ -102,7 +102,7 @@ public class McremoveCommand implements CommandExecutor {
|
|||||||
PlayerProfile playerProfile = Users.getProfile(player);
|
PlayerProfile playerProfile = Users.getProfile(player);
|
||||||
|
|
||||||
if (playerProfile != null) {
|
if (playerProfile != null) {
|
||||||
Users.getProfiles().remove(playerProfile);
|
Users.remove(player.getName());
|
||||||
|
|
||||||
if (player.isOnline()) {
|
if (player.isOnline()) {
|
||||||
Users.addUser((Player) player);
|
Users.addUser((Player) player);
|
||||||
|
@ -284,20 +284,11 @@ public class mcMMO extends JavaPlugin {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
//Make sure to save player information if the server shuts down
|
Users.saveAll(); //Make sure to save player information if the server shuts down
|
||||||
for (PlayerProfile playerProfile : Users.getProfiles().values()) {
|
|
||||||
playerProfile.save();
|
|
||||||
}
|
|
||||||
|
|
||||||
PartyManager.getInstance().saveParties();
|
PartyManager.getInstance().saveParties();
|
||||||
|
|
||||||
getServer().getScheduler().cancelTasks(this); //This removes our tasks
|
getServer().getScheduler().cancelTasks(this); //This removes our tasks
|
||||||
|
placeStore.saveAll(); //Save our metadata
|
||||||
//Save our metadata
|
placeStore.cleanUp(); //Cleanup empty metadata stores
|
||||||
placeStore.saveAll();
|
|
||||||
|
|
||||||
//Cleanup empty metadata stores
|
|
||||||
placeStore.cleanUp();
|
|
||||||
|
|
||||||
//Remove other tasks BEFORE starting the Backup, or we just cancel it straight away.
|
//Remove other tasks BEFORE starting the Backup, or we just cancel it straight away.
|
||||||
try {
|
try {
|
||||||
|
@ -3,7 +3,6 @@ package com.gmail.nossr50.runnables;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
|
||||||
import com.gmail.nossr50.util.Database;
|
import com.gmail.nossr50.util.Database;
|
||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.Users;
|
||||||
|
|
||||||
@ -19,11 +18,9 @@ public class SQLReconnect implements Runnable {
|
|||||||
if (!Database.isConnected()) {
|
if (!Database.isConnected()) {
|
||||||
Database.connect();
|
Database.connect();
|
||||||
if (Database.isConnected()) {
|
if (Database.isConnected()) {
|
||||||
for (PlayerProfile playerProfile : Users.getProfiles().values()) {
|
Users.saveAll(); //Save all profiles
|
||||||
playerProfile.save(); //Save all profiles
|
Users.clearAll(); //Clear the profiles
|
||||||
}
|
|
||||||
|
|
||||||
Users.clearUsers(); //Clear the profiles
|
|
||||||
for (Player player : plugin.getServer().getOnlinePlayers()) {
|
for (Player player : plugin.getServer().getOnlinePlayers()) {
|
||||||
Users.addUser(player); //Add in new profiles, forcing them to 'load' again from MySQL
|
Users.addUser(player); //Add in new profiles, forcing them to 'load' again from MySQL
|
||||||
}
|
}
|
||||||
|
@ -58,13 +58,31 @@ public class Users {
|
|||||||
return playerProfile;
|
return playerProfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Remove a user.
|
||||||
|
*
|
||||||
|
* @param playerName The name of the player to remove
|
||||||
|
*/
|
||||||
|
public static void remove(String playerName) {
|
||||||
|
profiles.remove(playerName);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear all users.
|
* Clear all users.
|
||||||
*/
|
*/
|
||||||
public static void clearUsers() {
|
public static void clearAll() {
|
||||||
profiles.clear();
|
profiles.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Save all users.
|
||||||
|
*/
|
||||||
|
public static void saveAll() {
|
||||||
|
for (PlayerProfile playerProfile : profiles.values()) {
|
||||||
|
playerProfile.save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all PlayerProfiles.
|
* Get all PlayerProfiles.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user