Moves economy related code to its own class

This commit is contained in:
2021-09-02 01:29:44 +02:00
parent 7bfa60aeee
commit 3717e4d3b6
4 changed files with 72 additions and 43 deletions

View File

@@ -1,6 +1,7 @@
package net.knarcraft.bookswithoutborders.command;
import net.knarcraft.bookswithoutborders.BooksWithoutBorders;
import net.knarcraft.bookswithoutborders.utility.EconomyHelper;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@@ -63,7 +64,7 @@ public class CommandBooksWithoutBorders implements CommandExecutor {
if (bookPriceType != Material.AIR) {
sendErrorMessage(sender, "[" + (int) bookPriceQuantity + " " + bookPriceType.toString() + "(s) are required to create a book]");
} else {
sendErrorMessage(sender, "[" + BooksWithoutBorders.eco.format(bookPriceQuantity) + " is required to create a book]");
sendErrorMessage(sender, "[" + EconomyHelper.getEconomy().format(bookPriceQuantity) + " is required to create a book]");
}
}
sender.sendMessage(getCommandColor() + "Commands:");

View File

@@ -1,6 +1,7 @@
package net.knarcraft.bookswithoutborders.command;
import net.knarcraft.bookswithoutborders.BooksWithoutBorders;
import net.knarcraft.bookswithoutborders.utility.EconomyHelper;
import net.knarcraft.bookswithoutborders.utility.InventoryHelper;
import org.bukkit.Material;
import org.bukkit.command.Command;
@@ -109,7 +110,7 @@ public class CommandSetBookPrice implements CommandExecutor {
* @return <p>True if the price was changed successfully</p>
*/
private boolean setEconomyPrice(CommandSender sender, double price) {
if (booksWithoutBorders.setupEconomy()) {
if (EconomyHelper.setupEconomy()) {
BooksWithoutBorders.bookPriceQuantity = price;
BooksWithoutBorders.bookPriceType = Material.AIR;
booksWithoutBorders.getConfig().set("Options.Price_to_create_book.Item_type", "Economy");
@@ -118,7 +119,7 @@ public class CommandSetBookPrice implements CommandExecutor {
booksWithoutBorders.saveConfig();
BooksWithoutBorders.sendSuccessMessage(sender, "Book creation price set to " +
BooksWithoutBorders.eco.format(BooksWithoutBorders.bookPriceQuantity) + "!");
EconomyHelper.getEconomy().format(BooksWithoutBorders.bookPriceQuantity) + "!");
return true;
} else {
BooksWithoutBorders.sendErrorMessage(sender, "BooksWithoutBorders failed to hook into Vault! Book price not set!");