Makes sure only intended items are re-forge-able, and changes version to 1.0.0

This commit is contained in:
Kristian Knarvik 2022-08-08 19:27:54 +02:00
parent 7dc2228781
commit 64617accf8
5 changed files with 19 additions and 8 deletions

View File

@ -6,7 +6,7 @@
<groupId>net.knarcraft</groupId> <groupId>net.knarcraft</groupId>
<artifactId>blacksmith</artifactId> <artifactId>blacksmith</artifactId>
<version>1.19.1-SNAPSHOT</version> <version>1.0.0-SNAPSHOT</version>
<name>Blacksmith</name> <name>Blacksmith</name>
<description>Blacksmith Character for the CitizensAPI</description> <description>Blacksmith Character for the CitizensAPI</description>

View File

@ -1,12 +1,16 @@
package net.knarcraft.blacksmith.config; package net.knarcraft.blacksmith.config;
import net.citizensnpcs.api.util.DataKey; import net.citizensnpcs.api.util.DataKey;
import net.knarcraft.blacksmith.BlacksmithPlugin;
import net.knarcraft.blacksmith.trait.BlacksmithTrait;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.logging.Level;
/** /**
* A class which keeps track of all Blacksmith settings/config values for one NPC * A class which keeps track of all Blacksmith settings/config values for one NPC
@ -333,8 +337,11 @@ public class NPCSettings {
continue; continue;
} }
Material material = Material.matchMaterial(String.valueOf(item)); Material material = Material.matchMaterial(String.valueOf(item));
if (material != null) { if (material != null && BlacksmithTrait.isRepairable(new ItemStack(material, 1))) {
this.reforgeAbleItems.add(material); this.reforgeAbleItems.add(material);
} else {
BlacksmithPlugin.getInstance().getLogger().log(Level.WARNING, "Unable to verify " + material +
" as a valid reforge-able item");
} }
} }
} }

View File

@ -8,6 +8,7 @@ import net.knarcraft.blacksmith.config.NPCSettings;
import net.knarcraft.blacksmith.manager.EconomyManager; import net.knarcraft.blacksmith.manager.EconomyManager;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -208,8 +209,8 @@ public class BlacksmithTrait extends Trait {
* @param item <p>The item to check</p> * @param item <p>The item to check</p>
* @return <p>True if the item is repairable</p> * @return <p>True if the item is repairable</p>
*/ */
private static boolean isRepairable(ItemStack item) { public static boolean isRepairable(ItemStack item) {
return item.getItemMeta() instanceof Damageable; return item.getItemMeta() instanceof Damageable && EnchantmentTarget.BREAKABLE.includes(item);
} }
} }

View File

@ -47,11 +47,14 @@ defaults:
# All settable delays # All settable delays
delays-in-seconds: delays-in-seconds:
maximum: 30 # The maximum time for a re-forge to finish # The maximum time for a re-forge to finish
maximum: 30
minimum: 5 # The minimum time for a re-forge to finish # The minimum time for a re-forge to finish
minimum: 5
reforge-cool-down: 60 # The cool-down period between each re-forge # The cool-down period between each re-forge
reforge-cool-down: 60
# All messages used by the NPC # All messages used by the NPC
messages: messages:

View File

@ -1,7 +1,7 @@
name: Blacksmith name: Blacksmith
author: EpicKnarvik97, aPunch, jrbudda, HurricanKai author: EpicKnarvik97, aPunch, jrbudda, HurricanKai
authors: [ EpicKnarvik97, aPunch, jrbudda, HurricanKai ] authors: [ EpicKnarvik97, aPunch, jrbudda, HurricanKai ]
version: 1.18.1 version: 1.0.0
main: net.knarcraft.blacksmith.BlacksmithPlugin main: net.knarcraft.blacksmith.BlacksmithPlugin
depend: [ Citizens, Vault ] depend: [ Citizens, Vault ]