mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-19 19:25:48 +00:00
Fixed #3007
This commit is contained in:
parent
08a4cd7556
commit
df7b262d14
@ -50,6 +50,7 @@
|
|||||||
* Fixed #2999
|
* Fixed #2999
|
||||||
* Fixed #2593
|
* Fixed #2593
|
||||||
* Fixed #2937
|
* Fixed #2937
|
||||||
|
* Fixed #3007
|
||||||
|
|
||||||
## Release Candidate 22 (18 Apr 2021)
|
## Release Candidate 22 (18 Apr 2021)
|
||||||
https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#22
|
https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#22
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
package io.github.thebusybiscuit.slimefun4.api.items;
|
package io.github.thebusybiscuit.slimefun4.api.items;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.ParametersAreNonnullByDefault;
|
import javax.annotation.ParametersAreNonnullByDefault;
|
||||||
|
|
||||||
@ -9,8 +12,6 @@ import io.github.thebusybiscuit.cscorelib2.config.Config;
|
|||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
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
|
* This class represents a Setting for a {@link SlimefunItem} that can be modified via
|
||||||
* the {@code Items.yml} {@link Config} file.
|
* the {@code Items.yml} {@link Config} file.
|
||||||
@ -91,6 +92,16 @@ public class ItemSetting<T> {
|
|||||||
return key;
|
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 <strong>current</strong> value of this {@link ItemSetting}.
|
* This returns the <strong>current</strong> value of this {@link ItemSetting}.
|
||||||
*
|
*
|
||||||
@ -188,4 +199,19 @@ public class ItemSetting<T> {
|
|||||||
return getClass().getSimpleName() + " {" + getKey() + " = " + currentValue + " (default: " + getDefaultValue() + ")";
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,5 @@
|
|||||||
package io.github.thebusybiscuit.slimefun4.implementation.items.magical.talismans;
|
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.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -20,6 +7,21 @@ import java.util.concurrent.ThreadLocalRandom;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.stream.Collectors;
|
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}
|
* 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}.
|
* with an extra {@link Enchantment} when they enchant their {@link ItemStack}.
|
||||||
@ -48,8 +50,13 @@ public class MagicianTalisman extends Talisman {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!enchantments.isEmpty()) {
|
try {
|
||||||
addItemSetting(enchantments.toArray(new ItemSetting[0]));
|
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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user