diff --git a/.gitignore b/.gitignore index 626bd858f..c1fc8b034 100644 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,14 @@ zBench zMyst zSotanna zSotanna2 +/.recommenders/index/http___download_eclipse_org_recommenders_models_mars_/_0.fdt +/.recommenders/index/http___download_eclipse_org_recommenders_models_mars_/_0.fdx +/.recommenders/index/http___download_eclipse_org_recommenders_models_mars_/_0.fnm +/.recommenders/index/http___download_eclipse_org_recommenders_models_mars_/_0.frq +/.recommenders/index/http___download_eclipse_org_recommenders_models_mars_/_0.nrm +/.recommenders/index/http___download_eclipse_org_recommenders_models_mars_/_0.prx +/.recommenders/index/http___download_eclipse_org_recommenders_models_mars_/_0.tii +/.recommenders/index/http___download_eclipse_org_recommenders_models_mars_/_0.tis +/.recommenders/index/http___download_eclipse_org_recommenders_models_mars_/segments.gen +/.recommenders/index/http___download_eclipse_org_recommenders_models_mars_/segments_1 +/.recommenders/index/http___download_eclipse_org_recommenders_models_mars_/write.lock diff --git a/Plugins/BuildFiles/common.xml b/Plugins/BuildFiles/common.xml index 5141a3cb9..3359861d8 100644 --- a/Plugins/BuildFiles/common.xml +++ b/Plugins/BuildFiles/common.xml @@ -86,6 +86,9 @@ + + + @@ -152,6 +155,9 @@ + + + @@ -198,6 +204,9 @@ + + + @@ -234,6 +243,9 @@ + + + diff --git a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerStats/PlayerStats.java b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerStats/PlayerStats.java index c15651813..4547d4732 100644 --- a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerStats/PlayerStats.java +++ b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerStats/PlayerStats.java @@ -1,6 +1,5 @@ package mineplex.bungee.playerStats; -import java.util.HashMap; import java.util.HashSet; import java.util.UUID; import java.util.concurrent.TimeUnit; @@ -17,9 +16,8 @@ import net.md_5.bungee.event.EventHandler; public class PlayerStats implements Listener, Runnable { private Plugin _plugin; - private PlayerStatsRepository _repository; + private PlayerStatsRepository _repository; - private PlayerCache _playerCache = new PlayerCache(); private HashSet _retrievingPlayerInfo = new HashSet(); public PlayerStats(Plugin plugin) @@ -52,7 +50,7 @@ public class PlayerStats implements Listener, Runnable boolean addOrUpdatePlayer = false; - playerInfo = _playerCache.getPlayer(uuid); + playerInfo = PlayerCache.getInstance().getPlayer(uuid); if (playerInfo == null) { @@ -81,11 +79,11 @@ public class PlayerStats implements Listener, Runnable else playerInfo = updatedPlayerInfo; - _playerCache.addPlayer(playerInfo); + PlayerCache.getInstance().addPlayer(playerInfo); } playerInfo.setSessionId(_repository.updatePlayerStats(playerInfo.getId(), ipInfo.id)); - _playerCache.addPlayer(playerInfo); + PlayerCache.getInstance().addPlayer(playerInfo); } finally { @@ -106,13 +104,13 @@ public class PlayerStats implements Listener, Runnable PlayerInfo playerInfo = null; - playerInfo = _playerCache.getPlayer(uuid); + playerInfo = PlayerCache.getInstance().getPlayer(uuid); int timeout = 5; while (playerInfo == null && _retrievingPlayerInfo.contains(uuid) && timeout <= 5) { - playerInfo = _playerCache.getPlayer(uuid); + playerInfo = PlayerCache.getInstance().getPlayer(uuid); if (playerInfo != null) break; @@ -140,6 +138,6 @@ public class PlayerStats implements Listener, Runnable @Override public void run() { - _playerCache.clean(); + PlayerCache.getInstance().clean(); } } diff --git a/Plugins/Mineplex.Core/.classpath b/Plugins/Mineplex.Core/.classpath index 8171cd881..7dba3b7ca 100644 --- a/Plugins/Mineplex.Core/.classpath +++ b/Plugins/Mineplex.Core/.classpath @@ -14,5 +14,6 @@ + diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/AccountCache.java b/Plugins/Mineplex.Core/src/mineplex/core/account/AccountCache.java deleted file mode 100644 index e6ac95b35..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/AccountCache.java +++ /dev/null @@ -1,33 +0,0 @@ -package mineplex.core.account; - -import java.util.UUID; - -import mineplex.serverdata.data.Data; - -public class AccountCache implements Data -{ - private UUID _uuid; - private Integer _id; - - public AccountCache(UUID uuid, int id) - { - _uuid = uuid; - _id = id; - } - - public UUID getUUID() - { - return _uuid; - } - - public int getId() - { - return _id; - } - - @Override - public String getDataId() - { - return _uuid.toString(); - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java index 48ea446a6..8bf3fddcf 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java @@ -22,10 +22,8 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.timing.TimingManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import mineplex.serverdata.Region; -import mineplex.serverdata.data.BungeeServer; -import mineplex.serverdata.redis.RedisDataRepository; -import mineplex.serverdata.servers.ServerManager; +import mineplex.playerCache.PlayerCache; +import mineplex.playerCache.PlayerInfo; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; @@ -48,7 +46,6 @@ public class CoreClientManager extends MiniPlugin private AccountRepository _repository; private NautHashMap _clientList; private HashSet _duplicateLoginGlitchPreventionList; - private RedisDataRepository _accountCacheRepository; private NautHashMap _loginProcessors = new NautHashMap(); private LinkedList _querylessLoginProcessors = new LinkedList(); @@ -66,9 +63,6 @@ public class CoreClientManager extends MiniPlugin _repository = new AccountRepository(plugin, webServer); _clientList = new NautHashMap(); _duplicateLoginGlitchPreventionList = new HashSet(); - - _accountCacheRepository = new RedisDataRepository(ServerManager.getMasterConnection(), ServerManager.getSlaveConnection(), - Region.ALL, AccountCache.class, "accountCache"); } public AccountRepository getRepository() @@ -251,7 +245,15 @@ public class CoreClientManager extends MiniPlugin Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid)); if (client.getAccountId() > 0) - _accountCacheRepository.addElement(new AccountCache(uuid, client.getAccountId()), 60 * 60 * 6); + { + PlayerInfo playerInfo = PlayerCache.getInstance().getPlayer(uuid); + + if (playerInfo != null) + { + playerInfo.setAccountId(client.getAccountId()); + PlayerCache.getInstance().addPlayer(playerInfo); + } + } } catch (Exception exception) { @@ -326,13 +328,12 @@ public class CoreClientManager extends MiniPlugin if (client.getAccountId() > 0) { - try + PlayerInfo playerInfo = PlayerCache.getInstance().getPlayer(uuid); + + if (playerInfo != null) { - _accountCacheRepository.addElement(new AccountCache(uuid, client.getAccountId()), 60 * 60 * 6); - } - catch (Exception e) - { - e.printStackTrace(); + playerInfo.setAccountId(client.getAccountId()); + PlayerCache.getInstance().addPlayer(playerInfo); } } @@ -544,9 +545,4 @@ public class CoreClientManager extends MiniPlugin return client.GetRank().has(rank); } - - public int getCachedClientAccountId(UUID uuid) - { - return _accountCacheRepository.getElement(uuid.toString()).getId(); - } } \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java index 71f7ea718..31a02818b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java @@ -24,6 +24,7 @@ import mineplex.core.donation.repository.token.DonorTokenWrapper; import mineplex.core.server.util.TransactionResponse; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.playerCache.PlayerCache; public class DonationManager extends MiniDbClientPlugin { @@ -279,7 +280,7 @@ public class DonationManager extends MiniDbClientPlugin { public void run() { - RewardCoins(null, caller, player.getName(), ClientManager.getCachedClientAccountId(player.getUniqueId()), total, false); + RewardCoins(null, caller, player.getName(), PlayerCache.getInstance().getPlayer(player.getUniqueId()).getAccountId(), total, false); } }); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/inventory/InventoryManager.java b/Plugins/Mineplex.Core/src/mineplex/core/inventory/InventoryManager.java index 8c87db300..8117ceeed 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/inventory/InventoryManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/inventory/InventoryManager.java @@ -21,6 +21,7 @@ import mineplex.core.inventory.data.InventoryRepository; import mineplex.core.inventory.data.Item; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.playerCache.PlayerCache; public class InventoryManager extends MiniDbClientPlugin { @@ -180,7 +181,7 @@ public class InventoryManager extends MiniDbClientPlugin synchronized (_inventoryLock) { - final boolean success = _repository.incrementClientInventoryItem(ClientManager.getCachedClientAccountId(uuid), _items.get(item).Id, count); + final boolean success = _repository.incrementClientInventoryItem(PlayerCache.getInstance().getPlayer(uuid).getAccountId(), _items.get(item).Id, count); if (callback != null) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java index 38051c268..addbfc4bd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java @@ -23,6 +23,7 @@ import mineplex.core.common.util.UtilServer; import mineplex.core.stats.command.GiveStatCommand; import mineplex.core.stats.command.TimeCommand; import mineplex.core.stats.event.StatChangeEvent; +import mineplex.playerCache.PlayerCache; public class StatsManager extends MiniDbClientPlugin { @@ -139,7 +140,7 @@ public class StatsManager extends MiniDbClientPlugin if (player.isOnline()) continue; - int uploadKey = ClientManager.getCachedClientAccountId(player.getUniqueId()); + int uploadKey = PlayerCache.getInstance().getPlayer(player.getUniqueId()).getAccountId(); uploadQueue.put(uploadKey, new NautHashMap()); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/task/TaskManager.java b/Plugins/Mineplex.Core/src/mineplex/core/task/TaskManager.java index 2ecce2580..83f495718 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/task/TaskManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/task/TaskManager.java @@ -14,6 +14,7 @@ import mineplex.core.account.CoreClientManager; import mineplex.core.common.util.Callback; import mineplex.core.common.util.NautHashMap; import mineplex.core.task.repository.TaskRepository; +import mineplex.playerCache.PlayerCache; public class TaskManager extends MiniDbClientPlugin { @@ -68,7 +69,7 @@ public class TaskManager extends MiniDbClientPlugin synchronized (_taskLock) { - final boolean success = _repository.addAccountTask(ClientManager.getCachedClientAccountId(uuid), _tasks.get(task)); + final boolean success = _repository.addAccountTask(PlayerCache.getInstance().getPlayer(uuid).getAccountId(), _tasks.get(task)); if (callback != null) { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java index 553848414..ac3c3dc40 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java @@ -4,6 +4,7 @@ import org.bukkit.plugin.java.JavaPlugin; import net.minecraft.server.v1_7_R4.MinecraftServer; import mineplex.core.account.CoreClientManager; +import mineplex.core.achievement.AchievementManager; import mineplex.core.antihack.AntiHack; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.chat.Chat; @@ -23,6 +24,7 @@ import mineplex.core.punish.Punish; import mineplex.core.recharge.Recharge; import mineplex.core.serverConfig.ServerConfiguration; import mineplex.core.spawn.Spawn; +import mineplex.core.stats.StatsManager; import mineplex.core.status.ServerStatusManager; import mineplex.core.teleport.Teleport; import mineplex.core.updater.FileUpdater; @@ -79,7 +81,7 @@ public class Clans extends JavaPlugin BlockRestore blockRestore = new BlockRestore(this); IgnoreManager ignoreManager = new IgnoreManager(this, _clientManager, preferenceManager, portal); - Chat chat = new Chat(this, _clientManager, preferenceManager, serverStatusManager.getCurrentServerName()); + Chat chat = new Chat(this, _clientManager, preferenceManager, new AchievementManager(new StatsManager(this, _clientManager), _clientManager, _donationManager), serverStatusManager.getCurrentServerName()); new MessageManager(this, _clientManager, preferenceManager, ignoreManager, punish, new FriendManager(this, _clientManager, preferenceManager, portal), chat); new MemoryFix(this); diff --git a/Plugins/Mineplex.PlayerCache/src/mineplex/playerCache/PlayerCache.java b/Plugins/Mineplex.PlayerCache/src/mineplex/playerCache/PlayerCache.java index 15cffb719..cf320dbde 100644 --- a/Plugins/Mineplex.PlayerCache/src/mineplex/playerCache/PlayerCache.java +++ b/Plugins/Mineplex.PlayerCache/src/mineplex/playerCache/PlayerCache.java @@ -8,9 +8,19 @@ import mineplex.serverdata.servers.ServerManager; public class PlayerCache { + private static PlayerCache _instance = null; + private RedisDataRepository _repository; - public PlayerCache() + public static PlayerCache getInstance() + { + if (_instance == null) + _instance = new PlayerCache(); + + return _instance; + } + + private PlayerCache() { _repository = new RedisDataRepository( ServerManager.getMasterConnection(), @@ -22,12 +32,30 @@ public class PlayerCache public void addPlayer(PlayerInfo player) { - _repository.addElement(player, 60 * 60 * 6); // 6 Hours + try + { + _repository.addElement(player, 60 * 60 * 6); // 6 Hours + } + catch (Exception exception) + { + System.out.println("Error adding player info in PlayerCache : " + exception.getMessage()); + exception.printStackTrace(); + } } public PlayerInfo getPlayer(UUID uuid) { - return _repository.getElement(uuid.toString()); + try + { + return _repository.getElement(uuid.toString()); + } + catch (Exception exception) + { + System.out.println("Error retrieving player info in PlayerCache : " + exception.getMessage()); + exception.printStackTrace(); + } + + return null; } public void clean() diff --git a/Plugins/Mineplex.PlayerCache/src/mineplex/playerCache/PlayerInfo.java b/Plugins/Mineplex.PlayerCache/src/mineplex/playerCache/PlayerInfo.java index 700839ccb..636981ede 100644 --- a/Plugins/Mineplex.PlayerCache/src/mineplex/playerCache/PlayerInfo.java +++ b/Plugins/Mineplex.PlayerCache/src/mineplex/playerCache/PlayerInfo.java @@ -7,6 +7,7 @@ import mineplex.serverdata.data.Data; public class PlayerInfo implements Data { private int _id; + private int _accountId; private UUID _uuid; private String _name; private boolean _online; @@ -34,6 +35,11 @@ public class PlayerInfo implements Data return _id; } + public int getAccountId() + { + return _accountId; + } + public UUID getUUID() { return _uuid; @@ -83,4 +89,9 @@ public class PlayerInfo implements Data { _version = version; } + + public void setAccountId(int accountId) + { + _accountId = accountId; + } } diff --git a/Plugins/Mineplex.StaffServer/.classpath b/Plugins/Mineplex.StaffServer/.classpath index acc97657a..e03947a20 100644 --- a/Plugins/Mineplex.StaffServer/.classpath +++ b/Plugins/Mineplex.StaffServer/.classpath @@ -11,6 +11,6 @@ - + diff --git a/Plugins/Mineplex.StaffServer/.settings/org.eclipse.jdt.core.prefs b/Plugins/Mineplex.StaffServer/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 7341ab168..000000000 --- a/Plugins/Mineplex.StaffServer/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,11 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.7 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.7