1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-19 19:25:48 +00:00
This commit is contained in:
TheBusyBiscuit 2020-03-15 13:41:44 +01:00
parent 46003a1026
commit 8502c42128
8 changed files with 45 additions and 22 deletions

View File

@ -59,6 +59,7 @@
* Fixed #1570
* Fixed #1686
* Fixed #1648
* Fixed #1397
## Release Candidate 9 (07 Mar 2020)

View File

@ -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<String, ItemStack> 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());
}

View File

@ -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) {

View File

@ -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);
}

View File

@ -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;
}
}

View File

@ -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<String> 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<Object> 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) -> {

View File

@ -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) -> {

View File

@ -38,12 +38,12 @@ public class ExplosivePickaxe extends SimpleSlimefunItem<BlockBreakHandler> 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<ItemStack> drops) {
if (isItem(item)) {