Mineplex2018-withcommit/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/JoinServerButton.java

58 lines
1.3 KiB
Java
Raw Normal View History

2016-07-25 16:55:18 +02:00
package mineplex.clanshub;
import mineplex.core.common.Rank;
import mineplex.core.shop.item.IButton;
import mineplex.core.shop.page.ShopPageBase;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
2016-07-27 04:32:46 +02:00
/**
* GUI button to select a server from a display
*/
2016-07-25 16:55:18 +02:00
public class JoinServerButton implements IButton
{
private ShopPageBase<?, ?> _page;
private ClansTransferManager _transferManager;
private ServerInfo _serverInfo;
public JoinServerButton(ShopPageBase<?, ?> page, ClansTransferManager transferManager, ServerInfo serverInfo)
{
_page = page;
_transferManager = transferManager;
_serverInfo = serverInfo;
}
@Override
public void onClick(Player player, ClickType clickType)
{
selectServer(player, _serverInfo);
}
2016-07-27 04:32:46 +02:00
/**
* Selects a server to send a player to
* @param player The player to send
* @param serverInfo The server to send the player to
*/
2016-07-25 16:55:18 +02:00
public void selectServer(Player player, ServerInfo serverInfo)
{
if (serverInfo != null)
{
System.out.println("Selecting server :" + serverInfo.Name);
int slots = 1;
if (serverInfo.getAvailableSlots() < slots && !_page.getClient().GetRank().has(Rank.ULTRA))
{
_page.playDenySound(player);
}
else
{
_transferManager.selectServer(player, serverInfo);
}
}
else
{
_page.playDenySound(player);
}
}
2016-07-27 04:32:46 +02:00
}