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

FlexCategories can now be made visible in CheatSheetSlimefunGuide

This commit is contained in:
Martin Brom 2021-06-06 20:31:24 +02:00
parent cc23211504
commit 96ec2ba1f6
4 changed files with 24 additions and 23 deletions

View File

@ -77,12 +77,12 @@ public abstract class FlexCategory extends Category {
}
@Override
public final void add(SlimefunItem item) {
public final void add(@Nonnull SlimefunItem item) {
throw new UnsupportedOperationException("You cannot add items to a FlexCategory!");
}
@Override
public final List<SlimefunItem> getItems() {
public final @Nonnull List<SlimefunItem> getItems() {
throw new UnsupportedOperationException("A FlexCategory has no items!");
}
@ -92,7 +92,7 @@ public abstract class FlexCategory extends Category {
}
@Override
public final void remove(SlimefunItem item) {
public final void remove(@Nonnull SlimefunItem item) {
throw new UnsupportedOperationException("A FlexCategory has no items, so there is nothing remove!");
}

View File

@ -64,7 +64,7 @@ public class MultiCategory extends FlexCategory {
@Override
@ParametersAreNonnullByDefault
public boolean isVisible(Player p, PlayerProfile profile, SlimefunGuideMode mode) {
return true;
return mode == SlimefunGuideMode.SURVIVAL_MODE;
}
@Override

View File

@ -47,13 +47,12 @@ public class CheatSheetSlimefunGuide extends SurvivalSlimefunGuide {
* The {@link PlayerProfile} of the {@link Player}
* @return a {@link List} of visible {@link Category} instances
*/
@Nonnull
@Override
protected List<Category> getVisibleCategories(@Nonnull Player p, @Nonnull PlayerProfile profile) {
protected @Nonnull List<Category> getVisibleCategories(@Nonnull Player p, @Nonnull PlayerProfile profile) {
List<Category> categories = new LinkedList<>();
for (Category category : SlimefunPlugin.getRegistry().getCategories()) {
if (!(category instanceof FlexCategory)) {
if (!(category instanceof FlexCategory) || ((FlexCategory) category).isVisible(p, profile, getMode())) {
categories.add(category);
}
}
@ -61,15 +60,13 @@ public class CheatSheetSlimefunGuide extends SurvivalSlimefunGuide {
return categories;
}
@Nonnull
@Override
public SlimefunGuideMode getMode() {
public @Nonnull SlimefunGuideMode getMode() {
return SlimefunGuideMode.CHEAT_MODE;
}
@Nonnull
@Override
public ItemStack getItem() {
public @Nonnull ItemStack getItem() {
return item;
}

View File

@ -83,18 +83,17 @@ public class SurvivalSlimefunGuide implements SlimefunGuideImplementation {
*
* @return The {@link Sound}
*/
@Nonnull
public Sound getSound() {
public @Nonnull Sound getSound() {
return sound;
}
@Override
public SlimefunGuideMode getMode() {
public @Nonnull SlimefunGuideMode getMode() {
return SlimefunGuideMode.SURVIVAL_MODE;
}
@Override
public ItemStack getItem() {
public @Nonnull ItemStack getItem() {
return item;
}
@ -111,13 +110,16 @@ public class SurvivalSlimefunGuide implements SlimefunGuideImplementation {
* The {@link PlayerProfile} of the {@link Player}
* @return a {@link List} of visible {@link Category} instances
*/
@Nonnull
protected List<Category> getVisibleCategories(@Nonnull Player p, @Nonnull PlayerProfile profile) {
protected @Nonnull List<Category> getVisibleCategories(@Nonnull Player p, @Nonnull PlayerProfile profile) {
List<Category> categories = new LinkedList<>();
for (Category category : SlimefunPlugin.getRegistry().getCategories()) {
try {
if (!category.isHidden(p) && (!(category instanceof FlexCategory) || ((FlexCategory) category).isVisible(p, profile, getMode()))) {
if (category instanceof FlexCategory) {
if (((FlexCategory) category).isVisible(p, profile, getMode())) {
categories.add(category);
}
} else if (!category.isHidden(p)) {
categories.add(category);
}
} catch (Exception | LinkageError x) {
@ -219,6 +221,7 @@ public class SurvivalSlimefunGuide implements SlimefunGuideImplementation {
}
@Override
@ParametersAreNonnullByDefault
public void openCategory(PlayerProfile profile, Category category, int page) {
Player p = profile.getPlayer();
@ -321,6 +324,7 @@ public class SurvivalSlimefunGuide implements SlimefunGuideImplementation {
}
@Override
@ParametersAreNonnullByDefault
public void openSearch(PlayerProfile profile, String input, boolean addToHistory) {
Player p = profile.getPlayer();
@ -382,6 +386,7 @@ public class SurvivalSlimefunGuide implements SlimefunGuideImplementation {
}
@Override
@ParametersAreNonnullByDefault
public void displayItem(PlayerProfile profile, ItemStack item, int index, boolean addToHistory) {
Player p = profile.getPlayer();
@ -486,6 +491,7 @@ public class SurvivalSlimefunGuide implements SlimefunGuideImplementation {
}
@Override
@ParametersAreNonnullByDefault
public void displayItem(PlayerProfile profile, SlimefunItem item, boolean addToHistory) {
Player p = profile.getPlayer();
@ -619,9 +625,8 @@ public class SurvivalSlimefunGuide implements SlimefunGuideImplementation {
}
}
@Nonnull
@ParametersAreNonnullByDefault
private static ItemStack getDisplayItem(Player p, boolean isSlimefunRecipe, ItemStack item) {
private static @Nonnull ItemStack getDisplayItem(Player p, boolean isSlimefunRecipe, ItemStack item) {
if (isSlimefunRecipe) {
SlimefunItem slimefunItem = SlimefunItem.getByItem(item);
@ -722,8 +727,7 @@ public class SurvivalSlimefunGuide implements SlimefunGuideImplementation {
return SlimefunPlugin.getPermissionsService().hasPermission(p, item);
}
@Nonnull
private ChestMenu create(@Nonnull Player p) {
private @Nonnull ChestMenu create(@Nonnull Player p) {
ChestMenu menu = new ChestMenu(SlimefunPlugin.getLocalization().getMessage(p, "guide.title.main"));
menu.setEmptySlotsClickable(false);