Adds a separate message for clicking an NPC with an empty hand
All checks were successful
EpicKnarvik97/Blacksmith/pipeline/head This commit looks good

This commit is contained in:
Kristian Knarvik 2024-08-03 13:09:09 +02:00
parent d0df4800f0
commit 5efba6687c
8 changed files with 54 additions and 2 deletions

View File

@ -230,6 +230,7 @@ All currently supported presets, and available filters for each preset:
| startReforgeMessage | &eOk, let's see what I can do... | The message displayed when a blacksmith starts reforging an item. | | startReforgeMessage | &eOk, let's see what I can do... | The message displayed when a blacksmith starts reforging an item. |
| successMessage | There you go! All better! | The message displayed when a blacksmith successfully repairs an item. | | successMessage | There you go! All better! | The message displayed when a blacksmith successfully repairs an item. |
| notDamagedMessage | &cThat item is not in need of repair | The message displayed if a player tries to reforge an item with full durability. | | notDamagedMessage | &cThat item is not in need of repair | The message displayed if a player tries to reforge an item with full durability. |
| noItemMessage | Please present the item you want to reforge | The message displayed when a blacksmith is clicked with an empty hand |
### Scrapper global-only options ### Scrapper global-only options
@ -284,6 +285,7 @@ All currently supported presets, and available filters for each preset:
| cannotSalvageArmorTrimMessage | &cI'm sorry, but I'm unable to salvage armor trims! | The message displayed when telling a player that the scrapper cannot salvage items with armor trim. | | cannotSalvageArmorTrimMessage | &cI'm sorry, but I'm unable to salvage armor trims! | The message displayed when telling a player that the scrapper cannot salvage items with armor trim. |
| armorTrimSalvageNotFoundMessage | &cI'm sorry, but I don't know how to salvage that armor trim! | The message displayed when telling a player that the scrapper cannot find the correct items to return as armor trim salvage. This will happen if more armor trim materials are added, or the Spigot API is changed. | | armorTrimSalvageNotFoundMessage | &cI'm sorry, but I don't know how to salvage that armor trim! | The message displayed when telling a player that the scrapper cannot find the correct items to return as armor trim salvage. This will happen if more armor trim materials are added, or the Spigot API is changed. |
| cannotSalvageNetheriteMessage | &cI'm sorry, but I'm unable to salvage netherite items! | The message displayed when telling a player that the scrapper cannot salvage netherite items. | | cannotSalvageNetheriteMessage | &cI'm sorry, but I'm unable to salvage netherite items! | The message displayed when telling a player that the scrapper cannot salvage netherite items. |
| noItemMessage | Please present the item you want to salvage | The message displayed when a scrapper is clicked with an empty hand |
## Language customization ## Language customization

View File

@ -175,6 +175,16 @@ public class BlacksmithNPCSettings implements TraitSettings<BlacksmithSetting> {
return asString(BlacksmithSetting.ITEM_UNEXPECTEDLY_CHANGED_MESSAGE); return asString(BlacksmithSetting.ITEM_UNEXPECTEDLY_CHANGED_MESSAGE);
} }
/**
* Gets the message displayed if a player presents the blacksmith with an empty hand
*
* @return <p>The no item message</p>
*/
@NotNull
public String getNoItemMessage() {
return asString(BlacksmithSetting.NO_ITEM_MESSAGE);
}
/** /**
* Gets all items reforge-able by this NPC * Gets all items reforge-able by this NPC
* *

View File

@ -186,6 +186,12 @@ public enum BlacksmithSetting implements Setting {
"The message to display if a player is trying to reforge an item with full durability", "The message to display if a player is trying to reforge an item with full durability",
true, true), true, true),
/**
* The message displayed when clicking a blacksmith with an empty hand
*/
NO_ITEM_MESSAGE("noItemMessage", SettingValueType.STRING, "Please present the item you want to reforge",
"The message to display when a blacksmith is clicked with an empty hand", true, true),
/*------------------ /*------------------
| Global settings | | Global settings |
------------------*/ ------------------*/

View File

