From 1dc669740cb1495facf49ae5ec33e211ec1b1868 Mon Sep 17 00:00:00 2001 From: AlexLander123 <13492360+AlexLander123@users.noreply.github.com> Date: Fri, 18 Oct 2019 21:27:28 +0800 Subject: [PATCH] Allow /sf cheat to have all categories unlocked - If the player who who is using /sf cheat have not unlocked the category, they will still have access to it - Removed empty code --- .../mrCookieSlime/Slimefun/SlimefunGuide.java | 67 +++++++++---------- 1 file changed, 33 insertions(+), 34 deletions(-) diff --git a/src/main/java/me/mrCookieSlime/Slimefun/SlimefunGuide.java b/src/main/java/me/mrCookieSlime/Slimefun/SlimefunGuide.java index 24dc96c9b..cc3eb0518 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/SlimefunGuide.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/SlimefunGuide.java @@ -432,11 +432,28 @@ public final class SlimefunGuide { } } - if (locked) { - // Dont display that Category... - } - else if (!(category instanceof LockedCategory)) { - if (!(category instanceof SeasonalCategory)) { + if (!locked) { + if (!(category instanceof LockedCategory)) { + if (!(category instanceof SeasonalCategory)) { + menu.addItem(index, category.getItem()); + menu.addMenuClickHandler(index, (pl, slot, item, action) -> { + openCategory(pl, category, survival, 1, book); + return false; + }); + index++; + } + else { + if (((SeasonalCategory) category).isUnlocked()) { + menu.addItem(index, category.getItem()); + menu.addMenuClickHandler(index, (pl, slot, item, action) -> { + openCategory(pl, category, survival, 1, book); + return false; + }); + index++; + } + } + } + else if (!survival || ((LockedCategory) category).hasUnlocked(p, profile)) { menu.addItem(index, category.getItem()); menu.addMenuClickHandler(index, (pl, slot, item, action) -> { openCategory(pl, category, survival, 1, book); @@ -445,38 +462,20 @@ public final class SlimefunGuide { index++; } else { - if (((SeasonalCategory) category).isUnlocked()) { - menu.addItem(index, category.getItem()); - menu.addMenuClickHandler(index, (pl, slot, item, action) -> { - openCategory(pl, category, survival, 1, book); - return false; - }); - index++; + List parents = new ArrayList<>(); + parents.add(""); + parents.add(ChatColor.translateAlternateColorCodes('&', "&rYou need to unlock all Items")); + parents.add(ChatColor.translateAlternateColorCodes('&', "&rfrom the following Categories first:")); + parents.add(""); + + for (Category parent : ((LockedCategory) category).getParents()) { + parents.add(parent.getItem().getItemMeta().getDisplayName()); } - } - } - else if (((LockedCategory) category).hasUnlocked(p, profile)) { - menu.addItem(index, category.getItem()); - menu.addMenuClickHandler(index, (pl, slot, item, action) -> { - openCategory(pl, category, survival, 1, book); - return false; - }); - index++; - } - else { - List parents = new ArrayList<>(); - parents.add(""); - parents.add(ChatColor.translateAlternateColorCodes('&', "&rYou need to unlock all Items")); - parents.add(ChatColor.translateAlternateColorCodes('&', "&rfrom the following Categories first:")); - parents.add(""); - for (Category parent : ((LockedCategory) category).getParents()) { - parents.add(parent.getItem().getItemMeta().getDisplayName()); + menu.addItem(index, new CustomItem(Material.BARRIER, "&4LOCKED &7- &r" + category.getItem().getItemMeta().getDisplayName(), parents.toArray(new String[0]))); + menu.addMenuClickHandler(index, (pl, slot, item, action) -> false); + index++; } - - menu.addItem(index, new CustomItem(Material.BARRIER, "&4LOCKED &7- &r" + category.getItem().getItemMeta().getDisplayName(), parents.toArray(new String[0]))); - menu.addMenuClickHandler(index, (pl, slot, item, action) -> false); - index++; } } }