1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-20 11:45:51 +00:00

Renamed categories to item groups

This commit is contained in:
TheBusyBiscuit 2021-06-26 15:59:24 +02:00
parent f6890f4c49
commit 7714c50ab9
13 changed files with 101 additions and 102 deletions

View File

@ -21,8 +21,8 @@ import org.bukkit.inventory.meta.ItemMeta;
import io.github.thebusybiscuit.cscorelib2.item.CustomItem; import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon; import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
import io.github.thebusybiscuit.slimefun4.core.categories.LockedCategory; import io.github.thebusybiscuit.slimefun4.api.items.groups.LockedItemGroup;
import io.github.thebusybiscuit.slimefun4.core.categories.SeasonalCategory; import io.github.thebusybiscuit.slimefun4.api.items.groups.SeasonalItemGroup;
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide; import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
@ -31,8 +31,8 @@ import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
* *
* @author TheBusyBiscuit * @author TheBusyBiscuit
* *
* @see LockedCategory * @see LockedItemGroup
* @see SeasonalCategory * @see SeasonalItemGroup
* *
*/ */
public class ItemGroup implements Keyed { public class ItemGroup implements Keyed {
@ -205,7 +205,7 @@ public class ItemGroup implements Keyed {
name = item.getItemMeta().getDisplayName(); name = item.getItemMeta().getDisplayName();
} }
if (this instanceof SeasonalCategory) { if (this instanceof SeasonalItemGroup) {
meta.setDisplayName(ChatColor.GOLD + name); meta.setDisplayName(ChatColor.GOLD + name);
} else { } else {
meta.setDisplayName(ChatColor.YELLOW + name); meta.setDisplayName(ChatColor.YELLOW + name);

View File

@ -1,4 +1,4 @@
package io.github.thebusybiscuit.slimefun4.core.categories; package io.github.thebusybiscuit.slimefun4.api.items.groups;
import java.util.List; import java.util.List;
@ -16,7 +16,7 @@ import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode; import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode;
/** /**
* A {@link FlexCategory} is a {@link ItemGroup} inside the {@link SlimefunGuide} that can * A {@link FlexItemGroup} is a {@link ItemGroup} inside the {@link SlimefunGuide} that can
* be completely modified. * be completely modified.
* It cannot hold any {@link SlimefunItem} but can be completely overridden * It cannot hold any {@link SlimefunItem} but can be completely overridden
* to perform any action upon being opened. * to perform any action upon being opened.
@ -24,20 +24,20 @@ import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode;
* @author TheBusyBiscuit * @author TheBusyBiscuit
* *
*/ */
public abstract class FlexCategory extends ItemGroup { public abstract class FlexItemGroup extends ItemGroup {
@ParametersAreNonnullByDefault @ParametersAreNonnullByDefault
protected FlexCategory(NamespacedKey key, ItemStack item) { protected FlexItemGroup(NamespacedKey key, ItemStack item) {
this(key, item, 3); this(key, item, 3);
} }
@ParametersAreNonnullByDefault @ParametersAreNonnullByDefault
protected FlexCategory(NamespacedKey key, ItemStack item, int tier) { protected FlexItemGroup(NamespacedKey key, ItemStack item, int tier) {
super(key, item, tier); super(key, item, tier);
} }
/** /**
* This method returns whether this {@link FlexCategory} is visible under the given context. * This method returns whether this {@link FlexItemGroup} is visible under the given context.
* Implementing this method gives full flexibility over who can see the Category when and where. * Implementing this method gives full flexibility over who can see the Category when and where.
* *
* @param p * @param p
@ -45,20 +45,20 @@ public abstract class FlexCategory extends ItemGroup {
* @param profile * @param profile
* The {@link PlayerProfile} of the {@link Player} * The {@link PlayerProfile} of the {@link Player}
* @param layout * @param layout
* The {@link SlimefunGuideMode} in which this {@link FlexCategory} is viewed * The {@link SlimefunGuideMode} in which this {@link FlexItemGroup} is viewed
* *
* @return Whether to display this {@link FlexCategory} * @return Whether to display this {@link FlexItemGroup}
*/ */
@ParametersAreNonnullByDefault @ParametersAreNonnullByDefault
public abstract boolean isVisible(Player p, PlayerProfile profile, SlimefunGuideMode layout); public abstract boolean isVisible(Player p, PlayerProfile profile, SlimefunGuideMode layout);
/** /**
* This method is called when a {@link Player} opens this {@link FlexCategory}. * This method is called when a {@link Player} opens this {@link FlexItemGroup}.
* This is an abstract method which needs to be implemented in order to determine what this * This is an abstract method which needs to be implemented in order to determine what this
* {@link FlexCategory} should actually do as it cannot hold any items. * {@link FlexItemGroup} should actually do as it cannot hold any items.
* *
* @param p * @param p
* The {@link Player} who wants to open this {@link FlexCategory} * The {@link Player} who wants to open this {@link FlexItemGroup}
* @param profile * @param profile
* The corresponding {@link PlayerProfile} for that {@link Player} * The corresponding {@link PlayerProfile} for that {@link Player}
* @param layout * @param layout

View File

@ -1,4 +1,4 @@
package io.github.thebusybiscuit.slimefun4.core.categories; package io.github.thebusybiscuit.slimefun4.api.items.groups;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
@ -29,10 +29,10 @@ import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
* @author TheBusyBiscuit * @author TheBusyBiscuit
* *
* @see ItemGroup * @see ItemGroup
* @see SeasonalCategory * @see SeasonalItemGroup
* *
*/ */
public class LockedCategory extends ItemGroup { public class LockedItemGroup extends ItemGroup {
private final NamespacedKey[] keys; private final NamespacedKey[] keys;
private final Set<ItemGroup> parents = new HashSet<>(); private final Set<ItemGroup> parents = new HashSet<>();
@ -50,7 +50,7 @@ public class LockedCategory extends ItemGroup {
* *
*/ */
@ParametersAreNonnullByDefault @ParametersAreNonnullByDefault
public LockedCategory(NamespacedKey key, ItemStack item, NamespacedKey... parents) { public LockedItemGroup(NamespacedKey key, ItemStack item, NamespacedKey... parents) {
this(key, item, 3, parents); this(key, item, 3, parents);
} }
@ -68,7 +68,7 @@ public class LockedCategory extends ItemGroup {
* *
*/ */
@ParametersAreNonnullByDefault @ParametersAreNonnullByDefault
public LockedCategory(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 LockedCategory must not have any 'null' parents!");
@ -99,7 +99,7 @@ public class LockedCategory extends ItemGroup {
} }
/** /**
* Gets the list of parent categories for this {@link LockedCategory}. * Gets the list of parent categories for this {@link LockedItemGroup}.
* *
* @return the list of parent categories * @return the list of parent categories
* *
@ -112,7 +112,7 @@ public class LockedCategory extends ItemGroup {
} }
/** /**
* Adds a parent {@link ItemGroup} to this {@link LockedCategory}. * Adds a parent {@link ItemGroup} to this {@link LockedItemGroup}.
* *
* @param category * @param category
* The {@link ItemGroup} to add as a parent * The {@link ItemGroup} to add as a parent
@ -129,10 +129,10 @@ public class LockedCategory extends ItemGroup {
} }
/** /**
* Removes a {@link ItemGroup} from the parents of this {@link LockedCategory}. * Removes a {@link ItemGroup} from the parents of this {@link LockedItemGroup}.
* *
* @param category * @param category
* The {@link ItemGroup} to remove from the parents of this {@link LockedCategory} * The {@link ItemGroup} to remove from the parents of this {@link LockedItemGroup}
* *
* @see #getParents() * @see #getParents()
* @see #addParent(ItemGroup) * @see #addParent(ItemGroup)

View File

@ -1,4 +1,4 @@
package io.github.thebusybiscuit.slimefun4.core.categories; package io.github.thebusybiscuit.slimefun4.api.items.groups;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -20,45 +20,46 @@ import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import io.github.thebusybiscuit.slimefun4.implementation.guide.SurvivalSlimefunGuide; import io.github.thebusybiscuit.slimefun4.implementation.guide.SurvivalSlimefunGuide;
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
public class MultiCategory extends FlexCategory { public class NestedItemGroup extends FlexItemGroup {
private static final int CATEGORY_SIZE = 36; private static final int GROUP_SIZE = 36;
private final List<SubCategory> subCategories = new ArrayList<>(); private final List<SubItemGroup> subGroups = new ArrayList<>();
@ParametersAreNonnullByDefault @ParametersAreNonnullByDefault
public MultiCategory(NamespacedKey key, ItemStack item) { public NestedItemGroup(NamespacedKey key, ItemStack item) {
this(key, item, 3); this(key, item, 3);
} }
@ParametersAreNonnullByDefault @ParametersAreNonnullByDefault
public MultiCategory(NamespacedKey key, ItemStack item, int tier) { public NestedItemGroup(NamespacedKey key, ItemStack item, int tier) {
super(key, item, tier); super(key, item, tier);
} }
/** /**
* This will add the given {@link SubCategory} to this {@link MultiCategory}. * This will add the given {@link SubItemGroup} to this {@link NestedItemGroup}.
* *
* @param category * @param category
* The {@link SubCategory} to add. * The {@link SubItemGroup} to add.
*/ */
public void addSubCategory(@Nonnull SubCategory category) { public void addSubGroup(@Nonnull SubItemGroup category) {
Validate.notNull(category, "The Category cannot be null!"); Validate.notNull(category, "The sub item group cannot be null!");
subCategories.add(category); subGroups.add(category);
} }
/** /**
* This will remove the given {@link SubCategory} from this {@link MultiCategory} (if present). * This will remove the given {@link SubItemGroup} from this {@link NestedItemGroup} (if present).
* *
* @param category * @param category
* The {@link SubCategory} to remove. * The {@link SubItemGroup} to remove.
*/ */
public void removeSubCategory(@Nonnull SubCategory category) { public void removeSubGroup(@Nonnull SubItemGroup category) {
Validate.notNull(category, "The Category cannot be null!"); Validate.notNull(category, "The sub item group cannot be null!");
subCategories.remove(category); subGroups.remove(category);
} }
@Override @Override
@ -96,12 +97,12 @@ public class MultiCategory extends FlexCategory {
int index = 9; int index = 9;
int target = (CATEGORY_SIZE * (page - 1)) - 1; int target = (GROUP_SIZE * (page - 1)) - 1;
while (target < (subCategories.size() - 1) && index < CATEGORY_SIZE + 9) { while (target < (subGroups.size() - 1) && index < GROUP_SIZE + 9) {
target++; target++;
SubCategory category = subCategories.get(target); SubItemGroup category = subGroups.get(target);
menu.addItem(index, category.getItem(p)); menu.addItem(index, category.getItem(p));
menu.addMenuClickHandler(index, (pl, slot, item, action) -> { menu.addMenuClickHandler(index, (pl, slot, item, action) -> {
SlimefunGuide.openCategory(profile, category, mode, 1); SlimefunGuide.openCategory(profile, category, mode, 1);
@ -111,7 +112,7 @@ public class MultiCategory extends FlexCategory {
index++; index++;
} }
int pages = target == subCategories.size() - 1 ? page : (subCategories.size() - 1) / CATEGORY_SIZE + 1; int pages = target == subGroups.size() - 1 ? page : (subGroups.size() - 1) / GROUP_SIZE + 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) -> {

View File

@ -1,4 +1,4 @@
package io.github.thebusybiscuit.slimefun4.core.categories; package io.github.thebusybiscuit.slimefun4.api.items.groups;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.Month; import java.time.Month;
@ -20,14 +20,14 @@ import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
* @author TheBusyBiscuit * @author TheBusyBiscuit
* *
* @see ItemGroup * @see ItemGroup
* @see LockedCategory * @see LockedItemGroup
*/ */
public class SeasonalCategory extends ItemGroup { public class SeasonalItemGroup extends ItemGroup {
private final Month month; private final Month month;
/** /**
* The constructor for a {@link SeasonalCategory}. * The constructor for a {@link SeasonalItemGroup}.
* *
* @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}
@ -39,7 +39,7 @@ public class SeasonalCategory extends ItemGroup {
* The display item for this category * The display item for this category
*/ */
@ParametersAreNonnullByDefault @ParametersAreNonnullByDefault
public SeasonalCategory(NamespacedKey key, Month month, int tier, ItemStack item) { public SeasonalItemGroup(NamespacedKey key, Month month, int tier, ItemStack item) {
super(key, item, tier); super(key, item, tier);
Validate.notNull(month, "The Month cannot be null"); Validate.notNull(month, "The Month cannot be null");
@ -47,9 +47,9 @@ public class SeasonalCategory extends ItemGroup {
} }
/** /**
* This method returns the {@link Month} in which this {@link SeasonalCategory} will appear. * This method returns the {@link Month} in which this {@link SeasonalItemGroup} will appear.
* *
* @return the {@link Month} in which this {@link SeasonalCategory} appears * @return the {@link Month} in which this {@link SeasonalItemGroup} appears
*/ */
@Nonnull @Nonnull
public Month getMonth() { public Month getMonth() {

View File

@ -1,4 +1,4 @@
package io.github.thebusybiscuit.slimefun4.core.categories; package io.github.thebusybiscuit.slimefun4.api.items.groups;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault; import javax.annotation.ParametersAreNonnullByDefault;
@ -12,31 +12,31 @@ import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
/** /**
* The {@link SubCategory} is a child {@link ItemGroup} of the * The {@link SubItemGroup} is a child {@link ItemGroup} of the
* {@link MultiCategory}. * {@link NestedItemGroup}.
* *
* @author TheBusyBiscuit * @author TheBusyBiscuit
* *
* @see MultiCategory * @see NestedItemGroup
* *
*/ */
public class SubCategory extends ItemGroup { public class SubItemGroup extends ItemGroup {
private final MultiCategory multiCategory; private final NestedItemGroup multiCategory;
@ParametersAreNonnullByDefault @ParametersAreNonnullByDefault
public SubCategory(NamespacedKey key, MultiCategory parent, ItemStack item) { public SubItemGroup(NamespacedKey key, NestedItemGroup parent, ItemStack item) {
this(key, parent, item, 3); this(key, parent, item, 3);
} }
@ParametersAreNonnullByDefault @ParametersAreNonnullByDefault
public SubCategory(NamespacedKey key, MultiCategory 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 category cannot be null");
multiCategory = parent; multiCategory = parent;
parent.addSubCategory(this); parent.addSubGroup(this);
} }
@Override @Override
@ -49,7 +49,7 @@ public class SubCategory extends ItemGroup {
} }
@Nonnull @Nonnull
public final MultiCategory getParent() { public final NestedItemGroup getParent() {
return multiCategory; return multiCategory;
} }

View File

@ -0,0 +1,4 @@
/**
* This package contains a few {@link io.github.thebusybiscuit.slimefun4.api.items.ItemGroup} variations.
*/
package io.github.thebusybiscuit.slimefun4.api.items.groups;

View File

@ -1,6 +0,0 @@
/**
* This package stores API classes that are centered around the extension of the
* {@link me.mrCookieSlime.Slimefun.Objects.Category} class, such as
* {@link io.github.thebusybiscuit.slimefun4.core.categories.SeasonalCategory} for example.
*/
package io.github.thebusybiscuit.slimefun4.core.categories;

View File

@ -13,8 +13,8 @@ import org.bukkit.inventory.Recipe;
import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import io.github.thebusybiscuit.slimefun4.api.items.groups.FlexItemGroup;
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
import io.github.thebusybiscuit.slimefun4.core.categories.FlexCategory;
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode; import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
@ -53,7 +53,7 @@ public class CheatSheetSlimefunGuide extends SurvivalSlimefunGuide {
List<ItemGroup> categories = new LinkedList<>(); List<ItemGroup> categories = new LinkedList<>();
for (ItemGroup category : SlimefunPlugin.getRegistry().getCategories()) { for (ItemGroup category : SlimefunPlugin.getRegistry().getCategories()) {
if (!(category instanceof FlexCategory)) { if (!(category instanceof FlexItemGroup)) {
categories.add(category); categories.add(category);
} }
} }

View File

@ -31,10 +31,10 @@ import io.github.thebusybiscuit.cscorelib2.recipes.MinecraftRecipe;
import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon; import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import io.github.thebusybiscuit.slimefun4.api.items.groups.FlexItemGroup;
import io.github.thebusybiscuit.slimefun4.api.items.groups.LockedItemGroup;
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem; import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem;
import io.github.thebusybiscuit.slimefun4.core.categories.FlexCategory;
import io.github.thebusybiscuit.slimefun4.core.categories.LockedCategory;
import io.github.thebusybiscuit.slimefun4.core.guide.GuideHistory; import io.github.thebusybiscuit.slimefun4.core.guide.GuideHistory;
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide; import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideImplementation; import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideImplementation;
@ -117,7 +117,7 @@ public class SurvivalSlimefunGuide implements SlimefunGuideImplementation {
for (ItemGroup category : SlimefunPlugin.getRegistry().getCategories()) { for (ItemGroup category : SlimefunPlugin.getRegistry().getCategories()) {
try { try {
if (!category.isHidden(p) && (!(category instanceof FlexCategory) || ((FlexCategory) category).isVisible(p, profile, getMode()))) { if (!category.isHidden(p) && (!(category instanceof FlexItemGroup) || ((FlexItemGroup) category).isVisible(p, profile, getMode()))) {
categories.add(category); categories.add(category);
} }
} catch (Exception | LinkageError x) { } catch (Exception | LinkageError x) {
@ -193,7 +193,7 @@ public class SurvivalSlimefunGuide implements SlimefunGuideImplementation {
} }
private void displayCategory(ChestMenu menu, Player p, PlayerProfile profile, ItemGroup category, int index) { private void displayCategory(ChestMenu menu, Player p, PlayerProfile profile, ItemGroup category, int index) {
if (!(category instanceof LockedCategory) || !isSurvivalMode() || ((LockedCategory) category).hasUnlocked(p, profile)) { if (!(category instanceof LockedItemGroup) || !isSurvivalMode() || ((LockedItemGroup) category).hasUnlocked(p, profile)) {
menu.addItem(index, category.getItem(p)); menu.addItem(index, category.getItem(p));
menu.addMenuClickHandler(index, (pl, slot, item, action) -> { menu.addMenuClickHandler(index, (pl, slot, item, action) -> {
openCategory(profile, category, 1); openCategory(profile, category, 1);
@ -209,7 +209,7 @@ public class SurvivalSlimefunGuide implements SlimefunGuideImplementation {
lore.add(""); lore.add("");
for (ItemGroup parent : ((LockedCategory) category).getParents()) { for (ItemGroup parent : ((LockedItemGroup) category).getParents()) {
lore.add(parent.getItem(p).getItemMeta().getDisplayName()); lore.add(parent.getItem(p).getItemMeta().getDisplayName());
} }
@ -226,8 +226,8 @@ public class SurvivalSlimefunGuide implements SlimefunGuideImplementation {
return; return;
} }
if (category instanceof FlexCategory) { if (category instanceof FlexItemGroup) {
((FlexCategory) category).open(p, profile, getMode()); ((FlexItemGroup) category).open(p, profile, getMode());
return; return;
} }

View File

@ -8,7 +8,7 @@ import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.cscorelib2.item.CustomItem; import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack;
import io.github.thebusybiscuit.slimefun4.core.categories.LockedCategory; import io.github.thebusybiscuit.slimefun4.api.items.groups.LockedItemGroup;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
@ -21,7 +21,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
*/ */
class EnderTalisman extends Talisman { class EnderTalisman extends Talisman {
private static final LockedCategory ENDER_TALISMANS_CATEGORY = new LockedCategory(new NamespacedKey(SlimefunPlugin.instance(), "ender_talismans"), new CustomItem(SlimefunItems.ENDER_TALISMAN, "&7Talismans - &aTier II"), 3, Talisman.TALISMANS_CATEGORY.getKey()); private static final LockedItemGroup ENDER_TALISMANS_CATEGORY = new LockedItemGroup(new NamespacedKey(SlimefunPlugin.instance(), "ender_talismans"), new CustomItem(SlimefunItems.ENDER_TALISMAN, "&7Talismans - &aTier II"), 3, Talisman.TALISMANS_CATEGORY.getKey());
@ParametersAreNonnullByDefault @ParametersAreNonnullByDefault
public EnderTalisman(Talisman parent, SlimefunItemStack item) { public EnderTalisman(Talisman parent, SlimefunItemStack item) {

View File

@ -7,8 +7,8 @@ import org.bukkit.NamespacedKey;
import io.github.thebusybiscuit.cscorelib2.item.CustomItem; import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
import io.github.thebusybiscuit.slimefun4.core.categories.LockedCategory; import io.github.thebusybiscuit.slimefun4.api.items.groups.LockedItemGroup;
import io.github.thebusybiscuit.slimefun4.core.categories.SeasonalCategory; import io.github.thebusybiscuit.slimefun4.api.items.groups.SeasonalItemGroup;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import io.github.thebusybiscuit.slimefun4.utils.ChatUtils; import io.github.thebusybiscuit.slimefun4.utils.ChatUtils;
@ -25,8 +25,8 @@ import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
* @author TheBusyBiscuit * @author TheBusyBiscuit
* *
* @see ItemGroup * @see ItemGroup
* @see LockedCategory * @see LockedItemGroup
* @see SeasonalCategory * @see SeasonalItemGroup
* *
*/ */
class DefaultCategories { class DefaultCategories {
@ -51,16 +51,16 @@ class DefaultCategories {
protected final ItemGroup resources = new ItemGroup(new NamespacedKey(SlimefunPlugin.instance(), "resources"), new CustomItem(SlimefunItems.SYNTHETIC_SAPPHIRE, "&7Resources"), 1); protected final ItemGroup resources = new ItemGroup(new NamespacedKey(SlimefunPlugin.instance(), "resources"), new CustomItem(SlimefunItems.SYNTHETIC_SAPPHIRE, "&7Resources"), 1);
// Locked Categories // Locked Categories
protected final LockedCategory electricity = new LockedCategory(new NamespacedKey(SlimefunPlugin.instance(), "electricity"), new CustomItem(SlimefunItems.NUCLEAR_REACTOR, "&bEnergy and Electricity"), 4, basicMachines.getKey()); protected final LockedItemGroup electricity = new LockedItemGroup(new NamespacedKey(SlimefunPlugin.instance(), "electricity"), new CustomItem(SlimefunItems.NUCLEAR_REACTOR, "&bEnergy and Electricity"), 4, basicMachines.getKey());
protected final LockedCategory androids = new LockedCategory(new NamespacedKey(SlimefunPlugin.instance(), "androids"), new CustomItem(SlimefunItems.PROGRAMMABLE_ANDROID, "&cProgrammable Androids"), 4, basicMachines.getKey()); protected final LockedItemGroup androids = new LockedItemGroup(new NamespacedKey(SlimefunPlugin.instance(), "androids"), new CustomItem(SlimefunItems.PROGRAMMABLE_ANDROID, "&cProgrammable Androids"), 4, basicMachines.getKey());
protected final ItemGroup cargo = new LockedCategory(new NamespacedKey(SlimefunPlugin.instance(), "cargo"), new CustomItem(SlimefunItems.CARGO_MANAGER, "&cCargo Management"), 4, basicMachines.getKey()); protected final ItemGroup cargo = new LockedItemGroup(new NamespacedKey(SlimefunPlugin.instance(), "cargo"), new CustomItem(SlimefunItems.CARGO_MANAGER, "&cCargo Management"), 4, basicMachines.getKey());
protected final LockedCategory gps = new LockedCategory(new NamespacedKey(SlimefunPlugin.instance(), "gps"), new CustomItem(SlimefunItems.GPS_TRANSMITTER, "&bGPS-based Machines"), 4, basicMachines.getKey()); protected final LockedItemGroup gps = new LockedItemGroup(new NamespacedKey(SlimefunPlugin.instance(), "gps"), new CustomItem(SlimefunItems.GPS_TRANSMITTER, "&bGPS-based Machines"), 4, basicMachines.getKey());
// Seasonal Categories // Seasonal Categories
protected final SeasonalCategory christmas = new SeasonalCategory(new NamespacedKey(SlimefunPlugin.instance(), "christmas"), Month.DECEMBER, 1, new CustomItem(SlimefunUtils.getCustomHead("215ba31cde2671b8f176de6a9ffd008035f0590d63ee240be6e8921cd2037a45"), ChatUtils.christmas("Christmas") + " &7(December only)")); protected final SeasonalItemGroup christmas = new SeasonalItemGroup(new NamespacedKey(SlimefunPlugin.instance(), "christmas"), Month.DECEMBER, 1, new CustomItem(SlimefunUtils.getCustomHead("215ba31cde2671b8f176de6a9ffd008035f0590d63ee240be6e8921cd2037a45"), ChatUtils.christmas("Christmas") + " &7(December only)"));
protected final SeasonalCategory valentinesDay = new SeasonalCategory(new NamespacedKey(SlimefunPlugin.instance(), "valentines_day"), Month.FEBRUARY, 2, new CustomItem(SlimefunUtils.getCustomHead("55d89431d14bfef2060461b4a3565614dc51115c001fae2508e8684bc0ae6a80"), "&dValentine's Day" + " &7(14th February)")); protected final SeasonalItemGroup valentinesDay = new SeasonalItemGroup(new NamespacedKey(SlimefunPlugin.instance(), "valentines_day"), Month.FEBRUARY, 2, new CustomItem(SlimefunUtils.getCustomHead("55d89431d14bfef2060461b4a3565614dc51115c001fae2508e8684bc0ae6a80"), "&dValentine's Day" + " &7(14th February)"));
protected final SeasonalCategory easter = new SeasonalCategory(new NamespacedKey(SlimefunPlugin.instance(), "easter"), Month.APRIL, 2, new CustomItem(HeadTexture.EASTER_EGG.getAsItemStack(), "&6Easter" + " &7(April)")); protected final SeasonalItemGroup easter = new SeasonalItemGroup(new NamespacedKey(SlimefunPlugin.instance(), "easter"), Month.APRIL, 2, new CustomItem(HeadTexture.EASTER_EGG.getAsItemStack(), "&6Easter" + " &7(April)"));
protected final SeasonalCategory birthday = new SeasonalCategory(new NamespacedKey(SlimefunPlugin.instance(), "birthday"), Month.OCTOBER, 1, new CustomItem(Material.FIREWORK_ROCKET, "&a&lTheBusyBiscuit's Birthday &7(26th October)")); protected final SeasonalItemGroup birthday = new SeasonalItemGroup(new NamespacedKey(SlimefunPlugin.instance(), "birthday"), Month.OCTOBER, 1, new CustomItem(Material.FIREWORK_ROCKET, "&a&lTheBusyBiscuit's Birthday &7(26th October)"));
protected final SeasonalCategory halloween = new SeasonalCategory(new NamespacedKey(SlimefunPlugin.instance(), "halloween"), Month.OCTOBER, 1, new CustomItem(Material.JACK_O_LANTERN, "&6&lHalloween &7(31st October)")); protected final SeasonalItemGroup halloween = new SeasonalItemGroup(new NamespacedKey(SlimefunPlugin.instance(), "halloween"), Month.OCTOBER, 1, new CustomItem(Material.JACK_O_LANTERN, "&6&lHalloween &7(31st October)"));
} }

View File

@ -17,10 +17,10 @@ import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack;
import io.github.thebusybiscuit.slimefun4.api.items.groups.FlexItemGroup;
import io.github.thebusybiscuit.slimefun4.api.items.groups.LockedItemGroup;
import io.github.thebusybiscuit.slimefun4.api.items.groups.SeasonalItemGroup;
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
import io.github.thebusybiscuit.slimefun4.core.categories.FlexCategory;
import io.github.thebusybiscuit.slimefun4.core.categories.LockedCategory;
import io.github.thebusybiscuit.slimefun4.core.categories.SeasonalCategory;
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode; import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode;
import io.github.thebusybiscuit.slimefun4.core.researching.Research; import io.github.thebusybiscuit.slimefun4.core.researching.Research;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
@ -130,14 +130,14 @@ class TestCategories {
@Test @Test
@DisplayName("Test LockedCategory parental locking") @DisplayName("Test LockedCategory parental locking")
void testLockedCategoriesParents() { void testLockedCategoriesParents() {
Assertions.assertThrows(IllegalArgumentException.class, () -> new LockedCategory(new NamespacedKey(plugin, "locked"), new CustomItem(Material.GOLD_NUGGET, "&6Locked Test"), (NamespacedKey) null)); Assertions.assertThrows(IllegalArgumentException.class, () -> new LockedItemGroup(new NamespacedKey(plugin, "locked"), new CustomItem(Material.GOLD_NUGGET, "&6Locked Test"), (NamespacedKey) null));
ItemGroup category = new ItemGroup(new NamespacedKey(plugin, "unlocked"), new CustomItem(Material.EMERALD, "&5I am SHERlocked")); ItemGroup category = new ItemGroup(new NamespacedKey(plugin, "unlocked"), new CustomItem(Material.EMERALD, "&5I am SHERlocked"));
category.register(plugin); category.register(plugin);
ItemGroup unregistered = new ItemGroup(new NamespacedKey(plugin, "unregistered"), new CustomItem(Material.EMERALD, "&5I am unregistered")); ItemGroup unregistered = new ItemGroup(new NamespacedKey(plugin, "unregistered"), new CustomItem(Material.EMERALD, "&5I am unregistered"));
LockedCategory locked = new LockedCategory(new NamespacedKey(plugin, "locked"), new CustomItem(Material.GOLD_NUGGET, "&6Locked Test"), category.getKey(), unregistered.getKey()); LockedItemGroup locked = new LockedItemGroup(new NamespacedKey(plugin, "locked"), new CustomItem(Material.GOLD_NUGGET, "&6Locked Test"), category.getKey(), unregistered.getKey());
locked.register(plugin); locked.register(plugin);
Assertions.assertTrue(locked.getParents().contains(category)); Assertions.assertTrue(locked.getParents().contains(category));
@ -159,12 +159,12 @@ class TestCategories {
Player player = server.addPlayer(); Player player = server.addPlayer();
PlayerProfile profile = TestUtilities.awaitProfile(player); PlayerProfile profile = TestUtilities.awaitProfile(player);
Assertions.assertThrows(IllegalArgumentException.class, () -> new LockedCategory(new NamespacedKey(plugin, "locked"), new CustomItem(Material.GOLD_NUGGET, "&6Locked Test"), (NamespacedKey) null)); Assertions.assertThrows(IllegalArgumentException.class, () -> new LockedItemGroup(new NamespacedKey(plugin, "locked"), new CustomItem(Material.GOLD_NUGGET, "&6Locked Test"), (NamespacedKey) null));
ItemGroup category = new ItemGroup(new NamespacedKey(plugin, "parent"), new CustomItem(Material.EMERALD, "&5I am SHERlocked")); ItemGroup category = new ItemGroup(new NamespacedKey(plugin, "parent"), new CustomItem(Material.EMERALD, "&5I am SHERlocked"));
category.register(plugin); category.register(plugin);
LockedCategory locked = new LockedCategory(new NamespacedKey(plugin, "locked2"), new CustomItem(Material.GOLD_NUGGET, "&6Locked Test"), category.getKey()); LockedItemGroup locked = new LockedItemGroup(new NamespacedKey(plugin, "locked2"), new CustomItem(Material.GOLD_NUGGET, "&6Locked Test"), category.getKey());
locked.register(plugin); locked.register(plugin);
// No Items, so it should be unlocked // No Items, so it should be unlocked
@ -192,7 +192,7 @@ class TestCategories {
void testSeasonalCategories() { void testSeasonalCategories() {
// Category with current Month // Category with current Month
Month month = LocalDate.now().getMonth(); Month month = LocalDate.now().getMonth();
SeasonalCategory category = new SeasonalCategory(new NamespacedKey(plugin, "seasonal"), month, 1, new CustomItem(Material.NETHER_STAR, "&cSeasonal Test")); SeasonalItemGroup category = new SeasonalItemGroup(new NamespacedKey(plugin, "seasonal"), month, 1, new CustomItem(Material.NETHER_STAR, "&cSeasonal Test"));
SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "SEASONAL_ITEM", new CustomItem(Material.NETHER_STAR, "&dSeasonal Test Star")); SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "SEASONAL_ITEM", new CustomItem(Material.NETHER_STAR, "&dSeasonal Test Star"));
item.setCategory(category); item.setCategory(category);
item.register(plugin); item.register(plugin);
@ -204,14 +204,14 @@ class TestCategories {
Assertions.assertFalse(category.isHidden(player)); Assertions.assertFalse(category.isHidden(player));
// Category with future Month // Category with future Month
SeasonalCategory category2 = new SeasonalCategory(category.getKey(), month.plus(6), 1, new CustomItem(Material.MILK_BUCKET, "&dSeasonal Test")); SeasonalItemGroup category2 = new SeasonalItemGroup(category.getKey(), month.plus(6), 1, new CustomItem(Material.MILK_BUCKET, "&dSeasonal Test"));
Assertions.assertTrue(category2.isHidden(player)); Assertions.assertTrue(category2.isHidden(player));
} }
@Test @Test
@DisplayName("Test the FlexCategory") @DisplayName("Test the FlexCategory")
void testFlexCategory() { void testFlexCategory() {
FlexCategory category = new FlexCategory(new NamespacedKey(plugin, "flex"), new CustomItem(Material.REDSTONE, "&4Weird flex but ok")) { FlexItemGroup category = new FlexItemGroup(new NamespacedKey(plugin, "flex"), new CustomItem(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) {