58 lines
1.3 KiB
Java
58 lines
1.3 KiB
Java
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;
|
|
|
|
/**
|
|
* GUI button to select a server from a display
|
|
*/
|
|
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);
|
|
}
|
|
|
|
/**
|
|
* Selects a server to send a player to
|
|
* @param player The player to send
|
|
* @param serverInfo The server to send the player to
|
|
*/
|
|
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);
|
|
}
|
|
}
|
|
} |