diff --git a/CHANGELOG.md b/CHANGELOG.md
index eca85998d..be5acc363 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -35,6 +35,7 @@
* Removed an old version of bStats
* CraftBukkit is officially no longer supported, Slimefun will now be disabled on old builds of CraftBukkit
* Removed the deprecated ItemManipulationAPI for BlockMenus
+* Removed the "Written Book" variant of the Slimefun Guide
#### Fixes
* Fixed a couple of compatibility issues with ItemsAdder
diff --git a/pom.xml b/pom.xml
index 0b0c8f43a..dba2fecb3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -336,7 +336,7 @@
com.github.TheBusyBiscuit
CS-CoreLib2
- 0.28
+ 0.29
compile
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/PlayerPreResearchEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/PlayerPreResearchEvent.java
index d80efd9b1..9edcb48a0 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/PlayerPreResearchEvent.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/PlayerPreResearchEvent.java
@@ -3,16 +3,16 @@ package io.github.thebusybiscuit.slimefun4.api.events;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
+import org.apache.commons.lang.Validate;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
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.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.SurvivalSlimefunGuide;
+import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
/**
* 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
*
- * @see ChestSlimefunGuide
- * @see BookSlimefunGuide
+ * @see SurvivalSlimefunGuide
*
*/
public class PlayerPreResearchEvent extends Event implements Cancellable {
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 43cc9d4ae..a0f84107c 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/SlimefunRegistry.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/SlimefunRegistry.java
@@ -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.researching.Research;
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.ChestSlimefunGuide;
+import io.github.thebusybiscuit.slimefun4.implementation.guide.SurvivalSlimefunGuide;
import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.Objects.SlimefunBlockHandler;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
@@ -98,9 +97,8 @@ public final class SlimefunRegistry {
boolean showVanillaRecipes = cfg.getBoolean("guide.show-vanilla-recipes");
- layouts.put(SlimefunGuideLayout.CHEST, new ChestSlimefunGuide(showVanillaRecipes));
- layouts.put(SlimefunGuideLayout.CHEAT_SHEET, new CheatSheetSlimefunGuide());
- layouts.put(SlimefunGuideLayout.BOOK, new BookSlimefunGuide());
+ layouts.put(SlimefunGuideLayout.SURVIVAL_MODE, new SurvivalSlimefunGuide(showVanillaRecipes));
+ layouts.put(SlimefunGuideLayout.CHEAT_MODE, new CheatSheetSlimefunGuide());
researchRanks.addAll(cfg.getStringList("research-ranks"));
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/OpenGuideCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/OpenGuideCommand.java
index a4af9f2bd..14b1d1654 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/OpenGuideCommand.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/OpenGuideCommand.java
@@ -19,8 +19,7 @@ class OpenGuideCommand extends SubCommand {
public void onExecute(CommandSender sender, String[] args) {
if (sender instanceof Player) {
if (sender.hasPermission("slimefun.command.open_guide")) {
- boolean book = SlimefunPlugin.getCfg().getBoolean("guide.default-view-book");
- SlimefunGuide.openGuide((Player) sender, book ? SlimefunGuideLayout.BOOK : SlimefunGuideLayout.CHEST);
+ SlimefunGuide.openGuide((Player) sender, SlimefunGuideLayout.SURVIVAL_MODE);
} else {
SlimefunPlugin.getLocalization().sendMessage(sender, "messages.no-permission", true);
}
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 94970ac43..24fe06c4a 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
@@ -3,14 +3,14 @@ package io.github.thebusybiscuit.slimefun4.core.guide;
import java.util.Optional;
import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
-import io.github.thebusybiscuit.slimefun4.implementation.guide.BookSlimefunGuide;
-import io.github.thebusybiscuit.slimefun4.implementation.guide.ChestSlimefunGuide;
+import io.github.thebusybiscuit.slimefun4.implementation.guide.SurvivalSlimefunGuide;
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
@@ -22,36 +22,35 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
* @author TheBusyBiscuit
*
* @see SlimefunGuideImplementation
- * @see ChestSlimefunGuide
- * @see BookSlimefunGuide
+ * @see SurvivalSlimefunGuide
*
*/
public final class SlimefunGuide {
private SlimefunGuide() {}
+ @Nonnull
public static ItemStack getItem(@Nonnull SlimefunGuideLayout design) {
return SlimefunPlugin.getRegistry().getGuideLayout(design).getItem();
}
- public static void openCheatMenu(Player p) {
- openMainMenuAsync(p, SlimefunGuideLayout.CHEAT_SHEET, 1);
+ public static void openCheatMenu(@Nonnull Player p) {
+ openMainMenuAsync(p, SlimefunGuideLayout.CHEAT_MODE, 1);
}
- public static void openGuide(Player p, ItemStack guide) {
- if (SlimefunUtils.isItemSimilar(guide, getItem(SlimefunGuideLayout.CHEST), true)) {
- openGuide(p, SlimefunGuideLayout.CHEST);
- } 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);
+ public static void openGuide(@Nonnull Player p, @Nullable ItemStack guide) {
+ if (SlimefunUtils.isItemSimilar(guide, getItem(SlimefunGuideLayout.CHEAT_MODE), true)) {
+ openGuide(p, SlimefunGuideLayout.CHEAT_MODE);
} 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())) {
return;
}
@@ -86,32 +85,29 @@ public final class SlimefunGuide {
}
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) {
- layout = SlimefunPlugin.getRegistry().getGuideLayout(SlimefunGuideLayout.CHEAT_SHEET);
+ layout = SlimefunPlugin.getRegistry().getGuideLayout(SlimefunGuideLayout.CHEAT_MODE);
}
layout.openSearch(profile, input, 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) {
- 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) {
- return SlimefunUtils.isItemSimilar(item, getItem(SlimefunGuideLayout.CHEST), true) || SlimefunUtils.isItemSimilar(item, getItem(SlimefunGuideLayout.BOOK), true) || SlimefunUtils.isItemSimilar(item, getItem(SlimefunGuideLayout.CHEAT_SHEET), true);
+ public static boolean isGuideItem(@Nonnull ItemStack item) {
+ return SlimefunUtils.isItemSimilar(item, getItem(SlimefunGuideLayout.SURVIVAL_MODE), true) || SlimefunUtils.isItemSimilar(item, getItem(SlimefunGuideLayout.CHEAT_MODE), true);
}
+ @Nonnull
public static SlimefunGuideLayout getDefaultLayout() {
- if (SlimefunPlugin.getCfg().getBoolean("guide.default-view-book")) {
- return SlimefunGuideLayout.BOOK;
- } else {
- return SlimefunGuideLayout.CHEST;
- }
+ return SlimefunGuideLayout.SURVIVAL_MODE;
}
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuideImplementation.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuideImplementation.java
index 5ed728760..cfb851ac4 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuideImplementation.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuideImplementation.java
@@ -11,8 +11,7 @@ import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
import io.github.thebusybiscuit.slimefun4.core.researching.Research;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
-import io.github.thebusybiscuit.slimefun4.implementation.guide.BookSlimefunGuide;
-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.SlimefunItem.SlimefunItem;
@@ -23,8 +22,7 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
* @author TheBusyBiscuit
*
* @see SlimefunGuideLayout
- * @see ChestSlimefunGuide
- * @see BookSlimefunGuide
+ * @see SurvivalSlimefunGuide
*
*/
public interface SlimefunGuideImplementation {
@@ -54,7 +52,9 @@ public interface SlimefunGuideImplementation {
*
* @return Whether this is a survival mode implementation
*/
- boolean isSurvivalMode();
+ default boolean isSurvivalMode() {
+ return getLayout() != SlimefunGuideLayout.CHEAT_MODE;
+ }
void openMainMenu(PlayerProfile profile, int page);
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuideLayout.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuideLayout.java
index 562fe5981..a401e225b 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuideLayout.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuideLayout.java
@@ -15,22 +15,15 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
*/
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}
*/
- CHEST,
+ SURVIVAL_MODE,
/**
* This is an admin-only design which creates a {@link SlimefunGuide} that allows
* you to spawn in any {@link SlimefunItem}
*/
- CHEAT_SHEET;
-
- public static final SlimefunGuideLayout[] valuesCache = values();
+ CHEAT_MODE;
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/GuideLayoutOption.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/GuideLayoutOption.java
index 38564d077..b249163ab 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/GuideLayoutOption.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/GuideLayoutOption.java
@@ -4,6 +4,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
+import javax.annotation.Nonnull;
+
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
@@ -32,16 +34,19 @@ class GuideLayoutOption implements SlimefunGuideOption {
@Override
public Optional 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 current = getSelectedOption(p, guide);
if (current.isPresent()) {
SlimefunGuideLayout layout = current.get();
ItemStack item = new ItemStack(Material.AIR);
- if (layout == SlimefunGuideLayout.CHEST) {
+ if (layout == SlimefunGuideLayout.SURVIVAL_MODE) {
item.setType(Material.CHEST);
- } else if (layout == SlimefunGuideLayout.BOOK) {
- item.setType(Material.BOOK);
} else {
item.setType(Material.COMMAND_BLOCK);
}
@@ -50,12 +55,9 @@ class GuideLayoutOption implements SlimefunGuideOption {
meta.setDisplayName(ChatColor.GRAY + "Slimefun Guide Design: " + ChatColor.YELLOW + ChatUtils.humanize(layout.name()));
List lore = new ArrayList<>();
lore.add("");
- lore.add((layout == SlimefunGuideLayout.CHEST ? ChatColor.GREEN : ChatColor.GRAY) + "Chest");
- lore.add((layout == SlimefunGuideLayout.BOOK ? ChatColor.GREEN : ChatColor.GRAY) + "Book");
+ lore.add((layout == SlimefunGuideLayout.SURVIVAL_MODE ? ChatColor.GREEN : ChatColor.GRAY) + "Chest");
- if (p.hasPermission("slimefun.cheat.items")) {
- lore.add((layout == SlimefunGuideLayout.CHEAT_SHEET ? ChatColor.GREEN : ChatColor.GRAY) + "Cheat Sheet");
- }
+ lore.add((layout == SlimefunGuideLayout.CHEAT_MODE ? ChatColor.GREEN : ChatColor.GRAY) + "Cheat Sheet");
lore.add("");
lore.add(ChatColor.GRAY + "\u21E8 " + ChatColor.YELLOW + "Click to change your layout");
@@ -80,31 +82,26 @@ class GuideLayoutOption implements SlimefunGuideOption {
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 (layout == SlimefunGuideLayout.CHEST) {
- return SlimefunGuideLayout.BOOK;
+ if (layout == SlimefunGuideLayout.SURVIVAL_MODE) {
+ return SlimefunGuideLayout.CHEAT_MODE;
+ } else {
+ return SlimefunGuideLayout.SURVIVAL_MODE;
}
-
- if (layout == SlimefunGuideLayout.BOOK) {
- return SlimefunGuideLayout.CHEAT_SHEET;
- }
-
- return SlimefunGuideLayout.CHEST;
} else {
- return layout == SlimefunGuideLayout.CHEST ? SlimefunGuideLayout.BOOK : SlimefunGuideLayout.CHEST;
+ return SlimefunGuideLayout.SURVIVAL_MODE;
}
}
@Override
public Optional getSelectedOption(Player p, ItemStack guide) {
- for (SlimefunGuideLayout layout : SlimefunGuideLayout.valuesCache) {
- if (SlimefunUtils.isItemSimilar(guide, SlimefunGuide.getItem(layout), true, false)) {
- return Optional.of(layout);
- }
+ if (SlimefunUtils.isItemSimilar(guide, SlimefunGuide.getItem(SlimefunGuideLayout.CHEAT_MODE), true, false)) {
+ return Optional.of(SlimefunGuideLayout.CHEAT_MODE);
+ } else {
+ return Optional.of(SlimefunGuideLayout.SURVIVAL_MODE);
}
-
- return Optional.empty();
}
@Override
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/SlimefunGuideSettings.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/SlimefunGuideSettings.java
index 1ed862a13..f0e498809 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/SlimefunGuideSettings.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/SlimefunGuideSettings.java
@@ -65,7 +65,7 @@ public final class SlimefunGuideSettings {
}
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);
return false;
});
@@ -141,7 +141,7 @@ public final class SlimefunGuideSettings {
for (SlimefunGuideOption> option : options) {
if (option instanceof FireworksOption) {
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);
}
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/MinecraftRecipeService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/MinecraftRecipeService.java
index 9366dcb27..694f1b352 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/MinecraftRecipeService.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/MinecraftRecipeService.java
@@ -20,14 +20,14 @@ import org.bukkit.plugin.Plugin;
import io.github.thebusybiscuit.cscorelib2.recipes.MinecraftRecipe;
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 snapshot contains a compiled list of all recipes that could be found on the
* 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
*
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java
index 88da97cfb..9dcc9f2ba 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java
@@ -203,7 +203,6 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
if (minecraftVersion == MinecraftVersion.UNIT_TEST) {
// We handle Unit Tests seperately.
setInstance(this);
- getLogger().log(Level.INFO, "This is a UNIT TEST Environment.");
onUnitTestStart();
} else if (isVersionUnsupported()) {
// We wanna ensure that the Server uses a compatible version of Minecraft.
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/BookSlimefunGuide.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/BookSlimefunGuide.java
deleted file mode 100644
index a5c7c1d29..000000000
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/BookSlimefunGuide.java
+++ /dev/null
@@ -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 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 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 lines) {
- if (category instanceof LockedCategory && !((LockedCategory) category).hasUnlocked(p, profile)) {
- List 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 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 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 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 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);
- }
-
-}
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
index d02c04c7e..982cdc894 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/CheatSheetSlimefunGuide.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/CheatSheetSlimefunGuide.java
@@ -21,13 +21,13 @@ import me.mrCookieSlime.Slimefun.Objects.Category;
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}.
*
* @author TheBusyBiscuit
*
*/
-public class CheatSheetSlimefunGuide extends ChestSlimefunGuide {
+public class CheatSheetSlimefunGuide extends SurvivalSlimefunGuide {
private final ItemStack item;
@@ -67,7 +67,7 @@ public class CheatSheetSlimefunGuide extends ChestSlimefunGuide {
@Override
public SlimefunGuideLayout getLayout() {
- return SlimefunGuideLayout.CHEAT_SHEET;
+ return SlimefunGuideLayout.CHEAT_MODE;
}
@Override
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/RecipeChoiceTask.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/RecipeChoiceTask.java
index 51917a37e..acb1b57f9 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/RecipeChoiceTask.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/RecipeChoiceTask.java
@@ -21,7 +21,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
* 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.
*
- * 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}.
*
* @author TheBusyBiscuit
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/ChestSlimefunGuide.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/SurvivalSlimefunGuide.java
similarity index 98%
rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/ChestSlimefunGuide.java
rename to src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/SurvivalSlimefunGuide.java
index ed9468473..20d9b1d0c 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/ChestSlimefunGuide.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/SurvivalSlimefunGuide.java
@@ -51,18 +51,17 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
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.
*
* @author TheBusyBiscuit
*
* @see SlimefunGuide
* @see SlimefunGuideImplementation
- * @see BookSlimefunGuide
* @see CheatSheetSlimefunGuide
*
*/
-public class ChestSlimefunGuide implements SlimefunGuideImplementation {
+public class SurvivalSlimefunGuide implements SlimefunGuideImplementation {
private static final int CATEGORY_SIZE = 36;
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 boolean showVanillaRecipes;
- public ChestSlimefunGuide(boolean showVanillaRecipes) {
+ public SurvivalSlimefunGuide(boolean showVanillaRecipes) {
this.showVanillaRecipes = showVanillaRecipes;
item = new SlimefunGuideItem(this, "&aSlimefun Guide &7(Chest GUI)");
}
@Override
public SlimefunGuideLayout getLayout() {
- return SlimefunGuideLayout.CHEST;
+ return SlimefunGuideLayout.SURVIVAL_MODE;
}
@Override
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/ElevatorPlate.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/ElevatorPlate.java
index 1d7dc7ae0..f38a70d4f 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/ElevatorPlate.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/ElevatorPlate.java
@@ -12,17 +12,12 @@ import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
-import org.bukkit.NamespacedKey;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.inventory.ItemStack;
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.slimefun4.core.handlers.BlockPlaceHandler;
import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler;
@@ -125,39 +120,46 @@ public class ElevatorPlate extends SimpleSlimefunItem {
@ParametersAreNonnullByDefault
private void openFloorSelector(Block b, List floors, Player p) {
- CustomBookInterface book = new CustomBookInterface(SlimefunPlugin.instance());
- ChatComponent page = null;
-
- for (int i = 0; i < floors.size(); i++) {
- 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");
- }
-
- Block block = floors.get(i);
- String floor = ChatColors.color(BlockStorage.getLocationInfo(block.getLocation(), DATA_KEY));
- ChatComponent line;
-
- if (block.getY() == b.getY()) {
- line = new ChatComponent("\n" + ChatColor.GRAY + "> " + (floors.size() - i) + ". " + ChatColor.BLACK + floor);
- line.setHoverEvent(new HoverEvent(ChatColors.color(SlimefunPlugin.getLocalization().getMessage(p, "machines.ELEVATOR.current-floor")), "", ChatColor.WHITE + floor, ""));
- } else {
- 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, ""));
- line.setClickEvent(new ClickEvent(new NamespacedKey(SlimefunPlugin.instance(), DATA_KEY + i), player -> teleport(player, floor, block)));
- }
-
- page.append(line);
- }
-
- if (page != null) {
- book.addPage(page);
- }
-
- book.open(p);
+ 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.");
+ // TODO: Re-implement the Elevator plate
+ // CustomBookInterface book = new CustomBookInterface(SlimefunPlugin.instance());
+ // ChatComponent page = null;
+ //
+ // for (int i = 0; i < floors.size(); i++) {
+ // 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");
+ // }
+ //
+ // Block block = floors.get(i);
+ // String floor = ChatColors.color(BlockStorage.getLocationInfo(block.getLocation(), DATA_KEY));
+ // ChatComponent line;
+ //
+ // if (block.getY() == b.getY()) {
+ // line = new ChatComponent("\n" + ChatColor.GRAY + "> " + (floors.size() - i) + ". " + ChatColor.BLACK +
+ // floor);
+ // line.setHoverEvent(new HoverEvent(ChatColors.color(SlimefunPlugin.getLocalization().getMessage(p,
+ // "machines.ELEVATOR.current-floor")), "", ChatColor.WHITE + floor, ""));
+ // } else {
+ // 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, ""));
+ // line.setClickEvent(new ClickEvent(new NamespacedKey(SlimefunPlugin.instance(), DATA_KEY + i), player ->
+ // teleport(player, floor, block)));
+ // }
+ //
+ // page.append(line);
+ // }
+ //
+ // if (page != null) {
+ // book.addPage(page);
+ // }
+ //
+ // book.open(p);
}
@ParametersAreNonnullByDefault
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunGuideListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunGuideListener.java
index 5575ce2aa..6da3e9b29 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunGuideListener.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunGuideListener.java
@@ -12,8 +12,8 @@ import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
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.SlimefunGuideOpenEvent;
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout;
import io.github.thebusybiscuit.slimefun4.core.guide.options.SlimefunGuideSettings;
@@ -47,24 +47,20 @@ public class SlimefunGuideListener implements Listener {
public void onInteract(PlayerRightClickEvent e) {
Player p = e.getPlayer();
- if (tryOpenGuide(p, e, SlimefunGuideLayout.BOOK) == Result.ALLOW) {
+ if (tryOpenGuide(p, e, SlimefunGuideLayout.SURVIVAL_MODE) == Result.ALLOW) {
if (p.isSneaking()) {
SlimefunGuideSettings.openSettings(p, e.getItem());
} 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()) {
SlimefunGuideSettings.openSettings(p, e.getItem());
} else {
- openGuide(p, e, SlimefunGuideLayout.CHEST);
- }
- } else if (tryOpenGuide(p, e, SlimefunGuideLayout.CHEAT_SHEET) == Result.ALLOW) {
- if (p.isSneaking()) {
- SlimefunGuideSettings.openSettings(p, e.getItem());
- } else {
- // We rather just run the command here,
- // all necessary permission checks will be handled there.
+ /*
+ * We rather just run the command here, all
+ * necessary permission checks will be handled there.
+ */
p.chat("/sf cheat");
}
}
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
index 9413104e2..84aff21b3 100644
--- a/src/main/resources/config.yml
+++ b/src/main/resources/config.yml
@@ -20,7 +20,6 @@ options:
drop-excess-sf-give-items: false
guide:
- default-view-book: false
show-vanilla-recipes: true
receive-on-first-join: true
diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/commands/TestGuideCommand.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/commands/TestGuideCommand.java
index 663d1e1bc..0dc875e54 100644
--- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/commands/TestGuideCommand.java
+++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/commands/TestGuideCommand.java
@@ -39,7 +39,7 @@ class TestGuideCommand {
player.setOp(op);
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));
}
}
diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/guide/TestChestSlimefunGuide.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/guide/TestChestSlimefunGuide.java
deleted file mode 100644
index 5880e650f..000000000
--- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/guide/TestChestSlimefunGuide.java
+++ /dev/null
@@ -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());
- }
-
-}
diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/guide/TestBookSlimefunGuide.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/guide/TestSurvivalSlimefunGuide.java
similarity index 74%
rename from src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/guide/TestBookSlimefunGuide.java
rename to src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/guide/TestSurvivalSlimefunGuide.java
index 6d56a54e6..abd0578c8 100644
--- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/guide/TestBookSlimefunGuide.java
+++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/guide/TestSurvivalSlimefunGuide.java
@@ -9,9 +9,9 @@ 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.BookSlimefunGuide;
+import io.github.thebusybiscuit.slimefun4.implementation.guide.SurvivalSlimefunGuide;
-class TestBookSlimefunGuide {
+class TestSurvivalSlimefunGuide {
@BeforeAll
public static void load() {
@@ -27,9 +27,9 @@ class TestBookSlimefunGuide {
@Test
@DisplayName("Test Getters for Chest Slimefun Guide")
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());
}