mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-20 03:35:51 +00:00
Merge branch 'master' into fixes/blocks
This commit is contained in:
commit
3777b59596
2
.github/workflows/discord-webhook.yml
vendored
2
.github/workflows/discord-webhook.yml
vendored
@ -6,6 +6,8 @@ on:
|
|||||||
- 'src/**'
|
- 'src/**'
|
||||||
- '!src/main/resources/languages/**'
|
- '!src/main/resources/languages/**'
|
||||||
- 'pom.xml'
|
- 'pom.xml'
|
||||||
|
tags-ignore:
|
||||||
|
- 'RC.*'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
report:
|
report:
|
||||||
|
22
CHANGELOG.md
22
CHANGELOG.md
@ -2,7 +2,7 @@
|
|||||||
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
||||||
**Table of contents**
|
**Table of contents**
|
||||||
|
|
||||||
- [Release Candidate 19 (TBD)](#release-candidate-19-tbd)
|
- [Release Candidate 19 (11 Jan 2021)](#release-candidate-19-11-jan-2021)
|
||||||
- [Release Candidate 18 (03 Dec 2020)](#release-candidate-18-03-dec-2020)
|
- [Release Candidate 18 (03 Dec 2020)](#release-candidate-18-03-dec-2020)
|
||||||
- [Release Candidate 17 (17 Oct 2020)](#release-candidate-17-17-oct-2020)
|
- [Release Candidate 17 (17 Oct 2020)](#release-candidate-17-17-oct-2020)
|
||||||
- [Release Candidate 16 (07 Sep 2020)](#release-candidate-16-07-sep-2020)
|
- [Release Candidate 16 (07 Sep 2020)](#release-candidate-16-07-sep-2020)
|
||||||
@ -24,7 +24,19 @@
|
|||||||
|
|
||||||
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
||||||
|
|
||||||
## Release Candidate 19 (TBD)
|
## Release Candidate 20 (TBD)
|
||||||
|
|
||||||
|
#### Additions
|
||||||
|
|
||||||
|
#### Changes
|
||||||
|
* (API) Improvements to the BlockBreakHandler
|
||||||
|
|
||||||
|
#### Fixes
|
||||||
|
* Fixed elevator floor order
|
||||||
|
* Fixed "block-explosions" (e.g. beds in Nether) not properly respecting explosion-resistant blocks
|
||||||
|
* Fixed #2560
|
||||||
|
|
||||||
|
## Release Candidate 19 (11 Jan 2021)
|
||||||
|
|
||||||
#### Additions
|
#### Additions
|
||||||
* Added Bee Armor (1.15+ only)
|
* Added Bee Armor (1.15+ only)
|
||||||
@ -36,7 +48,8 @@
|
|||||||
* General performance improvements
|
* General performance improvements
|
||||||
* 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
|
||||||
* (API) Improvements to the BlockBreakHandler
|
* Removed the "Written Book" variant of the Slimefun Guide
|
||||||
|
* The Elevator has an Inventory menu now
|
||||||
|
|
||||||
#### Fixes
|
#### Fixes
|
||||||
* Fixed a couple of compatibility issues with ItemsAdder
|
* Fixed a couple of compatibility issues with ItemsAdder
|
||||||
@ -47,8 +60,7 @@
|
|||||||
* Fixed #2664
|
* Fixed #2664
|
||||||
* Fixed #2655
|
* Fixed #2655
|
||||||
* Fixed /sf timings --verbose not working correctly
|
* Fixed /sf timings --verbose not working correctly
|
||||||
* Fixed "block-explosions" (e.g. beds in Nether) not properly respecting explosion-resistant blocks
|
* Fixed #2675
|
||||||
* Fixed #2560
|
|
||||||
|
|
||||||
## Release Candidate 18 (03 Dec 2020)
|
## Release Candidate 18 (03 Dec 2020)
|
||||||
|
|
||||||
|
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 {
|
||||||
|
@ -9,14 +9,14 @@ import org.bukkit.event.Event;
|
|||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout;
|
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This {@link Event} is called whenever a {@link Player} tries to open the Slimefun Guide book.
|
* This {@link Event} is called whenever a {@link Player} tries to open the Slimefun Guide book.
|
||||||
*
|
*
|
||||||
* @author Linox
|
* @author Linox
|
||||||
*
|
*
|
||||||
* @see SlimefunGuideLayout
|
* @see SlimefunGuideMode
|
||||||
*/
|
*/
|
||||||
public class SlimefunGuideOpenEvent extends Event implements Cancellable {
|
public class SlimefunGuideOpenEvent extends Event implements Cancellable {
|
||||||
|
|
||||||
@ -24,10 +24,10 @@ public class SlimefunGuideOpenEvent extends Event implements Cancellable {
|
|||||||
|
|
||||||
private final Player player;
|
private final Player player;
|
||||||
private final ItemStack guide;
|
private final ItemStack guide;
|
||||||
private SlimefunGuideLayout layout;
|
private SlimefunGuideMode layout;
|
||||||
private boolean cancelled;
|
private boolean cancelled;
|
||||||
|
|
||||||
public SlimefunGuideOpenEvent(@Nonnull Player p, @Nonnull ItemStack guide, @Nonnull SlimefunGuideLayout layout) {
|
public SlimefunGuideOpenEvent(@Nonnull Player p, @Nonnull ItemStack guide, @Nonnull SlimefunGuideMode layout) {
|
||||||
Validate.notNull(p, "The Player cannot be null");
|
Validate.notNull(p, "The Player cannot be null");
|
||||||
Validate.notNull(guide, "Guide cannot be null");
|
Validate.notNull(guide, "Guide cannot be null");
|
||||||
Validate.notNull(layout, "Layout cannot be null");
|
Validate.notNull(layout, "Layout cannot be null");
|
||||||
@ -59,23 +59,23 @@ public class SlimefunGuideOpenEvent extends Event implements Cancellable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This returns the {@link SlimefunGuideLayout} of the Slimefun Guide
|
* This returns the {@link SlimefunGuideMode} of the Slimefun Guide
|
||||||
* that {@link Player} tries to open.
|
* that {@link Player} tries to open.
|
||||||
*
|
*
|
||||||
* @return The {@link SlimefunGuideLayout}
|
* @return The {@link SlimefunGuideMode}
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public SlimefunGuideLayout getGuideLayout() {
|
public SlimefunGuideMode getGuideLayout() {
|
||||||
return layout;
|
return layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Changes the {@link SlimefunGuideLayout} that was tried to be opened with.
|
* Changes the {@link SlimefunGuideMode} that was tried to be opened with.
|
||||||
*
|
*
|
||||||
* @param layout
|
* @param layout
|
||||||
* The new {@link SlimefunGuideLayout}
|
* The new {@link SlimefunGuideMode}
|
||||||
*/
|
*/
|
||||||
public void setGuideLayout(@Nonnull SlimefunGuideLayout layout) {
|
public void setGuideLayout(@Nonnull SlimefunGuideMode layout) {
|
||||||
Validate.notNull(layout, "You must specify a layout that is not-null!");
|
Validate.notNull(layout, "You must specify a layout that is not-null!");
|
||||||
this.layout = layout;
|
this.layout = layout;
|
||||||
}
|
}
|
||||||
|
@ -26,13 +26,13 @@ import io.github.thebusybiscuit.cscorelib2.config.Config;
|
|||||||
import io.github.thebusybiscuit.slimefun4.api.geo.GEOResource;
|
import io.github.thebusybiscuit.slimefun4.api.geo.GEOResource;
|
||||||
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
|
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideImplementation;
|
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideImplementation;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout;
|
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode;
|
||||||
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;
|
||||||
@ -75,13 +75,14 @@ public final class SlimefunRegistry {
|
|||||||
|
|
||||||
private NamespacedKey soulboundKey;
|
private NamespacedKey soulboundKey;
|
||||||
private NamespacedKey itemChargeKey;
|
private NamespacedKey itemChargeKey;
|
||||||
|
private NamespacedKey guideKey;
|
||||||
|
|
||||||
private final KeyMap<GEOResource> geoResources = new KeyMap<>();
|
private final KeyMap<GEOResource> geoResources = new KeyMap<>();
|
||||||
|
|
||||||
private final Map<UUID, PlayerProfile> profiles = new ConcurrentHashMap<>();
|
private final Map<UUID, PlayerProfile> profiles = new ConcurrentHashMap<>();
|
||||||
private final Map<String, BlockStorage> worlds = new ConcurrentHashMap<>();
|
private final Map<String, BlockStorage> worlds = new ConcurrentHashMap<>();
|
||||||
private final Map<String, BlockInfoConfig> chunks = new HashMap<>();
|
private final Map<String, BlockInfoConfig> chunks = new HashMap<>();
|
||||||
private final Map<SlimefunGuideLayout, SlimefunGuideImplementation> layouts = new EnumMap<>(SlimefunGuideLayout.class);
|
private final Map<SlimefunGuideMode, SlimefunGuideImplementation> layouts = new EnumMap<>(SlimefunGuideMode.class);
|
||||||
private final Map<EntityType, Set<ItemStack>> mobDrops = new EnumMap<>(EntityType.class);
|
private final Map<EntityType, Set<ItemStack>> mobDrops = new EnumMap<>(EntityType.class);
|
||||||
|
|
||||||
private final Map<String, BlockMenuPreset> blockMenuPresets = new HashMap<>();
|
private final Map<String, BlockMenuPreset> blockMenuPresets = new HashMap<>();
|
||||||
@ -95,12 +96,11 @@ public final class SlimefunRegistry {
|
|||||||
|
|
||||||
soulboundKey = new NamespacedKey(plugin, "soulbound");
|
soulboundKey = new NamespacedKey(plugin, "soulbound");
|
||||||
itemChargeKey = new NamespacedKey(plugin, "item_charge");
|
itemChargeKey = new NamespacedKey(plugin, "item_charge");
|
||||||
|
guideKey = new NamespacedKey(plugin, "slimefun_guide_mode");
|
||||||
|
|
||||||
boolean showVanillaRecipes = cfg.getBoolean("guide.show-vanilla-recipes");
|
boolean showVanillaRecipes = cfg.getBoolean("guide.show-vanilla-recipes");
|
||||||
|
layouts.put(SlimefunGuideMode.SURVIVAL_MODE, new SurvivalSlimefunGuide(showVanillaRecipes));
|
||||||
layouts.put(SlimefunGuideLayout.CHEST, new ChestSlimefunGuide(showVanillaRecipes));
|
layouts.put(SlimefunGuideMode.CHEAT_MODE, new CheatSheetSlimefunGuide());
|
||||||
layouts.put(SlimefunGuideLayout.CHEAT_SHEET, new CheatSheetSlimefunGuide());
|
|
||||||
layouts.put(SlimefunGuideLayout.BOOK, new BookSlimefunGuide());
|
|
||||||
|
|
||||||
researchRanks.addAll(cfg.getStringList("research-ranks"));
|
researchRanks.addAll(cfg.getStringList("research-ranks"));
|
||||||
|
|
||||||
@ -199,7 +199,7 @@ public final class SlimefunRegistry {
|
|||||||
return multiblocks;
|
return multiblocks;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SlimefunGuideImplementation getGuideLayout(SlimefunGuideLayout layout) {
|
public SlimefunGuideImplementation getGuideLayout(SlimefunGuideMode layout) {
|
||||||
return layouts.get(layout);
|
return layouts.get(layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -282,4 +282,9 @@ public final class SlimefunRegistry {
|
|||||||
return itemChargeKey;
|
return itemChargeKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
public NamespacedKey getGuideDataKey() {
|
||||||
|
return guideKey;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,7 +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.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.SlimefunGuideMode;
|
||||||
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;
|
||||||
|
|
||||||
@ -45,12 +45,12 @@ public abstract class FlexCategory extends Category {
|
|||||||
* @param profile
|
* @param profile
|
||||||
* The {@link PlayerProfile} of the {@link Player}
|
* The {@link PlayerProfile} of the {@link Player}
|
||||||
* @param layout
|
* @param layout
|
||||||
* The {@link SlimefunGuideLayout} in which this {@link FlexCategory} is viewed
|
* The {@link SlimefunGuideMode} in which this {@link FlexCategory} is viewed
|
||||||
*
|
*
|
||||||
* @return Whether to display this {@link FlexCategory}
|
* @return Whether to display this {@link FlexCategory}
|
||||||
*/
|
*/
|
||||||
@ParametersAreNonnullByDefault
|
@ParametersAreNonnullByDefault
|
||||||
public abstract boolean isVisible(Player p, PlayerProfile profile, SlimefunGuideLayout layout);
|
public abstract boolean isVisible(Player p, PlayerProfile profile, SlimefunGuideMode layout);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is called when a {@link Player} opens this {@link FlexCategory}.
|
* This method is called when a {@link Player} opens this {@link FlexCategory}.
|
||||||
@ -62,9 +62,9 @@ public abstract class FlexCategory extends Category {
|
|||||||
* @param profile
|
* @param profile
|
||||||
* The corresponding {@link PlayerProfile} for that {@link Player}
|
* The corresponding {@link PlayerProfile} for that {@link Player}
|
||||||
* @param layout
|
* @param layout
|
||||||
* The current {@link SlimefunGuideLayout}
|
* The current {@link SlimefunGuideMode}
|
||||||
*/
|
*/
|
||||||
public abstract void open(Player p, PlayerProfile profile, SlimefunGuideLayout layout);
|
public abstract void open(Player p, PlayerProfile profile, SlimefunGuideMode layout);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final boolean isHidden(@Nonnull Player p) {
|
public final boolean isHidden(@Nonnull Player p) {
|
||||||
|
@ -14,6 +14,7 @@ import org.bukkit.NamespacedKey;
|
|||||||
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.SlimefunAddon;
|
||||||
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 me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
@ -76,8 +77,8 @@ public class LockedCategory extends Category {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void register() {
|
public void register(@Nonnull SlimefunAddon addon) {
|
||||||
super.register();
|
super.register(addon);
|
||||||
|
|
||||||
List<NamespacedKey> namespacedKeys = new ArrayList<>();
|
List<NamespacedKey> namespacedKeys = new ArrayList<>();
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ import org.bukkit.entity.Player;
|
|||||||
import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand;
|
import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand;
|
import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand;
|
||||||
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.SlimefunGuideMode;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
|
|
||||||
class GuideCommand extends SubCommand {
|
class GuideCommand extends SubCommand {
|
||||||
@ -19,7 +19,7 @@ class GuideCommand 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.guide")) {
|
if (sender.hasPermission("slimefun.command.guide")) {
|
||||||
SlimefunGuideLayout design = SlimefunGuide.getDefaultLayout();
|
SlimefunGuideMode design = SlimefunGuide.getDefaultLayout();
|
||||||
((Player) sender).getInventory().addItem(SlimefunGuide.getItem(design).clone());
|
((Player) sender).getInventory().addItem(SlimefunGuide.getItem(design).clone());
|
||||||
} else {
|
} else {
|
||||||
SlimefunPlugin.getLocalization().sendMessage(sender, "messages.no-permission", true);
|
SlimefunPlugin.getLocalization().sendMessage(sender, "messages.no-permission", true);
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
package io.github.thebusybiscuit.slimefun4.core.commands.subcommands;
|
package io.github.thebusybiscuit.slimefun4.core.commands.subcommands;
|
||||||
|
|
||||||
|
import javax.annotation.ParametersAreNonnullByDefault;
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand;
|
import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand;
|
import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand;
|
||||||
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.SlimefunGuideMode;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
|
|
||||||
class OpenGuideCommand extends SubCommand {
|
class OpenGuideCommand extends SubCommand {
|
||||||
@ -16,11 +18,11 @@ class OpenGuideCommand extends SubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ParametersAreNonnullByDefault
|
||||||
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, SlimefunGuideMode.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,16 @@ 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 javax.annotation.ParametersAreNonnullByDefault;
|
||||||
|
|
||||||
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 +24,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() {}
|
||||||
|
|
||||||
public static ItemStack getItem(@Nonnull SlimefunGuideLayout design) {
|
@Nonnull
|
||||||
|
public static ItemStack getItem(@Nonnull SlimefunGuideMode 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, SlimefunGuideMode.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 (getItem(SlimefunGuideMode.CHEAT_MODE).equals(guide)) {
|
||||||
openGuide(p, SlimefunGuideLayout.CHEST);
|
openGuide(p, SlimefunGuideMode.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, SlimefunGuideMode.SURVIVAL_MODE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void openGuide(Player p, SlimefunGuideLayout layout) {
|
public static void openGuide(@Nonnull Player p, @Nonnull SlimefunGuideMode layout) {
|
||||||
if (!SlimefunPlugin.getWorldSettingsService().isWorldEnabled(p.getWorld())) {
|
if (!SlimefunPlugin.getWorldSettingsService().isWorldEnabled(p.getWorld())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -67,51 +68,60 @@ public final class SlimefunGuide {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void openMainMenuAsync(Player player, SlimefunGuideLayout layout, int selectedPage) {
|
@ParametersAreNonnullByDefault
|
||||||
|
private static void openMainMenuAsync(Player player, SlimefunGuideMode layout, int selectedPage) {
|
||||||
if (!PlayerProfile.get(player, profile -> SlimefunPlugin.runSync(() -> openMainMenu(profile, layout, selectedPage)))) {
|
if (!PlayerProfile.get(player, profile -> SlimefunPlugin.runSync(() -> openMainMenu(profile, layout, selectedPage)))) {
|
||||||
SlimefunPlugin.getLocalization().sendMessage(player, "messages.opening-guide");
|
SlimefunPlugin.getLocalization().sendMessage(player, "messages.opening-guide");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void openMainMenu(PlayerProfile profile, SlimefunGuideLayout layout, int selectedPage) {
|
@ParametersAreNonnullByDefault
|
||||||
|
public static void openMainMenu(PlayerProfile profile, SlimefunGuideMode layout, int selectedPage) {
|
||||||
SlimefunPlugin.getRegistry().getGuideLayout(layout).openMainMenu(profile, selectedPage);
|
SlimefunPlugin.getRegistry().getGuideLayout(layout).openMainMenu(profile, selectedPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void openCategory(PlayerProfile profile, Category category, SlimefunGuideLayout layout, int selectedPage) {
|
@ParametersAreNonnullByDefault
|
||||||
if (category == null) {
|
public static void openCategory(PlayerProfile profile, Category category, SlimefunGuideMode layout, int selectedPage) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SlimefunPlugin.getRegistry().getGuideLayout(layout).openCategory(profile, category, selectedPage);
|
SlimefunPlugin.getRegistry().getGuideLayout(layout).openCategory(profile, category, selectedPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ParametersAreNonnullByDefault
|
||||||
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(SlimefunGuideMode.SURVIVAL_MODE);
|
||||||
|
|
||||||
if (!survival) {
|
if (!survival) {
|
||||||
layout = SlimefunPlugin.getRegistry().getGuideLayout(SlimefunGuideLayout.CHEAT_SHEET);
|
layout = SlimefunPlugin.getRegistry().getGuideLayout(SlimefunGuideMode.CHEAT_MODE);
|
||||||
}
|
}
|
||||||
|
|
||||||
layout.openSearch(profile, input, addToHistory);
|
layout.openSearch(profile, input, addToHistory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ParametersAreNonnullByDefault
|
||||||
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(SlimefunGuideMode.SURVIVAL_MODE).displayItem(profile, item, 0, addToHistory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ParametersAreNonnullByDefault
|
||||||
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(SlimefunGuideMode.SURVIVAL_MODE).displayItem(profile, item, addToHistory);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isGuideItem(ItemStack item) {
|
public static boolean isGuideItem(@Nullable 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);
|
if (item == null) {
|
||||||
}
|
return false;
|
||||||
|
|
||||||
public static SlimefunGuideLayout getDefaultLayout() {
|
|
||||||
if (SlimefunPlugin.getCfg().getBoolean("guide.default-view-book")) {
|
|
||||||
return SlimefunGuideLayout.BOOK;
|
|
||||||
} else {
|
} else {
|
||||||
return SlimefunGuideLayout.CHEST;
|
return SlimefunUtils.isItemSimilar(item, getItem(SlimefunGuideMode.SURVIVAL_MODE), true) || SlimefunUtils.isItemSimilar(item, getItem(SlimefunGuideMode.CHEAT_MODE), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the default layout for the Slimefun guide.
|
||||||
|
* Currently this is only {@link SlimefunGuideMode#SURVIVAL_MODE}.
|
||||||
|
*
|
||||||
|
* @return The default {@link SlimefunGuideLayout}.
|
||||||
|
*/
|
||||||
|
@Nonnull
|
||||||
|
public static SlimefunGuideMode getDefaultLayout() {
|
||||||
|
return SlimefunGuideMode.SURVIVAL_MODE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
|
||||||
@ -22,21 +21,20 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
|||||||
*
|
*
|
||||||
* @author TheBusyBiscuit
|
* @author TheBusyBiscuit
|
||||||
*
|
*
|
||||||
* @see SlimefunGuideLayout
|
* @see SlimefunGuideMode
|
||||||
* @see ChestSlimefunGuide
|
* @see SurvivalSlimefunGuide
|
||||||
* @see BookSlimefunGuide
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public interface SlimefunGuideImplementation {
|
public interface SlimefunGuideImplementation {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Every {@link SlimefunGuideImplementation} can be associated with a
|
* Every {@link SlimefunGuideImplementation} can be associated with a
|
||||||
* {@link SlimefunGuideLayout}.
|
* {@link SlimefunGuideMode}.
|
||||||
*
|
*
|
||||||
* @return The layout this {@link SlimefunGuideImplementation} represents
|
* @return The mode this {@link SlimefunGuideImplementation} represents
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@Nonnull
|
||||||
SlimefunGuideLayout getLayout();
|
SlimefunGuideMode getMode();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the {@link ItemStack} representation for this {@link SlimefunGuideImplementation}.
|
* Returns the {@link ItemStack} representation for this {@link SlimefunGuideImplementation}.
|
||||||
@ -48,14 +46,6 @@ public interface SlimefunGuideImplementation {
|
|||||||
@Nonnull
|
@Nonnull
|
||||||
ItemStack getItem();
|
ItemStack getItem();
|
||||||
|
|
||||||
/**
|
|
||||||
* This method returns whether this {@link SlimefunGuideImplementation} is meant
|
|
||||||
* for Survival Mode.
|
|
||||||
*
|
|
||||||
* @return Whether this is a survival mode implementation
|
|
||||||
*/
|
|
||||||
boolean isSurvivalMode();
|
|
||||||
|
|
||||||
void openMainMenu(PlayerProfile profile, int page);
|
void openMainMenu(PlayerProfile profile, int page);
|
||||||
|
|
||||||
void openCategory(PlayerProfile profile, Category category, int page);
|
void openCategory(PlayerProfile profile, Category category, int page);
|
||||||
|
@ -13,24 +13,17 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
|||||||
* @see SlimefunGuideImplementation
|
* @see SlimefunGuideImplementation
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public enum SlimefunGuideLayout {
|
public enum SlimefunGuideMode {
|
||||||
|
|
||||||
/**
|
|
||||||
* 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,9 @@ 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 javax.annotation.ParametersAreNonnullByDefault;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.NamespacedKey;
|
import org.bukkit.NamespacedKey;
|
||||||
@ -13,35 +16,41 @@ import org.bukkit.inventory.meta.ItemMeta;
|
|||||||
|
|
||||||
import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
|
import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
|
||||||
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.SlimefunGuideMode;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.ChatUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.ChatUtils;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
||||||
|
|
||||||
class GuideLayoutOption implements SlimefunGuideOption<SlimefunGuideLayout> {
|
class GuideModeOption implements SlimefunGuideOption<SlimefunGuideMode> {
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public SlimefunAddon getAddon() {
|
public SlimefunAddon getAddon() {
|
||||||
return SlimefunPlugin.instance();
|
return SlimefunPlugin.instance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public NamespacedKey getKey() {
|
public NamespacedKey getKey() {
|
||||||
return new NamespacedKey(SlimefunPlugin.instance(), "guide_layout");
|
return new NamespacedKey(SlimefunPlugin.instance(), "guide_layout");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public Optional<ItemStack> getDisplayItem(Player p, ItemStack guide) {
|
public Optional<ItemStack> getDisplayItem(Player p, ItemStack guide) {
|
||||||
Optional<SlimefunGuideLayout> current = getSelectedOption(p, guide);
|
if (!p.hasPermission("slimefun.cheat.items")) {
|
||||||
|
// Only Players with the appropriate permission can access the cheat sheet
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
Optional<SlimefunGuideMode> current = getSelectedOption(p, guide);
|
||||||
|
|
||||||
if (current.isPresent()) {
|
if (current.isPresent()) {
|
||||||
SlimefunGuideLayout layout = current.get();
|
SlimefunGuideMode layout = current.get();
|
||||||
ItemStack item = new ItemStack(Material.AIR);
|
ItemStack item = new ItemStack(Material.AIR);
|
||||||
|
|
||||||
if (layout == SlimefunGuideLayout.CHEST) {
|
if (layout == SlimefunGuideMode.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 +59,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 == SlimefunGuideMode.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 == SlimefunGuideMode.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");
|
||||||
@ -69,46 +75,43 @@ class GuideLayoutOption implements SlimefunGuideOption<SlimefunGuideLayout> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(Player p, ItemStack guide) {
|
public void onClick(@Nonnull Player p, @Nonnull ItemStack guide) {
|
||||||
Optional<SlimefunGuideLayout> current = getSelectedOption(p, guide);
|
Optional<SlimefunGuideMode> current = getSelectedOption(p, guide);
|
||||||
|
|
||||||
if (current.isPresent()) {
|
if (current.isPresent()) {
|
||||||
SlimefunGuideLayout next = getNextLayout(p, current.get());
|
SlimefunGuideMode next = getNextMode(p, current.get());
|
||||||
setSelectedOption(p, guide, next);
|
setSelectedOption(p, guide, next);
|
||||||
}
|
}
|
||||||
|
|
||||||
SlimefunGuideSettings.openSettings(p, guide);
|
SlimefunGuideSettings.openSettings(p, guide);
|
||||||
}
|
}
|
||||||
|
|
||||||
private SlimefunGuideLayout getNextLayout(Player p, SlimefunGuideLayout layout) {
|
@Nonnull
|
||||||
|
private SlimefunGuideMode getNextMode(@Nonnull Player p, @Nonnull SlimefunGuideMode mode) {
|
||||||
if (p.hasPermission("slimefun.cheat.items")) {
|
if (p.hasPermission("slimefun.cheat.items")) {
|
||||||
if (layout == SlimefunGuideLayout.CHEST) {
|
if (mode == SlimefunGuideMode.SURVIVAL_MODE) {
|
||||||
return SlimefunGuideLayout.BOOK;
|
return SlimefunGuideMode.CHEAT_MODE;
|
||||||
|
} else {
|
||||||
|
return SlimefunGuideMode.SURVIVAL_MODE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (layout == SlimefunGuideLayout.BOOK) {
|
|
||||||
return SlimefunGuideLayout.CHEAT_SHEET;
|
|
||||||
}
|
|
||||||
|
|
||||||
return SlimefunGuideLayout.CHEST;
|
|
||||||
} else {
|
} else {
|
||||||
return layout == SlimefunGuideLayout.CHEST ? SlimefunGuideLayout.BOOK : SlimefunGuideLayout.CHEST;
|
return SlimefunGuideMode.SURVIVAL_MODE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
@Override
|
||||||
|
public Optional<SlimefunGuideMode> getSelectedOption(@Nonnull Player p, @Nonnull ItemStack guide) {
|
||||||
|
if (SlimefunUtils.isItemSimilar(guide, SlimefunGuide.getItem(SlimefunGuideMode.CHEAT_MODE), true, false)) {
|
||||||
|
return Optional.of(SlimefunGuideMode.CHEAT_MODE);
|
||||||
|
} else {
|
||||||
|
return Optional.of(SlimefunGuideMode.SURVIVAL_MODE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<SlimefunGuideLayout> getSelectedOption(Player p, ItemStack guide) {
|
@ParametersAreNonnullByDefault
|
||||||
for (SlimefunGuideLayout layout : SlimefunGuideLayout.valuesCache) {
|
public void setSelectedOption(Player p, ItemStack guide, SlimefunGuideMode value) {
|
||||||
if (SlimefunUtils.isItemSimilar(guide, SlimefunGuide.getItem(layout), true, false)) {
|
|
||||||
return Optional.of(layout);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setSelectedOption(Player p, ItemStack guide, SlimefunGuideLayout value) {
|
|
||||||
guide.setItemMeta(SlimefunGuide.getItem(value).getItemMeta());
|
guide.setItemMeta(SlimefunGuide.getItem(value).getItemMeta());
|
||||||
}
|
}
|
||||||
|
|
@ -13,7 +13,7 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
||||||
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.SlimefunGuideMode;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.services.localization.Language;
|
import io.github.thebusybiscuit.slimefun4.core.services.localization.Language;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.ChatUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.ChatUtils;
|
||||||
@ -39,7 +39,7 @@ public final class SlimefunGuideSettings {
|
|||||||
private static final List<SlimefunGuideOption<?>> options = new ArrayList<>();
|
private static final List<SlimefunGuideOption<?>> options = new ArrayList<>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
options.add(new GuideLayoutOption());
|
options.add(new GuideModeOption());
|
||||||
options.add(new FireworksOption());
|
options.add(new FireworksOption());
|
||||||
options.add(new PlayerLanguageOption());
|
options.add(new PlayerLanguageOption());
|
||||||
}
|
}
|
||||||
@ -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(SlimefunGuideMode.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(SlimefunGuideMode.SURVIVAL_MODE)).orElse(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -393,19 +393,6 @@ final class CargoUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the whitelist/blacklist slots in a Cargo Input Node. If you wish to access the items
|
|
||||||
* in the cargo (without hardcoding the slots in case of change) then you can use this method.
|
|
||||||
*
|
|
||||||
* @deprecated Renamed to {@link #getFilteringSlots()}
|
|
||||||
*
|
|
||||||
* @return The slot indexes for the whitelist/blacklist section.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public static int[] getWhitelistBlacklistSlots() {
|
|
||||||
return getFilteringSlots();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the {@link ItemFilter} slots for a Cargo Node. If you wish to access the items
|
* Gets the {@link ItemFilter} slots for a Cargo Node. If you wish to access the items
|
||||||
* in the cargo (without hardcoding the slots in case of change) then you can use this method.
|
* in the cargo (without hardcoding the slots in case of change) then you can use this method.
|
||||||
|
@ -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
|
||||||
*
|
*
|
||||||
|
@ -1,59 +0,0 @@
|
|||||||
package io.github.thebusybiscuit.slimefun4.core.services.plugins;
|
|
||||||
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.function.Function;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
|
|
||||||
import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.integrations.IntegrationsManager;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This Service holds all interactions and hooks with third-party {@link Plugin Plugins}
|
|
||||||
* that are not necessarily a dependency or a {@link SlimefunAddon}.
|
|
||||||
*
|
|
||||||
* Integration with these plugins happens inside Slimefun itself.
|
|
||||||
*
|
|
||||||
* @author TheBusyBiscuit
|
|
||||||
*
|
|
||||||
* @deprecated Renamed to {@link IntegrationsManager}
|
|
||||||
*
|
|
||||||
* @see SlimefunPlugin
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public class ThirdPartyPluginService extends IntegrationsManager {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This gets overridden if ExoticGarden is loaded
|
|
||||||
*/
|
|
||||||
private Function<Block, Optional<ItemStack>> exoticGardenIntegration = b -> Optional.empty();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This initializes the {@link ThirdPartyPluginService}
|
|
||||||
*
|
|
||||||
* @param plugin
|
|
||||||
* Our instance of {@link SlimefunPlugin}
|
|
||||||
*/
|
|
||||||
public ThirdPartyPluginService(@Nonnull SlimefunPlugin plugin) {
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public void loadExoticGarden(Plugin plugin, Function<Block, Optional<ItemStack>> method) {
|
|
||||||
if (plugin.getName().equals("ExoticGarden")) {
|
|
||||||
exoticGardenIntegration = method;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public Optional<ItemStack> harvestExoticGardenPlant(Block block) {
|
|
||||||
return exoticGardenIntegration.apply(block);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,4 +0,0 @@
|
|||||||
/**
|
|
||||||
* This package contains all hooks to external plugins
|
|
||||||
*/
|
|
||||||
package io.github.thebusybiscuit.slimefun4.core.services.plugins;
|
|
@ -33,6 +33,8 @@ public class ConsolePerformanceInspector implements PerformanceInspector {
|
|||||||
*
|
*
|
||||||
* @param console
|
* @param console
|
||||||
* The {@link CommandSender}, preferabbly a {@link ConsoleCommandSender}
|
* The {@link CommandSender}, preferabbly a {@link ConsoleCommandSender}
|
||||||
|
* @param verbose
|
||||||
|
* Whether the summary will be verbose or not
|
||||||
*/
|
*/
|
||||||
public ConsolePerformanceInspector(@Nonnull CommandSender console, boolean verbose) {
|
public ConsolePerformanceInspector(@Nonnull CommandSender console, boolean verbose) {
|
||||||
Validate.notNull(console, "CommandSender cannot be null");
|
Validate.notNull(console, "CommandSender cannot be null");
|
||||||
|
@ -50,7 +50,6 @@ import io.github.thebusybiscuit.slimefun4.core.services.PerWorldSettingsService;
|
|||||||
import io.github.thebusybiscuit.slimefun4.core.services.PermissionsService;
|
import io.github.thebusybiscuit.slimefun4.core.services.PermissionsService;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.services.UpdaterService;
|
import io.github.thebusybiscuit.slimefun4.core.services.UpdaterService;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.services.github.GitHubService;
|
import io.github.thebusybiscuit.slimefun4.core.services.github.GitHubService;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.services.plugins.ThirdPartyPluginService;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.core.services.profiler.SlimefunProfiler;
|
import io.github.thebusybiscuit.slimefun4.core.services.profiler.SlimefunProfiler;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.altar.AncientAltar;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.altar.AncientAltar;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.altar.AncientPedestal;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.altar.AncientPedestal;
|
||||||
@ -152,7 +151,7 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
|
|||||||
private final PerWorldSettingsService worldSettingsService = new PerWorldSettingsService(this);
|
private final PerWorldSettingsService worldSettingsService = new PerWorldSettingsService(this);
|
||||||
private final MinecraftRecipeService recipeService = new MinecraftRecipeService(this);
|
private final MinecraftRecipeService recipeService = new MinecraftRecipeService(this);
|
||||||
|
|
||||||
private final IntegrationsManager integrations = new ThirdPartyPluginService(this);
|
private final IntegrationsManager integrations = new IntegrationsManager(this);
|
||||||
private final SlimefunProfiler profiler = new SlimefunProfiler();
|
private final SlimefunProfiler profiler = new SlimefunProfiler();
|
||||||
|
|
||||||
private LocalizationService local;
|
private LocalizationService local;
|
||||||
@ -204,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.
|
||||||
@ -832,18 +830,6 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
|
|||||||
return instance.worldSettingsService;
|
return instance.worldSettingsService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This method has been renamed.
|
|
||||||
*
|
|
||||||
* @deprecated Please use {@link #getIntegrations()} instead.
|
|
||||||
*
|
|
||||||
* @return the {@link ThirdPartyPluginService}
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public static ThirdPartyPluginService getThirdPartySupportService() {
|
|
||||||
return (ThirdPartyPluginService) instance.integrations;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This returns our instance of {@link IntegrationsManager}.
|
* This returns our instance of {@link IntegrationsManager}.
|
||||||
* This is responsible for managing any integrations with third party {@link Plugin plugins}.
|
* This is responsible for managing any integrations with third party {@link Plugin plugins}.
|
||||||
@ -903,18 +889,24 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
|
|||||||
return instance.gitHubService;
|
return instance.gitHubService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
/**
|
||||||
public static SlimefunRegistry getRegistry() {
|
* This returns our {@link NetworkManager} which is responsible
|
||||||
validateInstance();
|
* for handling the Cargo and Energy networks.
|
||||||
return instance.registry;
|
*
|
||||||
}
|
* @return Our {@link NetworkManager} instance
|
||||||
|
*/
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public static NetworkManager getNetworkManager() {
|
public static NetworkManager getNetworkManager() {
|
||||||
validateInstance();
|
validateInstance();
|
||||||
return instance.networkManager;
|
return instance.networkManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
public static SlimefunRegistry getRegistry() {
|
||||||
|
validateInstance();
|
||||||
|
return instance.registry;
|
||||||
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public static GrapplingHookListener getGrapplingHookListener() {
|
public static GrapplingHookListener getGrapplingHookListener() {
|
||||||
validateInstance();
|
validateInstance();
|
||||||
|
@ -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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -12,7 +12,7 @@ import org.bukkit.inventory.Recipe;
|
|||||||
|
|
||||||
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
|
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.categories.FlexCategory;
|
import io.github.thebusybiscuit.slimefun4.core.categories.FlexCategory;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout;
|
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.itemstack.SlimefunGuideItem;
|
import io.github.thebusybiscuit.slimefun4.utils.itemstack.SlimefunGuideItem;
|
||||||
@ -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;
|
||||||
|
|
||||||
@ -37,11 +37,6 @@ public class CheatSheetSlimefunGuide extends ChestSlimefunGuide {
|
|||||||
item = new SlimefunGuideItem(this, "&cSlimefun Guide &4(Cheat Sheet)");
|
item = new SlimefunGuideItem(this, "&cSlimefun Guide &4(Cheat Sheet)");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isSurvivalMode() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a {@link List} of visible {@link Category} instances that the {@link SlimefunGuide} would display.
|
* Returns a {@link List} of visible {@link Category} instances that the {@link SlimefunGuide} would display.
|
||||||
*
|
*
|
||||||
@ -65,11 +60,13 @@ public class CheatSheetSlimefunGuide extends ChestSlimefunGuide {
|
|||||||
return categories;
|
return categories;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public SlimefunGuideLayout getLayout() {
|
public SlimefunGuideMode getMode() {
|
||||||
return SlimefunGuideLayout.CHEAT_SHEET;
|
return SlimefunGuideMode.CHEAT_MODE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getItem() {
|
public ItemStack getItem() {
|
||||||
return item;
|
return item;
|
||||||
|
@ -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
|
||||||
|
@ -27,6 +27,7 @@ import io.github.thebusybiscuit.cscorelib2.chat.ChatInput;
|
|||||||
import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils;
|
import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils;
|
||||||
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
||||||
import io.github.thebusybiscuit.cscorelib2.recipes.MinecraftRecipe;
|
import io.github.thebusybiscuit.cscorelib2.recipes.MinecraftRecipe;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
|
||||||
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
|
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem;
|
import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.categories.FlexCategory;
|
import io.github.thebusybiscuit.slimefun4.core.categories.FlexCategory;
|
||||||
@ -34,7 +35,7 @@ import io.github.thebusybiscuit.slimefun4.core.categories.LockedCategory;
|
|||||||
import io.github.thebusybiscuit.slimefun4.core.guide.GuideHistory;
|
import io.github.thebusybiscuit.slimefun4.core.guide.GuideHistory;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
|
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideImplementation;
|
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideImplementation;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout;
|
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.guide.options.SlimefunGuideSettings;
|
import io.github.thebusybiscuit.slimefun4.core.guide.options.SlimefunGuideSettings;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlock;
|
import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlock;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine;
|
import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine;
|
||||||
@ -51,18 +52,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 +71,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 SlimefunGuideMode getMode() {
|
||||||
return SlimefunGuideLayout.CHEST;
|
return SlimefunGuideMode.SURVIVAL_MODE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -86,9 +86,8 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation {
|
|||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
protected final boolean isSurvivalMode() {
|
||||||
public boolean isSurvivalMode() {
|
return getMode() != SlimefunGuideMode.CHEAT_MODE;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -105,8 +104,18 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation {
|
|||||||
List<Category> categories = new LinkedList<>();
|
List<Category> categories = new LinkedList<>();
|
||||||
|
|
||||||
for (Category category : SlimefunPlugin.getRegistry().getCategories()) {
|
for (Category category : SlimefunPlugin.getRegistry().getCategories()) {
|
||||||
if (!category.isHidden(p) && (!(category instanceof FlexCategory) || ((FlexCategory) category).isVisible(p, profile, getLayout()))) {
|
try {
|
||||||
categories.add(category);
|
if (!category.isHidden(p) && (!(category instanceof FlexCategory) || ((FlexCategory) category).isVisible(p, profile, getMode()))) {
|
||||||
|
categories.add(category);
|
||||||
|
}
|
||||||
|
} catch (Exception | LinkageError x) {
|
||||||
|
SlimefunAddon addon = category.getAddon();
|
||||||
|
|
||||||
|
if (addon != null) {
|
||||||
|
addon.getLogger().log(Level.SEVERE, x, () -> "Could not display Category: " + category);
|
||||||
|
} else {
|
||||||
|
SlimefunPlugin.logger().log(Level.SEVERE, x, () -> "Could not display Category: " + category);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,7 +213,7 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (category instanceof FlexCategory) {
|
if (category instanceof FlexCategory) {
|
||||||
((FlexCategory) category).open(p, profile, getLayout());
|
((FlexCategory) category).open(p, profile, getMode());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -29,7 +29,7 @@ public enum AndroidType {
|
|||||||
FARMER,
|
FARMER,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link AdvancedFarmerAndroid} is an extension of the {@link FarmerAndroid},
|
* The Advanced Farmer is an extension of the {@link FarmerAndroid},
|
||||||
* it can also harvest plants from ExoticGarden.
|
* it can also harvest plants from ExoticGarden.
|
||||||
*/
|
*/
|
||||||
ADVANCED_FARMER,
|
ADVANCED_FARMER,
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package io.github.thebusybiscuit.slimefun4.implementation.items.androids;
|
package io.github.thebusybiscuit.slimefun4.implementation.items.androids;
|
||||||
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.concurrent.ThreadLocalRandom;
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
|
|
||||||
@ -12,11 +11,9 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.data.Ageable;
|
import org.bukkit.block.data.Ageable;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import io.github.thebusybiscuit.slimefun4.api.events.AndroidFarmEvent;
|
import io.github.thebusybiscuit.slimefun4.api.events.AndroidFarmEvent;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
|
||||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||||
@ -49,8 +46,6 @@ public class FarmerAndroid extends ProgrammableAndroid {
|
|||||||
AndroidFarmEvent event = new AndroidFarmEvent(block, instance, isAdvanced, drop);
|
AndroidFarmEvent event = new AndroidFarmEvent(block, instance, isAdvanced, drop);
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
|
||||||
handleExoticGarden(event);
|
|
||||||
|
|
||||||
if (!event.isCancelled()) {
|
if (!event.isCancelled()) {
|
||||||
drop = event.getDrop();
|
drop = event.getDrop();
|
||||||
|
|
||||||
@ -65,24 +60,6 @@ public class FarmerAndroid extends ProgrammableAndroid {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Deprecated method.
|
|
||||||
*
|
|
||||||
* @deprecated This will be moved into an {@link EventHandler} inside exoticgarden itself on the next update.
|
|
||||||
*
|
|
||||||
* @param event
|
|
||||||
* the event
|
|
||||||
* @param isAdvanced
|
|
||||||
* is advanced
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
private void handleExoticGarden(AndroidFarmEvent event) {
|
|
||||||
if (event.isAdvanced() && SlimefunPlugin.getIntegrations().isExoticGardenInstalled()) {
|
|
||||||
Optional<ItemStack> result = SlimefunPlugin.getThirdPartySupportService().harvestExoticGardenPlant(event.getBlock());
|
|
||||||
result.ifPresent(event::setDrop);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private ItemStack getDropFromCrop(Material crop) {
|
private ItemStack getDropFromCrop(Material crop) {
|
||||||
Random random = ThreadLocalRandom.current();
|
Random random = ThreadLocalRandom.current();
|
||||||
|
|
||||||
|
@ -0,0 +1,93 @@
|
|||||||
|
package io.github.thebusybiscuit.slimefun4.implementation.items.elevator;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.Validate;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This represents an {@link ElevatorFloor} to which a {@link Player}
|
||||||
|
* can travel to using an {@link ElevatorPlate}.
|
||||||
|
*
|
||||||
|
* @author TheBusyBiscuit
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class ElevatorFloor {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of this floor.
|
||||||
|
*/
|
||||||
|
private final String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The floor number.
|
||||||
|
*/
|
||||||
|
private final int number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@link Location} of this floor.
|
||||||
|
*/
|
||||||
|
private final Location location;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This constructs a new {@link ElevatorFloor} with the given name
|
||||||
|
* and the {@link Location} of the provided {@link Block}.
|
||||||
|
*
|
||||||
|
* @param name
|
||||||
|
* The name of this {@link ElevatorFloor}
|
||||||
|
* @param block
|
||||||
|
* The {@link Block} of this floor
|
||||||
|
*/
|
||||||
|
public ElevatorFloor(@Nonnull String name, int number, @Nonnull Block block) {
|
||||||
|
Validate.notNull(name, "An ElevatorFloor must have a name");
|
||||||
|
Validate.notNull(block, "An ElevatorFloor must have a block");
|
||||||
|
|
||||||
|
this.name = name;
|
||||||
|
this.number = number;
|
||||||
|
this.location = block.getLocation();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This returns the name of this {@link ElevatorFloor}.
|
||||||
|
*
|
||||||
|
* @return The name of this floor
|
||||||
|
*/
|
||||||
|
@Nonnull
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This returns the {@link Location} of this {@link ElevatorFloor}.
|
||||||
|
*
|
||||||
|
* @return The {@link Location} of this floor
|
||||||
|
*/
|
||||||
|
@Nonnull
|
||||||
|
public Location getLocation() {
|
||||||
|
return location;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This returns the "altitude" of this floor.
|
||||||
|
* This is equivalent to the Y level of {@link #getLocation()}.
|
||||||
|
*
|
||||||
|
* @return The altitude of this floor
|
||||||
|
*/
|
||||||
|
public int getAltitude() {
|
||||||
|
return location.getBlockY();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This returns the number of this floor.
|
||||||
|
* The lowest floor will have the number 0 and it
|
||||||
|
* increments from there.
|
||||||
|
*
|
||||||
|
* @return The number of this floor.
|
||||||
|
*/
|
||||||
|
public int getNumber() {
|
||||||
|
return number;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package io.github.thebusybiscuit.slimefun4.implementation.items.gps;
|
package io.github.thebusybiscuit.slimefun4.implementation.items.elevator;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
@ -12,22 +12,19 @@ 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.Inventory;
|
||||||
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;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.ChatUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.ChatUtils;
|
||||||
import io.papermc.lib.PaperLib;
|
import io.papermc.lib.PaperLib;
|
||||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
|
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
|
||||||
@ -42,7 +39,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
|||||||
* to teleport between them.
|
* to teleport between them.
|
||||||
*
|
*
|
||||||
* @author TheBusyBiscuit
|
* @author TheBusyBiscuit
|
||||||
*
|
* @author Walshy
|
||||||
*/
|
*/
|
||||||
public class ElevatorPlate extends SimpleSlimefunItem<BlockUseHandler> {
|
public class ElevatorPlate extends SimpleSlimefunItem<BlockUseHandler> {
|
||||||
|
|
||||||
@ -51,6 +48,11 @@ public class ElevatorPlate extends SimpleSlimefunItem<BlockUseHandler> {
|
|||||||
*/
|
*/
|
||||||
private static final String DATA_KEY = "floor";
|
private static final String DATA_KEY = "floor";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the size of our {@link Inventory}.
|
||||||
|
*/
|
||||||
|
private static final int GUI_SIZE = 27;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is our {@link Set} of currently teleporting {@link Player Players}.
|
* This is our {@link Set} of currently teleporting {@link Player Players}.
|
||||||
* It is used to prevent them from triggering the {@link ElevatorPlate} they land on.
|
* It is used to prevent them from triggering the {@link ElevatorPlate} they land on.
|
||||||
@ -77,6 +79,7 @@ public class ElevatorPlate extends SimpleSlimefunItem<BlockUseHandler> {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public BlockUseHandler getItemHandler() {
|
public BlockUseHandler getItemHandler() {
|
||||||
return e -> {
|
return e -> {
|
||||||
@ -89,19 +92,24 @@ public class ElevatorPlate extends SimpleSlimefunItem<BlockUseHandler> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public List<Block> getFloors(@Nonnull Block b) {
|
public List<ElevatorFloor> getFloors(@Nonnull Block b) {
|
||||||
List<Block> floors = new LinkedList<>();
|
LinkedList<ElevatorFloor> floors = new LinkedList<>();
|
||||||
|
int index = 0;
|
||||||
|
|
||||||
for (int y = b.getWorld().getMaxHeight(); y > 0; y--) {
|
for (int y = 0; y < b.getWorld().getMaxHeight(); y++) {
|
||||||
if (y == b.getY()) {
|
if (y == b.getY()) {
|
||||||
floors.add(b);
|
String name = ChatColors.color(BlockStorage.getLocationInfo(b.getLocation(), DATA_KEY));
|
||||||
|
floors.addFirst(new ElevatorFloor(name, index, b));
|
||||||
|
index++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Block block = b.getWorld().getBlockAt(b.getX(), y, b.getZ());
|
Block block = b.getWorld().getBlockAt(b.getX(), y, b.getZ());
|
||||||
|
|
||||||
if (block.getType() == getItem().getType() && BlockStorage.check(block, getId())) {
|
if (block.getType() == getItem().getType() && BlockStorage.check(block, getId())) {
|
||||||
floors.add(block);
|
String name = ChatColors.color(BlockStorage.getLocationInfo(block.getLocation(), DATA_KEY));
|
||||||
|
floors.addFirst(new ElevatorFloor(name, index, block));
|
||||||
|
index++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,54 +122,69 @@ public class ElevatorPlate extends SimpleSlimefunItem<BlockUseHandler> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Block> floors = getFloors(b);
|
List<ElevatorFloor> floors = getFloors(b);
|
||||||
|
|
||||||
if (floors.size() < 2) {
|
if (floors.size() < 2) {
|
||||||
SlimefunPlugin.getLocalization().sendMessage(p, "machines.ELEVATOR.no-destinations", true);
|
SlimefunPlugin.getLocalization().sendMessage(p, "machines.ELEVATOR.no-destinations", true);
|
||||||
} else {
|
} else {
|
||||||
openFloorSelector(b, floors, p);
|
openFloorSelector(b, floors, p, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParametersAreNonnullByDefault
|
@ParametersAreNonnullByDefault
|
||||||
private void openFloorSelector(Block b, List<Block> floors, Player p) {
|
private void openFloorSelector(Block b, List<ElevatorFloor> floors, Player p, int page) {
|
||||||
CustomBookInterface book = new CustomBookInterface(SlimefunPlugin.instance());
|
ChestMenu menu = new ChestMenu(SlimefunPlugin.getLocalization().getMessage(p, "machines.ELEVATOR.pick-a-floor"));
|
||||||
ChatComponent page = null;
|
menu.setEmptySlotsClickable(false);
|
||||||
|
|
||||||
for (int i = 0; i < floors.size(); i++) {
|
int index = GUI_SIZE * (page - 1);
|
||||||
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");
|
for (int i = 0; i < Math.min(GUI_SIZE, floors.size() - index); i++) {
|
||||||
}
|
ElevatorFloor floor = floors.get(index + i);
|
||||||
|
|
||||||
Block block = floors.get(i);
|
// @formatter:off
|
||||||
String floor = ChatColors.color(BlockStorage.getLocationInfo(block.getLocation(), DATA_KEY));
|
if (floor.getAltitude() == b.getY()) {
|
||||||
ChatComponent line;
|
menu.addItem(i, new CustomItem(
|
||||||
|
Material.COMPASS,
|
||||||
if (block.getY() == b.getY()) {
|
ChatColor.GRAY.toString() + floor.getNumber() + ". " + ChatColor.BLACK + floor.getName(),
|
||||||
line = new ChatComponent("\n" + ChatColor.GRAY + "> " + (floors.size() - i) + ". " + ChatColor.BLACK + floor);
|
SlimefunPlugin.getLocalization().getMessage(p, "machines.ELEVATOR.current-floor") + ' ' + ChatColor.WHITE + floor.getName()
|
||||||
line.setHoverEvent(new HoverEvent(ChatColors.color(SlimefunPlugin.getLocalization().getMessage(p, "machines.ELEVATOR.current-floor")), "", ChatColor.WHITE + floor, ""));
|
), ChestMenuUtils.getEmptyClickHandler());
|
||||||
} else {
|
} else {
|
||||||
line = new ChatComponent("\n" + ChatColor.GRAY + (floors.size() - i) + ". " + ChatColor.BLACK + floor);
|
menu.addItem(i, new CustomItem(
|
||||||
line.setHoverEvent(new HoverEvent(ChatColors.color(SlimefunPlugin.getLocalization().getMessage(p, "machines.ELEVATOR.click-to-teleport")), "", ChatColor.WHITE + floor, ""));
|
Material.PAPER,
|
||||||
line.setClickEvent(new ClickEvent(new NamespacedKey(SlimefunPlugin.instance(), DATA_KEY + i), player -> teleport(player, floor, block)));
|
ChatColor.GRAY.toString() + floor.getNumber() + ". " + ChatColor.BLACK + floor.getName(),
|
||||||
|
SlimefunPlugin.getLocalization().getMessage(p, "machines.ELEVATOR.click-to-teleport") + ' ' + ChatColor.WHITE + floor.getName()
|
||||||
|
), (player, slot, itemStack, clickAction) -> {
|
||||||
|
teleport(player, floor);
|
||||||
|
return false;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
// @formatter:on
|
||||||
page.append(line);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (page != null) {
|
int pages = 1 + (floors.size() / GUI_SIZE);
|
||||||
book.addPage(page);
|
|
||||||
|
// 0 index so size is the first slot of the last row.
|
||||||
|
for (int i = GUI_SIZE; i < GUI_SIZE + 9; i++) {
|
||||||
|
if (i == GUI_SIZE + 2 && pages > 1 && page != 1) {
|
||||||
|
menu.addItem(i, ChestMenuUtils.getPreviousButton(p, page, pages), (player, i1, itemStack, clickAction) -> {
|
||||||
|
openFloorSelector(b, floors, p, page - 1);
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
} else if (i == GUI_SIZE + 6 && pages > 1 && page != pages) {
|
||||||
|
menu.addItem(i, ChestMenuUtils.getNextButton(p, page, pages), (player, i1, itemStack, clickAction) -> {
|
||||||
|
openFloorSelector(b, floors, p, page + 1);
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
menu.addItem(i, ChestMenuUtils.getBackground(), (player, i1, itemStack, clickAction) -> false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
book.open(p);
|
menu.open(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParametersAreNonnullByDefault
|
@ParametersAreNonnullByDefault
|
||||||
private void teleport(Player player, String floorName, Block target) {
|
private void teleport(Player player, ElevatorFloor floor) {
|
||||||
SlimefunPlugin.runSync(() -> {
|
SlimefunPlugin.runSync(() -> {
|
||||||
users.add(player.getUniqueId());
|
users.add(player.getUniqueId());
|
||||||
|
|
||||||
@ -171,11 +194,12 @@ public class ElevatorPlate extends SimpleSlimefunItem<BlockUseHandler> {
|
|||||||
yaw = -180 + (yaw - 180);
|
yaw = -180 + (yaw - 180);
|
||||||
}
|
}
|
||||||
|
|
||||||
Location destination = new Location(player.getWorld(), target.getX() + 0.5, target.getY() + 0.4, target.getZ() + 0.5, yaw, player.getEyeLocation().getPitch());
|
Location loc = floor.getLocation();
|
||||||
|
Location destination = new Location(player.getWorld(), loc.getX() + 0.5, loc.getY() + 0.4, loc.getZ() + 0.5, yaw, player.getEyeLocation().getPitch());
|
||||||
|
|
||||||
PaperLib.teleportAsync(player, destination).thenAccept(teleported -> {
|
PaperLib.teleportAsync(player, destination).thenAccept(teleported -> {
|
||||||
if (teleported.booleanValue()) {
|
if (teleported.booleanValue()) {
|
||||||
player.sendTitle(ChatColor.WHITE + ChatColors.color(floorName), null, 20, 60, 20);
|
player.sendTitle(ChatColor.WHITE + ChatColors.color(floor.getName()), null, 20, 60, 20);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
@ -0,0 +1,5 @@
|
|||||||
|
/**
|
||||||
|
* This package holds the {@link io.github.thebusybiscuit.slimefun4.implementation.items.elevator.ElevatorPlate} and any
|
||||||
|
* related classes to making the elevator work.
|
||||||
|
*/
|
||||||
|
package io.github.thebusybiscuit.slimefun4.implementation.items.elevator;
|
@ -12,10 +12,10 @@ 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.SlimefunGuideMode;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.guide.options.SlimefunGuideSettings;
|
import io.github.thebusybiscuit.slimefun4.core.guide.options.SlimefunGuideSettings;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
||||||
@ -38,7 +38,7 @@ public class SlimefunGuideListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SlimefunGuideLayout type = SlimefunGuide.getDefaultLayout();
|
SlimefunGuideMode type = SlimefunGuide.getDefaultLayout();
|
||||||
p.getInventory().addItem(SlimefunGuide.getItem(type).clone());
|
p.getInventory().addItem(SlimefunGuide.getItem(type).clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -47,31 +47,27 @@ 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, SlimefunGuideMode.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, SlimefunGuideMode.SURVIVAL_MODE);
|
||||||
}
|
}
|
||||||
} else if (tryOpenGuide(p, e, SlimefunGuideLayout.CHEST) == Result.ALLOW) {
|
} else if (tryOpenGuide(p, e, SlimefunGuideMode.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");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParametersAreNonnullByDefault
|
@ParametersAreNonnullByDefault
|
||||||
private void openGuide(Player p, PlayerRightClickEvent e, SlimefunGuideLayout layout) {
|
private void openGuide(Player p, PlayerRightClickEvent e, SlimefunGuideMode layout) {
|
||||||
SlimefunGuideOpenEvent event = new SlimefunGuideOpenEvent(p, e.getItem(), layout);
|
SlimefunGuideOpenEvent event = new SlimefunGuideOpenEvent(p, e.getItem(), layout);
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
|
||||||
@ -83,7 +79,7 @@ public class SlimefunGuideListener implements Listener {
|
|||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@ParametersAreNonnullByDefault
|
@ParametersAreNonnullByDefault
|
||||||
private Result tryOpenGuide(Player p, PlayerRightClickEvent e, SlimefunGuideLayout layout) {
|
private Result tryOpenGuide(Player p, PlayerRightClickEvent e, SlimefunGuideMode layout) {
|
||||||
ItemStack item = e.getItem();
|
ItemStack item = e.getItem();
|
||||||
if (SlimefunUtils.isItemSimilar(item, SlimefunGuide.getItem(layout), true, false)) {
|
if (SlimefunUtils.isItemSimilar(item, SlimefunGuide.getItem(layout), true, false)) {
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ import org.bukkit.event.player.PlayerInteractEvent;
|
|||||||
|
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.gps.ElevatorPlate;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.elevator.ElevatorPlate;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.gps.Teleporter;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.gps.Teleporter;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||||
|
@ -109,6 +109,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines
|
|||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.XPCollector;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.XPCollector;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors.NetherStarReactor;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors.NetherStarReactor;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors.NuclearReactor;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors.NuclearReactor;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.implementation.items.elevator.ElevatorPlate;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.food.BirthdayCake;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.food.BirthdayCake;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.food.DietCookie;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.food.DietCookie;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.food.FortuneCookie;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.food.FortuneCookie;
|
||||||
@ -121,7 +122,6 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.geo.GEOMiner;
|
|||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.geo.GEOScanner;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.geo.GEOScanner;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.geo.OilPump;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.geo.OilPump;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.geo.PortableGEOScanner;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.geo.PortableGEOScanner;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.gps.ElevatorPlate;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.gps.GPSControlPanel;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.gps.GPSControlPanel;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.gps.GPSMarkerTool;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.gps.GPSMarkerTool;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.gps.GPSTransmitter;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.gps.GPSTransmitter;
|
||||||
|
@ -55,7 +55,6 @@ public class IntegrationsManager {
|
|||||||
|
|
||||||
// Addon support
|
// Addon support
|
||||||
private boolean isChestTerminalInstalled = false;
|
private boolean isChestTerminalInstalled = false;
|
||||||
private boolean isExoticGardenInstalled = false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This initializes the {@link IntegrationsManager}
|
* This initializes the {@link IntegrationsManager}
|
||||||
@ -140,7 +139,6 @@ public class IntegrationsManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
isChestTerminalInstalled = isAddonInstalled("ChestTerminal");
|
isChestTerminalInstalled = isAddonInstalled("ChestTerminal");
|
||||||
isExoticGardenInstalled = isAddonInstalled("ExoticGarden");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -249,8 +247,4 @@ public class IntegrationsManager {
|
|||||||
return isChestTerminalInstalled;
|
return isChestTerminalInstalled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isExoticGardenInstalled() {
|
|
||||||
return isExoticGardenInstalled;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package io.github.thebusybiscuit.slimefun4.utils.itemstack;
|
package io.github.thebusybiscuit.slimefun4.utils.itemstack;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
@ -10,10 +10,11 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.chat.ChatColors;
|
import io.github.thebusybiscuit.cscorelib2.chat.ChatColors;
|
||||||
|
import io.github.thebusybiscuit.cscorelib2.data.PersistentDataAPI;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
|
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideImplementation;
|
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideImplementation;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.guide.CheatSheetSlimefunGuide;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is just a helper {@link ItemStack} class for the {@link SlimefunGuide} {@link ItemStack}.
|
* This is just a helper {@link ItemStack} class for the {@link SlimefunGuide} {@link ItemStack}.
|
||||||
@ -32,12 +33,15 @@ public class SlimefunGuideItem extends ItemStack {
|
|||||||
ItemMeta meta = getItemMeta();
|
ItemMeta meta = getItemMeta();
|
||||||
meta.setDisplayName(ChatColors.color(name));
|
meta.setDisplayName(ChatColors.color(name));
|
||||||
|
|
||||||
List<String> lore = new LinkedList<>();
|
List<String> lore = new ArrayList<>();
|
||||||
lore.add(implementation instanceof CheatSheetSlimefunGuide ? ChatColors.color("&4&lOnly openable by Admins") : "");
|
SlimefunGuideMode type = implementation.getMode();
|
||||||
|
lore.add(type == SlimefunGuideMode.CHEAT_MODE ? ChatColors.color("&4&lOnly openable by Admins") : "");
|
||||||
lore.add(ChatColors.color("&eRight Click &8\u21E8 &7Browse Items"));
|
lore.add(ChatColors.color("&eRight Click &8\u21E8 &7Browse Items"));
|
||||||
lore.add(ChatColors.color("&eShift + Right Click &8\u21E8 &7Open Settings / Credits"));
|
lore.add(ChatColors.color("&eShift + Right Click &8\u21E8 &7Open Settings / Credits"));
|
||||||
|
|
||||||
meta.setLore(lore);
|
meta.setLore(lore);
|
||||||
|
|
||||||
|
PersistentDataAPI.setString(meta, SlimefunPlugin.getRegistry().getGuideDataKey(), type.name());
|
||||||
SlimefunPlugin.getItemTextureService().setTexture(meta, "SLIMEFUN_GUIDE");
|
SlimefunPlugin.getItemTextureService().setTexture(meta, "SLIMEFUN_GUIDE");
|
||||||
|
|
||||||
setItemMeta(meta);
|
setItemMeta(meta);
|
||||||
|
@ -7,6 +7,7 @@ import java.util.Comparator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import javax.annotation.ParametersAreNonnullByDefault;
|
import javax.annotation.ParametersAreNonnullByDefault;
|
||||||
|
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
@ -19,6 +20,7 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.categories.LockedCategory;
|
import io.github.thebusybiscuit.slimefun4.core.categories.LockedCategory;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.categories.SeasonalCategory;
|
import io.github.thebusybiscuit.slimefun4.core.categories.SeasonalCategory;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
|
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
|
||||||
@ -37,6 +39,8 @@ import me.mrCookieSlime.Slimefun.api.Slimefun;
|
|||||||
*/
|
*/
|
||||||
public class Category implements Keyed {
|
public class Category implements Keyed {
|
||||||
|
|
||||||
|
private SlimefunAddon addon;
|
||||||
|
|
||||||
protected final List<SlimefunItem> items = new ArrayList<>();
|
protected final List<SlimefunItem> items = new ArrayList<>();
|
||||||
protected final NamespacedKey key;
|
protected final NamespacedKey key;
|
||||||
protected final ItemStack item;
|
protected final ItemStack item;
|
||||||
@ -94,12 +98,40 @@ public class Category implements Keyed {
|
|||||||
* Registers this category.
|
* Registers this category.
|
||||||
* <p>
|
* <p>
|
||||||
* By default, a category is automatically registered when a {@link SlimefunItem} was added to it.
|
* By default, a category is automatically registered when a {@link SlimefunItem} was added to it.
|
||||||
|
*
|
||||||
|
* @param addon
|
||||||
|
* The {@link SlimefunAddon} that wants to register this {@link Category}
|
||||||
*/
|
*/
|
||||||
|
public void register(@Nonnull SlimefunAddon addon) {
|
||||||
|
Validate.notNull(addon, "The Addon cannot be null");
|
||||||
|
this.addon = addon;
|
||||||
|
|
||||||
|
SlimefunPlugin.getRegistry().getCategories().add(this);
|
||||||
|
Collections.sort(SlimefunPlugin.getRegistry().getCategories(), Comparator.comparingInt(Category::getTier));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Old way of registering categories, do not call this manually.
|
||||||
|
*
|
||||||
|
* @deprecated Please use {@link #register(SlimefunAddon)} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
public void register() {
|
public void register() {
|
||||||
SlimefunPlugin.getRegistry().getCategories().add(this);
|
SlimefunPlugin.getRegistry().getCategories().add(this);
|
||||||
Collections.sort(SlimefunPlugin.getRegistry().getCategories(), Comparator.comparingInt(Category::getTier));
|
Collections.sort(SlimefunPlugin.getRegistry().getCategories(), Comparator.comparingInt(Category::getTier));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This returns the {@link SlimefunAddon} which has registered this {@link Category}.
|
||||||
|
* Or null if it has not been registered yet.
|
||||||
|
*
|
||||||
|
* @return The {@link SlimefunAddon} or null if unregistered
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public final SlimefunAddon getAddon() {
|
||||||
|
return addon;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the given {@link SlimefunItem} to this {@link Category}.
|
* Adds the given {@link SlimefunItem} to this {@link Category}.
|
||||||
*
|
*
|
||||||
|
@ -477,7 +477,7 @@ public class SlimefunItem implements Placeable {
|
|||||||
private final void onEnable() {
|
private final void onEnable() {
|
||||||
// Register the Category too if it hasn't been registered yet
|
// Register the Category too if it hasn't been registered yet
|
||||||
if (!category.isRegistered()) {
|
if (!category.isRegistered()) {
|
||||||
category.register();
|
category.register(addon);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send out deprecation warnings for any classes or interfaces
|
// Send out deprecation warnings for any classes or interfaces
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
package me.mrCookieSlime.Slimefun.api;
|
package me.mrCookieSlime.Slimefun.api;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@ -25,17 +22,6 @@ public final class Slimefun {
|
|||||||
|
|
||||||
private Slimefun() {}
|
private Slimefun() {}
|
||||||
|
|
||||||
/**
|
|
||||||
* This returns the {@link Logger} for Slimefun.
|
|
||||||
*
|
|
||||||
* @deprecated Use {@link SlimefunPlugin#logger()} instead
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
@Nonnull
|
|
||||||
public static Logger getLogger() {
|
|
||||||
return SlimefunPlugin.logger();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if this player can use this item.
|
* Checks if this player can use this item.
|
||||||
*
|
*
|
||||||
|
@ -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
|
||||||
|
|
||||||
|
@ -23,7 +23,6 @@ softdepend:
|
|||||||
# We hook into these plugins too, but they depend on Slimefun.
|
# We hook into these plugins too, but they depend on Slimefun.
|
||||||
loadBefore:
|
loadBefore:
|
||||||
- ChestTerminal
|
- ChestTerminal
|
||||||
- ExoticGarden
|
|
||||||
|
|
||||||
# Our commands
|
# Our commands
|
||||||
commands:
|
commands:
|
||||||
|
@ -12,7 +12,7 @@ import org.junit.jupiter.params.provider.ValueSource;
|
|||||||
import be.seeseemelk.mockbukkit.MockBukkit;
|
import be.seeseemelk.mockbukkit.MockBukkit;
|
||||||
import be.seeseemelk.mockbukkit.ServerMock;
|
import be.seeseemelk.mockbukkit.ServerMock;
|
||||||
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.SlimefunGuideMode;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
||||||
|
|
||||||
@ -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(SlimefunGuideMode.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.BookSlimefunGuide;
|
|
||||||
|
|
||||||
class TestBookSlimefunGuide {
|
|
||||||
|
|
||||||
@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() {
|
|
||||||
BookSlimefunGuide guide = new BookSlimefunGuide();
|
|
||||||
|
|
||||||
Assertions.assertEquals(SlimefunGuideLayout.BOOK, guide.getLayout());
|
|
||||||
Assertions.assertTrue(guide.isSurvivalMode());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -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());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -22,7 +22,7 @@ import be.seeseemelk.mockbukkit.MockBukkit;
|
|||||||
import be.seeseemelk.mockbukkit.ServerMock;
|
import be.seeseemelk.mockbukkit.ServerMock;
|
||||||
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
||||||
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.SlimefunGuideMode;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.VanillaItem;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.VanillaItem;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting.GrindstoneListener;
|
import io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting.GrindstoneListener;
|
||||||
@ -82,8 +82,8 @@ public class TestGrindstoneListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@EnumSource(SlimefunGuideLayout.class)
|
@EnumSource(SlimefunGuideMode.class)
|
||||||
public void testGrindStoneWithSlimefunGuide(SlimefunGuideLayout layout) {
|
public void testGrindStoneWithSlimefunGuide(SlimefunGuideMode layout) {
|
||||||
InventoryClickEvent event = mockGrindStoneEvent(SlimefunGuide.getItem(layout));
|
InventoryClickEvent event = mockGrindStoneEvent(SlimefunGuide.getItem(layout));
|
||||||
Assertions.assertEquals(Result.DENY, event.getResult());
|
Assertions.assertEquals(Result.DENY, event.getResult());
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import org.junit.jupiter.api.AfterAll;
|
import org.junit.jupiter.api.AfterAll;
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
|
import org.junit.jupiter.api.DisplayName;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import be.seeseemelk.mockbukkit.MockBukkit;
|
import be.seeseemelk.mockbukkit.MockBukkit;
|
||||||
@ -19,7 +20,7 @@ import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
|
|||||||
import io.github.thebusybiscuit.slimefun4.core.categories.FlexCategory;
|
import io.github.thebusybiscuit.slimefun4.core.categories.FlexCategory;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.categories.LockedCategory;
|
import io.github.thebusybiscuit.slimefun4.core.categories.LockedCategory;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.categories.SeasonalCategory;
|
import io.github.thebusybiscuit.slimefun4.core.categories.SeasonalCategory;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout;
|
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode;
|
||||||
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.testing.TestUtilities;
|
import io.github.thebusybiscuit.slimefun4.testing.TestUtilities;
|
||||||
@ -28,7 +29,7 @@ import me.mrCookieSlime.Slimefun.Objects.Category;
|
|||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||||
|
|
||||||
public class TestCategories {
|
class TestCategories {
|
||||||
|
|
||||||
private static ServerMock server;
|
private static ServerMock server;
|
||||||
private static SlimefunPlugin plugin;
|
private static SlimefunPlugin plugin;
|
||||||
@ -45,17 +46,23 @@ public class TestCategories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCategoryGetters() {
|
@DisplayName("Test the Getters for Category")
|
||||||
|
void testCategoryGetters() {
|
||||||
Category category = new Category(new NamespacedKey(plugin, "getter_test"), new CustomItem(Material.DIAMOND_AXE, "&6Testing"));
|
Category category = new Category(new NamespacedKey(plugin, "getter_test"), new CustomItem(Material.DIAMOND_AXE, "&6Testing"));
|
||||||
|
|
||||||
Assertions.assertEquals(3, category.getTier());
|
Assertions.assertEquals(3, category.getTier());
|
||||||
Assertions.assertEquals(new NamespacedKey(SlimefunPlugin.instance(), "getter_test"), category.getKey());
|
Assertions.assertEquals(new NamespacedKey(SlimefunPlugin.instance(), "getter_test"), category.getKey());
|
||||||
Assertions.assertEquals("Testing", category.getUnlocalizedName());
|
Assertions.assertEquals("Testing", category.getUnlocalizedName());
|
||||||
Assertions.assertEquals(0, category.getItems().size());
|
Assertions.assertEquals(0, category.getItems().size());
|
||||||
|
|
||||||
|
Assertions.assertNull(category.getAddon());
|
||||||
|
category.register(plugin);
|
||||||
|
Assertions.assertEquals(plugin, category.getAddon());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAddItem() {
|
@DisplayName("Test adding an item to a Category")
|
||||||
|
void testAddItem() {
|
||||||
Category category = new Category(new NamespacedKey(plugin, "items_test"), new CustomItem(Material.DIAMOND_AXE, "&6Testing"));
|
Category category = new Category(new NamespacedKey(plugin, "items_test"), new CustomItem(Material.DIAMOND_AXE, "&6Testing"));
|
||||||
SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "CATEGORY_ITEMS_TEST_ITEM", new CustomItem(Material.BAMBOO, "&6Test Bamboo"));
|
SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "CATEGORY_ITEMS_TEST_ITEM", new CustomItem(Material.BAMBOO, "&6Test Bamboo"));
|
||||||
item.setCategory(category);
|
item.setCategory(category);
|
||||||
@ -73,7 +80,8 @@ public class TestCategories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHidden() {
|
@DisplayName("Test hidden Categories")
|
||||||
|
void testHidden() {
|
||||||
Category category = new Category(new NamespacedKey(plugin, "hiddenCategory"), new ItemStack(Material.BEACON));
|
Category category = new Category(new NamespacedKey(plugin, "hiddenCategory"), new ItemStack(Material.BEACON));
|
||||||
Player player = server.addPlayer();
|
Player player = server.addPlayer();
|
||||||
|
|
||||||
@ -103,7 +111,8 @@ public class TestCategories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testContains() {
|
@DisplayName("Test Category#contains")
|
||||||
|
void testContains() {
|
||||||
SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "CATEGORY_TEST_ITEM_2", new CustomItem(Material.BOW, "&6Test Bow"));
|
SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "CATEGORY_TEST_ITEM_2", new CustomItem(Material.BOW, "&6Test Bow"));
|
||||||
item.register(plugin);
|
item.register(plugin);
|
||||||
item.load();
|
item.load();
|
||||||
@ -118,16 +127,17 @@ public class TestCategories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testLockedCategoriesParents() {
|
@DisplayName("Test LockedCategory parental locking")
|
||||||
|
void testLockedCategoriesParents() {
|
||||||
Assertions.assertThrows(IllegalArgumentException.class, () -> new LockedCategory(new NamespacedKey(plugin, "locked"), new CustomItem(Material.GOLD_NUGGET, "&6Locked Test"), (NamespacedKey) null));
|
Assertions.assertThrows(IllegalArgumentException.class, () -> new LockedCategory(new NamespacedKey(plugin, "locked"), new CustomItem(Material.GOLD_NUGGET, "&6Locked Test"), (NamespacedKey) null));
|
||||||
|
|
||||||
Category category = new Category(new NamespacedKey(plugin, "unlocked"), new CustomItem(Material.EMERALD, "&5I am SHERlocked"));
|
Category category = new Category(new NamespacedKey(plugin, "unlocked"), new CustomItem(Material.EMERALD, "&5I am SHERlocked"));
|
||||||
category.register();
|
category.register(plugin);
|
||||||
|
|
||||||
Category unregistered = new Category(new NamespacedKey(plugin, "unregistered"), new CustomItem(Material.EMERALD, "&5I am unregistered"));
|
Category unregistered = new Category(new NamespacedKey(plugin, "unregistered"), new CustomItem(Material.EMERALD, "&5I am unregistered"));
|
||||||
|
|
||||||
LockedCategory locked = new LockedCategory(new NamespacedKey(plugin, "locked"), new CustomItem(Material.GOLD_NUGGET, "&6Locked Test"), category.getKey(), unregistered.getKey());
|
LockedCategory locked = new LockedCategory(new NamespacedKey(plugin, "locked"), new CustomItem(Material.GOLD_NUGGET, "&6Locked Test"), category.getKey(), unregistered.getKey());
|
||||||
locked.register();
|
locked.register(plugin);
|
||||||
|
|
||||||
Assertions.assertTrue(locked.getParents().contains(category));
|
Assertions.assertTrue(locked.getParents().contains(category));
|
||||||
Assertions.assertFalse(locked.getParents().contains(unregistered));
|
Assertions.assertFalse(locked.getParents().contains(unregistered));
|
||||||
@ -143,17 +153,18 @@ public class TestCategories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testLockedCategoriesUnlocking() throws InterruptedException {
|
@DisplayName("Test an unlocked LockedCategory")
|
||||||
|
void testLockedCategoriesUnlocking() throws InterruptedException {
|
||||||
Player player = server.addPlayer();
|
Player player = server.addPlayer();
|
||||||
PlayerProfile profile = TestUtilities.awaitProfile(player);
|
PlayerProfile profile = TestUtilities.awaitProfile(player);
|
||||||
|
|
||||||
Assertions.assertThrows(IllegalArgumentException.class, () -> new LockedCategory(new NamespacedKey(plugin, "locked"), new CustomItem(Material.GOLD_NUGGET, "&6Locked Test"), (NamespacedKey) null));
|
Assertions.assertThrows(IllegalArgumentException.class, () -> new LockedCategory(new NamespacedKey(plugin, "locked"), new CustomItem(Material.GOLD_NUGGET, "&6Locked Test"), (NamespacedKey) null));
|
||||||
|
|
||||||
Category category = new Category(new NamespacedKey(plugin, "parent"), new CustomItem(Material.EMERALD, "&5I am SHERlocked"));
|
Category category = new Category(new NamespacedKey(plugin, "parent"), new CustomItem(Material.EMERALD, "&5I am SHERlocked"));
|
||||||
category.register();
|
category.register(plugin);
|
||||||
|
|
||||||
LockedCategory locked = new LockedCategory(new NamespacedKey(plugin, "locked"), new CustomItem(Material.GOLD_NUGGET, "&6Locked Test"), category.getKey());
|
LockedCategory locked = new LockedCategory(new NamespacedKey(plugin, "locked"), new CustomItem(Material.GOLD_NUGGET, "&6Locked Test"), category.getKey());
|
||||||
locked.register();
|
locked.register(plugin);
|
||||||
|
|
||||||
// No Items, so it should be unlocked
|
// No Items, so it should be unlocked
|
||||||
Assertions.assertTrue(locked.hasUnlocked(player, profile));
|
Assertions.assertTrue(locked.hasUnlocked(player, profile));
|
||||||
@ -176,7 +187,8 @@ public class TestCategories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSeasonalCategories() {
|
@DisplayName("Test a seasonal Category")
|
||||||
|
void testSeasonalCategories() {
|
||||||
// Category with current Month
|
// Category with current Month
|
||||||
Month month = LocalDate.now().getMonth();
|
Month month = LocalDate.now().getMonth();
|
||||||
SeasonalCategory category = new SeasonalCategory(new NamespacedKey(plugin, "seasonal"), month, 1, new CustomItem(Material.NETHER_STAR, "&cSeasonal Test"));
|
SeasonalCategory category = new SeasonalCategory(new NamespacedKey(plugin, "seasonal"), month, 1, new CustomItem(Material.NETHER_STAR, "&cSeasonal Test"));
|
||||||
@ -196,16 +208,17 @@ public class TestCategories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFlexCategory() {
|
@DisplayName("Test the FlexCategory")
|
||||||
|
void testFlexCategory() {
|
||||||
FlexCategory category = new FlexCategory(new NamespacedKey(plugin, "flex"), new CustomItem(Material.REDSTONE, "&4Weird flex but ok")) {
|
FlexCategory category = new FlexCategory(new NamespacedKey(plugin, "flex"), new CustomItem(Material.REDSTONE, "&4Weird flex but ok")) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void open(Player p, PlayerProfile profile, SlimefunGuideLayout layout) {
|
public void open(Player p, PlayerProfile profile, SlimefunGuideMode layout) {
|
||||||
// Nothing
|
// Nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isVisible(Player p, PlayerProfile profile, SlimefunGuideLayout layout) {
|
public boolean isVisible(Player p, PlayerProfile profile, SlimefunGuideMode layout) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user