mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-19 19:25:48 +00:00
Fixed Mining Androids and improved itemsettings API
This commit is contained in:
parent
3aa02d5e04
commit
fbd701bced
@ -37,6 +37,7 @@
|
||||
* Androids operating on a Cobblestone/Stone/Basalt generator now work faster
|
||||
* (API) Improvements to the BlockBreakHandler
|
||||
* (API) Deprecated SlimefunBlockHandler
|
||||
* (API) Improved ItemSetting API and error handling
|
||||
|
||||
#### Fixes
|
||||
* Fixed #2794
|
||||
@ -60,6 +61,7 @@
|
||||
* Fixed #2876
|
||||
* Fixed #2877
|
||||
* Fixed #2878
|
||||
* Fixed Mining Androids being broken
|
||||
|
||||
## Release Candidate 20 (30 Jan 2021)
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package io.github.thebusybiscuit.slimefun4.api.items;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
@ -20,6 +21,8 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
*/
|
||||
public class ItemSetting<T> {
|
||||
|
||||
private SlimefunItem item;
|
||||
|
||||
private final String key;
|
||||
private final T defaultValue;
|
||||
|
||||
@ -28,20 +31,38 @@ public class ItemSetting<T> {
|
||||
/**
|
||||
* This creates a new {@link ItemSetting} with the given key and default value
|
||||
*
|
||||
* @param item
|
||||
* The {@link SlimefunItem} this {@link ItemSetting} belongs to
|
||||
* @param key
|
||||
* The key under which this setting will be stored (relative to the {@link SlimefunItem})
|
||||
* @param defaultValue
|
||||
* The default value for this {@link ItemSetting}
|
||||
*/
|
||||
@ParametersAreNonnullByDefault
|
||||
public ItemSetting(String key, T defaultValue) {
|
||||
public ItemSetting(SlimefunItem item, String key, T defaultValue) {
|
||||
Validate.notNull(key, "The key of an ItemSetting is not allowed to be null!");
|
||||
Validate.notNull(defaultValue, "The default value of an ItemSetting is not allowed to be null!");
|
||||
|
||||
this.item = item;
|
||||
this.key = key;
|
||||
this.defaultValue = defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* This creates a new {@link ItemSetting} with the given key and default value
|
||||
*
|
||||
* @deprecated Please use the other constructor.
|
||||
*
|
||||
* @param key
|
||||
* The key under which this setting will be stored (relative to the {@link SlimefunItem})
|
||||
* @param defaultValue
|
||||
* The default value for this {@link ItemSetting}
|
||||
*/
|
||||
@Deprecated
|
||||
public ItemSetting(String key, T defaultValue) {
|
||||
this(null, key, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method checks if a given input would be valid as a value for this
|
||||
* {@link ItemSetting}. You can override this method to implement your own checks.
|
||||
@ -90,9 +111,14 @@ public class ItemSetting<T> {
|
||||
*/
|
||||
@Nonnull
|
||||
public T getValue() {
|
||||
Validate.notNull(value, "ItemSetting '" + key + "' was invoked but was not initialized yet.");
|
||||
|
||||
return value;
|
||||
if (value != null) {
|
||||
return value;
|
||||
} else if (item != null) {
|
||||
item.warn("ItemSetting '" + key + "' was invoked but was not initialized yet.");
|
||||
return defaultValue;
|
||||
} else {
|
||||
throw new IllegalStateException("ItemSetting '" + key + "' was invoked but was not initialized yet.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -136,7 +162,7 @@ public class ItemSetting<T> {
|
||||
* The {@link SlimefunItem} who called this method
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public void load(@Nonnull SlimefunItem item) {
|
||||
public void reload() {
|
||||
Validate.notNull(item, "Cannot apply settings for a non-existing SlimefunItem");
|
||||
|
||||
SlimefunPlugin.getItemCfg().setDefaultValue(item.getId() + '.' + getKey(), getDefaultValue());
|
||||
@ -179,4 +205,17 @@ public class ItemSetting<T> {
|
||||
return getClass().getSimpleName() + " {" + getKey() + " = " + currentValue + " (default: " + getDefaultValue() + ")";
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a temporary workaround and will be removed.
|
||||
*
|
||||
* @deprecated Do not use this method!
|
||||
* @param item
|
||||
* the item
|
||||
*/
|
||||
@Deprecated
|
||||
public void reload(@Nullable SlimefunItem item) {
|
||||
this.item = item;
|
||||
reload();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import javax.annotation.ParametersAreNonnullByDefault;
|
||||
import org.apache.commons.lang.Validate;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
|
||||
/**
|
||||
* This variation of {@link ItemSetting} allows you to define an {@link Double} range
|
||||
@ -23,14 +24,19 @@ public class DoubleRangeSetting extends ItemSetting<Double> {
|
||||
private final double max;
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
public DoubleRangeSetting(String key, double min, double defaultValue, double max) {
|
||||
super(key, defaultValue);
|
||||
public DoubleRangeSetting(SlimefunItem item, String key, double min, double defaultValue, double max) {
|
||||
super(item, key, defaultValue);
|
||||
Validate.isTrue(defaultValue >= min && defaultValue <= max, "The default value is not in range.");
|
||||
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public DoubleRangeSetting(String key, double min, double defaultValue, double max) {
|
||||
this(null, key, min, defaultValue, max);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
protected String getErrorMessage() {
|
||||
|
@ -7,6 +7,7 @@ import javax.annotation.Nonnull;
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
|
||||
/**
|
||||
* This variation of {@link ItemSetting} allows you to allow {@link Enum} constants to be
|
||||
@ -25,12 +26,17 @@ public class EnumSetting<T extends Enum<T>> extends ItemSetting<String> {
|
||||
private final Class<T> enumClass;
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
public EnumSetting(String key, Class<T> enumClass, T defaultValue) {
|
||||
super(key, defaultValue.name());
|
||||
public EnumSetting(SlimefunItem item, String key, Class<T> enumClass, T defaultValue) {
|
||||
super(item, key, defaultValue.name());
|
||||
|
||||
this.enumClass = enumClass;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public EnumSetting(String key, Class<T> enumClass, T defaultValue) {
|
||||
this(null, key, enumClass, defaultValue);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
protected String getErrorMessage() {
|
||||
|
@ -6,6 +6,7 @@ import javax.annotation.ParametersAreNonnullByDefault;
|
||||
import org.apache.commons.lang.Validate;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
|
||||
/**
|
||||
* This variation of {@link ItemSetting} allows you to define an {@link Integer} range
|
||||
@ -23,14 +24,19 @@ public class IntRangeSetting extends ItemSetting<Integer> {
|
||||
private final int max;
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
public IntRangeSetting(String key, int min, int defaultValue, int max) {
|
||||
super(key, defaultValue);
|
||||
public IntRangeSetting(SlimefunItem item, String key, int min, int defaultValue, int max) {
|
||||
super(item, key, defaultValue);
|
||||
Validate.isTrue(defaultValue >= min && defaultValue <= max, "The default value is not in range.");
|
||||
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public IntRangeSetting(String key, int min, int defaultValue, int max) {
|
||||
this(null, key, min, defaultValue, max);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
protected String getErrorMessage() {
|
||||
|
@ -10,6 +10,7 @@ import org.bukkit.Material;
|
||||
import org.bukkit.Tag;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
|
||||
/**
|
||||
* This variation of {@link ItemSetting} allows you to define a default {@link Tag}.
|
||||
@ -28,12 +29,17 @@ public class MaterialTagSetting extends ItemSetting<List<String>> {
|
||||
private final Tag<Material> defaultTag;
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
public MaterialTagSetting(String key, Tag<Material> defaultTag) {
|
||||
super(key, getAsStringList(defaultTag));
|
||||
public MaterialTagSetting(SlimefunItem item, String key, Tag<Material> defaultTag) {
|
||||
super(item, key, getAsStringList(defaultTag));
|
||||
|
||||
this.defaultTag = defaultTag;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public MaterialTagSetting(String key, Tag<Material> defaultValue) {
|
||||
this(null, key, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* This {@link Tag} holds the default values for this {@link MaterialTagSetting}.
|
||||
*
|
||||
|
@ -53,13 +53,14 @@ public class MinerAndroid extends ProgrammableAndroid {
|
||||
// Determines the drops a miner android will get
|
||||
private final ItemStack effectivePickaxe = new ItemStack(Material.DIAMOND_PICKAXE);
|
||||
|
||||
private final ItemSetting<Boolean> firesEvent = new ItemSetting<>("trigger-event-for-generators", false);
|
||||
private final ItemSetting<Boolean> applyOptimizations = new ItemSetting<>("reduced-block-updates", true);
|
||||
private final ItemSetting<Boolean> firesEvent = new ItemSetting<>(this, "trigger-event-for-generators", false);
|
||||
private final ItemSetting<Boolean> applyOptimizations = new ItemSetting<>(this, "reduced-block-updates", true);
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
public MinerAndroid(Category category, int tier, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||
super(category, tier, item, recipeType, recipe);
|
||||
addItemSetting(firesEvent);
|
||||
|
||||
addItemSetting(firesEvent, applyOptimizations);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -53,7 +53,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
*/
|
||||
public class BlockPlacer extends SlimefunItem {
|
||||
|
||||
private final ItemSetting<List<String>> unplaceableBlocks = new MaterialTagSetting("unplaceable-blocks", SlimefunTag.UNBREAKABLE_MATERIALS);
|
||||
private final ItemSetting<List<String>> unplaceableBlocks = new MaterialTagSetting(this, "unplaceable-blocks", SlimefunTag.UNBREAKABLE_MATERIALS);
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
public BlockPlacer(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||
|
@ -44,7 +44,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
*/
|
||||
public class Crucible extends SimpleSlimefunItem<BlockUseHandler> implements RecipeDisplayItem {
|
||||
|
||||
private final ItemSetting<Boolean> allowWaterInNether = new ItemSetting<>("allow-water-in-nether", false);
|
||||
private final ItemSetting<Boolean> allowWaterInNether = new ItemSetting<>(this, "allow-water-in-nether", false);
|
||||
private final List<ItemStack> recipes;
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
|
@ -31,7 +31,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
*/
|
||||
public class RepairedSpawner extends AbstractMonsterSpawner {
|
||||
|
||||
private final ItemSetting<Boolean> allowSpawnEggs = new ItemSetting<>("allow-spawn-eggs", true);
|
||||
private final ItemSetting<Boolean> allowSpawnEggs = new ItemSetting<>(this, "allow-spawn-eggs", true);
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
public RepairedSpawner(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||
|
@ -12,8 +12,8 @@ class MultiToolMode {
|
||||
private final ItemSetting<Boolean> enabled;
|
||||
|
||||
MultiToolMode(@Nonnull MultiTool multiTool, int id, @Nonnull String itemId) {
|
||||
this.item = new ItemSetting<>("mode." + id + ".item", itemId);
|
||||
this.enabled = new ItemSetting<>("mode." + id + ".enabled", true);
|
||||
this.item = new ItemSetting<>(multiTool, "mode." + id + ".item", itemId);
|
||||
this.enabled = new ItemSetting<>(multiTool, "mode." + id + ".enabled", true);
|
||||
|
||||
multiTool.addItemSetting(item, enabled);
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ public class SolarHelmet extends SlimefunItem {
|
||||
throw new IllegalArgumentException("A Solar Helmet must have a positive charging level!");
|
||||
}
|
||||
|
||||
charge = new DoubleRangeSetting("charge-amount", 0.01, defaultChargingLevel, Double.MAX_VALUE);
|
||||
charge = new DoubleRangeSetting(this, "charge-amount", 0.01, defaultChargingLevel, Double.MAX_VALUE);
|
||||
addItemSetting(charge);
|
||||
}
|
||||
|
||||
|
@ -29,9 +29,9 @@ import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
|
||||
*/
|
||||
public class BookBinder extends AContainer {
|
||||
|
||||
private final ItemSetting<Boolean> bypassVanillaMaxLevel = new ItemSetting<>("bypass-vanilla-max-level", false);
|
||||
private final ItemSetting<Boolean> hasCustomMaxLevel = new ItemSetting<>("has-custom-max-level", false);
|
||||
private final ItemSetting<Integer> customMaxLevel = new IntRangeSetting("custom-max-level", 0, 15, Integer.MAX_VALUE);
|
||||
private final ItemSetting<Boolean> bypassVanillaMaxLevel = new ItemSetting<>(this, "bypass-vanilla-max-level", false);
|
||||
private final ItemSetting<Boolean> hasCustomMaxLevel = new ItemSetting<>(this, "has-custom-max-level", false);
|
||||
private final ItemSetting<Integer> customMaxLevel = new IntRangeSetting(this, "custom-max-level", 0, 15, Integer.MAX_VALUE);
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
public BookBinder(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||
|
@ -23,7 +23,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
*/
|
||||
public class MeatJerky extends SimpleSlimefunItem<ItemConsumptionHandler> {
|
||||
|
||||
private final ItemSetting<Integer> saturation = new IntRangeSetting("saturation-level", 0, 6, Integer.MAX_VALUE);
|
||||
private final ItemSetting<Integer> saturation = new IntRangeSetting(this, "saturation-level", 0, 6, Integer.MAX_VALUE);
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
public MeatJerky(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||
|
@ -37,9 +37,9 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
*/
|
||||
public class InfusedHopper extends SimpleSlimefunItem<BlockTicker> {
|
||||
|
||||
private final ItemSetting<Boolean> silent = new ItemSetting<>("silent", false);
|
||||
private final ItemSetting<Boolean> toggleable = new ItemSetting<>("toggleable-with-redstone", false);
|
||||
private final ItemSetting<Double> radius = new DoubleRangeSetting("radius", 0.1, 3.5, Double.MAX_VALUE);
|
||||
private final ItemSetting<Boolean> silent = new ItemSetting<>(this, "silent", false);
|
||||
private final ItemSetting<Boolean> toggleable = new ItemSetting<>(this, "toggleable-with-redstone", false);
|
||||
private final ItemSetting<Double> radius = new DoubleRangeSetting(this, "radius", 0.1, 3.5, Double.MAX_VALUE);
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
public InfusedHopper(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||
|
@ -22,7 +22,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
*/
|
||||
public class InfusedMagnet extends UnplaceableBlock {
|
||||
|
||||
private final ItemSetting<Double> radius = new DoubleRangeSetting("pickup-radius", 0.1, 6.0, Double.MAX_VALUE);
|
||||
private final ItemSetting<Double> radius = new DoubleRangeSetting(this, "pickup-radius", 0.1, 6.0, Double.MAX_VALUE);
|
||||
|
||||
public InfusedMagnet(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||
super(category, item, recipeType, recipe);
|
||||
|
@ -1,5 +1,7 @@
|
||||
package io.github.thebusybiscuit.slimefun4.implementation.items.magical;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Entity;
|
||||
@ -25,8 +27,9 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
*/
|
||||
public class TelepositionScroll extends SimpleSlimefunItem<ItemUseHandler> {
|
||||
|
||||
private final ItemSetting<Integer> radius = new IntRangeSetting("radius", 1, 10, Integer.MAX_VALUE);
|
||||
private final ItemSetting<Integer> radius = new IntRangeSetting(this, "radius", 1, 10, Integer.MAX_VALUE);
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
public TelepositionScroll(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||
super(category, item, recipeType, recipe);
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
package io.github.thebusybiscuit.slimefun4.implementation.items.magical.staves;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.GameMode;
|
||||
@ -25,8 +27,9 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
*/
|
||||
public class WindStaff extends SimpleSlimefunItem<ItemUseHandler> {
|
||||
|
||||
private final ItemSetting<Integer> multiplier = new IntRangeSetting("power", 1, 4, Integer.MAX_VALUE);
|
||||
private final ItemSetting<Integer> multiplier = new IntRangeSetting(this, "power", 1, 4, Integer.MAX_VALUE);
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
public WindStaff(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||
super(category, item, recipeType, recipe);
|
||||
|
||||
|
@ -29,7 +29,7 @@ import java.util.stream.Collectors;
|
||||
*/
|
||||
public class MagicianTalisman extends Talisman {
|
||||
|
||||
private final ItemSetting<Boolean> allowEnchantmentBooks = new ItemSetting<>("allow-enchantment-books", false);
|
||||
private final ItemSetting<Boolean> allowEnchantmentBooks = new ItemSetting<>(this, "allow-enchantment-books", false);
|
||||
|
||||
private final Set<TalismanEnchantment> enchantments = new HashSet<>();
|
||||
|
||||
@ -42,7 +42,7 @@ public class MagicianTalisman extends Talisman {
|
||||
for (Enchantment enchantment : Enchantment.values()) {
|
||||
try {
|
||||
for (int i = 1; i <= enchantment.getMaxLevel(); i++) {
|
||||
enchantments.add(new TalismanEnchantment(enchantment, i));
|
||||
enchantments.add(new TalismanEnchantment(this, enchantment, i));
|
||||
}
|
||||
} catch (Exception x) {
|
||||
SlimefunPlugin.logger().log(Level.SEVERE, x, () -> "The following Exception occurred while trying to register the following Enchantment: " + enchantment);
|
||||
|
@ -26,8 +26,8 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
*/
|
||||
public class BasicCircuitBoard extends SimpleSlimefunItem<ItemUseHandler> implements NotPlaceable, RandomMobDrop {
|
||||
|
||||
private final ItemSetting<Boolean> dropSetting = new ItemSetting<>("drop-from-golems", true);
|
||||
private final ItemSetting<Integer> chance = new IntRangeSetting("golem-drop-chance", 0, 75, 100);
|
||||
private final ItemSetting<Boolean> dropSetting = new ItemSetting<>(this, "drop-from-golems", true);
|
||||
private final ItemSetting<Integer> chance = new IntRangeSetting(this, "golem-drop-chance", 0, 75, 100);
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
public BasicCircuitBoard(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||
|
@ -1,6 +1,8 @@
|
||||
package io.github.thebusybiscuit.slimefun4.implementation.items.misc;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
@ -39,8 +41,9 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
*/
|
||||
public class StrangeNetherGoo extends SimpleSlimefunItem<ItemUseHandler> implements PiglinBarterDrop {
|
||||
|
||||
private final ItemSetting<Integer> chance = new IntRangeSetting("barter-chance", 0, 7, 100);
|
||||
private final ItemSetting<Integer> chance = new IntRangeSetting(this, "barter-chance", 0, 7, 100);
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
public StrangeNetherGoo(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||
super(category, item, recipeType, recipe);
|
||||
|
||||
|
@ -4,6 +4,9 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
@ -36,8 +39,9 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
*/
|
||||
public class OreCrusher extends MultiBlockMachine {
|
||||
|
||||
private final DoubleOreSetting doubleOres = new DoubleOreSetting();
|
||||
private final DoubleOreSetting doubleOres = new DoubleOreSetting(this);
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
public OreCrusher(Category category, SlimefunItemStack item) {
|
||||
super(category, item, new ItemStack[] { null, null, null, null, new ItemStack(Material.NETHER_BRICK_FENCE), null, new ItemStack(Material.IRON_BARS), new CustomItem(Material.DISPENSER, "Dispenser (Facing up)"), new ItemStack(Material.IRON_BARS) }, BlockFace.SELF);
|
||||
|
||||
@ -165,8 +169,8 @@ public class OreCrusher extends MultiBlockMachine {
|
||||
private final ItemStack quartz = new ItemStack(Material.QUARTZ, 1);
|
||||
private final ItemStack goldNuggets = new ItemStack(Material.GOLD_NUGGET, 4);
|
||||
|
||||
public DoubleOreSetting() {
|
||||
super("double-ores", true);
|
||||
public DoubleOreSetting(@Nonnull OreCrusher oreCrusher) {
|
||||
super(oreCrusher, "double-ores", true);
|
||||
}
|
||||
|
||||
private void apply(boolean value) {
|
||||
@ -196,8 +200,8 @@ public class OreCrusher extends MultiBlockMachine {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(SlimefunItem item) {
|
||||
super.load(item);
|
||||
public void reload() {
|
||||
super.reload();
|
||||
apply(getValue());
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
public class Smeltery extends AbstractSmeltery {
|
||||
|
||||
private final BlockFace[] faces = { BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST };
|
||||
private final ItemSetting<Integer> fireBreakingChance = new IntRangeSetting("fire-breaking-chance", 0, 34, 100);
|
||||
private final ItemSetting<Integer> fireBreakingChance = new IntRangeSetting(this, "fire-breaking-chance", 0, 34, 100);
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
public Smeltery(Category category, SlimefunItemStack item) {
|
||||
|
@ -7,6 +7,8 @@ import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@ -49,8 +51,9 @@ public class IndustrialMiner extends MultiBlockMachine {
|
||||
|
||||
private final int range;
|
||||
private final boolean silkTouch;
|
||||
private final ItemSetting<Boolean> canMineAncientDebris = new ItemSetting<>("can-mine-ancient-debris", false);
|
||||
private final ItemSetting<Boolean> canMineAncientDebris = new ItemSetting<>(this, "can-mine-ancient-debris", false);
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
public IndustrialMiner(Category category, SlimefunItemStack item, Material baseMaterial, boolean silkTouch, int range) {
|
||||
super(category, item, new ItemStack[] { null, null, null, new CustomItem(Material.PISTON, "Piston (facing up)"), new ItemStack(Material.CHEST), new CustomItem(Material.PISTON, "Piston (facing up)"), new ItemStack(baseMaterial), new ItemStack(Material.BLAST_FURNACE), new ItemStack(baseMaterial) }, BlockFace.UP);
|
||||
|
||||
|
@ -57,8 +57,9 @@ public class ClimbingPick extends SimpleSlimefunItem<ItemUseHandler> implements
|
||||
private static final double EFFICIENCY_MODIFIER = 0.125;
|
||||
private static final long COOLDOWN = 4;
|
||||
|
||||
private final ItemSetting<Boolean> dualWielding = new ItemSetting<>("dual-wielding", true);
|
||||
private final ItemSetting<Boolean> damageOnUse = new ItemSetting<>("damage-on-use", true);
|
||||
private final ItemSetting<Boolean> dualWielding = new ItemSetting<>(this, "dual-wielding", true);
|
||||
private final ItemSetting<Boolean> damageOnUse = new ItemSetting<>(this, "damage-on-use", true);
|
||||
|
||||
private final Map<Material, ClimbableSurface> surfaces = new EnumMap<>(Material.class);
|
||||
private final Set<UUID> users = new HashSet<>();
|
||||
|
||||
@ -86,7 +87,7 @@ public class ClimbingPick extends SimpleSlimefunItem<ItemUseHandler> implements
|
||||
}
|
||||
|
||||
protected void addSurface(@Nonnull Material type, double defaultValue) {
|
||||
ClimbableSurface surface = new ClimbableSurface(type, defaultValue);
|
||||
ClimbableSurface surface = new ClimbableSurface(this, type, defaultValue);
|
||||
addItemSetting(surface);
|
||||
surfaces.put(type, surface);
|
||||
}
|
||||
|
@ -43,8 +43,8 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
*/
|
||||
public class ExplosiveTool extends SimpleSlimefunItem<ToolUseHandler> implements NotPlaceable, DamageableItem {
|
||||
|
||||
private final ItemSetting<Boolean> damageOnUse = new ItemSetting<>("damage-on-use", true);
|
||||
private final ItemSetting<Boolean> callExplosionEvent = new ItemSetting<>("call-explosion-event", false);
|
||||
private final ItemSetting<Boolean> damageOnUse = new ItemSetting<>(this, "damage-on-use", true);
|
||||
private final ItemSetting<Boolean> callExplosionEvent = new ItemSetting<>(this, "call-explosion-event", false);
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
public ExplosiveTool(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||
|
@ -38,8 +38,8 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
*/
|
||||
public class GrapplingHook extends SimpleSlimefunItem<ItemUseHandler> {
|
||||
|
||||
private final ItemSetting<Boolean> consumeOnUse = new ItemSetting<>("consume-on-use", true);
|
||||
private final ItemSetting<Integer> despawnTicks = new IntRangeSetting("despawn-seconds", 0, 60, Integer.MAX_VALUE);
|
||||
private final ItemSetting<Boolean> consumeOnUse = new ItemSetting<>(this, "consume-on-use", true);
|
||||
private final ItemSetting<Integer> despawnTicks = new IntRangeSetting(this, "despawn-seconds", 0, 60, Integer.MAX_VALUE);
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
public GrapplingHook(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||
|
@ -29,7 +29,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
*/
|
||||
public class PickaxeOfTheSeeker extends SimpleSlimefunItem<ItemUseHandler> implements DamageableItem {
|
||||
|
||||
private final ItemSetting<Integer> maxRange = new IntRangeSetting("max-range", 1, 5, Integer.MAX_VALUE);
|
||||
private final ItemSetting<Integer> maxRange = new IntRangeSetting(this, "max-range", 1, 5, Integer.MAX_VALUE);
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
public PickaxeOfTheSeeker(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||
|
@ -34,7 +34,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
*/
|
||||
public class PickaxeOfVeinMining extends SimpleSlimefunItem<ToolUseHandler> {
|
||||
|
||||
private final ItemSetting<Integer> maxBlocks = new IntRangeSetting("max-blocks", 1, 16, Integer.MAX_VALUE);
|
||||
private final ItemSetting<Integer> maxBlocks = new IntRangeSetting(this, "max-blocks", 1, 16, Integer.MAX_VALUE);
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
public PickaxeOfVeinMining(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||
|
@ -35,7 +35,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
*/
|
||||
public class ExplosiveBow extends SlimefunBow {
|
||||
|
||||
private final ItemSetting<Integer> range = new IntRangeSetting("explosion-range", 1, 3, Integer.MAX_VALUE);
|
||||
private final ItemSetting<Integer> range = new IntRangeSetting(this, "explosion-range", 1, 3, Integer.MAX_VALUE);
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
public ExplosiveBow(Category category, SlimefunItemStack item, ItemStack[] recipe) {
|
||||
|
@ -37,11 +37,11 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
*/
|
||||
public class SwordOfBeheading extends SimpleSlimefunItem<EntityKillHandler> {
|
||||
|
||||
private final ItemSetting<Integer> chanceZombie = new IntRangeSetting("chance.ZOMBIE", 0, 40, 100);
|
||||
private final ItemSetting<Integer> chanceSkeleton = new IntRangeSetting("chance.SKELETON", 0, 40, 100);
|
||||
private final ItemSetting<Integer> chanceWitherSkeleton = new IntRangeSetting("chance.WITHER_SKELETON", 0, 25, 100);
|
||||
private final ItemSetting<Integer> chanceCreeper = new IntRangeSetting("chance.CREEPER", 0, 40, 100);
|
||||
private final ItemSetting<Integer> chancePlayer = new IntRangeSetting("chance.PLAYER", 0, 70, 100);
|
||||
private final ItemSetting<Integer> chanceZombie = new IntRangeSetting(this, "chance.ZOMBIE", 0, 40, 100);
|
||||
private final ItemSetting<Integer> chanceSkeleton = new IntRangeSetting(this, "chance.SKELETON", 0, 40, 100);
|
||||
private final ItemSetting<Integer> chanceWitherSkeleton = new IntRangeSetting(this, "chance.WITHER_SKELETON", 0, 25, 100);
|
||||
private final ItemSetting<Integer> chanceCreeper = new IntRangeSetting(this, "chance.CREEPER", 0, 40, 100);
|
||||
private final ItemSetting<Integer> chancePlayer = new IntRangeSetting(this, "chance.PLAYER", 0, 70, 100);
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
public SwordOfBeheading(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||
|
@ -30,7 +30,7 @@ public class VampireBlade extends SlimefunItem {
|
||||
|
||||
private static final double HEALING_AMOUNT = 4.0;
|
||||
|
||||
private final ItemSetting<Integer> chance = new IntRangeSetting("chance", 0, 45, 100);
|
||||
private final ItemSetting<Integer> chance = new IntRangeSetting(this, "chance", 0, 45, 100);
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
public VampireBlade(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||
|
@ -31,8 +31,8 @@ public class ClimbableSurface extends DoubleRangeSetting {
|
||||
* @param defaultValue
|
||||
* The default launch amount
|
||||
*/
|
||||
public ClimbableSurface(@Nonnull Material surface, double defaultValue) {
|
||||
super("launch-amounts." + surface.name(), 0, defaultValue, Double.MAX_VALUE);
|
||||
public ClimbableSurface(@Nonnull ClimbingPick climbingPick, @Nonnull Material surface, double defaultValue) {
|
||||
super(climbingPick, "launch-amounts." + surface.name(), 0, defaultValue, Double.MAX_VALUE);
|
||||
|
||||
this.type = surface;
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ public class GoldPanDrop extends ItemSetting<Integer> {
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
public GoldPanDrop(GoldPan goldPan, String key, int defaultValue, ItemStack output) {
|
||||
super(key, defaultValue);
|
||||
super(goldPan, key, defaultValue);
|
||||
|
||||
this.goldPan = goldPan;
|
||||
this.output = output;
|
||||
|
@ -1,6 +1,7 @@
|
||||
package io.github.thebusybiscuit.slimefun4.implementation.settings;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
|
||||
@ -14,14 +15,16 @@ import io.github.thebusybiscuit.slimefun4.implementation.listeners.TalismanListe
|
||||
*
|
||||
* @author TheBusyBiscuit
|
||||
*
|
||||
* @see MagicianTalisman
|
||||
*/
|
||||
public class TalismanEnchantment extends ItemSetting<Boolean> {
|
||||
|
||||
private final Enchantment enchantment;
|
||||
private final int level;
|
||||
|
||||
public TalismanEnchantment(@Nonnull Enchantment enchantment, int level) {
|
||||
super("allow-enchantments." + enchantment.getKey().getNamespace() + '.' + enchantment.getKey().getKey() + ".level." + level, true);
|
||||
@ParametersAreNonnullByDefault
|
||||
public TalismanEnchantment(MagicianTalisman talisman, Enchantment enchantment, int level) {
|
||||
super(talisman, "allow-enchantments." + enchantment.getKey().getNamespace() + '.' + enchantment.getKey().getKey() + ".level." + level, true);
|
||||
|
||||
this.enchantment = enchantment;
|
||||
this.level = level;
|
||||
|
@ -465,7 +465,7 @@ public class SlimefunItem implements Placeable {
|
||||
|
||||
// Load all item settings
|
||||
for (ItemSetting<?> setting : itemSettings) {
|
||||
setting.load(this);
|
||||
setting.reload(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,13 +34,15 @@ class TestDoubleRangeSetting {
|
||||
@Test
|
||||
@DisplayName("Test Constructor validation")
|
||||
void testConstructorValidation() {
|
||||
Assertions.assertThrows(IllegalArgumentException.class, () -> new DoubleRangeSetting("test", min, -1.0, max));
|
||||
SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "DOUBLE_RANGE_TEST_00", new CustomItem(Material.DIAMOND, "&cTest"));
|
||||
Assertions.assertThrows(IllegalArgumentException.class, () -> new DoubleRangeSetting(item, "test", min, -1.0, max));
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Test min and max getters")
|
||||
void testMinMaxGetters() {
|
||||
DoubleRangeSetting setting = new DoubleRangeSetting("test", min, 0.5, max);
|
||||
SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "DOUBLE_RANGE_TEST_0", new CustomItem(Material.DIAMOND, "&cTest"));
|
||||
DoubleRangeSetting setting = new DoubleRangeSetting(item, "test", min, 0.5, max);
|
||||
|
||||
Assertions.assertEquals(min, setting.getMinimum());
|
||||
Assertions.assertEquals(max, setting.getMaximum());
|
||||
@ -49,9 +51,9 @@ class TestDoubleRangeSetting {
|
||||
@Test
|
||||
@DisplayName("Test illegal values")
|
||||
void testIllegalValues() {
|
||||
DoubleRangeSetting setting = new DoubleRangeSetting("test", min, 0.5, max);
|
||||
|
||||
SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "DOUBLE_RANGE_TEST", new CustomItem(Material.DIAMOND, "&cTest"));
|
||||
DoubleRangeSetting setting = new DoubleRangeSetting(item, "test", min, 0.5, max);
|
||||
|
||||
item.addItemSetting(setting);
|
||||
item.register(plugin);
|
||||
|
||||
@ -63,9 +65,9 @@ class TestDoubleRangeSetting {
|
||||
@Test
|
||||
@DisplayName("Test allowed value")
|
||||
void testAllowedValue() {
|
||||
DoubleRangeSetting setting = new DoubleRangeSetting("test", min, 0.25, max);
|
||||
|
||||
SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "DOUBLE_RANGE_TEST_2", new CustomItem(Material.DIAMOND, "&cTest"));
|
||||
DoubleRangeSetting setting = new DoubleRangeSetting(item, "test", min, 0.25, max);
|
||||
|
||||
item.addItemSetting(setting);
|
||||
item.register(plugin);
|
||||
|
||||
|
@ -32,16 +32,17 @@ class TestEnumSetting {
|
||||
@Test
|
||||
@DisplayName("Test Enum Getters")
|
||||
void testEnumGetters() {
|
||||
EnumSetting<Material> setting = new EnumSetting<>("test", Material.class, Material.DIAMOND);
|
||||
SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MATERIAL_SETTING_TEST_0", new CustomItem(Material.DIAMOND, "&cTest"));
|
||||
EnumSetting<Material> setting = new EnumSetting<>(item, "test", Material.class, Material.DIAMOND);
|
||||
Assertions.assertArrayEquals(Material.values(), setting.getAllowedValues());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Test illegal values")
|
||||
void testIllegalValues() {
|
||||
EnumSetting<Material> setting = new EnumSetting<>("test", Material.class, Material.DIAMOND);
|
||||
|
||||
SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "ENUM_SETTING_TEST", new CustomItem(Material.DIAMOND, "&cTest"));
|
||||
EnumSetting<Material> setting = new EnumSetting<>(item, "test", Material.class, Material.DIAMOND);
|
||||
|
||||
item.addItemSetting(setting);
|
||||
item.register(plugin);
|
||||
|
||||
@ -52,9 +53,9 @@ class TestEnumSetting {
|
||||
@Test
|
||||
@DisplayName("Test allowed value")
|
||||
void testAllowedValue() {
|
||||
EnumSetting<Material> setting = new EnumSetting<>("test", Material.class, Material.DIAMOND);
|
||||
|
||||
SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MATERIAL_SETTING_TEST_2", new CustomItem(Material.DIAMOND, "&cTest"));
|
||||
EnumSetting<Material> setting = new EnumSetting<>(item, "test", Material.class, Material.DIAMOND);
|
||||
|
||||
item.addItemSetting(setting);
|
||||
item.register(plugin);
|
||||
|
||||
|
@ -34,13 +34,15 @@ class TestIntRangeSetting {
|
||||
@Test
|
||||
@DisplayName("Test Constructor validation")
|
||||
void testConstructorValidation() {
|
||||
Assertions.assertThrows(IllegalArgumentException.class, () -> new IntRangeSetting("test", min, -50, max));
|
||||
SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "INT_RANGE_TEST_00", new CustomItem(Material.DIAMOND, "&cTest"));
|
||||
Assertions.assertThrows(IllegalArgumentException.class, () -> new IntRangeSetting(item, "test", min, -50, max));
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Test min and max getters")
|
||||
void testMinMaxGetters() {
|
||||
IntRangeSetting setting = new IntRangeSetting("test", min, 1, max);
|
||||
SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "INT_RANGE_TEST_0", new CustomItem(Material.DIAMOND, "&cTest"));
|
||||
IntRangeSetting setting = new IntRangeSetting(item, "test", min, 1, max);
|
||||
|
||||
Assertions.assertEquals(min, setting.getMinimum());
|
||||
Assertions.assertEquals(max, setting.getMaximum());
|
||||
@ -49,9 +51,9 @@ class TestIntRangeSetting {
|
||||
@Test
|
||||
@DisplayName("Test illegal values")
|
||||
void testIllegalValues() {
|
||||
IntRangeSetting setting = new IntRangeSetting("test", min, 1, max);
|
||||
|
||||
SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "INT_RANGE_TEST", new CustomItem(Material.DIAMOND, "&cTest"));
|
||||
IntRangeSetting setting = new IntRangeSetting(item, "test", min, 1, max);
|
||||
|
||||
item.addItemSetting(setting);
|
||||
item.register(plugin);
|
||||
|
||||
@ -63,9 +65,9 @@ class TestIntRangeSetting {
|
||||
@Test
|
||||
@DisplayName("Test allowed value")
|
||||
void testAllowedValue() {
|
||||
IntRangeSetting setting = new IntRangeSetting("test", min, 1, max);
|
||||
|
||||
SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "INT_RANGE_TEST_2", new CustomItem(Material.DIAMOND, "&cTest"));
|
||||
IntRangeSetting setting = new IntRangeSetting(item, "test", min, 1, max);
|
||||
|
||||
item.addItemSetting(setting);
|
||||
item.register(plugin);
|
||||
|
||||
|
@ -37,17 +37,17 @@ class TestItemSettings {
|
||||
SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "ITEM_SETTINGS_TEST", new CustomItem(Material.DIAMOND, "&cTest"));
|
||||
item.register(plugin);
|
||||
|
||||
Assertions.assertThrows(IllegalArgumentException.class, () -> new ItemSetting<>("prematureInvocation", "Hello world").getValue());
|
||||
Assertions.assertThrows(IllegalArgumentException.class, () -> new ItemSetting<>(item, "prematureInvocation", "Hello world").getValue());
|
||||
Assertions.assertThrows(IllegalArgumentException.class, () -> item.addItemSetting());
|
||||
Assertions.assertThrows(IllegalArgumentException.class, () -> item.addItemSetting((ItemSetting<String>) null));
|
||||
Assertions.assertThrows(UnsupportedOperationException.class, () -> item.addItemSetting(new ItemSetting<>("test", "Hello World")));
|
||||
Assertions.assertThrows(UnsupportedOperationException.class, () -> item.addItemSetting(new ItemSetting<>(item, "test", "Hello World")));
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Test adding an Item Setting")
|
||||
void testAddItemSetting() {
|
||||
SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "ITEM_SETTINGS_TEST_2", new CustomItem(Material.DIAMOND, "&cTest"));
|
||||
ItemSetting<String> setting = new ItemSetting<>("test", "Hello World");
|
||||
ItemSetting<String> setting = new ItemSetting<>(item, "test", "Hello World");
|
||||
|
||||
Assertions.assertTrue(setting.isType(String.class));
|
||||
Assertions.assertFalse(setting.isType(Integer.class));
|
||||
@ -70,7 +70,7 @@ class TestItemSettings {
|
||||
@DisplayName("Test updating an Item Settings value")
|
||||
void testUpdateItemSetting() {
|
||||
SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "ITEM_SETTINGS_TEST_3", new CustomItem(Material.DIAMOND, "&cTest"));
|
||||
ItemSetting<String> setting = new ItemSetting<>("test", "Hello World");
|
||||
ItemSetting<String> setting = new ItemSetting<>(item, "test", "Hello World");
|
||||
|
||||
item.addItemSetting(setting);
|
||||
item.register(plugin);
|
||||
@ -87,7 +87,7 @@ class TestItemSettings {
|
||||
@DisplayName("Test Item Settings double-registration")
|
||||
void testAlreadyExistingItemSetting() {
|
||||
SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "ITEM_SETTINGS_TEST", new CustomItem(Material.DIAMOND, "&cTest"));
|
||||
ItemSetting<String> setting = new ItemSetting<>("test", "Hello World");
|
||||
ItemSetting<String> setting = new ItemSetting<>(item, "test", "Hello World");
|
||||
|
||||
item.addItemSetting(setting);
|
||||
Assertions.assertThrows(IllegalArgumentException.class, () -> item.addItemSetting(setting));
|
||||
|
@ -39,16 +39,17 @@ class TestMaterialTagSetting {
|
||||
@Test
|
||||
@DisplayName("Test Constructor")
|
||||
void testConstructorValidation() {
|
||||
MaterialTagSetting setting = new MaterialTagSetting("test", tag);
|
||||
SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MATERIAL_SETTING_TEST_0", new CustomItem(Material.DIAMOND, "&cTest"));
|
||||
MaterialTagSetting setting = new MaterialTagSetting(item, "test", tag);
|
||||
Assertions.assertEquals(tag, setting.getDefaultTag());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Test illegal values")
|
||||
void testIllegalValues() {
|
||||
MaterialTagSetting setting = new MaterialTagSetting("test", tag);
|
||||
|
||||
SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MATERIAL_SETTING_TEST", new CustomItem(Material.DIAMOND, "&cTest"));
|
||||
MaterialTagSetting setting = new MaterialTagSetting(item, "test", tag);
|
||||
|
||||
item.addItemSetting(setting);
|
||||
item.register(plugin);
|
||||
|
||||
@ -60,9 +61,9 @@ class TestMaterialTagSetting {
|
||||
@Test
|
||||
@DisplayName("Test allowed value")
|
||||
void testAllowedValue() {
|
||||
MaterialTagSetting setting = new MaterialTagSetting("test", tag);
|
||||
|
||||
SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MATERIAL_SETTING_TEST_2", new CustomItem(Material.DIAMOND, "&cTest"));
|
||||
MaterialTagSetting setting = new MaterialTagSetting(item, "test", tag);
|
||||
|
||||
item.addItemSetting(setting);
|
||||
item.register(plugin);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user