Broken commit implementing a lot of book-splitting code
Some checks failed
EpicKnarvik97/Blacksmith/pipeline/head There was a failure building this commit

This commit is contained in:
2024-11-27 12:16:57 +01:00
parent 90d3c49c12
commit e3dbeccc14
11 changed files with 438 additions and 13 deletions

View File

@ -7,6 +7,7 @@ import net.knarcraft.blacksmith.util.ConfigHelper;
import net.knarcraft.blacksmith.util.ItemHelper;
import org.bukkit.Material;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@ -212,6 +213,42 @@ public class GlobalScrapperSettings implements Settings<ScrapperSetting> {
return asDouble(ScrapperSetting.NETHERITE_SALVAGE_COST);
}
/**
* Gets the base cost of salvaging an enchanted book
*
* @return <p>The enchanted book salvage base cost</p>
*/
public double getEnchantedBookSalvageCost() {
return asDouble(ScrapperSetting.ENCHANTED_BOOK_SALVAGE_BASE_COST);
}
/**
* Gets the item cost of salvaging an enchanted book
*
* @return <p>The enchanted book salvage cost</p>
*/
public ItemStack getEnchantedBookItemCost() {
return ScrapperSetting.ENCHANTED_BOOK_SALVAGE_ITEM_COST;
}
/**
* Whether to multiply the cost of salvaging enchanted books based on the number of enchantments
*
* @return <p>Whether to multiply the cost of salvaging enchanted books based on the number of enchantments</p>
*/
public boolean multiplyEnchantedBookSalvageCost() {
return asBoolean(ScrapperSetting.ENCHANTED_BOOK_SALVAGE_MULTIPLY);
}
/**
* Whether to require both a monetary and item-based cost when salvaging enchanted books
*
* @return <p>Whether to require both a monetary and item-based cost when salvaging enchanted books</p>
*/
public boolean requireMoneyAndItemForEnchantedBookSalvage() {
return asBoolean(ScrapperSetting.ENCHANTED_BOOK_SALVAGE_REQUIRE_BOTH);
}
/**
* Gets trash salvage for the given material
*

View File

@ -83,6 +83,15 @@ public class ScrapperNPCSettings implements TraitSettings<ScrapperSetting> {
}
}
/**
* Gets whether this scrapper is able to split an enchanted book
*
* @return <p>True if this scrapper is able to split an enchanted book</p>
*/
public boolean splitEnchantedBook() {
return asBoolean(ScrapperSetting.SPLIT_ENCHANTED_BOOK);
}
/**
* Gets the raw current value of a setting
*
@ -171,6 +180,15 @@ public class ScrapperNPCSettings implements TraitSettings<ScrapperSetting> {
return asString(ScrapperSetting.COST_MESSAGE_NETHERITE);
}
/**
* Gets the message to use for displaying enchanted book salvage cost
*
* @return <p>The message to use for displaying enchanted book salvage cost</p>
*/
public String getEnchantedBookCostMessage() {
return asString(ScrapperSetting.COST_MESSAGE_ENCHANTED_BOOK);
}
@Override
@NotNull
public String getCoolDownUnexpiredMessage() {
@ -466,4 +484,34 @@ public class ScrapperNPCSettings implements TraitSettings<ScrapperSetting> {
return asString(ScrapperSetting.CANNOT_SALVAGE_NETHERITE_MESSAGE);
}
/**
* Gets the message to display when explaining that this scrapper is unable to salvage enchanted books
*
* @return <p>The message to display when explaining that this scrapper is unable to salvage enchanted books</p>
*/
@NotNull
public String getCannotSalvageEnchantedBookMessage() {
return asString(ScrapperSetting.CANNOT_SALVAGE_ENCHANTED_BOOK_MESSAGE);
}
/**
* Gets the message to display when explaining that the scrapper needs to be provided more items for enchanted book salvage
*
* @return <p>The message to display when explaining that the scrapper needs to be provided more items for enchanted book salvage</p>
*/
@NotNull
public String getNotEnoughItemsMessage() {
return asString(ScrapperSetting.NOT_ENOUGH_ITEMS_MESSAGE);
}
/**
* Gets the message to display when explaining that the scrapper cannot salvage an enchanted book with a single enchantment
*
* @return <p>The message to display when explaining that the scrapper cannot salvage an enchanted book with a single enchantment</p>
*/
@NotNull
public String getCannotSplitEnchantedBookFurtherMessage() {
return asString(ScrapperSetting.CANNOT_SPLIT_ENCHANTED_BOOK_FURTHER_MESSAGE);
}
}

