diff --git a/.github/ISSUE_TEMPLATE/bug-report-beta.yaml b/.github/ISSUE_TEMPLATE/bug-report-beta.yaml index 1f896992a..36ae2dd74 100644 --- a/.github/ISSUE_TEMPLATE/bug-report-beta.yaml +++ b/.github/ISSUE_TEMPLATE/bug-report-beta.yaml @@ -1,73 +1,119 @@ name: Bug Report (Beta) -about: Report a Bug or an Issue with Slimefun 4. -labels: ['\U0001F3AF Needs testing', '\U0001F41E Bug Report'] +description: Report a Bug or an Issue with Slimefun 4. +labels: ['🎯 Needs testing', '🐞 Bug Report'] + body: -- type: markdown - attributes: - value: '## Thanks for reporting a bug!' -- type: textarea +- id: description + type: textarea validations: required: true attributes: - label: ':round_pushpin: Description' + label: '📍 Description' description: | A clear and detailed description of what went wrong. The more information you can provide, the easier we can handle this problem. -- type: textarea + placeholder: | + (example) + When trying to do [...], I expected [...] to happen but [...] happened instead. + I am pretty sure this is not intended and should be fixed. + +- id: reproduction-steps + type: textarea validations: required: true attributes: - label: ':bookmark_tabs: Reproduction Steps' + label: '📑 Reproduction Steps' description: | Tell us the exact steps to reproduce this issue, the more detailed the easier we can reproduce it. - Youtube Videos and Screenshots are recommended! - value: | - 1. - 2. - 3. -- type: textarea + placeholder: | + (example) + 1. Craft [...] + 2. Right click with that item on a workbench + 3. The workbench explodes + +- id: expected-behaviour + type: textarea validations: required: true attributes: - label: ':bulb: Expected Behavior' + label: '💡 Expected Behavior' description: | What were you expecting to happen? What do you think would have been the correct behaviour? -- type: textarea + placeholder: | + I expected [...] to happen. + +- id: media + type: textarea attributes: - label: ':scroll: Server Log' + label: '📷 Screenshots / Videos' description: | - Take a look at your Server Log and post any errors you can find via https://pastebin.com/ + Videos and Screenshots help illustrate issues the best. + If you can capture any footage of the bug happening, it would help us out a lot! + +- id: server-log + type: input + attributes: + label: '📜 Server Log' + description: | + Take a look at your Server Log and upload any error messages from Slimefun + to a pasting site (e.g. https://pastebin.com/) If you are unsure about it, post your full log, you can find it under /logs/latest.log -- type: textarea + placeholder: https://pastebin.com/... + +- id: error-reports + type: input attributes: - label: ':open_file_folder: /error-reports/ Folder' + label: '📂 `/error-reports/` folder' description: | - Check the folder /plugins/Slimefun/error-reports/ and upload any files inside that folder. - You can also post these files via https://pastebin.com/ -- type: dropdown + Check the folder `/plugins/Slimefun/error-reports/` and upload any files inside that folder + to a pasting site (e.g. https://pastebin.com/) + placeholder: https://pastebin.com/... + +- id: server-software + type: dropdown validations: required: true attributes: - label: ':video_game: Minecraft Version' + label: '💻 Server Software' + description: 'Please select the software your Server is running on' + options: + - Spigot + - Paper + - Tuinity + - Purpur + - Other + +- id: minecraft-version + type: dropdown + validations: + required: true + attributes: + label: '🎮 Minecraft Version' description: 'Please select the Minecraft version of the server' options: #- 1.17.x - 1.16.x - 1.15.x - 1.14.x - - Older -- type: textarea + - (Older versions are not supported) + +- id: slimefun-version + type: textarea validations: required: true attributes: - label: ':compass: Environment' + label: '⭐ Slimefun version' description: | - Any issue without the exact version numbers will be closed! - "latest" IS NOT A VERSION NUMBER. - We recommend running "/sf versions" and showing us a screenshot of that. + **"latest" is not a version number, we need the exact version.** + We recommend running "/sf versions" and uploading a screenshot of that. Make sure that the screenshot covers the entire output of that command. If your issue is related to other plugins, make sure to include the versions of these plugins too! + placeholder: Slimefun version [...] + +- type: markdown + attributes: value: | - - Server software: - - Slimefun version: + ## ❤️ Thank you for submitting a bug report! + If anyone who sees this has some additional info which can help reproduce or track down this issue, + please comment down below. Any help is appreciated! diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemSetting.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemSetting.java index b753f9c1e..417199e91 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemSetting.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemSetting.java @@ -1,5 +1,8 @@ package io.github.thebusybiscuit.slimefun4.api.items; +import java.util.List; +import java.util.Objects; + import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; @@ -9,8 +12,6 @@ import io.github.thebusybiscuit.cscorelib2.config.Config; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; -import java.util.List; - /** * This class represents a Setting for a {@link SlimefunItem} that can be modified via * the {@code Items.yml} {@link Config} file. @@ -91,6 +92,16 @@ public class ItemSetting { return key; } + /** + * This returns the associated {@link SlimefunItem} for this {@link ItemSetting}. + * + * @return The associated {@link SlimefunItem} + */ + @Nonnull + protected SlimefunItem getItem() { + return item; + } + /** * This returns the current value of this {@link ItemSetting}. * @@ -188,4 +199,19 @@ public class ItemSetting { return getClass().getSimpleName() + " {" + getKey() + " = " + currentValue + " (default: " + getDefaultValue() + ")"; } + @Override + public final int hashCode() { + return Objects.hash(item, key); + } + + @Override + public final boolean equals(Object obj) { + if (obj instanceof ItemSetting) { + ItemSetting setting = (ItemSetting) obj; + return Objects.equals(getKey(), setting.getKey()) && Objects.equals(getItem(), setting.getItem()); + } else { + return false; + } + } + } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/MagicianTalisman.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/MagicianTalisman.java index ea305bf32..446cb0b8c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/MagicianTalisman.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/MagicianTalisman.java @@ -1,18 +1,5 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.magical.talismans; -import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; -import io.github.thebusybiscuit.slimefun4.implementation.settings.TalismanEnchantment; -import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; -import org.apache.commons.lang.Validate; -import org.bukkit.Material; -import org.bukkit.enchantments.Enchantment; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import javax.annotation.ParametersAreNonnullByDefault; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -20,6 +7,21 @@ import java.util.concurrent.ThreadLocalRandom; import java.util.logging.Level; import java.util.stream.Collectors; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import javax.annotation.ParametersAreNonnullByDefault; + +import org.apache.commons.lang.Validate; +import org.bukkit.Material; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; +import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; +import io.github.thebusybiscuit.slimefun4.implementation.settings.TalismanEnchantment; +import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; + /** * The {@link MagicianTalisman} is a special kind of {@link Talisman} which awards a {@link Player} * with an extra {@link Enchantment} when they enchant their {@link ItemStack}. @@ -48,8 +50,13 @@ public class MagicianTalisman extends Talisman { } } - if (!enchantments.isEmpty()) { - addItemSetting(enchantments.toArray(new ItemSetting[0])); + try { + if (!enchantments.isEmpty()) { + // Fixes #3007 - This is a Set, so every Enchantment should only be contained in here once. + addItemSetting(enchantments.toArray(new ItemSetting[0])); + } + } catch (Exception x) { + SlimefunPlugin.logger().log(Level.SEVERE, x, () -> "The following Exception was thrown when initializing the settings for " + toString()); } }