Make clans in the hub route through clans hubs

This commit is contained in:
AlexTheCoder 2016-07-25 11:18:10 -04:00
parent a1fd021f8d
commit 9a73784b7c
3 changed files with 51 additions and 173 deletions

View File

@ -1,7 +1,5 @@
package mineplex.hub.server;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@ -11,10 +9,44 @@ import java.util.List;
import java.util.Random;
import java.util.Set;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.boosters.BoosterManager;
import mineplex.core.brawl.fountain.BrawlShopProvider;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilTime.TimeUnit;
import mineplex.core.donation.DonationManager;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.party.Lang;
import mineplex.core.party.Party;
import mineplex.core.party.PartyManager;
import mineplex.core.party.event.PartySelectServerEvent;
import mineplex.core.portal.Portal;
import mineplex.core.recharge.Recharge;
import mineplex.core.shop.ShopBase;
import mineplex.core.status.ServerStatusManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.hub.HubManager;
import mineplex.hub.modules.StackerManager;
import mineplex.hub.queue.QueueManager;
import mineplex.hub.server.ui.LobbyShop;
import mineplex.hub.server.ui.QuickShop;
import mineplex.hub.server.ui.ServerCountSorter;
import mineplex.hub.server.ui.ServerNpcShop;
import mineplex.hub.server.ui.clans.ClansServerShop;
import mineplex.serverdata.Region;
import mineplex.serverdata.data.MinecraftServer;
import mineplex.serverdata.data.ServerGroup;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
@ -32,42 +64,7 @@ import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;
import mineplex.core.MiniDbClientPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilTime.TimeUnit;
import mineplex.core.donation.DonationManager;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.party.Party;
import mineplex.core.party.PartyManager;
import mineplex.core.portal.Portal;
import mineplex.core.recharge.Recharge;
import mineplex.core.shop.ShopBase;
import mineplex.core.status.ServerStatusManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.core.repository.tokens.SimpleClanToken;
import mineplex.hub.HubManager;
import mineplex.hub.modules.StackerManager;
import mineplex.hub.queue.QueueManager;
import mineplex.hub.server.ui.LobbyShop;
import mineplex.hub.server.ui.QuickShop;
import mineplex.hub.server.ui.ServerCountSorter;
import mineplex.hub.server.ui.ServerNpcShop;
import mineplex.hub.server.ui.clans.ClansServerShop;
import mineplex.serverdata.Region;
import mineplex.serverdata.data.MinecraftServer;
import mineplex.serverdata.data.ServerGroup;
public class ServerManager extends MiniDbClientPlugin<SimpleClanToken> implements BrawlShopProvider
public class ServerManager extends MiniPlugin implements BrawlShopProvider
{
private static final Long FREE_PORTAL_TIMER = -1L;
private static final Long BETA_PORTAL_TIMER = 120000L;
@ -107,7 +104,7 @@ public class ServerManager extends MiniDbClientPlugin<SimpleClanToken> implement
public ServerManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, Portal portal, PartyManager partyManager, ServerStatusManager statusManager, HubManager hubManager, StackerManager stackerManager, QueueManager queueManager, BoosterManager boosterManager)
{
super("Server Manager", plugin, clientManager);
super("Server Manager", plugin);
_clientManager = clientManager;
_donationManager = donationManager;
@ -919,38 +916,9 @@ public class ServerManager extends MiniDbClientPlugin<SimpleClanToken> implement
{
return _serverNpcShopMap.get("Bawk Bawk Battles");
}
@Override
public String getQuery(int accountId, String uuid, String name)
{
return "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 = " + accountId + ";";
}
@Override
public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException
{
SimpleClanToken clanToken = new SimpleClanToken();
while (resultSet.next())
{
String clanName = resultSet.getString(1);
String clanRole = resultSet.getString(2);
String homeServer = resultSet.getString(3);
int clanId = resultSet.getInt(4);
clanToken = new SimpleClanToken(clanName, clanRole, homeServer, clanId);
}
Set(playerName, clanToken);
}
@Override
protected SimpleClanToken addPlayer(String player)
{
return new SimpleClanToken();
}
public BoosterManager getBoosterManager()
{
return _boosterManager;
}
}
}

View File

