mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-19 19:25:48 +00:00
Merge pull request #3107 from martinbrom/fix/flex-category-visibility
FlexCategories can now be made visible in CheatSheet and Survival SlimefunGuide
This commit is contained in:
commit
0262830ef5
@ -77,12 +77,12 @@ public abstract class FlexCategory extends Category {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void add(SlimefunItem item) {
|
public final void add(@Nonnull SlimefunItem item) {
|
||||||
throw new UnsupportedOperationException("You cannot add items to a FlexCategory!");
|
throw new UnsupportedOperationException("You cannot add items to a FlexCategory!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final List<SlimefunItem> getItems() {
|
public final @Nonnull List<SlimefunItem> getItems() {
|
||||||
throw new UnsupportedOperationException("A FlexCategory has no items!");
|
throw new UnsupportedOperationException("A FlexCategory has no items!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,7 +92,7 @@ public abstract class FlexCategory extends Category {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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!");
|
throw new UnsupportedOperationException("A FlexCategory has no items, so there is nothing remove!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ public class MultiCategory extends FlexCategory {
|
|||||||
@Override
|
@Override
|
||||||
@ParametersAreNonnullByDefault
|
@ParametersAreNonnullByDefault
|
||||||
public boolean isVisible(Player p, PlayerProfile profile, SlimefunGuideMode mode) {
|
public boolean isVisible(Player p, PlayerProfile profile, SlimefunGuideMode mode) {
|
||||||
return true;
|
return mode == SlimefunGuideMode.SURVIVAL_MODE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -47,13 +47,12 @@ public class CheatSheetSlimefunGuide extends SurvivalSlimefunGuide {
|
|||||||
* The {@link PlayerProfile} of the {@link Player}
|
* The {@link PlayerProfile} of the {@link Player}
|
||||||
* @return a {@link List} of visible {@link Category} instances
|
* @return a {@link List} of visible {@link Category} instances
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
|
||||||
@Override
|
@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<>();
|
List<Category> categories = new LinkedList<>();
|
||||||
|
|
||||||
for (Category category : SlimefunPlugin.getRegistry().getCategories()) {
|
for (Category category : SlimefunPlugin.getRegistry().getCategories()) {
|
||||||
if (!(category instanceof FlexCategory)) {
|
if (!(category instanceof FlexCategory) || ((FlexCategory) category).isVisible(p, profile, getMode())) {
|
||||||
categories.add(category);
|
categories.add(category);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -61,15 +60,13 @@ public class CheatSheetSlimefunGuide extends SurvivalSlimefunGuide {
|
|||||||
return categories;
|
return categories;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
@Override
|
||||||
public SlimefunGuideMode getMode() {
|
public @Nonnull SlimefunGuideMode getMode() {
|
||||||
return SlimefunGuideMode.CHEAT_MODE;
|
return SlimefunGuideMode.CHEAT_MODE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getItem() {
|
public @Nonnull ItemStack getItem() {
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
|||||||
/**
|
/**
|
||||||
* The {@link SurvivalSlimefunGuide} is the standard version of our {@link SlimefunGuide}.
|
* The {@link SurvivalSlimefunGuide} is the standard version of our {@link SlimefunGuide}.
|
||||||
* It uses an {@link Inventory} to display {@link SlimefunGuide} contents.
|
* It uses an {@link Inventory} to display {@link SlimefunGuide} contents.
|
||||||
*
|
*
|
||||||
* @author TheBusyBiscuit
|
* @author TheBusyBiscuit
|
||||||
*
|
*
|
||||||
* @see SlimefunGuide
|
* @see SlimefunGuide
|
||||||
@ -83,18 +83,17 @@ public class SurvivalSlimefunGuide implements SlimefunGuideImplementation {
|
|||||||
*
|
*
|
||||||
* @return The {@link Sound}
|
* @return The {@link Sound}
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
public @Nonnull Sound getSound() {
|
||||||
public Sound getSound() {
|
|
||||||
return sound;
|
return sound;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SlimefunGuideMode getMode() {
|
public @Nonnull SlimefunGuideMode getMode() {
|
||||||
return SlimefunGuideMode.SURVIVAL_MODE;
|
return SlimefunGuideMode.SURVIVAL_MODE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getItem() {
|
public @Nonnull ItemStack getItem() {
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,13 +110,16 @@ public class SurvivalSlimefunGuide implements SlimefunGuideImplementation {
|
|||||||
* The {@link PlayerProfile} of the {@link Player}
|
* The {@link PlayerProfile} of the {@link Player}
|
||||||
* @return a {@link List} of visible {@link Category} instances
|
* @return a {@link List} of visible {@link Category} instances
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
protected @Nonnull List<Category> getVisibleCategories(@Nonnull Player p, @Nonnull PlayerProfile profile) {
|
||||||
protected List<Category> getVisibleCategories(@Nonnull Player p, @Nonnull PlayerProfile profile) {
|
|
||||||
List<Category> categories = new LinkedList<>();
|
List<Category> categories = new LinkedList<>();
|
||||||
|
|
||||||
for (Category category : SlimefunPlugin.getRegistry().getCategories()) {
|
for (Category category : SlimefunPlugin.getRegistry().getCategories()) {
|
||||||
try {
|
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);
|
categories.add(category);
|
||||||
}
|
}
|
||||||
} catch (Exception | LinkageError x) {
|
} catch (Exception | LinkageError x) {
|
||||||
@ -219,6 +221,7 @@ public class SurvivalSlimefunGuide implements SlimefunGuideImplementation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ParametersAreNonnullByDefault
|
||||||
public void openCategory(PlayerProfile profile, Category category, int page) {
|
public void openCategory(PlayerProfile profile, Category category, int page) {
|
||||||
Player p = profile.getPlayer();
|
Player p = profile.getPlayer();
|
||||||
|
|
||||||
@ -383,6 +386,7 @@ public class SurvivalSlimefunGuide implements SlimefunGuideImplementation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ParametersAreNonnullByDefault
|
||||||
public void displayItem(PlayerProfile profile, ItemStack item, int index, boolean addToHistory) {
|
public void displayItem(PlayerProfile profile, ItemStack item, int index, boolean addToHistory) {
|
||||||
Player p = profile.getPlayer();
|
Player p = profile.getPlayer();
|
||||||
|
|
||||||
@ -487,6 +491,7 @@ public class SurvivalSlimefunGuide implements SlimefunGuideImplementation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ParametersAreNonnullByDefault
|
||||||
public void displayItem(PlayerProfile profile, SlimefunItem item, boolean addToHistory) {
|
public void displayItem(PlayerProfile profile, SlimefunItem item, boolean addToHistory) {
|
||||||
Player p = profile.getPlayer();
|
Player p = profile.getPlayer();
|
||||||
|
|
||||||
@ -620,9 +625,8 @@ public class SurvivalSlimefunGuide implements SlimefunGuideImplementation {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@ParametersAreNonnullByDefault
|
@ParametersAreNonnullByDefault
|
||||||
private static ItemStack getDisplayItem(Player p, boolean isSlimefunRecipe, ItemStack item) {
|
private static @Nonnull ItemStack getDisplayItem(Player p, boolean isSlimefunRecipe, ItemStack item) {
|
||||||
if (isSlimefunRecipe) {
|
if (isSlimefunRecipe) {
|
||||||
SlimefunItem slimefunItem = SlimefunItem.getByItem(item);
|
SlimefunItem slimefunItem = SlimefunItem.getByItem(item);
|
||||||
|
|
||||||
@ -723,8 +727,7 @@ public class SurvivalSlimefunGuide implements SlimefunGuideImplementation {
|
|||||||
return SlimefunPlugin.getPermissionsService().hasPermission(p, item);
|
return SlimefunPlugin.getPermissionsService().hasPermission(p, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
private @Nonnull ChestMenu create(@Nonnull Player p) {
|
||||||
private ChestMenu create(@Nonnull Player p) {
|
|
||||||
ChestMenu menu = new ChestMenu(SlimefunPlugin.getLocalization().getMessage(p, "guide.title.main"));
|
ChestMenu menu = new ChestMenu(SlimefunPlugin.getLocalization().getMessage(p, "guide.title.main"));
|
||||||
|
|
||||||
menu.setEmptySlotsClickable(false);
|
menu.setEmptySlotsClickable(false);
|
||||||
|
Loading…
Reference in New Issue
Block a user