Style improvements and cost calculation alternative
This commit adds a lot of missing comments, and fixes a lot of bad formatting. Some spelling errors have also been fixed. Warning: This commit changes the name of some config values. Existing configurations will be broken! This commit also adds a natural cost option, which defaults to true. With natural cost turned on, the cost of repairing an item will increase with each damage the item has taken, rather than the cost decreasing for every damage taken.
This commit is contained in:
parent
2b321993d7
commit
781999c995
@ -29,19 +29,32 @@ import java.util.ArrayList;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Blacksmith's main class
|
||||||
|
*/
|
||||||
public class BlacksmithPlugin extends JavaPlugin {
|
public class BlacksmithPlugin extends JavaPlugin {
|
||||||
|
|
||||||
private static BlacksmithPlugin instance;
|
private static BlacksmithPlugin instance;
|
||||||
private Settings config;
|
private Settings config;
|
||||||
private Economy economy;
|
private Economy economy;
|
||||||
private HyperAPI hyperAPI;
|
private HyperAPI hyperAPI;
|
||||||
private BukkitConnector bukCon;
|
private BukkitConnector bukkitConnector;
|
||||||
private boolean useHyperAPI = false;
|
private boolean useHyperAPI = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets an instance of the Blacksmith plugin
|
||||||
|
*
|
||||||
|
* @return <p>An instance of the blacksmith plugin</p>
|
||||||
|
*/
|
||||||
public static BlacksmithPlugin getInstance() {
|
public static BlacksmithPlugin getInstance() {
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets settings for the blacksmith plugin
|
||||||
|
*
|
||||||
|
* @return <p>Settings for the blacksmith plugin</p>
|
||||||
|
*/
|
||||||
public Settings getSettings() {
|
public Settings getSettings() {
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
@ -56,33 +69,52 @@ public class BlacksmithPlugin extends JavaPlugin {
|
|||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
instance = this;
|
instance = this;
|
||||||
|
|
||||||
|
//Load settings
|
||||||
config = new Settings(this);
|
config = new Settings(this);
|
||||||
config.load();
|
config.load();
|
||||||
/* Setup Hyperconomy (Soft-Depend only, so this is completely optional!)
|
//Load HyperConomy if available
|
||||||
Hyperconomy uses your favorite Vault-compatible economy system
|
setupHyperConomy();
|
||||||
and calculates prices for items based on supply and demand on the fly.
|
|
||||||
This is only used to get the cost of a repair.*/
|
|
||||||
if (Bukkit.getPluginManager().getPlugin("HyperConomy") != null) {
|
|
||||||
getServer().getLogger().log(Level.INFO, "Found HyperConomy! Using that for calculating prices, base-prices and price-per-durability-point in the Blacksmith config.yml will NOT be used!");
|
|
||||||
this.useHyperAPI = true;
|
|
||||||
Plugin hcPlugin = getServer().getPluginManager().getPlugin("HyperConomy");
|
|
||||||
bukCon = (BukkitConnector) hcPlugin;
|
|
||||||
HyperConomy hc = Objects.requireNonNull(bukCon).getHC();
|
|
||||||
this.hyperAPI = (HyperAPI) hc.getAPI();
|
|
||||||
}
|
|
||||||
getLogger().log(Level.INFO, "Setting Up Vault now....");
|
getLogger().log(Level.INFO, "Setting Up Vault now....");
|
||||||
boolean canLoad = SetupVault();
|
boolean canLoad = setupVault();
|
||||||
if (!canLoad) {
|
if (!canLoad) {
|
||||||
getLogger().log(Level.INFO, "Vault Failed....");
|
getLogger().log(Level.SEVERE, "Vault Integration Failed....");
|
||||||
getServer().getPluginManager().disablePlugin(this);
|
getServer().getPluginManager().disablePlugin(this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
CitizensAPI.getTraitFactory().registerTrait(net.citizensnpcs.api.trait.TraitInfo.create(BlacksmithTrait.class).withName("blacksmith"));
|
//Register the blacksmith trait with Citizens
|
||||||
|
CitizensAPI.getTraitFactory().registerTrait(
|
||||||
|
net.citizensnpcs.api.trait.TraitInfo.create(BlacksmithTrait.class).withName("blacksmith"));
|
||||||
|
|
||||||
getLogger().log(Level.INFO, " v" + getDescription().getVersion() + " enabled.");
|
getLogger().log(Level.INFO, " v" + getDescription().getVersion() + " enabled.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean SetupVault() {
|
/**
|
||||||
|
* Sets up HyperConomy
|
||||||
|
*
|
||||||
|
* <p>Setup HyperConomy (Soft-Depend only, so this is completely optional!). HyperConomy uses your favorite
|
||||||
|
* Vault-compatible economy system and calculates prices for items based on supply and demand on the fly.
|
||||||
|
* This is only used to get the cost of a repair.</p>
|
||||||
|
*/
|
||||||
|
private void setupHyperConomy() {
|
||||||
|
if (Bukkit.getPluginManager().getPlugin("HyperConomy") != null) {
|
||||||
|
getServer().getLogger().log(Level.INFO, "Found HyperConomy! Using that for calculating prices, " +
|
||||||
|
"base-prices and price-per-durability-point in the Blacksmith config.yml will NOT be used!");
|
||||||
|
this.useHyperAPI = true;
|
||||||
|
Plugin hyperConomyPlugin = getServer().getPluginManager().getPlugin("HyperConomy");
|
||||||
|
bukkitConnector = (BukkitConnector) hyperConomyPlugin;
|
||||||
|
HyperConomy hyperConomy = Objects.requireNonNull(bukkitConnector).getHC();
|
||||||
|
this.hyperAPI = (HyperAPI) hyperConomy.getAPI();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets up Vault for economy
|
||||||
|
*
|
||||||
|
* @return <p>True if Vault was successfully set up</p>
|
||||||
|
*/
|
||||||
|
private boolean setupVault() {
|
||||||
// Setup Vault
|
// Setup Vault
|
||||||
RegisteredServiceProvider<Economy> economyProvider = getServer().getServicesManager().getRegistration(
|
RegisteredServiceProvider<Economy> economyProvider = getServer().getServicesManager().getRegistration(
|
||||||
Economy.class);
|
Economy.class);
|
||||||
@ -97,12 +129,20 @@ public class BlacksmithPlugin extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(final CommandSender sender, final @NotNull Command command, final @NotNull String label, final String[] args) {
|
public boolean onCommand(final CommandSender sender, final @NotNull Command command, final @NotNull String label,
|
||||||
|
final String[] args) {
|
||||||
|
//Handle the reload command
|
||||||
config.load();
|
config.load();
|
||||||
sender.sendMessage(ChatColor.GREEN + "Blacksmith config reloaded!");
|
sender.sendMessage(ChatColor.GREEN + "Blacksmith config reloaded!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets whether the given item is a type of tool
|
||||||
|
*
|
||||||
|
* @param item <p>The item to check if is tool or not</p>
|
||||||
|
* @return <p>True if the given item is a type of tool</p>
|
||||||
|
*/
|
||||||
public boolean isTool(ItemStack item) {
|
public boolean isTool(ItemStack item) {
|
||||||
return switch (item.getType()) {
|
return switch (item.getType()) {
|
||||||
case WOODEN_PICKAXE, WOODEN_SHOVEL, WOODEN_HOE, WOODEN_SWORD, WOODEN_AXE, STONE_PICKAXE, STONE_SHOVEL,
|
case WOODEN_PICKAXE, WOODEN_SHOVEL, WOODEN_HOE, WOODEN_SWORD, WOODEN_AXE, STONE_PICKAXE, STONE_SHOVEL,
|
||||||
@ -115,6 +155,12 @@ public class BlacksmithPlugin extends JavaPlugin {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets whether the given item is a type of armor
|
||||||
|
*
|
||||||
|
* @param item <p>The item to check if is armor or not</p>
|
||||||
|
* @return <p>True if the given item is a type of armor</p>
|
||||||
|
*/
|
||||||
public static boolean isArmor(ItemStack item) {
|
public static boolean isArmor(ItemStack item) {
|
||||||
return switch (item.getType()) {
|
return switch (item.getType()) {
|
||||||
case LEATHER_HELMET, LEATHER_CHESTPLATE, LEATHER_LEGGINGS, LEATHER_BOOTS, CHAINMAIL_HELMET,
|
case LEATHER_HELMET, LEATHER_CHESTPLATE, LEATHER_LEGGINGS, LEATHER_BOOTS, CHAINMAIL_HELMET,
|
||||||
@ -139,93 +185,124 @@ public class BlacksmithPlugin extends JavaPlugin {
|
|||||||
economy.withdrawPlayer(player, getCost(player.getInventory().getItemInMainHand(), player));
|
economy.withdrawPlayer(player, getCost(player.getInventory().getItemInMainHand(), player));
|
||||||
}
|
}
|
||||||
|
|
||||||
private double getCost(ItemStack item, Player player) {
|
|
||||||
DataKey root = config.getConfig().getKey("");
|
|
||||||
double price = Setting.BASE_PRICE.asDouble();
|
|
||||||
if (root.keyExists("base-prices." + item.getType().name().toLowerCase().replace('_', '-'))) {
|
|
||||||
price = root.getDouble("base-prices." + item.getType().name().toLowerCase().replace('_', '-'));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Adjust price based on durability and enchantments
|
|
||||||
if (this.useHyperAPI) {
|
|
||||||
// If using hyperconomy, price is calculated like so:
|
|
||||||
// New Item Price + Enchantments Price (from hyperconomy) / maxDurability = price per durability point
|
|
||||||
// Total price would then be base_price + price per durablity point * current durability
|
|
||||||
double hyperPrice = 0;
|
|
||||||
HItemStack hi = hyperAPI.getHyperPlayer(player.getName()).getItemInHand();
|
|
||||||
ItemStack item2 = player.getInventory().getItemInMainHand().clone();
|
|
||||||
|
|
||||||
for (TradeObject enchant : hyperAPI.getEnchantmentHyperObjects(hi, player.getName())) {
|
|
||||||
hyperPrice = hyperPrice + enchant.getBuyPrice(1);
|
|
||||||
Enchantment enchantment = Enchantment.getByKey(NamespacedKey.minecraft(enchant.getEnchantment().getEnchantmentName()));
|
|
||||||
item2.removeEnchantment(Objects.requireNonNull(enchantment));
|
|
||||||
}
|
|
||||||
|
|
||||||
ArrayList<Material> leathers = new ArrayList<>();
|
|
||||||
leathers.add(Material.LEATHER_BOOTS);
|
|
||||||
leathers.add(Material.LEATHER_CHESTPLATE);
|
|
||||||
leathers.add(Material.LEATHER_HELMET);
|
|
||||||
leathers.add(Material.LEATHER_LEGGINGS);
|
|
||||||
|
|
||||||
HItemStack hi3 = null;
|
|
||||||
if (leathers.contains(player.getInventory().getItemInMainHand().getType())) {
|
|
||||||
hi3 = bukCon.getBukkitCommon().getSerializableItemStack(new ItemStack(player.getInventory().getItemInMainHand().getType()));
|
|
||||||
}
|
|
||||||
|
|
||||||
TradeObject to = this.hyperAPI.getHyperObject(hi, "default");
|
|
||||||
if (to == null) {
|
|
||||||
to = hyperAPI.getHyperObject(hi3, "default");
|
|
||||||
if (to == null) {
|
|
||||||
HItemStack hi4 = bukCon.getBukkitCommon().getSerializableItemStack(new ItemStack(player.getInventory().getItemInMainHand().getType()));
|
|
||||||
to = this.hyperAPI.getHyperObject(hi4, "default");
|
|
||||||
}
|
|
||||||
hyperPrice = hyperPrice + to.getSellPrice(1);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
hyperPrice = to.getSellPrice(1);
|
|
||||||
}
|
|
||||||
double hyperPricePerDurability = hyperPrice / item.getType().getMaxDurability();
|
|
||||||
price += getDurability(item) * hyperPricePerDurability;
|
|
||||||
|
|
||||||
double enchantmentModifier = Setting.ENCHANTMENT_MODIFIER.asDouble();
|
|
||||||
for (Enchantment enchantment : item2.getEnchantments().keySet()) {
|
|
||||||
if (root.keyExists("enchantment-modifiers." + enchantment.getKey().asString().toLowerCase().replace('_', '-'))) {
|
|
||||||
enchantmentModifier = root.getDouble("enchantment-modifiers."
|
|
||||||
+ enchantment.getKey().asString().toLowerCase().replace('_', '-'));
|
|
||||||
}
|
|
||||||
price += enchantmentModifier * item2.getEnchantmentLevel(enchantment);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return price;
|
|
||||||
} else {
|
|
||||||
if (root.keyExists("price-per-durability-point." + item.getType().name().toLowerCase().replace('_', '-'))) {
|
|
||||||
price += getDurability(item) * root.getDouble("price-per-durability-point." + item.getType().name().toLowerCase().replace('_', '-'));
|
|
||||||
} else {
|
|
||||||
price += getDurability(item) * Setting.PRICE_PER_DURABILITY_POINT.asDouble();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
double enchantmentModifier = Setting.ENCHANTMENT_MODIFIER.asDouble();
|
|
||||||
for (Enchantment enchantment : item.getEnchantments().keySet()) {
|
|
||||||
if (root.keyExists("enchantment-modifiers." + enchantment.getKey().asString().toLowerCase().replace('_', '-'))) {
|
|
||||||
enchantmentModifier = root.getDouble("enchantment-modifiers."
|
|
||||||
+ enchantment.getKey().asString().toLowerCase().replace('_', '-'));
|
|
||||||
}
|
|
||||||
price += enchantmentModifier * item.getEnchantmentLevel(enchantment);
|
|
||||||
}
|
|
||||||
return price;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the durability of the given item
|
* Gets the durability of the given item
|
||||||
*
|
*
|
||||||
* @param itemStack <p>The item to get the durability of</p>
|
* @param itemStack <p>The item to get the durability of</p>
|
||||||
* @return <p>The durability of the item</p>
|
* @return <p>The durability of the item</p>
|
||||||
*/
|
*/
|
||||||
static short getDurability(ItemStack itemStack) {
|
public static short getDurability(ItemStack itemStack) {
|
||||||
Damageable damageable = (Damageable) itemStack.getItemMeta();
|
Damageable damageable = (Damageable) itemStack.getItemMeta();
|
||||||
return (short) (itemStack.getType().getMaxDurability() - damageable.getDamage());
|
return (short) (itemStack.getType().getMaxDurability() - damageable.getDamage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the damage done to the given item
|
||||||
|
*
|
||||||
|
* @param itemStack <p>The damage done to the item</p>
|
||||||
|
* @return <p>The damage done to the item</p>
|
||||||
|
*/
|
||||||
|
public static short getDamage(ItemStack itemStack) {
|
||||||
|
Damageable damageable = (Damageable) itemStack.getItemMeta();
|
||||||
|
return (short) damageable.getDamage();
|
||||||
|
}
|
||||||
|
|
||||||
|
private double getCost(ItemStack item, Player player) {
|
||||||
|
DataKey root = config.getConfig().getKey("");
|
||||||
|
String itemName = item.getType().name().toLowerCase().replace('_', '-');
|
||||||
|
double price;
|
||||||
|
if (root.keyExists("base-prices." + itemName)) {
|
||||||
|
price = root.getDouble("base-prices." + itemName);
|
||||||
|
} else {
|
||||||
|
price = Setting.BASE_PRICE.asDouble();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Adjust price based on durability and enchantments
|
||||||
|
if (this.useHyperAPI) {
|
||||||
|
return getHyperAPICost(player, item, root, price);
|
||||||
|
} else {
|
||||||
|
double pricePerDurabilityPoint;
|
||||||
|
if (root.keyExists("price-per-durability-point." + itemName)) {
|
||||||
|
pricePerDurabilityPoint = root.getDouble("price-per-durability-point." + itemName);
|
||||||
|
} else {
|
||||||
|
pricePerDurabilityPoint = Setting.PRICE_PER_DURABILITY_POINT.asDouble();
|
||||||
|
}
|
||||||
|
if (config.getNaturalCost()) {
|
||||||
|
//Cost increases with damage
|
||||||
|
price += ((double) getDamage(item)) * pricePerDurabilityPoint;
|
||||||
|
} else {
|
||||||
|
//Cost decreases with damage
|
||||||
|
price += ((double) getDurability(item)) * pricePerDurabilityPoint;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Add the enchantment modifier for each enchantment on the item
|
||||||
|
double enchantmentModifier = Setting.ENCHANTMENT_MODIFIER.asDouble();
|
||||||
|
for (Enchantment enchantment : item.getEnchantments().keySet()) {
|
||||||
|
String enchantmentKey = "enchantment-modifiers." +
|
||||||
|
enchantment.getKey().asString().toLowerCase().replace('_', '-');
|
||||||
|
if (root.keyExists(enchantmentKey)) {
|
||||||
|
price += root.getDouble(enchantmentKey) * item.getEnchantmentLevel(enchantment);
|
||||||
|
} else {
|
||||||
|
price += enchantmentModifier * item.getEnchantmentLevel(enchantment);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return price;
|
||||||
|
}
|
||||||
|
|
||||||
|
private double getHyperAPICost(Player player, ItemStack item, DataKey root, double price) {
|
||||||
|
// If using hyperConomy, price is calculated like so:
|
||||||
|
// New Item Price + Enchantments Price (from hyperConomy) / maxDurability = price per durability point
|
||||||
|
// Total price would then be base_price + price per durability point * current durability
|
||||||
|
double hyperPrice = 0;
|
||||||
|
HItemStack hi = hyperAPI.getHyperPlayer(player.getName()).getItemInHand();
|
||||||
|
ItemStack item2 = player.getInventory().getItemInMainHand().clone();
|
||||||
|
|
||||||
|
for (TradeObject enchant : hyperAPI.getEnchantmentHyperObjects(hi, player.getName())) {
|
||||||
|
hyperPrice = hyperPrice + enchant.getBuyPrice(1);
|
||||||
|
Enchantment enchantment = Enchantment.getByKey(
|
||||||
|
NamespacedKey.minecraft(enchant.getEnchantment().getEnchantmentName()));
|
||||||
|
item2.removeEnchantment(Objects.requireNonNull(enchantment));
|
||||||
|
}
|
||||||
|
|
||||||
|
ArrayList<Material> leathers = new ArrayList<>();
|
||||||
|
leathers.add(Material.LEATHER_BOOTS);
|
||||||
|
leathers.add(Material.LEATHER_CHESTPLATE);
|
||||||
|
leathers.add(Material.LEATHER_HELMET);
|
||||||
|
leathers.add(Material.LEATHER_LEGGINGS);
|
||||||
|
|
||||||
|
HItemStack hi3 = null;
|
||||||
|
if (leathers.contains(player.getInventory().getItemInMainHand().getType())) {
|
||||||
|
hi3 = bukkitConnector.getBukkitCommon().getSerializableItemStack(
|
||||||
|
new ItemStack(player.getInventory().getItemInMainHand().getType()));
|
||||||
|
}
|
||||||
|
|
||||||
|
TradeObject to = this.hyperAPI.getHyperObject(hi, "default");
|
||||||
|
if (to == null) {
|
||||||
|
to = hyperAPI.getHyperObject(hi3, "default");
|
||||||
|
if (to == null) {
|
||||||
|
HItemStack hi4 = bukkitConnector.getBukkitCommon().getSerializableItemStack(
|
||||||
|
new ItemStack(player.getInventory().getItemInMainHand().getType()));
|
||||||
|
to = this.hyperAPI.getHyperObject(hi4, "default");
|
||||||
|
}
|
||||||
|
hyperPrice = hyperPrice + to.getSellPrice(1);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
hyperPrice = to.getSellPrice(1);
|
||||||
|
}
|
||||||
|
double hyperPricePerDurability = hyperPrice / item.getType().getMaxDurability();
|
||||||
|
price += getDurability(item) * hyperPricePerDurability;
|
||||||
|
|
||||||
|
double enchantmentModifier = Setting.ENCHANTMENT_MODIFIER.asDouble();
|
||||||
|
for (Enchantment enchantment : item2.getEnchantments().keySet()) {
|
||||||
|
if (root.keyExists("enchantment-modifiers." + enchantment.getKey().asString().toLowerCase().replace('_', '-'))) {
|
||||||
|
enchantmentModifier = root.getDouble("enchantment-modifiers."
|
||||||
|
+ enchantment.getKey().asString().toLowerCase().replace('_', '-'));
|
||||||
|
}
|
||||||
|
price += enchantmentModifier * item2.getEnchantmentLevel(enchantment);
|
||||||
|
}
|
||||||
|
|
||||||
|
return price;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ public class BlacksmithTrait extends Trait {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load(DataKey key) {
|
public void load(DataKey key) {
|
||||||
for (DataKey sub : key.getRelative("reforgeable-items").getIntegerSubKeys()) {
|
for (DataKey sub : key.getRelative("reforge-able-items").getIntegerSubKeys()) {
|
||||||
if (Material.getMaterial(sub.getString("").toUpperCase().replace('-', '_')) != null) {
|
if (Material.getMaterial(sub.getString("").toUpperCase().replace('-', '_')) != null) {
|
||||||
reforgeAbleItems.add(Material.getMaterial(sub.getString("").toUpperCase().replace('-', '_')));
|
reforgeAbleItems.add(Material.getMaterial(sub.getString("").toUpperCase().replace('-', '_')));
|
||||||
}
|
}
|
||||||
@ -78,7 +78,7 @@ public class BlacksmithTrait extends Trait {
|
|||||||
public void save(DataKey key) {
|
public void save(DataKey key) {
|
||||||
//Save all items the blacksmith knows how to reforge
|
//Save all items the blacksmith knows how to reforge
|
||||||
for (int i = 0; i < reforgeAbleItems.size(); i++) {
|
for (int i = 0; i < reforgeAbleItems.size(); i++) {
|
||||||
key.getRelative("reforgeable-items").setString(String.valueOf(i),
|
key.getRelative("reforge-able-items").setString(String.valueOf(i),
|
||||||
reforgeAbleItems.get(i).name().toLowerCase().replace('_', '-'));
|
reforgeAbleItems.get(i).name().toLowerCase().replace('_', '-'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,19 +1,25 @@
|
|||||||
package net.apunch.blacksmith.util;
|
package net.apunch.blacksmith.util;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An enum representing all of Blacksmith's settings
|
||||||
|
*/
|
||||||
public enum Setting {
|
public enum Setting {
|
||||||
BASE_PRICE("base-prices.default", 10),
|
|
||||||
PRICE_PER_DURABILITY_POINT("price-per-durability-point.default", 1),
|
BASE_PRICE("base-prices.default", 10.0),
|
||||||
|
PRICE_PER_DURABILITY_POINT("price-per-durability-point.default", 1.0),
|
||||||
BUSY_WITH_PLAYER_MESSAGE("defaults.messages.busy-with-player", "§cI'm busy at the moment. Come back later!"),
|
BUSY_WITH_PLAYER_MESSAGE("defaults.messages.busy-with-player", "§cI'm busy at the moment. Come back later!"),
|
||||||
BUSY_WITH_REFORGE_MESSAGE("defaults.messages.busy-with-reforge", "§cI'm working on it. Be patient!"),
|
BUSY_WITH_REFORGE_MESSAGE("defaults.messages.busy-with-reforge", "§cI'm working on it. Be patient!"),
|
||||||
COOL_DOWN_UNEXPIRED_MESSAGE(
|
COOL_DOWN_UNEXPIRED_MESSAGE(
|
||||||
"defaults.messages.cooldown-not-expired",
|
"defaults.messages.cool-down-not-expired",
|
||||||
"§cYou've already had your chance! Give me a break!"),
|
"§cYou've already had your chance! Give me a break!"),
|
||||||
COST_MESSAGE(
|
COST_MESSAGE(
|
||||||
"defaults.messages.cost",
|
"defaults.messages.cost",
|
||||||
"§eIt will cost §a<price> §eto reforge that §a<item>§e! Click again to reforge!"),
|
"§eIt will cost §a<price> §eto reforge that §a<item>§e! Click again to reforge!"),
|
||||||
DROP_ITEM("defaults.dropitem", true),
|
DROP_ITEM("defaults.drop-item", true),
|
||||||
DISABLE_COOL_DOWN("defaults.disablecooldown", false),
|
DISABLE_COOL_DOWN("defaults.disable-cool-down", false),
|
||||||
DISABLE_DELAY("defaults.disabledelay", false),
|
DISABLE_DELAY("defaults.disable-delay", false),
|
||||||
ENCHANTMENT_MODIFIER("enchantment-modifiers.default", 5),
|
ENCHANTMENT_MODIFIER("enchantment-modifiers.default", 5),
|
||||||
FAIL_CHANCE("defaults.percent-chance-to-fail-reforge", 10),
|
FAIL_CHANCE("defaults.percent-chance-to-fail-reforge", 10),
|
||||||
FAIL_MESSAGE("defaults.messages.fail-reforge", "§cWhoops! Didn't mean to do that! Maybe next time?"),
|
FAIL_MESSAGE("defaults.messages.fail-reforge", "§cWhoops! Didn't mean to do that! Maybe next time?"),
|
||||||
@ -28,49 +34,118 @@ public enum Setting {
|
|||||||
MAX_ENCHANTMENTS("defaults.maximum-enchantments", 3),
|
MAX_ENCHANTMENTS("defaults.maximum-enchantments", 3),
|
||||||
MAX_REFORGE_DELAY("defaults.delays-in-seconds.maximum", 30),
|
MAX_REFORGE_DELAY("defaults.delays-in-seconds.maximum", 30),
|
||||||
MIN_REFORGE_DELAY("defaults.delays-in-seconds.minimum", 5),
|
MIN_REFORGE_DELAY("defaults.delays-in-seconds.minimum", 5),
|
||||||
REFORGE_COOL_DOWN("defaults.delays-in-seconds.reforge-cooldown", 60),
|
REFORGE_COOL_DOWN("defaults.delays-in-seconds.reforge-cool-down", 60),
|
||||||
START_REFORGE_MESSAGE("defaults.messages.start-reforge", "§eOk, let's see what I can do..."),
|
START_REFORGE_MESSAGE("defaults.messages.start-reforge", "§eOk, let's see what I can do..."),
|
||||||
SUCCESS_MESSAGE("defaults.messages.successful-reforge", "There you go! All better!");
|
SUCCESS_MESSAGE("defaults.messages.successful-reforge", "There you go! All better!"),
|
||||||
|
NATURAL_COST("defaults.natural-cost", true);
|
||||||
|
|
||||||
private final String path;
|
private final String path;
|
||||||
|
private final String childPath;
|
||||||
private Object value;
|
private Object value;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new setting
|
||||||
|
*
|
||||||
|
* @param path <p>The full config path for this setting</p>
|
||||||
|
* @param value <p>The default value of this setting</p>
|
||||||
|
*/
|
||||||
Setting(String path, Object value) {
|
Setting(String path, Object value) {
|
||||||
this.path = path;
|
this.path = path;
|
||||||
this.value = value;
|
this.value = value;
|
||||||
|
String[] pathParts = path.split("\\.");
|
||||||
|
this.childPath = String.join(".", Arrays.copyOfRange(pathParts, 1, pathParts.length));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the full config path for this setting
|
||||||
|
*
|
||||||
|
* @return <p>The full config path for this setting</p>
|
||||||
|
*/
|
||||||
public String getPath() {
|
public String getPath() {
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean asBoolean() {
|
/**
|
||||||
return (Boolean) value;
|
* Gets the config path without the root node
|
||||||
|
*
|
||||||
|
* @return <p>The config path without the root node</p>
|
||||||
|
*/
|
||||||
|
public String getChildPath() {
|
||||||
|
return childPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets this setting as a boolean
|
||||||
|
*
|
||||||
|
* <p>This will throw an exception if used for a non-boolean value</p>
|
||||||
|
*
|
||||||
|
* @return <p>This setting as a boolean</p>
|
||||||
|
*/
|
||||||
|
public boolean asBoolean() {
|
||||||
|
if (value instanceof String) {
|
||||||
|
return Boolean.parseBoolean((String) value);
|
||||||
|
} else {
|
||||||
|
return (Boolean) value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets this setting as a double
|
||||||
|
*
|
||||||
|
* <p>This will throw an exception if used for a non-double setting</p>
|
||||||
|
*
|
||||||
|
* @return <p>This setting as a double</p>
|
||||||
|
*/
|
||||||
public double asDouble() {
|
public double asDouble() {
|
||||||
if (value instanceof String) {
|
if (value instanceof String) {
|
||||||
return Double.parseDouble((String) value);
|
return Double.parseDouble((String) value);
|
||||||
|
} else if (value instanceof Integer) {
|
||||||
|
return (Integer) value;
|
||||||
|
} else {
|
||||||
|
return (Double) value;
|
||||||
}
|
}
|
||||||
if (value instanceof Integer) {
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets this setting as an integer
|
||||||
|
*
|
||||||
|
* <p>This will throw an exception if used for a non-integer setting</p>
|
||||||
|
*
|
||||||
|
* @return <p>This setting as an integer</p>
|
||||||
|
*/
|
||||||
|
public int asInt() {
|
||||||
|
if (value instanceof String) {
|
||||||
|
return Integer.parseInt((String) value);
|
||||||
|
} else {
|
||||||
return (Integer) value;
|
return (Integer) value;
|
||||||
}
|
}
|
||||||
return (Double) value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int asInt() {
|
|
||||||
return (Integer) value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets this setting as a string
|
||||||
|
*
|
||||||
|
* @return <p>This setting as a string</p>
|
||||||
|
*/
|
||||||
public String asString() {
|
public String asString() {
|
||||||
return value.toString();
|
return value.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value of this setting
|
||||||
|
*
|
||||||
|
* @return <p>The value of this setting</p>
|
||||||
|
*/
|
||||||
Object get() {
|
Object get() {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the value of this setting
|
||||||
|
*
|
||||||
|
* @param value <p>The new value of this setting</p>
|
||||||
|
*/
|
||||||
void set(Object value) {
|
void set(Object value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,9 @@ import net.citizensnpcs.api.util.YamlStorage;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A class which keeps track of all Blacksmith settings/config values
|
||||||
|
*/
|
||||||
public class Settings {
|
public class Settings {
|
||||||
|
|
||||||
private String busyWithPlayerMessage = Setting.BUSY_WITH_PLAYER_MESSAGE.asString();
|
private String busyWithPlayerMessage = Setting.BUSY_WITH_PLAYER_MESSAGE.asString();
|
||||||
@ -27,187 +30,328 @@ public class Settings {
|
|||||||
private boolean dropItem = Setting.DROP_ITEM.asBoolean();
|
private boolean dropItem = Setting.DROP_ITEM.asBoolean();
|
||||||
private boolean disableCoolDown = Setting.DISABLE_COOL_DOWN.asBoolean();
|
private boolean disableCoolDown = Setting.DISABLE_COOL_DOWN.asBoolean();
|
||||||
private boolean disableDelay = Setting.DISABLE_DELAY.asBoolean();
|
private boolean disableDelay = Setting.DISABLE_DELAY.asBoolean();
|
||||||
|
private boolean naturalCost = Setting.NATURAL_COST.asBoolean();
|
||||||
private final YamlStorage config;
|
private final YamlStorage config;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new "Settings"
|
||||||
|
*
|
||||||
|
* @param plugin <p>A reference to the blacksmith plugin</p>
|
||||||
|
*/
|
||||||
public Settings(BlacksmithPlugin plugin) {
|
public Settings(BlacksmithPlugin plugin) {
|
||||||
config = new YamlStorage(new File(plugin.getDataFolder() + File.separator + "config.yml"), "Blacksmith Configuration");
|
config = new YamlStorage(new File(plugin.getDataFolder() + File.separator + "config.yml"),
|
||||||
|
"Blacksmith Configuration\nWarning: The values under defaults are the values set for a blacksmith" +
|
||||||
|
"upon creation. To change any values for existing NPCs, edit the citizens NPC file.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads all configuration values from the config file
|
||||||
|
*/
|
||||||
public void load() {
|
public void load() {
|
||||||
|
//Load the config from disk
|
||||||
config.load();
|
config.load();
|
||||||
DataKey root = config.getKey("");
|
DataKey root = config.getKey("");
|
||||||
for (Setting setting : Setting.values()) {
|
for (Setting setting : Setting.values()) {
|
||||||
if (!root.keyExists(setting.getPath())) {
|
if (!root.keyExists(setting.getPath())) {
|
||||||
|
//If the setting does not exist in the config file, add it
|
||||||
root.setRaw(setting.getPath(), setting.get());
|
root.setRaw(setting.getPath(), setting.get());
|
||||||
} else {
|
} else {
|
||||||
|
//Set the setting to the value found in the path
|
||||||
setting.set(root.getRaw(setting.getPath()));
|
setting.set(root.getRaw(setting.getPath()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//Save any modified values to disk
|
||||||
config.save();
|
config.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the configuration used for saving/loading from disk
|
||||||
|
*
|
||||||
|
* @return <p>The configuration</p>
|
||||||
|
*/
|
||||||
public YamlStorage getConfig() {
|
public YamlStorage getConfig() {
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads variables from the given data key
|
||||||
|
*
|
||||||
|
* @param key <p>The data key to load variables from</p>
|
||||||
|
*/
|
||||||
public void loadVariables(DataKey key) {
|
public void loadVariables(DataKey key) {
|
||||||
// Override defaults if they exist
|
// Override defaults if they exist
|
||||||
if (key.keyExists("messages.busy-with-player")) {
|
if (key.keyExists(Setting.BUSY_WITH_PLAYER_MESSAGE.getChildPath())) {
|
||||||
busyWithPlayerMessage = key.getString("messages.busy-with-player");
|
busyWithPlayerMessage = key.getString(Setting.BUSY_WITH_PLAYER_MESSAGE.getChildPath());
|
||||||
}
|
}
|
||||||
if (key.keyExists("messages.busy-with-reforge")) {
|
if (key.keyExists(Setting.BUSY_WITH_REFORGE_MESSAGE.getChildPath())) {
|
||||||
busyReforgingMessage = key.getString("messages.busy-with-reforge");
|
busyReforgingMessage = key.getString(Setting.BUSY_WITH_REFORGE_MESSAGE.getChildPath());
|
||||||
}
|
}
|
||||||
if (key.keyExists("messages.cost")) {
|
if (key.keyExists(Setting.COST_MESSAGE.getChildPath())) {
|
||||||
costMessage = key.getString("messages.cost");
|
costMessage = key.getString(Setting.COST_MESSAGE.getChildPath());
|
||||||
}
|
}
|
||||||
if (key.keyExists("messages.invalid-item")) {
|
if (key.keyExists(Setting.INVALID_ITEM_MESSAGE.getChildPath())) {
|
||||||
invalidItemMessage = key.getString("messages.invalid-item");
|
invalidItemMessage = key.getString(Setting.INVALID_ITEM_MESSAGE.getChildPath());
|
||||||
}
|
}
|
||||||
if (key.keyExists("messages.start-reforge")) {
|
if (key.keyExists(Setting.START_REFORGE_MESSAGE.getChildPath())) {
|
||||||
startReforgeMessage = key.getString("messages.start-reforge");
|
startReforgeMessage = key.getString(Setting.START_REFORGE_MESSAGE.getChildPath());
|
||||||
}
|
}
|
||||||
if (key.keyExists("messages.successful-reforge")) {
|
if (key.keyExists(Setting.SUCCESS_MESSAGE.getChildPath())) {
|
||||||
successMessage = key.getString("messages.successful-reforge");
|
successMessage = key.getString(Setting.SUCCESS_MESSAGE.getChildPath());
|
||||||
}
|
}
|
||||||
if (key.keyExists("messages.fail-reforge")) {
|
if (key.keyExists(Setting.FAIL_MESSAGE.getChildPath())) {
|
||||||
failMessage = key.getString("messages.fail-reforge");
|
failMessage = key.getString(Setting.FAIL_MESSAGE.getChildPath());
|
||||||
}
|
}
|
||||||
if (key.keyExists("messages.insufficient-funds")) {
|
if (key.keyExists(Setting.INSUFFICIENT_FUNDS_MESSAGE.getChildPath())) {
|
||||||
insufficientFundsMessage = key.getString("messages.insufficient-funds");
|
insufficientFundsMessage = key.getString(Setting.INSUFFICIENT_FUNDS_MESSAGE.getChildPath());
|
||||||
}
|
}
|
||||||
if (key.keyExists("messages.cooldown-not-expired")) {
|
if (key.keyExists(Setting.COOL_DOWN_UNEXPIRED_MESSAGE.getChildPath())) {
|
||||||
coolDownUnexpiredMessage = key.getString("messages.cooldown-not-expired");
|
coolDownUnexpiredMessage = key.getString(Setting.COOL_DOWN_UNEXPIRED_MESSAGE.getChildPath());
|
||||||
}
|
}
|
||||||
if (key.keyExists("messages.item-changed-during-reforge")) {
|
if (key.keyExists(Setting.ITEM_UNEXPECTEDLY_CHANGED_MESSAGE.getChildPath())) {
|
||||||
itemChangedMessage = key.getString("messages.item-changed-during-reforge");
|
itemChangedMessage = key.getString(Setting.ITEM_UNEXPECTEDLY_CHANGED_MESSAGE.getChildPath());
|
||||||
}
|
}
|
||||||
if (key.keyExists("delays-in-seconds.minimum")) {
|
if (key.keyExists(Setting.MIN_REFORGE_DELAY.getChildPath())) {
|
||||||
minReforgeDelay = key.getInt("delays-in-seconds.minimum");
|
minReforgeDelay = key.getInt(Setting.MIN_REFORGE_DELAY.getChildPath());
|
||||||
}
|
}
|
||||||
if (key.keyExists("delays-in-seconds.maximum")) {
|
if (key.keyExists(Setting.MAX_REFORGE_DELAY.getChildPath())) {
|
||||||
maxReforgeDelay = key.getInt("delays-in-seconds.maximum");
|
maxReforgeDelay = key.getInt(Setting.MAX_REFORGE_DELAY.getChildPath());
|
||||||
}
|
}
|
||||||
if (key.keyExists("delays-in-seconds.reforge-cooldown")) {
|
if (key.keyExists(Setting.REFORGE_COOL_DOWN.getChildPath())) {
|
||||||
reforgeCoolDown = key.getInt("delays-in-seconds.reforge-cooldown");
|
reforgeCoolDown = key.getInt(Setting.REFORGE_COOL_DOWN.getChildPath());
|
||||||
}
|
}
|
||||||
if (key.keyExists("percent-chance-to-fail-reforge")) {
|
if (key.keyExists(Setting.FAIL_CHANCE.getChildPath())) {
|
||||||
failChance = key.getInt("percent-chance-to-fail-reforge");
|
failChance = key.getInt(Setting.FAIL_CHANCE.getChildPath());
|
||||||
}
|
}
|
||||||
if (key.keyExists("maximum-enchantments")) {
|
if (key.keyExists(Setting.MAX_ENCHANTMENTS.getChildPath())) {
|
||||||
maxEnchantments = key.getInt("maximum-enchantments");
|
maxEnchantments = key.getInt(Setting.MAX_ENCHANTMENTS.getChildPath());
|
||||||
}
|
}
|
||||||
if (key.keyExists("extra-enchantments-chance")) {
|
if (key.keyExists(Setting.EXTRA_ENCHANTMENT_CHANCE.getChildPath())) {
|
||||||
extraEnchantmentChance = key.getInt("extra-enchantment-chance");
|
extraEnchantmentChance = key.getInt(Setting.EXTRA_ENCHANTMENT_CHANCE.getChildPath());
|
||||||
}
|
}
|
||||||
if (key.keyExists("dropitem")) {
|
if (key.keyExists(Setting.DROP_ITEM.getChildPath())) {
|
||||||
dropItem = key.getBoolean("dropitem");
|
dropItem = key.getBoolean(Setting.DROP_ITEM.getChildPath());
|
||||||
}
|
}
|
||||||
if (key.keyExists("disable-cooldown")) {
|
if (key.keyExists(Setting.DISABLE_COOL_DOWN.getChildPath())) {
|
||||||
disableCoolDown = key.getBoolean("disable-cooldown");
|
disableCoolDown = key.getBoolean(Setting.DISABLE_COOL_DOWN.getChildPath());
|
||||||
}
|
}
|
||||||
if (key.keyExists("disable-delay")) {
|
if (key.keyExists(Setting.DISABLE_DELAY.getChildPath())) {
|
||||||
disableDelay = key.getBoolean("disable-delay");
|
disableDelay = key.getBoolean(Setting.DISABLE_DELAY.getChildPath());
|
||||||
|
}
|
||||||
|
if (key.keyExists(Setting.NATURAL_COST.getChildPath())) {
|
||||||
|
naturalCost = key.getBoolean(Setting.NATURAL_COST.getChildPath());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Saves variables to the given data key
|
||||||
|
*
|
||||||
|
* @param key <p>The data key to save variables to</p>
|
||||||
|
*/
|
||||||
public void saveVariables(DataKey key) {
|
public void saveVariables(DataKey key) {
|
||||||
key.setString("messages.busy-with-player", getBusyWithPlayerMessage());
|
//This saves variables to the specific NPC.
|
||||||
key.setString("messages.busy-with-reforge", getBusyReforgingMessage());
|
key.setString(Setting.BUSY_WITH_PLAYER_MESSAGE.getChildPath(), getBusyWithPlayerMessage());
|
||||||
key.setString("messages.cost", getCostMessage());
|
key.setString(Setting.BUSY_WITH_REFORGE_MESSAGE.getChildPath(), getBusyReforgingMessage());
|
||||||
key.setString("messages.invalid-item", getInvalidItemMessage());
|
key.setString(Setting.COST_MESSAGE.getChildPath(), getCostMessage());
|
||||||
key.setString("messages.start-reforge", getStartReforgeMessage());
|
key.setString(Setting.INVALID_ITEM_MESSAGE.getChildPath(), getInvalidItemMessage());
|
||||||
key.setString("messages.successful-reforge", getSuccessMessage());
|
key.setString(Setting.START_REFORGE_MESSAGE.getChildPath(), getStartReforgeMessage());
|
||||||
key.setString("messages.fail-reforge", getFailMessage());
|
key.setString(Setting.SUCCESS_MESSAGE.getChildPath(), getSuccessMessage());
|
||||||
key.setString("messages.insufficient-funds", getInsufficientFundsMessage());
|
key.setString(Setting.FAIL_MESSAGE.getChildPath(), getFailMessage());
|
||||||
key.setString("messages.cooldown-not-expired", getCoolDownUnexpiredMessage());
|
key.setString(Setting.INSUFFICIENT_FUNDS_MESSAGE.getChildPath(), getInsufficientFundsMessage());
|
||||||
key.setString("messages.item-changed-during-reforge", getItemChangedMessage());
|
key.setString(Setting.COOL_DOWN_UNEXPIRED_MESSAGE.getChildPath(), getCoolDownUnexpiredMessage());
|
||||||
key.setInt("delays-in-seconds.minimum", getMinReforgeDelay());
|
key.setString(Setting.ITEM_UNEXPECTEDLY_CHANGED_MESSAGE.getChildPath(), getItemChangedMessage());
|
||||||
key.setInt("delays-in-seconds.maximum", getMaxReforgeDelay());
|
key.setInt(Setting.MIN_REFORGE_DELAY.getChildPath(), getMinReforgeDelay());
|
||||||
key.setInt("delays-in-seconds.reforge-cooldown", getReforgeCoolDown());
|
key.setInt(Setting.MAX_REFORGE_DELAY.getChildPath(), getMaxReforgeDelay());
|
||||||
key.setInt("percent-chance-to-fail-reforge", getFailChance());
|
key.setInt(Setting.REFORGE_COOL_DOWN.getChildPath(), getReforgeCoolDown());
|
||||||
key.setInt("percent-chance-for-extra-enchantment", getExtraEnchantmentChance());
|
key.setInt(Setting.FAIL_CHANCE.getChildPath(), getFailChance());
|
||||||
key.setInt("maximum-enchantments", getMaxEnchantments());
|
key.setInt(Setting.EXTRA_ENCHANTMENT_CHANCE.getChildPath(), getExtraEnchantmentChance());
|
||||||
key.setBoolean("drop-item", getDropItem());
|
key.setInt(Setting.MAX_ENCHANTMENTS.getChildPath(), getMaxEnchantments());
|
||||||
key.setBoolean("disable-delay", getDisableDelay());
|
key.setBoolean(Setting.DROP_ITEM.getChildPath(), getDropItem());
|
||||||
key.setBoolean("disable-cooldown", getDisableCoolDown());
|
key.setBoolean(Setting.DISABLE_DELAY.getChildPath(), getDisableDelay());
|
||||||
|
key.setBoolean(Setting.DISABLE_COOL_DOWN.getChildPath(), getDisableCoolDown());
|
||||||
|
key.setBoolean(Setting.DISABLE_COOL_DOWN.getChildPath(), getDisableCoolDown());
|
||||||
|
key.setBoolean(Setting.NATURAL_COST.getChildPath(), getNaturalCost());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the message to display when the blacksmith is busy with another player
|
||||||
|
*
|
||||||
|
* @return <p>The busy with player message</p>
|
||||||
|
*/
|
||||||
public String getBusyWithPlayerMessage() {
|
public String getBusyWithPlayerMessage() {
|
||||||
return busyWithPlayerMessage;
|
return busyWithPlayerMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the message to display when the blacksmith is busy with reforging an item
|
||||||
|
*
|
||||||
|
* @return <p>The busy reforging message</p>
|
||||||
|
*/
|
||||||
public String getBusyReforgingMessage() {
|
public String getBusyReforgingMessage() {
|
||||||
return busyReforgingMessage;
|
return busyReforgingMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the message to use for displaying an item's cost
|
||||||
|
*
|
||||||
|
* @return <p>The message to use for displaying item cost</p>
|
||||||
|
*/
|
||||||
public String getCostMessage() {
|
public String getCostMessage() {
|
||||||
return costMessage;
|
return costMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the message to display when a blacksmith has been given an invalid item
|
||||||
|
*
|
||||||
|
* @return <p>The invalid item message</p>
|
||||||
|
*/
|
||||||
public String getInvalidItemMessage() {
|
public String getInvalidItemMessage() {
|
||||||
return invalidItemMessage;
|
return invalidItemMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the message to display when a blacksmith starts reforging an item
|
||||||
|
*
|
||||||
|
* @return <p>The start reforge message</p>
|
||||||
|
*/
|
||||||
public String getStartReforgeMessage() {
|
public String getStartReforgeMessage() {
|
||||||
return startReforgeMessage;
|
return startReforgeMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the message to display when a blacksmith has successfully repaired an item
|
||||||
|
*
|
||||||
|
* @return <p>The reforge success message</p>
|
||||||
|
*/
|
||||||
public String getSuccessMessage() {
|
public String getSuccessMessage() {
|
||||||
return successMessage;
|
return successMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the message to display when a blacksmith has failed to repair an item
|
||||||
|
*
|
||||||
|
* @return <p>The reforge fail message</p>
|
||||||
|
*/
|
||||||
public String getFailMessage() {
|
public String getFailMessage() {
|
||||||
return failMessage;
|
return failMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the message to display when a player cannot afford re-forging an item
|
||||||
|
*
|
||||||
|
* @return <p>The insufficient funds message</p>
|
||||||
|
*/
|
||||||
public String getInsufficientFundsMessage() {
|
public String getInsufficientFundsMessage() {
|
||||||
return insufficientFundsMessage;
|
return insufficientFundsMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the message to display when a blacksmith is still affected by a cool-down
|
||||||
|
*
|
||||||
|
* @return <p>The cool down unexpired message</p>
|
||||||
|
*/
|
||||||
public String getCoolDownUnexpiredMessage() {
|
public String getCoolDownUnexpiredMessage() {
|
||||||
return coolDownUnexpiredMessage;
|
return coolDownUnexpiredMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the message to display when a player has changed the item they're trying to reforge
|
||||||
|
*
|
||||||
|
* @return <p>The item changed message</p>
|
||||||
|
*/
|
||||||
public String getItemChangedMessage() {
|
public String getItemChangedMessage() {
|
||||||
return itemChangedMessage;
|
return itemChangedMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the minimum delay used to wait for a re-forge to finish.
|
||||||
|
*
|
||||||
|
* @return <p>The minimum reforge delay</p>
|
||||||
|
*/
|
||||||
public int getMinReforgeDelay() {
|
public int getMinReforgeDelay() {
|
||||||
return minReforgeDelay;
|
return minReforgeDelay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the maximum delay used to wait for a re-forge to finish
|
||||||
|
*
|
||||||
|
* @return <p>The maximum reforge delay</p>
|
||||||
|
*/
|
||||||
public int getMaxReforgeDelay() {
|
public int getMaxReforgeDelay() {
|
||||||
return maxReforgeDelay;
|
return maxReforgeDelay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the cool-down between each reforge
|
||||||
|
*
|
||||||
|
* @return <p>The reforge cool-down</p>
|
||||||
|
*/
|
||||||
public int getReforgeCoolDown() {
|
public int getReforgeCoolDown() {
|
||||||
return reforgeCoolDown;
|
return reforgeCoolDown;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the chance to fail a re-forge
|
||||||
|
*
|
||||||
|
* @return <p>The fail chance</p>
|
||||||
|
*/
|
||||||
public int getFailChance() {
|
public int getFailChance() {
|
||||||
return failChance;
|
return failChance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the chance for adding an extra enchantment to an item
|
||||||
|
*
|
||||||
|
* @return <p>The extra enchantment chance</p>
|
||||||
|
*/
|
||||||
public int getExtraEnchantmentChance() {
|
public int getExtraEnchantmentChance() {
|
||||||
return extraEnchantmentChance;
|
return extraEnchantmentChance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the max number of enchantment to add to an item
|
||||||
|
*
|
||||||
|
* @return <p>The maximum enchantments</p>
|
||||||
|
*/
|
||||||
public int getMaxEnchantments() {
|
public int getMaxEnchantments() {
|
||||||
return maxEnchantments;
|
return maxEnchantments;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets whether an item should be dropped on the ground instead of being given to the player
|
||||||
|
*
|
||||||
|
* @return <p>Whether to drop reforged items on the ground</p>
|
||||||
|
*/
|
||||||
public boolean getDropItem() {
|
public boolean getDropItem() {
|
||||||
return dropItem;
|
return dropItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets whether to disable the reforge-cool-down
|
||||||
|
*
|
||||||
|
* @return <p>Whether to disable the reforge-cool-down</p>
|
||||||
|
*/
|
||||||
public boolean getDisableCoolDown() {
|
public boolean getDisableCoolDown() {
|
||||||
return disableCoolDown;
|
return disableCoolDown;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets whether to disable the delay between starting reforging and the re-forge finishing
|
||||||
|
*
|
||||||
|
* @return <p>Whether to disable the reforge delay</p>
|
||||||
|
*/
|
||||||
public boolean getDisableDelay() {
|
public boolean getDisableDelay() {
|
||||||
return disableDelay;
|
return disableDelay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets whether to use a natural cost calculation
|
||||||
|
*
|
||||||
|
* <p>The natural cost makes repairs more expensive the more damaged an item is, rather than the opposite.</p>
|
||||||
|
*
|
||||||
|
* @return <p>Whether to use a natural cost calculation</p>
|
||||||
|
*/
|
||||||
|
public boolean getNaturalCost() {
|
||||||
|
return naturalCost;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user