diff --git a/src/me/tychsen/enchantgui/Config/EshopConfig.java b/src/me/tychsen/enchantgui/Config/EshopConfig.java index 2f05f1d..798b9ba 100644 --- a/src/me/tychsen/enchantgui/Config/EshopConfig.java +++ b/src/me/tychsen/enchantgui/Config/EshopConfig.java @@ -3,6 +3,7 @@ import me.tychsen.enchantgui.Economy.MoneyPayment; import me.tychsen.enchantgui.Economy.NullPayment; import me.tychsen.enchantgui.Economy.PaymentStrategy; +import me.tychsen.enchantgui.Economy.XPPayment; import me.tychsen.enchantgui.Menu.DefaultMenuSystem; import me.tychsen.enchantgui.Main; import org.bukkit.command.CommandSender; @@ -73,8 +74,7 @@ public PaymentStrategy getEconomy() { economy = new MoneyPayment(); break; case "xp": - // TODO: Implement XP payment. - economy = new NullPayment(); + economy = new XPPayment(); break; default: economy = new NullPayment(); diff --git a/src/me/tychsen/enchantgui/Economy/XPPayment.java b/src/me/tychsen/enchantgui/Economy/XPPayment.java new file mode 100644 index 0000000..cb4ecf6 --- /dev/null +++ b/src/me/tychsen/enchantgui/Economy/XPPayment.java @@ -0,0 +1,27 @@ +package me.tychsen.enchantgui.Economy; + +import org.bukkit.entity.Player; + +/** + * Created by denni on 26/01/2016. + */ +public class XPPayment implements PaymentStrategy { + @Override + public boolean withdraw(Player p, int amount) { + if (p.getLevel() >= amount) { + p.giveExpLevels(-amount); + return true; + } + + return false; + } + + @Override + public boolean hasSufficientFunds(Player p, int amount) { + if (p.getLevel() >= amount) { + return true; + } + + return false; + } +} diff --git a/src/me/tychsen/enchantgui/Menu/DefaultMenuGenerator.java b/src/me/tychsen/enchantgui/Menu/DefaultMenuGenerator.java index 9955ca7..d4af8d1 100644 --- a/src/me/tychsen/enchantgui/Menu/DefaultMenuGenerator.java +++ b/src/me/tychsen/enchantgui/Menu/DefaultMenuGenerator.java @@ -78,7 +78,7 @@ private Inventory generateEnchantMenu(Player p, ItemStack item, Map