Fix purchase item goal in tutorial
This commit is contained in:
parent
724604c76a
commit
fc3a4bdbfe
@ -366,6 +366,10 @@ public class GoldManager extends MiniDbClientPlugin<GoldData>
|
||||
{
|
||||
rewardGold(resultCallback, player, -amount, true);
|
||||
}
|
||||
if (amount == 0 && resultCallback != null)
|
||||
{
|
||||
resultCallback.run(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void rewardGold(final Callback<Boolean> callback, final Player player, final int amount, final boolean updateTotal)
|
||||
|
@ -9,7 +9,6 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.InventoryUtil;
|
||||
import mineplex.core.common.util.UtilItem;
|
||||
@ -109,38 +108,35 @@ public class ShopItemButton<T extends ShopPageBase<?, ?>> implements IButton
|
||||
final ItemStack eventItem = _item.clone();
|
||||
eventItem.setAmount(amount);
|
||||
|
||||
GoldManager.getInstance().deductGold(new Callback<Boolean>()
|
||||
GoldManager.getInstance().deductGold(success ->
|
||||
{
|
||||
public void run(Boolean success)
|
||||
if (success)
|
||||
{
|
||||
if (success)
|
||||
ClansPlayerBuyItemEvent event = new ClansPlayerBuyItemEvent(player, _page, ShopItemButton.this, eventItem, cost, amount);
|
||||
UtilServer.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled())
|
||||
{
|
||||
ClansPlayerBuyItemEvent event = new ClansPlayerBuyItemEvent(player, _page, ShopItemButton.this, eventItem, cost, amount);
|
||||
UtilServer.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled())
|
||||
{
|
||||
GoldManager.getInstance().addGold(player, cost);
|
||||
return;
|
||||
}
|
||||
|
||||
_item = event.getItem();
|
||||
final int finalCost = event.getCost();
|
||||
final int finalAmount = event.getAmount();
|
||||
|
||||
giftItem(player, finalAmount);
|
||||
GoldManager.notify(player, String.format("You have purchased %d item(s) for %dg", finalAmount, finalCost));
|
||||
|
||||
_page.playAcceptSound(player);
|
||||
}
|
||||
else
|
||||
{
|
||||
GoldManager.notify(player, "You cannot afford that item! Please relog to update your gold count.");
|
||||
_page.playDenySound(player);
|
||||
GoldManager.getInstance().addGold(player, cost);
|
||||
return;
|
||||
}
|
||||
|
||||
_page.refresh();
|
||||
_item = event.getItem();
|
||||
final int finalCost = event.getCost();
|
||||
final int finalAmount = event.getAmount();
|
||||
|
||||
giftItem(player, finalAmount);
|
||||
GoldManager.notify(player, String.format("You have purchased %d item(s) for %dg", finalAmount, finalCost));
|
||||
|
||||
_page.playAcceptSound(player);
|
||||
}
|
||||
else
|
||||
{
|
||||
GoldManager.notify(player, "You cannot afford that item! Please relog to update your gold count.");
|
||||
_page.playDenySound(player);
|
||||
}
|
||||
|
||||
_page.refresh();
|
||||
}, player, cost);
|
||||
}
|
||||
else
|
||||
|
@ -137,15 +137,10 @@ public class ClansMainTutorial extends Tutorial
|
||||
|
||||
if (!_taskManager.hasCompletedTask(player, getTaskIdentifier()))
|
||||
{
|
||||
_taskManager.completedTask(new Callback<Boolean>()
|
||||
_taskManager.completedTask(data ->
|
||||
{
|
||||
@Override
|
||||
public void run(Boolean data)
|
||||
{
|
||||
|
||||
GoldManager.getInstance().addGold(player, 32000);
|
||||
UtilPlayer.message(player, F.main("Clans", "You have earned " + F.elem(32000 + " Gold") + " for finishing the tutorial!"));
|
||||
}
|
||||
GoldManager.getInstance().addGold(player, 32000);
|
||||
UtilPlayer.message(player, F.main("Clans", "You have earned " + F.elem(32000 + " Gold") + " for finishing the tutorial!"));
|
||||
}, player, getTaskIdentifier());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user