Add buttons for support to give PPC subscriptions
This commit is contained in:
parent
3653eb36df
commit
17a11a63b6
@ -12,6 +12,7 @@ import java.util.Map;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.common.util.C;
|
||||
@ -33,6 +34,9 @@ public class SupportPowerplayPage extends SupportPage
|
||||
|
||||
_multiPageManager = new MultiPageManager<>(this, this::getSubscriptions, this::buildPowerPlayItem);
|
||||
|
||||
// 1 row is 7 items
|
||||
_multiPageManager.setElementsPerPage(21);
|
||||
|
||||
buildPage();
|
||||
}
|
||||
|
||||
@ -100,11 +104,45 @@ public class SupportPowerplayPage extends SupportPage
|
||||
return subscriptions;
|
||||
}
|
||||
|
||||
private ItemStack getSubscriptionIcon(PowerPlayData.SubscriptionDuration duration)
|
||||
{
|
||||
return new ItemBuilder(Material.GOLD_INGOT)
|
||||
.setAmount(duration.getLength())
|
||||
.setTitle(C.cGreenB + "Give " + duration.getLength() + " Month Subscription")
|
||||
.addLore(C.mBody + "Click to give" + C.cYellow + " 1 " + duration.getName())
|
||||
.addLore(C.mBody + "of PPC to " + C.cYellow + _target.getName())
|
||||
.build();
|
||||
}
|
||||
|
||||
private void addSubscriptionButton(int slot, PowerPlayData.SubscriptionDuration duration)
|
||||
{
|
||||
addButton(slot, getSubscriptionIcon(duration), (p, c) ->
|
||||
{
|
||||
getPlugin().getPowerPlayRepo().addSubscription(_target.getAccountId(), LocalDate.now(), duration.getName().toLowerCase());
|
||||
getShop().loadPowerPlay(getPlayer(), _target.getAccountId(), (success) ->
|
||||
{
|
||||
message("Gave a" + C.cYellow + " 1 " + duration.getName() + C.mBody + " PPC subscription to " + C.cYellow + _target.getName());
|
||||
|
||||
if (success)
|
||||
{
|
||||
refresh();
|
||||
}
|
||||
else
|
||||
{
|
||||
goBack();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void buildPage()
|
||||
{
|
||||
super.buildPage();
|
||||
|
||||
_multiPageManager.buildPage();
|
||||
|
||||
addSubscriptionButton(getSlotIndex(5, 3), PowerPlayData.SubscriptionDuration.MONTH);
|
||||
addSubscriptionButton(getSlotIndex(5, 5), PowerPlayData.SubscriptionDuration.YEAR);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user