Adds sound effects to Blacksmiths and Scrappers

This commit is contained in:
2024-07-28 12:48:45 +02:00
parent 92c1b96fba
commit 81dda85405
5 changed files with 47 additions and 9 deletions

View File

@@ -9,6 +9,7 @@ import net.knarcraft.blacksmith.util.ItemHelper;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.Registry;
import org.bukkit.Sound;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
@@ -30,7 +31,6 @@ import static net.knarcraft.blacksmith.formatting.BlacksmithStringFormatter.send
public class ReforgeSession extends Session implements Runnable {
private final BlacksmithTrait blacksmithTrait;
private final NPC npc;
private final ItemStack itemToReforge;
private final BlacksmithNPCSettings config;
private static List<String> enchantments = null;
@@ -45,9 +45,8 @@ public class ReforgeSession extends Session implements Runnable {
*/
ReforgeSession(@NotNull BlacksmithTrait blacksmithTrait, @NotNull Player player, @NotNull NPC npc,
@NotNull BlacksmithNPCSettings config) {
super(player);
super(player, npc);
this.blacksmithTrait = blacksmithTrait;
this.npc = npc;
this.itemToReforge = player.getInventory().getItemInMainHand();
this.config = config;
@@ -97,7 +96,9 @@ public class ReforgeSession extends Session implements Runnable {
*/
@Override
public void run() {
sendNPCMessage(this.npc, this.player, reforgeItem() ? this.config.getSuccessMessage() : this.config.getFailMessage());
boolean success = reforgeItem();
sendNPCMessage(this.npc, this.player, success ? this.config.getSuccessMessage() : this.config.getFailMessage());
playSound(success ? Sound.BLOCK_ANVIL_USE : Sound.ENTITY_VILLAGER_NO);
//Stop the reforged item from displaying in the blacksmith's hand
if (this.npc.getEntity() instanceof Player) {