Writes a lot of code necessary for the scrapper
Adds the classes necessary for the new scrapper Partly implements some scrapper functionality Restructures some classes to reduce code duplication Moves some classes to make some classes easier to find Adds a bunch of TODOs where things have an unfinished implementation
This commit is contained in:
@ -10,6 +10,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
import org.bukkit.plugin.ServicesManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
@ -32,7 +33,7 @@ public class EconomyManager {
|
||||
* @param logger <p>The logger to use for logging</p>
|
||||
* @return <p>True if Vault was successfully set up</p>
|
||||
*/
|
||||
public static boolean setUp(ServicesManager servicesManager, Logger logger) {
|
||||
public static boolean setUp(@NotNull ServicesManager servicesManager, @NotNull Logger logger) {
|
||||
//If already set up, there is nothing to do
|
||||
if (economy != null) {
|
||||
return true;
|
||||
@ -41,13 +42,13 @@ public class EconomyManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets whether the given player can pay for re-forging their held item
|
||||
* Gets whether the given player cannot pay for re-forging their held item
|
||||
*
|
||||
* @param player <p>The player holding an item</p>
|
||||
* @return <p>Whether the player can pay for the reforge</p>
|
||||
* @return <p>Whether the player cannot pay for the reforge</p>
|
||||
*/
|
||||
public static boolean canPay(Player player) {
|
||||
return economy.getBalance(player) - getHeldItemCost(player) >= 0;
|
||||
public static boolean cannotPayForHeldItemReforge(@NotNull Player player) {
|
||||
return !(economy.getBalance(player) - getHeldItemCost(player) >= 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -56,7 +57,7 @@ public class EconomyManager {
|
||||
* @param player <p>The player holding an item</p>
|
||||
* @return <p>The formatted cost</p>
|
||||
*/
|
||||
public static String formatCost(Player player) {
|
||||
public static String formatCost(@NotNull Player player) {
|
||||
double cost = getHeldItemCost(player);
|
||||
return economy.format(cost);
|
||||
}
|
||||
@ -68,7 +69,7 @@ public class EconomyManager {
|
||||
*
|
||||
* @param player <p>The player to withdraw from</p>
|
||||
*/
|
||||
public static void withdraw(Player player) {
|
||||
public static void withdraw(@NotNull Player player) {
|
||||
economy.withdrawPlayer(player, getHeldItemCost(player));
|
||||
}
|
||||
|
||||
@ -78,7 +79,7 @@ public class EconomyManager {
|
||||
* @param player <p>The player to calculate the cost for</p>
|
||||
* @return <p>The calculated cost</p>
|
||||
*/
|
||||
private static double getHeldItemCost(Player player) {
|
||||
private static double getHeldItemCost(@NotNull Player player) {
|
||||
return getCost(player.getInventory().getItemInMainHand());
|
||||
}
|
||||
|
||||
@ -88,8 +89,8 @@ public class EconomyManager {
|
||||
* @param item <p>The item to be repaired</p>
|
||||
* @return <p>The cost of the repair</p>
|
||||
*/
|
||||
private static double getCost(ItemStack item) {
|
||||
GlobalBlacksmithSettings globalBlacksmithSettings = BlacksmithPlugin.getInstance().getSettings();
|
||||
private static double getCost(@NotNull ItemStack item) {
|
||||
GlobalBlacksmithSettings globalBlacksmithSettings = BlacksmithPlugin.getInstance().getGlobalBlacksmithSettings();
|
||||
Material material = item.getType();
|
||||
|
||||
//Calculate the base price
|
||||
@ -121,8 +122,8 @@ public class EconomyManager {
|
||||
* @param item <p>The item to calculate enchantment cost for</p>
|
||||
* @return <p>The resulting enchantment cost</p>
|
||||
*/
|
||||
private static double getEnchantmentCost(ItemStack item) {
|
||||
GlobalBlacksmithSettings settings = BlacksmithPlugin.getInstance().getSettings();
|
||||
private static double getEnchantmentCost(@NotNull ItemStack item) {
|
||||
GlobalBlacksmithSettings settings = BlacksmithPlugin.getInstance().getGlobalBlacksmithSettings();
|
||||
double price = 0;
|
||||
for (Enchantment enchantment : item.getEnchantments().keySet()) {
|
||||
price += settings.getEnchantmentCost(enchantment) * item.getEnchantmentLevel(enchantment);
|
||||
@ -137,7 +138,7 @@ public class EconomyManager {
|
||||
* @param logger <p>The logger to use for logging</p>
|
||||
* @return <p>True if Vault was successfully set up</p>
|
||||
*/
|
||||
private static boolean setupVault(ServicesManager servicesManager, Logger logger) {
|
||||
private static boolean setupVault(@NotNull ServicesManager servicesManager, @NotNull Logger logger) {
|
||||
// Setup Vault
|
||||
RegisteredServiceProvider<Economy> economyProvider = servicesManager.getRegistration(Economy.class);
|
||||
if (economyProvider != null) {
|
||||
|
Reference in New Issue
Block a user