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

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
This commit is contained in:
AlexLander123 2019-10-18 21:27:28 +08:00
parent 2ff2355bb2
commit 1dc669740c

View File

@ -432,11 +432,28 @@ public final class SlimefunGuide {
} }
} }
if (locked) { if (!locked) {
// Dont display that Category... if (!(category instanceof LockedCategory)) {
} if (!(category instanceof SeasonalCategory)) {
else if (!(category instanceof LockedCategory)) { menu.addItem(index, category.getItem());
if (!(category instanceof SeasonalCategory)) { 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.addItem(index, category.getItem());
menu.addMenuClickHandler(index, (pl, slot, item, action) -> { menu.addMenuClickHandler(index, (pl, slot, item, action) -> {
openCategory(pl, category, survival, 1, book); openCategory(pl, category, survival, 1, book);
@ -445,38 +462,20 @@ public final class SlimefunGuide {
index++; index++;
} }
else { else {
if (((SeasonalCategory) category).isUnlocked()) { List<String> parents = new ArrayList<>();
menu.addItem(index, category.getItem()); parents.add("");
menu.addMenuClickHandler(index, (pl, slot, item, action) -> { parents.add(ChatColor.translateAlternateColorCodes('&', "&rYou need to unlock all Items"));
openCategory(pl, category, survival, 1, book); parents.add(ChatColor.translateAlternateColorCodes('&', "&rfrom the following Categories first:"));
return false; parents.add("");
});
index++; 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<String> 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()) { menu.addItem(index, new CustomItem(Material.BARRIER, "&4LOCKED &7- &r" + category.getItem().getItemMeta().getDisplayName(), parents.toArray(new String[0])));
parents.add(parent.getItem().getItemMeta().getDisplayName()); 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++;
} }
} }
} }