Speeds up smith presets by using caching and sets
All checks were successful
EpicKnarvik97/Blacksmith/pipeline/head This commit looks good

This commit is contained in:
2024-05-06 12:56:22 +02:00
parent 3dd8467a58
commit 3ed3c99c15
4 changed files with 87 additions and 52 deletions

View File

@@ -12,6 +12,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
/**
* The command for displaying which materials are contained in a preset
@@ -26,7 +27,7 @@ public class PresetCommand implements CommandExecutor {
}
String presetName = args[0].toUpperCase().replace('-', '_');
List<Material> includedMaterials;
Set<Material> includedMaterials;
try {
//Display the preset with the filter applied

View File

@@ -19,7 +19,7 @@ import org.bukkit.enchantments.Enchantment;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
import java.util.Set;
/**
* The command used for changing global blacksmith configuration options
@@ -215,7 +215,7 @@ public class BlackSmithConfigCommand implements CommandExecutor {
private void updateAllMatchedPrices(@NotNull GlobalBlacksmithSettings settings,
@NotNull BlacksmithSetting blacksmithSetting,
@NotNull String materialName, double newPrice) {
List<Material> materials = ItemHelper.getWildcardMatch(materialName, false);
Set<Material> materials = ItemHelper.getWildcardMatch(materialName, false);
for (Material material : materials) {
if (blacksmithSetting == BlacksmithSetting.BASE_PRICE) {
settings.setBasePrice(material, newPrice);