entry : getRegistry().getWorlds().entrySet()) {
+ try {
+ entry.getValue().save(true);
+ }
+ catch (Exception x) {
+ getLogger().log(Level.SEVERE, x, () -> "An Error occurred while saving Slimefun-Blocks in World '" + entry.getKey() + "' for Slimefun " + getVersion());
+ }
+ }
+
+ for (UniversalBlockMenu menu : registry.getUniversalInventories().values()) {
+ menu.save();
+ }
+
+ // Create a new backup zip
+ backupService.run();
+
+ // Prevent Memory Leaks
+ // These static Maps should be removed at some point...
+ AContainer.processing = null;
+ AContainer.progress = null;
+
+ AGenerator.processing = null;
+ AGenerator.progress = null;
+
+ Reactor.processing = null;
+ Reactor.progress = null;
+
+ instance = null;
+
+ // Close all inventories on the server to prevent item dupes
+ // (Incase some idiot uses /reload)
+ for (Player p : Bukkit.getOnlinePlayers()) {
+ p.closeInventory();
+ }
+ }
+
+ private void createDirectories() {
+ String[] storageFolders = { "Players", "blocks", "stored-blocks", "stored-inventories", "stored-chunks", "universal-inventories", "waypoints", "block-backups" };
+ String[] pluginFolders = { "scripts", "error-reports", "cache/github", "world-settings" };
+
+ for (String folder : storageFolders) {
+ File file = new File("data-storage/Slimefun", folder);
+
+ if (!file.exists()) {
+ file.mkdirs();
+ }
+ }
+
+ for (String folder : pluginFolders) {
+ File file = new File("plugins/Slimefun", folder);
+
+ if (!file.exists()) {
+ file.mkdirs();
+ }
+ }
+ }
+
+ private void registerListeners() {
+ new SlimefunBootsListener(this);
+ new SlimefunItemListener(this);
+ new SlimefunItemConsumeListener(this);
+ new BlockPhysicsListener(this);
+ new CargoNodeListener(this);
+ new MultiBlockListener(this);
+ new GadgetsListener(this);
+ new DispenserListener(this);
+ new BlockListener(this);
+ new EnhancedFurnaceListener(this);
+ new ItemPickupListener(this);
+ new DeathpointListener(this);
+ new ExplosionsListener(this);
+ new DebugFishListener(this);
+ new VanillaMachinesListener(this);
+ new FireworksListener(this);
+ new WitherListener(this);
+ new IronGolemListener(this);
+ new PlayerInteractEntityListener(this);
+
+ if (minecraftVersion.isAtLeast(MinecraftVersion.MINECRAFT_1_15)) {
+ new BeeListener(this);
+ }
+
+ new MobDropListener(this);
+
+ // Item-specific Listeners
+ new VampireBladeListener(this, (VampireBlade) SlimefunItems.BLADE_OF_VAMPIRES.getItem());
+ new CoolerListener(this, (Cooler) SlimefunItems.COOLER.getItem());
+ new SeismicAxeListener(this, (SeismicAxe) SlimefunItems.SEISMIC_AXE.getItem());
+ grapplingHookListener.register(this, (GrapplingHook) SlimefunItems.GRAPPLING_HOOK.getItem());
+ ancientAltarListener.register(this, (AncientAltar) SlimefunItems.ANCIENT_ALTAR.getItem());
+
+ bowListener.register(this);
+
+ // Toggleable Listeners for performance reasons
+ if (config.getBoolean("items.talismans")) {
+ new TalismanListener(this);
+ }
+
+ if (config.getBoolean("items.soulbound")) {
+ new SoulboundListener(this);
+ }
+
+ if (config.getBoolean("items.backpacks")) {
+ backpackListener.register(this);
+ }
+
+ // Handle Slimefun Guide being given on Join
+ new SlimefunGuideListener(this, config.getBoolean("guide.receive-on-first-join"));
+
+ // Load/Unload Worlds in Slimefun
+ new WorldListener(this);
+
+ // Clear the Slimefun Guide History upon Player Leaving
+ new PlayerProfileListener(this);
+ }
+
+ private void loadItems() {
+ try {
+ SlimefunItemSetup.setup(this);
+ }
+ catch (Exception | LinkageError x) {
+ getLogger().log(Level.SEVERE, x, () -> "An Error occurred while initializing SlimefunItems for Slimefun " + getVersion());
+ }
+ }
+
+ private void loadResearches() {
+ try {
+ ResearchSetup.setupResearches();
+ }
+ catch (Exception | LinkageError x) {
+ getLogger().log(Level.SEVERE, x, () -> "An Error occurred while initializing Slimefun Researches for Slimefun " + getVersion());
+ }
+ }
+
+ public static SlimefunPlugin instance() {
+ return instance;
+ }
+
+ public static Config getCfg() {
+ return instance.config;
+ }
+
+ public static Config getResearchCfg() {
+ return instance.researches;
+ }
+
+ public static Config getItemCfg() {
+ return instance.items;
+ }
+
+ public static GPSNetwork getGPSNetwork() {
+ return instance.gpsNetwork;
+ }
+
+ public static TickerTask getTickerTask() {
+ return instance.ticker;
+ }
+
+ /**
+ * This returns the version of Slimefun that is currently installed.
+ *
+ * @return The currently installed version of Slimefun
+ */
+ public static String getVersion() {
+ return instance.getDescription().getVersion();
+ }
+
+ /**
+ * This returns the {@link LocalizationService} of Slimefun.
+ *
+ * @return The {@link LocalizationService} of Slimefun
+ */
+ public static LocalizationService getLocalization() {
+ return instance.local;
+ }
+
+ public static ProtectionManager getProtectionManager() {
+ return instance.protections;
+ }
+
+ public static MinecraftRecipeService getMinecraftRecipeService() {
+ return instance.recipeService;
+ }
+
+ public static CustomItemDataService getItemDataService() {
+ return instance.itemDataService;
+ }
+
+ public static CustomTextureService getItemTextureService() {
+ return instance.textureService;
+ }
+
+ public static PermissionsService getPermissionsService() {
+ return instance.permissionsService;
+ }
+
+ public static BlockDataService getBlockDataService() {
+ return instance.blockDataService;
+ }
+
+ public static ThirdPartyPluginService getThirdPartySupportService() {
+ return instance.thirdPartySupportService;
+ }
+
+ public static PerWorldSettingsService getWorldSettingsService() {
+ return instance.worldSettingsService;
+ }
+
+ /**
+ * This method returns the {@link UpdaterService} of Slimefun.
+ * It is used to handle automatic updates.
+ *
+ * @return The {@link UpdaterService} for Slimefun
+ */
+ public static UpdaterService getUpdater() {
+ return instance.updaterService;
+ }
+
+ /**
+ * This method returns the {@link GitHubService} of Slimefun.
+ * It is used to retrieve data from GitHub repositories.
+ *
+ * @return The {@link GitHubService} for Slimefun
+ */
+ public static GitHubService getGitHubService() {
+ return instance.gitHubService;
+ }
+
+ public static SlimefunRegistry getRegistry() {
+ return instance.registry;
+ }
+
+ public static NetworkManager getNetworkManager() {
+ return instance.networkManager;
+ }
+
+ public static AncientAltarListener getAncientAltarListener() {
+ return instance.ancientAltarListener;
+ }
+
+ public static GrapplingHookListener getGrapplingHookListener() {
+ return instance.grapplingHookListener;
+ }
+
+ public static BackpackListener getBackpackListener() {
+ return instance.backpackListener;
+ }
+
+ public static SlimefunBowListener getBowListener() {
+ return instance.bowListener;
+ }
+
+ /**
+ * This method returns a {@link Set} of every {@link Plugin} that lists Slimefun
+ * as a required or optional dependency.
+ *
+ * We will just assume this to be a list of our addons.
+ *
+ * @return A {@link Set} of every {@link Plugin} that is dependent on Slimefun
+ */
+ public static Set getInstalledAddons() {
+ return Arrays.stream(instance.getServer().getPluginManager().getPlugins()).filter(plugin -> plugin.getDescription().getDepend().contains(instance.getName()) || plugin.getDescription().getSoftDepend().contains(instance.getName())).collect(Collectors.toSet());
+ }
+
+ /**
+ * The {@link Command} that was added by Slimefun.
+ *
+ * @return Slimefun's command
+ */
+ public static SlimefunCommand getCommand() {
+ return instance.command;
+ }
+
+ public static SlimefunProfiler getProfiler() {
+ return instance.profiler;
+ }
+
+ /**
+ * This returns the currently installed version of Minecraft.
+ *
+ * @return The current version of Minecraft
+ */
+ public static MinecraftVersion getMinecraftVersion() {
+ return instance.minecraftVersion;
+ }
+
+ public static String getCSCoreLibVersion() {
+ return CSCoreLib.getLib().getDescription().getVersion();
+ }
+
+ @Override
+ public JavaPlugin getJavaPlugin() {
+ return this;
+ }
+
+ @Override
+ public String getBugTrackerURL() {
+ return "https://github.com/TheBusyBiscuit/Slimefun4/issues";
+ }
+
+}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/BookSlimefunGuide.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/BookSlimefunGuide.java
index 4872834d4..afaa464d4 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/BookSlimefunGuide.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/BookSlimefunGuide.java
@@ -26,16 +26,16 @@ import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideImplementation;
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout;
import io.github.thebusybiscuit.slimefun4.core.researching.Research;
+import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import io.github.thebusybiscuit.slimefun4.utils.ChatUtils;
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
-import me.mrCookieSlime.Slimefun.SlimefunPlugin;
import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
import me.mrCookieSlime.Slimefun.api.Slimefun;
public class BookSlimefunGuide implements SlimefunGuideImplementation {
- private final NamespacedKey guideSearch = new NamespacedKey(SlimefunPlugin.instance, "search");
+ private final NamespacedKey guideSearch = new NamespacedKey(SlimefunPlugin.instance(), "search");
@Override
public SlimefunGuideLayout getLayout() {
@@ -53,17 +53,17 @@ public class BookSlimefunGuide implements SlimefunGuideImplementation {
}
private void openBook(Player p, PlayerProfile profile, List lines, boolean backButton) {
- CustomBookInterface book = new CustomBookInterface(SlimefunPlugin.instance);
- book.setTitle(SlimefunPlugin.getLocal().getMessage(p, "guide.title.main"));
+ CustomBookInterface book = new CustomBookInterface(SlimefunPlugin.instance());
+ book.setTitle(SlimefunPlugin.getLocalization().getMessage(p, "guide.title.main"));
for (int i = 0; i < lines.size(); i = i + 10) {
ChatComponent page = new ChatComponent("");
- ChatComponent header = new ChatComponent(ChatColors.color("&b&l- " + SlimefunPlugin.getLocal().getMessage(p, "guide.title.main") + " -\n\n"));
+ ChatComponent header = new ChatComponent(ChatColors.color("&b&l- " + SlimefunPlugin.getLocalization().getMessage(p, "guide.title.main") + " -\n\n"));
header.setHoverEvent(new HoverEvent(ChestMenuUtils.getSearchButton(p)));
header.setClickEvent(new ClickEvent(guideSearch, player -> Slimefun.runSync(() -> {
- SlimefunPlugin.getLocal().sendMessage(player, "guide.search.message");
- ChatInput.waitForPlayer(SlimefunPlugin.instance, player, msg -> SlimefunGuide.openSearch(profile, msg, true, true));
+ SlimefunPlugin.getLocalization().sendMessage(player, "guide.search.message");
+ ChatInput.waitForPlayer(SlimefunPlugin.instance(), player, msg -> SlimefunGuide.openSearch(profile, msg, true, true));
}, 1)));
page.append(header);
@@ -75,9 +75,9 @@ public class BookSlimefunGuide implements SlimefunGuideImplementation {
page.append(new ChatComponent("\n"));
if (backButton) {
- ChatComponent button = new ChatComponent(ChatColor.DARK_BLUE + "\u21E6 " + SlimefunPlugin.getLocal().getMessage(p, "guide.back.title"));
- button.setHoverEvent(new HoverEvent(ChatColor.DARK_BLUE + "\u21E6 " + SlimefunPlugin.getLocal().getMessage(p, "guide.back.title"), "", ChatColor.GRAY + SlimefunPlugin.getLocal().getMessage(p, "guide.back.guide")));
- button.setClickEvent(new ClickEvent(new NamespacedKey(SlimefunPlugin.instance, "slimefun_guide"), pl -> openMainMenu(profile, 1)));
+ ChatComponent button = new ChatComponent(ChatColor.DARK_BLUE + "\u21E6 " + SlimefunPlugin.getLocalization().getMessage(p, "guide.back.title"));
+ button.setHoverEvent(new HoverEvent(ChatColor.DARK_BLUE + "\u21E6 " + SlimefunPlugin.getLocalization().getMessage(p, "guide.back.title"), "", ChatColor.GRAY + SlimefunPlugin.getLocalization().getMessage(p, "guide.back.guide")));
+ button.setClickEvent(new ClickEvent(new NamespacedKey(SlimefunPlugin.instance(), "slimefun_guide"), pl -> openMainMenu(profile, 1)));
page.append(button);
}
@@ -114,10 +114,10 @@ public class BookSlimefunGuide implements SlimefunGuideImplementation {
if (category instanceof LockedCategory && !((LockedCategory) category).hasUnlocked(p, profile)) {
List lore = new LinkedList<>();
- lore.add(ChatColor.DARK_RED + SlimefunPlugin.getLocal().getMessage(p, "guide.locked") + " " + ChatColor.GRAY + "- " + ChatColor.RESET + category.getItem(p).getItemMeta().getDisplayName());
+ lore.add(ChatColor.DARK_RED + SlimefunPlugin.getLocalization().getMessage(p, "guide.locked") + " " + ChatColor.GRAY + "- " + ChatColor.RESET + category.getItem(p).getItemMeta().getDisplayName());
lore.add("");
- for (String line : SlimefunPlugin.getLocal().getMessages(p, "guide.locked-category")) {
+ for (String line : SlimefunPlugin.getLocalization().getMessages(p, "guide.locked-category")) {
lore.add(ChatColor.RESET + line);
}
@@ -133,7 +133,7 @@ public class BookSlimefunGuide implements SlimefunGuideImplementation {
}
else {
ChatComponent chatComponent = new ChatComponent(ChatUtils.crop(ChatColor.DARK_GREEN, ItemUtils.getItemName(category.getItem(p))) + "\n");
- chatComponent.setHoverEvent(new HoverEvent(ItemUtils.getItemName(category.getItem(p)), "", ChatColor.GRAY + "\u21E8 " + ChatColor.GREEN + SlimefunPlugin.getLocal().getMessage(p, "guide.tooltips.open-category")));
+ chatComponent.setHoverEvent(new HoverEvent(ItemUtils.getItemName(category.getItem(p)), "", ChatColor.GRAY + "\u21E8 " + ChatColor.GREEN + SlimefunPlugin.getLocalization().getMessage(p, "guide.tooltips.open-category")));
chatComponent.setClickEvent(new ClickEvent(category.getKey(), pl -> openCategory(profile, category, 1)));
lines.add(chatComponent);
}
@@ -189,13 +189,13 @@ public class BookSlimefunGuide implements SlimefunGuideImplementation {
}
private void appendSlimefunItem(Category category, int page, Player p, PlayerProfile profile, SlimefunItem item, List items) {
- NamespacedKey key = new NamespacedKey(SlimefunPlugin.instance, item.getID().toLowerCase(Locale.ROOT));
+ NamespacedKey key = new NamespacedKey(SlimefunPlugin.instance(), item.getID().toLowerCase(Locale.ROOT));
if (!Slimefun.hasUnlocked(p, item, false) && item.getResearch() != null) {
Research research = item.getResearch();
ChatComponent component = new ChatComponent(ChatUtils.crop(ChatColor.RED, item.getItemName()) + "\n");
- component.setHoverEvent(new HoverEvent(ChatColor.RESET + item.getItemName(), ChatColor.DARK_RED.toString() + ChatColor.BOLD + SlimefunPlugin.getLocal().getMessage(p, "guide.locked"), "", ChatColor.GREEN + "> Click to unlock", "", ChatColor.GRAY + "Cost: " + ChatColor.AQUA.toString() + research.getCost() + " Level(s)"));
+ component.setHoverEvent(new HoverEvent(ChatColor.RESET + item.getItemName(), ChatColor.DARK_RED.toString() + ChatColor.BOLD + SlimefunPlugin.getLocalization().getMessage(p, "guide.locked"), "", ChatColor.GREEN + "> Click to unlock", "", ChatColor.GRAY + "Cost: " + ChatColor.AQUA.toString() + research.getCost() + " Level(s)"));
component.setClickEvent(new ClickEvent(key, player -> Slimefun.runSync(() -> {
if (!SlimefunPlugin.getRegistry().getCurrentlyResearchingPlayers().contains(p.getUniqueId())) {
if (research.canUnlock(p)) {
@@ -207,7 +207,7 @@ public class BookSlimefunGuide implements SlimefunGuideImplementation {
}
}
else {
- SlimefunPlugin.getLocal().sendMessage(p, "messages.not-enough-xp", true);
+ SlimefunPlugin.getLocalization().sendMessage(p, "messages.not-enough-xp", true);
}
}
})));
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/ChestSlimefunGuide.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/ChestSlimefunGuide.java
index 88c956b7a..52b3670ed 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/ChestSlimefunGuide.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/ChestSlimefunGuide.java
@@ -36,11 +36,11 @@ import io.github.thebusybiscuit.slimefun4.core.guide.options.SlimefunGuideSettin
import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlock;
import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine;
import io.github.thebusybiscuit.slimefun4.core.researching.Research;
+import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import io.github.thebusybiscuit.slimefun4.utils.ChatUtils;
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.MenuClickHandler;
-import me.mrCookieSlime.Slimefun.SlimefunPlugin;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
@@ -55,13 +55,13 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation {
private final boolean showVanillaRecipes;
public ChestSlimefunGuide(boolean vanillaRecipes) {
+ showVanillaRecipes = vanillaRecipes;
+
if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_14)) {
sound = Sound.ITEM_BOOK_PAGE_TURN;
- showVanillaRecipes = vanillaRecipes;
}
else {
sound = Sound.ENTITY_BAT_TAKEOFF;
- showVanillaRecipes = false;
}
}
@@ -115,9 +115,10 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation {
while (target < (categories.size() - 1) && index < CATEGORY_SIZE + 9) {
target++;
- Category category = categories.get(target);
+ Category category = categories.get(target);
displayCategory(menu, p, profile, category, index);
+
index++;
}
@@ -126,14 +127,22 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation {
menu.addItem(46, ChestMenuUtils.getPreviousButton(p, page, pages));
menu.addMenuClickHandler(46, (pl, slot, item, action) -> {
int next = page - 1;
- if (next != page && next > 0) openMainMenu(profile, next);
+
+ if (next != page && next > 0) {
+ openMainMenu(profile, next);
+ }
+
return false;
});
menu.addItem(52, ChestMenuUtils.getNextButton(p, page, pages));
menu.addMenuClickHandler(52, (pl, slot, item, action) -> {
int next = page + 1;
- if (next != page && next <= pages) openMainMenu(profile, next);
+
+ if (next != page && next <= pages) {
+ openMainMenu(profile, next);
+ }
+
return false;
});
@@ -152,8 +161,8 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation {
List lore = new ArrayList<>();
lore.add("");
- for (String line : SlimefunPlugin.getLocal().getMessages(p, "guide.locked-category")) {
- lore.add(ChatColor.RESET + line);
+ for (String line : SlimefunPlugin.getLocalization().getMessages(p, "guide.locked-category")) {
+ lore.add(ChatColor.WHITE + line);
}
lore.add("");
@@ -162,7 +171,7 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation {
lore.add(parent.getItem(p).getItemMeta().getDisplayName());
}
- menu.addItem(index, new CustomItem(Material.BARRIER, "&4" + SlimefunPlugin.getLocal().getMessage(p, "guide.locked") + " &7- &r" + category.getItem(p).getItemMeta().getDisplayName(), lore.toArray(new String[0])));
+ menu.addItem(index, new CustomItem(Material.BARRIER, "&4" + SlimefunPlugin.getLocalization().getMessage(p, "guide.locked") + " &7- &f" + category.getItem(p).getItemMeta().getDisplayName(), lore.toArray(new String[0])));
menu.addMenuClickHandler(index, ChestMenuUtils.getEmptyClickHandler());
}
}
@@ -187,7 +196,7 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation {
ChestMenu menu = create(p);
createHeader(p, profile, menu);
- menu.addItem(1, new CustomItem(ChestMenuUtils.getBackButton(p, "", ChatColor.GRAY + SlimefunPlugin.getLocal().getMessage(p, "guide.back.guide"))));
+ menu.addItem(1, new CustomItem(ChestMenuUtils.getBackButton(p, "", ChatColor.GRAY + SlimefunPlugin.getLocalization().getMessage(p, "guide.back.guide"))));
menu.addMenuClickHandler(1, (pl, s, is, action) -> {
openMainMenu(profile, 1);
return false;
@@ -214,71 +223,75 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation {
for (int i = 0; i < CATEGORY_SIZE; i++) {
int target = categoryIndex + i;
- if (target >= category.getItems().size()) break;
+
+ if (target >= category.getItems().size()) {
+ break;
+ }
SlimefunItem sfitem = category.getItems().get(target);
if (Slimefun.isEnabled(p, sfitem, false)) {
- Research research = sfitem.getResearch();
-
- if (isSurvivalMode() && !Slimefun.hasPermission(p, sfitem, false)) {
- List message = SlimefunPlugin.getPermissionsService().getLore(sfitem);
- menu.addItem(index, new CustomItem(Material.BARRIER, sfitem.getItemName(), message.toArray(new String[0])));
- menu.addMenuClickHandler(index, ChestMenuUtils.getEmptyClickHandler());
- index++;
- }
- else if (isSurvivalMode() && research != null && !profile.hasUnlocked(research)) {
- menu.addItem(index, new CustomItem(Material.BARRIER, "&r" + ItemUtils.getItemName(sfitem.getItem()), "&4&l" + SlimefunPlugin.getLocal().getMessage(p, "guide.locked"), "", "&a> Click to unlock", "", "&7Cost: &b" + research.getCost() + " Level(s)"));
- menu.addMenuClickHandler(index, (pl, slot, item, action) -> {
- if (!SlimefunPlugin.getRegistry().getCurrentlyResearchingPlayers().contains(pl.getUniqueId())) {
- if (research.canUnlock(pl)) {
- if (profile.hasUnlocked(research)) {
- openCategory(profile, category, page);
- }
- else {
- unlockItem(pl, sfitem, player -> openCategory(profile, category, page));
- }
- }
- else {
- SlimefunPlugin.getLocal().sendMessage(pl, "messages.not-enough-xp", true);
- }
- }
- return false;
- });
-
- index++;
- }
- else {
- menu.addItem(index, sfitem.getItem());
- menu.addMenuClickHandler(index, (pl, slot, item, action) -> {
- try {
- if (isSurvivalMode()) {
- displayItem(profile, sfitem, true);
- }
- else {
- if (sfitem instanceof MultiBlockMachine) {
- SlimefunPlugin.getLocal().sendMessage(pl, "guide.cheat.no-multiblocks");
- }
- else {
- pl.getInventory().addItem(sfitem.getItem().clone());
- }
- }
- }
- catch (Exception | LinkageError x) {
- printErrorMessage(pl, x);
- }
-
- return false;
- });
-
- index++;
- }
+ displaySlimefunItem(menu, category, p, profile, sfitem, page, index);
+ index++;
}
}
menu.open(p);
}
+ private void displaySlimefunItem(ChestMenu menu, Category category, Player p, PlayerProfile profile, SlimefunItem sfitem, int page, int index) {
+ Research research = sfitem.getResearch();
+
+ if (isSurvivalMode() && !Slimefun.hasPermission(p, sfitem, false)) {
+ List message = SlimefunPlugin.getPermissionsService().getLore(sfitem);
+ menu.addItem(index, new CustomItem(Material.BARRIER, sfitem.getItemName(), message.toArray(new String[0])));
+ menu.addMenuClickHandler(index, ChestMenuUtils.getEmptyClickHandler());
+ }
+ else if (isSurvivalMode() && research != null && !profile.hasUnlocked(research)) {
+ menu.addItem(index, new CustomItem(Material.BARRIER, ChatColor.WHITE + ItemUtils.getItemName(sfitem.getItem()), "&4&l" + SlimefunPlugin.getLocalization().getMessage(p, "guide.locked"), "", "&a> Click to unlock", "", "&7Cost: &b" + research.getCost() + " Level(s)"));
+ menu.addMenuClickHandler(index, (pl, slot, item, action) -> {
+ if (!SlimefunPlugin.getRegistry().getCurrentlyResearchingPlayers().contains(pl.getUniqueId())) {
+ if (research.canUnlock(pl)) {
+ if (profile.hasUnlocked(research)) {
+ openCategory(profile, category, page);
+ }
+ else {
+ unlockItem(pl, sfitem, player -> openCategory(profile, category, page));
+ }
+ }
+ else {
+ SlimefunPlugin.getLocalization().sendMessage(pl, "messages.not-enough-xp", true);
+ }
+ }
+
+ return false;
+ });
+ }
+ else {
+ menu.addItem(index, sfitem.getItem());
+ menu.addMenuClickHandler(index, (pl, slot, item, action) -> {
+ try {
+ if (isSurvivalMode()) {
+ displayItem(profile, sfitem, true);
+ }
+ else {
+ if (sfitem instanceof MultiBlockMachine) {
+ SlimefunPlugin.getLocalization().sendMessage(pl, "guide.cheat.no-multiblocks");
+ }
+ else {
+ pl.getInventory().addItem(sfitem.getItem().clone());
+ }
+ }
+ }
+ catch (Exception | LinkageError x) {
+ printErrorMessage(pl, x);
+ }
+
+ return false;
+ });
+ }
+ }
+
@Override
public void openSearch(PlayerProfile profile, String input, boolean addToHistory) {
Player p = profile.getPlayer();
@@ -287,7 +300,7 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation {
return;
}
- ChestMenu menu = new ChestMenu(SlimefunPlugin.getLocal().getMessage(p, "guide.search.inventory").replace("%item%", ChatUtils.crop(ChatColor.RESET, input)));
+ ChestMenu menu = new ChestMenu(SlimefunPlugin.getLocalization().getMessage(p, "guide.search.inventory").replace("%item%", ChatUtils.crop(ChatColor.WHITE, input)));
String searchTerm = input.toLowerCase(Locale.ROOT);
if (addToHistory) {
@@ -316,7 +329,7 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation {
ItemStack categoryItem = category.getItem(p);
if (categoryItem != null && categoryItem.hasItemMeta() && categoryItem.getItemMeta().hasDisplayName()) {
- lore = Arrays.asList("", ChatColor.DARK_GRAY + "\u21E8 " + ChatColor.RESET + categoryItem.getItemMeta().getDisplayName());
+ lore = Arrays.asList("", ChatColor.DARK_GRAY + "\u21E8 " + ChatColor.WHITE + categoryItem.getItemMeta().getDisplayName());
}
}
@@ -367,7 +380,7 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation {
return;
}
- Recipe[] recipes = SlimefunPlugin.getMinecraftRecipes().getRecipesFor(item);
+ Recipe[] recipes = SlimefunPlugin.getMinecraftRecipeService().getRecipesFor(item);
if (recipes.length == 0) {
return;
@@ -389,7 +402,7 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation {
if (optional.isPresent()) {
MinecraftRecipe> mcRecipe = optional.get();
- RecipeChoice[] choices = SlimefunPlugin.getMinecraftRecipes().getRecipeShape(recipe);
+ RecipeChoice[] choices = SlimefunPlugin.getMinecraftRecipeService().getRecipeShape(recipe);
if (choices.length == 1 && choices[0] instanceof MaterialChoice) {
recipeItems[4] = new ItemStack(((MaterialChoice) choices[0]).getChoices().get(0));
@@ -455,13 +468,16 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation {
@Override
public void displayItem(PlayerProfile profile, SlimefunItem item, boolean addToHistory) {
Player p = profile.getPlayer();
- if (p == null) return;
+
+ if (p == null) {
+ return;
+ }
ChestMenu menu = create(p);
Optional wiki = item.getWikipage();
if (wiki.isPresent()) {
- menu.addItem(8, new CustomItem(Material.KNOWLEDGE_BOOK, ChatColor.RESET + SlimefunPlugin.getLocal().getMessage(p, "guide.tooltips.wiki"), "", ChatColor.GRAY + "\u21E8 " + ChatColor.GREEN + SlimefunPlugin.getLocal().getMessage(p, "guide.tooltips.open-category")));
+ menu.addItem(8, new CustomItem(Material.KNOWLEDGE_BOOK, ChatColor.WHITE + SlimefunPlugin.getLocalization().getMessage(p, "guide.tooltips.wiki"), "", ChatColor.GRAY + "\u21E8 " + ChatColor.GREEN + SlimefunPlugin.getLocalization().getMessage(p, "guide.tooltips.open-category")));
menu.addMenuClickHandler(8, (pl, slot, itemstack, action) -> {
pl.closeInventory();
ChatUtils.sendURL(pl, wiki.get());
@@ -544,8 +560,8 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation {
menu.addMenuClickHandler(7, (pl, slot, item, action) -> {
pl.closeInventory();
- SlimefunPlugin.getLocal().sendMessage(pl, "guide.search.message");
- ChatInput.waitForPlayer(SlimefunPlugin.instance, pl, msg -> SlimefunGuide.openSearch(profile, msg, isSurvivalMode(), isSurvivalMode()));
+ SlimefunPlugin.getLocalization().sendMessage(pl, "guide.search.message");
+ ChatInput.waitForPlayer(SlimefunPlugin.instance(), pl, msg -> SlimefunGuide.openSearch(profile, msg, isSurvivalMode(), isSurvivalMode()));
return false;
});
@@ -559,7 +575,7 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation {
GuideHistory history = profile.getGuideHistory();
if (isSurvivalMode() && history.size() > 1) {
- menu.addItem(slot, new CustomItem(ChestMenuUtils.getBackButton(p, "", "&rLeft Click: &7Go back to previous Page", "&rShift + left Click: &7Go back to Main Menu")));
+ menu.addItem(slot, new CustomItem(ChestMenuUtils.getBackButton(p, "", "&fLeft Click: &7Go back to previous Page", "&fShift + left Click: &7Go back to Main Menu")));
menu.addMenuClickHandler(slot, (pl, s, is, action) -> {
if (action.isShiftClicked()) {
@@ -573,7 +589,7 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation {
}
else {
- menu.addItem(slot, new CustomItem(ChestMenuUtils.getBackButton(p, "", ChatColor.GRAY + SlimefunPlugin.getLocal().getMessage(p, "guide.back.guide"))));
+ menu.addItem(slot, new CustomItem(ChestMenuUtils.getBackButton(p, "", ChatColor.GRAY + SlimefunPlugin.getLocalization().getMessage(p, "guide.back.guide"))));
menu.addMenuClickHandler(slot, (pl, s, is, action) -> {
openMainMenu(profile, 1);
return false;
@@ -589,8 +605,8 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation {
return item;
}
- String lore = Slimefun.hasPermission(p, slimefunItem, false) ? "&rNeeds to be unlocked elsewhere" : "&rNo Permission";
- return Slimefun.hasUnlocked(p, slimefunItem, false) ? item : new CustomItem(Material.BARRIER, ItemUtils.getItemName(item), "&4&l" + SlimefunPlugin.getLocal().getMessage(p, "guide.locked"), "", lore);
+ String lore = Slimefun.hasPermission(p, slimefunItem, false) ? "&fNeeds to be unlocked elsewhere" : "&fNo Permission";
+ return Slimefun.hasUnlocked(p, slimefunItem, false) ? item : new CustomItem(Material.BARRIER, ItemUtils.getItemName(item), "&4&l" + SlimefunPlugin.getLocalization().getMessage(p, "guide.locked"), "", lore);
}
else {
return item;
@@ -678,7 +694,7 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation {
}
private ChestMenu create(Player p) {
- ChestMenu menu = new ChestMenu(SlimefunPlugin.getLocal().getMessage(p, "guide.title.main"));
+ ChestMenu menu = new ChestMenu(SlimefunPlugin.getLocalization().getMessage(p, "guide.title.main"));
menu.setEmptySlotsClickable(false);
menu.addMenuOpeningHandler(pl -> pl.playSound(pl.getLocation(), sound, 1, 1));
@@ -686,8 +702,8 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation {
}
private void printErrorMessage(Player p, Throwable x) {
- p.sendMessage(ChatColor.DARK_RED + "An internal server error has occured. Please inform an admin, check the console for further info.");
- Slimefun.getLogger().log(Level.SEVERE, "An error has occured while trying to open a SlimefunItem in the guide!", x);
+ p.sendMessage(ChatColor.DARK_RED + "An internal server error has occurred. Please inform an admin, check the console for further info.");
+ Slimefun.getLogger().log(Level.SEVERE, "An error has occurred while trying to open a SlimefunItem in the guide!", x);
}
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/RecipeChoiceTask.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/RecipeChoiceTask.java
index 96e27ffbf..642ff0b58 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/RecipeChoiceTask.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/RecipeChoiceTask.java
@@ -13,7 +13,7 @@ import org.bukkit.inventory.Recipe;
import org.bukkit.inventory.RecipeChoice.MaterialChoice;
import io.github.thebusybiscuit.cscorelib2.collections.LoopIterator;
-import me.mrCookieSlime.Slimefun.SlimefunPlugin;
+import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
/**
* A {@link RecipeChoiceTask} is an asynchronously repeating task that cycles
@@ -42,7 +42,7 @@ class RecipeChoiceTask implements Runnable {
public void start(Inventory inv) {
Validate.notNull(inv, "Inventory must not be null");
inventory = inv;
- id = Bukkit.getScheduler().runTaskTimerAsynchronously(SlimefunPlugin.instance, this, 0, UPDATE_INTERVAL).getTaskId();
+ id = Bukkit.getScheduler().runTaskTimerAsynchronously(SlimefunPlugin.instance(), this, 0, UPDATE_INTERVAL).getTaskId();
}
public void add(int slot, MaterialChoice choice) {
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/RadioactiveItem.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/RadioactiveItem.java
index c8e0052b5..3135ee83c 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/RadioactiveItem.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/RadioactiveItem.java
@@ -2,8 +2,11 @@ package io.github.thebusybiscuit.slimefun4.implementation.items;
import org.bukkit.inventory.ItemStack;
+import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent;
+import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable;
import io.github.thebusybiscuit.slimefun4.core.attributes.Radioactive;
import io.github.thebusybiscuit.slimefun4.core.attributes.Radioactivity;
+import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
@@ -21,7 +24,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
* @see Radioactivity
*
*/
-public class RadioactiveItem extends SlimefunItem implements Radioactive {
+public class RadioactiveItem extends SlimefunItem implements Radioactive, NotPlaceable {
private final Radioactivity radioactivity;
@@ -41,8 +44,14 @@ public class RadioactiveItem extends SlimefunItem implements Radioactive {
*/
public RadioactiveItem(Category category, Radioactivity radioactivity, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, recipeType, recipe);
-
+
this.radioactivity = radioactivity;
+
+ addItemHandler(onRightClick());
+ }
+
+ private ItemUseHandler onRightClick() {
+ return PlayerRightClickEvent::cancel;
}
@Override
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/SimpleSlimefunItem.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/SimpleSlimefunItem.java
new file mode 100644
index 000000000..f8ce58999
--- /dev/null
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/SimpleSlimefunItem.java
@@ -0,0 +1,50 @@
+package io.github.thebusybiscuit.slimefun4.implementation.items;
+
+import org.bukkit.inventory.ItemStack;
+
+import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler;
+import me.mrCookieSlime.Slimefun.Lists.RecipeType;
+import me.mrCookieSlime.Slimefun.Objects.Category;
+import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
+import me.mrCookieSlime.Slimefun.Objects.handlers.ItemHandler;
+import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
+
+/**
+ * This is basically a quickstart class for your very first {@link SlimefunItem}.
+ * This class easily allows you to add one {@link ItemHandler} to your {@link SlimefunItem}.
+ *
+ * You could use an {@link ItemUseHandler} for example to give your {@link SlimefunItem}
+ * very basic right-click functionalities.
+ *
+ * @author TheBusyBiscuit
+ *
+ * @see ItemHandler
+ * @see ItemUseHandler
+ * @see SlimefunItem
+ *
+ * @param
+ * The Type of {@link ItemHandler} to add to this {@link SlimefunItem}
+ */
+public abstract class SimpleSlimefunItem extends SlimefunItem {
+
+ public SimpleSlimefunItem(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
+ super(category, item, recipeType, recipe);
+ }
+
+ public SimpleSlimefunItem(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput) {
+ super(category, item, recipeType, recipe, recipeOutput);
+ }
+
+ @Override
+ public void preRegister() {
+ addItemHandler(getItemHandler());
+ }
+
+ /**
+ * This returns the {@link ItemHandler} that will be added to this {@link SlimefunItem}.
+ *
+ * @return The {@link ItemHandler} that should be added to this {@link SlimefunItem}
+ */
+ public abstract T getItemHandler();
+
+}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/altar/AncientPedestal.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/altar/AncientPedestal.java
index e9893ea18..a57fddafa 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/altar/AncientPedestal.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/altar/AncientPedestal.java
@@ -3,8 +3,8 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.altar;
import org.bukkit.entity.Item;
import org.bukkit.inventory.ItemStack;
+import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.AncientAltarListener;
-import me.mrCookieSlime.Slimefun.SlimefunPlugin;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
@@ -20,7 +20,7 @@ public class AncientPedestal extends SlimefunItem {
Item stack = listener.findItem(b);
if (stack != null) {
- stack.removeMetadata("no_pickup", SlimefunPlugin.instance);
+ stack.removeMetadata("no_pickup", SlimefunPlugin.instance());
b.getWorld().dropItem(b.getLocation(), listener.fixItemStack(stack.getItemStack(), stack.getCustomName()));
stack.remove();
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AdvancedFarmerAndroid.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AdvancedFarmerAndroid.java
index 1c94c55e2..716d21473 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AdvancedFarmerAndroid.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AdvancedFarmerAndroid.java
@@ -7,7 +7,7 @@ import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
-import me.mrCookieSlime.Slimefun.SlimefunPlugin;
+import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
@@ -44,10 +44,7 @@ public abstract class AdvancedFarmerAndroid extends FarmerAndroid {
if (result.isPresent()) {
ItemStack drop = result.get();
menu.pushItem(drop, getOutputSlots());
-
- if (menu.fits(drop, getOutputSlots())) {
- block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getType());
- }
+ block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getType());
}
}
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ButcherAndroid.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ButcherAndroid.java
index f85145f3b..0c1e8ad0f 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ButcherAndroid.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ButcherAndroid.java
@@ -11,10 +11,9 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.metadata.FixedMetadataValue;
-import me.mrCookieSlime.Slimefun.SlimefunPlugin;
+import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
-import me.mrCookieSlime.Slimefun.api.BlockStorage;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
public abstract class ButcherAndroid extends ProgrammableAndroid {
@@ -31,14 +30,14 @@ public abstract class ButcherAndroid extends ProgrammableAndroid {
}
@Override
- protected void attack(Block b, Predicate predicate) {
+ protected void attack(Block b, BlockFace face, Predicate predicate) {
double damage = getTier() >= 3 ? 20D : 4D * getTier();
double radius = 4.0 + getTier();
for (Entity n : b.getWorld().getNearbyEntities(b.getLocation(), radius, radius, radius, n -> n instanceof LivingEntity && !(n instanceof ArmorStand) && !(n instanceof Player) && n.isValid() && predicate.test((LivingEntity) n))) {
boolean attack = false;
- switch (BlockFace.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "rotation"))) {
+ switch (face) {
case NORTH:
attack = n.getLocation().getZ() < b.getZ();
break;
@@ -57,10 +56,10 @@ public abstract class ButcherAndroid extends ProgrammableAndroid {
if (attack) {
if (n.hasMetadata(METADATA_KEY)) {
- n.removeMetadata(METADATA_KEY, SlimefunPlugin.instance);
+ n.removeMetadata(METADATA_KEY, SlimefunPlugin.instance());
}
- n.setMetadata(METADATA_KEY, new FixedMetadataValue(SlimefunPlugin.instance, new AndroidInstance(this, b)));
+ n.setMetadata(METADATA_KEY, new FixedMetadataValue(SlimefunPlugin.instance(), new AndroidInstance(this, b)));
((LivingEntity) n).damage(damage);
break;
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/FarmerAndroid.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/FarmerAndroid.java
index 4b32d5239..2edd555eb 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/FarmerAndroid.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/FarmerAndroid.java
@@ -11,7 +11,7 @@ import org.bukkit.block.data.BlockData;
import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion;
-import me.mrCookieSlime.Slimefun.SlimefunPlugin;
+import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/FisherAndroid.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/FisherAndroid.java
index e9de8d50d..5bc7adf33 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/FisherAndroid.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/FisherAndroid.java
@@ -11,7 +11,7 @@ import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.cscorelib2.collections.RandomizedSet;
import io.github.thebusybiscuit.cscorelib2.materials.MaterialCollections;
import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion;
-import me.mrCookieSlime.Slimefun.SlimefunPlugin;
+import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
@@ -62,10 +62,7 @@ public abstract class FisherAndroid extends ProgrammableAndroid {
if (ThreadLocalRandom.current().nextInt(100) < 10 * getTier()) {
ItemStack drop = fishingLoot.getRandom();
-
- if (menu.fits(drop, getOutputSlots())) {
- menu.pushItem(drop, getOutputSlots());
- }
+ menu.pushItem(drop, getOutputSlots());
}
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Instruction.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Instruction.java
index 8cb11286c..02a24c1af 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Instruction.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Instruction.java
@@ -41,12 +41,12 @@ enum Instruction {
// Directions
TURN_LEFT(AndroidType.NONE, HeadTexture.SCRIPT_LEFT, (android, b, inv, face) -> {
int mod = -1;
- android.rotate(b, mod);
+ android.rotate(b, face, mod);
}),
TURN_RIGHT(AndroidType.NONE, HeadTexture.SCRIPT_RIGHT, (android, b, inv, face) -> {
int mod = 1;
- android.rotate(b, mod);
+ android.rotate(b, face, mod);
}),
// Action - Pickaxe
@@ -83,22 +83,22 @@ enum Instruction {
// Action - Sword
ATTACK_MOBS_ANIMALS(AndroidType.FIGHTER, HeadTexture.SCRIPT_ATTACK, (android, b, inv, face) -> {
Predicate predicate = e -> true;
- android.attack(b, predicate);
+ android.attack(b, face, predicate);
}),
ATTACK_MOBS(AndroidType.FIGHTER, HeadTexture.SCRIPT_ATTACK, (android, b, inv, face) -> {
Predicate predicate = e -> e instanceof Monster;
- android.attack(b, predicate);
+ android.attack(b, face, predicate);
}),
ATTACK_ANIMALS(AndroidType.FIGHTER, HeadTexture.SCRIPT_ATTACK, (android, b, inv, face) -> {
Predicate predicate = e -> e instanceof Animals;
- android.attack(b, predicate);
+ android.attack(b, face, predicate);
}),
ATTACK_ANIMALS_ADULT(AndroidType.FIGHTER, HeadTexture.SCRIPT_ATTACK, (android, b, inv, face) -> {
Predicate predicate = e -> e instanceof Animals && e instanceof Ageable && ((Ageable) e).isAdult();
- android.attack(b, predicate);
+ android.attack(b, face, predicate);
}),
// Action - Axe
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/MinerAndroid.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/MinerAndroid.java
index 228b4678e..2553ba4d8 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/MinerAndroid.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/MinerAndroid.java
@@ -13,7 +13,7 @@ import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.cscorelib2.materials.MaterialCollections;
import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction;
import io.github.thebusybiscuit.slimefun4.api.events.AndroidMineEvent;
-import me.mrCookieSlime.Slimefun.SlimefunPlugin;
+import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ProgrammableAndroid.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ProgrammableAndroid.java
index e3a87fd1d..52547aa0e 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ProgrammableAndroid.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ProgrammableAndroid.java
@@ -2,7 +2,6 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.androids;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.LinkedList;
import java.util.List;
import java.util.Optional;
import java.util.function.Predicate;
@@ -16,6 +15,7 @@ import org.bukkit.Tag;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.Dispenser;
+import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.Rotatable;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
@@ -31,6 +31,7 @@ import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
import io.github.thebusybiscuit.cscorelib2.skull.SkullBlock;
import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
+import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
import io.github.thebusybiscuit.slimefun4.utils.NumberUtils;
import io.github.thebusybiscuit.slimefun4.utils.PatternUtils;
@@ -39,7 +40,6 @@ import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.AdvancedMenuClickHandler;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction;
-import me.mrCookieSlime.Slimefun.SlimefunPlugin;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.Objects.SlimefunBlockHandler;
@@ -49,6 +49,7 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineFuel;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.interfaces.InventoryBlock;
import me.mrCookieSlime.Slimefun.Objects.handlers.BlockTicker;
import me.mrCookieSlime.Slimefun.api.BlockStorage;
+import me.mrCookieSlime.Slimefun.api.Slimefun;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset;
@@ -82,7 +83,7 @@ public abstract class ProgrammableAndroid extends SlimefunItem implements Invent
boolean open = BlockStorage.getLocationInfo(b.getLocation(), "owner").equals(p.getUniqueId().toString()) || p.hasPermission("slimefun.android.bypass");
if (!open) {
- SlimefunPlugin.getLocal().sendMessage(p, "inventory.no-access", true);
+ SlimefunPlugin.getLocalization().sendMessage(p, "inventory.no-access", true);
}
return open;
@@ -92,7 +93,7 @@ public abstract class ProgrammableAndroid extends SlimefunItem implements Invent
public void newInstance(BlockMenu menu, Block b) {
menu.replaceExistingItem(15, new CustomItem(SlimefunUtils.getCustomHead("e01c7b5726178974b3b3a01b42a590e54366026fd43808f2a787648843a7f5a"), "&aStart/Continue"));
menu.addMenuClickHandler(15, (p, slot, item, action) -> {
- SlimefunPlugin.getLocal().sendMessage(p, "android.started", true);
+ SlimefunPlugin.getLocalization().sendMessage(p, "android.started", true);
BlockStorage.addBlockInfo(b, "paused", "false");
p.closeInventory();
return false;
@@ -101,14 +102,14 @@ public abstract class ProgrammableAndroid extends SlimefunItem implements Invent
menu.replaceExistingItem(17, new CustomItem(SlimefunUtils.getCustomHead("16139fd1c5654e56e9e4e2c8be7eb2bd5b499d633616663feee99b74352ad64"), "&4Pause"));
menu.addMenuClickHandler(17, (p, slot, item, action) -> {
BlockStorage.addBlockInfo(b, "paused", "true");
- SlimefunPlugin.getLocal().sendMessage(p, "android.stopped", true);
+ SlimefunPlugin.getLocalization().sendMessage(p, "android.stopped", true);
return false;
});
menu.replaceExistingItem(16, new CustomItem(SlimefunUtils.getCustomHead("d78f2b7e5e75639ea7fb796c35d364c4df28b4243e66b76277aadcd6261337"), "&bMemory Core", "", "&8\u21E8 &7Click to open the Script Editor"));
menu.addMenuClickHandler(16, (p, slot, item, action) -> {
BlockStorage.addBlockInfo(b, "paused", "true");
- SlimefunPlugin.getLocal().sendMessage(p, "android.stopped", true);
+ SlimefunPlugin.getLocalization().sendMessage(p, "android.stopped", true);
openScriptEditor(p, b);
return false;
});
@@ -198,8 +199,8 @@ public abstract class ProgrammableAndroid extends SlimefunItem implements Invent
@Override
public void tick(Block b, SlimefunItem item, Config data) {
- if (b != null) {
- ProgrammableAndroid.this.tick(b);
+ if (b != null && data != null) {
+ ProgrammableAndroid.this.tick(b, data);
}
}
@@ -211,9 +212,9 @@ public abstract class ProgrammableAndroid extends SlimefunItem implements Invent
}
public void openScript(Player p, Block b, String sourceCode) {
- ChestMenu menu = new ChestMenu(ChatColor.DARK_AQUA + SlimefunPlugin.getLocal().getMessage(p, "android.scripts.editor"));
+ ChestMenu menu = new ChestMenu(ChatColor.DARK_AQUA + SlimefunPlugin.getLocalization().getMessage(p, "android.scripts.editor"));
- menu.addItem(0, new CustomItem(Instruction.START.getItem(), SlimefunPlugin.getLocal().getMessage(p, "android.scripts.instructions.START"), "", "&7\u21E8 &eLeft Click &7to return to the Android's interface"));
+ menu.addItem(0, new CustomItem(Instruction.START.getItem(), SlimefunPlugin.getLocalization().getMessage(p, "android.scripts.instructions.START"), "", "&7\u21E8 &eLeft Click &7to return to the Android's interface"));
menu.addMenuClickHandler(0, (pl, slot, item, action) -> {
BlockStorage.getInventory(b).open(pl);
return false;
@@ -236,7 +237,7 @@ public abstract class ProgrammableAndroid extends SlimefunItem implements Invent
}
int slot = i + (hasFreeSlot ? 1 : 0);
- menu.addItem(slot, new CustomItem(Instruction.REPEAT.getItem(), SlimefunPlugin.getLocal().getMessage(p, "android.scripts.instructions.REPEAT"), "", "&7\u21E8 &eLeft Click &7to return to the Android's interface"));
+ menu.addItem(slot, new CustomItem(Instruction.REPEAT.getItem(), SlimefunPlugin.getLocalization().getMessage(p, "android.scripts.instructions.REPEAT"), "", "&7\u21E8 &eLeft Click &7to return to the Android's interface"));
menu.addMenuClickHandler(slot, (pl, s, item, action) -> {
BlockStorage.getInventory(b).open(pl);
return false;
@@ -244,7 +245,7 @@ public abstract class ProgrammableAndroid extends SlimefunItem implements Invent
}
else {
ItemStack stack = Instruction.valueOf(script[i]).getItem();
- menu.addItem(i, new CustomItem(stack, SlimefunPlugin.getLocal().getMessage(p, "android.scripts.instructions." + Instruction.valueOf(script[i]).name()), "", "&7\u21E8 &eLeft Click &7to edit", "&7\u21E8 &eRight Click &7to delete", "&7\u21E8 &eShift + Right Click &7to duplicate"));
+ menu.addItem(i, new CustomItem(stack, SlimefunPlugin.getLocalization().getMessage(p, "android.scripts.instructions." + Instruction.valueOf(script[i]).name()), "", "&7\u21E8 &eLeft Click &7to edit", "&7\u21E8 &eRight Click &7to delete", "&7\u21E8 &eShift + Right Click &7to duplicate"));
menu.addMenuClickHandler(i, (pl, slot, item, action) -> {
if (action.isRightClicked() && action.isShiftClicked()) {
if (script.length == 54) {
@@ -387,33 +388,17 @@ public abstract class ProgrammableAndroid extends SlimefunItem implements Invent
}
else {
Script script = scripts.get(target);
- List lore = new LinkedList<>();
- lore.add("&7by &r" + script.getAuthor());
- lore.add("");
- lore.add("&7Downloads: &r" + script.getDownloads());
- lore.add("&7Rating: " + getScriptRatingPercentage(script));
- lore.add("&a" + script.getUpvotes() + " \u263A &7| &4\u2639 " + script.getDownvotes());
- lore.add("");
- lore.add("&eLeft Click &rto download this Script");
- lore.add("&4(This will override your current Script)");
-
- if (script.canRate(p)) {
- lore.add("&eShift + Left Click &rto leave a positive Rating");
- lore.add("&eShift + Right Click &rto leave a negative Rating");
- }
-
- ItemStack item = new CustomItem(getItem(), "&b" + script.getName(), lore.toArray(new String[0]));
- menu.addItem(index, item, (player, slot, stack, action) -> {
+ menu.addItem(index, script.getAsItemStack(this, p), (player, slot, stack, action) -> {
if (action.isShiftClicked()) {
if (script.isAuthor(player)) {
- SlimefunPlugin.getLocal().sendMessage(player, "android.scripts.rating.own", true);
+ SlimefunPlugin.getLocalization().sendMessage(player, "android.scripts.rating.own", true);
}
else if (script.canRate(player)) {
script.rate(player, !action.isRightClicked());
openScriptDownloader(player, b, page);
}
else {
- SlimefunPlugin.getLocal().sendMessage(player, "android.scripts.rating.already", true);
+ SlimefunPlugin.getLocalization().sendMessage(player, "android.scripts.rating.already", true);
}
}
else if (!action.isRightClicked()) {
@@ -447,24 +432,24 @@ public abstract class ProgrammableAndroid extends SlimefunItem implements Invent
}
if (script.getSourceCode().equals(code)) {
- SlimefunPlugin.getLocal().sendMessage(p, "android.scripts.already-uploaded", true);
+ SlimefunPlugin.getLocalization().sendMessage(p, "android.scripts.already-uploaded", true);
return;
}
}
p.closeInventory();
- SlimefunPlugin.getLocal().sendMessages(p, "android.scripts.enter-name");
+ SlimefunPlugin.getLocalization().sendMessages(p, "android.scripts.enter-name");
int id = nextId;
- ChatInput.waitForPlayer(SlimefunPlugin.instance, p, msg -> {
+ ChatInput.waitForPlayer(SlimefunPlugin.instance(), p, msg -> {
Script.upload(p, getAndroidType(), id, msg, code);
- SlimefunPlugin.getLocal().sendMessages(p, "android.scripts.uploaded");
+ SlimefunPlugin.getLocalization().sendMessages(p, "android.scripts.uploaded");
openScriptDownloader(p, b, page);
});
}
public void openScriptEditor(Player p, Block b) {
- ChestMenu menu = new ChestMenu(ChatColor.DARK_AQUA + SlimefunPlugin.getLocal().getMessage(p, "android.scripts.editor"));
+ ChestMenu menu = new ChestMenu(ChatColor.DARK_AQUA + SlimefunPlugin.getLocalization().getMessage(p, "android.scripts.editor"));
menu.addItem(1, new CustomItem(SlimefunUtils.getCustomHead("d9bf6db4aeda9d8822b9f736538e8c18b9a4844f84eb45504adfbfee87eb"), "&2> Edit Script", "", "&aEdits your current Script"));
menu.addMenuClickHandler(1, (pl, slot, item, action) -> {
@@ -509,13 +494,8 @@ public abstract class ProgrammableAndroid extends SlimefunItem implements Invent
return list;
}
- protected String getScriptRatingPercentage(Script script) {
- float percentage = script.getRating();
- return NumberUtils.getColorFromPercentage(percentage) + String.valueOf(percentage) + ChatColor.RESET + "% ";
- }
-
protected void editInstruction(Player p, Block b, String[] script, int index) {
- ChestMenu menu = new ChestMenu(ChatColor.DARK_AQUA + SlimefunPlugin.getLocal().getMessage(p, "android.scripts.editor"));
+ ChestMenu menu = new ChestMenu(ChatColor.DARK_AQUA + SlimefunPlugin.getLocalization().getMessage(p, "android.scripts.editor"));
ChestMenuUtils.drawBackground(menu, 0, 1, 2, 3, 4, 5, 6, 7, 8);
menu.addItem(9, new CustomItem(SlimefunUtils.getCustomHead("16139fd1c5654e56e9e4e2c8be7eb2bd5b499d633616663feee99b74352ad64"), "&rDo nothing"), (pl, slot, item, action) -> {
@@ -527,7 +507,7 @@ public abstract class ProgrammableAndroid extends SlimefunItem implements Invent
int i = 10;
for (Instruction instruction : getValidScriptInstructions()) {
- menu.addItem(i, new CustomItem(instruction.getItem(), SlimefunPlugin.getLocal().getMessage(p, "android.scripts.instructions." + instruction.name())), (pl, slot, item, action) -> {
+ menu.addItem(i, new CustomItem(instruction.getItem(), SlimefunPlugin.getLocalization().getMessage(p, "android.scripts.instructions." + instruction.name())), (pl, slot, item, action) -> {
String code = addInstruction(script, index, instruction);
setScript(b.getLocation(), code);
openScript(p, b, code);
@@ -627,60 +607,69 @@ public abstract class ProgrammableAndroid extends SlimefunItem implements Invent
public abstract int getTier();
- protected void tick(Block b) {
+ protected void tick(Block b, Config data) {
if (b.getType() != Material.PLAYER_HEAD) {
// The Android was destroyed or moved.
return;
}
- if ("false".equals(BlockStorage.getLocationInfo(b.getLocation(), "paused"))) {
+ if ("false".equals(data.getString("paused"))) {
BlockMenu menu = BlockStorage.getInventory(b);
- float fuel = Float.parseFloat(BlockStorage.getLocationInfo(b.getLocation(), "fuel"));
+ String fuelData = data.getString("fuel");
+ float fuel = fuelData == null ? 0 : Float.parseFloat(fuelData);
if (fuel < 0.001) {
consumeFuel(b, menu);
}
else {
- String[] script = PatternUtils.DASH.split(BlockStorage.getLocationInfo(b.getLocation(), "script"));
+ String code = data.getString("script");
+ String[] script = PatternUtils.DASH.split(code == null ? DEFAULT_SCRIPT : code);
+
+ String indexData = data.getString("index");
+ int index = (indexData == null ? 0 : Integer.parseInt(indexData)) + 1;
- int index = Integer.parseInt(BlockStorage.getLocationInfo(b.getLocation(), "index")) + 1;
if (index >= script.length) {
index = 0;
}
- boolean refresh = true;
BlockStorage.addBlockInfo(b, "fuel", String.valueOf(fuel - 1));
Instruction instruction = Instruction.valueOf(script[index]);
-
- if (getAndroidType().isType(instruction.getRequiredType())) {
- BlockFace face = BlockFace.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "rotation"));
-
- switch (instruction) {
- case START:
- case WAIT:
- // Just "waiting" here which means we do nothing
- break;
- case REPEAT:
- BlockStorage.addBlockInfo(b, "index", String.valueOf(0));
- break;
- case CHOP_TREE:
- refresh = chopTree(b, menu, face);
- break;
- default:
- instruction.execute(this, b, menu, face);
- break;
- }
- }
-
- if (refresh) {
- BlockStorage.addBlockInfo(b, "index", String.valueOf(index));
- }
+ executeInstruction(instruction, b, menu, data, index);
}
}
}
- protected void rotate(Block b, int mod) {
- BlockFace current = BlockFace.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "rotation"));
+ private void executeInstruction(Instruction instruction, Block b, BlockMenu inv, Config data, int index) {
+ if (getAndroidType().isType(instruction.getRequiredType())) {
+ String rotationData = data.getString("rotation");
+ BlockFace face = rotationData == null ? BlockFace.NORTH : BlockFace.valueOf(rotationData);
+
+ switch (instruction) {
+ case START:
+ case WAIT:
+ // We are "waiting" here, so we only move a step forward
+ BlockStorage.addBlockInfo(b, "index", String.valueOf(index));
+ break;
+ case REPEAT:
+ // "repeat" just means, we reset our index
+ BlockStorage.addBlockInfo(b, "index", String.valueOf(0));
+ break;
+ case CHOP_TREE:
+ // We only move to the next step if we finished chopping wood
+ if (chopTree(b, inv, face)) {
+ BlockStorage.addBlockInfo(b, "index", String.valueOf(index));
+ }
+ break;
+ default:
+ // We set the index here in advance to fix moving android issues
+ BlockStorage.addBlockInfo(b, "index", String.valueOf(index));
+ instruction.execute(this, b, inv, face);
+ break;
+ }
+ }
+ }
+
+ protected void rotate(Block b, BlockFace current, int mod) {
int index = POSSIBLE_ROTATIONS.indexOf(current) + mod;
if (index == POSSIBLE_ROTATIONS.size()) {
@@ -693,7 +682,7 @@ public abstract class ProgrammableAndroid extends SlimefunItem implements Invent
BlockFace rotation = POSSIBLE_ROTATIONS.get(index);
Rotatable rotatatable = (Rotatable) b.getBlockData();
- rotatatable.setRotation(rotation);
+ rotatatable.setRotation(rotation.getOppositeFace());
b.setBlockData(rotatatable);
BlockStorage.addBlockInfo(b, "rotation", rotation.name());
}
@@ -739,7 +728,7 @@ public abstract class ProgrammableAndroid extends SlimefunItem implements Invent
dispenser.setItem(slot, null);
return true;
}
- else if (SlimefunUtils.isItemSimilar(newFuel, currentFuel, true)) {
+ else if (SlimefunUtils.isItemSimilar(newFuel, currentFuel, true, false)) {
int rest = newFuel.getType().getMaxStackSize() - currentFuel.getAmount();
if (rest > 0) {
@@ -766,7 +755,8 @@ public abstract class ProgrammableAndroid extends SlimefunItem implements Invent
menu.pushItem(new ItemStack(Material.BUCKET), getOutputSlots());
}
- BlockStorage.addBlockInfo(b, "fuel", String.valueOf((int) (fuel.getTicks() * this.getFuelEfficiency())));
+ int fuelLevel = (int) (fuel.getTicks() * getFuelEfficiency());
+ BlockStorage.addBlockInfo(b, "fuel", String.valueOf(fuelLevel));
break;
}
}
@@ -809,19 +799,22 @@ public abstract class ProgrammableAndroid extends SlimefunItem implements Invent
protected void move(Block b, BlockFace face, Block block) {
if (block.getY() > 0 && block.getY() < block.getWorld().getMaxHeight() && (block.getType() == Material.AIR || block.getType() == Material.CAVE_AIR)) {
- block.setType(Material.PLAYER_HEAD);
- Rotatable blockData = (Rotatable) block.getBlockData();
- blockData.setRotation(face.getOppositeFace());
- block.setBlockData(blockData);
+ BlockData blockData = Material.PLAYER_HEAD.createBlockData(data -> {
+ if (data instanceof Rotatable) {
+ Rotatable rotatable = ((Rotatable) data);
+ rotatable.setRotation(face.getOppositeFace());
+ }
+ });
- SkullBlock.setFromBase64(block, texture);
+ block.setBlockData(blockData);
+ Slimefun.runSync(() -> SkullBlock.setFromBase64(block, texture));
b.setType(Material.AIR);
BlockStorage.moveBlockInfo(b.getLocation(), block.getLocation());
}
}
- protected void attack(Block b, Predicate predicate) {
+ protected void attack(Block b, BlockFace face, Predicate predicate) {
throw new UnsupportedOperationException("Non-butcher Android tried to butcher!");
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Script.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Script.java
index 9aac880dc..783cff824 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Script.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Script.java
@@ -11,11 +11,15 @@ import java.util.logging.Level;
import org.apache.commons.lang.Validate;
import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
+import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.cscorelib2.config.Config;
+import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
import io.github.thebusybiscuit.slimefun4.utils.ChatUtils;
+import io.github.thebusybiscuit.slimefun4.utils.NumberUtils;
import me.mrCookieSlime.Slimefun.api.Slimefun;
public final class Script {
@@ -105,6 +109,30 @@ public final class Script {
return !upvoters.contains(p.getUniqueId().toString()) && !downvoters.contains(p.getUniqueId().toString());
}
+ ItemStack getAsItemStack(ProgrammableAndroid android, Player p) {
+ List lore = new LinkedList<>();
+ lore.add("&7by &r" + getAuthor());
+ lore.add("");
+ lore.add("&7Downloads: &r" + getDownloads());
+ lore.add("&7Rating: " + getScriptRatingPercentage());
+ lore.add("&a" + getUpvotes() + " \u263A &7| &4\u2639 " + getDownvotes());
+ lore.add("");
+ lore.add("&eLeft Click &rto download this Script");
+ lore.add("&4(This will override your current Script)");
+
+ if (canRate(p)) {
+ lore.add("&eShift + Left Click &rto leave a positive Rating");
+ lore.add("&eShift + Right Click &rto leave a negative Rating");
+ }
+
+ return new CustomItem(android.getItem(), "&b" + getName(), lore.toArray(new String[0]));
+ }
+
+ private String getScriptRatingPercentage() {
+ float percentage = getRating();
+ return NumberUtils.getColorFromPercentage(percentage) + String.valueOf(percentage) + ChatColor.RESET + "% ";
+ }
+
/**
* This method returns the amount of upvotes this {@link Script} has received.
*
@@ -195,7 +223,7 @@ public final class Script {
}
}
catch (Exception x) {
- Slimefun.getLogger().log(Level.SEVERE, x, () -> "An Exception occured while trying to load Android Script '" + file.getName() + "'");
+ Slimefun.getLogger().log(Level.SEVERE, x, () -> "An Exception occurred while trying to load Android Script '" + file.getName() + "'");
}
}
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/WoodcutterAndroid.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/WoodcutterAndroid.java
index 780c9ae02..60c85e59e 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/WoodcutterAndroid.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/WoodcutterAndroid.java
@@ -7,15 +7,16 @@ import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Effect;
import org.bukkit.Material;
+import org.bukkit.OfflinePlayer;
+import org.bukkit.Tag;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.cscorelib2.blocks.Vein;
-import io.github.thebusybiscuit.cscorelib2.materials.MaterialCollections;
import io.github.thebusybiscuit.cscorelib2.materials.MaterialConverter;
import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction;
-import me.mrCookieSlime.Slimefun.SlimefunPlugin;
+import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.api.BlockStorage;
@@ -24,6 +25,8 @@ import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
public abstract class WoodcutterAndroid extends ProgrammableAndroid {
+ private static final int MAX_REACH = 160;
+
public WoodcutterAndroid(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, recipeType, recipe);
}
@@ -35,14 +38,17 @@ public abstract class WoodcutterAndroid extends ProgrammableAndroid {
@Override
protected boolean chopTree(Block b, BlockMenu menu, BlockFace face) {
- if (MaterialCollections.getAllLogs().contains(b.getRelative(face).getType())) {
- List list = Vein.find(b.getRelative(face), 180, block -> MaterialCollections.getAllLogs().contains(block.getType()));
+ Block target = b.getRelative(face);
+
+ if (Tag.LOGS.isTagged(target.getType())) {
+ List list = Vein.find(target, MAX_REACH, block -> Tag.LOGS.isTagged(block.getType()));
if (!list.isEmpty()) {
Block log = list.get(list.size() - 1);
log.getWorld().playEffect(log.getLocation(), Effect.STEP_SOUND, log.getType());
- if (SlimefunPlugin.getProtectionManager().hasPermission(Bukkit.getOfflinePlayer(UUID.fromString(BlockStorage.getLocationInfo(b.getLocation(), "owner"))), log.getLocation(), ProtectableAction.BREAK_BLOCK)) {
+ OfflinePlayer owner = Bukkit.getOfflinePlayer(UUID.fromString(BlockStorage.getLocationInfo(b.getLocation(), "owner")));
+ if (SlimefunPlugin.getProtectionManager().hasPermission(owner, log.getLocation(), ProtectableAction.BREAK_BLOCK)) {
breakLog(log, b, menu, face);
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/HazmatArmorPiece.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/HazmatArmorPiece.java
new file mode 100644
index 000000000..f50860c3b
--- /dev/null
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/HazmatArmorPiece.java
@@ -0,0 +1,50 @@
+package io.github.thebusybiscuit.slimefun4.implementation.items.armor;
+
+import org.bukkit.NamespacedKey;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.potion.PotionEffect;
+
+import io.github.thebusybiscuit.slimefun4.core.attributes.ProtectiveArmor;
+import io.github.thebusybiscuit.slimefun4.core.attributes.ProtectionType;
+import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
+import me.mrCookieSlime.Slimefun.Lists.RecipeType;
+import me.mrCookieSlime.Slimefun.Objects.Category;
+import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
+
+/**
+ * Represents 1 {@link SlimefunArmorPiece} of the Hazmat armor set.
+ * One of the very few utilisations of {@link ProtectiveArmor}.
+ *
+ * @author Linox
+ *
+ * @see SlimefunArmorPiece
+ * @see ProtectiveArmor
+ *
+ */
+public class HazmatArmorPiece extends SlimefunArmorPiece implements ProtectiveArmor {
+
+ private final NamespacedKey namespacedKey;
+ private final ProtectionType[] types;
+
+ public HazmatArmorPiece(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, PotionEffect[] effects) {
+ super(category, item, recipeType, recipe, effects);
+
+ types = new ProtectionType[] { ProtectionType.BEES, ProtectionType.RADIATION };
+ namespacedKey = new NamespacedKey(SlimefunPlugin.instance(), "hazmat_suit");
+ }
+
+ @Override
+ public ProtectionType[] getProtectionTypes() {
+ return types;
+ }
+
+ @Override
+ public boolean isFullSetRequired() {
+ return true;
+ }
+
+ @Override
+ public NamespacedKey getArmorSetId() {
+ return namespacedKey;
+ }
+}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/SlimefunArmorPiece.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/SlimefunArmorPiece.java
index 925934c64..47473bab7 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/SlimefunArmorPiece.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/SlimefunArmorPiece.java
@@ -28,5 +28,4 @@ public class SlimefunArmorPiece extends SlimefunItem {
public PotionEffect[] getPotionEffects() {
return effects;
}
-
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/backpacks/EnderBackpack.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/backpacks/EnderBackpack.java
index ec7454918..14f7b30fe 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/backpacks/EnderBackpack.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/backpacks/EnderBackpack.java
@@ -5,10 +5,10 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable;
+import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler;
+import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
-import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
-import me.mrCookieSlime.Slimefun.Objects.handlers.ItemUseHandler;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
public class EnderBackpack extends SimpleSlimefunItem implements NotPlaceable {
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/backpacks/SlimefunBackpack.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/backpacks/SlimefunBackpack.java
index 84989af45..5d7af79f1 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/backpacks/SlimefunBackpack.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/backpacks/SlimefunBackpack.java
@@ -5,13 +5,13 @@ import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.slimefun4.api.player.PlayerBackpack;
+import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler;
+import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
+import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.BackpackListener;
-import me.mrCookieSlime.Slimefun.SlimefunPlugin;
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.ItemUseHandler;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
/**
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/BlockPlacer.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/BlockPlacer.java
index 2b8c95a48..7a0c7ee02 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/BlockPlacer.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/BlockPlacer.java
@@ -19,12 +19,12 @@ import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
import io.github.thebusybiscuit.cscorelib2.materials.MaterialCollections;
import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting;
import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable;
-import me.mrCookieSlime.Slimefun.SlimefunPlugin;
+import io.github.thebusybiscuit.slimefun4.core.handlers.BlockDispenseHandler;
+import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
+import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
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.BlockDispenseHandler;
import me.mrCookieSlime.Slimefun.api.BlockStorage;
import me.mrCookieSlime.Slimefun.api.Slimefun;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/Composter.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/Composter.java
index 096d69b52..11e1fd462 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/Composter.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/Composter.java
@@ -20,12 +20,12 @@ import io.github.thebusybiscuit.cscorelib2.materials.MaterialCollections;
import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction;
import io.github.thebusybiscuit.cscorelib2.scheduling.TaskQueue;
import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem;
+import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler;
+import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
+import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
-import me.mrCookieSlime.Slimefun.SlimefunPlugin;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
-import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
-import me.mrCookieSlime.Slimefun.Objects.handlers.BlockUseHandler;
import me.mrCookieSlime.Slimefun.api.BlockStorage;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
@@ -98,10 +98,10 @@ public class Composter extends SimpleSlimefunItem implements Re
pushItem(b, output.clone());
});
- tasks.execute(SlimefunPlugin.instance);
+ tasks.execute(SlimefunPlugin.instance());
}
else {
- SlimefunPlugin.getLocal().sendMessage(p, "machines.wrong-item", true);
+ SlimefunPlugin.getLocalization().sendMessage(p, "machines.wrong-item", true);
}
}
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/Crucible.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/Crucible.java
index 2e6de5d10..b87d1cfe6 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/Crucible.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/Crucible.java
@@ -17,12 +17,12 @@ import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.cscorelib2.materials.MaterialCollections;
import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction;
import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem;
+import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler;
+import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
+import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
-import me.mrCookieSlime.Slimefun.SlimefunPlugin;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
-import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
-import me.mrCookieSlime.Slimefun.Objects.handlers.BlockUseHandler;
import me.mrCookieSlime.Slimefun.api.BlockStorage;
import me.mrCookieSlime.Slimefun.api.Slimefun;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
@@ -93,7 +93,7 @@ public class Crucible extends SimpleSlimefunItem implements Rec
generateLiquid(block, water);
}
else {
- SlimefunPlugin.getLocal().sendMessage(p, "machines.wrong-item", true);
+ SlimefunPlugin.getLocalization().sendMessage(p, "machines.wrong-item", true);
}
}
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/EnhancedFurnace.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/EnhancedFurnace.java
index 3f7432f69..a57ea975c 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/EnhancedFurnace.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/EnhancedFurnace.java
@@ -7,10 +7,10 @@ import org.bukkit.block.Block;
import org.bukkit.block.Furnace;
import org.bukkit.inventory.ItemStack;
+import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
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.BlockTicker;
import me.mrCookieSlime.Slimefun.api.BlockStorage;
@@ -30,14 +30,14 @@ public class EnhancedFurnace extends SimpleSlimefunItem {
private final int speed;
private final int efficiency;
- private final int fortune;
+ private final int fortuneLevel;
public EnhancedFurnace(Category category, int speed, int efficiency, int fortune, SlimefunItemStack item, ItemStack[] recipe) {
super(category, item, RecipeType.ENHANCED_CRAFTING_TABLE, recipe);
this.speed = speed - 1;
this.efficiency = efficiency - 1;
- this.fortune = fortune - 1;
+ this.fortuneLevel = fortune - 1;
}
public int getSpeed() {
@@ -49,11 +49,8 @@ public class EnhancedFurnace extends SimpleSlimefunItem {
}
public int getOutput() {
- int bonus = this.fortune;
- bonus = ThreadLocalRandom.current().nextInt(bonus + 2) - 1;
- if (bonus <= 0) bonus = 0;
- bonus++;
- return bonus;
+ int bonus = ThreadLocalRandom.current().nextInt(fortuneLevel + 2);
+ return 1 + bonus;
}
@Override
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/HologramProjector.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/HologramProjector.java
index 08dadfda9..c030eee2d 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/HologramProjector.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/HologramProjector.java
@@ -11,17 +11,17 @@ import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.cscorelib2.chat.ChatColors;
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
import io.github.thebusybiscuit.cscorelib2.math.DoubleHandler;
+import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler;
+import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
+import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
import io.github.thebusybiscuit.slimefun4.utils.ChatUtils;
import io.github.thebusybiscuit.slimefun4.utils.holograms.SimpleHologram;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
-import me.mrCookieSlime.Slimefun.SlimefunPlugin;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.Objects.SlimefunBlockHandler;
-import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.UnregisterReason;
-import me.mrCookieSlime.Slimefun.Objects.handlers.BlockUseHandler;
import me.mrCookieSlime.Slimefun.api.BlockStorage;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
@@ -64,12 +64,12 @@ public class HologramProjector extends SimpleSlimefunItem {
}
private static void openEditor(Player p, Block projector) {
- ChestMenu menu = new ChestMenu(SlimefunPlugin.getLocal().getMessage(p, "machines.HOLOGRAM_PROJECTOR.inventory-title"));
+ ChestMenu menu = new ChestMenu(SlimefunPlugin.getLocalization().getMessage(p, "machines.HOLOGRAM_PROJECTOR.inventory-title"));
menu.addItem(0, new CustomItem(Material.NAME_TAG, "&7Text &e(Click to edit)", "", "&r" + ChatColors.color(BlockStorage.getLocationInfo(projector.getLocation(), "text"))));
menu.addMenuClickHandler(0, (pl, slot, item, action) -> {
pl.closeInventory();
- SlimefunPlugin.getLocal().sendMessage(pl, "machines.HOLOGRAM_PROJECTOR.enter-text", true);
+ SlimefunPlugin.getLocalization().sendMessage(pl, "machines.HOLOGRAM_PROJECTOR.enter-text", true);
ChatUtils.awaitInput(pl, message -> {
ArmorStand hologram = getArmorStand(projector, true);
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/InfusedHopper.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/InfusedHopper.java
index 15ba809cd..8e98ce420 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/InfusedHopper.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/InfusedHopper.java
@@ -10,11 +10,11 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting;
+import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
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.BlockTicker;
import me.mrCookieSlime.Slimefun.api.BlockStorage;
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/RainbowBlock.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/RainbowBlock.java
index c4f87726d..6f9c13dfc 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/RainbowBlock.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/RainbowBlock.java
@@ -2,24 +2,24 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.blocks;
import org.bukkit.inventory.ItemStack;
+import io.github.thebusybiscuit.slimefun4.core.handlers.RainbowTickHandler;
+import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
-import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
-import me.mrCookieSlime.Slimefun.Objects.handlers.RainbowTicker;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
-public class RainbowBlock extends SimpleSlimefunItem {
+public class RainbowBlock extends SimpleSlimefunItem {
- private final RainbowTicker ticker;
+ private final RainbowTickHandler ticker;
- public RainbowBlock(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput, RainbowTicker ticker) {
+ public RainbowBlock(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput, RainbowTickHandler ticker) {
super(category, item, recipeType, recipe, recipeOutput);
this.ticker = ticker;
}
@Override
- public RainbowTicker getItemHandler() {
+ public RainbowTickHandler getItemHandler() {
return ticker;
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/RepairedSpawner.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/RepairedSpawner.java
index 3af6687a6..6155cbd97 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/RepairedSpawner.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/RepairedSpawner.java
@@ -8,12 +8,12 @@ import org.bukkit.block.CreatureSpawner;
import org.bukkit.entity.EntityType;
import org.bukkit.inventory.ItemStack;
+import io.github.thebusybiscuit.slimefun4.core.handlers.BlockPlaceHandler;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
+import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
-import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
-import me.mrCookieSlime.Slimefun.Objects.handlers.BlockPlaceHandler;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
public class RepairedSpawner extends SimpleSlimefunItem {
@@ -24,7 +24,7 @@ public class RepairedSpawner extends SimpleSlimefunItem {
@Override
public BlockPlaceHandler getItemHandler() {
- return (e, item) -> {
+ return (p, e, item) -> {
// We need to explicitly ignore the lore here
if (SlimefunUtils.isItemSimilar(item, SlimefunItems.REPAIRED_SPAWNER, false, false)) {
Optional entity = getEntityType(item);
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/UnplaceableBlock.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/UnplaceableBlock.java
index 1d1b02824..5697103a3 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/UnplaceableBlock.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/UnplaceableBlock.java
@@ -4,10 +4,10 @@ import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent;
import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable;
+import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler;
+import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
-import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
-import me.mrCookieSlime.Slimefun.Objects.handlers.ItemUseHandler;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
public class UnplaceableBlock extends SimpleSlimefunItem implements NotPlaceable {
@@ -16,6 +16,10 @@ public class UnplaceableBlock extends SimpleSlimefunItem impleme
super(category, item, recipeType, recipe);
}
+ public UnplaceableBlock(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput) {
+ super(category, item, recipeType, recipe, recipeOutput);
+ }
+
@Override
public ItemUseHandler getItemHandler() {
return PlayerRightClickEvent::cancel;
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AbstractCargoNode.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AbstractCargoNode.java
index c1f66c733..79f38daa7 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AbstractCargoNode.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AbstractCargoNode.java
@@ -5,8 +5,8 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction;
+import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import io.github.thebusybiscuit.slimefun4.utils.ChatUtils;
-import me.mrCookieSlime.Slimefun.SlimefunPlugin;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AdvancedCargoOutputNode.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AdvancedCargoOutputNode.java
index fce306a53..49694f7fe 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AdvancedCargoOutputNode.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AdvancedCargoOutputNode.java
@@ -9,9 +9,9 @@ import org.bukkit.inventory.meta.ItemMeta;
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
import io.github.thebusybiscuit.cscorelib2.materials.MaterialCollections;
+import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
-import me.mrCookieSlime.Slimefun.SlimefunPlugin;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.Objects.SlimefunBlockHandler;
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoConnectorNode.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoConnectorNode.java
index 42c8d347a..13f46f541 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoConnectorNode.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoConnectorNode.java
@@ -5,11 +5,11 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.cscorelib2.chat.ChatColors;
+import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler;
import io.github.thebusybiscuit.slimefun4.core.networks.cargo.CargoNet;
+import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
-import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
-import me.mrCookieSlime.Slimefun.Objects.handlers.BlockUseHandler;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
public class CargoConnectorNode extends SimpleSlimefunItem {
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoInputNode.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoInputNode.java
index ae2d310d0..3d576c435 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoInputNode.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoInputNode.java
@@ -9,9 +9,9 @@ import org.bukkit.inventory.meta.ItemMeta;
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
import io.github.thebusybiscuit.cscorelib2.materials.MaterialCollections;
+import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
-import me.mrCookieSlime.Slimefun.SlimefunPlugin;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.Objects.SlimefunBlockHandler;
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoManager.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoManager.java
index 5a318b18b..29ff47e5b 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoManager.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoManager.java
@@ -8,6 +8,7 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent;
+import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler;
import io.github.thebusybiscuit.slimefun4.core.networks.cargo.CargoNet;
import io.github.thebusybiscuit.slimefun4.utils.holograms.SimpleHologram;
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
@@ -15,7 +16,6 @@ import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
import me.mrCookieSlime.Slimefun.Objects.handlers.BlockTicker;
-import me.mrCookieSlime.Slimefun.Objects.handlers.BlockUseHandler;
import me.mrCookieSlime.Slimefun.api.BlockStorage;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoOutputNode.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoOutputNode.java
index b3fe76d0f..668d55141 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoOutputNode.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoOutputNode.java
@@ -7,9 +7,9 @@ import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
import io.github.thebusybiscuit.cscorelib2.materials.MaterialCollections;
+import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
-import me.mrCookieSlime.Slimefun.SlimefunPlugin;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.Objects.SlimefunBlockHandler;
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/ReactorAccessPort.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/ReactorAccessPort.java
index 123b93e74..899b8b937 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/ReactorAccessPort.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/ReactorAccessPort.java
@@ -9,10 +9,10 @@ import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
+import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors.Reactor;
+import io.github.thebusybiscuit.slimefun4.implementation.items.misc.CoolantCell;
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
-import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
-import me.mrCookieSlime.Slimefun.SlimefunPlugin;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
@@ -74,18 +74,27 @@ public class ReactorAccessPort extends SlimefunItem {
@Override
public int[] getSlotsAccessedByItemTransport(ItemTransportFlow flow) {
- if (flow == ItemTransportFlow.INSERT) return getInputSlots();
- else return getOutputSlots();
+ if (flow == ItemTransportFlow.INSERT) {
+ return getInputSlots();
+ }
+ else {
+ return getOutputSlots();
+ }
}
@Override
public int[] getSlotsAccessedByItemTransport(DirtyChestMenu menu, ItemTransportFlow flow, ItemStack item) {
if (flow == ItemTransportFlow.INSERT) {
- if (SlimefunUtils.isItemSimilar(item, SlimefunItems.REACTOR_COOLANT_CELL, true)) return getCoolantSlots();
- else if (SlimefunUtils.isItemSimilar(item, SlimefunItems.NETHER_ICE_COOLANT_CELL, true)) return getCoolantSlots();
- else return getFuelSlots();
+ if (SlimefunItem.getByItem(item) instanceof CoolantCell) {
+ return getCoolantSlots();
+ }
+ else {
+ return getFuelSlots();
+ }
+ }
+ else {
+ return getOutputSlots();
}
- else return getOutputSlots();
}
};
@@ -157,10 +166,12 @@ public class ReactorAccessPort extends SlimefunItem {
}
private BlockMenu getReactor(Location l) {
- Location reactorL = new Location(l.getWorld(), l.getX(), l.getY() - 3, l.getZ());
+ Location location = new Location(l.getWorld(), l.getX(), l.getY() - 3, l.getZ());
+ SlimefunItem item = BlockStorage.check(location.getBlock());
- SlimefunItem item = BlockStorage.check(reactorL.getBlock());
- if (item instanceof Reactor) return BlockStorage.getInventory(reactorL);
+ if (item instanceof Reactor) {
+ return BlockStorage.getInventory(location);
+ }
return null;
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/JetBoots.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/JetBoots.java
index 8b1a62c48..a28dc115a 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/JetBoots.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/JetBoots.java
@@ -2,23 +2,31 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.electric.gadgets
import org.bukkit.inventory.ItemStack;
+import io.github.thebusybiscuit.slimefun4.core.attributes.Rechargeable;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
-import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.ChargableItem;
+import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
-public class JetBoots extends ChargableItem {
+public class JetBoots extends SlimefunItem implements Rechargeable {
private final double speed;
+ private final float capacity;
- public JetBoots(Category category, SlimefunItemStack item, ItemStack[] recipe, double speed) {
+ public JetBoots(Category category, SlimefunItemStack item, ItemStack[] recipe, double speed, float capacity) {
super(category, item, RecipeType.ENHANCED_CRAFTING_TABLE, recipe);
this.speed = speed;
+ this.capacity = capacity;
}
public double getSpeed() {
return speed;
}
+ @Override
+ public float getMaxItemCharge(ItemStack item) {
+ return capacity;
+ }
+
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/Jetpack.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/Jetpack.java
index 0e59465bf..9131a16c5 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/Jetpack.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/Jetpack.java
@@ -2,23 +2,31 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.electric.gadgets
import org.bukkit.inventory.ItemStack;
+import io.github.thebusybiscuit.slimefun4.core.attributes.Rechargeable;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
-import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.ChargableItem;
+import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
-public class Jetpack extends ChargableItem {
+public class Jetpack extends SlimefunItem implements Rechargeable {
private final double thrust;
+ private final float capacity;
- public Jetpack(Category category, SlimefunItemStack item, ItemStack[] recipe, double thrust) {
+ public Jetpack(Category category, SlimefunItemStack item, ItemStack[] recipe, double thrust, float capacity) {
super(category, item, RecipeType.ENHANCED_CRAFTING_TABLE, recipe);
this.thrust = thrust;
+ this.capacity = capacity;
}
public double getThrust() {
return thrust;
}
+ @Override
+ public float getMaxItemCharge(ItemStack item) {
+ return capacity;
+ }
+
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/MultiTool.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/MultiTool.java
index 33469534e..4f73938a6 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/MultiTool.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/MultiTool.java
@@ -10,29 +10,36 @@ import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
-import me.mrCookieSlime.Slimefun.SlimefunPlugin;
+import io.github.thebusybiscuit.slimefun4.core.attributes.Rechargeable;
+import io.github.thebusybiscuit.slimefun4.core.handlers.BlockBreakHandler;
+import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler;
+import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
-import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.ChargableItem;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
-import me.mrCookieSlime.Slimefun.Objects.handlers.BlockBreakHandler;
-import me.mrCookieSlime.Slimefun.Objects.handlers.ItemUseHandler;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
-import me.mrCookieSlime.Slimefun.api.energy.ItemEnergy;
-public class MultiTool extends ChargableItem {
+public class MultiTool extends SlimefunItem implements Rechargeable {
private static final float COST = 0.3F;
private final Map selectedMode = new HashMap<>();
private final List modes = new ArrayList<>();
+ private final float capacity;
- public MultiTool(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, String... items) {
+ public MultiTool(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, float capacity, String... items) {
super(category, item, recipeType, recipe);
for (int i = 0; i < items.length; i++) {
modes.add(new MultiToolMode(this, i, items[i]));
}
+
+ this.capacity = capacity;
+ }
+
+ @Override
+ public float getMaxItemCharge(ItemStack item) {
+ return capacity;
}
protected ItemUseHandler getItemUseHandler() {
@@ -44,11 +51,7 @@ public class MultiTool extends ChargableItem {
int index = selectedMode.getOrDefault(p.getUniqueId(), 0);
if (!p.isSneaking()) {
- float charge = ItemEnergy.getStoredEnergy(item);
-
- if (charge >= COST) {
- ItemEnergy.chargeItem(item, -COST);
-
+ if (removeItemCharge(item, COST)) {
SlimefunItem sfItem = modes.get(index).getItem();
if (sfItem != null) {
@@ -61,7 +64,7 @@ public class MultiTool extends ChargableItem {
SlimefunItem selectedItem = modes.get(index).getItem();
String itemName = selectedItem != null ? selectedItem.getItemName() : "Unknown";
- SlimefunPlugin.getLocal().sendMessage(p, "messages.mode-change", true, msg -> msg.replace("%device%", "Multi Tool").replace("%mode%", ChatColor.stripColor(itemName)));
+ SlimefunPlugin.getLocalization().sendMessage(p, "messages.mode-change", true, msg -> msg.replace("%device%", "Multi Tool").replace("%mode%", ChatColor.stripColor(itemName)));
selectedMode.put(p.getUniqueId(), index);
}
};
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/Multimeter.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/Multimeter.java
index 0c1df7c5f..8cbd760a1 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/Multimeter.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/Multimeter.java
@@ -7,11 +7,11 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.cscorelib2.math.DoubleHandler;
-import me.mrCookieSlime.Slimefun.SlimefunPlugin;
+import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler;
+import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
+import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
-import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
-import me.mrCookieSlime.Slimefun.Objects.handlers.ItemUseHandler;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
import me.mrCookieSlime.Slimefun.api.energy.ChargableBlock;
@@ -37,7 +37,7 @@ public class Multimeter extends SimpleSlimefunItem {
Player p = e.getPlayer();
p.sendMessage("");
- SlimefunPlugin.getLocal().sendMessage(p, "messages.multimeter", false, str -> str.replace("%stored%", stored).replace("%capacity%", capacity));
+ SlimefunPlugin.getLocalization().sendMessage(p, "messages.multimeter", false, str -> str.replace("%stored%", stored).replace("%capacity%", capacity));
p.sendMessage("");
}
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/SolarHelmet.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/SolarHelmet.java
index 953d9013c..fb19075ca 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/SolarHelmet.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/SolarHelmet.java
@@ -1,25 +1,65 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.electric.gadgets;
+import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting;
+import io.github.thebusybiscuit.slimefun4.core.attributes.Rechargeable;
+import io.github.thebusybiscuit.slimefun4.implementation.tasks.ArmorTask;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
+/**
+ * The {@link SolarHelmet} can be worn by {@link Player}.
+ * As long as that {@link Player} has contact with sunlight, the helmet will charge any
+ * {@link Rechargeable} {@link SlimefunItem} that this {@link Player} is currently wearing
+ * or holding.
+ *
+ * @author TheBusyBiscuit
+ *
+ * @see ArmorTask
+ * @see Rechargeable
+ *
+ */
public class SolarHelmet extends SlimefunItem {
- private final ItemSetting chargeSetting = new ItemSetting<>("charge-amount", 0.1);
+ private final ItemSetting charge;
- public SolarHelmet(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
- super(category, item, recipeType, recipe, null);
+ public SolarHelmet(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, double defaultChargingLevel) {
+ super(category, item, recipeType, recipe);
- addItemSetting(chargeSetting);
+ if (defaultChargingLevel <= 0) {
+ throw new IllegalArgumentException("A Solar Helmet must have a positive charging level!");
+ }
+
+ charge = new ItemSetting<>("charge-amount", defaultChargingLevel);
+ addItemSetting(charge);
}
- public double getChargeAmount() {
- return chargeSetting.getValue();
+ /**
+ * This method recharges the equipment of the given {@link Player} by the configured
+ * factor of this {@link SolarHelmet}.
+ *
+ * @param p
+ * The {@link Player} wearing this {@link SolarHelmet}
+ */
+ public void rechargeItems(Player p) {
+ recharge(p.getInventory().getHelmet());
+ recharge(p.getInventory().getChestplate());
+ recharge(p.getInventory().getLeggings());
+ recharge(p.getInventory().getBoots());
+ recharge(p.getInventory().getItemInMainHand());
+ recharge(p.getInventory().getItemInOffHand());
+ }
+
+ private void recharge(ItemStack item) {
+ SlimefunItem sfItem = SlimefunItem.getByItem(item);
+
+ if (sfItem instanceof Rechargeable) {
+ ((Rechargeable) sfItem).addItemCharge(item, charge.getValue().floatValue());
+ }
}
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/BioGenerator.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/BioGenerator.java
index 74760383d..563a3fd71 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/BioGenerator.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/BioGenerator.java
@@ -5,7 +5,7 @@ import org.bukkit.Tag;
import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion;
-import me.mrCookieSlime.Slimefun.SlimefunPlugin;
+import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AGenerator;
@@ -58,6 +58,17 @@ public abstract class BioGenerator extends AGenerator {
}
}
+ if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_15)) {
+ registerFuel(new MachineFuel(4, new ItemStack(Material.HONEYCOMB)));
+ registerFuel(new MachineFuel(40, new ItemStack(Material.HONEYCOMB_BLOCK)));
+ }
+
+ if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_16)) {
+ registerFuel(new MachineFuel(4, new ItemStack(Material.SHROOMLIGHT)));
+ registerFuel(new MachineFuel(2, new ItemStack(Material.CRIMSON_FUNGUS)));
+ registerFuel(new MachineFuel(2, new ItemStack(Material.WARPED_FUNGUS)));
+ }
+
// Leaves
for (Material m : Tag.LEAVES.getValues()) {
registerFuel(new MachineFuel(1, new ItemStack(m)));
@@ -67,6 +78,15 @@ public abstract class BioGenerator extends AGenerator {
for (Material m : Tag.SAPLINGS.getValues()) {
registerFuel(new MachineFuel(1, new ItemStack(m)));
}
+
+ // Corals
+ for (Material m : Tag.CORALS.getValues()) {
+ registerFuel(new MachineFuel(2, new ItemStack(m)));
+ }
+
+ for (Material m : Tag.CORAL_BLOCKS.getValues()) {
+ registerFuel(new MachineFuel(2, new ItemStack(m)));
+ }
}
@Override
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 3ebef8a14..512d6e2a3 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
@@ -1,17 +1,19 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.electric.generators;
import org.bukkit.Location;
+import org.bukkit.World;
+import org.bukkit.World.Environment;
import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent;
import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetComponent;
+import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler;
import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNetComponentType;
+import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
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.BlockUseHandler;
import me.mrCookieSlime.Slimefun.Objects.handlers.GeneratorTicker;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
@@ -60,11 +62,24 @@ public abstract class SolarGenerator extends SimpleSlimefunItem
@Override
public double generateEnergy(Location l, SlimefunItem item, Config data) {
- if (!l.getWorld().isChunkLoaded(l.getBlockX() >> 4, l.getBlockZ() >> 4) || l.getBlock().getLightFromSky() != 15) {
- return 0D;
+ World world = l.getWorld();
+
+ if (world.getEnvironment() != Environment.NORMAL) {
+ return 0;
}
- if (l.getWorld().getTime() < 12300 || l.getWorld().getTime() > 23850) {
+ boolean isDaytime = isDaytime(world);
+
+ // Performance optimization for daytime-only solar generators
+ if (!isDaytime && getNightEnergy() < 0.1) {
+ return 0;
+ }
+
+ if (!world.isChunkLoaded(l.getBlockX() >> 4, l.getBlockZ() >> 4) || l.getBlock().getLightFromSky() != 15) {
+ return 0;
+ }
+
+ if (isDaytime) {
return getDayEnergy();
}
@@ -78,6 +93,19 @@ public abstract class SolarGenerator extends SimpleSlimefunItem
};
}
+ /**
+ * This method returns whether a given {@link World} has daytime.
+ * It will also return false if a thunderstorm is active in this world.
+ *
+ * @param world
+ * The {@link World} to check
+ *
+ * @return Whether the given {@link World} has daytime and no active thunderstorm
+ */
+ private boolean isDaytime(World world) {
+ return !world.hasStorm() && !world.isThundering() && (world.getTime() < 12300 || world.getTime() > 23850);
+ }
+
@Override
public void preRegister() {
super.preRegister();
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoAnvil.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoAnvil.java
index 14e2a570e..831583010 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoAnvil.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoAnvil.java
@@ -57,12 +57,12 @@ public abstract class AutoAnvil extends AContainer {
if (timeleft > 0) {
ChestMenuUtils.updateProgressbar(menu, 22, timeleft, processing.get(b).getTicks(), getProgressBar());
- if (ChargableBlock.isChargable(b)) {
- if (ChargableBlock.getCharge(b) < getEnergyConsumption()) return;
- ChargableBlock.addCharge(b, -getEnergyConsumption());
- progress.put(b, timeleft - 1);
+ if (ChargableBlock.getCharge(b) < getEnergyConsumption()) {
+ return;
}
- else progress.put(b, timeleft - 1);
+
+ ChargableBlock.addCharge(b, -getEnergyConsumption());
+ progress.put(b, timeleft - 1);
}
else {
menu.replaceExistingItem(22, new CustomItem(new ItemStack(Material.BLACK_STAINED_GLASS_PANE), " "));
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoBrewer.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoBrewer.java
index d7e43cce9..85cb3d60e 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoBrewer.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoBrewer.java
@@ -29,7 +29,7 @@ import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
* @author Linox
*
*/
-public class AutoBrewer extends AContainer {
+public abstract class AutoBrewer extends AContainer {
private static final Map potionRecipes = new EnumMap<>(Material.class);
private static final Map fermentations = new EnumMap<>(PotionType.class);
@@ -68,17 +68,12 @@ public class AutoBrewer extends AContainer {
if (timeleft > 0) {
ChestMenuUtils.updateProgressbar(menu, 22, timeleft, processing.get(b).getTicks(), getProgressBar());
- if (ChargableBlock.isChargable(b)) {
- if (ChargableBlock.getCharge(b) < getEnergyConsumption()) {
- return;
- }
+ if (ChargableBlock.getCharge(b) < getEnergyConsumption()) {
+ return;
+ }
- ChargableBlock.addCharge(b, -getEnergyConsumption());
- progress.put(b, timeleft - 1);
- }
- else {
- progress.put(b, timeleft - 1);
- }
+ ChargableBlock.addCharge(b, -getEnergyConsumption());
+ progress.put(b, timeleft - 1);
}
else {
menu.replaceExistingItem(22, new CustomItem(new ItemStack(Material.BLACK_STAINED_GLASS_PANE), " "));
@@ -119,18 +114,16 @@ public class AutoBrewer extends AContainer {
if (isPotion(input1.getType()) || isPotion(input2.getType())) {
boolean slot = isPotion(input1.getType());
- ItemStack potionItem = slot ? input1 : input2;
ItemStack ingredient = slot ? input2 : input1;
- PotionMeta potion = (PotionMeta) potionItem.getItemMeta();
-
// Reject any named items
if (ingredient.hasItemMeta()) {
return null;
}
- PotionData potionData = potion.getBasePotionData();
- ItemStack output = brew(ingredient.getType(), potionItem.getType(), potion, potionData);
+ ItemStack potionItem = slot ? input1 : input2;
+ PotionMeta potion = (PotionMeta) potionItem.getItemMeta();
+ ItemStack output = brew(ingredient.getType(), potionItem.getType(), potion);
if (output == null) {
return null;
@@ -144,8 +137,10 @@ public class AutoBrewer extends AContainer {
}
}
- private ItemStack brew(Material input, Material potionType, PotionMeta potion, PotionData potionData) {
- if (potionData.getType() == PotionType.WATER) {
+ private ItemStack brew(Material input, Material potionType, PotionMeta potion) {
+ PotionData data = potion.getBasePotionData();
+
+ if (data.getType() == PotionType.WATER) {
if (input == Material.FERMENTED_SPIDER_EYE) {
potion.setBasePotionData(new PotionData(PotionType.WEAKNESS, false, false));
return new ItemStack(potionType);
@@ -166,18 +161,18 @@ public class AutoBrewer extends AContainer {
}
else if (input == Material.FERMENTED_SPIDER_EYE) {
- potion.setBasePotionData(new PotionData(fermentations.get(potionData.getType()), false, false));
+ potion.setBasePotionData(new PotionData(fermentations.get(data.getType()), false, false));
return new ItemStack(potionType);
}
else if (input == Material.REDSTONE) {
- potion.setBasePotionData(new PotionData(potionData.getType(), true, potionData.isUpgraded()));
+ potion.setBasePotionData(new PotionData(data.getType(), true, data.isUpgraded()));
return new ItemStack(potionType);
}
else if (input == Material.GLOWSTONE_DUST) {
- potion.setBasePotionData(new PotionData(potionData.getType(), potionData.isExtended(), true));
+ potion.setBasePotionData(new PotionData(data.getType(), data.isExtended(), true));
return new ItemStack(potionType);
}
- else if (potionData.getType() == PotionType.AWKWARD && potionRecipes.containsKey(input)) {
+ else if (data.getType() == PotionType.AWKWARD && potionRecipes.containsKey(input)) {
potion.setBasePotionData(new PotionData(potionRecipes.get(input), false, false));
return new ItemStack(potionType);
}
@@ -213,11 +208,6 @@ public class AutoBrewer extends AContainer {
return 6;
}
- @Override
- public int getSpeed() {
- return 1;
- }
-
@Override
public String getMachineIdentifier() {
return "AUTO_BREWER";
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoDisenchanter.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoDisenchanter.java
index 782a8f760..ff9b03605 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoDisenchanter.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoDisenchanter.java
@@ -17,10 +17,10 @@ import org.bukkit.inventory.meta.Repairable;
import io.github.thebusybiscuit.cscorelib2.inventory.InvUtils;
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
import io.github.thebusybiscuit.slimefun4.api.events.AutoDisenchantEvent;
+import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
import me.mrCookieSlime.EmeraldEnchants.EmeraldEnchants;
import me.mrCookieSlime.EmeraldEnchants.ItemEnchantment;
-import me.mrCookieSlime.Slimefun.SlimefunPlugin;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
@@ -78,15 +78,12 @@ public class AutoDisenchanter extends AContainer {
if (timeleft > 0) {
ChestMenuUtils.updateProgressbar(menu, 22, timeleft, processing.get(b).getTicks(), getProgressBar());
- if (ChargableBlock.isChargable(b)) {
- if (ChargableBlock.getCharge(b) < getEnergyConsumption()) {
- return;
- }
-
- ChargableBlock.addCharge(b, -getEnergyConsumption());
- progress.put(b, timeleft - 1);
+ if (ChargableBlock.getCharge(b) < getEnergyConsumption()) {
+ return;
}
- else progress.put(b, timeleft - 1);
+
+ ChargableBlock.addCharge(b, -getEnergyConsumption());
+ progress.put(b, timeleft - 1);
}
else {
menu.replaceExistingItem(22, new CustomItem(Material.BLACK_STAINED_GLASS_PANE, " "));
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoDrier.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoDrier.java
index ffdcb4c6c..c25892873 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoDrier.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoDrier.java
@@ -104,12 +104,12 @@ public class AutoDrier extends AContainer implements RecipeDisplayItem {
if (timeleft > 0) {
ChestMenuUtils.updateProgressbar(menu, 22, timeleft, processing.get(b).getTicks(), getProgressBar());
- if (ChargableBlock.isChargable(b)) {
- if (ChargableBlock.getCharge(b) < getEnergyConsumption()) return;
- ChargableBlock.addCharge(b, -getEnergyConsumption());
- progress.put(b, timeleft - 1);
+ if (ChargableBlock.getCharge(b) < getEnergyConsumption()) {
+ return;
}
- else progress.put(b, timeleft - 1);
+
+ ChargableBlock.addCharge(b, -getEnergyConsumption());
+ progress.put(b, timeleft - 1);
}
else {
menu.replaceExistingItem(22, new CustomItem(new ItemStack(Material.BLACK_STAINED_GLASS_PANE), " "));
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoEnchanter.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoEnchanter.java
index 9a0164f90..afcb3f41f 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoEnchanter.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoEnchanter.java
@@ -13,10 +13,10 @@ import org.bukkit.inventory.meta.EnchantmentStorageMeta;
import io.github.thebusybiscuit.cscorelib2.inventory.InvUtils;
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
+import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
import me.mrCookieSlime.EmeraldEnchants.EmeraldEnchants;
import me.mrCookieSlime.EmeraldEnchants.ItemEnchantment;
-import me.mrCookieSlime.Slimefun.SlimefunPlugin;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
@@ -67,17 +67,12 @@ public class AutoEnchanter extends AContainer {
if (timeleft > 0) {
ChestMenuUtils.updateProgressbar(menu, 22, timeleft, processing.get(b).getTicks(), getProgressBar());
- if (ChargableBlock.isChargable(b)) {
- if (ChargableBlock.getCharge(b) < getEnergyConsumption()) {
- return;
- }
+ if (ChargableBlock.getCharge(b) < getEnergyConsumption()) {
+ return;
+ }
- ChargableBlock.addCharge(b, -getEnergyConsumption());
- progress.put(b, timeleft - 1);
- }
- else {
- progress.put(b, timeleft - 1);
- }
+ ChargableBlock.addCharge(b, -getEnergyConsumption());
+ progress.put(b, timeleft - 1);
}
else {
menu.replaceExistingItem(22, new CustomItem(new ItemStack(Material.BLACK_STAINED_GLASS_PANE), " "));
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutomatedCraftingChamber.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutomatedCraftingChamber.java
index 08cfcc148..43348e0aa 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutomatedCraftingChamber.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutomatedCraftingChamber.java
@@ -15,12 +15,12 @@ import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction;
import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetComponent;
import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNetComponentType;
+import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.AdvancedMenuClickHandler;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItemSerializer;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItemSerializer.ItemFlag;
-import me.mrCookieSlime.Slimefun.SlimefunPlugin;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.Objects.SlimefunBlockHandler;
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ChargingBench.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ChargingBench.java
index f06c0f7e9..59ecfbc9b 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ChargingBench.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ChargingBench.java
@@ -4,13 +4,14 @@ import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.inventory.ItemStack;
+import io.github.thebusybiscuit.slimefun4.core.attributes.Rechargeable;
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.abstractItems.AContainer;
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.ItemEnergy;
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
public class ChargingBench extends AContainer {
@@ -50,38 +51,34 @@ public class ChargingBench extends AContainer {
for (int slot : getInputSlots()) {
ItemStack item = inv.getItemInSlot(slot);
- if (ItemEnergy.getMaxEnergy(item) > 0) {
- charge(b, inv, slot, item);
+ if (charge(b, inv, slot, item)) {
return;
}
}
}
- private void charge(Block b, BlockMenu inv, int slot, ItemStack item) {
- if (ItemEnergy.getStoredEnergy(item) < ItemEnergy.getMaxEnergy(item)) {
- ChargableBlock.addCharge(b, -getEnergyConsumption());
- float rest = ItemEnergy.addStoredEnergy(item, getEnergyConsumption() / 2F);
+ private boolean charge(Block b, BlockMenu inv, int slot, ItemStack item) {
+ SlimefunItem sfItem = SlimefunItem.getByItem(item);
- if (rest > 0F) {
- if (inv.fits(item, getOutputSlots())) {
- inv.pushItem(item, getOutputSlots());
- inv.replaceExistingItem(slot, null);
- }
- else {
- inv.replaceExistingItem(slot, item);
- }
+ if (sfItem instanceof Rechargeable) {
+ float charge = getEnergyConsumption() / 2F;
+
+ if (((Rechargeable) sfItem).addItemCharge(item, charge)) {
+ ChargableBlock.addCharge(b, -getEnergyConsumption());
}
- else {
- inv.replaceExistingItem(slot, item);
+ else if (inv.fits(item, getOutputSlots())) {
+ inv.pushItem(item, getOutputSlots());
+ inv.replaceExistingItem(slot, null);
}
+
+ return true;
}
- else if (inv.fits(item, getOutputSlots())) {
+ else if (sfItem != null && inv.fits(item, getOutputSlots())) {
inv.pushItem(item, getOutputSlots());
inv.replaceExistingItem(slot, null);
}
- else {
- inv.replaceExistingItem(slot, item);
- }
+
+ return false;
}
@Override
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/CropGrowthAccelerator.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/CropGrowthAccelerator.java
index d61483054..dc5bab316 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/CropGrowthAccelerator.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/CropGrowthAccelerator.java
@@ -14,11 +14,11 @@ import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion;
import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetComponent;
import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNetComponentType;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
+import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
import io.github.thebusybiscuit.slimefun4.utils.itemstack.ItemStackWrapper;
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
-import me.mrCookieSlime.Slimefun.SlimefunPlugin;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricDustWasher.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricDustWasher.java
index 94bf70331..4f037164e 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricDustWasher.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricDustWasher.java
@@ -6,10 +6,10 @@ import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
+import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.OreWasher;
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
-import me.mrCookieSlime.Slimefun.SlimefunPlugin;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer;
@@ -59,18 +59,14 @@ public abstract class ElectricDustWasher extends AContainer {
if (timeleft > 0 && getSpeed() < 10) {
ChestMenuUtils.updateProgressbar(menu, 22, timeleft, processing.get(b).getTicks(), getProgressBar());
- if (ChargableBlock.isChargable(b)) {
- if (ChargableBlock.getCharge(b) < getEnergyConsumption()) {
- return;
- }
- ChargableBlock.addCharge(b, -getEnergyConsumption());
- progress.put(b, timeleft - 1);
- }
- else {
- progress.put(b, timeleft - 1);
+ if (ChargableBlock.getCharge(b) < getEnergyConsumption()) {
+ return;
}
+
+ ChargableBlock.addCharge(b, -getEnergyConsumption());
+ progress.put(b, timeleft - 1);
}
- else if (ChargableBlock.isChargable(b)) {
+ else {
if (ChargableBlock.getCharge(b) < getEnergyConsumption()) {
return;
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricFurnace.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricFurnace.java
index b8b46b999..c631c5ad4 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricFurnace.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricFurnace.java
@@ -6,7 +6,7 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.RecipeChoice;
import org.bukkit.inventory.RecipeChoice.MaterialChoice;
-import me.mrCookieSlime.Slimefun.SlimefunPlugin;
+import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer;
@@ -20,7 +20,7 @@ public abstract class ElectricFurnace extends AContainer {
@Override
public void registerDefaultRecipes() {
- SlimefunPlugin.getMinecraftRecipes().subscribe(snapshot -> {
+ SlimefunPlugin.getMinecraftRecipeService().subscribe(snapshot -> {
for (FurnaceRecipe recipe : snapshot.getRecipes(FurnaceRecipe.class)) {
RecipeChoice choice = recipe.getInputChoice();
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricGoldPan.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricGoldPan.java
index 1564d400e..f8e75b2e4 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricGoldPan.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricGoldPan.java
@@ -63,19 +63,14 @@ public abstract class ElectricGoldPan extends AContainer implements RecipeDispla
if (timeleft > 0 && getSpeed() < 10) {
ChestMenuUtils.updateProgressbar(menu, 22, timeleft, processing.get(b).getTicks(), getProgressBar());
- if (ChargableBlock.isChargable(b)) {
- if (ChargableBlock.getCharge(b) < getEnergyConsumption()) {
- return;
- }
+ if (ChargableBlock.getCharge(b) < getEnergyConsumption()) {
+ return;
+ }
- ChargableBlock.addCharge(b, -getEnergyConsumption());
- progress.put(b, timeleft - 1);
- }
- else {
- progress.put(b, timeleft - 1);
- }
+ ChargableBlock.addCharge(b, -getEnergyConsumption());
+ progress.put(b, timeleft - 1);
}
- else if (ChargableBlock.isChargable(b)) {
+ else {
if (ChargableBlock.getCharge(b) < getEnergyConsumption()) {
return;
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricIngotPulverizer.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricIngotPulverizer.java
index 14993cfac..3fb9aec88 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricIngotPulverizer.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricIngotPulverizer.java
@@ -53,10 +53,9 @@ public class ElectricIngotPulverizer extends AContainer implements RecipeDisplay
@Override
protected void registerDefaultRecipes() {
- // this is an extra recipe on top of PostSetup.loadSmelteryRecipes() for converting Vanilla Gold Ingot to Slimefun gold dust
- registerRecipe(3,
- new ItemStack(Material.GOLD_INGOT),
- SlimefunItems.GOLD_DUST);
+ // this is an extra recipe on top of PostSetup.loadSmelteryRecipes() for converting
+ // Vanilla Gold Ingot to Slimefun gold dust
+ registerRecipe(3, new ItemStack(Material.GOLD_INGOT), SlimefunItems.GOLD_DUST);
}
@Override
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricPress.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricPress.java
index 09e81095d..94a1c3858 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricPress.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricPress.java
@@ -27,6 +27,7 @@ public abstract class ElectricPress extends AContainer implements RecipeDisplayI
addRecipe(3, new ItemStack(Material.DRIED_KELP, 9), new ItemStack(Material.DRIED_KELP_BLOCK));
addRecipe(3, new ItemStack(Material.BONE_MEAL, 9), new ItemStack(Material.BONE_BLOCK));
+ addRecipe(3, new ItemStack(Material.CLAY_BALL, 4), new ItemStack(Material.CLAY));
addRecipe(6, SlimefunItems.COPPER_INGOT, new CustomItem(SlimefunItems.COPPER_WIRE, 3));
addRecipe(16, new CustomItem(SlimefunItems.STEEL_INGOT, 8), SlimefunItems.STEEL_PLATE);
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricSmeltery.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricSmeltery.java
index 0d24f71e6..ee61a684a 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricSmeltery.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricSmeltery.java
@@ -13,11 +13,11 @@ import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction;
+import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.AdvancedMenuClickHandler;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction;
-import me.mrCookieSlime.Slimefun.SlimefunPlugin;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer;
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FluidPump.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FluidPump.java
index c405cb0f4..242e4fd75 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FluidPump.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FluidPump.java
@@ -14,6 +14,7 @@ import io.github.thebusybiscuit.cscorelib2.blocks.Vein;
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetComponent;
import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNetComponentType;
+import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
@@ -21,7 +22,6 @@ import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.AdvancedMenu
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction;
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.SlimefunItem.interfaces.InventoryBlock;
import me.mrCookieSlime.Slimefun.Objects.handlers.BlockTicker;
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FoodComposter.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FoodComposter.java
index 37d817556..ea89ba234 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FoodComposter.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FoodComposter.java
@@ -6,8 +6,8 @@ import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion;
import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
+import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import io.github.thebusybiscuit.slimefun4.implementation.items.misc.OrganicFertilizer;
-import me.mrCookieSlime.Slimefun.SlimefunPlugin;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer;
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FoodFabricator.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FoodFabricator.java
index e86ccc5ed..2a52499e5 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FoodFabricator.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FoodFabricator.java
@@ -5,8 +5,8 @@ import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
+import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import io.github.thebusybiscuit.slimefun4.implementation.items.misc.OrganicFood;
-import me.mrCookieSlime.Slimefun.SlimefunPlugin;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer;
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/HeatedPressureChamber.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/HeatedPressureChamber.java
index 9b1456608..e13a6b319 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/HeatedPressureChamber.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/HeatedPressureChamber.java
@@ -15,10 +15,10 @@ import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
+import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
-import me.mrCookieSlime.Slimefun.SlimefunPlugin;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
@@ -148,17 +148,12 @@ public abstract class HeatedPressureChamber extends AContainer {
if (timeleft > 0) {
ChestMenuUtils.updateProgressbar(menu, 22, timeleft, processing.get(b).getTicks(), getProgressBar());
- if (ChargableBlock.isChargable(b)) {
- if (ChargableBlock.getCharge(b) < getEnergyConsumption()) {
- return;
- }
+ if (ChargableBlock.getCharge(b) < getEnergyConsumption()) {
+ return;
+ }
- ChargableBlock.addCharge(b, -getEnergyConsumption());
- progress.put(b, timeleft - 1);
- }
- else {
- progress.put(b, timeleft - 1);
- }
+ ChargableBlock.addCharge(b, -getEnergyConsumption());
+ progress.put(b, timeleft - 1);
}
else {
menu.replaceExistingItem(22, new CustomItem(new ItemStack(Material.BLACK_STAINED_GLASS_PANE), " "));
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/WitherAssembler.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/WitherAssembler.java
index d71314f27..a4a1a86dd 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/WitherAssembler.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/WitherAssembler.java
@@ -13,14 +13,14 @@ import io.github.thebusybiscuit.cscorelib2.math.DoubleHandler;
import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction;
import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetComponent;
import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNetComponentType;
+import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
+import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
-import me.mrCookieSlime.Slimefun.SlimefunPlugin;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.Objects.SlimefunBlockHandler;
-import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.UnregisterReason;
import me.mrCookieSlime.Slimefun.Objects.handlers.BlockTicker;
@@ -63,7 +63,7 @@ public class WitherAssembler extends SimpleSlimefunItem implements
@Override
public void newInstance(BlockMenu menu, Block b) {
if (!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "enabled") == null || BlockStorage.getLocationInfo(b.getLocation(), "enabled").equals(String.valueOf(false))) {
- menu.replaceExistingItem(22, new CustomItem(new ItemStack(Material.GUNPOWDER), "&7Enabled: &4\u2718", "", "&e> Click to enable this Machine"));
+ menu.replaceExistingItem(22, new CustomItem(Material.GUNPOWDER, "&7Enabled: &4\u2718", "", "&e> Click to enable this Machine"));
menu.addMenuClickHandler(22, (p, slot, item, action) -> {
BlockStorage.addBlockInfo(b, "enabled", String.valueOf(true));
newInstance(menu, b);
@@ -71,7 +71,7 @@ public class WitherAssembler extends SimpleSlimefunItem implements
});
}
else {
- menu.replaceExistingItem(22, new CustomItem(new ItemStack(Material.REDSTONE), "&7Enabled: &2\u2714", "", "&e> Click to disable this Machine"));
+ menu.replaceExistingItem(22, new CustomItem(Material.REDSTONE, "&7Enabled: &2\u2714", "", "&e> Click to disable this Machine"));
menu.addMenuClickHandler(22, (p, slot, item, action) -> {
BlockStorage.addBlockInfo(b, "enabled", String.valueOf(false));
newInstance(menu, b);
@@ -81,7 +81,7 @@ public class WitherAssembler extends SimpleSlimefunItem implements
double offset = (!BlockStorage.hasBlockInfo(b) || BlockStorage.getLocationInfo(b.getLocation(), "offset") == null) ? 3.0F : Double.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "offset"));
- menu.replaceExistingItem(31, new CustomItem(new ItemStack(Material.PISTON), "&7Offset: &3" + offset + " Block(s)", "", "&rLeft Click: &7+0.1", "&rRight Click: &7-0.1"));
+ menu.replaceExistingItem(31, new CustomItem(Material.PISTON, "&7Offset: &3" + offset + " Block(s)", "", "&rLeft Click: &7+0.1", "&rRight Click: &7-0.1"));
menu.addMenuClickHandler(31, (p, slot, item, action) -> {
double offsetv = DoubleHandler.fixDouble(Double.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "offset")) + (action.isRightClicked() ? -0.1F : 0.1F));
BlockStorage.addBlockInfo(b, "offset", String.valueOf(offsetv));
@@ -97,17 +97,27 @@ public class WitherAssembler extends SimpleSlimefunItem implements
@Override
public int[] getSlotsAccessedByItemTransport(ItemTransportFlow flow) {
- if (flow == ItemTransportFlow.INSERT) return getInputSlots();
- else return new int[0];
+ if (flow == ItemTransportFlow.INSERT) {
+ return getInputSlots();
+ }
+ else {
+ return new int[0];
+ }
}
@Override
public int[] getSlotsAccessedByItemTransport(DirtyChestMenu menu, ItemTransportFlow flow, ItemStack item) {
- if (flow == ItemTransportFlow.INSERT) {
- if (SlimefunUtils.isItemSimilar(item, new ItemStack(Material.SOUL_SAND), true)) return getSoulSandSlots();
- else return getWitherSkullSlots();
+ if (flow == ItemTransportFlow.INSERT && item != null) {
+ if (item.getType() == Material.SOUL_SAND) {
+ return getSoulSandSlots();
+ }
+
+ if (item.getType() == Material.WITHER_SKELETON_SKULL) {
+ return getWitherSkullSlots();
+ }
}
- else return new int[0];
+
+ return new int[0];
}
};
@@ -121,7 +131,10 @@ public class WitherAssembler extends SimpleSlimefunItem implements
@Override
public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) {
- if (reason == UnregisterReason.EXPLODE) return false;
+ if (reason == UnregisterReason.EXPLODE) {
+ return false;
+ }
+
BlockMenu inv = BlockStorage.getInventory(b);
if (inv != null) {
@@ -139,6 +152,7 @@ public class WitherAssembler extends SimpleSlimefunItem implements
}
}
}
+
return true;
}
});
@@ -227,7 +241,7 @@ public class WitherAssembler extends SimpleSlimefunItem implements
int found = 0;
for (int slot : slots) {
- if (SlimefunUtils.isItemSimilar(menu.getItemInSlot(slot), new ItemStack(resource), true)) {
+ if (SlimefunUtils.isItemSimilar(menu.getItemInSlot(slot), new ItemStack(resource), true, false)) {
found += menu.getItemInSlot(slot).getAmount();
if (found > required) {
@@ -244,7 +258,7 @@ public class WitherAssembler extends SimpleSlimefunItem implements
int skulls = 3;
for (int slot : getSoulSandSlots()) {
- if (SlimefunUtils.isItemSimilar(inv.getItemInSlot(slot), new ItemStack(Material.SOUL_SAND), true)) {
+ if (SlimefunUtils.isItemSimilar(inv.getItemInSlot(slot), new ItemStack(Material.SOUL_SAND), true, false)) {
int amount = inv.getItemInSlot(slot).getAmount();
if (amount >= soulsand) {
@@ -259,7 +273,7 @@ public class WitherAssembler extends SimpleSlimefunItem implements
}
for (int slot : getWitherSkullSlots()) {
- if (SlimefunUtils.isItemSimilar(inv.getItemInSlot(slot), new ItemStack(Material.WITHER_SKELETON_SKULL), true)) {
+ if (SlimefunUtils.isItemSimilar(inv.getItemInSlot(slot), new ItemStack(Material.WITHER_SKELETON_SKULL), true, false)) {
int amount = inv.getItemInSlot(slot).getAmount();
if (amount >= skulls) {
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/reactors/Reactor.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/reactors/Reactor.java
index c6a1e11f4..582fd78e5 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/reactors/Reactor.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/reactors/Reactor.java
@@ -19,6 +19,7 @@ import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction;
import io.github.thebusybiscuit.slimefun4.api.events.ReactorExplodeEvent;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
+import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import io.github.thebusybiscuit.slimefun4.implementation.items.cargo.ReactorAccessPort;
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.AbstractEnergyProvider;
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
@@ -26,7 +27,6 @@ import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
import io.github.thebusybiscuit.slimefun4.utils.holograms.ReactorHologram;
import io.github.thebusybiscuit.slimefun4.utils.holograms.SimpleHologram;
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
-import me.mrCookieSlime.Slimefun.SlimefunPlugin;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
@@ -278,7 +278,7 @@ public abstract class Reactor extends AbstractEnergyProvider {
if (timeleft > 0) {
int produced = getEnergyProduction();
- int space = ChargableBlock.getMaxCharge(l) - charge;
+ int space = getCapacity() - charge;
if (space >= produced || !ReactorMode.GENERATOR.toString().equals(BlockStorage.getLocationInfo(l, MODE))) {
progress.put(l, timeleft - 1);
@@ -347,7 +347,7 @@ public abstract class Reactor extends AbstractEnergyProvider {
}
private void createByproduct(Location l, BlockMenu inv, BlockMenu accessPort) {
- inv.replaceExistingItem(22, new CustomItem(new ItemStack(Material.BLACK_STAINED_GLASS_PANE), " "));
+ inv.replaceExistingItem(22, new CustomItem(Material.BLACK_STAINED_GLASS_PANE, " "));
if (processing.get(l).getOutput() != null) {
inv.pushItem(processing.get(l).getOutput(), getOutputSlots());
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/DietCookie.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/DietCookie.java
index 9419ab0b1..634746bf9 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/DietCookie.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/DietCookie.java
@@ -5,11 +5,11 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
-import me.mrCookieSlime.Slimefun.SlimefunPlugin;
+import io.github.thebusybiscuit.slimefun4.core.handlers.ItemConsumptionHandler;
+import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
+import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
-import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
-import me.mrCookieSlime.Slimefun.Objects.handlers.ItemConsumptionHandler;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
/**
@@ -31,7 +31,7 @@ public class DietCookie extends SimpleSlimefunItem {
@Override
public ItemConsumptionHandler getItemHandler() {
return (e, p, item) -> {
- SlimefunPlugin.getLocal().sendMessage(p, "messages.diet-cookie");
+ SlimefunPlugin.getLocalization().sendMessage(p, "messages.diet-cookie");
p.playSound(p.getLocation(), Sound.ENTITY_GENERIC_EAT, 1, 1);
if (p.hasPotionEffect(PotionEffectType.LEVITATION)) {
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/FortuneCookie.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/FortuneCookie.java
index fd2eb27d9..cb8a13a23 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/FortuneCookie.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/FortuneCookie.java
@@ -7,13 +7,13 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.cscorelib2.chat.ChatColors;
+import io.github.thebusybiscuit.slimefun4.core.handlers.ItemConsumptionHandler;
import io.github.thebusybiscuit.slimefun4.core.services.LocalizationService;
-import me.mrCookieSlime.Slimefun.SlimefunPlugin;
+import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
+import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
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.ItemConsumptionHandler;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
/**
@@ -33,7 +33,7 @@ public class FortuneCookie extends SimpleSlimefunItem {
@Override
public ItemConsumptionHandler getItemHandler() {
return (e, p, item) -> {
- List messages = SlimefunPlugin.getLocal().getMessages(p, "messages.fortune-cookie");
+ List messages = SlimefunPlugin.getLocalization().getMessages(p, "messages.fortune-cookie");
String message = messages.get(ThreadLocalRandom.current().nextInt(messages.size()));
p.sendMessage(ChatColors.color(message));
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/MagicSugar.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/MagicSugar.java
index fb7af2b3e..a09eaf31e 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/MagicSugar.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/MagicSugar.java
@@ -9,10 +9,10 @@ import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils;
+import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler;
+import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
-import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
-import me.mrCookieSlime.Slimefun.Objects.handlers.ItemUseHandler;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
public class MagicSugar extends SimpleSlimefunItem {
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/MeatJerky.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/MeatJerky.java
index 7da8dad06..3ca675d84 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/MeatJerky.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/MeatJerky.java
@@ -3,10 +3,10 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.food;
import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting;
+import io.github.thebusybiscuit.slimefun4.core.handlers.ItemConsumptionHandler;
+import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
-import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
-import me.mrCookieSlime.Slimefun.Objects.handlers.ItemConsumptionHandler;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
/**
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/MonsterJerky.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/MonsterJerky.java
index 4033da48e..1766b481f 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/MonsterJerky.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/MonsterJerky.java
@@ -4,10 +4,10 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
+import io.github.thebusybiscuit.slimefun4.core.handlers.ItemConsumptionHandler;
+import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
-import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
-import me.mrCookieSlime.Slimefun.Objects.handlers.ItemConsumptionHandler;
import me.mrCookieSlime.Slimefun.api.Slimefun;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOMiner.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOMiner.java
index 7856b2ee0..ea157dcf0 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOMiner.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOMiner.java
@@ -14,11 +14,11 @@ import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
import io.github.thebusybiscuit.slimefun4.api.geo.GEOResource;
import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem;
+import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
import io.github.thebusybiscuit.slimefun4.utils.holograms.SimpleHologram;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.AdvancedMenuClickHandler;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction;
-import me.mrCookieSlime.Slimefun.SlimefunPlugin;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.Objects.SlimefunBlockHandler;
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOScanner.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOScanner.java
index 08c7f8b4e..de00637ad 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOScanner.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOScanner.java
@@ -3,11 +3,11 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.geo;
import org.bukkit.block.Block;
import org.bukkit.inventory.ItemStack;
-import me.mrCookieSlime.Slimefun.SlimefunPlugin;
+import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler;
+import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
+import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
-import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
-import me.mrCookieSlime.Slimefun.Objects.handlers.BlockUseHandler;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
public class GEOScanner extends SimpleSlimefunItem {
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/OilPump.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/OilPump.java
index afda67198..721020aa2 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/OilPump.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/OilPump.java
@@ -15,9 +15,9 @@ import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction;
import io.github.thebusybiscuit.slimefun4.api.geo.GEOResource;
import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
+import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
-import me.mrCookieSlime.Slimefun.SlimefunPlugin;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer;
@@ -36,7 +36,7 @@ public abstract class OilPump extends AContainer implements RecipeDisplayItem {
public OilPump(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, recipeType, recipe);
- oil = SlimefunPlugin.getRegistry().getGEOResources().get(new NamespacedKey(SlimefunPlugin.instance, "oil")).orElse(null);
+ oil = SlimefunPlugin.getRegistry().getGEOResources().get(new NamespacedKey(SlimefunPlugin.instance(), "oil")).orElse(null);
new BlockMenuPreset(getID(), getInventoryTitle()) {
@@ -52,7 +52,7 @@ public abstract class OilPump extends AContainer implements RecipeDisplayItem {
}
if (!SlimefunPlugin.getGPSNetwork().getResourceManager().getSupplies(oil, b.getWorld(), b.getX() >> 4, b.getZ() >> 4).isPresent()) {
- SlimefunPlugin.getLocal().sendMessage(p, "gps.geo.scan-required", true);
+ SlimefunPlugin.getLocalization().sendMessage(p, "gps.geo.scan-required", true);
return false;
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/PortableGEOScanner.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/PortableGEOScanner.java
index 5c80ebbe9..1c336c348 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/PortableGEOScanner.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/PortableGEOScanner.java
@@ -5,11 +5,11 @@ import java.util.Optional;
import org.bukkit.block.Block;
import org.bukkit.inventory.ItemStack;
-import me.mrCookieSlime.Slimefun.SlimefunPlugin;
+import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler;
+import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
+import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
-import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
-import me.mrCookieSlime.Slimefun.Objects.handlers.ItemUseHandler;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
public class PortableGEOScanner extends SimpleSlimefunItem {
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/ElevatorPlate.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/ElevatorPlate.java
index c618a1d88..86e7d4482 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/ElevatorPlate.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/ElevatorPlate.java
@@ -20,16 +20,16 @@ import io.github.thebusybiscuit.cscorelib2.chat.json.ClickEvent;
import io.github.thebusybiscuit.cscorelib2.chat.json.CustomBookInterface;
import io.github.thebusybiscuit.cscorelib2.chat.json.HoverEvent;
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
+import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler;
+import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
+import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
import io.github.thebusybiscuit.slimefun4.utils.ChatUtils;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
-import me.mrCookieSlime.Slimefun.SlimefunPlugin;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.Objects.SlimefunBlockHandler;
-import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.UnregisterReason;
-import me.mrCookieSlime.Slimefun.Objects.handlers.BlockUseHandler;
import me.mrCookieSlime.Slimefun.api.BlockStorage;
import me.mrCookieSlime.Slimefun.api.Slimefun;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
@@ -96,13 +96,13 @@ public class ElevatorPlate extends SimpleSlimefunItem {
return;
}
- CustomBookInterface book = new CustomBookInterface(SlimefunPlugin.instance);
+ CustomBookInterface book = new CustomBookInterface(SlimefunPlugin.instance());
ChatComponent page = null;
List floors = getFloors(b);
if (floors.size() < 2) {
- SlimefunPlugin.getLocal().sendMessage(p, "machines.ELEVATOR.no-destinations", true);
+ SlimefunPlugin.getLocalization().sendMessage(p, "machines.ELEVATOR.no-destinations", true);
}
for (int i = 0; i < floors.size(); i++) {
@@ -111,7 +111,7 @@ public class ElevatorPlate extends SimpleSlimefunItem {
book.addPage(page);
}
- page = new ChatComponent(ChatColors.color(SlimefunPlugin.getLocal().getMessage(p, "machines.ELEVATOR.pick-a-floor")) + "\n");
+ page = new ChatComponent(ChatColors.color(SlimefunPlugin.getLocalization().getMessage(p, "machines.ELEVATOR.pick-a-floor")) + "\n");
}
Block block = floors.get(i);
@@ -120,12 +120,12 @@ public class ElevatorPlate extends SimpleSlimefunItem {
if (block.getY() == b.getY()) {
line = new ChatComponent("\n" + ChatColor.GRAY + "> " + (floors.size() - i) + ". " + ChatColor.RESET + floor);
- line.setHoverEvent(new HoverEvent(ChatColors.color(SlimefunPlugin.getLocal().getMessage(p, "machines.ELEVATOR.current-floor")), "", ChatColor.RESET + floor, ""));
+ line.setHoverEvent(new HoverEvent(ChatColors.color(SlimefunPlugin.getLocalization().getMessage(p, "machines.ELEVATOR.current-floor")), "", ChatColor.RESET + floor, ""));
}
else {
line = new ChatComponent("\n" + ChatColor.GRAY.toString() + (floors.size() - i) + ". " + ChatColor.RESET + floor);
- line.setHoverEvent(new HoverEvent(ChatColors.color(SlimefunPlugin.getLocal().getMessage(p, "machines.ELEVATOR.click-to-teleport")), "", ChatColor.RESET + floor, ""));
- line.setClickEvent(new ClickEvent(new NamespacedKey(SlimefunPlugin.instance, DATA_KEY + i), player -> Slimefun.runSync(() -> {
+ line.setHoverEvent(new HoverEvent(ChatColors.color(SlimefunPlugin.getLocalization().getMessage(p, "machines.ELEVATOR.click-to-teleport")), "", ChatColor.RESET + floor, ""));
+ line.setClickEvent(new ClickEvent(new NamespacedKey(SlimefunPlugin.instance(), DATA_KEY + i), player -> Slimefun.runSync(() -> {
users.add(player.getUniqueId());
float yaw = player.getEyeLocation().getYaw() + 180;
@@ -156,14 +156,14 @@ public class ElevatorPlate extends SimpleSlimefunItem {
menu.addMenuClickHandler(4, (pl, slot, item, action) -> {
pl.closeInventory();
pl.sendMessage("");
- SlimefunPlugin.getLocal().sendMessage(p, "machines.ELEVATOR.enter-name");
+ SlimefunPlugin.getLocalization().sendMessage(p, "machines.ELEVATOR.enter-name");
pl.sendMessage("");
ChatUtils.awaitInput(pl, message -> {
BlockStorage.addBlockInfo(b, DATA_KEY, message.replace(ChatColor.COLOR_CHAR, '&'));
pl.sendMessage("");
- SlimefunPlugin.getLocal().sendMessage(p, "machines.ELEVATOR.named", msg -> msg.replace("%floor%", message));
+ SlimefunPlugin.getLocalization().sendMessage(p, "machines.ELEVATOR.named", msg -> msg.replace("%floor%", message));
pl.sendMessage("");
openEditor(pl, b);
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/GPSControlPanel.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/GPSControlPanel.java
index 88f0d31b0..4d11de893 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/GPSControlPanel.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/GPSControlPanel.java
@@ -2,11 +2,11 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.gps;
import org.bukkit.inventory.ItemStack;
-import me.mrCookieSlime.Slimefun.SlimefunPlugin;
+import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler;
+import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
+import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
-import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
-import me.mrCookieSlime.Slimefun.Objects.handlers.BlockUseHandler;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
public class GPSControlPanel extends SimpleSlimefunItem {
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/GPSMarkerTool.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/GPSMarkerTool.java
index 8ccef0015..b19fd4c0b 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/GPSMarkerTool.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/GPSMarkerTool.java
@@ -4,11 +4,11 @@ import org.bukkit.block.Block;
import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable;
-import me.mrCookieSlime.Slimefun.SlimefunPlugin;
+import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler;
+import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
+import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
-import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
-import me.mrCookieSlime.Slimefun.Objects.handlers.ItemUseHandler;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
public class GPSMarkerTool extends SimpleSlimefunItem implements NotPlaceable {
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/GPSTransmitter.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/GPSTransmitter.java
index 9523f936d..ef66e79c0 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/GPSTransmitter.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/GPSTransmitter.java
@@ -8,12 +8,12 @@ import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetComponent;
import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNetComponentType;
+import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
+import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
-import me.mrCookieSlime.Slimefun.SlimefunPlugin;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.Objects.SlimefunBlockHandler;
-import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.UnregisterReason;
import me.mrCookieSlime.Slimefun.Objects.handlers.BlockTicker;
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/TeleporterPylon.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/TeleporterPylon.java
index 1d4bba69d..742428e51 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/TeleporterPylon.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/TeleporterPylon.java
@@ -3,10 +3,10 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.gps;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
+import io.github.thebusybiscuit.slimefun4.core.handlers.RainbowTickHandler;
import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.RainbowBlock;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
-import me.mrCookieSlime.Slimefun.Objects.handlers.RainbowTicker;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
/**
@@ -17,12 +17,12 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
*
* @see Teleporter
* @see RainbowBlock
- * @see RainbowTicker
+ * @see RainbowTickHandler
*/
public class TeleporterPylon extends RainbowBlock {
public TeleporterPylon(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput) {
- super(category, item, recipeType, recipe, recipeOutput, new RainbowTicker(Material.CYAN_STAINED_GLASS, Material.PURPLE_STAINED_GLASS));
+ super(category, item, recipeType, recipe, recipeOutput, new RainbowTickHandler(Material.CYAN_STAINED_GLASS, Material.PURPLE_STAINED_GLASS));
}
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/EnchantmentRune.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/EnchantmentRune.java
new file mode 100644
index 000000000..c57ffe8d1
--- /dev/null
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/EnchantmentRune.java
@@ -0,0 +1,168 @@
+package io.github.thebusybiscuit.slimefun4.implementation.items.magical;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.EnumMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.concurrent.ThreadLocalRandom;
+
+import org.bukkit.Location;
+import org.bukkit.Material;
+import org.bukkit.Particle;
+import org.bukkit.Sound;
+import org.bukkit.enchantments.Enchantment;
+import org.bukkit.entity.Entity;
+import org.bukkit.entity.Item;
+import org.bukkit.entity.Player;
+import org.bukkit.event.player.PlayerDropItemEvent;
+import org.bukkit.inventory.ItemStack;
+
+import io.github.thebusybiscuit.slimefun4.core.handlers.ItemDropHandler;
+import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
+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.api.Slimefun;
+import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
+
+/**
+ * This {@link SlimefunItem} allows you to enchant any enchantable {@link ItemStack} with a random
+ * {@link Enchantment}. It is also one of the very few utilisations of {@link ItemDropHandler}.
+ *
+ * @author Linox
+ *
+ * @see ItemDropHandler
+ * @see Enchantment
+ *
+ */
+public class EnchantmentRune extends SimpleSlimefunItem