From 5df7a5e0c9f01eb08dd2de2a9b479f9ec45fe8aa Mon Sep 17 00:00:00 2001 From: Ty Sayers Date: Sat, 29 Aug 2015 17:31:54 -0700 Subject: [PATCH 1/2] Fix bugs related to multiple server UI and clan server transferring. --- Plugins/BuildFiles/common.xml | 3 + ...ngeCommand.java => ClanDeleteCommand.java} | 6 +- .../game/clans/core/ClanLoadCommand.java | 23 +++++++ .../clans/core/repository/ClanRepository.java | 68 +++++++++++++------ .../clans/clans/ClansDataAccessLayer.java | 12 +++- .../game/clans/clans/ClansDisplay.java | 2 +- .../game/clans/clans/ClansManager.java | 30 +++++--- ...ler.java => ClanDeleteCommandHandler.java} | 8 +-- .../clans/redis/ClanLoadCommandHandler.java | 41 +++++++++++ .../game/clans/items/GearManager.java | 2 +- .../mineplex/hub/server/ServerManager.java | 1 + .../src/mineplex/hub/server/ui/LobbyMenu.java | 2 +- .../mineplex/hub/server/ui/ServerNpcShop.java | 4 +- .../server/ui/clans/ClanMoveServerButton.java | 11 ++- .../hub/server/ui/clans/ClansServerPage.java | 2 +- .../redis/RedisServerRepository.java | 6 ++ 16 files changed, 171 insertions(+), 50 deletions(-) rename Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/{ClanServerChangeCommand.java => ClanDeleteCommand.java} (71%) create mode 100644 Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/ClanLoadCommand.java rename Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/redis/{ClanServerChangeHandler.java => ClanDeleteCommandHandler.java} (75%) create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/redis/ClanLoadCommandHandler.java diff --git a/Plugins/BuildFiles/common.xml b/Plugins/BuildFiles/common.xml index 103162fb8..7bf9af7e2 100644 --- a/Plugins/BuildFiles/common.xml +++ b/Plugins/BuildFiles/common.xml @@ -186,6 +186,9 @@ + + + diff --git a/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/ClanServerChangeCommand.java b/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/ClanDeleteCommand.java similarity index 71% rename from Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/ClanServerChangeCommand.java rename to Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/ClanDeleteCommand.java index 6a4422bd5..ed982367b 100644 --- a/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/ClanServerChangeCommand.java +++ b/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/ClanDeleteCommand.java @@ -4,19 +4,19 @@ import mineplex.game.clans.core.repository.tokens.SimpleClanToken; import mineplex.serverdata.commands.ServerCommand; -public class ClanServerChangeCommand extends ServerCommand +public class ClanDeleteCommand extends ServerCommand { private String _clanName; public String getClanName() { return _clanName; } - public ClanServerChangeCommand(String serverName, String clanName) + public ClanDeleteCommand(String serverName, String clanName) { super(serverName); _clanName = clanName; } - public ClanServerChangeCommand(SimpleClanToken clan) + public ClanDeleteCommand(SimpleClanToken clan) { this(clan.getHomeServer(), clan.getClanName()); } diff --git a/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/ClanLoadCommand.java b/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/ClanLoadCommand.java new file mode 100644 index 000000000..b0d28e6bd --- /dev/null +++ b/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/ClanLoadCommand.java @@ -0,0 +1,23 @@ +package mineplex.game.clans.core; + +import mineplex.serverdata.commands.ServerCommand; + + +public class ClanLoadCommand extends ServerCommand +{ + private String _clanName; + public String getClanName() { return _clanName; } + + public ClanLoadCommand(String serverName, String clanName) + { + super(serverName); + + _clanName = clanName; + } + + @Override + public void run() + { + // Utilitizes a callback functionality to seperate dependencies + } +} diff --git a/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/repository/ClanRepository.java b/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/repository/ClanRepository.java index 2c757ecfa..340318efa 100644 --- a/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/repository/ClanRepository.java +++ b/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/repository/ClanRepository.java @@ -41,11 +41,11 @@ public class ClanRepository extends RepositoryBase private static String CREATE_CLAN_TERRITORY_TABLE = "CREATE TABLE IF NOT EXISTS clanTerritory (id INT NOT NULL AUTO_INCREMENT, clanId INT, serverId INT NOT NULL, chunk VARCHAR(100), safe BIT(1), PRIMARY KEY (id), FOREIGN KEY (clanId) REFERENCES clans(id), INDEX clanIdIndex (clanId, serverId));"; private static String CREATE_CLAN_ALLIANCE_TABLE = "CREATE TABLE IF NOT EXISTS clanAlliances (id INT NOT NULL AUTO_INCREMENT, clanId INT, otherClanId INT, trusted BIT(1), PRIMARY KEY (id), FOREIGN KEY (otherClanId) REFERENCES clans(id), FOREIGN KEY (clanId) REFERENCES clans(id), INDEX clanIdIndex (clanId));"; - private static String RETRIEVE_CLAN_INFO = "SELECT c.id, c.name, c.description, c.home, c.admin, c.energy, c.kills, c.murder, c.deaths, c.warWins, c.warLosses, c.dateCreated, c.lastOnline FROM clans AS c WHERE lower(c.name) = ?;"; + private static String RETRIEVE_CLAN_INFO = "SELECT c.id, c.name, c.description, c.home, c.admin, c.energy, c.kills, c.murder, c.deaths, c.warWins, c.warLosses, c.generator, c.generatorStock, c.dateCreated, c.lastOnline FROM clans AS c WHERE lower(c.name) = ?;"; private static String RETRIEVE_PLAYER_CLAN_INFO = "SELECT clans.name, accountClan.clanRole, clanServer.serverName, clans.id FROM accountClan INNER JOIN clans ON clans.id = accountClan.clanId INNER JOIN clanServer ON clans.serverId = clanServer.id WHERE accountClan.accountId = ?;"; private static String RETRIEVE_START_CLAN_INFO = "SELECT c.id, c.name, c.description, c.home, c.admin, c.energy, c.kills, c.murder, c.deaths, c.warWins, c.warLosses, c.generator, c.generatorStock, c.dateCreated, c.lastOnline, ct.chunk, ct.safe FROM clans AS c LEFT JOIN clanTerritory AS ct ON ct.clanId = c.id WHERE c.serverId = ?;"; - private static String RETRIEVE_CLAN_MEMBER_INFO = "SELECT c.name, a.name, a.uuid, clanRole FROM accountClan AS ac INNER JOIN accounts AS a ON a.id = ac.accountId INNER JOIN clans AS c on c.id = ac.clanId WHERE c.serverId = ?;"; + private static String RETRIEVE_CLAN_MEMBERS = "SELECT c.name, a.name, a.uuid, clanRole FROM accountClan AS ac INNER JOIN accounts AS a ON a.id = ac.accountId INNER JOIN clans AS c on c.id = ac.clanId WHERE lower(c.name) = ?;"; private static String RETRIEVE_CLAN_ALLIANCE_INFO = "SELECT c.name, cOther.name, ca.trusted FROM clanAlliances AS ca INNER JOIN clans AS c ON c.id = ca.clanId INNER JOIN clans as cOther ON cOther.id = ca.otherClanId WHERE c.serverId = ?;"; private static String RETRIEVE_CLAN_ENEMY_INFO = "SELECT c.name, cOther.name, clanScore, otherClanScore, clanKills, otherClanKills, timeFormed FROM clanEnemies AS ce INNER JOIN clans AS c ON c.id = ce.clanId INNER JOIN clans as cOther ON cOther.id = ce.otherClanId WHERE c.serverId = ?;"; @@ -164,8 +164,10 @@ public class ClanRepository extends RepositoryBase } - public void retrieveClan(String clanName, final Callback callback) + public ClanToken retrieveClan(String clanName) { + final ClanToken clan = new ClanToken(); + executeQuery(RETRIEVE_CLAN_INFO, new ResultSetCallable() { @Override @@ -173,25 +175,49 @@ public class ClanRepository extends RepositoryBase { if (resultSet.next()) { - ClanToken token = new ClanToken(); - token.Id = resultSet.getInt(1); - token.Name = resultSet.getString(2); - token.Description = resultSet.getString(3); - token.Home = resultSet.getString(4); - token.Admin = resultSet.getBoolean(5); - token.Energy = resultSet.getInt(6); - token.Kills = resultSet.getInt(7); - token.Murder = resultSet.getInt(8); - token.Deaths = resultSet.getInt(9); - token.WarWins = resultSet.getInt(10); - token.WarLosses = resultSet.getInt(11); - token.DateCreated = resultSet.getTimestamp(12); - token.LastOnline = resultSet.getTimestamp(13); - - callback.run(token); + if (resultSet.next()) + { + clan.Id = resultSet.getInt(1); + clan.Name = resultSet.getString(2); + clan.Description = resultSet.getString(3); + clan.Home = resultSet.getString(4); + clan.Admin = resultSet.getBoolean(5); + clan.Energy = resultSet.getInt(6); + clan.Kills = resultSet.getInt(7); + clan.Murder = resultSet.getInt(8); + clan.Deaths = resultSet.getInt(9); + clan.WarWins = resultSet.getInt(10); + clan.WarLosses = resultSet.getInt(11); + clan.Generator = resultSet.getString(12); + clan.GeneratorStock = resultSet.getInt(13); + clan.DateCreated = resultSet.getTimestamp(14); + clan.LastOnline = resultSet.getTimestamp(15); + } } } }, new ColumnVarChar("name", 100, clanName.toLowerCase())); + + executeQuery(RETRIEVE_CLAN_MEMBERS, new ResultSetCallable() + { + @Override + public void processResultSet(ResultSet resultSet) throws SQLException + { + while (resultSet.next()) + { + String clanName = resultSet.getString(1); + + ClanMemberToken memberToken = new ClanMemberToken(); + memberToken.Name = resultSet.getString(2); + memberToken.PlayerUUID = UUID.fromString(resultSet.getString(3)); + memberToken.ClanRole = resultSet.getString(4); + + clan.Members.add(memberToken); + } + } + + }, new ColumnVarChar("name", 100, clanName.toLowerCase())); + + return clan; } public void clanExists(String clanName, final Callback callback) @@ -228,7 +254,7 @@ public class ClanRepository extends RepositoryBase } }, new ColumnInt("accountId", accountId)); } - + public Collection retrieveClans() { System.out.println("Beginning to load clans from database..."); @@ -240,7 +266,7 @@ public class ClanRepository extends RepositoryBase public void processResultSet(ResultSet resultSet) throws SQLException { while (resultSet.next()) - { + { ClanToken token = new ClanToken(); token.Id = resultSet.getInt(1); token.Name = resultSet.getString(2); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDataAccessLayer.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDataAccessLayer.java index 94304525a..88c41036d 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDataAccessLayer.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDataAccessLayer.java @@ -684,9 +684,17 @@ public class ClansDataAccessLayer _manager.log("Safe Zone at [" + claim.Chunk + "] set to [" + claim.Safe + "] by [" + player + "]."); } - public void retrieveClan(String clanName, Callback callback) + public void retrieveClan(final String clanName, final Callback callback) { - _repository.retrieveClan(clanName, callback); + runAsync(new Runnable() + { + @Override + public void run() + { + ClanToken clan = _repository.retrieveClan(clanName); + callback.run(clan); + } + }); } public void clanExists(String clanName, Callback callback) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDisplay.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDisplay.java index f16010650..6cb5c945f 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDisplay.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDisplay.java @@ -58,7 +58,7 @@ public class ClansDisplay extends MiniPlugin //Update Territory client.setTerritory(UtilWorld.chunkToStr(player.getLocation().getChunk())); - + //AutoClaim if (client.isAutoClaim()) Clans.getClanAdmin().claim(player); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java index 9928c0433..6d7733441 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java @@ -64,14 +64,16 @@ import mineplex.game.clans.clans.commands.ServerTimeCommand; import mineplex.game.clans.clans.loot.LootManager; import mineplex.game.clans.clans.map.ItemMapManager; import mineplex.game.clans.clans.murder.MurderManager; -import mineplex.game.clans.clans.redis.ClanServerChangeHandler; +import mineplex.game.clans.clans.redis.ClanDeleteCommandHandler; +import mineplex.game.clans.clans.redis.ClanLoadCommandHandler; import mineplex.game.clans.clans.regions.ClansRegions; import mineplex.game.clans.clans.scoreboard.ClansScoreboardManager; import mineplex.game.clans.clans.tntGenerator.TntGeneratorManager; import mineplex.game.clans.clans.war.WarManager; import mineplex.game.clans.economy.GoldManager; import mineplex.game.clans.clans.worldevent.WorldEventManager; -import mineplex.game.clans.core.ClanServerChangeCommand; +import mineplex.game.clans.core.ClanDeleteCommand; +import mineplex.game.clans.core.ClanLoadCommand; import mineplex.game.clans.core.repository.ClanTerritory; import mineplex.game.clans.core.repository.tokens.ClanMemberToken; import mineplex.game.clans.core.repository.tokens.ClanTerritoryToken; @@ -226,7 +228,8 @@ public class ClansManager extends MiniClientPlugin implements IRelat _classManager = new ClassManager(plugin, _clientManager, donationManager, skillManager, itemFactory, webServerAddress); // Register redis based server commands - ServerCommandManager.getInstance().registerCommandType(ClanServerChangeCommand.class, new ClanServerChangeHandler()); + ServerCommandManager.getInstance().registerCommandType(ClanDeleteCommand.class, new ClanDeleteCommandHandler()); + ServerCommandManager.getInstance().registerCommandType(ClanLoadCommand.class, new ClanLoadCommandHandler()); StatsManager statsManager = new StatsManager(plugin, _clientManager); AchievementManager achievementManager = new AchievementManager(statsManager, _clientManager, donationManager); @@ -237,14 +240,7 @@ public class ClansManager extends MiniClientPlugin implements IRelat for (ClanToken token : _clanDataAccess.getRepository().retrieveClans()) { - ClanInfo clan = new ClanInfo(this, token); - _clanMap.put(token.Name, clan); - - for (ClanMemberToken memberToken : token.Members) - _clanMemberMap.put(memberToken.Name, clan); - - for (ClanTerritoryToken territoryToken : token.Territories) - _claimMap.put(territoryToken.Chunk, new ClanTerritory(territoryToken)); + loadClan(token); } //RedisDataRepository(ConnectionData writeConn, ConnectionData readConn, Region region, Class elementType, String elementLabel) @@ -265,6 +261,18 @@ public class ClansManager extends MiniClientPlugin implements IRelat addCommand(new MapCommand(this)); } + public void loadClan(ClanToken clanToken) + { + ClanInfo clan = new ClanInfo(this, clanToken); + _clanMap.put(clanToken.Name, clan); + + for (ClanMemberToken memberToken : clanToken.Members) + _clanMemberMap.put(memberToken.Name, clan); + + for (ClanTerritoryToken territoryToken : clanToken.Territories) + _claimMap.put(territoryToken.Chunk, new ClanTerritory(territoryToken)); + } + public DisguiseManager getDisguiseManager() { return _disguiseManager; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/redis/ClanServerChangeHandler.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/redis/ClanDeleteCommandHandler.java similarity index 75% rename from Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/redis/ClanServerChangeHandler.java rename to Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/redis/ClanDeleteCommandHandler.java index 6e794960c..c08e9425c 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/redis/ClanServerChangeHandler.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/redis/ClanDeleteCommandHandler.java @@ -3,18 +3,18 @@ package mineplex.game.clans.clans.redis; import mineplex.core.common.util.UtilPlayer; import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.ClansManager; -import mineplex.game.clans.core.ClanServerChangeCommand; +import mineplex.game.clans.core.ClanDeleteCommand; import mineplex.serverdata.commands.CommandCallback; import mineplex.serverdata.commands.ServerCommand; -public class ClanServerChangeHandler implements CommandCallback +public class ClanDeleteCommandHandler implements CommandCallback { public void run(ServerCommand command) { - if (command instanceof ClanServerChangeCommand) + if (command instanceof ClanDeleteCommand) { - ClanServerChangeCommand serverCommand = (ClanServerChangeCommand) command; + ClanDeleteCommand serverCommand = (ClanDeleteCommand) command; String clanName = serverCommand.getClanName(); ClanInfo clanInfo = ClansManager.getInstance().getClan(clanName); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/redis/ClanLoadCommandHandler.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/redis/ClanLoadCommandHandler.java new file mode 100644 index 000000000..54274dd5d --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/redis/ClanLoadCommandHandler.java @@ -0,0 +1,41 @@ +package mineplex.game.clans.clans.redis; + +import mineplex.core.common.util.Callback; +import mineplex.core.common.util.UtilPlayer; +import mineplex.game.clans.clans.ClanInfo; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.core.ClanDeleteCommand; +import mineplex.game.clans.core.ClanLoadCommand; +import mineplex.game.clans.core.repository.tokens.ClanToken; +import mineplex.serverdata.commands.CommandCallback; +import mineplex.serverdata.commands.ServerCommand; + +public class ClanLoadCommandHandler implements CommandCallback +{ + + public void run(ServerCommand command) + { + if (command instanceof ClanLoadCommand) + { + ClanLoadCommand serverCommand = (ClanLoadCommand) command; + final String clanName = serverCommand.getClanName(); + + ClansManager.getInstance().getClanDataAccess().retrieveClan(clanName, new Callback() + { + @Override + public void run(ClanToken clan) + { + if (clan != null) + { + ClansManager.getInstance().loadClan(clan); // Load the clan data locally + System.out.println("Successfully finished loading and transferring clan '" + clanName + "'!"); + } + else + { + System.out.println("ERROR: UNABLE TO LOAD CLAN " + clanName + " DURING REMOTE CLAN LOAD COMMAND!"); + } + } + }); + } + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java index 464a8dbb9..c81cc00c5 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/GearManager.java @@ -38,7 +38,7 @@ import mineplex.serverdata.serialization.RuntimeTypeAdapterFactory; import mineplex.serverdata.servers.ServerManager; import net.minecraft.server.v1_7_R4.Packet; import net.minecraft.server.v1_7_R4.PacketPlayOutSetSlot; -import net.minecraft.util.com.google.common.collect.Sets; +import net.minecraft.util.com.google.common.collect.Sets; import org.bukkit.Bukkit; import org.bukkit.Location; diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java index 7da629370..ff9387b1f 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java @@ -683,6 +683,7 @@ public class ServerManager extends MiniPlugin { for (ServerGroup serverGroup : mineplex.serverdata.servers.ServerManager.getServerRepository(region).getServerGroups(null)) { + System.out.println("ADDING SERVER GROUP: " + serverGroup.getName()); addServerGroup(serverGroup); if (!serverGroup.getServerNpcName().isEmpty()) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/LobbyMenu.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/LobbyMenu.java index 2e743365c..4e41582fa 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/LobbyMenu.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/LobbyMenu.java @@ -32,7 +32,7 @@ public class LobbyMenu extends ShopPageBase implements buildPage(); } - @Override + @Override protected void buildPage() { List serverList = new ArrayList(getPlugin().getServerList(_serverGroup)); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcShop.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcShop.java index 16e3ccfa7..100a4689d 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcShop.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcShop.java @@ -31,12 +31,12 @@ public class ServerNpcShop extends ShopBase { return new ServerTypePage(getPlugin(), this, getClientManager(), getDonationManager(), player, _serverGroup); } - else + else { return new ServerNpcPage(getPlugin(), this, getClientManager(), getDonationManager(), _serverGroup.getServerNpcName(), player, _serverGroup.getPrefix()); } - } + } @Override protected boolean canOpenShop(Player player) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/clans/ClanMoveServerButton.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/clans/ClanMoveServerButton.java index 72908145b..026328740 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/clans/ClanMoveServerButton.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/clans/ClanMoveServerButton.java @@ -5,7 +5,8 @@ import org.bukkit.event.inventory.ClickType; import mineplex.core.common.util.Callback; import mineplex.core.shop.item.IButton; -import mineplex.game.clans.core.ClanServerChangeCommand; +import mineplex.game.clans.core.ClanDeleteCommand; +import mineplex.game.clans.core.ClanLoadCommand; import mineplex.game.clans.core.repository.ClanRepository; import mineplex.game.clans.core.repository.tokens.SimpleClanToken; @@ -33,8 +34,12 @@ public class ClanMoveServerButton implements IButton { if (success) { - ClanServerChangeCommand changeCommand = new ClanServerChangeCommand(_clan); - changeCommand.publish(); + ClanDeleteCommand deleteCommand = new ClanDeleteCommand(_clan); + ClanLoadCommand loadCommand = new ClanLoadCommand(_serverName, _clan.getClanName()); + + deleteCommand.publish(); + loadCommand.publish(); + System.out.println("Successfully finished moving clan to new home server!"); } else diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/clans/ClansServerPage.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/clans/ClansServerPage.java index d5c16fdfd..24506d9eb 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/clans/ClansServerPage.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/clans/ClansServerPage.java @@ -75,7 +75,7 @@ public class ClansServerPage extends ShopPageBase servers = getPlugin().getServerList("Clans"); - + int currentSlot = 9; for (ServerInfo server : servers) { diff --git a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/redis/RedisServerRepository.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/redis/RedisServerRepository.java index 971c8dd24..50b3bee6a 100644 --- a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/redis/RedisServerRepository.java +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/redis/RedisServerRepository.java @@ -311,6 +311,12 @@ public class RedisServerRepository implements ServerRepository { Map data = response.get(); + if (data.entrySet().size() == 0) + { + System.out.println("Encountered empty map! Skipping..."); + continue; + } + try { ServerGroup serverGroup = new ServerGroup(data, serverStatuses); From b0c657b5c0d0448d92239ded1f9d75befd614b90 Mon Sep 17 00:00:00 2001 From: Ty Sayers Date: Sat, 29 Aug 2015 17:33:01 -0700 Subject: [PATCH 2/2] Fix bug where generator location per-clan wasn't being reset properly on server transfer. --- .../src/mineplex/game/clans/core/repository/ClanRepository.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/repository/ClanRepository.java b/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/repository/ClanRepository.java index 340318efa..64f256ce2 100644 --- a/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/repository/ClanRepository.java +++ b/Plugins/Mineplex.Game.Clans.Core/src/mineplex/game/clans/core/repository/ClanRepository.java @@ -70,7 +70,7 @@ public class ClanRepository extends RepositoryBase private static String UPDATE_CLAN_ALLIANCE = "UPDATE clanAlliances SET trusted = ? WHERE clanId = ? AND otherClanId = ?;"; private static String UPDATE_CLAN_ENEMY = "UPDATE clanEnemies SET clanScore = ?, otherClanScore = ?, clanKills = ?, otherClanKills = ? WHERE clanId = ? AND otherClanId = ?;"; private static String UPDATE_CLAN_TERRITORY = "UPDATE clanTerritory SET safe = ? WHERE serverId = ? AND chunk = ?;"; - private static String UPDATE_CLAN_SERVER_ID = "UPDATE clans SET serverId = ?, home = '' WHERE id = ?;"; + private static String UPDATE_CLAN_SERVER_ID = "UPDATE clans SET serverId = ?, home = '', generator = '' WHERE id = ?;"; private static String UPDATE_CLAN_GENERATOR = "UPDATE clans SET generator = ?, generatorStock = ? WHERE id = ?;"; private static String GET_CLAN_SERVER = "SELECT id FROM clanServer WHERE clanServer.serverName = ?";