1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-19 19:25:48 +00:00

Some additional cleanup

This commit is contained in:
TheBusyBiscuit 2021-09-03 14:01:55 +02:00
parent 9451e256e5
commit 6951251394
28 changed files with 147 additions and 148 deletions

View File

@ -72,6 +72,7 @@ This RC brings a lot of breaking changes to the API. For more info on why we did
* Fixed #3225 * Fixed #3225
* Fixed #3206 * Fixed #3206
* Fixed androids not respecting Worldborders * Fixed androids not respecting Worldborders
* Fixed Ender Lumps showing an incorrect recipe in the guide
## Release Candidate 26 (20 Jul 2021) ## Release Candidate 26 (20 Jul 2021)
https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#26 https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#26

View File

@ -27,7 +27,8 @@ import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
/** /**
* Represents a category, which structure multiple {@link SlimefunItem} in the {@link SlimefunGuide}. * Represents an item group, which structure
* multiple {@link SlimefunItem} in the {@link SlimefunGuide}.
* *
* @author TheBusyBiscuit * @author TheBusyBiscuit
* *
@ -74,8 +75,8 @@ public class ItemGroup implements Keyed {
*/ */
@ParametersAreNonnullByDefault @ParametersAreNonnullByDefault
public ItemGroup(NamespacedKey key, ItemStack item, int tier) { public ItemGroup(NamespacedKey key, ItemStack item, int tier) {
Validate.notNull(key, "A Category's NamespacedKey must not be null!"); Validate.notNull(key, "An item group's NamespacedKey must not be null!");
Validate.notNull(item, "A Category's ItemStack must not be null!"); Validate.notNull(item, "An item group's ItemStack must not be null!");
this.item = item; this.item = item;
this.key = key; this.key = key;
@ -95,9 +96,10 @@ public class ItemGroup implements Keyed {
} }
/** /**
* Registers this category. * Registers this {@link ItemGroup}.
* <p> * <p>
* By default, a category is automatically registered when a {@link SlimefunItem} was added to it. * By default, an {@link ItemGroup} is automatically registered when
* a {@link SlimefunItem} was added to it.
* *
* @param addon * @param addon
* The {@link SlimefunAddon} that wants to register this {@link ItemGroup} * The {@link SlimefunAddon} that wants to register this {@link ItemGroup}
@ -106,7 +108,7 @@ public class ItemGroup implements Keyed {
Validate.notNull(addon, "The Addon cannot be null"); Validate.notNull(addon, "The Addon cannot be null");
if (isRegistered()) { if (isRegistered()) {
throw new UnsupportedOperationException("This Category has already been registered!"); throw new UnsupportedOperationException("This ItemGroup has already been registered!");
} }
this.addon = addon; this.addon = addon;
@ -135,7 +137,7 @@ public class ItemGroup implements Keyed {
public void setTier(int tier) { public void setTier(int tier) {
this.tier = tier; this.tier = tier;
// Refresh Category order if already registered. // Refresh ItemGroup order if already registered.
if (isRegistered()) { if (isRegistered()) {
sortCategoriesByTier(); sortCategoriesByTier();
} }
@ -167,7 +169,7 @@ public class ItemGroup implements Keyed {
* the {@link SlimefunItem} that should be added to this {@link ItemGroup} * the {@link SlimefunItem} that should be added to this {@link ItemGroup}
*/ */
public void add(@Nonnull SlimefunItem item) { public void add(@Nonnull SlimefunItem item) {
Validate.notNull(item, "Cannot add null Items to a Category!"); Validate.notNull(item, "Cannot add null Items to an ItemGroup!");
if (items.contains(item)) { if (items.contains(item)) {
// Ignore duplicate entries // Ignore duplicate entries
@ -184,7 +186,7 @@ public class ItemGroup implements Keyed {
* the {@link SlimefunItem} that should be removed from this {@link ItemGroup} * the {@link SlimefunItem} that should be removed from this {@link ItemGroup}
*/ */
public void remove(@Nonnull SlimefunItem item) { public void remove(@Nonnull SlimefunItem item) {
Validate.notNull(item, "Cannot remove null from a Category!"); Validate.notNull(item, "Cannot remove null from an ItemGroup!");
items.remove(item); items.remove(item);
} }
@ -250,7 +252,7 @@ public class ItemGroup implements Keyed {
/** /**
* Returns all instances of {@link SlimefunItem} bound to this {@link ItemGroup}. * Returns all instances of {@link SlimefunItem} bound to this {@link ItemGroup}.
* *
* @return the list of SlimefunItems bound to this category * @return the list of SlimefunItems bound to this {@link ItemGroup}
*/ */
@Nonnull @Nonnull
public List<SlimefunItem> getItems() { public List<SlimefunItem> getItems() {

View File

@ -21,7 +21,7 @@ import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
/** /**
* Represents a {@link ItemGroup} that cannot be opened until the parent category/categories * Represents a {@link ItemGroup} that cannot be opened until the parent group(s)
* are fully unlocked. * are fully unlocked.
* <p> * <p>
* See {@link ItemGroup} for the complete documentation. * See {@link ItemGroup} for the complete documentation.
@ -38,15 +38,15 @@ public class LockedItemGroup extends ItemGroup {
private final Set<ItemGroup> parents = new HashSet<>(); private final Set<ItemGroup> parents = new HashSet<>();
/** /**
* The basic constructor for a LockedCategory. * The basic constructor for a LockedItemGroup.
* Like {@link ItemGroup}, the default tier is automatically set to 3. * Like {@link ItemGroup}, the default tier is automatically set to 3.
* *
* @param key * @param key
* A unique identifier for this category * A unique identifier for this group
* @param item * @param item
* The display item for this category * The display item for this group
* @param parents * @param parents
* The parent categories for this category * The parent categories for this group
* *
*/ */
@ParametersAreNonnullByDefault @ParametersAreNonnullByDefault
@ -55,22 +55,22 @@ public class LockedItemGroup extends ItemGroup {
} }
/** /**
* The constructor for a LockedCategory. * The constructor for a LockedItemGroup.
* *
* @param key * @param key
* A unique identifier for this category * A unique identifier for this group
* @param item * @param item
* The display item for this category * The display item for this group
* @param tier * @param tier
* The tier of this category * The tier of this group
* @param parents * @param parents
* The parent categories for this category * The parent categories for this group
* *
*/ */
@ParametersAreNonnullByDefault @ParametersAreNonnullByDefault
public LockedItemGroup(NamespacedKey key, ItemStack item, int tier, NamespacedKey... parents) { public LockedItemGroup(NamespacedKey key, ItemStack item, int tier, NamespacedKey... parents) {
super(key, item, tier); super(key, item, tier);
Validate.noNullElements(parents, "A LockedCategory must not have any 'null' parents!"); Validate.noNullElements(parents, "A LockedItemGroup must not have any 'null' parents!");
this.keys = parents; this.keys = parents;
} }
@ -94,51 +94,50 @@ public class LockedItemGroup extends ItemGroup {
} }
for (NamespacedKey key : namespacedKeys) { for (NamespacedKey key : namespacedKeys) {
Slimefun.logger().log(Level.INFO, "Parent \"{0}\" for Category \"{1}\" was not found, probably just disabled.", new Object[] { key, getKey() }); Slimefun.logger().log(Level.INFO, "Parent \"{0}\" for LockedItemGroup \"{1}\" was not found, probably just disabled.", new Object[] { key, getKey() });
} }
} }
/** /**
* Gets the list of parent categories for this {@link LockedItemGroup}. * Gets the list of parent item groups for this {@link LockedItemGroup}.
* *
* @return the list of parent categories * @return the list of parent item groups
* *
* @see #addParent(ItemGroup) * @see #addParent(ItemGroup)
* @see #removeParent(ItemGroup) * @see #removeParent(ItemGroup)
*/ */
@Nonnull public @Nonnull Set<ItemGroup> getParents() {
public Set<ItemGroup> getParents() {
return parents; return parents;
} }
/** /**
* Adds a parent {@link ItemGroup} to this {@link LockedItemGroup}. * Adds a parent {@link ItemGroup} to this {@link LockedItemGroup}.
* *
* @param category * @param group
* The {@link ItemGroup} to add as a parent * The {@link ItemGroup} to add as a parent
* *
* @see #getParents() * @see #getParents()
* @see #removeParent(ItemGroup) * @see #removeParent(ItemGroup)
*/ */
public void addParent(ItemGroup category) { public void addParent(ItemGroup group) {
if (category == this || category == null) { if (group == this || group == null) {
throw new IllegalArgumentException("Category '" + item.getItemMeta().getDisplayName() + "' cannot be a parent of itself or have a 'null' parent."); throw new IllegalArgumentException("ItemGroup '" + item.getItemMeta().getDisplayName() + "' cannot be a parent of itself or have a 'null' parent.");
} }
parents.add(category); parents.add(group);
} }
/** /**
* Removes a {@link ItemGroup} from the parents of this {@link LockedItemGroup}. * Removes a {@link ItemGroup} from the parents of this {@link LockedItemGroup}.
* *
* @param category * @param group
* The {@link ItemGroup} to remove from the parents of this {@link LockedItemGroup} * The {@link ItemGroup} to remove from the parents of this {@link LockedItemGroup}
* *
* @see #getParents() * @see #getParents()
* @see #addParent(ItemGroup) * @see #addParent(ItemGroup)
*/ */
public void removeParent(@Nonnull ItemGroup category) { public void removeParent(@Nonnull ItemGroup group) {
parents.remove(category); parents.remove(group);
} }
/** /**
@ -155,8 +154,8 @@ public class LockedItemGroup extends ItemGroup {
Validate.notNull(p, "The player cannot be null!"); Validate.notNull(p, "The player cannot be null!");
Validate.notNull(profile, "The Profile cannot be null!"); Validate.notNull(profile, "The Profile cannot be null!");
for (ItemGroup category : parents) { for (ItemGroup parent : parents) {
for (SlimefunItem item : category.getItems()) { for (SlimefunItem item : parent.getItems()) {
// Check if the Player has researched every item (if the item is enabled) // Check if the Player has researched every item (if the item is enabled)
if (!item.isDisabledIn(p.getWorld()) && item.hasResearch() && !profile.hasUnlocked(item.getResearch())) { if (!item.isDisabledIn(p.getWorld()) && item.hasResearch() && !profile.hasUnlocked(item.getResearch())) {
return false; return false;

View File

@ -41,25 +41,25 @@ public class NestedItemGroup extends FlexItemGroup {
/** /**
* This will add the given {@link SubItemGroup} to this {@link NestedItemGroup}. * This will add the given {@link SubItemGroup} to this {@link NestedItemGroup}.
* *
* @param category * @param group
* The {@link SubItemGroup} to add. * The {@link SubItemGroup} to add.
*/ */
public void addSubGroup(@Nonnull SubItemGroup category) { public void addSubGroup(@Nonnull SubItemGroup group) {
Validate.notNull(category, "The sub item group cannot be null!"); Validate.notNull(group, "The sub item group cannot be null!");
subGroups.add(category); subGroups.add(group);
} }
/** /**
* This will remove the given {@link SubItemGroup} from this {@link NestedItemGroup} (if present). * This will remove the given {@link SubItemGroup} from this {@link NestedItemGroup} (if present).
* *
* @param category * @param group
* The {@link SubItemGroup} to remove. * The {@link SubItemGroup} to remove.
*/ */
public void removeSubGroup(@Nonnull SubItemGroup category) { public void removeSubGroup(@Nonnull SubItemGroup group) {
Validate.notNull(category, "The sub item group cannot be null!"); Validate.notNull(group, "The sub item group cannot be null!");
subGroups.remove(category); subGroups.remove(group);
} }
@Override @Override

View File

@ -32,11 +32,11 @@ public class SeasonalItemGroup extends ItemGroup {
* @param key * @param key
* The {@link NamespacedKey} that is used to identify this {@link ItemGroup} * The {@link NamespacedKey} that is used to identify this {@link ItemGroup}
* @param month * @param month
* The month when the category should be displayed (from 1 = January ; to 12 = December) * The month when the {@link ItemGroup} should be displayed (from 1 = January ; to 12 = December)
* @param tier * @param tier
* The tier of this category * The tier of this {@link ItemGroup}
* @param item * @param item
* The display item for this category * The display item for this {@link ItemGroup}
*/ */
@ParametersAreNonnullByDefault @ParametersAreNonnullByDefault
public SeasonalItemGroup(NamespacedKey key, Month month, int tier, ItemStack item) { public SeasonalItemGroup(NamespacedKey key, Month month, int tier, ItemStack item) {
@ -51,8 +51,7 @@ public class SeasonalItemGroup extends ItemGroup {
* *
* @return the {@link Month} in which this {@link SeasonalItemGroup} appears * @return the {@link Month} in which this {@link SeasonalItemGroup} appears
*/ */
@Nonnull public @Nonnull Month getMonth() {
public Month getMonth() {
return month; return month;
} }

View File

@ -22,7 +22,7 @@ import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
*/ */
public class SubItemGroup extends ItemGroup { public class SubItemGroup extends ItemGroup {
private final NestedItemGroup multiCategory; private final NestedItemGroup parentItemGroup;
@ParametersAreNonnullByDefault @ParametersAreNonnullByDefault
public SubItemGroup(NamespacedKey key, NestedItemGroup parent, ItemStack item) { public SubItemGroup(NamespacedKey key, NestedItemGroup parent, ItemStack item) {
@ -33,9 +33,9 @@ public class SubItemGroup extends ItemGroup {
public SubItemGroup(NamespacedKey key, NestedItemGroup parent, ItemStack item, int tier) { public SubItemGroup(NamespacedKey key, NestedItemGroup parent, ItemStack item, int tier) {
super(key, item, tier); super(key, item, tier);
Validate.notNull(parent, "The parent category cannot be null"); Validate.notNull(parent, "The parent group cannot be null");
multiCategory = parent; parentItemGroup = parent;
parent.addSubGroup(this); parent.addSubGroup(this);
} }
@ -48,17 +48,16 @@ public class SubItemGroup extends ItemGroup {
return true; return true;
} }
@Nonnull public final @Nonnull NestedItemGroup getParent() {
public final NestedItemGroup getParent() { return parentItemGroup;
return multiCategory;
} }
@Override @Override
public final void register(@Nonnull SlimefunAddon addon) { public final void register(@Nonnull SlimefunAddon addon) {
super.register(addon); super.register(addon);
if (!multiCategory.isRegistered()) { if (!parentItemGroup.isRegistered()) {
multiCategory.register(addon); parentItemGroup.register(addon);
} }
} }

View File

@ -76,7 +76,7 @@ public class Research implements Keyed {
} }
@Override @Override
public NamespacedKey getKey() { public @Nonnull NamespacedKey getKey() {
return key; return key;
} }
@ -114,8 +114,7 @@ public class Research implements Keyed {
* *
* @return The localized Name of this {@link Research}. * @return The localized Name of this {@link Research}.
*/ */
@Nonnull public @Nonnull String getName(@Nonnull Player p) {
public String getName(@Nonnull Player p) {
String localized = Slimefun.getLocalization().getResearchName(p, key); String localized = Slimefun.getLocalization().getResearchName(p, key);
return localized != null ? localized : name; return localized != null ? localized : name;
} }

View File

@ -2,4 +2,4 @@
* This package holds everything connected to the {@link io.github.thebusybiscuit.slimefun4.core.researching.Research} * This package holds everything connected to the {@link io.github.thebusybiscuit.slimefun4.core.researching.Research}
* class. * class.
*/ */
package io.github.thebusybiscuit.slimefun4.core.researching; package io.github.thebusybiscuit.slimefun4.api.researches;

View File

@ -66,7 +66,7 @@ import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.MenuClickHan
*/ */
public class SurvivalSlimefunGuide implements SlimefunGuideImplementation { public class SurvivalSlimefunGuide implements SlimefunGuideImplementation {
private static final int CATEGORY_SIZE = 36; private static final int MAX_ITEM_GROUPS = 36;
private static final Sound sound = Sound.ITEM_BOOK_PAGE_TURN; private static final Sound sound = Sound.ITEM_BOOK_PAGE_TURN;
private final int[] recipeSlots = { 3, 4, 5, 12, 13, 14, 21, 22, 23 }; private final int[] recipeSlots = { 3, 4, 5, 12, 13, 14, 21, 22, 23 };
@ -128,9 +128,9 @@ public class SurvivalSlimefunGuide implements SlimefunGuideImplementation {
SlimefunAddon addon = group.getAddon(); SlimefunAddon addon = group.getAddon();
if (addon != null) { if (addon != null) {
addon.getLogger().log(Level.SEVERE, x, () -> "Could not display Category: " + group); addon.getLogger().log(Level.SEVERE, x, () -> "Could not display item group: " + group);
} else { } else {
Slimefun.logger().log(Level.SEVERE, x, () -> "Could not display Category: " + group); Slimefun.logger().log(Level.SEVERE, x, () -> "Could not display item group: " + group);
} }
} }
} }
@ -153,23 +153,23 @@ public class SurvivalSlimefunGuide implements SlimefunGuideImplementation {
} }
ChestMenu menu = create(p); ChestMenu menu = create(p);
List<ItemGroup> categories = getVisibleItemGroups(p, profile); List<ItemGroup> itemGroups = getVisibleItemGroups(p, profile);
int index = 9; int index = 9;
createHeader(p, profile, menu); createHeader(p, profile, menu);
int target = (CATEGORY_SIZE * (page - 1)) - 1; int target = (MAX_ITEM_GROUPS * (page - 1)) - 1;
while (target < (categories.size() - 1) && index < CATEGORY_SIZE + 9) { while (target < (itemGroups.size() - 1) && index < MAX_ITEM_GROUPS + 9) {
target++; target++;
ItemGroup category = categories.get(target); ItemGroup group = itemGroups.get(target);
showItemGroup(menu, p, profile, category, index); showItemGroup(menu, p, profile, group, index);
index++; index++;
} }
int pages = target == categories.size() - 1 ? page : (categories.size() - 1) / CATEGORY_SIZE + 1; int pages = target == itemGroups.size() - 1 ? page : (itemGroups.size() - 1) / MAX_ITEM_GROUPS + 1;
menu.addItem(46, ChestMenuUtils.getPreviousButton(p, page, pages)); menu.addItem(46, ChestMenuUtils.getPreviousButton(p, page, pages));
menu.addMenuClickHandler(46, (pl, slot, item, action) -> { menu.addMenuClickHandler(46, (pl, slot, item, action) -> {
@ -245,7 +245,7 @@ public class SurvivalSlimefunGuide implements SlimefunGuideImplementation {
addBackButton(menu, 1, p, profile); addBackButton(menu, 1, p, profile);
int pages = (category.getItems().size() - 1) / CATEGORY_SIZE + 1; int pages = (category.getItems().size() - 1) / MAX_ITEM_GROUPS + 1;
menu.addItem(46, ChestMenuUtils.getPreviousButton(p, page, pages)); menu.addItem(46, ChestMenuUtils.getPreviousButton(p, page, pages));
menu.addMenuClickHandler(46, (pl, slot, item, action) -> { menu.addMenuClickHandler(46, (pl, slot, item, action) -> {
@ -270,9 +270,9 @@ public class SurvivalSlimefunGuide implements SlimefunGuideImplementation {
}); });
int index = 9; int index = 9;
int categoryIndex = CATEGORY_SIZE * (page - 1); int categoryIndex = MAX_ITEM_GROUPS * (page - 1);
for (int i = 0; i < CATEGORY_SIZE; i++) { for (int i = 0; i < MAX_ITEM_GROUPS; i++) {
int target = categoryIndex + i; int target = categoryIndex + i;
if (target >= category.getItems().size()) { if (target >= category.getItems().size()) {

View File

@ -40,7 +40,7 @@ class TestChargeCommand {
@Test @Test
@DisplayName("Test if /sf charge charges the item the player is holding") @DisplayName("Test if /sf charge charges the item the player is holding")
void testCommand() { void testCommand() {
ItemGroup category = TestUtilities.getCategory(plugin, "rechargeable"); ItemGroup category = TestUtilities.getItemGroup(plugin, "rechargeable");
SlimefunItemStack RECHARGEABLE_ITEM = new SlimefunItemStack("SF_CHARGE_TEST_ITEM", Material.REDSTONE_BLOCK, "Rechargeable Item", "This isn't real", LoreBuilder.powerCharged(0, 100)); SlimefunItemStack RECHARGEABLE_ITEM = new SlimefunItemStack("SF_CHARGE_TEST_ITEM", Material.REDSTONE_BLOCK, "Rechargeable Item", "This isn't real", LoreBuilder.powerCharged(0, 100));
new RechargeableMock(category, RECHARGEABLE_ITEM, RecipeType.NULL, new ItemStack[9]).register(plugin); new RechargeableMock(category, RECHARGEABLE_ITEM, RecipeType.NULL, new ItemStack[9]).register(plugin);

View File

@ -41,7 +41,7 @@ class TestDamageableItem {
} }
public static MockDamageable getDummyItem(String id, boolean damageable, @Nullable Enchantment enchantment, @Nullable Integer enchantmentLevel) { public static MockDamageable getDummyItem(String id, boolean damageable, @Nullable Enchantment enchantment, @Nullable Integer enchantmentLevel) {
ItemGroup category = TestUtilities.getCategory(plugin, "damageable_item_test"); ItemGroup category = TestUtilities.getItemGroup(plugin, "damageable_item_test");
SlimefunItemStack stack = new SlimefunItemStack("DAMAGEABLE_PICKAXE_" + id, Material.DIAMOND_PICKAXE, "&4This pickaxe can break", "&6It appears, it breaks, but most importantly, it tests."); SlimefunItemStack stack = new SlimefunItemStack("DAMAGEABLE_PICKAXE_" + id, Material.DIAMOND_PICKAXE, "&4This pickaxe can break", "&6It appears, it breaks, but most importantly, it tests.");
if (enchantment != null && enchantmentLevel != null) { if (enchantment != null && enchantmentLevel != null) {
ItemMeta im = stack.getItemMeta(); ItemMeta im = stack.getItemMeta();

View File

@ -37,7 +37,7 @@ class TestRadioactiveItem {
@EnumSource(value = Radioactivity.class) @EnumSource(value = Radioactivity.class)
@DisplayName("Test radioactive items being radioactive") @DisplayName("Test radioactive items being radioactive")
void testWikiPages(Radioactivity radioactivity) { void testWikiPages(Radioactivity radioactivity) {
ItemGroup category = TestUtilities.getCategory(plugin, "radioactivity_test"); ItemGroup category = TestUtilities.getItemGroup(plugin, "radioactivity_test");
SlimefunItemStack stack = new SlimefunItemStack("RADIOACTIVE_" + radioactivity.name(), Material.EMERALD, "&4Radioactive!!!", "Imagine dragons"); SlimefunItemStack stack = new SlimefunItemStack("RADIOACTIVE_" + radioactivity.name(), Material.EMERALD, "&4Radioactive!!!", "Imagine dragons");
RadioactiveItem item = new RadioactiveItem(category, radioactivity, stack, RecipeType.NULL, new ItemStack[9]); RadioactiveItem item = new RadioactiveItem(category, radioactivity, stack, RecipeType.NULL, new ItemStack[9]);

View File

@ -203,7 +203,7 @@ class TestAutoCrafter {
@Nonnull @Nonnull
private AbstractAutoCrafter getVanillaAutoCrafter() { private AbstractAutoCrafter getVanillaAutoCrafter() {
SlimefunItemStack item = new SlimefunItemStack("MOCK_AUTO_CRAFTER", Material.CRAFTING_TABLE, "Mock Auto Crafter"); SlimefunItemStack item = new SlimefunItemStack("MOCK_AUTO_CRAFTER", Material.CRAFTING_TABLE, "Mock Auto Crafter");
return new VanillaAutoCrafter(TestUtilities.getCategory(plugin, "auto_crafter"), item, RecipeType.NULL, new ItemStack[9]); return new VanillaAutoCrafter(TestUtilities.getItemGroup(plugin, "auto_crafter"), item, RecipeType.NULL, new ItemStack[9]);
} }
} }

View File

@ -37,7 +37,7 @@ class TestEnderBackpack implements SlimefunItemTest<EnderBackpack> {
@Override @Override
public EnderBackpack registerSlimefunItem(Slimefun plugin, String id) { public EnderBackpack registerSlimefunItem(Slimefun plugin, String id) {
SlimefunItemStack item = new SlimefunItemStack(id, Material.ENDER_CHEST, "&5Test Ender Backpack"); SlimefunItemStack item = new SlimefunItemStack(id, Material.ENDER_CHEST, "&5Test Ender Backpack");
EnderBackpack backpack = new EnderBackpack(TestUtilities.getCategory(plugin, "ender_backpack"), item, RecipeType.NULL, new ItemStack[9]); EnderBackpack backpack = new EnderBackpack(TestUtilities.getItemGroup(plugin, "ender_backpack"), item, RecipeType.NULL, new ItemStack[9]);
backpack.register(plugin); backpack.register(plugin);
return backpack; return backpack;
} }

View File

@ -39,7 +39,7 @@ class TestDietCookie implements SlimefunItemTest<DietCookie> {
@Override @Override
public DietCookie registerSlimefunItem(Slimefun plugin, String id) { public DietCookie registerSlimefunItem(Slimefun plugin, String id) {
SlimefunItemStack item = new SlimefunItemStack(id, Material.COOKIE, "&5Test Cookie"); SlimefunItemStack item = new SlimefunItemStack(id, Material.COOKIE, "&5Test Cookie");
DietCookie cookie = new DietCookie(TestUtilities.getCategory(plugin, "diet_cookie"), item, RecipeType.NULL, new ItemStack[9]); DietCookie cookie = new DietCookie(TestUtilities.getItemGroup(plugin, "diet_cookie"), item, RecipeType.NULL, new ItemStack[9]);
cookie.register(plugin); cookie.register(plugin);
return cookie; return cookie;
} }

View File

@ -37,7 +37,7 @@ class TestMeatJerky implements SlimefunItemTest<MeatJerky> {
@Override @Override
public MeatJerky registerSlimefunItem(Slimefun plugin, String id) { public MeatJerky registerSlimefunItem(Slimefun plugin, String id) {
SlimefunItemStack item = new SlimefunItemStack(id, Material.COOKED_BEEF, "&5Test Jerky"); SlimefunItemStack item = new SlimefunItemStack(id, Material.COOKED_BEEF, "&5Test Jerky");
MeatJerky meat = new MeatJerky(TestUtilities.getCategory(plugin, "test_jerky"), item, RecipeType.NULL, new ItemStack[9]); MeatJerky meat = new MeatJerky(TestUtilities.getItemGroup(plugin, "test_jerky"), item, RecipeType.NULL, new ItemStack[9]);
meat.register(plugin); meat.register(plugin);
return meat; return meat;
} }

View File

@ -38,7 +38,7 @@ class TestMonsterJerky implements SlimefunItemTest<MonsterJerky> {
@Override @Override
public MonsterJerky registerSlimefunItem(Slimefun plugin, String id) { public MonsterJerky registerSlimefunItem(Slimefun plugin, String id) {
SlimefunItemStack item = new SlimefunItemStack(id, Material.ROTTEN_FLESH, "&5Test Monster Jerky"); SlimefunItemStack item = new SlimefunItemStack(id, Material.ROTTEN_FLESH, "&5Test Monster Jerky");
MonsterJerky jerky = new MonsterJerky(TestUtilities.getCategory(plugin, "monster_jerky"), item, RecipeType.NULL, new ItemStack[9]); MonsterJerky jerky = new MonsterJerky(TestUtilities.getItemGroup(plugin, "monster_jerky"), item, RecipeType.NULL, new ItemStack[9]);
jerky.register(plugin); jerky.register(plugin);
return jerky; return jerky;
} }

View File

@ -55,7 +55,7 @@ class TestClimbingPick implements SlimefunItemTest<ClimbingPick> {
@Override @Override
public ClimbingPick registerSlimefunItem(Slimefun plugin, String id) { public ClimbingPick registerSlimefunItem(Slimefun plugin, String id) {
SlimefunItemStack item = new SlimefunItemStack(id, Material.IRON_PICKAXE, "&5Test Pick", id); SlimefunItemStack item = new SlimefunItemStack(id, Material.IRON_PICKAXE, "&5Test Pick", id);
ClimbingPick pick = new ClimbingPick(TestUtilities.getCategory(plugin, "climbing_pick"), item, RecipeType.NULL, new ItemStack[9]) { ClimbingPick pick = new ClimbingPick(TestUtilities.getItemGroup(plugin, "climbing_pick"), item, RecipeType.NULL, new ItemStack[9]) {
@Override @Override
public boolean isDualWieldingEnabled() { public boolean isDualWieldingEnabled() {

View File

@ -38,7 +38,7 @@ class TestPortableDustbin implements SlimefunItemTest<PortableDustbin> {
@Override @Override
public PortableDustbin registerSlimefunItem(Slimefun plugin, String id) { public PortableDustbin registerSlimefunItem(Slimefun plugin, String id) {
SlimefunItemStack item = new SlimefunItemStack(id, Material.BUCKET, "&4Test Dustbin"); SlimefunItemStack item = new SlimefunItemStack(id, Material.BUCKET, "&4Test Dustbin");
PortableDustbin dustbin = new PortableDustbin(TestUtilities.getCategory(plugin, "dustbin"), item, RecipeType.NULL, new ItemStack[9]); PortableDustbin dustbin = new PortableDustbin(TestUtilities.getItemGroup(plugin, "dustbin"), item, RecipeType.NULL, new ItemStack[9]);
dustbin.register(plugin); dustbin.register(plugin);
return dustbin; return dustbin;
} }

View File

@ -46,7 +46,7 @@ class TestTapeMeasure implements SlimefunItemTest<TapeMeasure> {
@Override @Override
public TapeMeasure registerSlimefunItem(Slimefun plugin, String id) { public TapeMeasure registerSlimefunItem(Slimefun plugin, String id) {
SlimefunItemStack item = new SlimefunItemStack(id, Material.PLAYER_HEAD, "&5Test Pick", id); SlimefunItemStack item = new SlimefunItemStack(id, Material.PLAYER_HEAD, "&5Test Pick", id);
TapeMeasure tapeMeasure = new TapeMeasure(TestUtilities.getCategory(plugin, "tape_measure"), item, RecipeType.NULL, new ItemStack[9]); TapeMeasure tapeMeasure = new TapeMeasure(TestUtilities.getItemGroup(plugin, "tape_measure"), item, RecipeType.NULL, new ItemStack[9]);
tapeMeasure.register(plugin); tapeMeasure.register(plugin);
return tapeMeasure; return tapeMeasure;
} }

View File

@ -49,7 +49,7 @@ class TestBeeListener {
PlayerProfile profile = TestUtilities.awaitProfile(player); PlayerProfile profile = TestUtilities.awaitProfile(player);
if (hasArmor) { if (hasArmor) {
ItemGroup category = TestUtilities.getCategory(plugin, "bee_suit_test"); ItemGroup category = TestUtilities.getItemGroup(plugin, "bee_suit_test");
SlimefunItemStack chestplate = new SlimefunItemStack("MOCK_BEE_SUIT", Material.LEATHER_CHESTPLATE, "&cBee Suit Prototype"); SlimefunItemStack chestplate = new SlimefunItemStack("MOCK_BEE_SUIT", Material.LEATHER_CHESTPLATE, "&cBee Suit Prototype");
MockBeeProtectionSuit armor = new MockBeeProtectionSuit(category, chestplate); MockBeeProtectionSuit armor = new MockBeeProtectionSuit(category, chestplate);
armor.register(plugin); armor.register(plugin);

View File

@ -67,7 +67,7 @@ class TestCargoNodeListener {
Block b = l.getBlock(); Block b = l.getBlock();
Block against = b.getRelative(BlockFace.DOWN); Block against = b.getRelative(BlockFace.DOWN);
ItemGroup category = TestUtilities.getCategory(plugin, "cargo_test"); ItemGroup category = TestUtilities.getItemGroup(plugin, "cargo_test");
SlimefunItemStack item = new SlimefunItemStack("MOCK_CARGO_NODE", new CustomItemStack(Material.PLAYER_HEAD, "&4Cargo node!")); SlimefunItemStack item = new SlimefunItemStack("MOCK_CARGO_NODE", new CustomItemStack(Material.PLAYER_HEAD, "&4Cargo node!"));
CargoInputNode node = new CargoInputNode(category, item, RecipeType.NULL, new ItemStack[9], null); CargoInputNode node = new CargoInputNode(category, item, RecipeType.NULL, new ItemStack[9], null);
node.register(plugin); node.register(plugin);
@ -86,7 +86,7 @@ class TestCargoNodeListener {
Block b = l.getBlock(); Block b = l.getBlock();
b.setType(Material.GRASS); b.setType(Material.GRASS);
ItemGroup category = TestUtilities.getCategory(plugin, "cargo_test"); ItemGroup category = TestUtilities.getItemGroup(plugin, "cargo_test");
SlimefunItemStack item = new SlimefunItemStack("MOCK_CARGO_NODE_2", new CustomItemStack(Material.PLAYER_HEAD, "&4Cargo node!")); SlimefunItemStack item = new SlimefunItemStack("MOCK_CARGO_NODE_2", new CustomItemStack(Material.PLAYER_HEAD, "&4Cargo node!"));
CargoInputNode node = new CargoInputNode(category, item, RecipeType.NULL, new ItemStack[9], null); CargoInputNode node = new CargoInputNode(category, item, RecipeType.NULL, new ItemStack[9], null);
node.register(plugin); node.register(plugin);

View File

@ -61,7 +61,7 @@ class TestSoulboundListener {
PlayerMock player = server.addPlayer(); PlayerMock player = server.addPlayer();
SlimefunItemStack item = new SlimefunItemStack("SOULBOUND_ITEM_" + (enabled ? "ENABLED" : "DISABLED"), Material.DIAMOND_SWORD, "&5Soulbound Sword"); SlimefunItemStack item = new SlimefunItemStack("SOULBOUND_ITEM_" + (enabled ? "ENABLED" : "DISABLED"), Material.DIAMOND_SWORD, "&5Soulbound Sword");
SoulboundItem soulboundItem = new SoulboundItem(TestUtilities.getCategory(plugin, "soulbound"), item, RecipeType.NULL, new ItemStack[9]); SoulboundItem soulboundItem = new SoulboundItem(TestUtilities.getItemGroup(plugin, "soulbound"), item, RecipeType.NULL, new ItemStack[9]);
soulboundItem.register(plugin); soulboundItem.register(plugin);
if (!enabled) { if (!enabled) {

View File

@ -86,7 +86,7 @@ class TestVillagerTradingListener {
@Test @Test
void testTradingWithSyntheticEmerald() { void testTradingWithSyntheticEmerald() {
ItemGroup category = TestUtilities.getCategory(plugin, "shiny_emeralds"); ItemGroup category = TestUtilities.getItemGroup(plugin, "shiny_emeralds");
SlimefunItemStack stack = new SlimefunItemStack("FAKE_EMERALD", Material.EMERALD, "&aTrade me"); SlimefunItemStack stack = new SlimefunItemStack("FAKE_EMERALD", Material.EMERALD, "&aTrade me");
SyntheticEmerald item = new SyntheticEmerald(category, stack, RecipeType.ENHANCED_CRAFTING_TABLE, new ItemStack[9]); SyntheticEmerald item = new SyntheticEmerald(category, stack, RecipeType.ENHANCED_CRAFTING_TABLE, new ItemStack[9]);
item.register(plugin); item.register(plugin);

View File

@ -30,7 +30,7 @@ import io.github.thebusybiscuit.slimefun4.test.TestUtilities;
import be.seeseemelk.mockbukkit.MockBukkit; import be.seeseemelk.mockbukkit.MockBukkit;
import be.seeseemelk.mockbukkit.ServerMock; import be.seeseemelk.mockbukkit.ServerMock;
class TestCategories { class TestItemGroups {
private static ServerMock server; private static ServerMock server;
private static Slimefun plugin; private static Slimefun plugin;
@ -47,8 +47,8 @@ class TestCategories {
} }
@Test @Test
@DisplayName("Test the Getters for Category") @DisplayName("Test the Getters for ItemGroup")
void testCategoryGetters() { void testItemGroupGetters() {
ItemGroup category = new ItemGroup(new NamespacedKey(plugin, "getter_test"), new CustomItemStack(Material.DIAMOND_AXE, "&6Testing")); ItemGroup category = new ItemGroup(new NamespacedKey(plugin, "getter_test"), new CustomItemStack(Material.DIAMOND_AXE, "&6Testing"));
Assertions.assertEquals(3, category.getTier()); Assertions.assertEquals(3, category.getTier());
@ -62,10 +62,10 @@ class TestCategories {
} }
@Test @Test
@DisplayName("Test adding an item to a Category") @DisplayName("Test adding an item to a ItemGroup")
void testAddItem() { void testAddItem() {
ItemGroup category = new ItemGroup(new NamespacedKey(plugin, "items_test"), new CustomItemStack(Material.DIAMOND_AXE, "&6Testing")); ItemGroup category = new ItemGroup(new NamespacedKey(plugin, "items_test"), new CustomItemStack(Material.DIAMOND_AXE, "&6Testing"));
SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "CATEGORY_ITEMS_TEST_ITEM", new CustomItemStack(Material.BAMBOO, "&6Test Bamboo")); SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "ITEM_GROUPS_TEST_ITEM", new CustomItemStack(Material.BAMBOO, "&6Test Bamboo"));
item.setItemGroup(category); item.setItemGroup(category);
item.register(plugin); item.register(plugin);
item.load(); item.load();
@ -81,96 +81,96 @@ class TestCategories {
} }
@Test @Test
@DisplayName("Test hidden Categories") @DisplayName("Test hidden Item Groups")
void testHidden() { void testHidden() {
ItemGroup category = new ItemGroup(new NamespacedKey(plugin, "hiddenCategory"), new ItemStack(Material.BEACON)); ItemGroup group = new ItemGroup(new NamespacedKey(plugin, "hiddenItemGroup"), new ItemStack(Material.BEACON));
Player player = server.addPlayer(); Player player = server.addPlayer();
// Empty Categories are also hidden // Empty Item Groups are also hidden
Assertions.assertTrue(category.isHidden(player)); Assertions.assertTrue(group.isHidden(player));
SlimefunItem disabledItem = TestUtilities.mockSlimefunItem(plugin, "DISABLED_CATEGORY_ITEM", new CustomItemStack(Material.BEETROOT, "&4Disabled")); SlimefunItem disabledItem = TestUtilities.mockSlimefunItem(plugin, "DISABLED_ITEM_GROUP_ITEM", new CustomItemStack(Material.BEETROOT, "&4Disabled"));
Slimefun.getItemCfg().setValue("DISABLED_CATEGORY_ITEM.enabled", false); Slimefun.getItemCfg().setValue("DISABLED_ITEM_GROUP_ITEM.enabled", false);
disabledItem.setItemGroup(category); disabledItem.setItemGroup(group);
disabledItem.register(plugin); disabledItem.register(plugin);
disabledItem.load(); disabledItem.load();
// A disabled Item should also make the Category hide // A disabled Item should also make the ItemGroup hide
Assertions.assertTrue(category.isHidden(player)); Assertions.assertTrue(group.isHidden(player));
SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "CATEGORY_HIDDEN_TEST", new CustomItemStack(Material.BAMBOO, "&6Test Bamboo")); SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "ITEM_GROUP_HIDDEN_TEST", new CustomItemStack(Material.BAMBOO, "&6Test Bamboo"));
item.setItemGroup(category); item.setItemGroup(group);
item.setHidden(true); item.setHidden(true);
item.register(plugin); item.register(plugin);
item.load(); item.load();
// A hidden Item should also make the Category hide // A hidden Item should also make the ItemGroup hide
Assertions.assertTrue(category.isHidden(player)); Assertions.assertTrue(group.isHidden(player));
item.setHidden(false); item.setHidden(false);
Assertions.assertFalse(category.isHidden(player)); Assertions.assertFalse(group.isHidden(player));
} }
@Test @Test
@DisplayName("Test Category#contains") @DisplayName("Test ItemGroup#contains")
void testContains() { void testContains() {
SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "CATEGORY_TEST_ITEM_2", new CustomItemStack(Material.BOW, "&6Test Bow")); SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "ITEM_GROUP_TEST_ITEM_2", new CustomItemStack(Material.BOW, "&6Test Bow"));
item.register(plugin); item.register(plugin);
item.load(); item.load();
ItemGroup category = item.getItemGroup(); ItemGroup group = item.getItemGroup();
Assertions.assertTrue(category.contains(item)); Assertions.assertTrue(group.contains(item));
Assertions.assertFalse(category.contains(null)); Assertions.assertFalse(group.contains(null));
// Unregistered Item // Unregistered Item
Assertions.assertFalse(category.contains(TestUtilities.mockSlimefunItem(plugin, "NULL", new ItemStack(Material.BEDROCK)))); Assertions.assertFalse(group.contains(TestUtilities.mockSlimefunItem(plugin, "NULL", new ItemStack(Material.BEDROCK))));
} }
@Test @Test
@DisplayName("Test LockedCategory parental locking") @DisplayName("Test LockedItemGroup parental locking")
void testLockedCategoriesParents() { void testLockedItemGroupsParents() {
Assertions.assertThrows(IllegalArgumentException.class, () -> new LockedItemGroup(new NamespacedKey(plugin, "locked"), new CustomItemStack(Material.GOLD_NUGGET, "&6Locked Test"), (NamespacedKey) null)); Assertions.assertThrows(IllegalArgumentException.class, () -> new LockedItemGroup(new NamespacedKey(plugin, "locked"), new CustomItemStack(Material.GOLD_NUGGET, "&6Locked Test"), (NamespacedKey) null));
ItemGroup category = new ItemGroup(new NamespacedKey(plugin, "unlocked"), new CustomItemStack(Material.EMERALD, "&5I am SHERlocked")); ItemGroup group = new ItemGroup(new NamespacedKey(plugin, "unlocked"), new CustomItemStack(Material.EMERALD, "&5I am SHERlocked"));
category.register(plugin); group.register(plugin);
ItemGroup unregistered = new ItemGroup(new NamespacedKey(plugin, "unregistered"), new CustomItemStack(Material.EMERALD, "&5I am unregistered")); ItemGroup unregistered = new ItemGroup(new NamespacedKey(plugin, "unregistered"), new CustomItemStack(Material.EMERALD, "&5I am unregistered"));
LockedItemGroup locked = new LockedItemGroup(new NamespacedKey(plugin, "locked"), new CustomItemStack(Material.GOLD_NUGGET, "&6Locked Test"), category.getKey(), unregistered.getKey()); LockedItemGroup locked = new LockedItemGroup(new NamespacedKey(plugin, "locked"), new CustomItemStack(Material.GOLD_NUGGET, "&6Locked Test"), group.getKey(), unregistered.getKey());
locked.register(plugin); locked.register(plugin);
Assertions.assertTrue(locked.getParents().contains(category)); Assertions.assertTrue(locked.getParents().contains(group));
Assertions.assertFalse(locked.getParents().contains(unregistered)); Assertions.assertFalse(locked.getParents().contains(unregistered));
locked.removeParent(category); locked.removeParent(group);
Assertions.assertFalse(locked.getParents().contains(category)); Assertions.assertFalse(locked.getParents().contains(group));
Assertions.assertThrows(IllegalArgumentException.class, () -> locked.addParent(locked)); Assertions.assertThrows(IllegalArgumentException.class, () -> locked.addParent(locked));
Assertions.assertThrows(IllegalArgumentException.class, () -> locked.addParent(null)); Assertions.assertThrows(IllegalArgumentException.class, () -> locked.addParent(null));
locked.addParent(category); locked.addParent(group);
Assertions.assertTrue(locked.getParents().contains(category)); Assertions.assertTrue(locked.getParents().contains(group));
} }
@Test @Test
@DisplayName("Test an unlocked LockedCategory") @DisplayName("Test an unlocked LockedItemGroup")
void testLockedCategoriesUnlocking() throws InterruptedException { void testLockedItemGroupsUnlocking() throws InterruptedException {
Player player = server.addPlayer(); Player player = server.addPlayer();
PlayerProfile profile = TestUtilities.awaitProfile(player); PlayerProfile profile = TestUtilities.awaitProfile(player);
Assertions.assertThrows(IllegalArgumentException.class, () -> new LockedItemGroup(new NamespacedKey(plugin, "locked"), new CustomItemStack(Material.GOLD_NUGGET, "&6Locked Test"), (NamespacedKey) null)); Assertions.assertThrows(IllegalArgumentException.class, () -> new LockedItemGroup(new NamespacedKey(plugin, "locked"), new CustomItemStack(Material.GOLD_NUGGET, "&6Locked Test"), (NamespacedKey) null));
ItemGroup category = new ItemGroup(new NamespacedKey(plugin, "parent"), new CustomItemStack(Material.EMERALD, "&5I am SHERlocked")); ItemGroup group = new ItemGroup(new NamespacedKey(plugin, "parent"), new CustomItemStack(Material.EMERALD, "&5I am SHERlocked"));
category.register(plugin); group.register(plugin);
LockedItemGroup locked = new LockedItemGroup(new NamespacedKey(plugin, "locked2"), new CustomItemStack(Material.GOLD_NUGGET, "&6Locked Test"), category.getKey()); LockedItemGroup locked = new LockedItemGroup(new NamespacedKey(plugin, "locked2"), new CustomItemStack(Material.GOLD_NUGGET, "&6Locked Test"), group.getKey());
locked.register(plugin); locked.register(plugin);
// No Items, so it should be unlocked // No Items, so it should be unlocked
Assertions.assertTrue(locked.hasUnlocked(player, profile)); Assertions.assertTrue(locked.hasUnlocked(player, profile));
SlimefunItem item = new SlimefunItem(category, new SlimefunItemStack("LOCKED_CATEGORY_TEST", new CustomItemStack(Material.LANTERN, "&6Test Item for locked categories")), RecipeType.NULL, new ItemStack[9]); SlimefunItem item = new SlimefunItem(group, new SlimefunItemStack("LOCKED_CATEGORY_TEST", new CustomItemStack(Material.LANTERN, "&6Test Item for locked categories")), RecipeType.NULL, new ItemStack[9]);
item.register(plugin); item.register(plugin);
item.load(); item.load();
@ -188,30 +188,30 @@ class TestCategories {
} }
@Test @Test
@DisplayName("Test a seasonal Category") @DisplayName("Test a seasonal ItemGroup")
void testSeasonalCategories() { void ItemGroups() {
// Category with current Month // Category with current Month
Month month = LocalDate.now().getMonth(); Month month = LocalDate.now().getMonth();
SeasonalItemGroup category = new SeasonalItemGroup(new NamespacedKey(plugin, "seasonal"), month, 1, new CustomItemStack(Material.NETHER_STAR, "&cSeasonal Test")); SeasonalItemGroup group = new SeasonalItemGroup(new NamespacedKey(plugin, "seasonal"), month, 1, new CustomItemStack(Material.NETHER_STAR, "&cSeasonal Test"));
SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "SEASONAL_ITEM", new CustomItemStack(Material.NETHER_STAR, "&dSeasonal Test Star")); SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "SEASONAL_ITEM", new CustomItemStack(Material.NETHER_STAR, "&dSeasonal Test Star"));
item.setItemGroup(category); item.setItemGroup(group);
item.register(plugin); item.register(plugin);
item.load(); item.load();
Player player = server.addPlayer(); Player player = server.addPlayer();
Assertions.assertEquals(month, category.getMonth()); Assertions.assertEquals(month, group.getMonth());
Assertions.assertFalse(category.isHidden(player)); Assertions.assertFalse(group.isHidden(player));
// Category with future Month // Category with future Month
SeasonalItemGroup category2 = new SeasonalItemGroup(category.getKey(), month.plus(6), 1, new CustomItemStack(Material.MILK_BUCKET, "&dSeasonal Test")); SeasonalItemGroup category2 = new SeasonalItemGroup(group.getKey(), month.plus(6), 1, new CustomItemStack(Material.MILK_BUCKET, "&dSeasonal Test"));
Assertions.assertTrue(category2.isHidden(player)); Assertions.assertTrue(category2.isHidden(player));
} }
@Test @Test
@DisplayName("Test the FlexCategory") @DisplayName("Test the FlexItemGroup")
void testFlexCategory() { void testFlexCategory() {
FlexItemGroup category = new FlexItemGroup(new NamespacedKey(plugin, "flex"), new CustomItemStack(Material.REDSTONE, "&4Weird flex but ok")) { FlexItemGroup group = new FlexItemGroup(new NamespacedKey(plugin, "flex"), new CustomItemStack(Material.REDSTONE, "&4Weird flex but ok")) {
@Override @Override
public void open(Player p, PlayerProfile profile, SlimefunGuideMode layout) { public void open(Player p, PlayerProfile profile, SlimefunGuideMode layout) {
@ -225,11 +225,11 @@ class TestCategories {
}; };
Player player = server.addPlayer(); Player player = server.addPlayer();
Assertions.assertFalse(category.isHidden(player)); Assertions.assertFalse(group.isHidden(player));
Assertions.assertThrows(UnsupportedOperationException.class, () -> category.add(null)); Assertions.assertThrows(UnsupportedOperationException.class, () -> group.add(null));
Assertions.assertThrows(UnsupportedOperationException.class, () -> category.contains(null)); Assertions.assertThrows(UnsupportedOperationException.class, () -> group.contains(null));
Assertions.assertThrows(UnsupportedOperationException.class, () -> category.remove(null)); Assertions.assertThrows(UnsupportedOperationException.class, () -> group.remove(null));
Assertions.assertThrows(UnsupportedOperationException.class, () -> category.getItems()); Assertions.assertThrows(UnsupportedOperationException.class, () -> group.getItems());
} }
} }

View File

@ -121,7 +121,7 @@ class TestRechargeableItems {
} }
private RechargeableMock mock(String id, float capacity) { private RechargeableMock mock(String id, float capacity) {
ItemGroup category = TestUtilities.getCategory(plugin, "rechargeable"); ItemGroup category = TestUtilities.getItemGroup(plugin, "rechargeable");
return new RechargeableMock(category, new SlimefunItemStack(id, new CustomItemStack(Material.REDSTONE_LAMP, "&3" + id)), capacity); return new RechargeableMock(category, new SlimefunItemStack(id, new CustomItemStack(Material.REDSTONE_LAMP, "&3" + id)), capacity);
} }

View File

@ -59,7 +59,7 @@ class TestArmorTask {
PotionEffect[] effects = { new PotionEffect(PotionEffectType.SPEED, 50, 3), new PotionEffect(PotionEffectType.SATURATION, 128, 12) }; PotionEffect[] effects = { new PotionEffect(PotionEffectType.SPEED, 50, 3), new PotionEffect(PotionEffectType.SATURATION, 128, 12) };
SlimefunItemStack helmet = new SlimefunItemStack("HELMET_FLEX", Material.IRON_HELMET, "&bSuper cool Helmet"); SlimefunItemStack helmet = new SlimefunItemStack("HELMET_FLEX", Material.IRON_HELMET, "&bSuper cool Helmet");
SlimefunArmorPiece armor = new SlimefunArmorPiece(TestUtilities.getCategory(plugin, "armor_test"), helmet, RecipeType.NULL, new ItemStack[9], effects); SlimefunArmorPiece armor = new SlimefunArmorPiece(TestUtilities.getItemGroup(plugin, "armor_test"), helmet, RecipeType.NULL, new ItemStack[9], effects);
armor.register(plugin); armor.register(plugin);
player.getInventory().setHelmet(helmet.clone()); player.getInventory().setHelmet(helmet.clone());
@ -80,7 +80,7 @@ class TestArmorTask {
// Setting the time to noon, to exclude the Solar Helmet check // Setting the time to noon, to exclude the Solar Helmet check
player.getWorld().setTime(16000); player.getWorld().setTime(16000);
ItemGroup category = TestUtilities.getCategory(plugin, "hazmat_suit_test"); ItemGroup category = TestUtilities.getItemGroup(plugin, "hazmat_suit_test");
SlimefunItemStack item = new SlimefunItemStack("MOCK_URANIUM_" + String.valueOf(hazmat).toUpperCase(Locale.ROOT) + "_" + String.valueOf(radioactiveFire).toUpperCase(Locale.ROOT), Material.EMERALD, "&aHi, I am deadly"); SlimefunItemStack item = new SlimefunItemStack("MOCK_URANIUM_" + String.valueOf(hazmat).toUpperCase(Locale.ROOT) + "_" + String.valueOf(radioactiveFire).toUpperCase(Locale.ROOT), Material.EMERALD, "&aHi, I am deadly");
new RadioactiveItem(category, Radioactivity.VERY_DEADLY, item, RecipeType.NULL, new ItemStack[9]).register(plugin); new RadioactiveItem(category, Radioactivity.VERY_DEADLY, item, RecipeType.NULL, new ItemStack[9]).register(plugin);

View File

@ -43,7 +43,7 @@ public final class TestUtilities {
} }
@ParametersAreNonnullByDefault @ParametersAreNonnullByDefault
public static @Nonnull ItemGroup getCategory(Plugin plugin, String name) { public static @Nonnull ItemGroup getItemGroup(Plugin plugin, String name) {
return new ItemGroup(new NamespacedKey(plugin, name), new CustomItemStack(Material.NETHER_STAR, "&4Test Category")); return new ItemGroup(new NamespacedKey(plugin, name), new CustomItemStack(Material.NETHER_STAR, "&4Test Category"));
} }