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

51 lines
1.1 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;
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);
}
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);
}
}
}