diff --git a/Changelog.txt b/Changelog.txt index a328372db..05d6784ad 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,8 +1,14 @@ Version 2.2.027 + Added Tridents / Crossbows to salvage.vanilla.yml config (see notes) Fixed Ricocheted arrows losing some data after a ricochet + Fixed an issue where Folia could have all of its threads lock up effectively killing the server Fixed concurrency issue with Folia regarding locale strings Fixed concurrency issue with Folia regarding COTW summons + NOTES: + Tridents and Crossbows are now in the salvage.vanilla.yml config, you will need to either delete this config file to regenerate it or add the entries manually. + You can check the default config file after running this mcMMO update at least once in the defaults folder at plugins\mcMMO\defaults to see what you would need to add if you want to take the manual approach + Version 2.2.026 Fixed NullPointerException on ChunkUnloadEvent diff --git a/src/main/java/com/gmail/nossr50/config/skills/salvage/SalvageConfig.java b/src/main/java/com/gmail/nossr50/config/skills/salvage/SalvageConfig.java index 7f68b6121..48435581d 100644 --- a/src/main/java/com/gmail/nossr50/config/skills/salvage/SalvageConfig.java +++ b/src/main/java/com/gmail/nossr50/config/skills/salvage/SalvageConfig.java @@ -9,6 +9,7 @@ import com.gmail.nossr50.skills.salvage.salvageables.Salvageable; import com.gmail.nossr50.skills.salvage.salvageables.SalvageableFactory; import com.gmail.nossr50.util.ItemUtils; import com.gmail.nossr50.util.LogUtils; +import com.gmail.nossr50.util.skills.SkillUtils; import org.bukkit.Material; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.inventory.ItemStack; @@ -17,8 +18,6 @@ import java.io.IOException; import java.util.*; import java.util.logging.Level; -import static com.gmail.nossr50.util.skills.SkillUtils.getRepairAndSalvageQuantities; - public class SalvageConfig extends BukkitConfig { private final HashSet notSupported; private Set salvageables; @@ -42,7 +41,6 @@ public class SalvageConfig extends BukkitConfig { Set keys = section.getKeys(false); //Original version of 1.16 support had maximum quantities that were bad, this fixes it - if (mcMMO.getUpgradeManager().shouldUpgrade(UpgradeType.FIX_NETHERITE_SALVAGE_QUANTITIES)) { mcMMO.p.getLogger().log(Level.INFO, "Fixing incorrect Salvage quantities on Netherite gear, this will only run once..."); for (String namespacedkey : mcMMO.getMaterialMapStore().getNetheriteArmor()) { @@ -59,7 +57,6 @@ public class SalvageConfig extends BukkitConfig { } } - for (String key : keys) { // Validate all the things! List reason = new ArrayList<>(); @@ -85,6 +82,8 @@ public class SalvageConfig extends BukkitConfig { salvageMaterialType = MaterialType.STONE; } else if (ItemUtils.isStringTool(salvageItem)) { salvageMaterialType = MaterialType.STRING; + } else if (ItemUtils.isPrismarineTool(salvageItem)) { + salvageMaterialType = MaterialType.PRISMARINE; } else if (ItemUtils.isLeatherArmor(salvageItem)) { salvageMaterialType = MaterialType.LEATHER; } else if (ItemUtils.isIronArmor(salvageItem) || ItemUtils.isIronTool(salvageItem)) { @@ -145,7 +144,7 @@ public class SalvageConfig extends BukkitConfig { // Maximum Quantity int maximumQuantity = itemMaterial != null - ? getRepairAndSalvageQuantities(itemMaterial, salvageMaterial) + ? SkillUtils.getRepairAndSalvageQuantities(itemMaterial, salvageMaterial) : config.getInt("Salvageables." + key + ".MaximumQuantity", 1); if (maximumQuantity <= 0 && itemMaterial != null) { diff --git a/src/main/java/com/gmail/nossr50/datatypes/skills/MaterialType.java b/src/main/java/com/gmail/nossr50/datatypes/skills/MaterialType.java index 85952bac7..6b00c688e 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/skills/MaterialType.java +++ b/src/main/java/com/gmail/nossr50/datatypes/skills/MaterialType.java @@ -11,6 +11,7 @@ public enum MaterialType { GOLD, DIAMOND, NETHERITE, + PRISMARINE, OTHER; public Material getDefaultMaterial() { @@ -41,6 +42,8 @@ public enum MaterialType { return Material.getMaterial("NETHERITE_SCRAP"); else return Material.DIAMOND; + case PRISMARINE: + return Material.PRISMARINE_CRYSTALS; case OTHER: default: diff --git a/src/main/java/com/gmail/nossr50/skills/salvage/SalvageManager.java b/src/main/java/com/gmail/nossr50/skills/salvage/SalvageManager.java index cd583e754..6cc39975b 100644 --- a/src/main/java/com/gmail/nossr50/skills/salvage/SalvageManager.java +++ b/src/main/java/com/gmail/nossr50/skills/salvage/SalvageManager.java @@ -35,7 +35,7 @@ import java.util.Map.Entry; public class SalvageManager extends SkillManager { private boolean placedAnvil; - private int lastClick; + private int lastClick; public SalvageManager(McMMOPlayer mcMMOPlayer) { super(mcMMOPlayer, PrimarySkillType.SALVAGE); diff --git a/src/main/java/com/gmail/nossr50/skills/taming/TrackedTamingEntity.java b/src/main/java/com/gmail/nossr50/skills/taming/TrackedTamingEntity.java index 8af370b9e..fd46bbd90 100644 --- a/src/main/java/com/gmail/nossr50/skills/taming/TrackedTamingEntity.java +++ b/src/main/java/com/gmail/nossr50/skills/taming/TrackedTamingEntity.java @@ -13,7 +13,8 @@ public class TrackedTamingEntity extends CancellableRunnable { private final @NotNull CallOfTheWildType callOfTheWildType; private final @NotNull Player player; - protected TrackedTamingEntity(@NotNull LivingEntity livingEntity, @NotNull CallOfTheWildType callOfTheWildType, @NotNull Player player) { + public TrackedTamingEntity(@NotNull LivingEntity livingEntity, @NotNull CallOfTheWildType callOfTheWildType, + @NotNull Player player) { this.player = player; this.callOfTheWildType = callOfTheWildType; this.livingEntity = livingEntity; diff --git a/src/main/java/com/gmail/nossr50/util/ItemUtils.java b/src/main/java/com/gmail/nossr50/util/ItemUtils.java index 6dc9b2785..d3aee583c 100644 --- a/src/main/java/com/gmail/nossr50/util/ItemUtils.java +++ b/src/main/java/com/gmail/nossr50/util/ItemUtils.java @@ -436,6 +436,10 @@ public final class ItemUtils { return mcMMO.getMaterialMapStore().isStringTool(item.getType().getKey().getKey()); } + public static boolean isPrismarineTool(ItemStack item) { + return mcMMO.getMaterialMapStore().isPrismarineTool(item.getType().getKey().getKey()); + } + /** * Checks to see if an item is a gold tool. * diff --git a/src/main/java/com/gmail/nossr50/util/MaterialMapStore.java b/src/main/java/com/gmail/nossr50/util/MaterialMapStore.java index 01c6bf8fe..7047f6933 100644 --- a/src/main/java/com/gmail/nossr50/util/MaterialMapStore.java +++ b/src/main/java/com/gmail/nossr50/util/MaterialMapStore.java @@ -33,6 +33,7 @@ public class MaterialMapStore { private final @NotNull HashSet ironArmor; private final @NotNull HashSet ironTools; private final @NotNull HashSet stringTools; + private final @NotNull HashSet prismarineTools; private final @NotNull HashSet goldArmor; private final @NotNull HashSet goldTools; private final @NotNull HashSet chainmailArmor; @@ -89,6 +90,7 @@ public class MaterialMapStore { bows = new HashSet<>(); crossbows = new HashSet<>(); stringTools = new HashSet<>(); + prismarineTools = new HashSet<>(); tools = new HashSet<>(); swords = new HashSet<>(); @@ -462,7 +464,7 @@ public class MaterialMapStore { fillIronToolsWhiteList(); fillGoldToolsWhiteList(); fillDiamondToolsWhiteList(); - fillnetheriteToolsWhiteList(); + fillNetheriteToolsWhiteList(); fillSwords(); fillAxes(); @@ -472,6 +474,7 @@ public class MaterialMapStore { fillTridents(); fillMaces(); fillStringTools(); + fillPrismarineTools(); fillBows(); fillCrossbows(); @@ -501,6 +504,11 @@ public class MaterialMapStore { stringTools.add("bow"); stringTools.add("fishing_rod"); stringTools.add("carrot_on_a_stick"); + stringTools.add("crossbow"); + } + + private void fillPrismarineTools() { + prismarineTools.add("trident"); } private void fillMaces() { @@ -674,7 +682,7 @@ public class MaterialMapStore { diamondTools.add("diamond_shovel"); } - private void fillnetheriteToolsWhiteList() { + private void fillNetheriteToolsWhiteList() { netheriteTools.add("netherite_sword"); netheriteTools.add("netherite_axe"); netheriteTools.add("netherite_hoe"); @@ -976,6 +984,14 @@ public class MaterialMapStore { return stringTools.contains(id); } + public boolean isPrismarineTool(@NotNull Material material) { + return isPrismarineTool(material.getKey().getKey()); + } + + public boolean isPrismarineTool(@NotNull String id) { + return prismarineTools.contains(id); + } + public boolean isGlass(@NotNull Material material) { return glassBlocks.contains(material.getKey().getKey()); } diff --git a/src/main/java/com/gmail/nossr50/util/MobMetadataUtils.java b/src/main/java/com/gmail/nossr50/util/MobMetadataUtils.java index 172f6190c..600af8029 100644 --- a/src/main/java/com/gmail/nossr50/util/MobMetadataUtils.java +++ b/src/main/java/com/gmail/nossr50/util/MobMetadataUtils.java @@ -17,7 +17,6 @@ import java.util.concurrent.ConcurrentMap; import static com.gmail.nossr50.util.MetadataService.*; -//TODO: Use SpawnReason where appropriate instead of MobMetaFlagType public final class MobMetadataUtils { private static final @NotNull ConcurrentMap> mobRegistry; //transient data private static final @NotNull EnumMap mobFlagKeyMap; //used for persistent data diff --git a/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java b/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java index a6186d369..23843c1bc 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java @@ -280,7 +280,11 @@ public final class SkillUtils { @Nullable public static Material getRepairAndSalvageItem(@NotNull ItemStack inHand) { - if (ItemUtils.isDiamondTool(inHand) || ItemUtils.isDiamondArmor(inHand)) { + if (ItemUtils.isPrismarineTool(inHand)) { + return Material.PRISMARINE_CRYSTALS; + } else if (ItemUtils.isNetheriteTool(inHand) || ItemUtils.isNetheriteArmor(inHand)) { + return Material.NETHERITE_SCRAP; + } else if (ItemUtils.isDiamondTool(inHand) || ItemUtils.isDiamondArmor(inHand)) { return Material.DIAMOND; } else if (ItemUtils.isGoldTool(inHand) || ItemUtils.isGoldArmor(inHand)) { return Material.GOLD_INGOT; @@ -306,7 +310,12 @@ public final class SkillUtils { public static int getRepairAndSalvageQuantities(Material itemMaterial, Material recipeMaterial) { int quantity = 0; - if (mcMMO.getMaterialMapStore().isNetheriteTool(itemMaterial) || mcMMO.getMaterialMapStore().isNetheriteArmor(itemMaterial)) { + if (mcMMO.getMaterialMapStore().isPrismarineTool(itemMaterial)) { + return 16; + } + + if (mcMMO.getMaterialMapStore().isNetheriteTool(itemMaterial) + || mcMMO.getMaterialMapStore().isNetheriteArmor(itemMaterial)) { //One netherite bar requires 4 netherite scraps return 4; } diff --git a/src/main/resources/salvage.vanilla.yml b/src/main/resources/salvage.vanilla.yml index 4977c492b..dbcd66a5e 100644 --- a/src/main/resources/salvage.vanilla.yml +++ b/src/main/resources/salvage.vanilla.yml @@ -290,3 +290,10 @@ Salvageables: CARROT_ON_A_STICK: MinimumLevel: 0 XpMultiplier: .5 + CROSSBOW: + MinimumLevel: 0 + XpMultiplier: 1 + # Other + TRIDENT: + MinimumLevel: 0 + XpMultiplier: 1