@ -2,35 +2,26 @@ package mineplex.hub.server.ui.clans;
import java.util.Collection;
import java.util.Comparator;
import java.util.TreeSet;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.donation.DonationManager;
import mineplex.core.shop.item.DisplayButton;
import mineplex.core.shop.item.IButton;
import mineplex.core.shop.item.ShopItem;
import mineplex.core.shop.page.ShopPageBase;
import mineplex.game.clans.core.repository.ClanRepository;
import mineplex.game.clans.core.repository.tokens.SimpleClanToken;
import mineplex.hub.server.ServerInfo;
import mineplex.hub.server.ServerManager;
import mineplex.hub.server.ui.button.JoinServerButton;
import mineplex.serverdata.data.DataRepository;
import org.bukkit.Material;
import org.bukkit.entity.Player;
public class ClansServerPage extends ShopPageBase<ServerManager, ClansServerShop>
{
public ClansServerPage(ServerManager plugin, ClansServerShop shop, CoreClientManager clientManager,
DonationManager donationManager, Player player)
{
super(plugin, shop, clientManager, donationManager, "Clans Beta", player, 54);
super(plugin, shop, clientManager, donationManager, "Clans", player, 54);
buildPage();
}
@ -38,29 +29,12 @@ public class ClansServerPage extends ShopPageBase<ServerManager, ClansServerShop
@Override
protected void buildPage()
{
if (!getPlugin().Get(_player).getClanName().isEmpty())
{
buildClanPage(getPlugin().Get(_player));
}
else
{
buildNoClanPage();
}
buildHubsPage();
}
private void buildClanPage(SimpleClanToken clan)
private void buildHubsPage()
{
buildJoinHomeServer(clan);
// if (isLeader(clan))
// {
// buildMoveClan(clan);
// }
}
private void buildNoClanPage()
{
Collection<ServerInfo> servers = UtilAlg.sortSet(getPlugin().getServerList("Clans"), new Comparator<ServerInfo>()
Collection<ServerInfo> servers = UtilAlg.sortSet(getPlugin().getServerList("ClansHub"), new Comparator<ServerInfo>()
{
@Override
public int compare(ServerInfo o1, ServerInfo o2)
@ -77,72 +51,12 @@ public class ClansServerPage extends ShopPageBase<ServerManager, ClansServerShop
}
}
private boolean isLeader(SimpleClanToken clan)
{
return clan.getClanRole().equalsIgnoreCase("Leader");
}
private void buildJoinHomeServer(SimpleClanToken clan)
{
ServerInfo serverInfo = getServerInfo(clan.getHomeServer());
boolean serverOnline = (serverInfo != null);
String serverStatus = serverOnline ? C.cGreen + "Online" : C.cRed + "Offline";
String title = (serverOnline ? C.cGreen : C.cRed) + C.Bold + "Join Home Server!";
// String description = C.cGold + "Join your home server, " + C.cAqua + clan.getHomeServer() + C.cGold + "!";
String serverName = C.cYellow + "Server Name: " + C.cWhite + clan.getHomeServer();
String serverDesc = C.cYellow + "Server Status: " + C.cWhite + serverStatus;
String players = (serverOnline ? C.cYellow + "Players: " + C.cWhite + serverInfo.CurrentPlayers + "/" + serverInfo.MaxPlayers : "" );
String change = C.cRed + "Note: " + C.cWhite + "You must leave your Clan to ";
String change2 = C.cWhite + "play on a different Clans Server!";
ShopItem shopItem = new ShopItem(Material.EMERALD_BLOCK, title, new String[] {" ", serverName, serverDesc, players, " ", change, change2, " "}, 0, true, true);
addButton(13, shopItem, new JoinServerButton(this, getPlugin(), getServerInfo(clan.getHomeServer()), getPlayer()));
}
private void buildJoinServer(int slot, ServerInfo server)
{
String title = C.cGreen + C.Bold + "Join Clans Server!";
String desc1 = C.cYellow + "Server Name " + C.cWhite + server.Name;
String desc2 = C.cYellow + "Players " + C.cWhite + server.CurrentPlayers + "/" + server.MaxPlayers;
String desc3 = C.cRed + "Note: " + C.cWhite + "Creating or Joining a clan on this";
String desc4 = C.cWhite + "server will set your Home Server!";
String title = C.cGreen + server.Name;
String desc = C.cYellow + "Players: " + C.cWhite + server.CurrentPlayers + "/" + server.MaxPlayers;
ShopItem shopItem = new ShopItem(Material.GOLD_BLOCK, title, new String[] {" ", desc1, desc2, " ", desc3, desc4}, 0, true, true);
ShopItem shopItem = new ShopItem(Material.EMERALD_BLOCK, title, new String[] {" ", desc}, 0, true, true);
addButton(slot, shopItem, new JoinServerButton(this, getPlugin(), server, getPlayer()));
}
/*
private void buildMoveClan(final SimpleClanToken clan)
{
// Build button for moving clan to another server
String title = C.cRed + C.Bold + "Change Clan's Home Server!";
String description = C.cGold + "Move your clan to another server!";
String desc2 = C.Bold + C.cRed + "Warning: " + ChatColor.RESET + C.cGold + "Changing your clan's";
String desc3 = C.cGold + "home server will permanently unclaim";
String desc4 = C.cGold + "your land and prevent you from";
String desc5 = C.cGold + "joining the original server.";
ShopItem shopItem = new ShopItem(Material.BOOK_AND_QUILL, title, new String[] {" ", description, desc2, desc3, desc4, desc5, " "}, 0, true, true);
IButton button = new IButton()
{
@Override
public void onClick(Player player, ClickType clickType)
{
ClanMoveServerShop shop = new ClanMoveServerShop(getPlugin(), getClientManager(), getDonationManager(), clan);
if (!shop.attemptShopOpen(player))
{
playDenySound(player);
}
}
};
addButton(26, shopItem, button);
}
*/
private ServerInfo getServerInfo(String serverName)
{
return getPlugin().getServerInfo(serverName);
}
}
}

View File

@ -6,20 +6,16 @@ import mineplex.core.donation.DonationManager;
import mineplex.core.party.Party;
import mineplex.core.shop.ShopBase;
import mineplex.core.shop.page.ShopPageBase;
import mineplex.game.clans.core.repository.ClanRepository;
import mineplex.hub.server.ServerManager;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
public class ClansServerShop extends ShopBase<ServerManager>
{
private ClanRepository _repository;
{
public ClansServerShop(ServerManager plugin, CoreClientManager clientManager, DonationManager donationManager)
{
super(plugin, clientManager, donationManager, "Clans Beta");
_repository = new ClanRepository(plugin.getPlugin(), plugin.getStatusManager().getCurrentServerName());
super(plugin, clientManager, donationManager, "Clans");
}
@Override