View File

@ -91,6 +91,12 @@ public enum ScrapperSetting implements Setting {
*/
SALVAGE_NETHERITE("salvageNetherite", SettingValueType.BOOLEAN, true,
"Whether to enable salvaging of netherite items", true, false),
/**
* The setting for whether the NPC should allow salvaging an enchanted books with several enchantments into several books with one enchantment
*/
SPLIT_ENCHANTED_BOOK("splitEnchantedBook", SettingValueType.BOOLEAN, false, "Whether to enable " +
"splitting of enchanted books", true, false),
/*-----------
| Messages |
@ -194,6 +200,13 @@ public enum ScrapperSetting implements Setting {
"&eIt will cost &a{cost}&e to salvage that &a{item}&e into diamond!",
"The message to display when explaining the shown item's netherite salvage cost", true, true),
/**
* The message displayed when displaying the cost of salvaging the player's held enchanted book
*/
COST_MESSAGE_ENCHANTED_BOOK("costMessageEnchantedBook", SettingValueType.STRING,
"&eIt will cost &a{cost}&e to salvage that enchanted book!",
"The message to display when explaining the shown enchanted book's salvage cost", true, true),
/**
* The message displayed when explaining that all items will be returned as salvage
*/
@ -236,6 +249,27 @@ public enum ScrapperSetting implements Setting {
"&cI'm sorry, but I'm unable to salvage netherite items!",
"The message to display when asked to salvage netherite items, and that option is disabled", true, true),
/**
* The message displayed when explaining that enchanted book salvage is disabled
*/
CANNOT_SALVAGE_ENCHANTED_BOOK_MESSAGE("cannotSalvageEnchantedBookMessage", SettingValueType.STRING,
"&cI'm sorry, but I'm unable to salvage enchanted books!",
"The message to display when asked to salvage enchanted books, and the option is disabled", true, true),
/**
* The message displayed when explaining that a player needs to provide items to salvage an enchanted book
*/
NOT_ENOUGH_ITEMS_MESSAGE("notEnoughItemsMessage", SettingValueType.STRING,
"&cI'm sorry, but you need to provide enough items for salvaging the enchanted book",
"The message displayed when a player attempts to salvage an enchanted book without providing enough items", true, true),
/**
* The message displayed when explaining that a player cannot salvage an enchanted book containing a single enchantment
*/
CANNOT_SPLIT_ENCHANTED_BOOK_FURTHER_MESSAGE("cannotSplitEnchantedBookFurtherMessage", SettingValueType.STRING,
"&cI'm sorry, but I cannot salvage that enchanted book any further",
"The message displayed when a player attempts to salvage an enchanted book with a single enchantment", true, true),
/**
* The message displayed when clicking a scrapper with an empty hand
*/
@ -264,6 +298,30 @@ public enum ScrapperSetting implements Setting {
NETHERITE_SALVAGE_COST("netheriteSalvagePrice", SettingValueType.POSITIVE_DOUBLE, 15,
"The cost of using the scrapper to remove netherite from an item", false, false),
/**
* The setting for the enchanted book salvage cost
*/
ENCHANTED_BOOK_SALVAGE_BASE_COST("enchantedBookSalvageBasePrice", SettingValueType.POSITIVE_DOUBLE, 10,
"The per-enchantment cost of splitting an enchanted book", false, false),
/**
* The setting for the enchanted book item cost
*/
ENCHANTED_BOOK_SALVAGE_ITEM_COST("enchantedBookSalvageItemCost", SettingValueType.ITEM_STACK, null,
"The item that needs to be provided in order to salvage an enchanted book", false, false),
/**
* The setting for whether to multiply enchanted book cost
*/
ENCHANTED_BOOK_SALVAGE_MULTIPLY("enchantedBookSalvageMultiplyByEnchantmentNumber", SettingValueType.BOOLEAN,
true, "Whether to multiply the cost of salvaging an enchanted book by the number of enchantments on the book", false, false),
/**
* The setting for whether to require both monetary and item payment for salvaging enchanted books
*/
ENCHANTED_BOOK_SALVAGE_REQUIRE_BOTH("enchantedBookSalvageRequireMoneyAndItem", SettingValueType.BOOLEAN,
true, "Whether salvaging an enchanted book will cost both the configured money amount and the configured item", false, false),
/**
* Whether to display exact time in minutes and seconds when displaying a remaining cool-down
*/