Implement Fountain GUI
This commit is contained in:
parent
8a5fdccb60
commit
c60beec68c
@ -23,6 +23,16 @@ public class MaterialData
|
|||||||
return new MaterialData(material, data);
|
return new MaterialData(material, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Material getMaterial()
|
||||||
|
{
|
||||||
|
return _material;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte getData()
|
||||||
|
{
|
||||||
|
return _data;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o)
|
public boolean equals(Object o)
|
||||||
{
|
{
|
||||||
|
@ -23,12 +23,13 @@ public class Fountain
|
|||||||
private final String _name;
|
private final String _name;
|
||||||
private final String _dataKey;
|
private final String _dataKey;
|
||||||
private final Location _location;
|
private final Location _location;
|
||||||
|
private Location _lavaLocation;
|
||||||
private final Hologram _hologram;
|
private final Hologram _hologram;
|
||||||
private final Counter _counter;
|
private final Counter _counter;
|
||||||
|
|
||||||
private final FountainShop _shop;
|
private final FountainShop _shop;
|
||||||
|
|
||||||
public Fountain(Location location, String name, String dataKey, long goal, FountainManager fountainManager,
|
public Fountain(Location location, Location lavaLocation, String name, String dataKey, long goal, FountainManager fountainManager,
|
||||||
CoreClientManager clientManager, DonationManager donationManager, HologramManager hologramManager,
|
CoreClientManager clientManager, DonationManager donationManager, HologramManager hologramManager,
|
||||||
StatsManager statsManager)
|
StatsManager statsManager)
|
||||||
{
|
{
|
||||||
@ -38,6 +39,7 @@ public class Fountain
|
|||||||
_name = name;
|
_name = name;
|
||||||
_dataKey = dataKey;
|
_dataKey = dataKey;
|
||||||
_location = location;
|
_location = location;
|
||||||
|
_lavaLocation = lavaLocation;
|
||||||
_hologram = new Hologram(hologramManager, location.clone().add(0, 2, 0), name).start();
|
_hologram = new Hologram(hologramManager, location.clone().add(0, 2, 0), name).start();
|
||||||
_counter = new Counter(dataKey, goal);
|
_counter = new Counter(dataKey, goal);
|
||||||
|
|
||||||
@ -84,4 +86,14 @@ public class Fountain
|
|||||||
{
|
{
|
||||||
_shop.attemptShopOpen(player);
|
_shop.attemptShopOpen(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public double getFillPercent()
|
||||||
|
{
|
||||||
|
return _counter.getFillPercent();
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getCount()
|
||||||
|
{
|
||||||
|
return _counter.getCount();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ import mineplex.core.updater.event.UpdateEvent;
|
|||||||
import mineplex.serverdata.redis.counter.Counter;
|
import mineplex.serverdata.redis.counter.Counter;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.World;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
@ -26,6 +27,7 @@ public class FountainManager extends MiniPlugin
|
|||||||
{
|
{
|
||||||
private HologramManager _hologramManager;
|
private HologramManager _hologramManager;
|
||||||
private StatsManager _statsManager;
|
private StatsManager _statsManager;
|
||||||
|
private DonationManager _donationManager;
|
||||||
|
|
||||||
private Fountain _gemFountain;
|
private Fountain _gemFountain;
|
||||||
|
|
||||||
@ -35,8 +37,10 @@ public class FountainManager extends MiniPlugin
|
|||||||
|
|
||||||
_hologramManager = hologramManager;
|
_hologramManager = hologramManager;
|
||||||
_statsManager = statsManager;
|
_statsManager = statsManager;
|
||||||
|
_donationManager = donationManager;
|
||||||
|
|
||||||
_gemFountain = new Fountain(new Location(Bukkit.getWorlds().get(0), -32.5, 72, -23.5),
|
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", 1000000, this, clientManager, donationManager, _hologramManager, _statsManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,4 +63,9 @@ public class FountainManager extends MiniPlugin
|
|||||||
{
|
{
|
||||||
return _gemFountain;
|
return _gemFountain;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DonationManager getDonationManager()
|
||||||
|
{
|
||||||
|
return _donationManager;
|
||||||
|
}
|
||||||
}
|
}
|
@ -2,10 +2,14 @@ package mineplex.core.brawl.fountain.command;
|
|||||||
|
|
||||||
import mineplex.core.brawl.fountain.FountainManager;
|
import mineplex.core.brawl.fountain.FountainManager;
|
||||||
import mineplex.core.command.CommandBase;
|
import mineplex.core.command.CommandBase;
|
||||||
|
import mineplex.core.common.CurrencyType;
|
||||||
import mineplex.core.common.Rank;
|
import mineplex.core.common.Rank;
|
||||||
|
import mineplex.core.common.util.Callback;
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
import mineplex.core.server.util.TransactionResponse;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.omg.PortableInterceptor.SUCCESSFUL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Shaun Bennett
|
* @author Shaun Bennett
|
||||||
@ -14,7 +18,7 @@ public class AddCommand extends CommandBase<FountainManager>
|
|||||||
{
|
{
|
||||||
public AddCommand(FountainManager plugin)
|
public AddCommand(FountainManager plugin)
|
||||||
{
|
{
|
||||||
super(plugin, Rank.ADMIN, "add");
|
super(plugin, Rank.ALL, "add");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -28,9 +32,28 @@ public class AddCommand extends CommandBase<FountainManager>
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
long amount = Long.parseLong(args[0]);
|
int amount = Integer.parseInt(args[0]);
|
||||||
Plugin.getGemFountain().increment(caller, amount);
|
|
||||||
UtilPlayer.message(caller, F.main("Fountain", "Added " + F.elem(amount) + " to the fountain!"));
|
Plugin.getDonationManager().purchaseUnknownSalesPackage(new Callback<TransactionResponse>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run(TransactionResponse result)
|
||||||
|
{
|
||||||
|
if (result == TransactionResponse.Success)
|
||||||
|
{
|
||||||
|
Plugin.getGemFountain().increment(caller, amount);
|
||||||
|
UtilPlayer.message(caller, F.main("Fountain", "Added " + F.elem(amount) + " to the fountain!"));
|
||||||
|
}
|
||||||
|
else if (result == TransactionResponse.InsufficientFunds)
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.main("Fountain", "You do not have enough gems!"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.main("Fountain", "There was an error processing your request!"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, caller, "GemFountain.Add", CurrencyType.Gems, amount, false);
|
||||||
}
|
}
|
||||||
catch (NumberFormatException ex)
|
catch (NumberFormatException ex)
|
||||||
{
|
{
|
||||||
|
@ -12,7 +12,7 @@ public class FountainCommand extends MultiCommandBase<FountainManager>
|
|||||||
{
|
{
|
||||||
public FountainCommand(FountainManager plugin)
|
public FountainCommand(FountainManager plugin)
|
||||||
{
|
{
|
||||||
super(plugin, Rank.ADMIN, "fountain");
|
super(plugin, Rank.ALL, "fountain");
|
||||||
|
|
||||||
AddCommand(new AddCommand(plugin));
|
AddCommand(new AddCommand(plugin));
|
||||||
AddCommand(new GuiCommand(plugin));
|
AddCommand(new GuiCommand(plugin));
|
||||||
|
@ -1,12 +1,16 @@
|
|||||||
package mineplex.core.brawl.fountain.gui;
|
package mineplex.core.brawl.fountain.gui;
|
||||||
|
|
||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
|
import mineplex.core.brawl.fountain.Fountain;
|
||||||
import mineplex.core.brawl.fountain.FountainManager;
|
import mineplex.core.brawl.fountain.FountainManager;
|
||||||
import mineplex.core.brawl.fountain.gui.button.FountainAddButton;
|
import mineplex.core.brawl.fountain.gui.button.FountainAddButton;
|
||||||
import mineplex.core.common.CurrencyType;
|
import mineplex.core.common.CurrencyType;
|
||||||
|
import mineplex.core.common.MaterialData;
|
||||||
|
import mineplex.core.common.util.C;
|
||||||
import mineplex.core.donation.DonationManager;
|
import mineplex.core.donation.DonationManager;
|
||||||
import mineplex.core.shop.item.ShopItem;
|
import mineplex.core.shop.item.ShopItem;
|
||||||
import mineplex.core.shop.page.ShopPageBase;
|
import mineplex.core.shop.page.ShopPageBase;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -14,10 +18,18 @@ import org.bukkit.entity.Player;
|
|||||||
*/
|
*/
|
||||||
public class FountainPage extends ShopPageBase<FountainManager, FountainShop>
|
public class FountainPage extends ShopPageBase<FountainManager, FountainShop>
|
||||||
{
|
{
|
||||||
public FountainPage(FountainManager plugin, FountainShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player)
|
private final MaterialData EMPTY_XP = MaterialData.of(Material.STAINED_GLASS_PANE, (byte) 7);
|
||||||
|
private final MaterialData XP = MaterialData.of(Material.STAINED_GLASS_PANE, (byte) 5);
|
||||||
|
private final int[] XP_SLOTS = { 2, 3, 4, 5, 6 };
|
||||||
|
|
||||||
|
private Fountain _fountain;
|
||||||
|
|
||||||
|
public FountainPage(FountainManager plugin, FountainShop shop, CoreClientManager clientManager, DonationManager donationManager, Fountain fountain, Player player)
|
||||||
{
|
{
|
||||||
super(plugin, shop, clientManager, donationManager, "Fountain Keeper", player, 27);
|
super(plugin, shop, clientManager, donationManager, "Fountain Keeper", player, 27);
|
||||||
|
|
||||||
|
_fountain = fountain;
|
||||||
|
|
||||||
buildPage();
|
buildPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,5 +40,22 @@ public class FountainPage extends ShopPageBase<FountainManager, FountainShop>
|
|||||||
new String[] {}, 1, false, false);
|
new String[] {}, 1, false, false);
|
||||||
|
|
||||||
addButton(22, addItem, new FountainAddButton());
|
addButton(22, addItem, new FountainAddButton());
|
||||||
|
|
||||||
|
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!" };
|
||||||
|
|
||||||
|
final double percentForEach = 1D / XP_SLOTS.length;
|
||||||
|
double check = percentForEach;
|
||||||
|
|
||||||
|
for (int i = 0; i < XP_SLOTS.length; i++)
|
||||||
|
{
|
||||||
|
MaterialData data = fillPercent >= check ? XP : EMPTY_XP;
|
||||||
|
ShopItem shopItem = new ShopItem(data.getMaterial(), data.getData(), title,
|
||||||
|
lore, 1, false, false);
|
||||||
|
|
||||||
|
setItem(XP_SLOTS[i], shopItem);
|
||||||
|
check += percentForEach;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ public class FountainShop extends ShopBase<FountainManager>
|
|||||||
@Override
|
@Override
|
||||||
protected ShopPageBase<FountainManager, ? extends ShopBase<FountainManager>> buildPagesFor(Player player)
|
protected ShopPageBase<FountainManager, ? extends ShopBase<FountainManager>> buildPagesFor(Player player)
|
||||||
{
|
{
|
||||||
return new FountainPage(getPlugin(), this, getClientManager(), getDonationManager(), player);
|
return new FountainPage(getPlugin(), this, getClientManager(), getDonationManager(), _fountain, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Fountain getFountain()
|
public Fountain getFountain()
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
package mineplex.core.brawl.fountain.gui.button;
|
package mineplex.core.brawl.fountain.gui.button;
|
||||||
|
|
||||||
|
import mineplex.core.common.jsonchat.ClickEvent;
|
||||||
|
import mineplex.core.common.jsonchat.JsonMessage;
|
||||||
|
import mineplex.core.common.util.C;
|
||||||
import mineplex.core.shop.item.IButton;
|
import mineplex.core.shop.item.IButton;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.inventory.ClickType;
|
import org.bukkit.event.inventory.ClickType;
|
||||||
@ -12,6 +15,13 @@ public class FountainAddButton implements IButton
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(Player player, ClickType clickType)
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,6 +73,11 @@ public class DonationManager extends MiniDbClientPlugin<Donor>
|
|||||||
Get(token.Name).loadToken(token.DonorToken);
|
Get(token.Name).loadToken(token.DonorToken);
|
||||||
//_repository.updateGemsAndCoins(uuid, Get(token.Name).GetGems(), Get(token.Name).getCoins());
|
//_repository.updateGemsAndCoins(uuid, Get(token.Name).GetGems(), Get(token.Name).getCoins());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void purchaseUnknownSalesPackage(Callback<TransactionResponse> callback, Player player, String packageName, CurrencyType currencyType, int cost, boolean oneTimePurchase)
|
||||||
|
{
|
||||||
|
PurchaseUnknownSalesPackage(callback, player.getName(), getClientManager().getAccountId(player), packageName, currencyType, cost, oneTimePurchase);
|
||||||
|
}
|
||||||
|
|
||||||
public void PurchaseUnknownSalesPackage(final Callback<TransactionResponse> callback, final String name, final int accountId, final String packageName, final CurrencyType currencyType, final int cost, boolean oneTimePurchase)
|
public void PurchaseUnknownSalesPackage(final Callback<TransactionResponse> callback, final String name, final int accountId, final String packageName, final CurrencyType currencyType, final int cost, boolean oneTimePurchase)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user