Update Gem Fountain purchase gui
This commit is contained in:
parent
b802cdec6d
commit
e3833b95ad
@ -2,11 +2,13 @@ package mineplex.core.brawl.fountain;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.brawl.fountain.gui.FountainShop;
|
||||
import mineplex.core.common.CurrencyType;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilText;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.hologram.Hologram;
|
||||
import mineplex.core.hologram.HologramManager;
|
||||
import mineplex.core.shop.item.SalesPackageBase;
|
||||
import mineplex.core.stats.StatsManager;
|
||||
import mineplex.serverdata.redis.counter.GoalCounter;
|
||||
import mineplex.serverdata.redis.counter.GoalCounterListener;
|
||||
@ -67,11 +69,21 @@ public class Fountain implements GoalCounterListener
|
||||
|
||||
public void increment(Player player, long amount)
|
||||
{
|
||||
_statsManager.incrementStat(player, "Global.Fountain." + getDataKey(), amount);
|
||||
_statsManager.incrementStat(player, getStatName(), amount);
|
||||
_counter.addAndGet(amount);
|
||||
updateVisuals();
|
||||
}
|
||||
|
||||
public long getAmountAdded(Player player)
|
||||
{
|
||||
return _statsManager.Get(player).getStat(getStatName());
|
||||
}
|
||||
|
||||
private final String getStatName()
|
||||
{
|
||||
return "Global.Fountain." + getDataKey();
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return _name;
|
||||
|
@ -41,7 +41,7 @@ public class FountainManager extends MiniPlugin
|
||||
|
||||
World world = Bukkit.getWorlds().get(0);
|
||||
_gemFountain = new Fountain(new Location(world, -32.5, 72, -23.5), new Location(world, -33.5, 71, -31.5),
|
||||
C.cGreen + "Gem Fountain", "GemFountain", 1000000, this, clientManager, donationManager, _hologramManager, _statsManager);
|
||||
C.cGreen + "Gem Fountain", "GemFountain_01", 1000000, this, clientManager, donationManager, _hologramManager, _statsManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -0,0 +1,27 @@
|
||||
package mineplex.core.brawl.fountain;
|
||||
|
||||
import mineplex.core.common.CurrencyType;
|
||||
import mineplex.core.shop.item.SalesPackageBase;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* @author Shaun Bennett
|
||||
*/
|
||||
public class GemFountainSalesPackage extends SalesPackageBase
|
||||
{
|
||||
public GemFountainSalesPackage(int gems)
|
||||
{
|
||||
super("Add " + gems + " Gems", Material.EMERALD, (byte) 0, new String[] {}, gems, 1);
|
||||
|
||||
CurrencyCostMap.put(CurrencyType.Gems, gems);
|
||||
KnownPackage = false;
|
||||
OneTimePurchaseOnly = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Sold(Player player, CurrencyType currencyType)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -14,7 +14,7 @@ public class GuiCommand extends CommandBase<FountainManager>
|
||||
{
|
||||
public GuiCommand(FountainManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ADMIN, "gui");
|
||||
super(plugin, Rank.ALL, "gui");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -14,7 +14,7 @@ public class ResetCommand extends CommandBase<FountainManager>
|
||||
{
|
||||
public ResetCommand(FountainManager plugin)
|
||||
{
|
||||
super(plugin, Rank.DEVELOPER, "reset");
|
||||
super(plugin, Rank.ADMIN, "reset");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -36,14 +36,16 @@ public class FountainPage extends ShopPageBase<FountainManager, FountainShop>
|
||||
@Override
|
||||
protected void buildPage()
|
||||
{
|
||||
ShopItem addItem = new ShopItem(CurrencyType.Gems.GetDisplayMaterial(), "Add to Fountain",
|
||||
new String[] {}, 1, false, false);
|
||||
|
||||
addButton(22, addItem, new FountainAddButton());
|
||||
|
||||
// Experience Bar
|
||||
long added = _fountain.getAmountAdded(getPlayer());
|
||||
final double fillPercent = _fountain.getFillPercent();
|
||||
String title = Math.round(fillPercent * 100) + "% Complete";
|
||||
String[] lore = new String[] { " ", C.cWhite + "Reaching the goal for this week will", C.cWhite + "unlock the weekend brawl minigame!" };
|
||||
String[] lore = new String[] {
|
||||
" ",
|
||||
C.cWhite + "Reaching the goal for this week will",
|
||||
C.cWhite + "unlock the weekend brawl minigame!",
|
||||
" ",
|
||||
C.cWhite + "You have added " + C.cGreen + added + " Gems"};
|
||||
|
||||
final double percentForEach = 1D / XP_SLOTS.length;
|
||||
double check = percentForEach;
|
||||
@ -57,5 +59,16 @@ public class FountainPage extends ShopPageBase<FountainManager, FountainShop>
|
||||
setItem(XP_SLOTS[i], shopItem);
|
||||
check += percentForEach;
|
||||
}
|
||||
|
||||
int playerGems = getDonationManager().Get(getPlayer()).GetGems();
|
||||
ShopItem add1 = new ShopItem(Material.EMERALD, "Add 100 Gems", new String[] {}, 1, playerGems < 100, false);
|
||||
ShopItem add2 = new ShopItem(Material.EMERALD, "Add 1,000 Gems", new String[] {}, 64, playerGems < 1000, false);
|
||||
ShopItem add3 = new ShopItem(Material.EMERALD, "Add 10,000 Gems", new String[] {}, 1, playerGems < 10000, false);
|
||||
ShopItem add4 = new ShopItem(Material.EMERALD, "Add 100,000 Gems", new String[] {}, 64, playerGems < 100000, false);
|
||||
// Buttons
|
||||
addButton(19, add1, new FountainAddButton(this, 100));
|
||||
addButton(21, add2, new FountainAddButton(this, 1000));
|
||||
addButton(23, add3, new FountainAddButton(this, 10000));
|
||||
addButton(25, add4, new FountainAddButton(this, 100000));
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,20 @@
|
||||
package mineplex.core.brawl.fountain.gui.button;
|
||||
|
||||
import mineplex.core.brawl.fountain.Fountain;
|
||||
import mineplex.core.brawl.fountain.FountainManager;
|
||||
import mineplex.core.brawl.fountain.GemFountainSalesPackage;
|
||||
import mineplex.core.brawl.fountain.gui.FountainPage;
|
||||
import mineplex.core.brawl.fountain.gui.FountainShop;
|
||||
import mineplex.core.common.CurrencyType;
|
||||
import mineplex.core.common.jsonchat.ClickEvent;
|
||||
import mineplex.core.common.jsonchat.JsonMessage;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.cosmetic.CosmeticManager;
|
||||
import mineplex.core.cosmetic.ui.CosmeticShop;
|
||||
import mineplex.core.shop.item.IButton;
|
||||
import mineplex.core.shop.item.SalesPackageBase;
|
||||
import mineplex.core.shop.page.ConfirmationPage;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
@ -12,16 +23,27 @@ import org.bukkit.event.inventory.ClickType;
|
||||
*/
|
||||
public class FountainAddButton implements IButton
|
||||
{
|
||||
private final FountainPage _page;
|
||||
private final int _gems;
|
||||
private final SalesPackageBase _salesPackage;
|
||||
|
||||
public FountainAddButton(FountainPage page, int gems)
|
||||
{
|
||||
_page = page;
|
||||
_gems = gems;
|
||||
_salesPackage = new GemFountainSalesPackage(gems);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
player.closeInventory();
|
||||
|
||||
new JsonMessage("Click to add to gem pool").sendToPlayer(player);
|
||||
new JsonMessage(C.cGreenB + "100 Gems ").click(ClickEvent.RUN_COMMAND, "/fountain add 100")
|
||||
.extra(C.cGreenB + "1000 Gems ").click(ClickEvent.RUN_COMMAND, "/fountain add 1000")
|
||||
.extra(C.cGreenB + "10000 Gems ").click(ClickEvent.RUN_COMMAND, "/fountain add 10000")
|
||||
.extra(C.cGreenB + "100000 Gems ").click(ClickEvent.RUN_COMMAND, "/fountain add 100000")
|
||||
.sendToPlayer(player);
|
||||
_page.getShop().openPageForPlayer(player, new ConfirmationPage<FountainManager, FountainShop>(_page.getPlugin(), _page.getShop(), _page.getClientManager(), _page.getDonationManager(), new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
_page.getPlugin().getGemFountain().increment(player, _gems);
|
||||
_page.refresh();
|
||||
}
|
||||
}, _page, _salesPackage, CurrencyType.Gems, player));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user