diff --git a/CHANGELOG.md b/CHANGELOG.md index a69c8c260..d8d87341f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,7 @@ * Fixed a translation not showing properly * Fixed #1577 * Fixed #1597 +* Fixed disabled Slimefun Addons not showing under /sf versions ## Release Candidate 6 (16 Feb 2020) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/SlimefunBranch.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/SlimefunBranch.java index 5eee54dc1..bbf830007 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/SlimefunBranch.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/SlimefunBranch.java @@ -1,20 +1,33 @@ package io.github.thebusybiscuit.slimefun4.api; +/** + * This enum represents the branch this Slimefun build is on. + * development or stable, unofficial or even unknown. + * + * @author TheBusyBiscuit + * + */ public enum SlimefunBranch { - DEVELOPMENT("master"), - STABLE("stable"), - UNOFFICIAL("Unknown"), - UNKNOWN("Unknown"); + DEVELOPMENT("master", true), + STABLE("stable", true), + UNOFFICIAL("Unknown", false), + UNKNOWN("Unknown", false); private final String name; + private final boolean official; - private SlimefunBranch(String name) { + private SlimefunBranch(String name, boolean official) { this.name = name; + this.official = official; } public String getName() { return name; } + public boolean isOfficial() { + return official; + } + } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/SlimefunRegistry.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/SlimefunRegistry.java index a519caf0b..bd15803c8 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/SlimefunRegistry.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/SlimefunRegistry.java @@ -16,10 +16,10 @@ import org.bukkit.inventory.ItemStack; import io.github.thebusybiscuit.cscorelib2.collections.KeyMap; import io.github.thebusybiscuit.slimefun4.api.geo.GEOResource; -import io.github.thebusybiscuit.slimefun4.core.guide.BookSlimefunGuide; -import io.github.thebusybiscuit.slimefun4.core.guide.ChestSlimefunGuide; -import io.github.thebusybiscuit.slimefun4.core.guide.ISlimefunGuide; +import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideImplementation; import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout; +import io.github.thebusybiscuit.slimefun4.implementation.guide.BookSlimefunGuide; +import io.github.thebusybiscuit.slimefun4.implementation.guide.ChestSlimefunGuide; import me.mrCookieSlime.Slimefun.SlimefunPlugin; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.Objects.Research; @@ -66,7 +66,7 @@ public class SlimefunRegistry { private final Map worlds = new HashMap<>(); private final Map chunks = new HashMap<>(); private final Map profiles = new HashMap<>(); - private final Map layouts = new EnumMap<>(SlimefunGuideLayout.class); + private final Map layouts = new EnumMap<>(SlimefunGuideLayout.class); private final Map> drops = new EnumMap<>(EntityType.class); private final Map capacities = new HashMap<>(); private final Map blockMenuPresets = new HashMap<>(); @@ -80,7 +80,7 @@ public class SlimefunRegistry { private final Map automatedCraftingChamberRecipes = new HashMap<>(); public SlimefunRegistry() { - ISlimefunGuide chestGuide = new ChestSlimefunGuide(SlimefunPlugin.getCfg().getBoolean("options.show-vanilla-recipes-in-guide")); + SlimefunGuideImplementation chestGuide = new ChestSlimefunGuide(SlimefunPlugin.getCfg().getBoolean("options.show-vanilla-recipes-in-guide")); layouts.put(SlimefunGuideLayout.CHEST, chestGuide); layouts.put(SlimefunGuideLayout.CHEAT_SHEET, chestGuide); layouts.put(SlimefunGuideLayout.BOOK, new BookSlimefunGuide()); @@ -120,7 +120,7 @@ public class SlimefunRegistry { return multiblocks; } - public ISlimefunGuide getGuideLayout(SlimefunGuideLayout layout) { + public SlimefunGuideImplementation getGuideLayout(SlimefunGuideLayout layout) { return layouts.get(layout); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/CheatCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/CheatCommand.java index 053c4b7d2..34b8e80c9 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/CheatCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/CheatCommand.java @@ -5,7 +5,7 @@ import org.bukkit.entity.Player; import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand; import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand; -import me.mrCookieSlime.Slimefun.SlimefunGuide; +import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide; import me.mrCookieSlime.Slimefun.SlimefunPlugin; public class CheatCommand extends SubCommand { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/GuideCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/GuideCommand.java index 99cd48380..9936e502c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/GuideCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/GuideCommand.java @@ -5,8 +5,8 @@ import org.bukkit.entity.Player; import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand; import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand; +import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide; import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout; -import me.mrCookieSlime.Slimefun.SlimefunGuide; import me.mrCookieSlime.Slimefun.SlimefunPlugin; public class GuideCommand extends SubCommand { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/OpenGuideCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/OpenGuideCommand.java index dd3aba3f3..95d3974bb 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/OpenGuideCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/OpenGuideCommand.java @@ -5,8 +5,8 @@ import org.bukkit.entity.Player; import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand; import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand; +import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide; import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout; -import me.mrCookieSlime.Slimefun.SlimefunGuide; import me.mrCookieSlime.Slimefun.SlimefunPlugin; public class OpenGuideCommand extends SubCommand { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SearchCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SearchCommand.java index 1178aa3bd..c071da431 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SearchCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SearchCommand.java @@ -7,7 +7,7 @@ import org.bukkit.entity.Player; import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand; import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand; -import me.mrCookieSlime.Slimefun.SlimefunGuide; +import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide; import me.mrCookieSlime.Slimefun.SlimefunPlugin; import me.mrCookieSlime.Slimefun.api.PlayerProfile; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/ISlimefunGuide.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/ISlimefunGuide.java deleted file mode 100644 index f4ceb7543..000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/ISlimefunGuide.java +++ /dev/null @@ -1,51 +0,0 @@ -package io.github.thebusybiscuit.slimefun4.core.guide; - -import java.util.LinkedList; - -import org.bukkit.ChatColor; -import org.bukkit.inventory.ItemStack; - -import me.mrCookieSlime.Slimefun.Objects.Category; -import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; -import me.mrCookieSlime.Slimefun.api.GuideHandler; -import me.mrCookieSlime.Slimefun.api.PlayerProfile; - -public interface ISlimefunGuide { - - SlimefunGuideLayout getLayout(); - ItemStack getItem(); - - void openMainMenu(PlayerProfile profile, boolean survival, int page); - void openCategory(PlayerProfile profile, Category category, boolean survival, int page); - void openSearch(PlayerProfile profile, String input, boolean survival, boolean addToHistory); - void displayItem(PlayerProfile profile, ItemStack item, boolean addToHistory); - void displayItem(PlayerProfile profile, SlimefunItem item, boolean addToHistory); - - default String shorten(String string, String string2) { - if (ChatColor.stripColor(string + string2).length() > 19) { - return (string + ChatColor.stripColor(string2)).substring(0, 18) + "..."; - } - else { - return string + ChatColor.stripColor(string2); - } - } - - default Object getLastEntry(PlayerProfile profile, boolean remove) { - LinkedList history = profile.getGuideHistory(); - - if (remove && !history.isEmpty()) { - history.removeLast(); - } - - return history.isEmpty() ? null: history.getLast(); - } - - default void handleHistory(PlayerProfile profile, Object last, boolean survival) { - if (last == null) openMainMenu(profile, survival, 1); - else if (last instanceof Category) openCategory(profile, (Category) last, survival, 1); - else if (last instanceof SlimefunItem) displayItem(profile, (SlimefunItem) last, false); - else if (last instanceof GuideHandler) ((GuideHandler) last).run(profile.getPlayer(), survival, getLayout() == SlimefunGuideLayout.BOOK); - else if (last instanceof String) openSearch(profile, (String) last, survival, false); - else displayItem(profile, (ItemStack) last, false); - } -} diff --git a/src/main/java/me/mrCookieSlime/Slimefun/SlimefunGuide.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuide.java similarity index 93% rename from src/main/java/me/mrCookieSlime/Slimefun/SlimefunGuide.java rename to src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuide.java index 1905b5c21..0e1caf52b 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/SlimefunGuide.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuide.java @@ -1,4 +1,4 @@ -package me.mrCookieSlime.Slimefun; +package io.github.thebusybiscuit.slimefun4.core.guide; import java.util.Arrays; import java.util.LinkedList; @@ -11,8 +11,7 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import io.github.thebusybiscuit.cscorelib2.chat.ChatColors; -import io.github.thebusybiscuit.slimefun4.core.guide.ISlimefunGuide; -import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout; +import me.mrCookieSlime.Slimefun.SlimefunPlugin; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; import me.mrCookieSlime.Slimefun.Setup.SlimefunManager; @@ -74,13 +73,13 @@ public final class SlimefunGuide { if (!SlimefunPlugin.getWhitelist().getBoolean(p.getWorld().getName() + ".enabled")) return; if (!SlimefunPlugin.getWhitelist().getBoolean(p.getWorld().getName() + ".enabled-items.SLIMEFUN_GUIDE")) return; - ISlimefunGuide guide = SlimefunPlugin.getRegistry().getGuideLayout(layout); + SlimefunGuideImplementation guide = SlimefunPlugin.getRegistry().getGuideLayout(layout); Object last = null; Optional profile = PlayerProfile.find(p); if (profile.isPresent()) { last = guide.getLastEntry(profile.get(), false); - guide.handleHistory(profile.get(), last, true); + guide.openEntry(profile.get(), last, true); } else { openMainMenuAsync(p, true, layout, 1); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuideImplementation.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuideImplementation.java new file mode 100644 index 000000000..c632db490 --- /dev/null +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuideImplementation.java @@ -0,0 +1,62 @@ +package io.github.thebusybiscuit.slimefun4.core.guide; + +import java.util.LinkedList; + +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import me.mrCookieSlime.Slimefun.Objects.Category; +import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; +import me.mrCookieSlime.Slimefun.api.GuideHandler; +import me.mrCookieSlime.Slimefun.api.PlayerProfile; + +public interface SlimefunGuideImplementation { + + SlimefunGuideLayout getLayout(); + + ItemStack getItem(); + + void openMainMenu(PlayerProfile profile, boolean survival, int page); + + void openCategory(PlayerProfile profile, Category category, boolean survival, int page); + + void openSearch(PlayerProfile profile, String input, boolean survival, boolean addToHistory); + + void displayItem(PlayerProfile profile, ItemStack item, boolean addToHistory); + + void displayItem(PlayerProfile profile, SlimefunItem item, boolean addToHistory); + + /** + * Retrieves the last page in the {@link SlimefunGuide} that was visited by a {@link Player}. + * Optionally also rewinds the history back to that entry. + * + * @param profile The {@link PlayerProfile} of the {@link Player} you are querying + * @param remove Whether to remove the current entry so it moves back to the entry returned. + * @return The last Guide Entry that was saved to the given Players guide history. + */ + default Object getLastEntry(PlayerProfile profile, boolean remove) { + LinkedList history = profile.getGuideHistory(); + + if (remove && !history.isEmpty()) { + history.removeLast(); + } + + return history.isEmpty() ? null : history.getLast(); + } + + /** + * Opens the given Guide Entry to the {@link Player} of the specified {@link PlayerProfile}. + * + * @param profile The {@link PlayerProfile} of the {@link Player} we are opening this to + * @param entry The Guide Entry to open + * @param survival Whether this is the survival-version of the guide or cheat sheet version + */ + default void openEntry(PlayerProfile profile, Object entry, boolean survival) { + if (entry == null) openMainMenu(profile, survival, 1); + else if (entry instanceof Category) openCategory(profile, (Category) entry, survival, 1); + else if (entry instanceof SlimefunItem) displayItem(profile, (SlimefunItem) entry, false); + else if (entry instanceof GuideHandler) ((GuideHandler) entry).run(profile.getPlayer(), survival, getLayout() == SlimefunGuideLayout.BOOK); + else if (entry instanceof String) openSearch(profile, (String) entry, survival, false); + else displayItem(profile, (ItemStack) entry, false); + } +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/GuideSettings.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuideSettings.java similarity index 99% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/GuideSettings.java rename to src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuideSettings.java index a9b7feadd..1c9c74a24 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/GuideSettings.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuideSettings.java @@ -28,16 +28,15 @@ import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; import io.github.thebusybiscuit.slimefun4.utils.NumberUtils; import me.mrCookieSlime.CSCoreLibPlugin.CSCoreLib; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu; -import me.mrCookieSlime.Slimefun.SlimefunGuide; import me.mrCookieSlime.Slimefun.SlimefunPlugin; import me.mrCookieSlime.Slimefun.Setup.SlimefunManager; -public final class GuideSettings { +public final class SlimefunGuideSettings { public static final NamespacedKey FIREWORKS_KEY = new NamespacedKey(SlimefunPlugin.instance, "research_fireworks"); private static final int[] BACKGROUND_SLOTS = {1, 3, 5, 7, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 26, 27, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 48, 50, 52, 53}; - private GuideSettings() {} + private SlimefunGuideSettings() {} public static void openSettings(Player p, ItemStack guide) { ChestMenu menu = new ChestMenu(SlimefunPlugin.getLocal().getMessage(p, "guide.title.settings")); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/UpdaterService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/UpdaterService.java index 1bb61b8d3..0a3faf5b2 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/UpdaterService.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/UpdaterService.java @@ -11,19 +11,16 @@ import io.github.thebusybiscuit.slimefun4.api.SlimefunBranch; public class UpdaterService { + private final Plugin plugin; private final Updater updater; private final SlimefunBranch branch; public UpdaterService(Plugin plugin, File file) { + this.plugin = plugin; String version = plugin.getDescription().getVersion(); - if (version.equals("UNOFFICIAL")) { + if (version.contains("UNOFFICIAL")) { // This Server is using a modified build that is not a public release. - plugin.getLogger().log(Level.WARNING, "##################################################"); - plugin.getLogger().log(Level.WARNING, "It looks like you are using an unofficially modified build of Slimefun!"); - plugin.getLogger().log(Level.WARNING, "Auto-Updates have been disabled, this build is not considered safe."); - plugin.getLogger().log(Level.WARNING, "Do not report bugs encountered in this Version of Slimefun."); - plugin.getLogger().log(Level.WARNING, "##################################################"); updater = null; branch = SlimefunBranch.UNOFFICIAL; } @@ -51,6 +48,30 @@ public class UpdaterService { if (updater != null) { updater.start(); } + else { + drawBorder(); + plugin.getLogger().log(Level.WARNING, "It looks like you are using an unofficially modified build of Slimefun!"); + plugin.getLogger().log(Level.WARNING, "Auto-Updates have been disabled, this build is not considered safe."); + plugin.getLogger().log(Level.WARNING, "Do not report bugs encountered in this Version of Slimefun to any official sources."); + drawBorder(); + } + } + + public void disable() { + drawBorder(); + plugin.getLogger().log(Level.WARNING, "It looks like you have disabled auto-updates for Slimefun!"); + plugin.getLogger().log(Level.WARNING, "Auto-Updates keep your server safe, performant and bug-free."); + plugin.getLogger().log(Level.WARNING, "We respect your decision."); + + if (branch != SlimefunBranch.STABLE) { + plugin.getLogger().log(Level.WARNING, "If you are just scared of Slimefun breaking, then please consider using a \"stable\" build instead of disabling auto-updates."); + } + + drawBorder(); + } + + private void drawBorder() { + plugin.getLogger().log(Level.WARNING, "#######################################################"); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/BookSlimefunGuide.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/BookSlimefunGuide.java similarity index 87% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/BookSlimefunGuide.java rename to src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/BookSlimefunGuide.java index de62610e5..777239a04 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/BookSlimefunGuide.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/BookSlimefunGuide.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.guide; +package io.github.thebusybiscuit.slimefun4.implementation.guide; import java.util.ArrayList; import java.util.List; @@ -12,11 +12,14 @@ import org.bukkit.inventory.ItemStack; import io.github.thebusybiscuit.cscorelib2.chat.ChatColors; import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils; import io.github.thebusybiscuit.cscorelib2.item.CustomItem; +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.utils.ChatUtils; import me.mrCookieSlime.CSCoreLibPlugin.PlayerRunnable; import me.mrCookieSlime.CSCoreLibPlugin.general.Chat.TellRawMessage; import me.mrCookieSlime.CSCoreLibPlugin.general.Chat.TellRawMessage.HoverAction; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.CustomBookOverlay; -import me.mrCookieSlime.Slimefun.SlimefunGuide; import me.mrCookieSlime.Slimefun.SlimefunPlugin; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.Objects.LockedCategory; @@ -27,7 +30,7 @@ import me.mrCookieSlime.Slimefun.api.GuideHandler; import me.mrCookieSlime.Slimefun.api.PlayerProfile; import me.mrCookieSlime.Slimefun.api.Slimefun; -public class BookSlimefunGuide implements ISlimefunGuide { +public class BookSlimefunGuide implements SlimefunGuideImplementation { @Override public SlimefunGuideLayout getLayout() { @@ -102,18 +105,18 @@ public class BookSlimefunGuide implements ISlimefunGuide { parents.append(ChatColors.color("\n&c" + ItemUtils.getItemName(parent.getItem(p)))); } - texts.add(ChatColors.color(shorten("&c" , ItemUtils.getItemName(category.getItem(p))))); + texts.add(ChatColors.color(ChatUtils.crop(ChatColor.RED, ItemUtils.getItemName(category.getItem(p))))); tooltips.add(parents.toString()); actions.add(null); } else if (category instanceof SeasonalCategory) { if (((SeasonalCategory) category).isUnlocked()) { - texts.add(ChatColors.color(shorten("&a", ItemUtils.getItemName(category.getItem(p))))); + texts.add(ChatColors.color(ChatUtils.crop(ChatColor.GREEN, ItemUtils.getItemName(category.getItem(p))))); tooltips.add(ChatColors.color("&eClick to open the following Category:\n" + ItemUtils.getItemName(category.getItem(p)))); actions.add(new PlayerRunnable(1) { @Override - public void run(final Player p) { + public void run(Player p) { Slimefun.runSync(() -> openCategory(profile, category, survival, 1), 1L); } @@ -121,12 +124,12 @@ public class BookSlimefunGuide implements ISlimefunGuide { } } else { - texts.add(ChatColors.color(shorten("&a", ItemUtils.getItemName(category.getItem(p))))); + texts.add(ChatColors.color(ChatUtils.crop(ChatColor.GREEN, ItemUtils.getItemName(category.getItem(p))))); tooltips.add(ChatColors.color("&eClick to open the following Category:\n" + ItemUtils.getItemName(category.getItem(p)))); actions.add(new PlayerRunnable(1) { @Override - public void run(final Player p) { + public void run(Player p) { Slimefun.runSync(() -> openCategory(profile, category, survival, 1), 1L); } @@ -188,13 +191,13 @@ public class BookSlimefunGuide implements ISlimefunGuide { if (survival && !Slimefun.hasUnlocked(p, item, false) && item.getResearch() != null) { Research research = item.getResearch(); - texts.add(ChatColors.color(shorten("&7", item.getItemName()))); + texts.add(ChatColors.color(ChatUtils.crop(ChatColor.GRAY, item.getItemName()))); tooltips.add(ChatColors.color(item.getItemName() + "\n&c&lLOCKED\n\n&7Cost: " + (p.getLevel() >= research.getCost() ? "&b": "&4") + research.getCost() + " Levels\n\n&a> Click to unlock")); actions.add(new PlayerRunnable(2) { @Override - public void run(final Player p) { - if (!Research.isResearching(p)) { + public void run(Player p) { + if (!SlimefunPlugin.getRegistry().getCurrentlyResearchingPlayers().contains(p.getUniqueId())) { if (research.canUnlock(p)) { if (profile.hasUnlocked(research)) { openCategory(profile, category, true, page); @@ -220,7 +223,7 @@ public class BookSlimefunGuide implements ISlimefunGuide { }); } else { - texts.add(ChatColors.color(shorten("&a", item.getItemName()))); + texts.add(ChatColors.color(ChatUtils.crop(ChatColor.GREEN, item.getItemName()))); StringBuilder tooltip = new StringBuilder(); tooltip.append(item.getItemName()); @@ -246,7 +249,7 @@ public class BookSlimefunGuide implements ISlimefunGuide { } } else { - texts.add(ChatColors.color(shorten("&4", ItemUtils.getItemName(item.getItem())))); + texts.add(ChatColors.color(ChatUtils.crop(ChatColor.DARK_RED, ItemUtils.getItemName(item.getItem())))); tooltips.add(ChatColors.color("&cNo Permission!")); actions.add(null); } @@ -268,7 +271,7 @@ public class BookSlimefunGuide implements ISlimefunGuide { pageMessage.addClickEvent(new PlayerRunnable(2) { @Override - public void run(final Player p) { + public void run(Player p) { openMainMenu(profile, survival, 1); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/ChestSlimefunGuide.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/ChestSlimefunGuide.java similarity index 95% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/ChestSlimefunGuide.java rename to src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/ChestSlimefunGuide.java index 0c6b6e254..7f3e08395 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/ChestSlimefunGuide.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/ChestSlimefunGuide.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.guide; +package io.github.thebusybiscuit.slimefun4.implementation.guide; import java.util.ArrayList; import java.util.Arrays; @@ -22,11 +22,14 @@ import io.github.thebusybiscuit.cscorelib2.chat.ChatInput; import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils; import io.github.thebusybiscuit.cscorelib2.item.CustomItem; import io.github.thebusybiscuit.cscorelib2.recipes.MinecraftRecipe; +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.guide.SlimefunGuideSettings; import io.github.thebusybiscuit.slimefun4.utils.ChatUtils; import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.MenuClickHandler; -import me.mrCookieSlime.Slimefun.SlimefunGuide; import me.mrCookieSlime.Slimefun.SlimefunPlugin; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; @@ -40,7 +43,7 @@ import me.mrCookieSlime.Slimefun.api.GuideHandler; import me.mrCookieSlime.Slimefun.api.PlayerProfile; import me.mrCookieSlime.Slimefun.api.Slimefun; -public class ChestSlimefunGuide implements ISlimefunGuide { +public class ChestSlimefunGuide implements SlimefunGuideImplementation { private static final int[] RECIPE_SLOTS = {3, 4, 5, 12, 13, 14, 21, 22, 23}; private static final int CATEGORY_SIZE = 36; @@ -219,9 +222,8 @@ public class ChestSlimefunGuide implements ISlimefunGuide { if (Slimefun.hasPermission(p, sfitem, false)) { menu.addItem(index, new CustomItem(Material.BARRIER, "&r" + ItemUtils.getItemName(sfitem.getItem()), "&4&lLOCKED", "", "&a> Click to unlock", "", "&7Cost: &b" + research.getCost() + " Level")); menu.addMenuClickHandler(index, (pl, slot, item, action) -> { - if (!Research.isResearching(pl)) { + if (!SlimefunPlugin.getRegistry().getCurrentlyResearchingPlayers().contains(pl.getUniqueId())) { if (research.canUnlock(pl)) { - if (profile.hasUnlocked(research)) { openCategory(profile, category, true, page); } @@ -240,7 +242,9 @@ public class ChestSlimefunGuide implements ISlimefunGuide { } } } - else SlimefunPlugin.getLocal().sendMessage(pl, "messages.not-enough-xp", true); + else { + SlimefunPlugin.getLocal().sendMessage(pl, "messages.not-enough-xp", true); + } } return false; }); @@ -284,7 +288,7 @@ public class ChestSlimefunGuide implements ISlimefunGuide { Player p = profile.getPlayer(); if (p == null) return; - ChestMenu menu = new ChestMenu("Searching for: " + shorten("", input)); + ChestMenu menu = new ChestMenu("Searching for: " + ChatUtils.crop(ChatColor.RESET, input)); String searchTerm = input.toLowerCase(); if (addToHistory) { @@ -497,7 +501,7 @@ public class ChestSlimefunGuide implements ISlimefunGuide { // Settings Panel menu.addItem(1, ChestMenuUtils.getMenuButton(p)); menu.addMenuClickHandler(1, (pl, slot, item, action) -> { - GuideSettings.openSettings(pl, pl.getInventory().getItemInMainHand()); + SlimefunGuideSettings.openSettings(pl, pl.getInventory().getItemInMainHand()); return false; }); @@ -536,7 +540,7 @@ public class ChestSlimefunGuide implements ISlimefunGuide { } else { Object last = getLastEntry(profile, true); - handleHistory(profile, last, survival); + openEntry(profile, last, survival); } return false; }); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/RecipeChoiceTask.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/RecipeChoiceTask.java similarity index 95% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/RecipeChoiceTask.java rename to src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/RecipeChoiceTask.java index 7f0f08e73..aae061d09 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/RecipeChoiceTask.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/RecipeChoiceTask.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.core.guide; +package io.github.thebusybiscuit.slimefun4.implementation.guide; import java.util.HashMap; import java.util.Map; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoManagerBlock.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoManager.java similarity index 92% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoManagerBlock.java rename to src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoManager.java index 7561b5730..825dd1c20 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoManagerBlock.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoManager.java @@ -19,9 +19,9 @@ import me.mrCookieSlime.Slimefun.api.BlockStorage; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; import me.mrCookieSlime.Slimefun.api.item_transport.CargoNet; -public class CargoManagerBlock extends SlimefunItem { +public class CargoManager extends SlimefunItem { - public CargoManagerBlock(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { + public CargoManager(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { super(category, item, recipeType, recipe); registerBlockHandler(getID(), (p, b, tool, reason) -> { diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/JetBoots.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/JetBoots.java similarity index 77% rename from src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/JetBoots.java rename to src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/JetBoots.java index 50e375612..73de26c6f 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/JetBoots.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/JetBoots.java @@ -1,9 +1,10 @@ -package me.mrCookieSlime.Slimefun.Objects.SlimefunItem; +package io.github.thebusybiscuit.slimefun4.implementation.items.electric.gadgets; import org.bukkit.inventory.ItemStack; import me.mrCookieSlime.Slimefun.Lists.Categories; import me.mrCookieSlime.Slimefun.Lists.RecipeType; +import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.ChargableItem; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; public class JetBoots extends ChargableItem { diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/Jetpack.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/Jetpack.java similarity index 77% rename from src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/Jetpack.java rename to src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/Jetpack.java index 764f5b45b..5c4731321 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/Jetpack.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/Jetpack.java @@ -1,9 +1,10 @@ -package me.mrCookieSlime.Slimefun.Objects.SlimefunItem; +package io.github.thebusybiscuit.slimefun4.implementation.items.electric.gadgets; import org.bukkit.inventory.ItemStack; import me.mrCookieSlime.Slimefun.Lists.Categories; import me.mrCookieSlime.Slimefun.Lists.RecipeType; +import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.ChargableItem; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; public class Jetpack extends ChargableItem { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/Multimeter.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/Multimeter.java similarity index 98% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/Multimeter.java rename to src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/Multimeter.java index e3bad2e81..6ff037405 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/Multimeter.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/Multimeter.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.electric; +package io.github.thebusybiscuit.slimefun4.implementation.items.electric.gadgets; import java.util.Optional; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/SolarHelmet.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/SolarHelmet.java similarity index 97% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/SolarHelmet.java rename to src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/SolarHelmet.java index 808832398..8e55fe412 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/SolarHelmet.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/SolarHelmet.java @@ -1,4 +1,4 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.electric; +package io.github.thebusybiscuit.slimefun4.implementation.items.electric.gadgets; import org.bukkit.inventory.ItemStack; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/SolarGenerator.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/SolarGenerator.java index 12ef680dd..c6c0e301f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/SolarGenerator.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/SolarGenerator.java @@ -8,10 +8,10 @@ import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; +import me.mrCookieSlime.Slimefun.Objects.handlers.GeneratorTicker; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; -import me.mrCookieSlime.Slimefun.api.energy.EnergyTicker; -public abstract class SolarGenerator extends SimpleSlimefunItem { +public abstract class SolarGenerator extends SimpleSlimefunItem { public SolarGenerator(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { super(category, item, recipeType, recipe); @@ -25,8 +25,8 @@ public abstract class SolarGenerator extends SimpleSlimefunItem { } @Override - public EnergyTicker getItemHandler() { - return new EnergyTicker() { + public GeneratorTicker getItemHandler() { + return new GeneratorTicker() { @Override public double generateEnergy(Location l, SlimefunItem item, Config data) { diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/EnderTalisman.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/EnderTalisman.java similarity index 89% rename from src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/EnderTalisman.java rename to src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/EnderTalisman.java index 4c02dc0d8..f3501e0a2 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/EnderTalisman.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/EnderTalisman.java @@ -1,4 +1,4 @@ -package me.mrCookieSlime.Slimefun.Objects.SlimefunItem; +package io.github.thebusybiscuit.slimefun4.implementation.items.magical; import org.bukkit.inventory.ItemStack; @@ -9,7 +9,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; /** * @since 4.0 */ -public class EnderTalisman extends Talisman { +class EnderTalisman extends Talisman { public EnderTalisman(Talisman parent) { super(Categories.TALISMANS_2, parent.upgrade(), new ItemStack[] {SlimefunItems.ENDER_LUMP_3, null, SlimefunItems.ENDER_LUMP_3, null, parent.getItem(), null, SlimefunItems.ENDER_LUMP_3, null, SlimefunItems.ENDER_LUMP_3}, parent.isConsumable(), parent.isEventCancelled(), parent.getSuffix(), parent.getChance(), parent.getEffects()); diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/SoulboundItem.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/SoulboundItem.java similarity index 85% rename from src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/SoulboundItem.java rename to src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/SoulboundItem.java index 51b663216..9d1f7bb93 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/SoulboundItem.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/SoulboundItem.java @@ -1,10 +1,11 @@ -package me.mrCookieSlime.Slimefun.Objects.SlimefunItem; +package io.github.thebusybiscuit.slimefun4.implementation.items.magical; import org.bukkit.inventory.ItemStack; import io.github.thebusybiscuit.slimefun4.core.attributes.Soulbound; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; +import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.interfaces.NotPlaceable; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/Talisman.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/Talisman.java similarity index 98% rename from src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/Talisman.java rename to src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/Talisman.java index b3271b5b8..9e2d36f57 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/Talisman.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/Talisman.java @@ -1,4 +1,4 @@ -package me.mrCookieSlime.Slimefun.Objects.SlimefunItem; +package io.github.thebusybiscuit.slimefun4.implementation.items.magical; import java.util.ArrayList; import java.util.List; @@ -23,6 +23,7 @@ import me.mrCookieSlime.Slimefun.Lists.Categories; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.Objects.Research; +import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; import me.mrCookieSlime.Slimefun.api.Slimefun; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/ExplosiveBow.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/ExplosiveBow.java index 818ca8e8c..1a396855d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/ExplosiveBow.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/ExplosiveBow.java @@ -4,7 +4,6 @@ import org.bukkit.Sound; import org.bukkit.inventory.ItemStack; import org.bukkit.util.Vector; -import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunBow; import me.mrCookieSlime.Slimefun.Objects.handlers.BowShootHandler; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/IcyBow.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/IcyBow.java index 120dbb116..e6761f929 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/IcyBow.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/IcyBow.java @@ -6,7 +6,6 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; -import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunBow; import me.mrCookieSlime.Slimefun.Objects.handlers.BowShootHandler; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/SlimefunBow.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/SlimefunBow.java similarity index 58% rename from src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/SlimefunBow.java rename to src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/SlimefunBow.java index c773b647e..143e66878 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/SlimefunBow.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/SlimefunBow.java @@ -1,12 +1,22 @@ -package me.mrCookieSlime.Slimefun.Objects.SlimefunItem; +package io.github.thebusybiscuit.slimefun4.implementation.items.weapons; +import org.bukkit.entity.Arrow; import org.bukkit.inventory.ItemStack; import me.mrCookieSlime.Slimefun.Lists.Categories; import me.mrCookieSlime.Slimefun.Lists.RecipeType; +import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; import me.mrCookieSlime.Slimefun.Objects.handlers.BowShootHandler; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; +/** + * This class represents a {@link SlimefunItem} that is a Bow. + * It comes with a {@link BowShootHandler} to handle actions that shall be performed + * whenever an {@link Arrow} fired from this {@link SlimefunBow} hits a target. + * + * @author TheBusyBiscuit + * + */ public abstract class SlimefunBow extends SlimefunItem { public SlimefunBow(SlimefunItemStack item, ItemStack[] recipe) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GearListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GearListener.java index 3ba0b70c2..3e60797b8 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GearListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GearListener.java @@ -5,8 +5,6 @@ import io.github.thebusybiscuit.slimefun4.implementation.tasks.JetpackTask; import io.github.thebusybiscuit.slimefun4.implementation.tasks.MagnetTask; import io.github.thebusybiscuit.slimefun4.implementation.tasks.ParachuteTask; import me.mrCookieSlime.Slimefun.Lists.SlimefunItems; -import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.JetBoots; -import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.Jetpack; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; import me.mrCookieSlime.Slimefun.Setup.SlimefunManager; import me.mrCookieSlime.Slimefun.SlimefunPlugin; @@ -16,6 +14,13 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerToggleSneakEvent; +import io.github.thebusybiscuit.slimefun4.implementation.items.electric.gadgets.JetBoots; +import io.github.thebusybiscuit.slimefun4.implementation.items.electric.gadgets.Jetpack; +import io.github.thebusybiscuit.slimefun4.implementation.tasks.JetBootsTask; +import io.github.thebusybiscuit.slimefun4.implementation.tasks.JetpackTask; +import io.github.thebusybiscuit.slimefun4.implementation.tasks.MagnetTask; +import io.github.thebusybiscuit.slimefun4.implementation.tasks.ParachuteTask; + public class GearListener implements Listener { public GearListener(SlimefunPlugin plugin) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunBowListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunBowListener.java index 098d2183e..2a86978dc 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunBowListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunBowListener.java @@ -13,8 +13,8 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.entity.ProjectileHitEvent; +import io.github.thebusybiscuit.slimefun4.implementation.items.weapons.SlimefunBow; import me.mrCookieSlime.Slimefun.SlimefunPlugin; -import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunBow; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; import me.mrCookieSlime.Slimefun.Objects.handlers.BowShootHandler; import me.mrCookieSlime.Slimefun.api.Slimefun; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunGuideListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunGuideListener.java index 2297ec167..5ee68c79e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunGuideListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunGuideListener.java @@ -8,9 +8,9 @@ import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.inventory.ItemStack; import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent; -import io.github.thebusybiscuit.slimefun4.core.guide.GuideSettings; +import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideSettings; +import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide; import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout; -import me.mrCookieSlime.Slimefun.SlimefunGuide; import me.mrCookieSlime.Slimefun.SlimefunPlugin; import me.mrCookieSlime.Slimefun.Setup.SlimefunManager; @@ -43,19 +43,19 @@ public class SlimefunGuideListener implements Listener { if (SlimefunManager.isItemSimilar(item, SlimefunGuide.getItem(SlimefunGuideLayout.BOOK), true)) { e.cancel(); - if (p.isSneaking()) GuideSettings.openSettings(p, item); + if (p.isSneaking()) SlimefunGuideSettings.openSettings(p, item); else SlimefunGuide.openGuide(p, SlimefunGuideLayout.BOOK); } else if (SlimefunManager.isItemSimilar(item, SlimefunGuide.getItem(SlimefunGuideLayout.CHEST), true)) { e.cancel(); - if (p.isSneaking()) GuideSettings.openSettings(p, item); + if (p.isSneaking()) SlimefunGuideSettings.openSettings(p, item); else SlimefunGuide.openGuide(p, SlimefunGuideLayout.CHEST); } else if (SlimefunManager.isItemSimilar(item, SlimefunGuide.getItem(SlimefunGuideLayout.CHEAT_SHEET), true)) { e.cancel(); - if (p.isSneaking()) GuideSettings.openSettings(p, item); + if (p.isSneaking()) SlimefunGuideSettings.openSettings(p, item); else { // We rather just run the command here, // all necessary permission checks will be handled there. diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TalismanListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TalismanListener.java index 18463b804..146042021 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TalismanListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TalismanListener.java @@ -34,9 +34,9 @@ import org.bukkit.util.Vector; import io.github.thebusybiscuit.cscorelib2.item.CustomItem; import io.github.thebusybiscuit.cscorelib2.materials.MaterialCollections; +import io.github.thebusybiscuit.slimefun4.implementation.items.magical.Talisman; import me.mrCookieSlime.Slimefun.SlimefunPlugin; import me.mrCookieSlime.Slimefun.Lists.SlimefunItems; -import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.Talisman; import me.mrCookieSlime.Slimefun.api.Slimefun; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/VanillaMachinesListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/VanillaMachinesListener.java index 02fffc3bf..859cf8388 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/VanillaMachinesListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/VanillaMachinesListener.java @@ -12,8 +12,8 @@ import org.bukkit.inventory.BrewerInventory; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; +import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide; import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout; -import me.mrCookieSlime.Slimefun.SlimefunGuide; import me.mrCookieSlime.Slimefun.SlimefunPlugin; import me.mrCookieSlime.Slimefun.Lists.SlimefunItems; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/MiscSetup.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/MiscSetup.java index 470490b2c..c4aa9407f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/MiscSetup.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/MiscSetup.java @@ -198,11 +198,18 @@ public final class MiscSetup { sender.sendMessage(ChatColor.GREEN + "( " + vanilla + " Items from Slimefun, " + (total - vanilla) + " Items from " + SlimefunPlugin.getInstalledAddons().size() + " Addons )"); sender.sendMessage(""); sender.sendMessage(ChatColor.GREEN + "Slimefun is an Open-Source project that is maintained by community developers!"); - sender.sendMessage(""); - sender.sendMessage(ChatColor.GREEN + " -- Source Code: https://github.com/TheBusyBiscuit/Slimefun4"); - sender.sendMessage(ChatColor.GREEN + " -- Wiki: https://github.com/TheBusyBiscuit/Slimefun4/wiki"); - sender.sendMessage(ChatColor.GREEN + " -- Bug Reports: https://github.com/TheBusyBiscuit/Slimefun4/issues"); - sender.sendMessage(ChatColor.GREEN + " -- Discord: https://discord.gg/fsD4Bkh"); + + if (SlimefunPlugin.getUpdater().getBranch().isOfficial()) { + sender.sendMessage(""); + sender.sendMessage(ChatColor.GREEN + " -- Source Code: https://github.com/TheBusyBiscuit/Slimefun4"); + sender.sendMessage(ChatColor.GREEN + " -- Wiki: https://github.com/TheBusyBiscuit/Slimefun4/wiki"); + sender.sendMessage(ChatColor.GREEN + " -- Bug Reports: https://github.com/TheBusyBiscuit/Slimefun4/issues"); + sender.sendMessage(ChatColor.GREEN + " -- Discord: https://discord.gg/fsD4Bkh"); + } + else { + sender.sendMessage(ChatColor.GREEN + " -- UNOFFICIALLY MODIFIED BUILD - NO OFFICIAL SUPPORT GIVEN"); + } + sender.sendMessage(""); SlimefunPlugin.getItemCfg().save(); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java index bf5082971..f1aa1ebd1 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java @@ -45,13 +45,15 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.RepairedSp import io.github.thebusybiscuit.slimefun4.implementation.items.cargo.AdvancedCargoOutputNode; import io.github.thebusybiscuit.slimefun4.implementation.items.cargo.CargoConnector; import io.github.thebusybiscuit.slimefun4.implementation.items.cargo.CargoInputNode; -import io.github.thebusybiscuit.slimefun4.implementation.items.cargo.CargoManagerBlock; +import io.github.thebusybiscuit.slimefun4.implementation.items.cargo.CargoManager; import io.github.thebusybiscuit.slimefun4.implementation.items.cargo.CargoOutputNode; import io.github.thebusybiscuit.slimefun4.implementation.items.cargo.ReactorAccessPort; import io.github.thebusybiscuit.slimefun4.implementation.items.cargo.TrashCan; import io.github.thebusybiscuit.slimefun4.implementation.items.electric.Capacitor; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.Multimeter; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.SolarHelmet; +import io.github.thebusybiscuit.slimefun4.implementation.items.electric.gadgets.JetBoots; +import io.github.thebusybiscuit.slimefun4.implementation.items.electric.gadgets.Jetpack; +import io.github.thebusybiscuit.slimefun4.implementation.items.electric.gadgets.Multimeter; +import io.github.thebusybiscuit.slimefun4.implementation.items.electric.gadgets.SolarHelmet; import io.github.thebusybiscuit.slimefun4.implementation.items.electric.generators.BioGenerator; import io.github.thebusybiscuit.slimefun4.implementation.items.electric.generators.CoalGenerator; import io.github.thebusybiscuit.slimefun4.implementation.items.electric.generators.CombustionGenerator; @@ -109,8 +111,10 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.magical.Knowledge import io.github.thebusybiscuit.slimefun4.implementation.items.magical.KnowledgeTome; import io.github.thebusybiscuit.slimefun4.implementation.items.magical.MagicEyeOfEnder; import io.github.thebusybiscuit.slimefun4.implementation.items.magical.SoulboundBackpack; +import io.github.thebusybiscuit.slimefun4.implementation.items.magical.SoulboundItem; import io.github.thebusybiscuit.slimefun4.implementation.items.magical.SoulboundRune; import io.github.thebusybiscuit.slimefun4.implementation.items.magical.StormStaff; +import io.github.thebusybiscuit.slimefun4.implementation.items.magical.Talisman; import io.github.thebusybiscuit.slimefun4.implementation.items.magical.TelepositionScroll; import io.github.thebusybiscuit.slimefun4.implementation.items.magical.WaterStaff; import io.github.thebusybiscuit.slimefun4.implementation.items.magical.WindStaff; @@ -158,16 +162,12 @@ import me.mrCookieSlime.Slimefun.Lists.SlimefunItems; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.Alloy; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.EasterEgg; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.HandledBlock; -import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.JetBoots; -import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.Jetpack; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.Juice; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.RadioactiveItem; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunArmorPiece; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunBackpack; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunMachine; -import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SoulboundItem; -import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.Talisman; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.VanillaItem; import me.mrCookieSlime.Slimefun.Objects.handlers.MultiBlockInteractionHandler; import me.mrCookieSlime.Slimefun.Setup.SlimefunManager; @@ -3136,7 +3136,7 @@ public final class SlimefunItemSetup { new CustomItem(SlimefunItems.CARGO_MOTOR, 4)) .register(plugin); - new CargoManagerBlock(Categories.CARGO, (SlimefunItemStack) SlimefunItems.CARGO_MANAGER, RecipeType.ENHANCED_CRAFTING_TABLE, + new CargoManager(Categories.CARGO, (SlimefunItemStack) SlimefunItems.CARGO_MANAGER, RecipeType.ENHANCED_CRAFTING_TABLE, new ItemStack[] {null, SlimefunItems.HOLOGRAM_PROJECTOR, null, SlimefunItems.REINFORCED_PLATE, SlimefunItems.CARGO_MOTOR, SlimefunItems.REINFORCED_PLATE, SlimefunItems.ALUMINUM_BRONZE_INGOT, SlimefunItems.ANDROID_MEMORY_CORE, SlimefunItems.ALUMINUM_BRONZE_INGOT}) .register(plugin); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/AncientAltarTask.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/AncientAltarTask.java index db3e9744b..88c3ca044 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/AncientAltarTask.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/AncientAltarTask.java @@ -135,7 +135,7 @@ public class AncientAltarTask implements Runnable { AncientAltarListener listener = SlimefunPlugin.getAncientAltarListener(); pedestals.forEach(b -> listener.getAltarsInUse().remove(b.getLocation())); - + // This should re-enable altar blocks on craft completion. listener.getAltarsInUse().remove(altar.getLocation()); altars.remove(altar); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ChatUtils.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ChatUtils.java index e61434e4c..1b8fa57d7 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ChatUtils.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ChatUtils.java @@ -20,6 +20,15 @@ public final class ChatUtils { sender.sendMessage(ChatColors.color("&7&o" + url)); sender.sendMessage(""); } + + public static String crop(ChatColor color, String string) { + if (ChatColor.stripColor(color + string).length() > 19) { + return (color + ChatColor.stripColor(string)).substring(0, 18) + "..."; + } + else { + return color + ChatColor.stripColor(string); + } + } public static String christmas(String text) { return ChatColors.alternating(text, ChatColor.GREEN, ChatColor.RED); diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/Category.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/Category.java index bfab15722..525cb4324 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/Category.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/Objects/Category.java @@ -15,6 +15,7 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import io.github.thebusybiscuit.cscorelib2.item.CustomItem; +import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide; import me.mrCookieSlime.Slimefun.SlimefunPlugin; import me.mrCookieSlime.Slimefun.Lists.Categories; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; @@ -32,10 +33,10 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; */ public class Category implements Keyed { - private final NamespacedKey key; - private final ItemStack item; - private final List items; - private final int tier; + protected final NamespacedKey key; + protected final ItemStack item; + protected final List items; + protected final int tier; /** * Constructs a Category with the given display item. @@ -50,7 +51,15 @@ public class Category implements Keyed { public Category(ItemStack item) { this(item, 3); } - + + /** + * Constructs a new {@link Category} with the given {@link NamespacedKey} as an identifier + * and the given {@link ItemStack} as its display item. + * The tier is set to a default value of {@code 3}. + * + * @param key The {@link NamespacedKey} that is used to identify this {@link Category} + * @param item The {@link ItemStack} that is used to display this {@link Category} + */ public Category(NamespacedKey key, ItemStack item) { this(key, item, 3); } @@ -70,7 +79,15 @@ public class Category implements Keyed { public Category(ItemStack item, int tier) { this(new NamespacedKey(SlimefunPlugin.instance, "invalid_category"), item, tier); } - + + /** + * Constructs a new {@link Category} with the given {@link NamespacedKey} as an identifier + * and the given {@link ItemStack} as its display item. + * + * @param key The {@link NamespacedKey} that is used to identify this {@link Category} + * @param item The {@link ItemStack} that is used to display this {@link Category} + * @param tier The tier of this {@link Category}, higher tiers will make this {@link Category} appear further down in the {@link SlimefunGuide} + */ public Category(NamespacedKey key, ItemStack item, int tier) { this.item = item; this.key = key; @@ -110,20 +127,21 @@ public class Category implements Keyed { } /** - * Bounds the provided {@link SlimefunItem} to this category. + * Adds the given {@link SlimefunItem} to this {@link Category}. * - * @param item the SlimefunItem to bound to this category - * - * @since 4.0 + * @param item the {@link SlimefunItem} that should be added to this {@link Category} */ public void add(SlimefunItem item) { items.add(item); } - public ItemStack getItem() { - return item.clone(); - } - + /** + * This method returns a localized display item of this {@link Category} + * for the specified {@link Player}. + * + * @param p The Player to create this {@link ItemStack} for + * @return A localized display item for this {@link Category} + */ public ItemStack getItem(Player p) { return new CustomItem(item, meta -> { String name = SlimefunPlugin.getLocal().getCategoryName(p, getKey()); @@ -141,11 +159,9 @@ public class Category implements Keyed { } /** - * Returns the list of SlimefunItems bound to this category. + * Returns all instances of {@link SlimefunItem} bound to this {@link Category}. * * @return the list of SlimefunItems bound to this category - * - * @since 4.0 */ public List getItems() { return this.items; @@ -153,10 +169,9 @@ public class Category implements Keyed { /** * Returns the tier of this category. + * The tier determines the position of this {@link Category} in the {@link SlimefunGuide}. * * @return the tier of this category - * - * @since 4.0 */ public int getTier() { return tier; @@ -164,7 +179,7 @@ public class Category implements Keyed { @Override public String toString() { - return "Slimefun Category {" + item.getItemMeta().getDisplayName() + ",tier=" + tier + "}"; + return "Slimefun Category {" + key + ",tier=" + tier + "}"; } } diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/LockedCategory.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/LockedCategory.java index 2d0f47575..4e6e85e6e 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/LockedCategory.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/Objects/LockedCategory.java @@ -83,7 +83,9 @@ public class LockedCategory extends Category { * @see #removeParent(Category) */ public void addParent(Category category) { - if (category == this || category == null) throw new IllegalArgumentException("Category '" + this.getItem().getItemMeta().getDisplayName() + "' cannot be a parent of itself or have a 'null' parent."); + if (category == this || category == null) { + throw new IllegalArgumentException("Category '" + item.getItemMeta().getDisplayName() + "' cannot be a parent of itself or have a 'null' parent."); + } this.parents.add(category); } diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/Research.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/Research.java index 8f35c3a1a..f503b288a 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/Research.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/Objects/Research.java @@ -14,7 +14,7 @@ import org.bukkit.entity.Player; import io.github.thebusybiscuit.cscorelib2.data.PersistentDataAPI; import io.github.thebusybiscuit.slimefun4.api.events.ResearchUnlockEvent; -import io.github.thebusybiscuit.slimefun4.core.guide.GuideSettings; +import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideSettings; import io.github.thebusybiscuit.slimefun4.implementation.setup.ResearchSetup; import io.github.thebusybiscuit.slimefun4.utils.FireworkUtils; import me.mrCookieSlime.Slimefun.SlimefunPlugin; @@ -149,12 +149,10 @@ public class Research implements Keyed { } /** - * Unlocks the research for the specified player. + * Unlocks this {@link Research} for the specified {@link Player}. * - * @param p Player to unlock the research - * @param instant Whether to unlock the research instantly - * - * @since 4.0 + * @param p The {@link Player} for which to unlock this {@link Research} + * @param instant Whether to unlock the research instantly */ public void unlock(final Player p, boolean instant) { if (!instant) { @@ -170,7 +168,7 @@ public class Research implements Keyed { profile.setResearched(this, true); SlimefunPlugin.getLocal().sendMessage(p, "messages.unlocked", true, msg -> msg.replace("%research%", getName(p))); - if (SlimefunPlugin.getSettings().researchFireworksEnabled && (!PersistentDataAPI.hasByte(p, GuideSettings.FIREWORKS_KEY) || PersistentDataAPI.getByte(p, GuideSettings.FIREWORKS_KEY) == (byte) 1)) { + if (SlimefunPlugin.getSettings().researchFireworksEnabled && (!PersistentDataAPI.hasByte(p, SlimefunGuideSettings.FIREWORKS_KEY) || PersistentDataAPI.getByte(p, SlimefunGuideSettings.FIREWORKS_KEY) == (byte) 1)) { FireworkUtils.launchRandom(p, 1); } }; @@ -207,9 +205,7 @@ public class Research implements Keyed { } /** - * Registers the research. - * - * @since 4.0 + * Registers this {@link Research}. */ public void register() { SlimefunPlugin.getResearchCfg().setDefaultValue("enable-researching", true); @@ -241,6 +237,7 @@ public class Research implements Keyed { } } + // Temporary migration method from ids to Namespaced Keys. private void migrate(int id, String path) { if (SlimefunPlugin.getResearchCfg().contains(id + ".enabled")) { SlimefunPlugin.getResearchCfg().setValue(path + ".enabled", SlimefunPlugin.getResearchCfg().getBoolean(id + ".enabled")); @@ -254,24 +251,10 @@ public class Research implements Keyed { } /** - * Gets if the specified player is currently unlocking a research. - * - * @param p Player to check - * @return true if the player is unlocking a research, otherwise false - * - * @since 4.0 - */ - public static boolean isResearching(Player p) { - return SlimefunPlugin.getRegistry().getCurrentlyResearchingPlayers().contains(p.getUniqueId()); - } - - /** - * Attempts to get the research with the given ID. + * Attempts to get a {@link Research} with the given ID. * * @param id ID of the research to get * @return Research if found, or null - * - * @since 4.0 */ public static Research getByID(int id) { for (Research research : SlimefunPlugin.getRegistry().getResearches()) { diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/SlimefunItem.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/SlimefunItem.java index 6bc815ba6..386f500ba 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/SlimefunItem.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/SlimefunItem.java @@ -24,8 +24,8 @@ import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon; import io.github.thebusybiscuit.slimefun4.api.items.Placeable; import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetComponent; import io.github.thebusybiscuit.slimefun4.core.attributes.Radioactive; +import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide; import io.github.thebusybiscuit.slimefun4.implementation.items.altar.AltarRecipe; -import me.mrCookieSlime.Slimefun.SlimefunGuide; import me.mrCookieSlime.Slimefun.SlimefunPlugin; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Lists.SlimefunItems; @@ -33,12 +33,12 @@ import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.Objects.Research; import me.mrCookieSlime.Slimefun.Objects.SlimefunBlockHandler; import me.mrCookieSlime.Slimefun.Objects.handlers.BlockTicker; +import me.mrCookieSlime.Slimefun.Objects.handlers.GeneratorTicker; import me.mrCookieSlime.Slimefun.Objects.handlers.ItemHandler; import me.mrCookieSlime.Slimefun.Setup.SlimefunManager; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; import me.mrCookieSlime.Slimefun.api.energy.EnergyNet; import me.mrCookieSlime.Slimefun.api.energy.EnergyNetComponentType; -import me.mrCookieSlime.Slimefun.api.energy.EnergyTicker; public class SlimefunItem implements Placeable { @@ -68,7 +68,7 @@ public class SlimefunItem implements Placeable { private final OptionalMap, ItemHandler> itemhandlers = new OptionalMap<>(HashMap::new); private boolean ticking = false; private BlockTicker blockTicker; - private EnergyTicker energyTicker; + private GeneratorTicker energyTicker; public SlimefunItem(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { this(category, item, recipeType, recipe, null); @@ -193,7 +193,7 @@ public class SlimefunItem implements Placeable { return blockTicker; } - public EnergyTicker getEnergyTicker() { + public GeneratorTicker getEnergyTicker() { return energyTicker; } @@ -467,8 +467,8 @@ public class SlimefunItem implements Placeable { SlimefunPlugin.getRegistry().getTickerBlocks().add(getID()); blockTicker = (BlockTicker) handler; } - else if (handler instanceof EnergyTicker) { - energyTicker = (EnergyTicker) handler; + else if (handler instanceof GeneratorTicker) { + energyTicker = (GeneratorTicker) handler; EnergyNet.registerComponent(getID(), EnergyNetComponentType.GENERATOR); } } diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AGenerator.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AGenerator.java index b8503c405..d6ffa9e0d 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AGenerator.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AGenerator.java @@ -31,12 +31,12 @@ import me.mrCookieSlime.Slimefun.Lists.SlimefunItems; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.interfaces.RecipeDisplayItem; +import me.mrCookieSlime.Slimefun.Objects.handlers.GeneratorTicker; import me.mrCookieSlime.Slimefun.Setup.SlimefunManager; import me.mrCookieSlime.Slimefun.api.BlockStorage; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; import me.mrCookieSlime.Slimefun.api.energy.ChargableBlock; import me.mrCookieSlime.Slimefun.api.energy.EnergyNetComponentType; -import me.mrCookieSlime.Slimefun.api.energy.EnergyTicker; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset; import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow; @@ -167,7 +167,7 @@ public abstract class AGenerator extends SlimefunItem implements RecipeDisplayIt @Override public void preRegister() { - addItemHandler(new EnergyTicker() { + addItemHandler(new GeneratorTicker() { @Override public double generateEnergy(Location l, SlimefunItem sf, Config data) { diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AReactor.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AReactor.java index 796ba6c2c..439ce885f 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AReactor.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AReactor.java @@ -33,13 +33,13 @@ import me.mrCookieSlime.Slimefun.Lists.SlimefunItems; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.interfaces.RecipeDisplayItem; +import me.mrCookieSlime.Slimefun.Objects.handlers.GeneratorTicker; import me.mrCookieSlime.Slimefun.Setup.SlimefunManager; import me.mrCookieSlime.Slimefun.api.BlockStorage; import me.mrCookieSlime.Slimefun.api.Slimefun; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; import me.mrCookieSlime.Slimefun.api.energy.ChargableBlock; import me.mrCookieSlime.Slimefun.api.energy.EnergyNetComponentType; -import me.mrCookieSlime.Slimefun.api.energy.EnergyTicker; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset; import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow; @@ -250,7 +250,7 @@ public abstract class AReactor extends SlimefunItem implements RecipeDisplayItem @Override public void preRegister() { - addItemHandler(new EnergyTicker() { + addItemHandler(new GeneratorTicker() { private final Set explode = new HashSet<>(); diff --git a/src/main/java/me/mrCookieSlime/Slimefun/api/energy/EnergyTicker.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/handlers/GeneratorTicker.java similarity index 64% rename from src/main/java/me/mrCookieSlime/Slimefun/api/energy/EnergyTicker.java rename to src/main/java/me/mrCookieSlime/Slimefun/Objects/handlers/GeneratorTicker.java index 29be3bc11..0f27fe3d5 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/api/energy/EnergyTicker.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/Objects/handlers/GeneratorTicker.java @@ -1,19 +1,18 @@ -package me.mrCookieSlime.Slimefun.api.energy; +package me.mrCookieSlime.Slimefun.Objects.handlers; import org.bukkit.Location; import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; -import me.mrCookieSlime.Slimefun.Objects.handlers.ItemHandler; -public abstract class EnergyTicker implements ItemHandler { +public abstract class GeneratorTicker implements ItemHandler { public abstract double generateEnergy(Location l, SlimefunItem item, Config data); public abstract boolean explode(Location l); @Override public Class getIdentifier() { - return EnergyTicker.class; + return GeneratorTicker.class; } } diff --git a/src/main/java/me/mrCookieSlime/Slimefun/SlimefunPlugin.java b/src/main/java/me/mrCookieSlime/Slimefun/SlimefunPlugin.java index c6655b431..725607b26 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/SlimefunPlugin.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/SlimefunPlugin.java @@ -164,6 +164,9 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon { if (config.getBoolean("options.auto-update")) { updaterService.start(); } + else { + updaterService.disable(); + } // Registering all GEO Resources getLogger().log(Level.INFO, "Loading GEO-Resources..."); diff --git a/src/main/java/me/mrCookieSlime/Slimefun/api/item_transport/CargoNet.java b/src/main/java/me/mrCookieSlime/Slimefun/api/item_transport/CargoNet.java index 8504b89ea..8edc6e59a 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/api/item_transport/CargoNet.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/api/item_transport/CargoNet.java @@ -213,7 +213,7 @@ public class CargoNet extends Network { if (menu.getItemInSlot(17) == null) { Block target = getAttachedBlock(bus.getBlock()); - ItemAndInt stack = CargoUtils.withdraw(bus.getBlock(), target, -1); + ItemStackAndInteger stack = CargoUtils.withdraw(bus.getBlock(), target, -1); if (stack != null) { menu.replaceExistingItem(17, stack.getItem()); @@ -354,7 +354,7 @@ public class CargoNet extends Network { boolean roundrobin = "true".equals(cfg.getString("round-robin")); if (inputTarget != null) { - ItemAndInt slot = CargoUtils.withdraw(input.getBlock(), inputTarget, Integer.parseInt(cfg.getString("index"))); + ItemStackAndInteger slot = CargoUtils.withdraw(input.getBlock(), inputTarget, Integer.parseInt(cfg.getString("index"))); if (slot != null) { stack = slot.getItem(); @@ -413,7 +413,7 @@ public class CargoNet extends Network { //Chest Terminal Code if (extraChannels) { - List items = new ArrayList<>(); + List items = new ArrayList<>(); for (Location l : providers) { Block target = getAttachedBlock(l.getBlock()); @@ -438,7 +438,7 @@ public class CargoNet extends Network { if (is != null && CargoUtils.matchesFilter(l.getBlock(), is, -1)) { boolean add = true; - for (ItemAndInt item : items) { + for (ItemStackAndInteger item : items) { if (SlimefunManager.isItemSimilar(is, item.getItem(), true)) { add = false; item.add(is.getAmount() + stored); @@ -446,7 +446,7 @@ public class CargoNet extends Network { } if (add) { - items.add(new ItemAndInt(new CustomItem(is, 1), is.getAmount() + stored)); + items.add(new ItemStackAndInteger(new CustomItem(is, 1), is.getAmount() + stored)); } } } @@ -483,7 +483,7 @@ public class CargoNet extends Network { int slot = terminal_slots[i]; if (items.size() > i + (terminal_slots.length * (page - 1))) { - ItemAndInt item = items.get(i + (terminal_slots.length * (page - 1))); + ItemStackAndInteger item = items.get(i + (terminal_slots.length * (page - 1))); ItemStack stack = item.getItem().clone(); ItemMeta im = stack.getItemMeta(); @@ -539,17 +539,17 @@ public class CargoNet extends Network { return freq; } - private void handleWithdraw(DirtyChestMenu menu, List items, Location l) { + private void handleWithdraw(DirtyChestMenu menu, List items, Location l) { for (int slot : menu.getPreset().getSlotsAccessedByItemTransport(menu, ItemTransportFlow.WITHDRAW, null)) { filter(menu.getItemInSlot(slot), items, l); } } - private void filter(ItemStack is, List items, Location l) { + private void filter(ItemStack is, List items, Location l) { if (is != null && CargoUtils.matchesFilter(l.getBlock(), is, -1)) { boolean add = true; - for (ItemAndInt item : items) { + for (ItemStackAndInteger item : items) { if (SlimefunManager.isItemSimilar(is, item.getItem(), true)) { add = false; item.add(is.getAmount()); @@ -557,7 +557,7 @@ public class CargoNet extends Network { } if (add) { - items.add(new ItemAndInt(new CustomItem(is, 1), is.getAmount())); + items.add(new ItemStackAndInteger(new CustomItem(is, 1), is.getAmount())); } } } diff --git a/src/main/java/me/mrCookieSlime/Slimefun/api/item_transport/CargoUtils.java b/src/main/java/me/mrCookieSlime/Slimefun/api/item_transport/CargoUtils.java index 3c2424064..a70a9bfe0 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/api/item_transport/CargoUtils.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/api/item_transport/CargoUtils.java @@ -86,7 +86,7 @@ public final class CargoUtils { return null; } - public static ItemAndInt withdraw(Block node, Block target, int index) { + public static ItemStackAndInteger withdraw(Block node, Block target, int index) { DirtyChestMenu menu = getChestMenu(target); if (menu != null) { @@ -95,7 +95,7 @@ public final class CargoUtils { if (matchesFilter(node, is, index)) { menu.replaceExistingItem(slot, null); - return new ItemAndInt(is.clone(), slot); + return new ItemStackAndInteger(is.clone(), slot); } } } @@ -121,7 +121,7 @@ public final class CargoUtils { if (matchesFilter(node, is, index)) { inv.setItem(slot, null); - return new ItemAndInt(is.clone(), slot); + return new ItemStackAndInteger(is.clone(), slot); } } } diff --git a/src/main/java/me/mrCookieSlime/Slimefun/api/item_transport/ItemAndInt.java b/src/main/java/me/mrCookieSlime/Slimefun/api/item_transport/ItemStackAndInteger.java similarity index 80% rename from src/main/java/me/mrCookieSlime/Slimefun/api/item_transport/ItemAndInt.java rename to src/main/java/me/mrCookieSlime/Slimefun/api/item_transport/ItemStackAndInteger.java index baf4c6f77..75cbde684 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/api/item_transport/ItemAndInt.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/api/item_transport/ItemStackAndInteger.java @@ -2,12 +2,12 @@ package me.mrCookieSlime.Slimefun.api.item_transport; import org.bukkit.inventory.ItemStack; -public class ItemAndInt { +class ItemStackAndInteger { private final ItemStack item; private int number; - public ItemAndInt(ItemStack item, int amount) { + public ItemStackAndInteger(ItemStack item, int amount) { this.number = amount; this.item = item; }