@ -178,13 +178,25 @@ public class ScrapperNPCSettings implements TraitSettings<ScrapperSetting> {
} }
/** /**
* The message displayed if a player presents a different item after seeing the price to salvage an item * Gets the message displayed if a player presents a different item after seeing the price to salvage an item
*
* @return <p>The item changed message</p>
*/ */
@NotNull @NotNull
public String getItemChangedMessage() { public String getItemChangedMessage() {
return asString(ScrapperSetting.ITEM_UNEXPECTEDLY_CHANGED_MESSAGE); return asString(ScrapperSetting.ITEM_UNEXPECTEDLY_CHANGED_MESSAGE);
} }
/**
* Gets the message displayed if a player presents the scrapper with an empty hand
*
* @return <p>The no item message</p>
*/
@NotNull
public String getNoItemMessage() {
return asString(ScrapperSetting.NO_ITEM_MESSAGE);
}
/** /**
* Gets the minimum delay used to wait for a salvaging to finish. * Gets the minimum delay used to wait for a salvaging to finish.
* *

View File

@ -236,6 +236,12 @@ public enum ScrapperSetting implements Setting {
"&cI'm sorry, but I'm unable to salvage netherite items!", "&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 to display when asked to salvage netherite items, and that option is disabled", true, true),
/**
* The message displayed when clicking a scrapper with an empty hand
*/
NO_ITEM_MESSAGE("noItemMessage", SettingValueType.STRING, "Please present the item you want to salvage",
"The message to display when a scrapper is clicked with an empty hand", true, true),
/*------------------ /*------------------
| Global settings | | Global settings |
------------------*/ ------------------*/

View File

@ -68,6 +68,11 @@ public class BlacksmithTrait extends CustomTrait<BlacksmithSetting> {
@Override @Override
public void startSession(@NotNull Player player) { public void startSession(@NotNull Player player) {
ItemStack hand = player.getInventory().getItemInMainHand(); ItemStack hand = player.getInventory().getItemInMainHand();
if (hand.getType().isAir()) {
sendNPCMessage(this.npc, player, config.getNoItemMessage());
return;
}
//Refuse if not repairable, or if reforge-able items is set, but doesn't include the held item //Refuse if not repairable, or if reforge-able items is set, but doesn't include the held item
List<Material> reforgeAbleItems = config.getReforgeAbleItems(); List<Material> reforgeAbleItems = config.getReforgeAbleItems();

View File

@ -85,6 +85,11 @@ public class ScrapperTrait extends CustomTrait<ScrapperSetting> {
*/ */
public void startSession(@NotNull Player player) { public void startSession(@NotNull Player player) {
ItemStack itemInHand = player.getInventory().getItemInMainHand().clone(); ItemStack itemInHand = player.getInventory().getItemInMainHand().clone();
if (itemInHand.getType().isAir()) {
sendNPCMessage(this.npc, player, config.getNoItemMessage());
return;
}
List<Material> salvageAbleItems = getSettings().getSalvageAbleItems(); List<Material> salvageAbleItems = getSettings().getSalvageAbleItems();
boolean extended = getSettings().extendedSalvageEnabled(); boolean extended = getSettings().extendedSalvageEnabled();

View File

@ -111,6 +111,9 @@ blacksmith:
# The message to display if a player is trying to reforge an item with full durability # The message to display if a player is trying to reforge an item with full durability
notDamagedMessage: "&cThat item is not in need of repair" notDamagedMessage: "&cThat item is not in need of repair"
# The message to display when a blacksmith is clicked with an empty hand
noItemMessage: "Please present the item you want to reforge"
# Settings for the scrapper trait # Settings for the scrapper trait
scrapper: scrapper:
@ -239,4 +242,7 @@ scrapper:
armorTrimSalvageNotFoundMessage: "&cI'm sorry, but I don't know how to salvage that armor trim!" armorTrimSalvageNotFoundMessage: "&cI'm sorry, but I don't know how to salvage that armor trim!"
# The message to display when asked to salvage netherite items, and that option is disabled # The message to display when asked to salvage netherite items, and that option is disabled
cannotSalvageNetheriteMessage: "&cI'm sorry, but I'm unable to salvage netherite items!" cannotSalvageNetheriteMessage: "&cI'm sorry, but I'm unable to salvage netherite items!"
# The message to display when a scrapper is clicked with an empty hand
noItemMessage: "Please present the item you want to salvage"