diff --git a/CHANGELOG.md b/CHANGELOG.md index ee71c698a..cef92096f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -59,6 +59,7 @@ * Fixed #1570 * Fixed #1686 * Fixed #1648 +* Fixed #1397 ## Release Candidate 9 (07 Mar 2020) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/SlimefunRegistry.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/SlimefunRegistry.java index 27d5b6068..5e6bbb101 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/SlimefunRegistry.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/SlimefunRegistry.java @@ -19,6 +19,7 @@ import io.github.thebusybiscuit.slimefun4.api.geo.GEOResource; import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideImplementation; import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout; import io.github.thebusybiscuit.slimefun4.implementation.guide.BookSlimefunGuide; +import io.github.thebusybiscuit.slimefun4.implementation.guide.CheatSheetSlimefunGuide; import io.github.thebusybiscuit.slimefun4.implementation.guide.ChestSlimefunGuide; import me.mrCookieSlime.Slimefun.SlimefunPlugin; import me.mrCookieSlime.Slimefun.Objects.Category; @@ -81,9 +82,10 @@ public class SlimefunRegistry { private final Map automatedCraftingChamberRecipes = new HashMap<>(); public SlimefunRegistry() { - SlimefunGuideImplementation chestGuide = new ChestSlimefunGuide(SlimefunPlugin.getCfg().getBoolean("options.show-vanilla-recipes-in-guide")); - layouts.put(SlimefunGuideLayout.CHEST, chestGuide); - layouts.put(SlimefunGuideLayout.CHEAT_SHEET, chestGuide); + boolean showVanillaRecipes = SlimefunPlugin.getCfg().getBoolean("options.show-vanilla-recipes-in-guide"); + + layouts.put(SlimefunGuideLayout.CHEST, new ChestSlimefunGuide(showVanillaRecipes)); + layouts.put(SlimefunGuideLayout.CHEAT_SHEET, new CheatSheetSlimefunGuide(showVanillaRecipes)); layouts.put(SlimefunGuideLayout.BOOK, new BookSlimefunGuide()); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuide.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuide.java index 9eb75220a..bbbe12da0 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuide.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuide.java @@ -101,7 +101,9 @@ public final class SlimefunGuide { } private static void openMainMenuAsync(Player player, boolean survival, SlimefunGuideLayout layout, int selectedPage) { - if (!PlayerProfile.get(player, profile -> Slimefun.runSync(() -> openMainMenu(profile, layout, survival, selectedPage)))) SlimefunPlugin.getLocal().sendMessage(player, "messages.opening-guide"); + if (!PlayerProfile.get(player, profile -> Slimefun.runSync(() -> openMainMenu(profile, layout, survival, selectedPage)))) { + SlimefunPlugin.getLocal().sendMessage(player, "messages.opening-guide"); + } } public static void openMainMenu(PlayerProfile profile, SlimefunGuideLayout layout, boolean survival, int selectedPage) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/PermissionsService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/PermissionsService.java index 7f59c4a63..849e4e03e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/PermissionsService.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/PermissionsService.java @@ -31,7 +31,11 @@ public class PermissionsService { public void load() { config = new Config(plugin, "permissions.yml"); - config.getConfiguration().options().header("This file is used to assign permission nodes to items from Slimefun or any of its addons.\n" + "To assign an item a certain permission node you simply have to set the 'permission' attribute\n" + "to your desired permission node. You can also customize the text that is displayed when a Player does not have that permission."); + config.getConfiguration().options().header( + "This file is used to assign permission nodes to items from Slimefun or any of its addons.\n" + + "To assign an item a certain permission node you simply have to set the 'permission' attribute\n" + + "to your desired permission node. You can also customize the text that is displayed when a Player does not have that permission." + ); config.getConfiguration().options().copyHeader(true); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/CheatSheetSlimefunGuide.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/CheatSheetSlimefunGuide.java new file mode 100644 index 000000000..70f0c341b --- /dev/null +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/CheatSheetSlimefunGuide.java @@ -0,0 +1,15 @@ +package io.github.thebusybiscuit.slimefun4.implementation.guide; + +import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout; + +public class CheatSheetSlimefunGuide extends ChestSlimefunGuide { + + public CheatSheetSlimefunGuide(boolean showVanillaRecipes) { + super(showVanillaRecipes); + } + + @Override + public SlimefunGuideLayout getLayout() { + return SlimefunGuideLayout.CHEAT_SHEET; + } +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/ChestSlimefunGuide.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/ChestSlimefunGuide.java index 6db66690f..e193a12b7 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/ChestSlimefunGuide.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/ChestSlimefunGuide.java @@ -45,9 +45,9 @@ import me.mrCookieSlime.Slimefun.api.Slimefun; public class ChestSlimefunGuide implements SlimefunGuideImplementation { - private static final int[] RECIPE_SLOTS = { 3, 4, 5, 12, 13, 14, 21, 22, 23 }; private static final int CATEGORY_SIZE = 36; + private final int[] recipeSlots = { 3, 4, 5, 12, 13, 14, 21, 22, 23 }; private final boolean showVanillaRecipes; public ChestSlimefunGuide(boolean showVanillaRecipes) { @@ -81,7 +81,7 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation { int index = 9; int pages = (categories.size() + handlers.size() - 1) / CATEGORY_SIZE + 1; - fillInv(p, profile, menu, survival); + createHeader(p, profile, menu, survival); int target = (CATEGORY_SIZE * (page - 1)) - 1; @@ -147,11 +147,11 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation { else { List lore = new ArrayList<>(); lore.add(""); - + for (String line : SlimefunPlugin.getLocal().getMessages(p, "guide.locked-category")) { lore.add(ChatColor.RESET + line); } - + lore.add(""); for (Category parent : ((LockedCategory) category).getParents()) { @@ -174,7 +174,7 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation { } ChestMenu menu = create(p); - fillInv(p, profile, menu, survival); + createHeader(p, profile, menu, survival); menu.addItem(1, new CustomItem(ChestMenuUtils.getBackButton(p, "", ChatColor.GRAY + SlimefunPlugin.getLocal().getMessage(p, "guide.back.guide")))); menu.addMenuClickHandler(1, (pl, s, is, action) -> { @@ -288,7 +288,7 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation { } menu.setEmptySlotsClickable(false); - fillInv(p, profile, menu, survival); + createHeader(p, profile, menu, survival); addBackButton(menu, 1, p, profile, survival); int index = 9; @@ -379,7 +379,7 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation { recipeItems[4] = new ItemStack(((MaterialChoice) choices[0]).getChoices().get(0)); if (((MaterialChoice) choices[0]).getChoices().size() > 1) { - task.add(RECIPE_SLOTS[4], (MaterialChoice) choices[0]); + task.add(recipeSlots[4], (MaterialChoice) choices[0]); } } else { @@ -388,7 +388,7 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation { recipeItems[i] = new ItemStack(((MaterialChoice) choices[i]).getChoices().get(0)); if (((MaterialChoice) choices[i]).getChoices().size() > 1) { - task.add(RECIPE_SLOTS[i], (MaterialChoice) choices[i]); + task.add(recipeSlots[i], (MaterialChoice) choices[i]); } } } @@ -476,14 +476,14 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation { }; for (int i = 0; i < 9; i++) { - menu.addItem(RECIPE_SLOTS[i], getDisplayItem(p, isSlimefunRecipe, recipe[i]), clickHandler); + menu.addItem(recipeSlots[i], getDisplayItem(p, isSlimefunRecipe, recipe[i]), clickHandler); } menu.addItem(10, recipeType.getItem(p), ChestMenuUtils.getEmptyClickHandler()); menu.addItem(16, output, ChestMenuUtils.getEmptyClickHandler()); } - private void fillInv(Player p, PlayerProfile profile, ChestMenu menu, boolean survival) { + private void createHeader(Player p, PlayerProfile profile, ChestMenu menu, boolean survival) { for (int i = 0; i < 9; i++) { menu.addItem(i, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler()); } @@ -501,7 +501,7 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation { pl.closeInventory(); SlimefunPlugin.getLocal().sendMessage(pl, "guide.search.message"); - ChatInput.waitForPlayer(SlimefunPlugin.instance, pl, msg -> SlimefunGuide.openSearch(profile, msg, survival, true)); + ChatInput.waitForPlayer(SlimefunPlugin.instance, pl, msg -> SlimefunGuide.openSearch(profile, msg, survival, survival)); return false; }); @@ -514,8 +514,7 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation { private void addBackButton(ChestMenu menu, int slot, Player p, PlayerProfile profile, boolean survival) { List playerHistory = profile.getGuideHistory(); - if (playerHistory.size() > 1) { - + if (survival && playerHistory.size() > 1) { menu.addItem(slot, new CustomItem(ChestMenuUtils.getBackButton(p, "", "&rLeft Click: &7Go back to previous Page", "&rShift + left Click: &7Go back to Main Menu"))); menu.addMenuClickHandler(slot, (pl, s, is, action) -> { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Android.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Android.java index cb89b0349..913c55081 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Android.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Android.java @@ -237,10 +237,10 @@ abstract class Android extends SlimefunItem { String author = (op != null && op.getName() != null) ? op.getName() : script.getString("author_name"); if (script.getString("author").equals(p.getUniqueId().toString())) { - menu.addItem(index, new CustomItem(this.getItem(), "&b" + script.getString("name"), "&7by &r" + author, "", "&7Downloads: &r" + script.getInt("downloads"), "&7Rating: " + getScriptRatingPercentage(script), "&a" + getScriptRating(script, true) + " \u263A &7- &4\u2639 " + getScriptRating(script, false), "", "&eLeft Click &rto download this Script", "&4(This will override your current Script)")); + menu.addItem(index, new CustomItem(this.getItem(), "&b" + script.getString("name"), "&7by &r" + author, "", "&7Downloads: &r" + script.getInt("downloads"), "&7Rating: " + getScriptRatingPercentage(script), "&a" + getScriptRating(script, true) + " \u263A &7| &4\u2639 " + getScriptRating(script, false), "", "&eLeft Click &rto download this Script", "&4(This will override your current Script)")); } else { - menu.addItem(index, new CustomItem(this.getItem(), "&b" + script.getString("name"), "&7by &r" + author, "", "&7Downloads: &r" + script.getInt("downloads"), "&7Rating: " + getScriptRatingPercentage(script), "&a" + getScriptRating(script, true) + " \u263A &7- &4\u2639 " + getScriptRating(script, false), "", "&eLeft Click &rto download this Script", "&4(This will override your current Script)", "&eShift + Left Click &rto leave a positive Rating", "&eShift + Right Click &rto leave a negative Rating")); + menu.addItem(index, new CustomItem(this.getItem(), "&b" + script.getString("name"), "&7by &r" + author, "", "&7Downloads: &r" + script.getInt("downloads"), "&7Rating: " + getScriptRatingPercentage(script), "&a" + getScriptRating(script, true) + " \u263A &7| &4\u2639 " + getScriptRating(script, false), "", "&eLeft Click &rto download this Script", "&4(This will override your current Script)", "&eShift + Left Click &rto leave a positive Rating", "&eShift + Right Click &rto leave a negative Rating")); } menu.addMenuClickHandler(index, (pl, slot, item, action) -> { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ExplosivePickaxe.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ExplosivePickaxe.java index 24e1748f7..94d61a0fd 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ExplosivePickaxe.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ExplosivePickaxe.java @@ -38,12 +38,12 @@ public class ExplosivePickaxe extends SimpleSlimefunItem impl @Override public BlockBreakHandler getItemHandler() { return new BlockBreakHandler() { - + @Override public boolean isPrivate() { return false; } - + @Override public boolean onBlockBreak(BlockBreakEvent e, ItemStack item, int fortune, List drops) { if (isItem(item)) {