Finishes the scrapper implementation
Some checks failed
EpicKnarvik97/Blacksmith/pipeline/head There was a failure building this commit

This commit is contained in:
2024-05-04 01:01:56 +02:00
parent 455db78988
commit 4012e532da
30 changed files with 501 additions and 216 deletions

View File

@@ -26,41 +26,57 @@ fee. Costs are highly customizable.
To create a new blacksmith, simply add the blacksmith trait to an NPC by selecting it with `/npc select`, and then using
`/trait add Blacksmith` (See Citizens' documentation for more details).
Right-clicking the NPC will tell you if the currently held item is repairable by the blacksmith. If it is, the
blacksmith should give a price quote. Right-clicking again starts the repair. The item should be given back or dropped
after a random delay according to the set limits.
To create a new scrapper, simply add the scrapper trait to an NPC by selecting it with `/npc select`, and then using
`/trait add Scrapper` (See Citizens' documentation for more details).
While costs are always set globally (no blacksmith can do the same job for cheaper), the blacksmith's messages,
cool-down between each reforge, whether the item is dropped or given, the chance of failing or adding an enchantment,
the maximum number of added enchantments, max and min delays, the length of the cool-down and which items the blacksmith
is able to reforge can be changed individually.
Right-clicking the NPC will tell you if the currently held item is repairable by the blacksmith / salvageable by the
scrapper. If it is, the blacksmith / scrapper should give a price quote. Right-clicking again starts the repair /
salvage. The item should be given back or dropped after a random delay according to the set limits.
While costs are always set globally (no blacksmith or scrapper can do the same job for cheaper), the blacksmith /
scrapper's messages, cool-down between each reforge / salvage, whether the item is dropped or given, the chance of
failing or adding an enchantment, the maximum number of added enchantments, max and min delays, the length of the
cool-down and which items the blacksmith is able to reforge / salvage can be changed individually.
Also note: As a change from the original plugin, unless a value for an NPC has been explicitly set for that NPC, it will
mirror the values set in config.yml. This also means that configuration values aren't populated automatically in
citizen's NPC save file. While you can manually set the values using the same keys as in config.yml, you should use the
/blacksmith command when possible.
`/blacksmith` or `/scrapper` command when possible.
### Special behavior
In addition to just being able to repair items, blacksmiths have some random features which can be cool or annoying:
In addition to just being able to repair items, blacksmiths / scrappers have some random features which can be cool or
annoying:
- There is a chance that blacksmiths fail to repair an item, leaving it at about the same durability as before. Use
- There is a chance that blacksmiths / scrappers fail to repair an item, leaving it at about the same durability as
before (scrappers with `extendedSalvageEnabled` turned on might cause items in a stack to be lost). Use
failReforgeChance to control the chance. Set it to 0 to remove the feature.
- There is a chance a blacksmith may add an enchantment to a reforged item. You can control the probability using
extraEnchantmentChance, and set the maximum number of enchantments using maxEnchantments. EnchantmentBlocklist can be
extraEnchantmentChance, and set the maximum number of enchantments using maxEnchantments. EnchantmentBlockList can be
used to block any enchantments you don't want to randomly grant.
### Scrapper basics
A scrapper will produce salvage for a damage-able item by calculating the amount of items returned based on items in the
recipe, and the percentage of durability left on the item. To avoid returning relatively worthless items instead of
valuable items, `ignoredSalvage` can be configured. If the item is fully repaired, the worthless items will be returned
as well, but otherwise, only the valuable items are considered as possible salvage. A scrapper will by default only
salvage damage-able items (same as blacksmiths), but enabling `extendedSalvageEnabled` for a scrapper will allow it to
salvage any crafting table recipe. Note that to salvage for example planks into wood, four wood will be taken.
When an item is salvaged, EXP will be returned based on enchantments on the item.
## Commands
| Command | Arguments | Description |
|-------------------|-------------------------------|----------------------------------------------------------------------------------------------|
| /blacksmith | \<option> \[new-value] | Changes a configuration option for the selected blacksmith (use Citizens' /npc select first) |
| /blacksmithconfig | \<reload/option> \[new-value] | Changes a default/global blacksmith configuration value |
| /blacksmithConfig | \<reload/option> \[new-value] | Changes a default/global blacksmith configuration value |
| /scrapper | \<option> \[new-value] | Changes a configuration option for the selected scrapper (use Citizens' /npc select first) |
| /scrapperconfig | \<reload/option> \[new-value] | Changes a default/global scrapper configuration value |
| /scrapperConfig | \<reload/option> \[new-value] | Changes a default/global scrapper configuration value |
| /preset | \<preset>\[:filter] | Displays all materials included in the given preset, after applying the filter if set |
For /blacksmith, /blacksmithconfig, /scrapper and /scrapperconfig, if a new value isn't specified, a description of the
For /blacksmith, /blacksmithConfig, /scrapper and /scrapperConfig, if a new value isn't specified, a description of the
configuration option, and the current value, is displayed instead.
For /blacksmith or /scrapper, using -1 or null as the value will clear a custom value, making the NPC use the default
@@ -171,15 +187,15 @@ All currently supported presets, and available filters for each preset:
| failReforgeRemovesEnchantments | true/false | Whether a failed reforge should remove or downgrade all enchantments on the item. |
| extraEnchantmentChance | 0-100 | The chance of the blacksmith adding an enchantment to an item. |
| maxEnchantments | 0-10 | The maximum number of different enchantments a blacksmith can add. |
| maxReforgeDelay | 0-3600 | The maximum number of seconds a player needs to wait for an item to be repaired. |
| minReforgeDelay | 0-3600 | The minimum number of seconds a player needs to wait for an item to be repaired. |
| reforgeCoolDown | 0-3600 | The cool-down, in seconds, a player has to wait between each time they use one specific blacksmith. |
| maxReforgeWaitTimeSeconds | 0-3600 | The maximum number of seconds a player needs to wait for an item to be repaired. |
| minReforgeWaitTimeSeconds | 0-3600 | The minimum number of seconds a player needs to wait for an item to be repaired. |
| reforgeCoolDownSeconds | 0-3600 | The cool-down, in seconds, a player has to wait between each time they use one specific blacksmith. |
| reforgeAbleItems | DIAMOND_LEGGINGS,GOLD-pickaxe,bow, etc. | Specifies which items this blacksmith is able to reforge. If set to "" or null, all normally repairable items can be repaired. If set to a list of items, only the items specified can be repaired. Some presets have been included for ease of use. Use a preset by specifying "preset:sword-smith" instead of a material such as "gold-pickaxe". |
| blacksmithTitle | text string | The title displayed as part of the message explaining that a blacksmith doesn't recognize a player's held item |
| enchantmentBlocklist | string list | A string list of all enchantments a blacksmith should not be allowed to add to items. |
| enchantmentBlockList | string list | A string list of all enchantments a blacksmith should not be allowed to add to items. |
| reforgeAnvils | true/false | Whether to allow the blacksmith to reforge anvils. If enabled, chipped and damaged anvils will be replaced with a normal anvil. |
#### Blacksmith per-npc messages (with default values set in config.yml)
#### Messages
| Message Key | Explanation |
|--------------------------|-----------------------------------------------------------------------------------------------------------------|
@@ -195,6 +211,46 @@ All currently supported presets, and available filters for each preset:
| successMessage | The message displayed when a blacksmith successfully repairs an item |
| notDamagedMessage | The message displayed if a player tries to reforge an item with full durability |
### Scrapper global-only options
| Key | Value type | Description |
|----------------|----------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| basePrice | positive decimal number | The cost of using a scrapper |
| showExactTime | true/false | If true, scrappers will display exact time remaining in minutes and seconds, instead of vague expressions |
| giveExperience | true/false | If true, each enchantment level on the salvaged item will give one EXP level as salvage |
| ignoredSalvage | TARGET_MATERIAL:IGNORED_MATERIAL | The items that should be ignored when calculating partial salvage. Because receiving just the sticks when salvaging a diamond pickaxe is kind of sad, this allows specifying for example: `*_SHOVEL;*_PICKAXE;*_AXE;*_HOE;*_SWORD:STICK` (the default) for ignoring sticks in salvage for shovels, pickaxes, axes, hoes and swords. A `:` character splits selected items and the ignored salvage. Different item specifications are split by a `;` character. Use `,` to split separate ignored salvages, like: `SHIELD:STICK,BOW_STRING` |
### Scrapper per-npc (with default values set in config.yml)
#### Configuration values
| Key | Value type | Description |
|---------------------------|-----------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| dropItem | true/false | Whether the scrapper should drop the repaired item on the ground (instead of putting it into the player's inventory). |
| failSalvageChance | 0-100 | The chance of the scrapper failing to salvage an item, either further damaging the item, partly repairing the item or causing some items to disappear. |
| salvageAbleItems | DIAMOND_LEGGINGS,GOLD-pickaxe,bow, etc. | Specifies which items this scrapper is able to salvage. If set to "" or null, all normally repairable items can be salvaged. If set to a list of items, only the items specified can be salvaged. Some presets have been included for ease of use. Use a preset by specifying "preset:sword-smith" instead of a material such as "gold-pickaxe". |
| maxSalvageWaitTimeSeconds | 0-3600 | The maximum number of seconds a player needs to wait for an item to be salvaged. |
| minSalvageWaitTimeSeconds | 0-3600 | The minimum number of seconds a player needs to wait for an item to be salvaged. |
| salvageCoolDownSeconds | 0-3600 | The cool-down, in seconds, a player has to wait between each time they use one specific scrapper. |
| scrapperTitle | text string | The title displayed as part of the message explaining that a scrapper doesn't recognize a player's held item |
| extendedSalvageEnabled | true/false | Whether to enable the extended salvage behavior for this scrapper. As long as it is allowed by salvageAbleItems and it can be crafted in a crafting table, it can be salvaged. This includes things like four planks salvaged into wood. |
#### Messages
| Message Key | Explanation |
|-----------------------------|---------------------------------------------------------------------------------------------------------------|
| busyPlayerMessage | The message displayed when the scrapper is serving another player |
| busySalvageMessage | The message displayed when the scrapper is busy salvaging an item |
| coolDownUnexpiredMessage | The message displayed when the player has to wait for the cool-down to expire before using the scrapper again |
| invalidItemMessage | The message displayed when a scrapper is presented an item which it cannot salvage |
| tooDamagedForSalvageMessage | The message displayed when a scrapper is presented with an item too damaged to produce salvage. |
| successSalvagedMessage | The message displayed when a scrapper successfully repairs an item |
| failSalvageMessage | The message displayed when a scrapper fails to salvage an item |
| itemChangedMessage | The message displayed when a player changes their item after being shown the salvage cost |
| startSalvageMessage | The message displayed when a scrapper starts salvaging an item |
| insufficientFundsMessage | The message displayed when a player is unable to pay for scrapping an item |
| costMessage | The message displayed when telling a player about the cost of scrapping an item |
## Language customization
All strings, even time units, are customizable. If you place a strings.yml file in the plugin folder, it will take