mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-19 19:25:48 +00:00
Removed "written book" slimefun guide and disabled elevators
This commit is contained in:
parent
93dc77b188
commit
7e48d96fa3
@ -35,6 +35,7 @@
|
|||||||
* Removed an old version of bStats
|
* Removed an old version of bStats
|
||||||
* CraftBukkit is officially no longer supported, Slimefun will now be disabled on old builds of CraftBukkit
|
* CraftBukkit is officially no longer supported, Slimefun will now be disabled on old builds of CraftBukkit
|
||||||
* Removed the deprecated ItemManipulationAPI for BlockMenus
|
* Removed the deprecated ItemManipulationAPI for BlockMenus
|
||||||
|
* Removed the "Written Book" variant of the Slimefun Guide
|
||||||
|
|
||||||
#### Fixes
|
#### Fixes
|
||||||
* Fixed a couple of compatibility issues with ItemsAdder
|
* Fixed a couple of compatibility issues with ItemsAdder
|
||||||
|
2
pom.xml
2
pom.xml
@ -336,7 +336,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.TheBusyBiscuit</groupId>
|
<groupId>com.github.TheBusyBiscuit</groupId>
|
||||||
<artifactId>CS-CoreLib2</artifactId>
|
<artifactId>CS-CoreLib2</artifactId>
|
||||||
<version>0.28</version>
|
<version>0.29</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -3,16 +3,16 @@ package io.github.thebusybiscuit.slimefun4.api.events;
|
|||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.ParametersAreNonnullByDefault;
|
import javax.annotation.ParametersAreNonnullByDefault;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.Validate;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.apache.commons.lang.Validate;
|
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.core.researching.Research;
|
import io.github.thebusybiscuit.slimefun4.core.researching.Research;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.guide.BookSlimefunGuide;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.guide.ChestSlimefunGuide;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.guide.CheatSheetSlimefunGuide;
|
import io.github.thebusybiscuit.slimefun4.implementation.guide.CheatSheetSlimefunGuide;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.implementation.guide.SurvivalSlimefunGuide;
|
||||||
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This {@link Event} is called whenever a {@link Player} clicks to unlock a {@link Research}.
|
* This {@link Event} is called whenever a {@link Player} clicks to unlock a {@link Research}.
|
||||||
@ -21,8 +21,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.guide.CheatSheetSlimefu
|
|||||||
*
|
*
|
||||||
* @author uiytt
|
* @author uiytt
|
||||||
*
|
*
|
||||||
* @see ChestSlimefunGuide
|
* @see SurvivalSlimefunGuide
|
||||||
* @see BookSlimefunGuide
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class PlayerPreResearchEvent extends Event implements Cancellable {
|
public class PlayerPreResearchEvent extends Event implements Cancellable {
|
||||||
|
@ -30,9 +30,8 @@ import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout;
|
|||||||
import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlock;
|
import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlock;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.researching.Research;
|
import io.github.thebusybiscuit.slimefun4.core.researching.Research;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.guide.BookSlimefunGuide;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.guide.CheatSheetSlimefunGuide;
|
import io.github.thebusybiscuit.slimefun4.implementation.guide.CheatSheetSlimefunGuide;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.guide.ChestSlimefunGuide;
|
import io.github.thebusybiscuit.slimefun4.implementation.guide.SurvivalSlimefunGuide;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunBlockHandler;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunBlockHandler;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||||
@ -98,9 +97,8 @@ public final class SlimefunRegistry {
|
|||||||
|
|
||||||
boolean showVanillaRecipes = cfg.getBoolean("guide.show-vanilla-recipes");
|
boolean showVanillaRecipes = cfg.getBoolean("guide.show-vanilla-recipes");
|
||||||
|
|
||||||
layouts.put(SlimefunGuideLayout.CHEST, new ChestSlimefunGuide(showVanillaRecipes));
|
layouts.put(SlimefunGuideLayout.SURVIVAL_MODE, new SurvivalSlimefunGuide(showVanillaRecipes));
|
||||||
layouts.put(SlimefunGuideLayout.CHEAT_SHEET, new CheatSheetSlimefunGuide());
|
layouts.put(SlimefunGuideLayout.CHEAT_MODE, new CheatSheetSlimefunGuide());
|
||||||
layouts.put(SlimefunGuideLayout.BOOK, new BookSlimefunGuide());
|
|
||||||
|
|
||||||
researchRanks.addAll(cfg.getStringList("research-ranks"));
|
researchRanks.addAll(cfg.getStringList("research-ranks"));
|
||||||
|
|
||||||
|
@ -19,8 +19,7 @@ class OpenGuideCommand extends SubCommand {
|
|||||||
public void onExecute(CommandSender sender, String[] args) {
|
public void onExecute(CommandSender sender, String[] args) {
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
if (sender.hasPermission("slimefun.command.open_guide")) {
|
if (sender.hasPermission("slimefun.command.open_guide")) {
|
||||||
boolean book = SlimefunPlugin.getCfg().getBoolean("guide.default-view-book");
|
SlimefunGuide.openGuide((Player) sender, SlimefunGuideLayout.SURVIVAL_MODE);
|
||||||
SlimefunGuide.openGuide((Player) sender, book ? SlimefunGuideLayout.BOOK : SlimefunGuideLayout.CHEST);
|
|
||||||
} else {
|
} else {
|
||||||
SlimefunPlugin.getLocalization().sendMessage(sender, "messages.no-permission", true);
|
SlimefunPlugin.getLocalization().sendMessage(sender, "messages.no-permission", true);
|
||||||
}
|
}
|
||||||
|
@ -3,14 +3,14 @@ package io.github.thebusybiscuit.slimefun4.core.guide;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
|
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.guide.BookSlimefunGuide;
|
import io.github.thebusybiscuit.slimefun4.implementation.guide.SurvivalSlimefunGuide;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.guide.ChestSlimefunGuide;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||||
@ -22,36 +22,35 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
|||||||
* @author TheBusyBiscuit
|
* @author TheBusyBiscuit
|
||||||
*
|
*
|
||||||
* @see SlimefunGuideImplementation
|
* @see SlimefunGuideImplementation
|
||||||
* @see ChestSlimefunGuide
|
* @see SurvivalSlimefunGuide
|
||||||
* @see BookSlimefunGuide
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public final class SlimefunGuide {
|
public final class SlimefunGuide {
|
||||||
|
|
||||||
private SlimefunGuide() {}
|
private SlimefunGuide() {}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
public static ItemStack getItem(@Nonnull SlimefunGuideLayout design) {
|
public static ItemStack getItem(@Nonnull SlimefunGuideLayout design) {
|
||||||
return SlimefunPlugin.getRegistry().getGuideLayout(design).getItem();
|
return SlimefunPlugin.getRegistry().getGuideLayout(design).getItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void openCheatMenu(Player p) {
|
public static void openCheatMenu(@Nonnull Player p) {
|
||||||
openMainMenuAsync(p, SlimefunGuideLayout.CHEAT_SHEET, 1);
|
openMainMenuAsync(p, SlimefunGuideLayout.CHEAT_MODE, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void openGuide(Player p, ItemStack guide) {
|
public static void openGuide(@Nonnull Player p, @Nullable ItemStack guide) {
|
||||||
if (SlimefunUtils.isItemSimilar(guide, getItem(SlimefunGuideLayout.CHEST), true)) {
|
if (SlimefunUtils.isItemSimilar(guide, getItem(SlimefunGuideLayout.CHEAT_MODE), true)) {
|
||||||
openGuide(p, SlimefunGuideLayout.CHEST);
|
openGuide(p, SlimefunGuideLayout.CHEAT_MODE);
|
||||||
} else if (SlimefunUtils.isItemSimilar(guide, getItem(SlimefunGuideLayout.BOOK), true)) {
|
|
||||||
openGuide(p, SlimefunGuideLayout.BOOK);
|
|
||||||
} else if (SlimefunUtils.isItemSimilar(guide, getItem(SlimefunGuideLayout.CHEAT_SHEET), true)) {
|
|
||||||
openGuide(p, SlimefunGuideLayout.CHEAT_SHEET);
|
|
||||||
} else {
|
} else {
|
||||||
// When using /sf cheat or /sf open_guide, ItemStack is null.
|
/*
|
||||||
openGuide(p, SlimefunGuideLayout.CHEST);
|
* When using /sf cheat or /sf open_guide the ItemStack is null anyway,
|
||||||
|
* so we don't even need to check here at this point.
|
||||||
|
*/
|
||||||
|
openGuide(p, SlimefunGuideLayout.SURVIVAL_MODE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void openGuide(Player p, SlimefunGuideLayout layout) {
|
public static void openGuide(@Nonnull Player p, @Nonnull SlimefunGuideLayout layout) {
|
||||||
if (!SlimefunPlugin.getWorldSettingsService().isWorldEnabled(p.getWorld())) {
|
if (!SlimefunPlugin.getWorldSettingsService().isWorldEnabled(p.getWorld())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -86,32 +85,29 @@ public final class SlimefunGuide {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void openSearch(PlayerProfile profile, String input, boolean survival, boolean addToHistory) {
|
public static void openSearch(PlayerProfile profile, String input, boolean survival, boolean addToHistory) {
|
||||||
SlimefunGuideImplementation layout = SlimefunPlugin.getRegistry().getGuideLayout(SlimefunGuideLayout.CHEST);
|
SlimefunGuideImplementation layout = SlimefunPlugin.getRegistry().getGuideLayout(SlimefunGuideLayout.SURVIVAL_MODE);
|
||||||
|
|
||||||
if (!survival) {
|
if (!survival) {
|
||||||
layout = SlimefunPlugin.getRegistry().getGuideLayout(SlimefunGuideLayout.CHEAT_SHEET);
|
layout = SlimefunPlugin.getRegistry().getGuideLayout(SlimefunGuideLayout.CHEAT_MODE);
|
||||||
}
|
}
|
||||||
|
|
||||||
layout.openSearch(profile, input, addToHistory);
|
layout.openSearch(profile, input, addToHistory);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void displayItem(PlayerProfile profile, ItemStack item, boolean addToHistory) {
|
public static void displayItem(PlayerProfile profile, ItemStack item, boolean addToHistory) {
|
||||||
SlimefunPlugin.getRegistry().getGuideLayout(SlimefunGuideLayout.CHEST).displayItem(profile, item, 0, addToHistory);
|
SlimefunPlugin.getRegistry().getGuideLayout(SlimefunGuideLayout.SURVIVAL_MODE).displayItem(profile, item, 0, addToHistory);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void displayItem(PlayerProfile profile, SlimefunItem item, boolean addToHistory) {
|
public static void displayItem(PlayerProfile profile, SlimefunItem item, boolean addToHistory) {
|
||||||
SlimefunPlugin.getRegistry().getGuideLayout(SlimefunGuideLayout.CHEST).displayItem(profile, item, addToHistory);
|
SlimefunPlugin.getRegistry().getGuideLayout(SlimefunGuideLayout.SURVIVAL_MODE).displayItem(profile, item, addToHistory);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isGuideItem(ItemStack item) {
|
public static boolean isGuideItem(@Nonnull ItemStack item) {
|
||||||
return SlimefunUtils.isItemSimilar(item, getItem(SlimefunGuideLayout.CHEST), true) || SlimefunUtils.isItemSimilar(item, getItem(SlimefunGuideLayout.BOOK), true) || SlimefunUtils.isItemSimilar(item, getItem(SlimefunGuideLayout.CHEAT_SHEET), true);
|
return SlimefunUtils.isItemSimilar(item, getItem(SlimefunGuideLayout.SURVIVAL_MODE), true) || SlimefunUtils.isItemSimilar(item, getItem(SlimefunGuideLayout.CHEAT_MODE), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
public static SlimefunGuideLayout getDefaultLayout() {
|
public static SlimefunGuideLayout getDefaultLayout() {
|
||||||
if (SlimefunPlugin.getCfg().getBoolean("guide.default-view-book")) {
|
return SlimefunGuideLayout.SURVIVAL_MODE;
|
||||||
return SlimefunGuideLayout.BOOK;
|
|
||||||
} else {
|
|
||||||
return SlimefunGuideLayout.CHEST;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,8 +11,7 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
|
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.researching.Research;
|
import io.github.thebusybiscuit.slimefun4.core.researching.Research;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.guide.BookSlimefunGuide;
|
import io.github.thebusybiscuit.slimefun4.implementation.guide.SurvivalSlimefunGuide;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.guide.ChestSlimefunGuide;
|
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||||
|
|
||||||
@ -23,8 +22,7 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
|||||||
* @author TheBusyBiscuit
|
* @author TheBusyBiscuit
|
||||||
*
|
*
|
||||||
* @see SlimefunGuideLayout
|
* @see SlimefunGuideLayout
|
||||||
* @see ChestSlimefunGuide
|
* @see SurvivalSlimefunGuide
|
||||||
* @see BookSlimefunGuide
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public interface SlimefunGuideImplementation {
|
public interface SlimefunGuideImplementation {
|
||||||
@ -54,7 +52,9 @@ public interface SlimefunGuideImplementation {
|
|||||||
*
|
*
|
||||||
* @return Whether this is a survival mode implementation
|
* @return Whether this is a survival mode implementation
|
||||||
*/
|
*/
|
||||||
boolean isSurvivalMode();
|
default boolean isSurvivalMode() {
|
||||||
|
return getLayout() != SlimefunGuideLayout.CHEAT_MODE;
|
||||||
|
}
|
||||||
|
|
||||||
void openMainMenu(PlayerProfile profile, int page);
|
void openMainMenu(PlayerProfile profile, int page);
|
||||||
|
|
||||||
|
@ -15,22 +15,15 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
|||||||
*/
|
*/
|
||||||
public enum SlimefunGuideLayout {
|
public enum SlimefunGuideLayout {
|
||||||
|
|
||||||
/**
|
|
||||||
* This design is a book representation of the {@link SlimefunGuide}
|
|
||||||
*/
|
|
||||||
BOOK,
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This design is the standard layout, it uses a {@link ChestMenu}
|
* This design is the standard layout, it uses a {@link ChestMenu}
|
||||||
*/
|
*/
|
||||||
CHEST,
|
SURVIVAL_MODE,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is an admin-only design which creates a {@link SlimefunGuide} that allows
|
* This is an admin-only design which creates a {@link SlimefunGuide} that allows
|
||||||
* you to spawn in any {@link SlimefunItem}
|
* you to spawn in any {@link SlimefunItem}
|
||||||
*/
|
*/
|
||||||
CHEAT_SHEET;
|
CHEAT_MODE;
|
||||||
|
|
||||||
public static final SlimefunGuideLayout[] valuesCache = values();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,8 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.NamespacedKey;
|
import org.bukkit.NamespacedKey;
|
||||||
@ -32,16 +34,19 @@ class GuideLayoutOption implements SlimefunGuideOption<SlimefunGuideLayout> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<ItemStack> getDisplayItem(Player p, ItemStack guide) {
|
public Optional<ItemStack> getDisplayItem(Player p, ItemStack guide) {
|
||||||
|
if (!p.hasPermission("slimefun.cheat.items")) {
|
||||||
|
// Only Players with the appropriate permission can access the cheat sheet
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
|
||||||
Optional<SlimefunGuideLayout> current = getSelectedOption(p, guide);
|
Optional<SlimefunGuideLayout> current = getSelectedOption(p, guide);
|
||||||
|
|
||||||
if (current.isPresent()) {
|
if (current.isPresent()) {
|
||||||
SlimefunGuideLayout layout = current.get();
|
SlimefunGuideLayout layout = current.get();
|
||||||
ItemStack item = new ItemStack(Material.AIR);
|
ItemStack item = new ItemStack(Material.AIR);
|
||||||
|
|
||||||
if (layout == SlimefunGuideLayout.CHEST) {
|
if (layout == SlimefunGuideLayout.SURVIVAL_MODE) {
|
||||||
item.setType(Material.CHEST);
|
item.setType(Material.CHEST);
|
||||||
} else if (layout == SlimefunGuideLayout.BOOK) {
|
|
||||||
item.setType(Material.BOOK);
|
|
||||||
} else {
|
} else {
|
||||||
item.setType(Material.COMMAND_BLOCK);
|
item.setType(Material.COMMAND_BLOCK);
|
||||||
}
|
}
|
||||||
@ -50,12 +55,9 @@ class GuideLayoutOption implements SlimefunGuideOption<SlimefunGuideLayout> {
|
|||||||
meta.setDisplayName(ChatColor.GRAY + "Slimefun Guide Design: " + ChatColor.YELLOW + ChatUtils.humanize(layout.name()));
|
meta.setDisplayName(ChatColor.GRAY + "Slimefun Guide Design: " + ChatColor.YELLOW + ChatUtils.humanize(layout.name()));
|
||||||
List<String> lore = new ArrayList<>();
|
List<String> lore = new ArrayList<>();
|
||||||
lore.add("");
|
lore.add("");
|
||||||
lore.add((layout == SlimefunGuideLayout.CHEST ? ChatColor.GREEN : ChatColor.GRAY) + "Chest");
|
lore.add((layout == SlimefunGuideLayout.SURVIVAL_MODE ? ChatColor.GREEN : ChatColor.GRAY) + "Chest");
|
||||||
lore.add((layout == SlimefunGuideLayout.BOOK ? ChatColor.GREEN : ChatColor.GRAY) + "Book");
|
|
||||||
|
|
||||||
if (p.hasPermission("slimefun.cheat.items")) {
|
lore.add((layout == SlimefunGuideLayout.CHEAT_MODE ? ChatColor.GREEN : ChatColor.GRAY) + "Cheat Sheet");
|
||||||
lore.add((layout == SlimefunGuideLayout.CHEAT_SHEET ? ChatColor.GREEN : ChatColor.GRAY) + "Cheat Sheet");
|
|
||||||
}
|
|
||||||
|
|
||||||
lore.add("");
|
lore.add("");
|
||||||
lore.add(ChatColor.GRAY + "\u21E8 " + ChatColor.YELLOW + "Click to change your layout");
|
lore.add(ChatColor.GRAY + "\u21E8 " + ChatColor.YELLOW + "Click to change your layout");
|
||||||
@ -80,33 +82,28 @@ class GuideLayoutOption implements SlimefunGuideOption<SlimefunGuideLayout> {
|
|||||||
SlimefunGuideSettings.openSettings(p, guide);
|
SlimefunGuideSettings.openSettings(p, guide);
|
||||||
}
|
}
|
||||||
|
|
||||||
private SlimefunGuideLayout getNextLayout(Player p, SlimefunGuideLayout layout) {
|
@Nonnull
|
||||||
|
private SlimefunGuideLayout getNextLayout(@Nonnull Player p, @Nonnull SlimefunGuideLayout layout) {
|
||||||
if (p.hasPermission("slimefun.cheat.items")) {
|
if (p.hasPermission("slimefun.cheat.items")) {
|
||||||
if (layout == SlimefunGuideLayout.CHEST) {
|
if (layout == SlimefunGuideLayout.SURVIVAL_MODE) {
|
||||||
return SlimefunGuideLayout.BOOK;
|
return SlimefunGuideLayout.CHEAT_MODE;
|
||||||
}
|
|
||||||
|
|
||||||
if (layout == SlimefunGuideLayout.BOOK) {
|
|
||||||
return SlimefunGuideLayout.CHEAT_SHEET;
|
|
||||||
}
|
|
||||||
|
|
||||||
return SlimefunGuideLayout.CHEST;
|
|
||||||
} else {
|
} else {
|
||||||
return layout == SlimefunGuideLayout.CHEST ? SlimefunGuideLayout.BOOK : SlimefunGuideLayout.CHEST;
|
return SlimefunGuideLayout.SURVIVAL_MODE;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return SlimefunGuideLayout.SURVIVAL_MODE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<SlimefunGuideLayout> getSelectedOption(Player p, ItemStack guide) {
|
public Optional<SlimefunGuideLayout> getSelectedOption(Player p, ItemStack guide) {
|
||||||
for (SlimefunGuideLayout layout : SlimefunGuideLayout.valuesCache) {
|
if (SlimefunUtils.isItemSimilar(guide, SlimefunGuide.getItem(SlimefunGuideLayout.CHEAT_MODE), true, false)) {
|
||||||
if (SlimefunUtils.isItemSimilar(guide, SlimefunGuide.getItem(layout), true, false)) {
|
return Optional.of(SlimefunGuideLayout.CHEAT_MODE);
|
||||||
return Optional.of(layout);
|
} else {
|
||||||
|
return Optional.of(SlimefunGuideLayout.SURVIVAL_MODE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSelectedOption(Player p, ItemStack guide, SlimefunGuideLayout value) {
|
public void setSelectedOption(Player p, ItemStack guide, SlimefunGuideLayout value) {
|
||||||
guide.setItemMeta(SlimefunGuide.getItem(value).getItemMeta());
|
guide.setItemMeta(SlimefunGuide.getItem(value).getItemMeta());
|
||||||
|
@ -65,7 +65,7 @@ public final class SlimefunGuideSettings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void addHeader(Player p, ChestMenu menu, ItemStack guide) {
|
private static void addHeader(Player p, ChestMenu menu, ItemStack guide) {
|
||||||
menu.addItem(0, new CustomItem(SlimefunGuide.getItem(SlimefunGuideLayout.CHEST), "&e\u21E6 " + SlimefunPlugin.getLocalization().getMessage(p, "guide.back.title"), "", "&7" + SlimefunPlugin.getLocalization().getMessage(p, "guide.back.guide")), (pl, slot, item, action) -> {
|
menu.addItem(0, new CustomItem(SlimefunGuide.getItem(SlimefunGuideLayout.SURVIVAL_MODE), "&e\u21E6 " + SlimefunPlugin.getLocalization().getMessage(p, "guide.back.title"), "", "&7" + SlimefunPlugin.getLocalization().getMessage(p, "guide.back.guide")), (pl, slot, item, action) -> {
|
||||||
SlimefunGuide.openGuide(pl, guide);
|
SlimefunGuide.openGuide(pl, guide);
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
@ -141,7 +141,7 @@ public final class SlimefunGuideSettings {
|
|||||||
for (SlimefunGuideOption<?> option : options) {
|
for (SlimefunGuideOption<?> option : options) {
|
||||||
if (option instanceof FireworksOption) {
|
if (option instanceof FireworksOption) {
|
||||||
FireworksOption fireworks = (FireworksOption) option;
|
FireworksOption fireworks = (FireworksOption) option;
|
||||||
return fireworks.getSelectedOption(p, SlimefunGuide.getItem(SlimefunGuideLayout.CHEST)).orElse(true);
|
return fireworks.getSelectedOption(p, SlimefunGuide.getItem(SlimefunGuideLayout.SURVIVAL_MODE)).orElse(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,14 +20,14 @@ import org.bukkit.plugin.Plugin;
|
|||||||
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.recipes.MinecraftRecipe;
|
import io.github.thebusybiscuit.cscorelib2.recipes.MinecraftRecipe;
|
||||||
import io.github.thebusybiscuit.cscorelib2.recipes.RecipeSnapshot;
|
import io.github.thebusybiscuit.cscorelib2.recipes.RecipeSnapshot;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.guide.ChestSlimefunGuide;
|
import io.github.thebusybiscuit.slimefun4.implementation.guide.SurvivalSlimefunGuide;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This Service is responsible for accessing a {@link RecipeSnapshot}.
|
* This Service is responsible for accessing a {@link RecipeSnapshot}.
|
||||||
* This snapshot contains a compiled list of all recipes that could be found on the
|
* This snapshot contains a compiled list of all recipes that could be found on the
|
||||||
* Server at the time the Service was loaded.
|
* Server at the time the Service was loaded.
|
||||||
*
|
*
|
||||||
* This Service is primarily used by the {@link ChestSlimefunGuide}.
|
* This Service is primarily used by the {@link SurvivalSlimefunGuide}.
|
||||||
*
|
*
|
||||||
* @author TheBusyBiscuit
|
* @author TheBusyBiscuit
|
||||||
*
|
*
|
||||||
|
@ -203,7 +203,6 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
|
|||||||
if (minecraftVersion == MinecraftVersion.UNIT_TEST) {
|
if (minecraftVersion == MinecraftVersion.UNIT_TEST) {
|
||||||
// We handle Unit Tests seperately.
|
// We handle Unit Tests seperately.
|
||||||
setInstance(this);
|
setInstance(this);
|
||||||
getLogger().log(Level.INFO, "This is a UNIT TEST Environment.");
|
|
||||||
onUnitTestStart();
|
onUnitTestStart();
|
||||||
} else if (isVersionUnsupported()) {
|
} else if (isVersionUnsupported()) {
|
||||||
// We wanna ensure that the Server uses a compatible version of Minecraft.
|
// We wanna ensure that the Server uses a compatible version of Minecraft.
|
||||||
|
@ -1,253 +0,0 @@
|
|||||||
package io.github.thebusybiscuit.slimefun4.implementation.guide;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.NamespacedKey;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.inventory.Inventory;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.chat.ChatColors;
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.chat.ChatInput;
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.chat.json.ChatComponent;
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.chat.json.ClickEvent;
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.chat.json.CustomBookInterface;
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.chat.json.HoverEvent;
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.core.categories.FlexCategory;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.core.categories.LockedCategory;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideImplementation;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.core.researching.Research;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.ChatUtils;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.itemstack.SlimefunGuideItem;
|
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
|
||||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@link BookSlimefunGuide} is a {@link SlimefunGuideImplementation} which
|
|
||||||
* uses a {@link CustomBookInterface} to display the contents of the {@link SlimefunGuide}.
|
|
||||||
* {@link Player Players} have the option to choose this Written Book layout over the
|
|
||||||
* standard {@link Inventory} variant.
|
|
||||||
*
|
|
||||||
* @author TheBusyBiscuit
|
|
||||||
*
|
|
||||||
* @see SlimefunGuide
|
|
||||||
* @see SlimefunGuideImplementation
|
|
||||||
* @see ChestSlimefunGuide
|
|
||||||
* @see CheatSheetSlimefunGuide
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class BookSlimefunGuide implements SlimefunGuideImplementation {
|
|
||||||
|
|
||||||
private final NamespacedKey guideSearch = new NamespacedKey(SlimefunPlugin.instance(), "search");
|
|
||||||
private final ItemStack item;
|
|
||||||
|
|
||||||
public BookSlimefunGuide() {
|
|
||||||
item = new SlimefunGuideItem(this, "&aSlimefun Guide &7(Book GUI)");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public SlimefunGuideLayout getLayout() {
|
|
||||||
return SlimefunGuideLayout.BOOK;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isSurvivalMode() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack getItem() {
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void openBook(Player p, PlayerProfile profile, List<ChatComponent> lines, boolean backButton) {
|
|
||||||
CustomBookInterface book = new CustomBookInterface(SlimefunPlugin.instance());
|
|
||||||
book.setTitle(SlimefunPlugin.getLocalization().getMessage(p, "guide.title.main"));
|
|
||||||
|
|
||||||
for (int i = 0; i < lines.size(); i = i + 10) {
|
|
||||||
ChatComponent page = new ChatComponent("");
|
|
||||||
ChatComponent header = new ChatComponent(ChatColors.color("&b&l- " + SlimefunPlugin.getLocalization().getMessage(p, "guide.title.main") + " -\n\n"));
|
|
||||||
header.setHoverEvent(new HoverEvent(ChestMenuUtils.getSearchButton(p)));
|
|
||||||
|
|
||||||
header.setClickEvent(new ClickEvent(guideSearch, player -> SlimefunPlugin.runSync(() -> {
|
|
||||||
SlimefunPlugin.getLocalization().sendMessage(player, "guide.search.message");
|
|
||||||
ChatInput.waitForPlayer(SlimefunPlugin.instance(), player, msg -> SlimefunGuide.openSearch(profile, msg, true, true));
|
|
||||||
}, 1)));
|
|
||||||
|
|
||||||
page.append(header);
|
|
||||||
|
|
||||||
for (int j = i; j < lines.size() && j < i + 10; j++) {
|
|
||||||
page.append(lines.get(j));
|
|
||||||
}
|
|
||||||
|
|
||||||
page.append(new ChatComponent("\n"));
|
|
||||||
|
|
||||||
if (backButton) {
|
|
||||||
ChatComponent button = new ChatComponent(ChatColor.DARK_BLUE + "\u21E6 " + SlimefunPlugin.getLocalization().getMessage(p, "guide.back.title"));
|
|
||||||
button.setHoverEvent(new HoverEvent(ChatColor.DARK_BLUE + "\u21E6 " + SlimefunPlugin.getLocalization().getMessage(p, "guide.back.title"), "", ChatColor.GRAY + SlimefunPlugin.getLocalization().getMessage(p, "guide.back.guide")));
|
|
||||||
button.setClickEvent(new ClickEvent(new NamespacedKey(SlimefunPlugin.instance(), "slimefun_guide"), pl -> openMainMenu(profile, 1)));
|
|
||||||
page.append(button);
|
|
||||||
}
|
|
||||||
|
|
||||||
book.addPage(page);
|
|
||||||
}
|
|
||||||
|
|
||||||
book.open(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void openMainMenu(PlayerProfile profile, int page) {
|
|
||||||
Player p = profile.getPlayer();
|
|
||||||
|
|
||||||
if (p == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<ChatComponent> lines = new LinkedList<>();
|
|
||||||
int tier = 0;
|
|
||||||
|
|
||||||
for (Category category : SlimefunPlugin.getRegistry().getCategories()) {
|
|
||||||
if (!category.isHidden(p) && (!(category instanceof FlexCategory) || ((FlexCategory) category).isVisible(p, profile, getLayout()))) {
|
|
||||||
if (tier < category.getTier()) {
|
|
||||||
tier = category.getTier();
|
|
||||||
|
|
||||||
if (tier > 1) {
|
|
||||||
for (int i = 0; i < 10 && lines.size() % 10 != 0; i++) {
|
|
||||||
lines.add(new ChatComponent("\n"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
lines.add(new ChatComponent(ChatColor.DARK_GRAY + "\u21E8" + ChatColor.DARK_BLUE + " Tier " + tier + "\n"));
|
|
||||||
}
|
|
||||||
|
|
||||||
addCategory(p, profile, category, lines);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
openBook(p, profile, lines, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addCategory(Player p, PlayerProfile profile, Category category, List<ChatComponent> lines) {
|
|
||||||
if (category instanceof LockedCategory && !((LockedCategory) category).hasUnlocked(p, profile)) {
|
|
||||||
List<String> lore = new LinkedList<>();
|
|
||||||
lore.add(ChatColor.DARK_RED + SlimefunPlugin.getLocalization().getMessage(p, "guide.locked") + " " + ChatColor.GRAY + "- " + ChatColor.RESET + category.getItem(p).getItemMeta().getDisplayName());
|
|
||||||
lore.add("");
|
|
||||||
|
|
||||||
for (String line : SlimefunPlugin.getLocalization().getMessages(p, "guide.locked-category")) {
|
|
||||||
lore.add(ChatColor.RESET + line);
|
|
||||||
}
|
|
||||||
|
|
||||||
lore.add("");
|
|
||||||
|
|
||||||
for (Category parent : ((LockedCategory) category).getParents()) {
|
|
||||||
lore.add(parent.getItem(p).getItemMeta().getDisplayName());
|
|
||||||
}
|
|
||||||
|
|
||||||
ChatComponent chatComponent = new ChatComponent(ChatUtils.crop(ChatColor.RED, ItemUtils.getItemName(category.getItem(p))) + "\n");
|
|
||||||
chatComponent.setHoverEvent(new HoverEvent(lore));
|
|
||||||
lines.add(chatComponent);
|
|
||||||
} else {
|
|
||||||
ChatComponent chatComponent = new ChatComponent(ChatUtils.crop(ChatColor.DARK_GREEN, ItemUtils.getItemName(category.getItem(p))) + "\n");
|
|
||||||
chatComponent.setHoverEvent(new HoverEvent(ItemUtils.getItemName(category.getItem(p)), "", ChatColor.GRAY + "\u21E8 " + ChatColor.GREEN + SlimefunPlugin.getLocalization().getMessage(p, "guide.tooltips.open-category")));
|
|
||||||
chatComponent.setClickEvent(new ClickEvent(category.getKey(), pl -> openCategory(profile, category, 1)));
|
|
||||||
lines.add(chatComponent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void openCategory(PlayerProfile profile, Category category, int page) {
|
|
||||||
Player p = profile.getPlayer();
|
|
||||||
|
|
||||||
if (p == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (category instanceof FlexCategory) {
|
|
||||||
((FlexCategory) category).open(p, profile, getLayout());
|
|
||||||
} else if (category.getItems().size() < 250) {
|
|
||||||
profile.getGuideHistory().add(category, page);
|
|
||||||
|
|
||||||
List<ChatComponent> items = new LinkedList<>();
|
|
||||||
|
|
||||||
for (SlimefunItem slimefunItem : category.getItems()) {
|
|
||||||
if (Slimefun.hasPermission(p, slimefunItem, false)) {
|
|
||||||
if (Slimefun.isEnabled(p, slimefunItem, false)) {
|
|
||||||
addSlimefunItem(category, page, p, profile, slimefunItem, items);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ChatComponent component = new ChatComponent(ChatUtils.crop(ChatColor.DARK_RED, ItemUtils.getItemName(slimefunItem.getItem())) + "\n");
|
|
||||||
|
|
||||||
List<String> lore = new ArrayList<>();
|
|
||||||
lore.add(ChatColor.DARK_RED + ChatColor.stripColor(ItemUtils.getItemName(slimefunItem.getItem())));
|
|
||||||
lore.add("");
|
|
||||||
|
|
||||||
for (String line : SlimefunPlugin.getPermissionsService().getLore(slimefunItem)) {
|
|
||||||
lore.add(ChatColors.color(line));
|
|
||||||
}
|
|
||||||
|
|
||||||
component.setHoverEvent(new HoverEvent(lore));
|
|
||||||
items.add(component);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
openBook(p, profile, items, true);
|
|
||||||
} else {
|
|
||||||
p.sendMessage(ChatColor.RED + "That Category is too big to open :/");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addSlimefunItem(Category category, int page, Player p, PlayerProfile profile, SlimefunItem item, List<ChatComponent> items) {
|
|
||||||
NamespacedKey key = new NamespacedKey(SlimefunPlugin.instance(), item.getId().toLowerCase(Locale.ROOT));
|
|
||||||
|
|
||||||
if (!Slimefun.hasUnlocked(p, item, false) && item.getResearch() != null) {
|
|
||||||
Research research = item.getResearch();
|
|
||||||
|
|
||||||
ChatComponent component = new ChatComponent(ChatUtils.crop(ChatColor.RED, item.getItemName()) + "\n");
|
|
||||||
component.setHoverEvent(new HoverEvent(ChatColor.RESET + item.getItemName(), ChatColor.DARK_RED.toString() + ChatColor.BOLD + SlimefunPlugin.getLocalization().getMessage(p, "guide.locked"), "", ChatColor.GREEN + "> Click to unlock", "", ChatColor.GRAY + "Cost: " + ChatColor.AQUA.toString() + research.getCost() + " Level(s)"));
|
|
||||||
component.setClickEvent(new ClickEvent(key, player -> SlimefunPlugin.runSync(() -> research.unlockFromGuide(this, player, profile, item, category, page))));
|
|
||||||
|
|
||||||
items.add(component);
|
|
||||||
} else {
|
|
||||||
ChatComponent component = new ChatComponent(ChatUtils.crop(ChatColor.DARK_GREEN, item.getItemName()) + "\n");
|
|
||||||
|
|
||||||
List<String> lore = new ArrayList<>();
|
|
||||||
lore.add(item.getItemName());
|
|
||||||
|
|
||||||
if (item.getItem().hasItemMeta() && item.getItem().getItemMeta().hasLore()) {
|
|
||||||
lore.addAll(item.getItem().getItemMeta().getLore());
|
|
||||||
}
|
|
||||||
|
|
||||||
component.setHoverEvent(new HoverEvent(lore));
|
|
||||||
component.setClickEvent(new ClickEvent(key, player -> SlimefunPlugin.runSync(() -> displayItem(profile, item, true))));
|
|
||||||
items.add(component);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void openSearch(PlayerProfile profile, String input, boolean addToHistory) {
|
|
||||||
// We need to write a book implementation for this at some point
|
|
||||||
SlimefunGuide.openSearch(profile, input, true, addToHistory);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void displayItem(PlayerProfile profile, ItemStack item, int index, boolean addToHistory) {
|
|
||||||
SlimefunGuide.displayItem(profile, item, addToHistory);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void displayItem(PlayerProfile profile, SlimefunItem item, boolean addToHistory) {
|
|
||||||
SlimefunGuide.displayItem(profile, item, addToHistory);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -21,13 +21,13 @@ import me.mrCookieSlime.Slimefun.Objects.Category;
|
|||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is an admin-variant of the {@link ChestSlimefunGuide} which allows a {@link Player}
|
* This is an admin-variant of the {@link SurvivalSlimefunGuide} which allows a {@link Player}
|
||||||
* to spawn in a {@link SlimefunItem} via click rather than showing their {@link Recipe}.
|
* to spawn in a {@link SlimefunItem} via click rather than showing their {@link Recipe}.
|
||||||
*
|
*
|
||||||
* @author TheBusyBiscuit
|
* @author TheBusyBiscuit
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class CheatSheetSlimefunGuide extends ChestSlimefunGuide {
|
public class CheatSheetSlimefunGuide extends SurvivalSlimefunGuide {
|
||||||
|
|
||||||
private final ItemStack item;
|
private final ItemStack item;
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ public class CheatSheetSlimefunGuide extends ChestSlimefunGuide {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SlimefunGuideLayout getLayout() {
|
public SlimefunGuideLayout getLayout() {
|
||||||
return SlimefunGuideLayout.CHEAT_SHEET;
|
return SlimefunGuideLayout.CHEAT_MODE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -21,7 +21,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
|||||||
* A {@link RecipeChoiceTask} is an asynchronously repeating task that cycles
|
* A {@link RecipeChoiceTask} is an asynchronously repeating task that cycles
|
||||||
* through the different variants of {@link Material} that a {@link MaterialChoice} or {@link Tag} can represent.
|
* through the different variants of {@link Material} that a {@link MaterialChoice} or {@link Tag} can represent.
|
||||||
*
|
*
|
||||||
* It is used in the {@link ChestSlimefunGuide} for any {@link ItemStack} from Minecraft
|
* It is used in the {@link SurvivalSlimefunGuide} for any {@link ItemStack} from Minecraft
|
||||||
* that accepts more than one {@link Material} in its {@link Recipe}.
|
* that accepts more than one {@link Material} in its {@link Recipe}.
|
||||||
*
|
*
|
||||||
* @author TheBusyBiscuit
|
* @author TheBusyBiscuit
|
||||||
|
@ -51,18 +51,17 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
|||||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link ChestSlimefunGuide} 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
|
||||||
* @see SlimefunGuideImplementation
|
* @see SlimefunGuideImplementation
|
||||||
* @see BookSlimefunGuide
|
|
||||||
* @see CheatSheetSlimefunGuide
|
* @see CheatSheetSlimefunGuide
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class ChestSlimefunGuide implements SlimefunGuideImplementation {
|
public class SurvivalSlimefunGuide implements SlimefunGuideImplementation {
|
||||||
|
|
||||||
private static final int CATEGORY_SIZE = 36;
|
private static final int CATEGORY_SIZE = 36;
|
||||||
private static final Sound sound = Sound.ITEM_BOOK_PAGE_TURN;
|
private static final Sound sound = Sound.ITEM_BOOK_PAGE_TURN;
|
||||||
@ -71,14 +70,14 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation {
|
|||||||
private final ItemStack item;
|
private final ItemStack item;
|
||||||
private final boolean showVanillaRecipes;
|
private final boolean showVanillaRecipes;
|
||||||
|
|
||||||
public ChestSlimefunGuide(boolean showVanillaRecipes) {
|
public SurvivalSlimefunGuide(boolean showVanillaRecipes) {
|
||||||
this.showVanillaRecipes = showVanillaRecipes;
|
this.showVanillaRecipes = showVanillaRecipes;
|
||||||
item = new SlimefunGuideItem(this, "&aSlimefun Guide &7(Chest GUI)");
|
item = new SlimefunGuideItem(this, "&aSlimefun Guide &7(Chest GUI)");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SlimefunGuideLayout getLayout() {
|
public SlimefunGuideLayout getLayout() {
|
||||||
return SlimefunGuideLayout.CHEST;
|
return SlimefunGuideLayout.SURVIVAL_MODE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
@ -12,17 +12,12 @@ import javax.annotation.ParametersAreNonnullByDefault;
|
|||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.NamespacedKey;
|
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.chat.ChatColors;
|
import io.github.thebusybiscuit.cscorelib2.chat.ChatColors;
|
||||||
import io.github.thebusybiscuit.cscorelib2.chat.json.ChatComponent;
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.chat.json.ClickEvent;
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.chat.json.CustomBookInterface;
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.chat.json.HoverEvent;
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.handlers.BlockPlaceHandler;
|
import io.github.thebusybiscuit.slimefun4.core.handlers.BlockPlaceHandler;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler;
|
import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler;
|
||||||
@ -125,39 +120,46 @@ public class ElevatorPlate extends SimpleSlimefunItem<BlockUseHandler> {
|
|||||||
|
|
||||||
@ParametersAreNonnullByDefault
|
@ParametersAreNonnullByDefault
|
||||||
private void openFloorSelector(Block b, List<Block> floors, Player p) {
|
private void openFloorSelector(Block b, List<Block> floors, Player p) {
|
||||||
CustomBookInterface book = new CustomBookInterface(SlimefunPlugin.instance());
|
p.sendMessage(ChatColor.DARK_RED + "Slimefun > " + ChatColor.RED + "Due to some issues, the elevator plate is temporarily disabled. It will be re-enabled soon, once the issue has been resolved.");
|
||||||
ChatComponent page = null;
|
// TODO: Re-implement the Elevator plate
|
||||||
|
// CustomBookInterface book = new CustomBookInterface(SlimefunPlugin.instance());
|
||||||
for (int i = 0; i < floors.size(); i++) {
|
// ChatComponent page = null;
|
||||||
if (i % 10 == 0) {
|
//
|
||||||
if (page != null) {
|
// for (int i = 0; i < floors.size(); i++) {
|
||||||
book.addPage(page);
|
// if (i % 10 == 0) {
|
||||||
}
|
// if (page != null) {
|
||||||
|
// book.addPage(page);
|
||||||
page = new ChatComponent(ChatColors.color(SlimefunPlugin.getLocalization().getMessage(p, "machines.ELEVATOR.pick-a-floor")) + "\n");
|
// }
|
||||||
}
|
//
|
||||||
|
// page = new ChatComponent(ChatColors.color(SlimefunPlugin.getLocalization().getMessage(p,
|
||||||
Block block = floors.get(i);
|
// "machines.ELEVATOR.pick-a-floor")) + "\n");
|
||||||
String floor = ChatColors.color(BlockStorage.getLocationInfo(block.getLocation(), DATA_KEY));
|
// }
|
||||||
ChatComponent line;
|
//
|
||||||
|
// Block block = floors.get(i);
|
||||||
if (block.getY() == b.getY()) {
|
// String floor = ChatColors.color(BlockStorage.getLocationInfo(block.getLocation(), DATA_KEY));
|
||||||
line = new ChatComponent("\n" + ChatColor.GRAY + "> " + (floors.size() - i) + ". " + ChatColor.BLACK + floor);
|
// ChatComponent line;
|
||||||
line.setHoverEvent(new HoverEvent(ChatColors.color(SlimefunPlugin.getLocalization().getMessage(p, "machines.ELEVATOR.current-floor")), "", ChatColor.WHITE + floor, ""));
|
//
|
||||||
} else {
|
// if (block.getY() == b.getY()) {
|
||||||
line = new ChatComponent("\n" + ChatColor.GRAY + (floors.size() - i) + ". " + ChatColor.BLACK + floor);
|
// line = new ChatComponent("\n" + ChatColor.GRAY + "> " + (floors.size() - i) + ". " + ChatColor.BLACK +
|
||||||
line.setHoverEvent(new HoverEvent(ChatColors.color(SlimefunPlugin.getLocalization().getMessage(p, "machines.ELEVATOR.click-to-teleport")), "", ChatColor.WHITE + floor, ""));
|
// floor);
|
||||||
line.setClickEvent(new ClickEvent(new NamespacedKey(SlimefunPlugin.instance(), DATA_KEY + i), player -> teleport(player, floor, block)));
|
// line.setHoverEvent(new HoverEvent(ChatColors.color(SlimefunPlugin.getLocalization().getMessage(p,
|
||||||
}
|
// "machines.ELEVATOR.current-floor")), "", ChatColor.WHITE + floor, ""));
|
||||||
|
// } else {
|
||||||
page.append(line);
|
// line = new ChatComponent("\n" + ChatColor.GRAY + (floors.size() - i) + ". " + ChatColor.BLACK + floor);
|
||||||
}
|
// line.setHoverEvent(new HoverEvent(ChatColors.color(SlimefunPlugin.getLocalization().getMessage(p,
|
||||||
|
// "machines.ELEVATOR.click-to-teleport")), "", ChatColor.WHITE + floor, ""));
|
||||||
if (page != null) {
|
// line.setClickEvent(new ClickEvent(new NamespacedKey(SlimefunPlugin.instance(), DATA_KEY + i), player ->
|
||||||
book.addPage(page);
|
// teleport(player, floor, block)));
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
book.open(p);
|
// page.append(line);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (page != null) {
|
||||||
|
// book.addPage(page);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// book.open(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParametersAreNonnullByDefault
|
@ParametersAreNonnullByDefault
|
||||||
|
@ -12,8 +12,8 @@ import org.bukkit.event.Listener;
|
|||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import io.github.thebusybiscuit.slimefun4.api.events.SlimefunGuideOpenEvent;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent;
|
import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.api.events.SlimefunGuideOpenEvent;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
|
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout;
|
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.guide.options.SlimefunGuideSettings;
|
import io.github.thebusybiscuit.slimefun4.core.guide.options.SlimefunGuideSettings;
|
||||||
@ -47,24 +47,20 @@ public class SlimefunGuideListener implements Listener {
|
|||||||
public void onInteract(PlayerRightClickEvent e) {
|
public void onInteract(PlayerRightClickEvent e) {
|
||||||
Player p = e.getPlayer();
|
Player p = e.getPlayer();
|
||||||
|
|
||||||
if (tryOpenGuide(p, e, SlimefunGuideLayout.BOOK) == Result.ALLOW) {
|
if (tryOpenGuide(p, e, SlimefunGuideLayout.SURVIVAL_MODE) == Result.ALLOW) {
|
||||||
if (p.isSneaking()) {
|
if (p.isSneaking()) {
|
||||||
SlimefunGuideSettings.openSettings(p, e.getItem());
|
SlimefunGuideSettings.openSettings(p, e.getItem());
|
||||||
} else {
|
} else {
|
||||||
openGuide(p, e, SlimefunGuideLayout.BOOK);
|
openGuide(p, e, SlimefunGuideLayout.SURVIVAL_MODE);
|
||||||
}
|
}
|
||||||
} else if (tryOpenGuide(p, e, SlimefunGuideLayout.CHEST) == Result.ALLOW) {
|
} else if (tryOpenGuide(p, e, SlimefunGuideLayout.CHEAT_MODE) == Result.ALLOW) {
|
||||||
if (p.isSneaking()) {
|
if (p.isSneaking()) {
|
||||||
SlimefunGuideSettings.openSettings(p, e.getItem());
|
SlimefunGuideSettings.openSettings(p, e.getItem());
|
||||||
} else {
|
} else {
|
||||||
openGuide(p, e, SlimefunGuideLayout.CHEST);
|
/*
|
||||||
}
|
* We rather just run the command here, all
|
||||||
} else if (tryOpenGuide(p, e, SlimefunGuideLayout.CHEAT_SHEET) == Result.ALLOW) {
|
* necessary permission checks will be handled there.
|
||||||
if (p.isSneaking()) {
|
*/
|
||||||
SlimefunGuideSettings.openSettings(p, e.getItem());
|
|
||||||
} else {
|
|
||||||
// We rather just run the command here,
|
|
||||||
// all necessary permission checks will be handled there.
|
|
||||||
p.chat("/sf cheat");
|
p.chat("/sf cheat");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,6 @@ options:
|
|||||||
drop-excess-sf-give-items: false
|
drop-excess-sf-give-items: false
|
||||||
|
|
||||||
guide:
|
guide:
|
||||||
default-view-book: false
|
|
||||||
show-vanilla-recipes: true
|
show-vanilla-recipes: true
|
||||||
receive-on-first-join: true
|
receive-on-first-join: true
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ class TestGuideCommand {
|
|||||||
player.setOp(op);
|
player.setOp(op);
|
||||||
server.execute("slimefun", player, "guide").assertSucceeded();
|
server.execute("slimefun", player, "guide").assertSucceeded();
|
||||||
|
|
||||||
ItemStack guide = SlimefunGuide.getItem(SlimefunGuideLayout.CHEST);
|
ItemStack guide = SlimefunGuide.getItem(SlimefunGuideLayout.SURVIVAL_MODE);
|
||||||
Assertions.assertEquals(op, SlimefunUtils.containsSimilarItem(player.getInventory(), guide, true));
|
Assertions.assertEquals(op, SlimefunUtils.containsSimilarItem(player.getInventory(), guide, true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,36 +0,0 @@
|
|||||||
package io.github.thebusybiscuit.slimefun4.testing.tests.guide;
|
|
||||||
|
|
||||||
import org.junit.jupiter.api.AfterAll;
|
|
||||||
import org.junit.jupiter.api.Assertions;
|
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
|
||||||
import org.junit.jupiter.api.DisplayName;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
import be.seeseemelk.mockbukkit.MockBukkit;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.guide.ChestSlimefunGuide;
|
|
||||||
|
|
||||||
class TestChestSlimefunGuide {
|
|
||||||
|
|
||||||
@BeforeAll
|
|
||||||
public static void load() {
|
|
||||||
MockBukkit.mock();
|
|
||||||
MockBukkit.load(SlimefunPlugin.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterAll
|
|
||||||
public static void unload() {
|
|
||||||
MockBukkit.unmock();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@DisplayName("Test Getters for Chest Slimefun Guide")
|
|
||||||
void testBasicGetters() {
|
|
||||||
ChestSlimefunGuide guide = new ChestSlimefunGuide(false);
|
|
||||||
|
|
||||||
Assertions.assertEquals(SlimefunGuideLayout.CHEST, guide.getLayout());
|
|
||||||
Assertions.assertTrue(guide.isSurvivalMode());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -9,9 +9,9 @@ import org.junit.jupiter.api.Test;
|
|||||||
import be.seeseemelk.mockbukkit.MockBukkit;
|
import be.seeseemelk.mockbukkit.MockBukkit;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout;
|
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.guide.BookSlimefunGuide;
|
import io.github.thebusybiscuit.slimefun4.implementation.guide.SurvivalSlimefunGuide;
|
||||||
|
|
||||||
class TestBookSlimefunGuide {
|
class TestSurvivalSlimefunGuide {
|
||||||
|
|
||||||
@BeforeAll
|
@BeforeAll
|
||||||
public static void load() {
|
public static void load() {
|
||||||
@ -27,9 +27,9 @@ class TestBookSlimefunGuide {
|
|||||||
@Test
|
@Test
|
||||||
@DisplayName("Test Getters for Chest Slimefun Guide")
|
@DisplayName("Test Getters for Chest Slimefun Guide")
|
||||||
void testBasicGetters() {
|
void testBasicGetters() {
|
||||||
BookSlimefunGuide guide = new BookSlimefunGuide();
|
SurvivalSlimefunGuide guide = new SurvivalSlimefunGuide(false);
|
||||||
|
|
||||||
Assertions.assertEquals(SlimefunGuideLayout.BOOK, guide.getLayout());
|
Assertions.assertEquals(SlimefunGuideLayout.SURVIVAL_MODE, guide.getLayout());
|
||||||
Assertions.assertTrue(guide.isSurvivalMode());
|
Assertions.assertTrue(guide.isSurvivalMode());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user