1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-20 03:35:51 +00:00

Merge branch 'master' of https://github.com/TheBusyBiscuit/Slimefun4 into fix/performance-improvements

# Conflicts:
#	src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GearListener.java
This commit is contained in:
Panda.com 2020-03-01 15:52:36 +01:00
commit 7b74a347b6
47 changed files with 306 additions and 220 deletions

View File

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

View File

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

View File

@ -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<String, BlockStorage> worlds = new HashMap<>();
private final Map<String, BlockInfoConfig> chunks = new HashMap<>();
private final Map<UUID, PlayerProfile> profiles = new HashMap<>();
private final Map<SlimefunGuideLayout, ISlimefunGuide> layouts = new EnumMap<>(SlimefunGuideLayout.class);
private final Map<SlimefunGuideLayout, SlimefunGuideImplementation> layouts = new EnumMap<>(SlimefunGuideLayout.class);
private final Map<EntityType, Set<ItemStack>> drops = new EnumMap<>(EntityType.class);
private final Map<String, Integer> capacities = new HashMap<>();
private final Map<String, BlockMenuPreset> blockMenuPresets = new HashMap<>();
@ -80,7 +80,7 @@ public class SlimefunRegistry {
private final Map<String, ItemStack> 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);
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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<EnergyTicker> {
public abstract class SolarGenerator extends SimpleSlimefunItem<GeneratorTicker> {
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<EnergyTicker> {
}
@Override
public EnergyTicker getItemHandler() {
return new EnergyTicker() {
public GeneratorTicker getItemHandler() {
return new GeneratorTicker() {
@Override
public double generateEnergy(Location l, SlimefunItem item, Config data) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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.

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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<SlimefunItem> items;
private final int tier;
protected final NamespacedKey key;
protected final ItemStack item;
protected final List<SlimefunItem> 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<SlimefunItem> 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 + "}";
}
}

View File

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

View File

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

View File

@ -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<Class<? extends ItemHandler>, 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);
}
}

View File

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

View File

@ -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<Location> explode = new HashSet<>();

View File

@ -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<? extends ItemHandler> getIdentifier() {
return EnergyTicker.class;
return GeneratorTicker.class;
}
}

View File

@ -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...");

View File

@ -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<ItemAndInt> items = new ArrayList<>();
List<ItemStackAndInteger> 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<ItemAndInt> items, Location l) {
private void handleWithdraw(DirtyChestMenu menu, List<ItemStackAndInteger> 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<ItemAndInt> items, Location l) {
private void filter(ItemStack is, List<ItemStackAndInteger> 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()));
}
}
}

View File

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

View File

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