Updates Spigot, and fixes depreciated code
All checks were successful
EpicKnarvik97/Blacksmith/pipeline/head This commit looks good
All checks were successful
EpicKnarvik97/Blacksmith/pipeline/head This commit looks good
This commit is contained in:
@ -170,7 +170,7 @@ public abstract class EditCommand<K extends CustomTrait<L>, L extends Setting> i
|
||||
getCurrentValueMessage(setting.getCommandName(), rawValue));
|
||||
} else {
|
||||
//Add a marker if the value has been customized
|
||||
String marker = BlacksmithPlugin.getStringFormatter().getUnformattedMessage(
|
||||
String marker = BlacksmithPlugin.getStringFormatter().getUnFormattedMessage(
|
||||
BlacksmithTranslatableMessage.SETTING_OVERRIDDEN_MARKER);
|
||||
formatter.displayNeutralMessage(sender,
|
||||
getCurrentValueMessage(setting.getCommandName(), rawValue) + marker);
|
||||
|
@ -172,7 +172,7 @@ public enum BlacksmithTranslatableMessage implements TranslatableMessage {
|
||||
* @return <p>The string to display to a user</p>
|
||||
*/
|
||||
public static String getItemValueChangedMessage(String setting, ItemType itemType, String item, String newValue) {
|
||||
StringReplacer stringReplacer = new StringReplacer(BlacksmithPlugin.getStringFormatter().getUnformattedMessage(
|
||||
StringReplacer stringReplacer = new StringReplacer(BlacksmithPlugin.getStringFormatter().getUnFormattedMessage(
|
||||
BlacksmithTranslatableMessage.VALUE_FOR_ITEM_CHANGED));
|
||||
stringReplacer.add("{setting}", setting);
|
||||
stringReplacer.add("{itemType}", itemType.getItemTypeName());
|
||||
@ -204,7 +204,7 @@ public enum BlacksmithTranslatableMessage implements TranslatableMessage {
|
||||
* @return <p>The string to display to a user</p>
|
||||
*/
|
||||
public static String getItemCurrentValueMessage(String setting, ItemType itemType, String item, String currentValue) {
|
||||
StringReplacer stringReplacer = new StringReplacer(BlacksmithPlugin.getStringFormatter().getUnformattedMessage(
|
||||
StringReplacer stringReplacer = new StringReplacer(BlacksmithPlugin.getStringFormatter().getUnFormattedMessage(
|
||||
BlacksmithTranslatableMessage.CURRENT_VALUE_FOR_ITEM));
|
||||
stringReplacer.add("{setting}", setting);
|
||||
stringReplacer.add("{itemType}", itemType.getItemTypeName());
|
||||
|
@ -19,9 +19,9 @@ public enum ItemType {
|
||||
public String getItemTypeName() {
|
||||
StringFormatter stringFormatter = BlacksmithPlugin.getStringFormatter();
|
||||
return switch (this) {
|
||||
case MATERIAL -> stringFormatter.getUnformattedMessage(BlacksmithTranslatableMessage.ITEM_TYPE_MATERIAL);
|
||||
case MATERIAL -> stringFormatter.getUnFormattedMessage(BlacksmithTranslatableMessage.ITEM_TYPE_MATERIAL);
|
||||
case ENCHANTMENT ->
|
||||
stringFormatter.getUnformattedMessage(BlacksmithTranslatableMessage.ITEM_TYPE_ENCHANTMENT);
|
||||
stringFormatter.getUnFormattedMessage(BlacksmithTranslatableMessage.ITEM_TYPE_ENCHANTMENT);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ public final class TimeFormatter {
|
||||
* @return <p>Text describing the time interval</p>
|
||||
*/
|
||||
private static String getMessageFromInterval(TimeInterval interval) {
|
||||
String text = BlacksmithPlugin.getStringFormatter().getUnformattedMessage(
|
||||
String text = BlacksmithPlugin.getStringFormatter().getUnFormattedMessage(
|
||||
BlacksmithTranslatableMessage.valueOf(interval.name()));
|
||||
|
||||
//Choose a random entry if a comma-separated list is provided
|
||||
|
@ -6,7 +6,9 @@ import net.knarcraft.blacksmith.config.blacksmith.BlacksmithNPCSettings;
|
||||
import net.knarcraft.blacksmith.manager.EconomyManager;
|
||||
import net.knarcraft.blacksmith.util.InputParsingHelper;
|
||||
import net.knarcraft.blacksmith.util.ItemHelper;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Registry;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -31,7 +33,7 @@ public class ReforgeSession extends Session implements Runnable {
|
||||
private final NPC npc;
|
||||
private final ItemStack itemToReforge;
|
||||
private final BlacksmithNPCSettings config;
|
||||
private static final String[] enchantments = new String[Enchantment.values().length];
|
||||
private static List<String> enchantments = null;
|
||||
private static final Random random = new Random();
|
||||
|
||||
/**
|
||||
@ -51,10 +53,15 @@ public class ReforgeSession extends Session implements Runnable {
|
||||
this.config = config;
|
||||
|
||||
//Populate enchantments the first time this is run
|
||||
if (enchantments[0] == null) {
|
||||
int i = 0;
|
||||
for (Enchantment enchantment : Enchantment.values()) {
|
||||
enchantments[i++] = enchantment.getKey().getKey();
|
||||
if (enchantments == null) {
|
||||
Registry<Enchantment> enchantmentRegistry = Bukkit.getRegistry(Enchantment.class);
|
||||
if (enchantmentRegistry == null) {
|
||||
throw new RuntimeException("Unable to get enchantment registry");
|
||||
}
|
||||
|
||||
enchantments = new ArrayList<>();
|
||||
for (Enchantment enchantment : enchantmentRegistry) {
|
||||
enchantments.add(enchantment.getKey().getKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,9 @@
|
||||
package net.knarcraft.blacksmith.util;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.Registry;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@ -44,7 +46,11 @@ public final class InputParsingHelper {
|
||||
*/
|
||||
public static @Nullable Enchantment matchEnchantment(@NotNull String input) {
|
||||
try {
|
||||
return Enchantment.getByKey(NamespacedKey.minecraft(
|
||||
Registry<Enchantment> enchantments = Bukkit.getRegistry(Enchantment.class);
|
||||
if (enchantments == null) {
|
||||
throw new RuntimeException("Unable to get enchantment registry");
|
||||
}
|
||||
return enchantments.get(NamespacedKey.minecraft(
|
||||
input.replace("-", "_").replace(" ", "_").toLowerCase()));
|
||||
} catch (IllegalArgumentException exception) {
|
||||
//Invalid characters, such as : will normally throw an illegal argument exception
|
||||
|
@ -3,7 +3,9 @@ package net.knarcraft.blacksmith.util;
|
||||
import net.knarcraft.blacksmith.config.SettingValueType;
|
||||
import net.knarcraft.blacksmith.config.SmithPreset;
|
||||
import net.knarcraft.blacksmith.config.SmithPresetFilter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Registry;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@ -82,8 +84,13 @@ public final class TabCompleteValuesHelper {
|
||||
* @return <p>A complete list of enchantments</p>
|
||||
*/
|
||||
private static @NotNull List<String> getAllEnchantments() {
|
||||
Registry<Enchantment> enchantmentRegistry = Bukkit.getRegistry(Enchantment.class);
|
||||
if (enchantmentRegistry == null) {
|
||||
throw new RuntimeException("Unable to get the enchantment registry");
|
||||
}
|
||||
|
||||
List<String> enchantments = new ArrayList<>();
|
||||
for (Enchantment enchantment : Enchantment.values()) {
|
||||
for (Enchantment enchantment : enchantmentRegistry) {
|
||||
enchantments.add(enchantment.getKey().getKey());
|
||||
}
|
||||
return enchantments;
|
||||
|
Reference in New Issue
Block a user