diff --git a/CHANGELOG.md b/CHANGELOG.md index a03f9aac5..2eda43a04 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,8 @@ **Table of contents** -- [Release Candidate 14 (TBD)](#release-candidate-14-tbd) +- [Release Candidate 15 (TBD)](#release-candidate-15-tbd) +- [Release Candidate 14 (12 Jul 2020)](#release-candidate-14-12-jul-2020) - [Release Candidate 13 (16 Jun 2020)](#release-candidate-13-16-jun-2020) - [Release Candidate 12 (27 May 2020)](#release-candidate-12-27-may-2020) - [Release Candidate 11 (25 Apr 2020)](#release-candidate-11-25-apr-2020) @@ -19,7 +20,39 @@ -## Release Candidate 14 (TBD) +## Release Candidate 15 (TBD) + +#### Additions +* Added "Bone Block -> Bone meal" recipe to the Grind Stone +* Added a [Metrics module](https://github.com/Slimefun/MetricsModule) which allows us to release updates to metrics (bStats) independently from the main plugin +* Added "Compressed Carbon -> Carbon" recipe to the Ore Crusher +* Added "Carbon -> Coal" recipe to the Ore Crusher +* Added Iron Golem Assembler +* Added Reinforced Cloth +* Added Bee protection to Hazmat Suit +* Added Enchantment Rune +* Added Tape Measure + +#### Changes +* Refactored and reworked the Generator API +* Small performance improvements to Energy networks +* Big performance improvements to Cargo networks when using ChestTerminal +* Slight changes to /sf timings +* Changed recipe of Hazmat Suits +* Uranium can no longer be placed down +* Huge performance improvements when using Paper +* Optimized Cargo networks for Paper +* Optimized Multiblocks for Paper +* Optimized Enhanced Furnaces for Paper + +#### Fixes +* Fixed Slimefun Armor sometimes not applying its effects +* Fixed #2075 +* Fixed #2093 +* Fixed #2086 +* Fixed #1894 + +## Release Candidate 14 (12 Jul 2020) #### Additions * Added support for Minecraft 1.16 @@ -42,9 +75,6 @@ * Added runtime deprecation warnings for ItemHandlers and Attributes used by Addons * Added a proper lag profiler * Added per-plugin lag info to /sf timings -* Added Reinforced Cloth -* Added Bee protection to Hazmat Suit -* Added Enchantment Rune * Added Indonesian translations #### Changes @@ -66,9 +96,9 @@ * performance improvements to Generators and Electric Machines * Cargo timings will now be attributed to the corresponding node and not the Cargo manager * Thunderstorms now count as night time for Solar Generators -* Fixed an issue with moving androids getting stuck -* Changed recipe of Hazmat Suits -* Uranium can no longer be placed down +* Coolant Cells can no longer be placed on the ground +* Crafting Nether Ice Coolant Cells now results in 4 items +* Moved Soulbound Backpack to the "Magical Gadgets" Category #### Fixes * Fixed #2005 @@ -93,10 +123,12 @@ * Fixed #2066 * Fixed Rainbow Glass Panes not properly connecting to blocks * Fixed Androids turning in the wrong direction -* Fixed a NullPointerException when generating an Error-Report -* Fixed Slimefun Armor sometimes not applying its effects * Fixed contributors losing their texture after restarts * Fixed "korean" showing up as "null" +* Fixed an issue with moving androids getting stuck +* Fixed Cargo nodes sometimes preventing chunks from unloading +* Fixed #2081 +* Fixed a NullPointerException when Generators throw an Error Report ## Release Candidate 13 (16 Jun 2020) https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#13 diff --git a/README.md b/README.md index 32fc24d49..78a818163 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ Here is a full summary of the differences between the two different versions of | | development (latest) | "stable" | | ------------------ | -------- | -------- | -| **Minecraft version(s)** | :video_game: **1.13.\* - 1.16.\*** | :video_game: **1.13.\* - 1.15.\*** | +| **Minecraft version(s)** | :video_game: **1.13.\* - 1.16.\*** | :video_game: **1.13.\* - 1.16.\*** | | **automatic updates** | :heavy_check_mark: | :heavy_check_mark: | | **frequent updates** | :heavy_check_mark: | :x: | | **latest content** | :heavy_check_mark: | :x: | @@ -114,6 +114,8 @@ To compile Slimefun yourself, follow these steps: If you are already using an IDE, make sure to import the project via git and set it as a *Maven project*. Then you should be able build it via Maven using the goals `clean package`. +If you have any further questions, then please join our [Discord Support Server](#discord) and ask your questions in the `#programming-help` channel. Note that we will not accept any bug reports from custom-compiled versions of Slimefun. + ### Code Quality Slimefun uses [Sonarcloud.io](https://sonarcloud.io/dashboard?id=TheBusyBiscuit_Slimefun4) to monitor Code Quality. @@ -157,6 +159,10 @@ All of the collected data is publicly accessible: https://bstats.org/plugin/bukk You can also disable this behaviour under `/plugins/bStats/config.yml`.
For more info see [bStats' Privacy Policy](https://bstats.org/privacy-policy) + +Our [bStats Module](https://github.com/Slimefun/MetricsModule) is downloaded automatically when installing this Plugin, this module will automatically update on server starts independently from the main plugin. This way we can automatically roll out updates to the bStats module, in cases of severe performance issues for example where live data and insight into what is impacting performance can be crucial. +These updates can of course be disabled under `/plugins/Slimefun/config.yml`. To disable metrics collection as a whole, see the paragraph above. +
diff --git a/pom.xml b/pom.xml index ee60ded43..c0082a726 100644 --- a/pom.xml +++ b/pom.xml @@ -60,7 +60,7 @@ https://repo.destroystokyo.com/repository/maven-public/ - worldedit-worldguard-repo + worldedit-repo https://maven.sk89q.com/repo/ @@ -169,6 +169,10 @@ io.github.thebusybiscuit.cscorelib2 me.mrCookieSlime.Slimefun.cscorelib2 + + io.papermc.lib + io.github.thebusybiscuit.slimefun4.libraries.paperlib + @@ -231,9 +235,17 @@ io.github.thebusybiscuit.slimefun4.utils* - Slimefun4 - Item Implementations + Slimefun4 - Items io.github.thebusybiscuit.slimefun4.implementation.items* + + Slimefun4 - Multiblocks + io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks* + + + Slimefun4 - Electrical Machines + io.github.thebusybiscuit.slimefun4.implementation.items.electric* + Slimefun4 - Old packages me.mrCookieSlime.Slimefun* @@ -298,7 +310,7 @@ org.mockito mockito-core - 3.3.3 + 3.4.4 test @@ -306,7 +318,7 @@ com.github.TheBusyBiscuit CS-CoreLib2 - 0.23.2 + 0.24 compile @@ -315,6 +327,23 @@ 1.7 compile + + com.konghq + unirest-java + 3.8.06 + + + com.google.code.gson + gson + + + + + io.papermc + paperlib + 1.0.4 + compile + @@ -331,6 +360,7 @@ + me.clip placeholderapi diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/ErrorReport.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/ErrorReport.java index 365fa129f..4297e2223 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/ErrorReport.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/ErrorReport.java @@ -1,7 +1,6 @@ package io.github.thebusybiscuit.slimefun4.api; import java.io.File; -import java.io.IOException; import java.io.PrintStream; import java.nio.charset.StandardCharsets; import java.time.LocalDateTime; @@ -18,6 +17,7 @@ import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.plugin.Plugin; +import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetProvider; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; import me.mrCookieSlime.Slimefun.Objects.handlers.BlockTicker; @@ -92,7 +92,7 @@ public class ErrorReport { addon.getLogger().log(Level.WARNING, ""); } - catch (IOException x) { + catch (Exception x) { addon.getLogger().log(Level.SEVERE, x, () -> "An Error occurred while saving an Error-Report for Slimefun " + SlimefunPlugin.getVersion()); } }); @@ -116,6 +116,12 @@ public class ErrorReport { stream.println(); } + if (item instanceof EnergyNetProvider) { + stream.println("Ticker-Info:"); + stream.println(" Type: Indirect (Energy Network)"); + stream.println(); + } + stream.println("Slimefun Data:"); stream.println(" ID: " + item.getID()); stream.println(" Inventory: " + BlockStorage.getStorage(l.getWorld()).hasInventory(l)); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/ResearchUnlockEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/ResearchUnlockEvent.java index eae5367c4..cd517ea68 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/ResearchUnlockEvent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/ResearchUnlockEvent.java @@ -19,8 +19,8 @@ public class ResearchUnlockEvent extends Event implements Cancellable { private static final HandlerList handlers = new HandlerList(); - private Player player; - private Research research; + private final Player player; + private final Research research; private boolean cancelled; public HandlerList getHandlers() { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/WrongItemStackException.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/WrongItemStackException.java new file mode 100644 index 000000000..b853a16e2 --- /dev/null +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/WrongItemStackException.java @@ -0,0 +1,36 @@ +package io.github.thebusybiscuit.slimefun4.api.exceptions; + +import org.bukkit.inventory.ItemStack; + +import io.github.thebusybiscuit.slimefun4.core.attributes.DamageableItem; +import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; +import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; + +/** + * A {@link WrongItemStackException} is thrown when someone tries to alter an {@link ItemStack} + * but actually wanted to alter a different one. + * + * If for example a {@link DamageableItem} accidentally damages the original {@link SlimefunItem} + * instead of the held {@link ItemStack}, this will be thrown. + * + * @author TheBusyBiscuit + * + * @see SlimefunItemStack + * @see SlimefunItem + * + */ +public class WrongItemStackException extends RuntimeException { + + private static final long serialVersionUID = 9144658137363309071L; + + /** + * This constructs a new {@link WrongItemStackException} with the given error context. + * + * @param message + * An error message to display + */ + public WrongItemStackException(String message) { + super("You probably wanted to alter a different ItemStack: " + message); + } + +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/GPSNetwork.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/GPSNetwork.java index 8694c661b..511c8e418 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/GPSNetwork.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/GPSNetwork.java @@ -54,7 +54,7 @@ public class GPSNetwork { private final Map> transmitters = new HashMap<>(); private final TeleportationManager teleportation = new TeleportationManager(); - private final ResourceManager resourceManager = new ResourceManager(SlimefunPlugin.instance); + private final ResourceManager resourceManager = new ResourceManager(SlimefunPlugin.instance()); /** * This method updates the status of a {@link GPSTransmitter}. @@ -256,7 +256,7 @@ public class GPSNetwork { SlimefunPlugin.getLocalization().sendMessage(p, "gps.waypoint.new", true); p.playSound(p.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, 0.5F, 1F); - ChatInput.waitForPlayer(SlimefunPlugin.instance, p, message -> addWaypoint(p, message, l)); + ChatInput.waitForPlayer(SlimefunPlugin.instance(), p, message -> addWaypoint(p, message, l)); }); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/TeleportationManager.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/TeleportationManager.java index 0b99e4370..9de0d816d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/TeleportationManager.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/TeleportationManager.java @@ -21,6 +21,7 @@ import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; import io.github.thebusybiscuit.slimefun4.utils.HeadTexture; +import io.papermc.lib.PaperLib; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu; import me.mrCookieSlime.Slimefun.api.Slimefun; @@ -58,10 +59,21 @@ public final class TeleportationManager { } int slot = teleporterInventory[index]; - Location l = waypoint.getLocation(); - menu.addItem(slot, - new CustomItem(waypoint.getIcon(), waypoint.getName().replace("player:death ", ""), "", "&8\u21E8 &7" + SlimefunPlugin.getLocalization().getResourceString(p, "tooltips.world") + ": &f" + l.getWorld().getName(), "&8\u21E8 &7X: &f" + l.getX(), "&8\u21E8 &7Y: &f" + l.getY(), "&8\u21E8 &7Z: &f" + l.getZ(), "&8\u21E8 &7" + SlimefunPlugin.getLocalization().getMessage(p, "machines.TELEPORTER.gui.time") + ": &f" + DoubleHandler.fixDouble(0.5 * getTeleportationTime(complexity, source, l)) + "s", "", "&8\u21E8 &c" + SlimefunPlugin.getLocalization().getMessage(p, "machines.TELEPORTER.gui.tooltip"))); + double time = DoubleHandler.fixDouble(0.5 * getTeleportationTime(complexity, source, l)); + + String[] lore = { + "", + "&8\u21E8 &7" + SlimefunPlugin.getLocalization().getResourceString(p, "tooltips.world") + ": &f" + l.getWorld().getName(), + "&8\u21E8 &7X: &f" + l.getX(), + "&8\u21E8 &7Y: &f" + l.getY(), + "&8\u21E8 &7Z: &f" + l.getZ(), + "&8\u21E8 &7" + SlimefunPlugin.getLocalization().getMessage(p, "machines.TELEPORTER.gui.time") + ": &f" + time + "s", + "", + "&8\u21E8 &c" + SlimefunPlugin.getLocalization().getMessage(p, "machines.TELEPORTER.gui.tooltip") + }; + + menu.addItem(slot, new CustomItem(waypoint.getIcon(), waypoint.getName().replace("player:death ", ""), lore)); menu.addMenuClickHandler(slot, (pl, s, item, action) -> { pl.closeInventory(); teleport(pl.getUniqueId(), complexity, source, l, false); @@ -117,16 +129,24 @@ public final class TeleportationManager { if (isValid(p, source)) { if (progress > 99) { p.sendTitle(ChatColors.color(SlimefunPlugin.getLocalization().getMessage(p, "machines.TELEPORTER.teleported")), ChatColors.color("&b100%"), 20, 60, 20); - p.teleport(destination); - if (resistance) { - p.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 600, 20)); - SlimefunPlugin.getLocalization().sendMessage(p, "machines.TELEPORTER.invulnerability"); - } + PaperLib.teleportAsync(p, destination).thenAccept(teleported -> { + if (teleported.booleanValue()) { + // This needs to run on the main Thread so we force it, as the + // async teleportation might happen on a seperate Thread. + Slimefun.runSync(() -> { + if (resistance) { + p.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 600, 20)); + SlimefunPlugin.getLocalization().sendMessage(p, "machines.TELEPORTER.invulnerability"); + } - destination.getWorld().spawnParticle(Particle.PORTAL, new Location(destination.getWorld(), destination.getX(), destination.getY() + 1, destination.getZ()), progress * 2, 0.2F, 0.8F, 0.2F); - destination.getWorld().playSound(destination, Sound.BLOCK_BEACON_ACTIVATE, 1F, 1F); - teleporterUsers.remove(uuid); + Location loc = new Location(destination.getWorld(), destination.getX(), destination.getY() + 1, destination.getZ()); + destination.getWorld().spawnParticle(Particle.PORTAL, loc, progress * 2, 0.2F, 0.8F, 0.2F); + destination.getWorld().playSound(destination, Sound.BLOCK_BEACON_ACTIVATE, 1F, 1F); + teleporterUsers.remove(uuid); + }); + } + }); } else { p.sendTitle(ChatColors.color(SlimefunPlugin.getLocalization().getMessage(p, "machines.TELEPORTER.teleporting")), ChatColors.color("&b" + progress + "%"), 0, 60, 0); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/Waypoint.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/Waypoint.java index d27a53d18..58ed699c6 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/Waypoint.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/Waypoint.java @@ -28,8 +28,8 @@ public class Waypoint { private final PlayerProfile profile; private final String id; - private String name; - private Location location; + private final String name; + private final Location location; public Waypoint(PlayerProfile profile, String id, Location l, String name) { Validate.notNull(profile, "Profile must never be null!"); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/network/Network.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/network/Network.java index 6980314ea..0158dbbd4 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/network/Network.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/network/Network.java @@ -29,7 +29,7 @@ public abstract class Network { private final NetworkManager manager; protected Location regulator; - private Queue nodeQueue = new ArrayDeque<>(); + private final Queue nodeQueue = new ArrayDeque<>(); protected final Set connectedLocations = new HashSet<>(); protected final Set regulatorNodes = new HashSet<>(); @@ -225,6 +225,10 @@ public abstract class Network { }); } + public Location getRegulator() { + return regulator; + } + public void tick() { discoverStep(); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/PlayerProfile.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/PlayerProfile.java index 50d58337b..a030a751e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/PlayerProfile.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/PlayerProfile.java @@ -372,7 +372,7 @@ public final class PlayerProfile { return true; } - Bukkit.getScheduler().runTaskAsynchronously(SlimefunPlugin.instance, () -> { + Bukkit.getScheduler().runTaskAsynchronously(SlimefunPlugin.instance(), () -> { PlayerProfile pp = new PlayerProfile(p); SlimefunPlugin.getRegistry().getPlayerProfiles().put(uuid, pp); callback.accept(pp); @@ -393,7 +393,7 @@ public final class PlayerProfile { public static boolean request(OfflinePlayer p) { if (!SlimefunPlugin.getRegistry().getPlayerProfiles().containsKey(p.getUniqueId())) { // Should probably prevent multiple requests for the same profile in the future - Bukkit.getScheduler().runTaskAsynchronously(SlimefunPlugin.instance, () -> { + Bukkit.getScheduler().runTaskAsynchronously(SlimefunPlugin.instance(), () -> { PlayerProfile pp = new PlayerProfile(p); SlimefunPlugin.getRegistry().getPlayerProfiles().put(p.getUniqueId(), pp); }); @@ -446,9 +446,7 @@ public final class PlayerProfile { fromUUID(UUID.fromString(uuid), profile -> { Optional backpack = profile.getBackpack(number); - if (backpack.isPresent()) { - callback.accept(backpack.get()); - } + backpack.ifPresent(callback); }); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/SlimefunRegistry.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/SlimefunRegistry.java index 3093112fb..710cd83e4 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/SlimefunRegistry.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/SlimefunRegistry.java @@ -21,7 +21,6 @@ import io.github.thebusybiscuit.cscorelib2.config.Config; import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; import io.github.thebusybiscuit.slimefun4.api.geo.GEOResource; import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; -import io.github.thebusybiscuit.slimefun4.core.attributes.WitherProof; import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideImplementation; import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout; import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlock; @@ -30,6 +29,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.implementation.guide.BookSlimefunGuide; import io.github.thebusybiscuit.slimefun4.implementation.guide.CheatSheetSlimefunGuide; import io.github.thebusybiscuit.slimefun4.implementation.guide.ChestSlimefunGuide; +import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.AutomatedCraftingChamber; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.Objects.SlimefunBlockHandler; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; @@ -71,21 +71,15 @@ public class SlimefunRegistry { private final KeyMap geoResources = new KeyMap<>(); - private final Set energyGenerators = new HashSet<>(); - private final Set energyCapacitors = new HashSet<>(); - private final Set energyConsumers = new HashSet<>(); - private final Set chargeableBlocks = new HashSet<>(); - private final Map witherProofBlocks = new HashMap<>(); - private final Map profiles = new ConcurrentHashMap<>(); private final Map worlds = new ConcurrentHashMap<>(); private final Map chunks = new HashMap<>(); private final Map layouts = new EnumMap<>(SlimefunGuideLayout.class); - private final Map> drops = new EnumMap<>(EntityType.class); + private final Map> mobDrops = new EnumMap<>(EntityType.class); private final Map capacities = new HashMap<>(); private final Map blockMenuPresets = new HashMap<>(); private final Map universalInventories = new HashMap<>(); - private final Map, Set> itemHandlers = new HashMap<>(); + private final Map, Set> globalItemHandlers = new HashMap<>(); private final Map blockHandlers = new HashMap<>(); private final Map> activeTickers = new HashMap<>(); @@ -200,11 +194,7 @@ public class SlimefunRegistry { } public Map> getMobDrops() { - return drops; - } - - public Set getMobDrops(EntityType entity) { - return drops.get(entity); + return mobDrops; } public Set getRadioactiveItems() { @@ -240,7 +230,7 @@ public class SlimefunRegistry { } public Map, Set> getPublicItemHandlers() { - return itemHandlers; + return globalItemHandlers; } public Map getBlockHandlers() { @@ -263,29 +253,16 @@ public class SlimefunRegistry { return geoResources; } + /** + * This method returns a list of recipes for the {@link AutomatedCraftingChamber} + * + * @deprecated This just a really bad way to do this. Someone needs to rewrite this. + * + * @return A list of recipes for the {@link AutomatedCraftingChamber} + */ @Deprecated public Map getAutomatedCraftingChamberRecipes() { return automatedCraftingChamberRecipes; } - public Set getEnergyGenerators() { - return energyGenerators; - } - - public Set getEnergyCapacitors() { - return energyCapacitors; - } - - public Set getEnergyConsumers() { - return energyConsumers; - } - - public Set getChargeableBlocks() { - return chargeableBlocks; - } - - public Map getWitherProofBlocks() { - return witherProofBlocks; - } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/EnergyNetComponent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/EnergyNetComponent.java index 954b9d32a..919df1866 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/EnergyNetComponent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/EnergyNetComponent.java @@ -2,7 +2,6 @@ package io.github.thebusybiscuit.slimefun4.core.attributes; import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNet; import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNetComponentType; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; /** @@ -37,33 +36,4 @@ public interface EnergyNetComponent extends ItemAttribute { */ int getCapacity(); - /** - * This method is used for internal purposes to register the component. - * You do not have to call this method yourself. - * - * @param id - * The id of the {@link SlimefunItem} this refers to - */ - default void registerComponent(String id) { - switch (getEnergyComponentType()) { - case CONSUMER: - SlimefunPlugin.getRegistry().getEnergyConsumers().add(id); - break; - case CAPACITOR: - SlimefunPlugin.getRegistry().getEnergyCapacitors().add(id); - break; - case GENERATOR: - SlimefunPlugin.getRegistry().getEnergyGenerators().add(id); - break; - default: - break; - } - - int capacity = getCapacity(); - - if (capacity > 0) { - SlimefunPlugin.getRegistry().getEnergyCapacities().put(id, capacity); - } - } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/EnergyNetProvider.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/EnergyNetProvider.java new file mode 100644 index 000000000..9a4e7e2e2 --- /dev/null +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/EnergyNetProvider.java @@ -0,0 +1,62 @@ +package io.github.thebusybiscuit.slimefun4.core.attributes; + +import org.bukkit.Location; + +import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNet; +import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNetComponentType; +import io.github.thebusybiscuit.slimefun4.implementation.items.electric.AbstractEnergyProvider; +import io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors.Reactor; +import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; +import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AGenerator; + +/** + * An {@link EnergyNetProvider} is an extension of {@link EnergyNetComponent} which provides + * energy to an {@link EnergyNet}. + * It must be implemented on any Generator or {@link Reactor}. + * + * @author TheBusyBiscuit + * + * @see EnergyNet + * @see EnergyNetComponent + * @see AbstractEnergyProvider + * @see AGenerator + * @see Reactor + * + */ +public interface EnergyNetProvider extends EnergyNetComponent { + + @Override + default EnergyNetComponentType getEnergyComponentType() { + return EnergyNetComponentType.GENERATOR; + } + + /** + * This method returns how much energy this {@link EnergyNetProvider} provides to the {@link EnergyNet}. + * We call this method on every tick, so make sure to keep it light and fast. + * Stored energy does not have to be handled in here. + * + * @param l + * The {@link Location} of this {@link EnergyNetProvider} + * @param data + * The stored block data + * + * @return The generated output energy of this {@link EnergyNetProvider}. + */ + int getGeneratedOutput(Location l, Config data); + + /** + * This method returns whether the given {@link Location} is going to explode on the + * next tick. + * + * @param l + * The {@link Location} of this {@link EnergyNetProvider} + * @param data + * The stored block data + * + * @return Whether or not this {@link Location} will explode. + */ + default boolean willExplode(Location l, Config data) { + return false; + } + +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/RandomMobDrop.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/RandomMobDrop.java new file mode 100644 index 000000000..a873b8620 --- /dev/null +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/RandomMobDrop.java @@ -0,0 +1,35 @@ +package io.github.thebusybiscuit.slimefun4.core.attributes; + +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDeathEvent; + +import io.github.thebusybiscuit.slimefun4.implementation.items.misc.BasicCircuitBoard; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.MobDropListener; +import me.mrCookieSlime.Slimefun.Lists.RecipeType; +import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; + +/** + * This interface, when attached to a {@link SlimefunItem}, provides an easy method for adding + * a % chance to drop for an {@link SlimefunItem} on {@link EntityDeathEvent}, this chance is 0-100 + * and used in conjunction with the MOB_DROP {@link RecipeType}. + * + * @author dNiym + * + * @see BasicCircuitBoard + * @see MobDropListener + * + */ +@FunctionalInterface +public interface RandomMobDrop extends ItemAttribute { + + /** + * Implement this method to make the object have a variable chance of being + * added to the dropList when {@link EntityType} (specified in the recipe) + * is killed by the {@link Player} + * + * @return The integer chance (0-100%) {@link SlimefunItem} has to drop. + */ + int getMobDropChance(); + +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/RechargeableHelper.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/RechargeableHelper.java index 29f6c8180..97aa0dc8a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/RechargeableHelper.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/RechargeableHelper.java @@ -14,6 +14,7 @@ import io.github.thebusybiscuit.cscorelib2.chat.ChatColors; import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.utils.PatternUtils; +import net.md_5.bungee.api.ChatColor; /** * This is just a simple helper class to provide static methods to the {@link Rechargeable} @@ -26,9 +27,9 @@ import io.github.thebusybiscuit.slimefun4.utils.PatternUtils; */ final class RechargeableHelper { - private static final NamespacedKey CHARGE_KEY = new NamespacedKey(SlimefunPlugin.instance, "item_charge"); + private static final NamespacedKey CHARGE_KEY = new NamespacedKey(SlimefunPlugin.instance(), "item_charge"); private static final String LORE_PREFIX = ChatColors.color("&8\u21E8 &e\u26A1 &7"); - private static final Pattern REGEX = Pattern.compile(ChatColors.color("(&c&o)?" + LORE_PREFIX) + "[0-9\\.]+ \\/ [0-9\\.]+ J"); + private static final Pattern REGEX = Pattern.compile(ChatColors.color("(&c&o)?" + LORE_PREFIX) + "[0-9.]+ / [0-9.]+ J"); private RechargeableHelper() {} @@ -69,7 +70,8 @@ final class RechargeableHelper { if (meta.hasLore()) { for (String line : meta.getLore()) { if (REGEX.matcher(line).matches()) { - return Float.parseFloat(PatternUtils.SLASH_SEPARATOR.split(line)[0].replace(LORE_PREFIX, "")); + String data = ChatColor.stripColor(PatternUtils.SLASH_SEPARATOR.split(line)[0].replace(LORE_PREFIX, "")); + return Float.parseFloat(data); } } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SlimefunCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SlimefunCommand.java index e13771812..632e61ecb 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SlimefunCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SlimefunCommand.java @@ -6,6 +6,7 @@ import java.util.List; import java.util.Map; import java.util.stream.Collectors; +import org.apache.commons.lang.Validate; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -14,7 +15,7 @@ import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerCommandPreprocessEvent; import io.github.thebusybiscuit.cscorelib2.chat.ChatColors; -import io.github.thebusybiscuit.slimefun4.core.commands.subcommands.Commands; +import io.github.thebusybiscuit.slimefun4.core.commands.subcommands.SlimefunSubCommands; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; /** @@ -25,6 +26,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; */ public class SlimefunCommand implements CommandExecutor, Listener { + private boolean registered = false; private final SlimefunPlugin plugin; private final List commands = new LinkedList<>(); private final Map commandUsage = new HashMap<>(); @@ -40,11 +42,14 @@ public class SlimefunCommand implements CommandExecutor, Listener { } public void register() { + Validate.isTrue(!registered, "Slimefun's subcommands have already been registered!"); + + registered = true; plugin.getServer().getPluginManager().registerEvents(this, plugin); plugin.getCommand("slimefun").setExecutor(this); plugin.getCommand("slimefun").setTabCompleter(new SlimefunTabCompleter(this)); - Commands.addCommands(this, commands); + commands.addAll(SlimefunSubCommands.getAllCommands(this)); } public SlimefunPlugin getPlugin() { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/Commands.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SlimefunSubCommands.java similarity index 68% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/Commands.java rename to src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SlimefunSubCommands.java index 192ef7026..0d337f1f4 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/Commands.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SlimefunSubCommands.java @@ -1,18 +1,28 @@ package io.github.thebusybiscuit.slimefun4.core.commands.subcommands; import java.util.Collection; +import java.util.LinkedList; +import java.util.List; import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand; import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; -public final class Commands { +/** + * This class holds the implementations of every {@link SubCommand}. + * The implementations themselves are package-private, this class only provides + * a static setup method + * + * @author TheBusyBiscuit + * + */ +public final class SlimefunSubCommands { - private Commands() { - } + private SlimefunSubCommands() {} - public static void addCommands(SlimefunCommand cmd, Collection commands) { + public static Collection getAllCommands(SlimefunCommand cmd) { SlimefunPlugin plugin = cmd.getPlugin(); + List commands = new LinkedList<>(); commands.add(new HelpCommand(plugin, cmd)); commands.add(new VersionsCommand(plugin, cmd)); @@ -27,5 +37,7 @@ public final class Commands { commands.add(new SearchCommand(plugin, cmd)); commands.add(new DebugFishCommand(plugin, cmd)); commands.add(new BackpackCommand(plugin, cmd)); + + return commands; } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/VersionsCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/VersionsCommand.java index 386d7ccbc..2ca581eff 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/VersionsCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/VersionsCommand.java @@ -2,17 +2,17 @@ package io.github.thebusybiscuit.slimefun4.core.commands.subcommands; import java.util.Collection; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.command.CommandSender; -import org.bukkit.command.ConsoleCommandSender; -import org.bukkit.plugin.Plugin; - import io.github.thebusybiscuit.cscorelib2.chat.ChatColors; import io.github.thebusybiscuit.cscorelib2.reflection.ReflectionUtils; import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand; import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.command.CommandSender; +import org.bukkit.command.ConsoleCommandSender; +import org.bukkit.plugin.Plugin; +import io.papermc.lib.PaperLib; class VersionsCommand extends SubCommand { @@ -33,13 +33,19 @@ class VersionsCommand extends SubCommand { @Override public void onExecute(CommandSender sender, String[] args) { if (sender.hasPermission("slimefun.command.versions") || sender instanceof ConsoleCommandSender) { - sender.sendMessage(ChatColors.color("&a" + Bukkit.getName() + " &2" + ReflectionUtils.getVersion())); + // After all these years... Spigot still displays as "CraftBukkit" + // so we will just fix this inconsistency for them :) + String serverSoftware = PaperLib.isSpigot() && !PaperLib.isPaper() ? "Spigot" : Bukkit.getName(); + sender.sendMessage(ChatColors.color("&a" + serverSoftware + " &2" + ReflectionUtils.getVersion())); sender.sendMessage(""); sender.sendMessage(ChatColors.color("&aCS-CoreLib &2v" + SlimefunPlugin.getCSCoreLibVersion())); sender.sendMessage(ChatColors.color("&aSlimefun &2v" + SlimefunPlugin.getVersion())); + if (SlimefunPlugin.getMetricsService().getVersion() != null) + sender.sendMessage(ChatColors.color("&aMetrics: &2#" + SlimefunPlugin.getMetricsService().getVersion() + ')')); + if (SlimefunPlugin.getRegistry().isBackwardsCompatible()) { - sender.sendMessage(ChatColor.YELLOW + "Backwards compatiblity enabled!"); + sender.sendMessage(ChatColor.YELLOW + "Backwards compatibility enabled!"); } sender.sendMessage(""); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/ContributorsMenu.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/ContributorsMenu.java index 2dd9ce001..3b89ff019 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/ContributorsMenu.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/ContributorsMenu.java @@ -60,13 +60,19 @@ final class ContributorsMenu { menu.addItem(46, ChestMenuUtils.getPreviousButton(p, page + 1, pages)); menu.addMenuClickHandler(46, (pl, slot, item, action) -> { - if (page > 0) open(pl, page - 1); + if (page > 0) { + open(pl, page - 1); + } + return false; }); menu.addItem(52, ChestMenuUtils.getNextButton(p, page + 1, pages)); menu.addMenuClickHandler(52, (pl, slot, item, action) -> { - if (page + 1 < pages) open(pl, page + 1); + if (page + 1 < pages) { + open(pl, page + 1); + } + return false; }); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/FireworksOption.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/FireworksOption.java index e6ac96373..9563e42f6 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/FireworksOption.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/FireworksOption.java @@ -16,12 +16,12 @@ class FireworksOption implements SlimefunGuideOption { @Override public SlimefunAddon getAddon() { - return SlimefunPlugin.instance; + return SlimefunPlugin.instance(); } @Override public NamespacedKey getKey() { - return new NamespacedKey(SlimefunPlugin.instance, "research_fireworks"); + return new NamespacedKey(SlimefunPlugin.instance(), "research_fireworks"); } @Override diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/GuideLayoutOption.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/GuideLayoutOption.java index 16173c9ba..e6fe73e3a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/GuideLayoutOption.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/GuideLayoutOption.java @@ -22,12 +22,12 @@ class GuideLayoutOption implements SlimefunGuideOption { @Override public SlimefunAddon getAddon() { - return SlimefunPlugin.instance; + return SlimefunPlugin.instance(); } @Override public NamespacedKey getKey() { - return new NamespacedKey(SlimefunPlugin.instance, "guide_layout"); + return new NamespacedKey(SlimefunPlugin.instance(), "guide_layout"); } @Override diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/PlayerLanguageOption.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/PlayerLanguageOption.java index ffd660b1a..6d55090a2 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/PlayerLanguageOption.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/PlayerLanguageOption.java @@ -23,7 +23,7 @@ class PlayerLanguageOption implements SlimefunGuideOption { @Override public SlimefunAddon getAddon() { - return SlimefunPlugin.instance; + return SlimefunPlugin.instance(); } @Override @@ -93,7 +93,7 @@ class PlayerLanguageOption implements SlimefunGuideOption { String defaultLanguageString = SlimefunPlugin.getLocalization().getMessage(p, "languages.default"); menu.addItem(9, new CustomItem(defaultLanguage.getItem(), ChatColor.GRAY + defaultLanguageString + ChatColor.DARK_GRAY + " (" + defaultLanguage.getName(p) + ")", "", "&7\u21E8 &e" + SlimefunPlugin.getLocalization().getMessage(p, "guide.languages.select-default")), (pl, i, item, action) -> { - SlimefunPlugin.instance.getServer().getPluginManager().callEvent(new PlayerLanguageChangeEvent(pl, SlimefunPlugin.getLocalization().getLanguage(pl), defaultLanguage)); + SlimefunPlugin.instance().getServer().getPluginManager().callEvent(new PlayerLanguageChangeEvent(pl, SlimefunPlugin.getLocalization().getLanguage(pl), defaultLanguage)); setSelectedOption(pl, guide, null); SlimefunPlugin.getLocalization().sendMessage(pl, "guide.languages.updated", msg -> msg.replace("%lang%", defaultLanguageString)); @@ -106,7 +106,7 @@ class PlayerLanguageOption implements SlimefunGuideOption { for (Language language : SlimefunPlugin.getLocalization().getLanguages()) { menu.addItem(slot, new CustomItem(language.getItem(), ChatColor.GREEN + language.getName(p), "&b" + SlimefunPlugin.getLocalization().getProgress(language) + '%', "", "&7\u21E8 &e" + SlimefunPlugin.getLocalization().getMessage(p, "guide.languages.select")), (pl, i, item, action) -> { - SlimefunPlugin.instance.getServer().getPluginManager().callEvent(new PlayerLanguageChangeEvent(pl, SlimefunPlugin.getLocalization().getLanguage(pl), language)); + SlimefunPlugin.instance().getServer().getPluginManager().callEvent(new PlayerLanguageChangeEvent(pl, SlimefunPlugin.getLocalization().getLanguage(pl), language)); setSelectedOption(pl, guide, language.getId()); String name = language.getName(pl); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/EntityInteractHandler.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/EntityInteractHandler.java index 5f35f94dd..919275888 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/EntityInteractHandler.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/EntityInteractHandler.java @@ -6,7 +6,7 @@ import org.bukkit.event.player.PlayerInteractAtEntityEvent; import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemStack; -import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; import me.mrCookieSlime.Slimefun.Objects.handlers.ItemHandler; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/EntityKillHandler.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/EntityKillHandler.java index adaa86513..919da18a9 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/EntityKillHandler.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/EntityKillHandler.java @@ -5,7 +5,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.inventory.ItemStack; -import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; import me.mrCookieSlime.Slimefun.Objects.handlers.ItemHandler; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/ItemConsumptionHandler.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/ItemConsumptionHandler.java index 6599fc4b9..3e7756cf8 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/ItemConsumptionHandler.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/ItemConsumptionHandler.java @@ -4,9 +4,9 @@ import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerItemConsumeEvent; import org.bukkit.inventory.ItemStack; +import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; import io.github.thebusybiscuit.slimefun4.implementation.items.food.DietCookie; import io.github.thebusybiscuit.slimefun4.implementation.items.food.FortuneCookie; -import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; import me.mrCookieSlime.Slimefun.Objects.handlers.ItemHandler; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/ItemUseHandler.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/ItemUseHandler.java index ebc661018..cccbb295c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/ItemUseHandler.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/ItemUseHandler.java @@ -3,7 +3,7 @@ package io.github.thebusybiscuit.slimefun4.core.handlers; import org.bukkit.entity.Player; import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent; -import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; import me.mrCookieSlime.Slimefun.Objects.handlers.ItemHandler; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/multiblocks/MultiBlockMachine.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/multiblocks/MultiBlockMachine.java index a4fd5fb55..78ec599a1 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/multiblocks/MultiBlockMachine.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/multiblocks/MultiBlockMachine.java @@ -9,6 +9,7 @@ import org.bukkit.Material; import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; +import org.bukkit.block.BlockState; import org.bukkit.block.Chest; import org.bukkit.block.data.type.Dispenser; import org.bukkit.entity.Player; @@ -22,6 +23,7 @@ import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable; import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem; import io.github.thebusybiscuit.slimefun4.core.handlers.MultiBlockInteractionHandler; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; +import io.papermc.lib.PaperLib; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; @@ -52,6 +54,16 @@ public abstract class MultiBlockMachine extends SlimefunItem implements NotPlace this.displayRecipes = new ArrayList<>(); this.displayRecipes.addAll(Arrays.asList(machineRecipes)); this.multiblock = new MultiBlock(this, convertItemStacksToMaterial(recipe), trigger); + + registerDefaultRecipes(displayRecipes); + } + + public MultiBlockMachine(Category category, SlimefunItemStack item, ItemStack[] recipe, BlockFace trigger) { + this(category, item, recipe, new ItemStack[0], trigger); + } + + protected void registerDefaultRecipes(List recipes) { + // Override this method to register some default recipes } public List getRecipes() { @@ -153,10 +165,14 @@ public abstract class MultiBlockMachine extends SlimefunItem implements NotPlace if (id != null && id.equals("OUTPUT_CHEST")) { // Found the output chest! Now, let's check if we can fit the product in it. - Inventory inv = ((Chest) potentialOutput.getState()).getInventory(); + BlockState state = PaperLib.getBlockState(potentialOutput, false).getState(); - if (InvUtils.fits(inv, output)) { - return inv; + if (state instanceof Chest) { + Inventory inv = ((Chest) state).getInventory(); + + if (InvUtils.fits(inv, output)) { + return inv; + } } } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoNet.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoNet.java index d38d1a675..f8df07d58 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoNet.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoNet.java @@ -1,6 +1,5 @@ package io.github.thebusybiscuit.slimefun4.core.networks.cargo; -import java.util.Deque; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; @@ -8,23 +7,18 @@ import java.util.List; import java.util.Map; import java.util.Optional; import java.util.Set; -import java.util.concurrent.atomic.AtomicReference; import java.util.logging.Level; import org.bukkit.Location; import org.bukkit.block.Block; -import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; import io.github.thebusybiscuit.slimefun4.api.network.Network; import io.github.thebusybiscuit.slimefun4.api.network.NetworkComponent; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.utils.holograms.SimpleHologram; -import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; import me.mrCookieSlime.Slimefun.api.BlockStorage; import me.mrCookieSlime.Slimefun.api.Slimefun; -import me.mrCookieSlime.Slimefun.api.inventory.DirtyChestMenu; /** * The {@link CargoNet} is a type of {@link Network} which deals with {@link ItemStack} transportation. @@ -49,7 +43,7 @@ public class CargoNet extends ChestTerminalNetwork { private final Set inputNodes = new HashSet<>(); private final Set outputNodes = new HashSet<>(); - private final Map roundRobin = new HashMap<>(); + protected final Map roundRobin = new HashMap<>(); private int tickDelayThreshold = 0; public static CargoNet getNetworkFromLocation(Location l) { @@ -182,7 +176,9 @@ public class CargoNet extends ChestTerminalNetwork { } SlimefunPlugin.getProfiler().scheduleEntries(1 + inputNodes.size()); - Slimefun.runSync(() -> run(inputs, outputs, chestTerminalInputs, chestTerminalOutputs)); + + CargoNetworkTask runnable = new CargoNetworkTask(this, inputs, outputs, chestTerminalInputs, chestTerminalOutputs); + Slimefun.runSync(runnable); } } @@ -240,135 +236,6 @@ public class CargoNet extends ChestTerminalNetwork { return output; } - private void run(Map inputs, Map> outputs, Set chestTerminalInputs, Set chestTerminalOutputs) { - long timestamp = System.nanoTime(); - - // Chest Terminal Code - if (SlimefunPlugin.getThirdPartySupportService().isChestTerminalInstalled()) { - handleItemRequests(chestTerminalInputs, chestTerminalOutputs); - } - - // All operations happen here: Everything gets iterated from the Input Nodes. - // (Apart from ChestTerminal Buses) - for (Map.Entry entry : inputs.entrySet()) { - long nodeTimestamp = System.nanoTime(); - Location input = entry.getKey(); - Optional attachedBlock = getAttachedBlock(input.getBlock()); - - if (attachedBlock.isPresent()) { - routeItems(input, attachedBlock.get(), entry.getValue(), outputs); - } - - // This will prevent this timings from showing up for the Cargo Manager - timestamp += SlimefunPlugin.getProfiler().closeEntry(entry.getKey(), SlimefunItems.CARGO_INPUT_NODE.getItem(), nodeTimestamp); - } - - // Chest Terminal Code - if (SlimefunPlugin.getThirdPartySupportService().isChestTerminalInstalled()) { - updateTerminals(chestTerminalInputs); - } - - // Submit a timings report - SlimefunPlugin.getProfiler().closeEntry(regulator, SlimefunItems.CARGO_MANAGER.getItem(), timestamp); - } - - private void routeItems(Location inputNode, Block inputTarget, int frequency, Map> outputNodes) { - AtomicReference inventory = new AtomicReference<>(); - ItemStackAndInteger slot = CargoUtils.withdraw(inputNode.getBlock(), inputTarget, inventory); - - if (slot == null) { - return; - } - - ItemStack stack = slot.getItem(); - int previousSlot = slot.getInt(); - List outputs = outputNodes.get(frequency); - - if (outputs != null) { - stack = distributeItem(stack, inputNode, outputs); - } - - if (stack != null) { - Object inputInventory = inventory.get(); - - if (inputInventory instanceof DirtyChestMenu) { - DirtyChestMenu menu = (DirtyChestMenu) inputInventory; - - if (menu.getItemInSlot(previousSlot) == null) { - menu.replaceExistingItem(previousSlot, stack); - } - else { - inputTarget.getWorld().dropItem(inputTarget.getLocation().add(0, 1, 0), stack); - } - } - - if (inputInventory instanceof Inventory) { - Inventory inv = (Inventory) inputInventory; - - if (inv.getItem(previousSlot) == null) { - inv.setItem(previousSlot, stack); - } - else { - inputTarget.getWorld().dropItem(inputTarget.getLocation().add(0, 1, 0), stack); - } - } - } - } - - private ItemStack distributeItem(ItemStack stack, Location inputNode, List outputNodes) { - ItemStack item = stack; - - Deque destinations = new LinkedList<>(outputNodes); - Config cfg = BlockStorage.getLocationInfo(inputNode); - boolean roundrobin = "true".equals(cfg.getString("round-robin")); - - if (roundrobin) { - roundRobinSort(inputNode, destinations); - } - - for (Location output : destinations) { - Optional target = getAttachedBlock(output.getBlock()); - - if (target.isPresent()) { - item = CargoUtils.insert(output.getBlock(), target.get(), item); - - if (item == null) { - break; - } - } - } - - return item; - } - - /** - * This method sorts a given {@link Deque} of output node locations using a semi-accurate - * round-robin method. - * - * @param inputNode - * The {@link Location} of the input node - * @param outputNodes - * A {@link Deque} of {@link Location Locations} of the output nodes - */ - private void roundRobinSort(Location inputNode, Deque outputNodes) { - int index = roundRobin.getOrDefault(inputNode, 0); - - if (index < outputNodes.size()) { - // Not ideal but actually not bad performance-wise over more elegant alternatives - for (int i = 0; i < index; i++) { - Location temp = outputNodes.removeFirst(); - outputNodes.add(temp); - } - - index++; - } - else { - index = 1; - } - - roundRobin.put(inputNode, index); - } - /** * This method returns the frequency a given node is set to. * Should there be an {@link Exception} to this method it will fall back to zero in diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoNetworkTask.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoNetworkTask.java new file mode 100644 index 000000000..eec1652df --- /dev/null +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoNetworkTask.java @@ -0,0 +1,181 @@ +package io.github.thebusybiscuit.slimefun4.core.networks.cargo; + +import java.util.Deque; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; + +import org.bukkit.Location; +import org.bukkit.block.Block; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; + +import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; +import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; +import me.mrCookieSlime.Slimefun.api.BlockStorage; +import me.mrCookieSlime.Slimefun.api.inventory.DirtyChestMenu; + +/** + * The {@link CargoNetworkTask} is the actual {@link Runnable} responsible for moving {@link ItemStack ItemStacks} + * around the {@link CargoNet}. + * + * Inbefore this was just a method in the {@link CargoNet} class. + * However for aesthetic reasons but mainly to prevent the Cargo Task from showing up as + * "lambda:xyz-123" in timing reports... this was moved. + * + * @see CargoNet + * @see CargoUtils + * @see ChestTerminalNetwork + * + */ +class CargoNetworkTask implements Runnable { + + private final CargoNet network; + private final Map inventories = new HashMap<>(); + + private final Map inputs; + private final Map> outputs; + + private final Set chestTerminalInputs; + private final Set chestTerminalOutputs; + + CargoNetworkTask(CargoNet network, Map inputs, Map> outputs, Set chestTerminalInputs, Set chestTerminalOutputs) { + this.network = network; + + this.inputs = inputs; + this.outputs = outputs; + this.chestTerminalInputs = chestTerminalInputs; + this.chestTerminalOutputs = chestTerminalOutputs; + } + + @Override + public void run() { + long timestamp = System.nanoTime(); + + // Chest Terminal Code + if (SlimefunPlugin.getThirdPartySupportService().isChestTerminalInstalled()) { + network.handleItemRequests(inventories, chestTerminalInputs, chestTerminalOutputs); + } + + // All operations happen here: Everything gets iterated from the Input Nodes. + // (Apart from ChestTerminal Buses) + for (Map.Entry entry : inputs.entrySet()) { + long nodeTimestamp = System.nanoTime(); + Location input = entry.getKey(); + Optional attachedBlock = network.getAttachedBlock(input); + + attachedBlock.ifPresent(block -> routeItems(input, block, entry.getValue(), outputs)); + + // This will prevent this timings from showing up for the Cargo Manager + timestamp += SlimefunPlugin.getProfiler().closeEntry(entry.getKey(), SlimefunItems.CARGO_INPUT_NODE.getItem(), nodeTimestamp); + } + + // Chest Terminal Code + if (SlimefunPlugin.getThirdPartySupportService().isChestTerminalInstalled()) { + network.updateTerminals(chestTerminalInputs); + } + + // Submit a timings report + SlimefunPlugin.getProfiler().closeEntry(network.getRegulator(), SlimefunItems.CARGO_MANAGER.getItem(), timestamp); + } + + private void routeItems(Location inputNode, Block inputTarget, int frequency, Map> outputNodes) { + ItemStackAndInteger slot = CargoUtils.withdraw(inventories, inputNode.getBlock(), inputTarget); + + if (slot == null) { + return; + } + + ItemStack stack = slot.getItem(); + int previousSlot = slot.getInt(); + List destinations = outputNodes.get(frequency); + + if (destinations != null) { + stack = distributeItem(stack, inputNode, destinations); + } + + if (stack != null) { + Inventory inv = inventories.get(inputTarget.getLocation()); + + if (inv != null) { + if (inv.getItem(previousSlot) == null) { + inv.setItem(previousSlot, stack); + } + else { + inputTarget.getWorld().dropItem(inputTarget.getLocation().add(0, 1, 0), stack); + } + } + else { + DirtyChestMenu menu = CargoUtils.getChestMenu(inputTarget); + + if (menu != null) { + if (menu.getItemInSlot(previousSlot) == null) { + menu.replaceExistingItem(previousSlot, stack); + } + else { + inputTarget.getWorld().dropItem(inputTarget.getLocation().add(0, 1, 0), stack); + } + } + } + } + } + + private ItemStack distributeItem(ItemStack stack, Location inputNode, List outputNodes) { + ItemStack item = stack; + + Deque destinations = new LinkedList<>(outputNodes); + Config cfg = BlockStorage.getLocationInfo(inputNode); + boolean roundrobin = "true".equals(cfg.getString("round-robin")); + + if (roundrobin) { + roundRobinSort(inputNode, destinations); + } + + for (Location output : destinations) { + Optional target = network.getAttachedBlock(output); + + if (target.isPresent()) { + item = CargoUtils.insert(inventories, output.getBlock(), target.get(), item); + + if (item == null) { + break; + } + } + } + + return item; + } + + /** + * This method sorts a given {@link Deque} of output node locations using a semi-accurate + * round-robin method. + * + * @param inputNode + * The {@link Location} of the input node + * @param outputNodes + * A {@link Deque} of {@link Location Locations} of the output nodes + */ + private void roundRobinSort(Location inputNode, Deque outputNodes) { + int index = network.roundRobin.getOrDefault(inputNode, 0); + + if (index < outputNodes.size()) { + // Not ideal but actually not bad performance-wise over more elegant alternatives + for (int i = 0; i < index; i++) { + Location temp = outputNodes.removeFirst(); + outputNodes.add(temp); + } + + index++; + } + else { + index = 1; + } + + network.roundRobin.put(inputNode, index); + } + +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoUtils.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoUtils.java index 0d4426c94..b13b43d67 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoUtils.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoUtils.java @@ -1,10 +1,9 @@ package io.github.thebusybiscuit.slimefun4.core.networks.cargo; -import java.util.LinkedList; -import java.util.List; -import java.util.concurrent.atomic.AtomicReference; +import java.util.Map; import java.util.logging.Level; +import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Tag; import org.bukkit.block.Block; @@ -20,6 +19,7 @@ import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; import io.github.thebusybiscuit.slimefun4.utils.itemstack.ItemStackWrapper; +import io.papermc.lib.PaperLib; import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; import me.mrCookieSlime.Slimefun.api.BlockStorage; import me.mrCookieSlime.Slimefun.api.Slimefun; @@ -83,15 +83,23 @@ final class CargoUtils { return false; } - static ItemStack withdraw(Block node, Block target, ItemStack template) { + static ItemStack withdraw(Map inventories, Block node, Block target, ItemStack template) { DirtyChestMenu menu = getChestMenu(target); if (menu == null) { if (hasInventory(target)) { - BlockState state = target.getState(); + Inventory inventory = inventories.get(target.getLocation()); + + if (inventory != null) { + return withdrawFromVanillaInventory(node, template, inventory); + } + + BlockState state = PaperLib.getBlockState(target, false).getState(); if (state instanceof InventoryHolder) { - return withdrawFromVanillaInventory(node, template, ((InventoryHolder) state).getInventory()); + inventory = ((InventoryHolder) state).getInventory(); + inventories.put(target.getLocation(), inventory); + return withdrawFromVanillaInventory(node, template, inventory); } } @@ -135,10 +143,10 @@ final class CargoUtils { ItemStackWrapper wrapper = new ItemStackWrapper(template); for (int slot = minSlot; slot < maxSlot; slot++) { - // Changes to this ItemStack are synchronized with the Item in the Inventory + // Changes to these ItemStacks are synchronized with the Item in the Inventory ItemStack itemInSlot = contents[slot]; - if (SlimefunUtils.isItemSimilar(itemInSlot, wrapper, true) && matchesFilter(node, itemInSlot)) { + if (SlimefunUtils.isItemSimilar(itemInSlot, wrapper, true, false) && matchesFilter(node, itemInSlot)) { if (itemInSlot.getAmount() > template.getAmount()) { itemInSlot.setAmount(itemInSlot.getAmount() - template.getAmount()); return template; @@ -154,7 +162,7 @@ final class CargoUtils { return null; } - static ItemStackAndInteger withdraw(Block node, Block target, AtomicReference inventory) { + static ItemStackAndInteger withdraw(Map inventories, Block node, Block target) { DirtyChestMenu menu = getChestMenu(target); if (menu != null) { @@ -163,45 +171,55 @@ final class CargoUtils { if (matchesFilter(node, is)) { menu.replaceExistingItem(slot, null); - inventory.set(menu); return new ItemStackAndInteger(is, slot); } } } else if (hasInventory(target)) { - BlockState state = target.getState(); + Inventory inventory = inventories.get(target.getLocation()); + + if (inventory != null) { + return withdrawFromVanillaInventory(node, inventory); + } + + BlockState state = PaperLib.getBlockState(target, false).getState(); if (state instanceof InventoryHolder) { - Inventory inv = ((InventoryHolder) state).getInventory(); - - ItemStack[] contents = inv.getContents(); - int minSlot = 0; - int maxSlot = contents.length; - - if (inv instanceof FurnaceInventory) { - minSlot = 2; - maxSlot = 3; - } - else if (inv instanceof BrewerInventory) { - maxSlot = 3; - } - - for (int slot = minSlot; slot < maxSlot; slot++) { - ItemStack is = contents[slot]; - - if (matchesFilter(node, is)) { - inv.setItem(slot, null); - inventory.set(inv); - return new ItemStackAndInteger(is, slot); - } - } + inventory = ((InventoryHolder) state).getInventory(); + inventories.put(target.getLocation(), inventory); + return withdrawFromVanillaInventory(node, inventory); } } return null; } - static ItemStack insert(Block node, Block target, ItemStack stack) { + private static ItemStackAndInteger withdrawFromVanillaInventory(Block node, Inventory inv) { + ItemStack[] contents = inv.getContents(); + int minSlot = 0; + int maxSlot = contents.length; + + if (inv instanceof FurnaceInventory) { + minSlot = 2; + maxSlot = 3; + } + else if (inv instanceof BrewerInventory) { + maxSlot = 3; + } + + for (int slot = minSlot; slot < maxSlot; slot++) { + ItemStack is = contents[slot]; + + if (matchesFilter(node, is)) { + inv.setItem(slot, null); + return new ItemStackAndInteger(is, slot); + } + } + + return null; + } + + static ItemStack insert(Map inventories, Block node, Block target, ItemStack stack) { if (!matchesFilter(node, stack)) { return stack; } @@ -210,10 +228,18 @@ final class CargoUtils { if (menu == null) { if (hasInventory(target)) { - BlockState state = target.getState(); + Inventory inventory = inventories.get(target.getLocation()); + + if (inventory != null) { + return insertIntoVanillaInventory(stack, inventory); + } + + BlockState state = PaperLib.getBlockState(target, false).getState(); if (state instanceof InventoryHolder) { - return insertIntoVanillaInventory(stack, ((InventoryHolder) state).getInventory()); + inventory = ((InventoryHolder) state).getInventory(); + inventories.put(target.getLocation(), inventory); + return insertIntoVanillaInventory(stack, inventory); } } @@ -222,8 +248,9 @@ final class CargoUtils { ItemStackWrapper wrapper = new ItemStackWrapper(stack); - for (int slot : menu.getPreset().getSlotsAccessedByItemTransport(menu, ItemTransportFlow.INSERT, stack)) { + for (int slot : menu.getPreset().getSlotsAccessedByItemTransport(menu, ItemTransportFlow.INSERT, wrapper)) { ItemStack itemInSlot = menu.getItemInSlot(slot); + if (itemInSlot == null) { menu.replaceExistingItem(slot, stack); return null; @@ -251,7 +278,7 @@ final class CargoUtils { return stack; } - static ItemStack insertIntoVanillaInventory(ItemStack stack, Inventory inv) { + private static ItemStack insertIntoVanillaInventory(ItemStack stack, Inventory inv) { ItemStack[] contents = inv.getContents(); int minSlot = 0; int maxSlot = contents.length; @@ -312,9 +339,6 @@ final class CargoUtils { } itemInSlot.setAmount(Math.min(amount, maxStackSize)); - // Setting item in inventory will clone the ItemStack - inv.setItem(slot, itemInSlot); - return stack; } } @@ -359,9 +383,10 @@ final class CargoUtils { } // Store the returned Config instance to avoid heavy calls - Config blockInfo = BlockStorage.getLocationInfo(block.getLocation()); - String id = blockInfo.getString("id"); + Config blockData = BlockStorage.getLocationInfo(block.getLocation()); + String id = blockData.getString("id"); + // Cargo Output nodes have no filter actually if (id.equals("CARGO_NODE_OUTPUT")) { return true; } @@ -373,43 +398,9 @@ final class CargoUtils { return false; } - boolean lore = "true".equals(blockInfo.getString("filter-lore")); - ItemStackWrapper wrapper = new ItemStackWrapper(item); - - if ("whitelist".equals(blockInfo.getString("filter-type"))) { - List templateItems = new LinkedList<>(); - - for (int slot : FILTER_SLOTS) { - ItemStack template = menu.getItemInSlot(slot); - - if (template != null) { - templateItems.add(template); - } - } - - if (templateItems.isEmpty()) { - return false; - } - - for (ItemStack stack : templateItems) { - if (SlimefunUtils.isItemSimilar(wrapper, stack, lore)) { - return true; - } - } - - return false; - } - else { - for (int slot : FILTER_SLOTS) { - ItemStack itemInSlot = menu.getItemInSlot(slot); - - if (itemInSlot != null && SlimefunUtils.isItemSimilar(wrapper, itemInSlot, lore, false)) { - return false; - } - } - - return true; - } + boolean lore = "true".equals(blockData.getString("filter-lore")); + boolean allowByDefault = !"whitelist".equals(blockData.getString("filter-type")); + return matchesFilterList(item, menu, lore, allowByDefault); } catch (Exception x) { Slimefun.getLogger().log(Level.SEVERE, x, () -> "An Exception occurred while trying to filter items for a Cargo Node (" + id + ") at " + new BlockPosition(block)); @@ -417,6 +408,27 @@ final class CargoUtils { } } + private static boolean matchesFilterList(ItemStack item, BlockMenu menu, boolean respectLore, boolean defaultValue) { + ItemStackWrapper wrapper = null; + + for (int slot : FILTER_SLOTS) { + ItemStack stack = menu.getItemInSlot(slot); + + if (stack != null) { + if (wrapper == null) { + // Only create this as needed to save performance + wrapper = new ItemStackWrapper(item); + } + + if (SlimefunUtils.isItemSimilar(stack, wrapper, respectLore, false)) { + return !defaultValue; + } + } + } + + return defaultValue; + } + /** * Get the whitelist/blacklist slots in a Cargo Input Node. If you wish to access the items * in the cargo (without hardcoding the slots in case of change) then you can use this method. diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ChestTerminalNetwork.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ChestTerminalNetwork.java index 2edafc0e7..d7d1a0cfe 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ChestTerminalNetwork.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ChestTerminalNetwork.java @@ -12,7 +12,7 @@ import java.util.Map; import java.util.Optional; import java.util.Queue; import java.util.Set; -import java.util.concurrent.atomic.AtomicReference; +import java.util.logging.Level; import org.bukkit.Location; import org.bukkit.Material; @@ -32,9 +32,11 @@ import io.github.thebusybiscuit.slimefun4.api.network.Network; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.papermc.lib.PaperLib; import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; import me.mrCookieSlime.Slimefun.api.BlockStorage; +import me.mrCookieSlime.Slimefun.api.Slimefun; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; import me.mrCookieSlime.Slimefun.api.inventory.DirtyChestMenu; import me.mrCookieSlime.Slimefun.api.inventory.UniversalBlockMenu; @@ -69,40 +71,43 @@ abstract class ChestTerminalNetwork extends Network { super(SlimefunPlugin.getNetworkManager(), regulator); } - protected Optional getAttachedBlock(Block block) { - if (block.getType() == Material.PLAYER_WALL_HEAD) { - BlockFace cached = connectorCache.get(block.getLocation()); + protected Optional getAttachedBlock(Location l) { + if (l.getWorld().isChunkLoaded(l.getBlockX() >> 4, l.getBlockZ() >> 4)) { + Block block = l.getBlock(); - if (cached != null) { - return Optional.of(block.getRelative(cached)); + if (block.getType() == Material.PLAYER_WALL_HEAD) { + BlockFace cached = connectorCache.get(l); + + if (cached != null) { + return Optional.of(block.getRelative(cached)); + } + + BlockFace face = ((Directional) block.getBlockData()).getFacing().getOppositeFace(); + connectorCache.put(l, face); + return Optional.of(block.getRelative(face)); } - - BlockFace face = ((Directional) block.getBlockData()).getFacing().getOppositeFace(); - connectorCache.put(block.getLocation(), face); - return Optional.of(block.getRelative(face)); } return Optional.empty(); } - protected void handleItemRequests(Set providers, Set destinations) { - collectImportRequests(); - collectExportRequests(); + protected void handleItemRequests(Map inventories, Set providers, Set destinations) { + collectImportRequests(inventories); + collectExportRequests(inventories); collectTerminalRequests(); Iterator iterator = itemRequests.iterator(); while (iterator.hasNext()) { ItemRequest request = iterator.next(); + BlockMenu menu = BlockStorage.getInventory(request.getTerminal()); - if (terminals.contains(request.getTerminal()) || imports.contains(request.getTerminal()) || exports.contains(request.getTerminal())) { - BlockMenu menu = BlockStorage.getInventory(request.getTerminal()); - + if (menu != null) { switch (request.getDirection()) { case INSERT: - distributeInsertionRequest(request, menu, iterator, destinations); + distributeInsertionRequest(inventories, request, menu, iterator, destinations); break; case WITHDRAW: - collectExtractionRequest(request, menu, iterator, providers); + collectExtractionRequest(inventories, request, menu, iterator, providers); break; default: break; @@ -111,14 +116,14 @@ abstract class ChestTerminalNetwork extends Network { } } - private void distributeInsertionRequest(ItemRequest request, BlockMenu terminal, Iterator iterator, Set destinations) { + private void distributeInsertionRequest(Map inventories, ItemRequest request, BlockMenu terminal, Iterator iterator, Set destinations) { ItemStack item = request.getItem(); for (Location l : destinations) { - Optional target = getAttachedBlock(l.getBlock()); + Optional target = getAttachedBlock(l); if (target.isPresent()) { - item = CargoUtils.insert(l.getBlock(), target.get(), item); + item = CargoUtils.insert(inventories, l.getBlock(), target.get(), item); if (item == null) { terminal.replaceExistingItem(request.getSlot(), null); @@ -134,7 +139,7 @@ abstract class ChestTerminalNetwork extends Network { iterator.remove(); } - private void collectExtractionRequest(ItemRequest request, BlockMenu terminal, Iterator iterator, Set providers) { + private void collectExtractionRequest(Map inventories, ItemRequest request, BlockMenu terminal, Iterator iterator, Set providers) { int slot = request.getSlot(); ItemStack prevStack = terminal.getItemInSlot(slot); @@ -147,10 +152,10 @@ abstract class ChestTerminalNetwork extends Network { ItemStack item = request.getItem(); for (Location l : providers) { - Optional target = getAttachedBlock(l.getBlock()); + Optional target = getAttachedBlock(l); if (target.isPresent()) { - ItemStack is = CargoUtils.withdraw(l.getBlock(), target.get(), item); + ItemStack is = CargoUtils.withdraw(inventories, l.getBlock(), target.get(), item); if (is != null) { if (stack == null) { @@ -184,7 +189,7 @@ abstract class ChestTerminalNetwork extends Network { iterator.remove(); } - private void collectImportRequests() { + private void collectImportRequests(Map inventories) { SlimefunItem item = SlimefunItem.getByID("CT_IMPORT_BUS"); for (Location bus : imports) { @@ -192,10 +197,10 @@ abstract class ChestTerminalNetwork extends Network { BlockMenu menu = BlockStorage.getInventory(bus); if (menu.getItemInSlot(17) == null) { - Optional target = getAttachedBlock(bus.getBlock()); + Optional target = getAttachedBlock(bus); if (target.isPresent()) { - ItemStackAndInteger stack = CargoUtils.withdraw(bus.getBlock(), target.get(), new AtomicReference<>()); + ItemStackAndInteger stack = CargoUtils.withdraw(inventories, bus.getBlock(), target.get()); if (stack != null) { menu.replaceExistingItem(17, stack.getItem()); @@ -211,7 +216,7 @@ abstract class ChestTerminalNetwork extends Network { } } - private void collectExportRequests() { + private void collectExportRequests(Map inventories) { SlimefunItem item = SlimefunItem.getByID("CT_EXPORT_BUS"); for (Location bus : exports) { @@ -219,11 +224,9 @@ abstract class ChestTerminalNetwork extends Network { BlockMenu menu = BlockStorage.getInventory(bus); if (menu.getItemInSlot(17) != null) { - Optional target = getAttachedBlock(bus.getBlock()); + Optional target = getAttachedBlock(bus); - if (target.isPresent()) { - menu.replaceExistingItem(17, CargoUtils.insert(bus.getBlock(), target.get(), menu.getItemInSlot(17))); - } + target.ifPresent(block -> menu.replaceExistingItem(17, CargoUtils.insert(inventories, bus.getBlock(), block, menu.getItemInSlot(17)))); } if (menu.getItemInSlot(17) == null) { @@ -231,7 +234,10 @@ abstract class ChestTerminalNetwork extends Network { for (int slot : slots) { ItemStack template = menu.getItemInSlot(slot); - if (template != null) items.add(new CustomItem(template, 1)); + + if (template != null) { + items.add(new CustomItem(template, 1)); + } } if (!items.isEmpty()) { @@ -252,18 +258,13 @@ abstract class ChestTerminalNetwork extends Network { } private void collectTerminalRequests() { - SlimefunItem item = SlimefunItem.getByID("CHEST_TERMINAL"); - for (Location terminal : terminals) { - long timestamp = SlimefunPlugin.getProfiler().newEntry(); BlockMenu menu = BlockStorage.getInventory(terminal); ItemStack sendingItem = menu.getItemInSlot(TERMINAL_OUT_SLOT); if (sendingItem != null) { itemRequests.add(new ItemRequest(terminal, TERMINAL_OUT_SLOT, sendingItem, ItemTransportFlow.INSERT)); } - - SlimefunPlugin.getProfiler().closeEntry(terminal, item, timestamp); } } @@ -275,6 +276,16 @@ abstract class ChestTerminalNetwork extends Network { * A {@link Set} of providers to this {@link ChestTerminalNetwork} */ protected void updateTerminals(Set providers) { + if (terminals.isEmpty()) { + // Performance improvement - We don't need to compute items for + // Cargo networks without any Chest Terminals + return; + } + + // Timings will be slightly inaccurate here but most often people are gonna + // use no more than one terminal anyway, so this might be fine + long timestamp = SlimefunPlugin.getProfiler().newEntry(); + SlimefunItem item = SlimefunItem.getByID("CHEST_TERMINAL"); List items = findAvailableItems(providers); for (Location l : terminals) { @@ -291,6 +302,8 @@ abstract class ChestTerminalNetwork extends Network { int index = i + (TERMINAL_SLOTS.length * (page - 1)); updateTerminal(l, terminal, slot, index, items); } + + SlimefunPlugin.getProfiler().closeEntry(l, item, timestamp); } } @@ -324,7 +337,8 @@ abstract class ChestTerminalNetwork extends Network { terminal.replaceExistingItem(slot, stack); terminal.addMenuClickHandler(slot, (p, sl, is, action) -> { int amount = item.getInt() > item.getItem().getMaxStackSize() ? item.getItem().getMaxStackSize() : item.getInt(); - itemRequests.add(new ItemRequest(l, 44, new CustomItem(item.getItem(), action.isRightClicked() ? amount : 1), ItemTransportFlow.WITHDRAW)); + ItemStack requestedItem = new CustomItem(item.getItem(), action.isRightClicked() ? amount : 1); + itemRequests.add(new ItemRequest(l, 44, requestedItem, ItemTransportFlow.WITHDRAW)); return false; }); @@ -339,7 +353,7 @@ abstract class ChestTerminalNetwork extends Network { List items = new LinkedList<>(); for (Location l : providers) { - Optional block = getAttachedBlock(l.getBlock()); + Optional block = getAttachedBlock(l); if (block.isPresent()) { Block target = block.get(); @@ -353,17 +367,21 @@ abstract class ChestTerminalNetwork extends Network { } else if (BlockStorage.hasInventory(target)) { BlockMenu blockMenu = BlockStorage.getInventory(target); - Config cfg = BlockStorage.getLocationInfo(target.getLocation()); - if (cfg.getString("id").startsWith("BARREL_") && cfg.getString("storedItems") != null) { - gatherItemsFromBarrel(l, cfg, blockMenu, items); + if (blockMenu.getPreset().getID().startsWith("BARREL_")) { + Config cfg = BlockStorage.getLocationInfo(target.getLocation()); + String data = cfg.getString("storedItems"); + + if (data != null) { + gatherItemsFromBarrel(l, data, blockMenu, items); + } } else { handleWithdraw(blockMenu, items, l); } } else if (CargoUtils.hasInventory(target)) { - BlockState state = target.getState(); + BlockState state = PaperLib.getBlockState(target, false).getState(); if (state instanceof InventoryHolder) { Inventory inv = ((InventoryHolder) state).getInventory(); @@ -380,27 +398,32 @@ abstract class ChestTerminalNetwork extends Network { return items; } - private void gatherItemsFromBarrel(Location l, Config cfg, BlockMenu blockMenu, List items) { - int stored = Integer.parseInt(cfg.getString("storedItems")); + private void gatherItemsFromBarrel(Location l, String data, BlockMenu blockMenu, List items) { + try { + int stored = Integer.parseInt(data); - for (int slot : blockMenu.getPreset().getSlotsAccessedByItemTransport((DirtyChestMenu) blockMenu, ItemTransportFlow.WITHDRAW, null)) { - ItemStack is = blockMenu.getItemInSlot(slot); + for (int slot : blockMenu.getPreset().getSlotsAccessedByItemTransport((DirtyChestMenu) blockMenu, ItemTransportFlow.WITHDRAW, null)) { + ItemStack is = blockMenu.getItemInSlot(slot); - if (is != null && CargoUtils.matchesFilter(l.getBlock(), is)) { - boolean add = true; + if (is != null && CargoUtils.matchesFilter(l.getBlock(), is)) { + boolean add = true; - for (ItemStackAndInteger item : items) { - if (SlimefunUtils.isItemSimilar(is, item.getItem(), true)) { - add = false; - item.add(is.getAmount() + stored); + for (ItemStackAndInteger item : items) { + if (SlimefunUtils.isItemSimilar(is, item.getItemStackWrapper(), true, false)) { + add = false; + item.add(is.getAmount() + stored); + } + } + + if (add) { + items.add(new ItemStackAndInteger(is, is.getAmount() + stored)); } } - - if (add) { - items.add(new ItemStackAndInteger(is, is.getAmount() + stored)); - } } } + catch (Exception x) { + Slimefun.getLogger().log(Level.SEVERE, "An Exception occured while trying to read data from a Barrel", x); + } } private void handleWithdraw(DirtyChestMenu menu, List items, Location l) { @@ -414,7 +437,7 @@ abstract class ChestTerminalNetwork extends Network { boolean add = true; for (ItemStackAndInteger item : items) { - if (SlimefunUtils.isItemSimilar(stack, item.getItem(), true)) { + if (SlimefunUtils.isItemSimilar(stack, item.getItemStackWrapper(), true)) { add = false; item.add(stack.getAmount()); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ItemStackAndInteger.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ItemStackAndInteger.java index 62e4a1929..395f6856e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ItemStackAndInteger.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ItemStackAndInteger.java @@ -2,9 +2,12 @@ package io.github.thebusybiscuit.slimefun4.core.networks.cargo; import org.bukkit.inventory.ItemStack; +import io.github.thebusybiscuit.slimefun4.utils.itemstack.ItemStackWrapper; + class ItemStackAndInteger { private final ItemStack item; + private ItemStackWrapper wrapper; private int number; ItemStackAndInteger(ItemStack item, int amount) { @@ -20,6 +23,14 @@ class ItemStackAndInteger { return item; } + public ItemStackWrapper getItemStackWrapper() { + if (wrapper == null && item != null) { + wrapper = new ItemStackWrapper(item); + } + + return wrapper; + } + public void add(int amount) { number += amount; } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/energy/EnergyNet.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/energy/EnergyNet.java index b73fd8cf2..0faf773e8 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/energy/EnergyNet.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/energy/EnergyNet.java @@ -1,6 +1,8 @@ package io.github.thebusybiscuit.slimefun4.core.networks.energy; +import java.util.HashMap; import java.util.HashSet; +import java.util.Map; import java.util.Optional; import java.util.Set; import java.util.concurrent.atomic.AtomicLong; @@ -15,6 +17,7 @@ import io.github.thebusybiscuit.slimefun4.api.ErrorReport; import io.github.thebusybiscuit.slimefun4.api.network.Network; import io.github.thebusybiscuit.slimefun4.api.network.NetworkComponent; import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetComponent; +import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetProvider; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors.Reactor; @@ -35,6 +38,7 @@ import me.mrCookieSlime.Slimefun.api.energy.ChargableBlock; * * @see Network * @see EnergyNetComponent + * @see EnergyNetProvider * @see EnergyNetComponentType * */ @@ -49,16 +53,10 @@ public class EnergyNet extends Network { return EnergyNetComponentType.NONE; } - if (SlimefunPlugin.getRegistry().getEnergyGenerators().contains(id)) { - return EnergyNetComponentType.GENERATOR; - } + SlimefunItem item = SlimefunItem.getByID(id); - if (SlimefunPlugin.getRegistry().getEnergyCapacitors().contains(id)) { - return EnergyNetComponentType.CAPACITOR; - } - - if (SlimefunPlugin.getRegistry().getEnergyConsumers().contains(id)) { - return EnergyNetComponentType.CONSUMER; + if (item instanceof EnergyNetComponent) { + return ((EnergyNetComponent) item).getEnergyComponentType(); } return EnergyNetComponentType.NONE; @@ -143,10 +141,10 @@ public class EnergyNet extends Network { SimpleHologram.update(b, "&4No Energy Network found"); } else { - double supply = DoubleHandler.fixDouble(tickAllGenerators(timestamp::getAndAdd) + tickAllCapacitors()); - double demand = 0; - - int availableEnergy = (int) supply; + Map generatorsWithCapacity = new HashMap<>(); + int supply = tickAllGenerators(generatorsWithCapacity, timestamp::getAndAdd) + tickAllCapacitors(); + int remainingEnergy = supply; + int demand = 0; for (Location machine : consumers) { int capacity = ChargableBlock.getMaxCharge(machine); @@ -156,20 +154,20 @@ public class EnergyNet extends Network { int availableSpace = capacity - charge; demand += availableSpace; - if (availableEnergy > 0) { - if (availableEnergy > availableSpace) { + if (remainingEnergy > 0) { + if (remainingEnergy > availableSpace) { ChargableBlock.setUnsafeCharge(machine, capacity, false); - availableEnergy -= availableSpace; + remainingEnergy -= availableSpace; } else { - ChargableBlock.setUnsafeCharge(machine, charge + availableEnergy, false); - availableEnergy = 0; + ChargableBlock.setUnsafeCharge(machine, charge + remainingEnergy, false); + remainingEnergy = 0; } } } } - storeExcessEnergy(availableEnergy); + storeExcessEnergy(generatorsWithCapacity, remainingEnergy); updateHologram(b, supply, demand); } @@ -177,7 +175,7 @@ public class EnergyNet extends Network { SlimefunPlugin.getProfiler().closeEntry(b.getLocation(), SlimefunItems.ENERGY_REGULATOR.getItem(), timestamp.get()); } - private void storeExcessEnergy(int available) { + private void storeExcessEnergy(Map generators, int available) { for (Location capacitor : storage) { if (available > 0) { int capacity = ChargableBlock.getMaxCharge(capacitor); @@ -196,40 +194,82 @@ public class EnergyNet extends Network { } } - for (Location generator : generators) { - int capacity = ChargableBlock.getMaxCharge(generator); + for (Map.Entry entry : generators.entrySet()) { + Location generator = entry.getKey(); + int capacity = entry.getValue(); - if (capacity > 0) { - if (available > 0) { - if (available > capacity) { - ChargableBlock.setUnsafeCharge(generator, capacity, false); - available = available - capacity; - } - else { - ChargableBlock.setUnsafeCharge(generator, available, false); - available = 0; - } + if (available > 0) { + if (available > capacity) { + ChargableBlock.setUnsafeCharge(generator, capacity, false); + available -= capacity; } else { - ChargableBlock.setUnsafeCharge(generator, 0, false); + ChargableBlock.setUnsafeCharge(generator, available, false); + available = 0; } } + else { + ChargableBlock.setUnsafeCharge(generator, 0, false); + } } } - private double tickAllGenerators(LongConsumer timeCallback) { - double supply = 0; + private int tickAllGenerators(Map generatorsWithCapacity, LongConsumer timeCallback) { Set exploded = new HashSet<>(); + int supply = 0; for (Location source : generators) { long timestamp = SlimefunPlugin.getProfiler().newEntry(); Config config = BlockStorage.getLocationInfo(source); SlimefunItem item = SlimefunItem.getByID(config.getString("id")); - if (item != null) { + if (item instanceof EnergyNetProvider) { try { + EnergyNetProvider provider = (EnergyNetProvider) item; + int energy = provider.getGeneratedOutput(source, config); + + if (provider.getCapacity() > 0) { + generatorsWithCapacity.put(source, provider.getCapacity()); + String charge = config.getString("energy-charge"); + + if (charge != null) { + energy += Integer.parseInt(charge); + } + } + + if (provider.willExplode(source, config)) { + exploded.add(source); + BlockStorage.clearBlockInfo(source); + + Slimefun.runSync(() -> { + source.getBlock().setType(Material.LAVA); + source.getWorld().createExplosion(source, 0F, false); + }); + } + else { + supply += energy; + } + } + catch (Exception | LinkageError t) { + exploded.add(source); + new ErrorReport(t, source, item); + } + + long time = SlimefunPlugin.getProfiler().closeEntry(source, item, timestamp); + timeCallback.accept(time); + } + else if (item != null) { + try { + // This will be removed very very soon + // It is only here for temporary backwards compatibility GeneratorTicker generator = item.getEnergyTicker(); + Integer capacity = SlimefunPlugin.getRegistry().getEnergyCapacities().get(item.getID()); + + if (capacity != null && capacity.intValue() > 0) { + generatorsWithCapacity.put(source, capacity); + } + if (generator != null) { double energy = generator.generateEnergy(source, item, config); @@ -267,12 +307,11 @@ public class EnergyNet extends Network { } generators.removeAll(exploded); - return supply; } - private double tickAllCapacitors() { - double supply = 0; + private int tickAllCapacitors() { + int supply = 0; for (Location capacitor : storage) { supply += ChargableBlock.getCharge(capacitor); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/researching/Research.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/researching/Research.java index c3ce60dfc..410ed6b0e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/researching/Research.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/researching/Research.java @@ -41,7 +41,7 @@ public class Research implements Keyed { private final NamespacedKey key; private final int id; - private String name; + private final String name; private boolean enabled = true; private int cost; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/MetricsService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/MetricsService.java new file mode 100644 index 000000000..fef03a78a --- /dev/null +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/MetricsService.java @@ -0,0 +1,242 @@ +package io.github.thebusybiscuit.slimefun4.core.services; + +import javax.annotation.Nullable; +import java.io.File; +import java.io.IOException; +import java.lang.reflect.Method; +import java.net.URL; +import java.net.URLClassLoader; +import java.nio.file.Files; +import java.nio.file.StandardCopyOption; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.logging.Level; + +import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; +import io.github.thebusybiscuit.slimefun4.utils.PatternUtils; +import kong.unirest.HttpResponse; +import kong.unirest.JsonNode; +import kong.unirest.Unirest; +import kong.unirest.UnirestException; +import me.mrCookieSlime.Slimefun.api.Slimefun; +import org.bukkit.plugin.Plugin; + +/** + * This Class represents a Metrics Service that sends data to https://bstats.org/ + * This data is used to analyse the usage of this {@link Plugin}. + *

+ * You can find more info in the README file of this Project on GitHub.
+ * Note: To start the metrics you will need to be calling {@link #start()} + * + * @author WalshyDev + */ +public class MetricsService { + + private static final String REPO_NAME = "MetricsModule"; + private static final String GH_API = "https://api.github.com/repos/Slimefun/" + REPO_NAME; + private static final String GH_RELEASES = "https://github.com/Slimefun/" + REPO_NAME + "/releases/download"; + + private final SlimefunPlugin plugin; + private final File parentFolder; + private final File metricsModuleFile; + + private URLClassLoader moduleClassLoader; + private String metricVersion = null; + private boolean hasDownloadedUpdate = false; + + static { + Unirest.config() + .concurrency(2, 1) + .setDefaultHeader("User-Agent", "MetricsModule Auto-Updater") + .setDefaultHeader("Accept", "application/vnd.github.v3+json") + .enableCookieManagement(false) + .cookieSpec("ignoreCookies"); + } + + public MetricsService(SlimefunPlugin plugin) { + this.plugin = plugin; + this.parentFolder = new File(plugin.getDataFolder(), "cache" + File.separatorChar + "modules"); + + if (!parentFolder.exists()) { + parentFolder.mkdirs(); + } + + this.metricsModuleFile = new File(parentFolder, REPO_NAME + ".jar"); + } + + /** + * This method loads the metric module and starts the metrics collection. + */ + public void start() { + if (!metricsModuleFile.exists()) { + plugin.getLogger().info(REPO_NAME + " does not exist, downloading..."); + + if (!download(getLatestVersion())) { + plugin.getLogger().warning("Failed to start metrics as the file could not be downloaded."); + return; + } + } + + try { + // Load the jar file into a child class loader using the SF PluginClassLoader + // as a parent. + moduleClassLoader = URLClassLoader.newInstance(new URL[] { metricsModuleFile.toURI().toURL() }, + plugin.getClass().getClassLoader()); + Class cl = moduleClassLoader.loadClass("dev.walshy.sfmetrics.MetricsModule"); + + metricVersion = cl.getPackage().getImplementationVersion(); + + // If it has not been newly downloaded, auto-updates are on AND there's a new version + // then cleanup, download and start + if (!hasDownloadedUpdate && hasAutoUpdates() && checkForUpdate(metricVersion) + ) { + plugin.getLogger().info("Cleaning up and re-loading Metrics."); + cleanUp(); + start(); + return; + } + + // Finally, we're good to start this. + Method start = cl.getDeclaredMethod("start"); + String version = cl.getPackage().getImplementationVersion(); + + // This is required to be sync due to bStats. + Slimefun.runSync(() -> { + try { + start.invoke(null); + plugin.getLogger().info("Metrics build #" + version + " started."); + } catch (Exception e) { + plugin.getLogger().log(Level.WARNING, "Failed to start metrics.", e); + } + }); + } catch (Exception e) { + plugin.getLogger().log(Level.WARNING, + "Failed to load the metrics module. Maybe the jar is corrupt?", e); + } + } + + /** + * This will close the child classloader and mark all the resources held under this no longer + * in use, they will be cleaned up the next GC run. + */ + public void cleanUp() { + try { + if (this.moduleClassLoader != null) { + this.moduleClassLoader.close(); + } + } catch (IOException e) { + plugin.getLogger().log(Level.WARNING, + "Could not clean up module class loader. Some memory may have been leaked."); + } + } + + /** + * Checks for a new update and compares it against the current version. + * If there is a new version available then this returns true. + * + * @param currentVersion The current version which is being used. + * @return True if there is an update available. + */ + public boolean checkForUpdate(String currentVersion) { + if (currentVersion == null || !PatternUtils.NUMERIC.matcher(currentVersion).matches()) { + return false; + } + + int latest = getLatestVersion(); + + if (latest > Integer.parseInt(currentVersion)) { + return download(latest); + } + + return false; + } + + /** + * Gets the latest version available as an int. + * This is an internal method used by {@link #checkForUpdate(String)}. + * If it cannot get the version for whatever reason this will return 0, effectively always + * being behind. + * + * @return The latest version as an integer or -1 if it failed to fetch. + */ + private int getLatestVersion() { + try { + HttpResponse response = Unirest.get(GH_API + "/releases/latest") + .asJson(); + if (!response.isSuccess()) return -1; + + JsonNode node = response.getBody(); + + if (node == null) return -1; + + return node.getObject().getInt("tag_name"); + } catch (UnirestException e) { + plugin.getLogger().log(Level.SEVERE, "Failed to fetch latest builds for SFMetrics"); + return -1; + } + } + + /** + * Downloads the version specified to Slimefun's data folder. + * + * @param version The version to download. + */ + private boolean download(int version) { + File f = new File(parentFolder, "Metrics-" + version + ".jar"); + + try { + plugin.getLogger().log(Level.INFO, "# Starting download of MetricsModule build: #{0}", version); + + AtomicInteger lastPercentPosted = new AtomicInteger(); + HttpResponse response = Unirest.get(GH_RELEASES + "/" + version + + "/" + REPO_NAME + ".jar") + .downloadMonitor((b, fileName, bytesWritten, totalBytes) -> { + int percent = (int) (20 * (Math.round((((double) bytesWritten / totalBytes) * 100) / 20))); + + if (percent != 0 && percent != lastPercentPosted.get()) { + plugin.getLogger().info("# Downloading... " + percent + "% " + + "(" + bytesWritten + "/" + totalBytes + " bytes)"); + lastPercentPosted.set(percent); + } + }) + .asFile(f.getPath()); + if (response.isSuccess()) { + plugin.getLogger().log(Level.INFO, "Successfully downloaded {0} build: #{1}", new Object[] {REPO_NAME, version}); + + // Replace the metric file with the new one + Files.move(f.toPath(), metricsModuleFile.toPath(), StandardCopyOption.REPLACE_EXISTING); + + metricVersion = String.valueOf(version); + hasDownloadedUpdate = true; + return true; + } + } catch (UnirestException e) { + plugin.getLogger().log(Level.WARNING, "Failed to fetch the latest jar file from the" + + " builds page. Perhaps GitHub is down."); + } catch (IOException e) { + plugin.getLogger().log(Level.WARNING, "Failed to replace the old metric file with the " + + "new one. Please do this manually! Error: {0}", e.getMessage()); + } + return false; + } + + /** + * Returns the currently downloaded metrics version. + * This can change! It may be null or an + * older version before it has downloaded a newer one. + * + * @return The current version or null if not loaded. + */ + @Nullable + public String getVersion() { + return metricVersion; + } + + /** + * Returns if the current server has metrics auto-updates enabled. + * + * @return True if the current server has metrics auto-updates enabled. + */ + public boolean hasAutoUpdates() { + return SlimefunPlugin.instance().getConfig().getBoolean("metrics.auto-update"); + } +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/ContributionsConnector.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/ContributionsConnector.java index 5f50d2783..7aea16847 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/ContributionsConnector.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/ContributionsConnector.java @@ -6,10 +6,9 @@ import java.util.List; import java.util.Map; import java.util.logging.Level; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; - +import kong.unirest.JsonNode; +import kong.unirest.json.JSONArray; +import kong.unirest.json.JSONObject; import me.mrCookieSlime.Slimefun.api.Slimefun; class ContributionsConnector extends GitHubConnector { @@ -57,10 +56,10 @@ class ContributionsConnector extends GitHubConnector { } @Override - public void onSuccess(JsonElement element) { + public void onSuccess(JsonNode element) { finished = true; - if (element.isJsonArray()) { - computeContributors(element.getAsJsonArray()); + if (element.isArray()) { + computeContributors(element.getArray()); } else { Slimefun.getLogger().log(Level.WARNING, "Received an unusual answer from GitHub, possibly a timeout? ({0})", element); @@ -82,13 +81,13 @@ class ContributionsConnector extends GitHubConnector { return "/contributors?per_page=100&page=" + page; } - private void computeContributors(JsonArray array) { - for (int i = 0; i < array.size(); i++) { - JsonObject object = array.get(i).getAsJsonObject(); + private void computeContributors(JSONArray array) { + for (int i = 0; i < array.length(); i++) { + JSONObject object = array.getJSONObject(i); - String name = object.get("login").getAsString(); - int commits = object.get("contributions").getAsInt(); - String profile = object.get("html_url").getAsString(); + String name = object.getString("login"); + int commits = object.getInt("contributions"); + String profile = object.getString("html_url"); if (!blacklist.contains(name)) { github.addContributor(aliases.getOrDefault(name, name), profile, role, commits); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubConnector.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubConnector.java index 68e76ec42..1ab1b4149 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubConnector.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubConnector.java @@ -6,17 +6,14 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStreamReader; -import java.net.URL; -import java.net.URLConnection; -import java.nio.channels.Channels; -import java.nio.channels.ReadableByteChannel; import java.nio.charset.StandardCharsets; import java.util.logging.Level; -import com.google.gson.JsonElement; -import com.google.gson.JsonParser; - -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; +import kong.unirest.HttpResponse; +import kong.unirest.JsonNode; +import kong.unirest.Unirest; +import kong.unirest.UnirestException; +import kong.unirest.json.JSONException; import me.mrCookieSlime.Slimefun.api.Slimefun; abstract class GitHubConnector { @@ -34,7 +31,7 @@ abstract class GitHubConnector { public abstract String getURLSuffix(); - public abstract void onSuccess(JsonElement element); + public abstract void onSuccess(JsonNode element); public void onFailure() { // Don't do anything by default @@ -48,58 +45,54 @@ abstract class GitHubConnector { } try { - URL website = new URL("https://api.github.com/repos/" + repository + getURLSuffix()); + HttpResponse resp = Unirest.get("https://api.github.com/repos/" + repository + getURLSuffix()) + .header("User-Agent", "Slimefun4 (https://github.com/Slimefun)") + .asJson(); - URLConnection connection = website.openConnection(); - connection.setConnectTimeout(8000); - connection.addRequestProperty("Accept-Charset", "UTF-8"); - connection.addRequestProperty("User-Agent", "Slimefun 4 GitHub Agent (by TheBusyBiscuit)"); - connection.setDoOutput(true); - - try (ReadableByteChannel channel = Channels.newChannel(connection.getInputStream())) { - try (FileOutputStream stream = new FileOutputStream(file)) { - stream.getChannel().transferFrom(channel, 0, Long.MAX_VALUE); - parseData(); - } + if (resp.isSuccess()) { + onSuccess(resp.getBody()); + writeCacheFile(resp.getBody()); + } + else { + Slimefun.getLogger().log(Level.WARNING, "Failed to fetch {0}", repository + getURLSuffix()); } } - catch (IOException e) { + catch (UnirestException e) { if (github.isLoggingEnabled()) { Slimefun.getLogger().log(Level.WARNING, "Could not connect to GitHub in time."); } - if (hasData()) { - parseData(); - } - else { - onFailure(); - } - } - } + // It has the cached file, let's just read that then + if (file.exists()) { + JsonNode cache = readCacheFile(); - public boolean hasData() { - return getFile().exists(); - } - - public File getFile() { - return file; - } - - public void parseData() { - try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(getFile()), StandardCharsets.UTF_8))) { - StringBuilder builder = new StringBuilder(); - - String line; - while ((line = reader.readLine()) != null) { - builder.append(line); + if (cache != null) { + onSuccess(cache); + return; + } } - JsonElement element = new JsonParser().parse(builder.toString()); - onSuccess(element); - } - catch (IOException x) { - Slimefun.getLogger().log(Level.SEVERE, x, () -> "An Error occurred while parsing GitHub-Data for Slimefun " + SlimefunPlugin.getVersion()); + // If the request failed and it failed to read the cache then call onFailure. onFailure(); } } + + private JsonNode readCacheFile() { + try (BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8))) { + return new JsonNode(br.readLine()); + } + catch (IOException | JSONException e) { + Slimefun.getLogger().log(Level.WARNING, "Failed to read Github cache file: {0}", file.getName()); + return null; + } + } + + private void writeCacheFile(JsonNode node) { + try (FileOutputStream fos = new FileOutputStream(file)) { + fos.write(node.toString().getBytes(StandardCharsets.UTF_8)); + } + catch (IOException e) { + Slimefun.getLogger().log(Level.WARNING, "Failed to populate GitHub cache"); + } + } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubIssuesTracker.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubIssuesTracker.java index 9686d4e92..84af62998 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubIssuesTracker.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubIssuesTracker.java @@ -2,10 +2,9 @@ package io.github.thebusybiscuit.slimefun4.core.services.github; import java.util.logging.Level; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; - +import kong.unirest.JsonNode; +import kong.unirest.json.JSONArray; +import kong.unirest.json.JSONObject; import me.mrCookieSlime.Slimefun.api.Slimefun; class GitHubIssuesTracker extends GitHubConnector { @@ -25,15 +24,15 @@ class GitHubIssuesTracker extends GitHubConnector { } @Override - public void onSuccess(JsonElement element) { - if (element.isJsonArray()) { - JsonArray array = element.getAsJsonArray(); + public void onSuccess(JsonNode element) { + if (element.isArray()) { + JSONArray array = element.getArray(); int issues = 0; int pullRequests = 0; - for (JsonElement elem : array) { - JsonObject obj = elem.getAsJsonObject(); + for (int i = 0; i < array.length(); i++) { + JSONObject obj = array.getJSONObject(i); if (obj.has("pull_request")) { pullRequests++; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubService.java index 1942eeb52..77df08cc0 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubService.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubService.java @@ -9,14 +9,13 @@ import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; - import io.github.thebusybiscuit.cscorelib2.config.Config; import io.github.thebusybiscuit.slimefun4.core.services.localization.Translators; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.utils.HeadTexture; import io.github.thebusybiscuit.slimefun4.utils.NumberUtils; +import kong.unirest.JsonNode; +import kong.unirest.json.JSONObject; /** * This Service is responsible for grabbing every {@link Contributor} to this project @@ -108,11 +107,11 @@ public class GitHubService { connectors.add(new GitHubConnector(this, repository) { @Override - public void onSuccess(JsonElement element) { - JsonObject object = element.getAsJsonObject(); - forks = object.get("forks").getAsInt(); - stars = object.get("stargazers_count").getAsInt(); - lastUpdate = NumberUtils.parseGitHubDate(object.get("pushed_at").getAsString()); + public void onSuccess(JsonNode element) { + JSONObject object = element.getObject(); + forks = object.getInt("forks"); + stars = object.getInt("stargazers_count"); + lastUpdate = NumberUtils.parseGitHubDate(object.getString("pushed_at")); } @Override @@ -206,9 +205,7 @@ public class GitHubService { for (Contributor contributor : contributors.values()) { Optional uuid = contributor.getUniqueId(); - if (uuid.isPresent()) { - uuidCache.setValue(contributor.getName(), uuid.get()); - } + uuid.ifPresent(value -> uuidCache.setValue(contributor.getName(), value)); if (contributor.hasTexture()) { String texture = contributor.getTexture(); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubTask.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubTask.java index d7d9a9186..de91ac576 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubTask.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubTask.java @@ -56,9 +56,9 @@ class GitHubTask implements Runnable { } } - if (requests >= MAX_REQUESTS_PER_MINUTE && SlimefunPlugin.instance != null && SlimefunPlugin.instance.isEnabled()) { + if (requests >= MAX_REQUESTS_PER_MINUTE && SlimefunPlugin.instance() != null && SlimefunPlugin.instance().isEnabled()) { // Slow down API requests and wait a minute after more than x requests were made - Bukkit.getScheduler().runTaskLaterAsynchronously(SlimefunPlugin.instance, this::grabTextures, 2 * 60 * 20L); + Bukkit.getScheduler().runTaskLaterAsynchronously(SlimefunPlugin.instance(), this::grabTextures, 2 * 60 * 20L); } for (GitHubConnector connector : gitHubService.getConnectors()) { @@ -94,14 +94,14 @@ class GitHubTask implements Runnable { // Retry after 5 minutes if it was rate-limiting if (x.getMessage().contains("429")) { - Bukkit.getScheduler().runTaskLaterAsynchronously(SlimefunPlugin.instance, this::grabTextures, 5 * 60 * 20L); + Bukkit.getScheduler().runTaskLaterAsynchronously(SlimefunPlugin.instance(), this::grabTextures, 5 * 60 * 20L); } return -1; } catch (TooManyRequestsException x) { Slimefun.getLogger().log(Level.WARNING, "Received a rate-limit from mojang.com, retrying in 4 minutes"); - Bukkit.getScheduler().runTaskLaterAsynchronously(SlimefunPlugin.instance, this::grabTextures, 4 * 60 * 20L); + Bukkit.getScheduler().runTaskLaterAsynchronously(SlimefunPlugin.instance(), this::grabTextures, 4 * 60 * 20L); return -1; } @@ -116,9 +116,7 @@ class GitHubTask implements Runnable { if (!uuid.isPresent()) { uuid = MinecraftAccount.getUUID(contributor.getMinecraftName()); - if (uuid.isPresent()) { - contributor.setUniqueId(uuid.get()); - } + uuid.ifPresent(contributor::setUniqueId); } if (uuid.isPresent()) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/metrics/AddonsChart.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/metrics/AddonsChart.java deleted file mode 100644 index 2ed2a7d59..000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/metrics/AddonsChart.java +++ /dev/null @@ -1,27 +0,0 @@ -package io.github.thebusybiscuit.slimefun4.core.services.metrics; - -import java.util.HashMap; -import java.util.Map; - -import org.bstats.bukkit.Metrics.AdvancedPie; -import org.bukkit.plugin.Plugin; - -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; - -class AddonsChart extends AdvancedPie { - - AddonsChart() { - super("installed_addons", () -> { - Map addons = new HashMap<>(); - - for (Plugin plugin : SlimefunPlugin.getInstalledAddons()) { - if (plugin.isEnabled()) { - addons.put(plugin.getName(), 1); - } - } - - return addons; - }); - } - -} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/metrics/AutoUpdaterChart.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/metrics/AutoUpdaterChart.java deleted file mode 100644 index eba426338..000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/metrics/AutoUpdaterChart.java +++ /dev/null @@ -1,16 +0,0 @@ -package io.github.thebusybiscuit.slimefun4.core.services.metrics; - -import org.bstats.bukkit.Metrics.SimplePie; - -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; - -class AutoUpdaterChart extends SimplePie { - - AutoUpdaterChart() { - super("auto_updates", () -> { - boolean enabled = SlimefunPlugin.getUpdater().isEnabled(); - return enabled ? "enabled" : "disabled"; - }); - } - -} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/metrics/CommandChart.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/metrics/CommandChart.java deleted file mode 100644 index d9fc909c1..000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/metrics/CommandChart.java +++ /dev/null @@ -1,25 +0,0 @@ -package io.github.thebusybiscuit.slimefun4.core.services.metrics; - -import java.util.HashMap; -import java.util.Map; - -import org.bstats.bukkit.Metrics.AdvancedPie; - -import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; - -class CommandChart extends AdvancedPie { - - CommandChart() { - super("commands_ran", () -> { - Map commands = new HashMap<>(); - - for (Map.Entry entry : SlimefunPlugin.getCommand().getCommandUsage().entrySet()) { - commands.put("/sf " + entry.getKey().getName(), entry.getValue()); - } - - return commands; - }); - } - -} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/metrics/CompatibilityModeChart.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/metrics/CompatibilityModeChart.java deleted file mode 100644 index 045c2657e..000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/metrics/CompatibilityModeChart.java +++ /dev/null @@ -1,16 +0,0 @@ -package io.github.thebusybiscuit.slimefun4.core.services.metrics; - -import org.bstats.bukkit.Metrics.SimplePie; - -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; - -class CompatibilityModeChart extends SimplePie { - - CompatibilityModeChart() { - super("compatibility_mode", () -> { - boolean enabled = SlimefunPlugin.getRegistry().isBackwardsCompatible(); - return enabled ? "enabled" : "disabled"; - }); - } - -} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/metrics/GuideLayoutChart.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/metrics/GuideLayoutChart.java deleted file mode 100644 index 75fc72b42..000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/metrics/GuideLayoutChart.java +++ /dev/null @@ -1,17 +0,0 @@ -package io.github.thebusybiscuit.slimefun4.core.services.metrics; - -import org.bstats.bukkit.Metrics.SimplePie; - -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; - -class GuideLayoutChart extends SimplePie { - - GuideLayoutChart() { - super("guide_layout", () -> { - boolean book = SlimefunPlugin.getCfg().getBoolean("guide.default-view-book"); - - return book ? "Book" : "Chest GUI"; - }); - } - -} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/metrics/MetricsService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/metrics/MetricsService.java deleted file mode 100644 index d6654f6a2..000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/metrics/MetricsService.java +++ /dev/null @@ -1,55 +0,0 @@ -package io.github.thebusybiscuit.slimefun4.core.services.metrics; - -import org.bstats.bukkit.Metrics; -import org.bukkit.plugin.Plugin; - -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; - -/** - * This Class represents a Metrics Service that sends data to https://bstats.org/ - * This data is used to analyse the usage of this {@link Plugin}. - * - * You can find more info in the README file of this Project on GitHub. - * - * @author TheBusyBiscuit - * - */ -public class MetricsService { - - private final SlimefunPlugin plugin; - - /** - * This creates a new {@link MetricsService}. The constructor does not set up - * anything related to bStats yet, that happens in the {@link MetricsService#start()} method. - * - * @param plugin - * The instance of our {@link SlimefunPlugin} - */ - public MetricsService(SlimefunPlugin plugin) { - this.plugin = plugin; - } - - /** - * This method intializes and starts the metrics collection. - */ - public void start() { - Metrics metrics = new Metrics(plugin, 4574); - - if (SlimefunPlugin.getUpdater().getBranch().isOfficial()) { - // We really do not need this data if it is an unofficially modified build... - metrics.addCustomChart(new AutoUpdaterChart()); - } - - metrics.addCustomChart(new ResourcePackChart()); - metrics.addCustomChart(new SlimefunVersionChart()); - metrics.addCustomChart(new ServerLanguageChart()); - metrics.addCustomChart(new PlayerLanguageChart()); - metrics.addCustomChart(new ResearchesEnabledChart()); - metrics.addCustomChart(new GuideLayoutChart()); - metrics.addCustomChart(new AddonsChart()); - metrics.addCustomChart(new CommandChart()); - metrics.addCustomChart(new ServerSizeChart()); - metrics.addCustomChart(new CompatibilityModeChart()); - } - -} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/metrics/PlayerLanguageChart.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/metrics/PlayerLanguageChart.java deleted file mode 100644 index 347bf0640..000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/metrics/PlayerLanguageChart.java +++ /dev/null @@ -1,31 +0,0 @@ -package io.github.thebusybiscuit.slimefun4.core.services.metrics; - -import java.util.HashMap; -import java.util.Map; - -import org.bstats.bukkit.Metrics.AdvancedPie; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; - -import io.github.thebusybiscuit.slimefun4.core.services.localization.Language; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; - -class PlayerLanguageChart extends AdvancedPie { - - PlayerLanguageChart() { - super("player_languages", () -> { - Map languages = new HashMap<>(); - - for (Player p : Bukkit.getOnlinePlayers()) { - Language language = SlimefunPlugin.getLocalization().getLanguage(p); - boolean supported = SlimefunPlugin.getLocalization().isLanguageLoaded(language.getId()); - - String lang = supported ? language.getId() : "Unsupported Language"; - languages.merge(lang, 1, Integer::sum); - } - - return languages; - }); - } - -} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/metrics/ResearchesEnabledChart.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/metrics/ResearchesEnabledChart.java deleted file mode 100644 index 87a66bf2f..000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/metrics/ResearchesEnabledChart.java +++ /dev/null @@ -1,16 +0,0 @@ -package io.github.thebusybiscuit.slimefun4.core.services.metrics; - -import org.bstats.bukkit.Metrics.SimplePie; - -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; - -class ResearchesEnabledChart extends SimplePie { - - ResearchesEnabledChart() { - super("servers_with_researches_enabled", () -> { - boolean enabled = SlimefunPlugin.getRegistry().isFreeCreativeResearchingEnabled(); - return enabled ? "enabled" : "disabled"; - }); - } - -} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/metrics/ResourcePackChart.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/metrics/ResourcePackChart.java deleted file mode 100644 index 0622c6e03..000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/metrics/ResourcePackChart.java +++ /dev/null @@ -1,25 +0,0 @@ -package io.github.thebusybiscuit.slimefun4.core.services.metrics; - -import org.bstats.bukkit.Metrics.SimplePie; - -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; - -class ResourcePackChart extends SimplePie { - - ResourcePackChart() { - super("resourcepack", () -> { - String version = SlimefunPlugin.getItemTextureService().getVersion(); - - if (version != null && version.startsWith("v")) { - return version + " (Official)"; - } - else if (SlimefunPlugin.getItemTextureService().isActive()) { - return "Custom / Modified"; - } - else { - return "None"; - } - }); - } - -} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/metrics/ServerLanguageChart.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/metrics/ServerLanguageChart.java deleted file mode 100644 index e006eaf6d..000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/metrics/ServerLanguageChart.java +++ /dev/null @@ -1,18 +0,0 @@ -package io.github.thebusybiscuit.slimefun4.core.services.metrics; - -import org.bstats.bukkit.Metrics.SimplePie; - -import io.github.thebusybiscuit.slimefun4.core.services.localization.Language; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; - -class ServerLanguageChart extends SimplePie { - - ServerLanguageChart() { - super("language", () -> { - Language language = SlimefunPlugin.getLocalization().getDefaultLanguage(); - boolean supported = SlimefunPlugin.getLocalization().isLanguageLoaded(language.getId()); - return supported ? language.getId() : "Unsupported Language"; - }); - } - -} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/metrics/ServerSizeChart.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/metrics/ServerSizeChart.java deleted file mode 100644 index 607859ba6..000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/metrics/ServerSizeChart.java +++ /dev/null @@ -1,40 +0,0 @@ -package io.github.thebusybiscuit.slimefun4.core.services.metrics; - -import org.bstats.bukkit.Metrics.SimplePie; -import org.bukkit.Bukkit; - -class ServerSizeChart extends SimplePie { - - ServerSizeChart() { - super("server_size", () -> { - int players = Bukkit.getOnlinePlayers().size(); - - if (players < 10) { - return "0-10"; - } - - if (players < 25) { - return "10-25"; - } - - if (players < 50) { - return "25-50"; - } - - if (players < 100) { - return "50-100"; - } - - if (players < 200) { - return "100-200"; - } - - if (players < 300) { - return "200-300"; - } - - return "300+"; - }); - } - -} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/metrics/SlimefunVersionChart.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/metrics/SlimefunVersionChart.java deleted file mode 100644 index 6140b60b0..000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/metrics/SlimefunVersionChart.java +++ /dev/null @@ -1,24 +0,0 @@ -package io.github.thebusybiscuit.slimefun4.core.services.metrics; - -import java.util.HashMap; -import java.util.Map; - -import org.bstats.bukkit.Metrics.DrilldownPie; - -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; - -class SlimefunVersionChart extends DrilldownPie { - - SlimefunVersionChart() { - super("slimefun_version", () -> { - Map> outerMap = new HashMap<>(); - Map innerMap = new HashMap<>(); - - innerMap.put(SlimefunPlugin.getVersion(), 1); - outerMap.put(SlimefunPlugin.getUpdater().getBranch().getName(), innerMap); - - return outerMap; - }); - } - -} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/metrics/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/metrics/package-info.java deleted file mode 100644 index 3528603ca..000000000 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/metrics/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * This package contains everything related to bStats Metrics - */ -package io.github.thebusybiscuit.slimefun4.core.services.metrics; \ No newline at end of file diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/plugins/PlaceholderAPIHook.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/plugins/PlaceholderAPIHook.java index 111ee37ad..457068e97 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/plugins/PlaceholderAPIHook.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/plugins/PlaceholderAPIHook.java @@ -16,7 +16,7 @@ class PlaceholderAPIHook extends PlaceholderExpansion { @Override public String getAuthor() { - return SlimefunPlugin.instance.getDescription().getAuthors().toString(); + return SlimefunPlugin.instance().getDescription().getAuthors().toString(); } @Override @@ -26,7 +26,7 @@ class PlaceholderAPIHook extends PlaceholderExpansion { @Override public String getVersion() { - return SlimefunPlugin.instance.getDescription().getVersion(); + return SlimefunPlugin.instance().getDescription().getVersion(); } @Override diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/PerformanceSummary.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/PerformanceSummary.java index 5262a1745..af5cb695e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/PerformanceSummary.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/PerformanceSummary.java @@ -17,23 +17,22 @@ import io.github.thebusybiscuit.slimefun4.utils.NumberUtils; import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.chat.HoverEvent; import net.md_5.bungee.api.chat.TextComponent; +import net.md_5.bungee.api.chat.hover.content.Content; +import net.md_5.bungee.api.chat.hover.content.Text; class PerformanceSummary { // The threshold at which a Block or Chunk is significant enough to appear in /sf timings - private static final int VISIBILITY_THRESHOLD = 280_000; - private static final int MIN_ITEMS = 3; - private static final int MAX_ITEMS = 10; - - // A minecraft server tick is 50ms and Slimefun ticks are stretched across - // two ticks (sync and async blocks), so we use 100ms as a reference here - static final int MAX_TICK_DURATION = 100; + private static final int VISIBILITY_THRESHOLD = 300_000; + private static final int MIN_ITEMS = 4; + private static final int MAX_ITEMS = 12; private final SlimefunProfiler profiler; private final PerformanceRating rating; private final long totalElapsedTime; private final int totalTickedBlocks; private final float percentage; + private final int tickRate; private final Map chunks; private final Map plugins; @@ -45,6 +44,7 @@ class PerformanceSummary { this.percentage = profiler.getPercentageOfTick(); this.totalElapsedTime = totalElapsedTime; this.totalTickedBlocks = totalTickedBlocks; + this.tickRate = profiler.getTickRate(); chunks = profiler.getByChunk(); plugins = profiler.getByPlugin(); @@ -54,7 +54,8 @@ class PerformanceSummary { public void send(CommandSender sender) { sender.sendMessage(""); sender.sendMessage(ChatColor.GREEN + "===== Slimefun Lag Profiler ====="); - sender.sendMessage(ChatColor.GOLD + "Total: " + ChatColor.YELLOW + NumberUtils.getAsMillis(totalElapsedTime)); + sender.sendMessage(ChatColor.GOLD + "Total time: " + ChatColor.YELLOW + NumberUtils.getAsMillis(totalElapsedTime)); + sender.sendMessage(ChatColor.GOLD + "Running every: " + ChatColor.YELLOW + NumberUtils.roundDecimalNumber(tickRate / 20.0) + "s (" + tickRate + " ticks)"); sender.sendMessage(ChatColor.GOLD + "Performance: " + getPerformanceRating()); sender.sendMessage(""); @@ -128,7 +129,8 @@ class PerformanceSummary { builder.append("\n\n&c+ &6").append(hidden).append(" more"); } - hoverComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(ChatColors.color(builder.toString())))); + Content content = new Text(TextComponent.fromLegacyText(ChatColors.color(builder.toString()))); + hoverComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, content)); component.addExtra(hoverComponent); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/ProfiledBlock.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/ProfiledBlock.java index 70c5c2549..940bca213 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/ProfiledBlock.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/ProfiledBlock.java @@ -1,5 +1,6 @@ package io.github.thebusybiscuit.slimefun4.core.services.profiler; +import org.bukkit.Location; import org.bukkit.block.Block; import io.github.thebusybiscuit.cscorelib2.blocks.BlockPosition; @@ -11,6 +12,11 @@ class ProfiledBlock { private final BlockPosition position; private final SlimefunItem item; + ProfiledBlock(Location l, SlimefunItem item) { + this.position = new BlockPosition(l); + this.item = item; + } + ProfiledBlock(BlockPosition position, SlimefunItem item) { this.position = position; this.item = item; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/SlimefunProfiler.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/SlimefunProfiler.java index 2f22a1f1a..fad49ad33 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/SlimefunProfiler.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/SlimefunProfiler.java @@ -19,7 +19,6 @@ import org.bukkit.Server; import org.bukkit.block.Block; import org.bukkit.command.CommandSender; -import io.github.thebusybiscuit.cscorelib2.blocks.BlockPosition; import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.implementation.tasks.TickerTask; @@ -41,7 +40,11 @@ import me.mrCookieSlime.Slimefun.api.Slimefun; */ public class SlimefunProfiler { - private final ExecutorService executor = Executors.newFixedThreadPool(3); + // A minecraft server tick is 50ms and Slimefun ticks are stretched across + // two ticks (sync and async blocks), so we use 100ms as a reference here + private static final int MAX_TICK_DURATION = 100; + + private final ExecutorService executor = Executors.newFixedThreadPool(4); private final AtomicBoolean running = new AtomicBoolean(false); private final AtomicInteger queued = new AtomicInteger(0); @@ -78,8 +81,10 @@ public class SlimefunProfiler { * Be careful to {@link #closeEntry(Location, SlimefunItem, long)} all of them again! * No {@link PerformanceSummary} will be sent until all entires were closed. * + * If the specified amount is negative, scheduled entries will be removed + * * @param amount - * The amount of entries that should be scheduled. + * The amount of entries that should be scheduled. Can be negative */ public void scheduleEntries(int amount) { if (running.get()) { @@ -111,8 +116,9 @@ public class SlimefunProfiler { long elapsedTime = System.nanoTime() - timestamp; executor.execute(() -> { - ProfiledBlock block = new ProfiledBlock(new BlockPosition(l), item); - timings.put(block, elapsedTime); + ProfiledBlock block = new ProfiledBlock(l, item); + + timings.putIfAbsent(block, elapsedTime); queued.decrementAndGet(); }); @@ -125,43 +131,53 @@ public class SlimefunProfiler { public void stop() { running.set(false); - if (SlimefunPlugin.instance == null || !SlimefunPlugin.instance.isEnabled()) { + if (SlimefunPlugin.instance() == null || !SlimefunPlugin.instance().isEnabled()) { // Slimefun has been disabled return; } - // Since we got more than one Thread in our pool, blocking this one is completely fine - executor.execute(() -> { + // Since we got more than one Thread in our pool, + // blocking this one is (hopefully) completely fine + executor.execute(this::finishReport); + } - // Wait for all timing results to come in - while (queued.get() > 0 && !running.get()) { - try { - Thread.sleep(1); - } - catch (InterruptedException e) { - Slimefun.getLogger().log(Level.SEVERE, "A waiting Thread was interrupted", e); - Thread.currentThread().interrupt(); + private void finishReport() { + // We will only wait for a maximum of this many 1ms sleeps + int iterations = 1000; + + // Wait for all timing results to come in + while (!running.get() && queued.get() > 0) { + try { + Thread.sleep(1); + iterations--; + + // If we waited for too long, then we should just abort + if (iterations <= 0) { + return; } } - - if (running.get()) { - // Looks like the next profiling has already started, abort! - return; + catch (InterruptedException e) { + Slimefun.getLogger().log(Level.SEVERE, "A Profiler Thread was interrupted", e); + Thread.currentThread().interrupt(); } + } - totalElapsedTime = timings.values().stream().mapToLong(Long::longValue).sum(); + if (running.get() && queued.get() > 0) { + // Looks like the next profiling has already started, abort! + return; + } - if (!requests.isEmpty()) { - PerformanceSummary summary = new PerformanceSummary(this, totalElapsedTime, timings.size()); - Iterator iterator = requests.iterator(); + totalElapsedTime = timings.values().stream().mapToLong(Long::longValue).sum(); - while (iterator.hasNext()) { - summary.send(iterator.next()); - iterator.remove(); - } + if (!requests.isEmpty()) { + PerformanceSummary summary = new PerformanceSummary(this, totalElapsedTime, timings.size()); + Iterator iterator = requests.iterator(); + + while (iterator.hasNext()) { + summary.send(iterator.next()); + iterator.remove(); } - }); - + } } /** @@ -253,7 +269,7 @@ public class SlimefunProfiler { protected float getPercentageOfTick() { float millis = totalElapsedTime / 1000000.0F; - float fraction = (millis * 100.0F) / PerformanceSummary.MAX_TICK_DURATION; + float fraction = (millis * 100.0F) / MAX_TICK_DURATION; return Math.round((fraction * 100.0F) / 100.0F); } @@ -278,6 +294,10 @@ public class SlimefunProfiler { return NumberUtils.getAsMillis(totalElapsedTime); } + public int getTickRate() { + return SlimefunPlugin.getTickerTask().getTickRate(); + } + /** * This method checks whether the {@link SlimefunProfiler} has collected timings on * the given {@link Block} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java index 1823f1f8e..2c61892c8 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java @@ -44,6 +44,7 @@ public final class SlimefunItems { public static final SlimefunItemStack BROKEN_SPAWNER = new SlimefunItemStack("BROKEN_SPAWNER", Material.SPAWNER, "&cBroken Spawner", "&7Type: &b", "", "&cFractured, must be repaired in an Ancient Altar"); public static final SlimefunItemStack REPAIRED_SPAWNER = new SlimefunItemStack("REINFORCED_SPAWNER", Material.SPAWNER, "&bReinforced Spawner", "&7Type: &b"); public static final SlimefunItemStack INFERNAL_BONEMEAL = new SlimefunItemStack("INFERNAL_BONEMEAL", Material.BONE_MEAL, "&4Infernal Bonemeal", "", "&cSpeeds up the Growth of", "&cNether Warts as well"); + public static final SlimefunItemStack TAPE_MEASURE = new SlimefunItemStack("TAPE_MEASURE", "180d5c43a6cf5bb7769fd0c8240e1e70d2ae38ef9d78a1db401aca6a2cb36f65", "&6Tape Measure", "", "&eCrouch & Right Click &7to set an anchor", "&eRight Click &7to measure"); /* Gadgets */ public static final SlimefunItemStack GOLD_PAN = new SlimefunItemStack("GOLD_PAN", Material.BOWL, "&6Gold Pan", "", "&eRight Click&7 to collect resources", "&7from Gravel"); @@ -815,6 +816,7 @@ public final class SlimefunItems { public static final SlimefunItemStack FLUID_PUMP = new SlimefunItemStack("FLUID_PUMP", Material.BLUE_TERRACOTTA, "&9Fluid Pump", "", LoreBuilder.machine(MachineTier.ADVANCED, MachineType.MACHINE), "&8\u21E8 &e\u26A1 &732 J/Block"); public static final SlimefunItemStack CHARGING_BENCH = new SlimefunItemStack("CHARGING_BENCH", Material.CRAFTING_TABLE, "&6Charging Bench", "", "&fCharges Items such as Jetpacks", "", LoreBuilder.machine(MachineTier.BASIC, MachineType.MACHINE), LoreBuilder.powerBuffer(128), "&8\u21E8 &e\u26A1 &7Energy Loss: &c50%"); + public static final SlimefunItemStack IRON_GOLEM_ASSEMBLER = new SlimefunItemStack("IRON_GOLEM_ASSEMBLER", Material.IRON_BLOCK, "&6Iron Golem Assembler", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), "&8\u21E8 &7Cooldown: &b30 Seconds", LoreBuilder.powerBuffer(4096), "&8\u21E8 &e\u26A1 &72048 J/Golem"); public static final SlimefunItemStack WITHER_ASSEMBLER = new SlimefunItemStack("WITHER_ASSEMBLER", Material.OBSIDIAN, "&5Wither Assembler", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), "&8\u21E8 &7Cooldown: &b30 Seconds", LoreBuilder.powerBuffer(4096), "&8\u21E8 &e\u26A1 &74096 J/Wither"); public static final SlimefunItemStack TRASH_CAN = new SlimefunItemStack("TRASH_CAN_BLOCK", HeadTexture.TRASH_CAN, "&3Trash Can", "", "&fWill destroy all Items put into it"); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java index 85fc62f3a..b46b45f22 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java @@ -41,12 +41,11 @@ import io.github.thebusybiscuit.slimefun4.core.services.PerWorldSettingsService; import io.github.thebusybiscuit.slimefun4.core.services.PermissionsService; import io.github.thebusybiscuit.slimefun4.core.services.UpdaterService; import io.github.thebusybiscuit.slimefun4.core.services.github.GitHubService; -import io.github.thebusybiscuit.slimefun4.core.services.metrics.MetricsService; +import io.github.thebusybiscuit.slimefun4.core.services.MetricsService; import io.github.thebusybiscuit.slimefun4.core.services.plugins.ThirdPartyPluginService; import io.github.thebusybiscuit.slimefun4.core.services.profiler.SlimefunProfiler; import io.github.thebusybiscuit.slimefun4.implementation.items.altar.AncientAltar; import io.github.thebusybiscuit.slimefun4.implementation.items.backpacks.Cooler; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.BasicCircuitBoard; import io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors.Reactor; import io.github.thebusybiscuit.slimefun4.implementation.items.tools.GrapplingHook; import io.github.thebusybiscuit.slimefun4.implementation.items.weapons.SeismicAxe; @@ -91,6 +90,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.setup.SlimefunItemSetup import io.github.thebusybiscuit.slimefun4.implementation.tasks.ArmorTask; import io.github.thebusybiscuit.slimefun4.implementation.tasks.SlimefunStartupTask; import io.github.thebusybiscuit.slimefun4.implementation.tasks.TickerTask; +import io.papermc.lib.PaperLib; import me.mrCookieSlime.CSCoreLibPlugin.CSCoreLib; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AGenerator; @@ -107,7 +107,7 @@ import me.mrCookieSlime.Slimefun.api.inventory.UniversalBlockMenu; */ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon { - public static SlimefunPlugin instance; + private static SlimefunPlugin instance; private MinecraftVersion minecraftVersion = MinecraftVersion.UNKNOWN; @@ -166,6 +166,8 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon { } else if (getServer().getPluginManager().isPluginEnabled("CS-CoreLib")) { long timestamp = System.nanoTime(); + + PaperLib.suggestPaper(this); // We wanna ensure that the Server uses a compatible version of Minecraft if (isVersionUnsupported()) { @@ -195,7 +197,7 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon { networkManager = new NetworkManager(networkSize); // Setting up bStats - metricsService.start(); + new Thread(metricsService::start).start(); // Starting the Auto-Updater if (config.getBoolean("options.auto-update")) { @@ -331,7 +333,7 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon { @Override public void onDisable() { // Slimefun never loaded successfully, so we don't even bother doing stuff here - if (instance == null || minecraftVersion == MinecraftVersion.UNIT_TEST) { + if (instance() == null || minecraftVersion == MinecraftVersion.UNIT_TEST) { return; } @@ -366,6 +368,8 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon { // Create a new backup zip backupService.run(); + metricsService.cleanUp(); + // Prevent Memory Leaks // These static Maps should be removed at some point... AContainer.processing = null; @@ -432,7 +436,7 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon { new BeeListener(this); } - new MobDropListener(this, (BasicCircuitBoard) SlimefunItems.BASIC_CIRCUIT_BOARD.getItem()); + new MobDropListener(this); // Item-specific Listeners new VampireBladeListener(this, (VampireBlade) SlimefunItems.BLADE_OF_VAMPIRES.getItem()); @@ -484,6 +488,10 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon { } } + public static SlimefunPlugin instance() { + return instance; + } + public static Config getCfg() { return instance.config; } @@ -564,6 +572,16 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon { return instance.updaterService; } + /** + * This method returns the {@link MetricsService} of Slimefun. + * It is used to handle sending metric information to bStats. + * + * @return The {@link MetricsService} for Slimefun + */ + public static MetricsService getMetricsService() { + return instance.metricsService; + } + /** * This method returns the {@link GitHubService} of Slimefun. * It is used to retrieve data from GitHub repositories. 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 cac68da1f..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 @@ -35,7 +35,7 @@ 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,7 +53,7 @@ public class BookSlimefunGuide implements SlimefunGuideImplementation { } private void openBook(Player p, PlayerProfile profile, List lines, boolean backButton) { - CustomBookInterface book = new CustomBookInterface(SlimefunPlugin.instance); + 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) { @@ -63,7 +63,7 @@ public class BookSlimefunGuide implements SlimefunGuideImplementation { header.setClickEvent(new ClickEvent(guideSearch, player -> Slimefun.runSync(() -> { SlimefunPlugin.getLocalization().sendMessage(player, "guide.search.message"); - ChatInput.waitForPlayer(SlimefunPlugin.instance, player, msg -> SlimefunGuide.openSearch(profile, msg, true, true)); + ChatInput.waitForPlayer(SlimefunPlugin.instance(), player, msg -> SlimefunGuide.openSearch(profile, msg, true, true)); }, 1))); page.append(header); @@ -77,7 +77,7 @@ public class BookSlimefunGuide implements SlimefunGuideImplementation { if (backButton) { ChatComponent button = new ChatComponent(ChatColor.DARK_BLUE + "\u21E6 " + SlimefunPlugin.getLocalization().getMessage(p, "guide.back.title")); button.setHoverEvent(new HoverEvent(ChatColor.DARK_BLUE + "\u21E6 " + SlimefunPlugin.getLocalization().getMessage(p, "guide.back.title"), "", ChatColor.GRAY + SlimefunPlugin.getLocalization().getMessage(p, "guide.back.guide"))); - button.setClickEvent(new ClickEvent(new NamespacedKey(SlimefunPlugin.instance, "slimefun_guide"), pl -> openMainMenu(profile, 1))); + button.setClickEvent(new ClickEvent(new NamespacedKey(SlimefunPlugin.instance(), "slimefun_guide"), pl -> openMainMenu(profile, 1))); page.append(button); } @@ -189,7 +189,7 @@ 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(); 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 6d8ead8b1..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 @@ -561,7 +561,7 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation { pl.closeInventory(); SlimefunPlugin.getLocalization().sendMessage(pl, "guide.search.message"); - ChatInput.waitForPlayer(SlimefunPlugin.instance, pl, msg -> SlimefunGuide.openSearch(profile, msg, isSurvivalMode(), isSurvivalMode())); + ChatInput.waitForPlayer(SlimefunPlugin.instance(), pl, msg -> SlimefunGuide.openSearch(profile, msg, isSurvivalMode(), isSurvivalMode())); return false; }); 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 f48420ec3..c2facc104 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 @@ -31,7 +31,7 @@ class RecipeChoiceTask implements Runnable { private Inventory inventory; private int id; - private Map> iterators = new HashMap<>(); + private final Map> iterators = new HashMap<>(); /** * This will start this task for the given {@link Inventory}. @@ -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/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/SimpleSlimefunItem.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/SimpleSlimefunItem.java similarity index 92% rename from src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/SimpleSlimefunItem.java rename to src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/SimpleSlimefunItem.java index 690b13c58..f8ce58999 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/SimpleSlimefunItem.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/SimpleSlimefunItem.java @@ -1,10 +1,11 @@ -package me.mrCookieSlime.Slimefun.Objects.SlimefunItem; +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; 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 8c2242596..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 @@ -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/ButcherAndroid.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ButcherAndroid.java index f0580738c..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 @@ -14,7 +14,6 @@ import org.bukkit.metadata.FixedMetadataValue; 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/Instruction.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Instruction.java index a2c70889b..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 @@ -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/ProgrammableAndroid.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ProgrammableAndroid.java index 874b13505..149614e11 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 @@ -14,6 +14,7 @@ import org.bukkit.Sound; import org.bukkit.Tag; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; +import org.bukkit.block.BlockState; import org.bukkit.block.Dispenser; import org.bukkit.block.data.BlockData; import org.bukkit.block.data.Rotatable; @@ -36,6 +37,7 @@ import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; import io.github.thebusybiscuit.slimefun4.utils.NumberUtils; import io.github.thebusybiscuit.slimefun4.utils.PatternUtils; import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.papermc.lib.PaperLib; import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.AdvancedMenuClickHandler; @@ -441,7 +443,7 @@ public abstract class ProgrammableAndroid extends SlimefunItem implements Invent 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.getLocalization().sendMessages(p, "android.scripts.uploaded"); openScriptDownloader(p, b, page); @@ -532,7 +534,7 @@ public abstract class ProgrammableAndroid extends SlimefunItem implements Invent private void registerDefaultFuelTypes() { switch (getFuelSource()) { case SOLID: - registerFuelType(new MachineFuel(800, new ItemStack(Material.COAL_BLOCK))); + registerFuelType(new MachineFuel(80, new ItemStack(Material.COAL_BLOCK))); registerFuelType(new MachineFuel(45, new ItemStack(Material.BLAZE_ROD))); registerFuelType(new MachineFuel(70, new ItemStack(Material.DRIED_KELP_BLOCK))); @@ -689,19 +691,23 @@ public abstract class ProgrammableAndroid extends SlimefunItem implements Invent protected void depositItems(BlockMenu menu, Block facedBlock) { if (facedBlock.getType() == Material.DISPENSER && BlockStorage.check(facedBlock, "ANDROID_INTERFACE_ITEMS")) { - Dispenser d = (Dispenser) facedBlock.getState(); + BlockState state = PaperLib.getBlockState(facedBlock, false).getState(); - for (int slot : getOutputSlots()) { - ItemStack stack = menu.getItemInSlot(slot); + if (state instanceof Dispenser) { + Dispenser d = (Dispenser) state; - if (stack != null) { - Optional optional = d.getInventory().addItem(stack).values().stream().findFirst(); + for (int slot : getOutputSlots()) { + ItemStack stack = menu.getItemInSlot(slot); - if (optional.isPresent()) { - menu.replaceExistingItem(slot, optional.get()); - } - else { - menu.replaceExistingItem(slot, null); + if (stack != null) { + Optional optional = d.getInventory().addItem(stack).values().stream().findFirst(); + + if (optional.isPresent()) { + menu.replaceExistingItem(slot, optional.get()); + } + else { + menu.replaceExistingItem(slot, null); + } } } } @@ -710,13 +716,17 @@ public abstract class ProgrammableAndroid extends SlimefunItem implements Invent protected void refuel(BlockMenu menu, Block facedBlock) { if (facedBlock.getType() == Material.DISPENSER && BlockStorage.check(facedBlock, "ANDROID_INTERFACE_FUEL")) { - Dispenser d = (Dispenser) facedBlock.getState(); + BlockState state = PaperLib.getBlockState(facedBlock, false).getState(); - for (int slot = 0; slot < 9; slot++) { - ItemStack item = d.getInventory().getItem(slot); + if (state instanceof Dispenser) { + Dispenser d = (Dispenser) state; - if (item != null) { - insertFuel(menu, d.getInventory(), slot, menu.getItemInSlot(43), item); + for (int slot = 0; slot < 9; slot++) { + ItemStack item = d.getInventory().getItem(slot); + + if (item != null) { + insertFuel(menu, d.getInventory(), slot, menu.getItemInSlot(43), item); + } } } } @@ -814,7 +824,7 @@ public abstract class ProgrammableAndroid extends SlimefunItem implements Invent } } - 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/WoodcutterAndroid.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/WoodcutterAndroid.java index 60c85e59e..f0900fa58 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 @@ -69,9 +69,7 @@ public abstract class WoodcutterAndroid extends ProgrammableAndroid { if (log.getY() == android.getRelative(face).getY()) { Optional sapling = MaterialConverter.getSaplingFromLog(log.getType()); - if (sapling.isPresent()) { - log.setType(sapling.get()); - } + sapling.ifPresent(log::setType); } else { log.setType(Material.AIR); 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 index 6cc0d0324..f50860c3b 100644 --- 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 @@ -30,7 +30,7 @@ public class HazmatArmorPiece extends SlimefunArmorPiece implements ProtectiveAr super(category, item, recipeType, recipe, effects); types = new ProtectionType[] { ProtectionType.BEES, ProtectionType.RADIATION }; - namespacedKey = new NamespacedKey(SlimefunPlugin.instance, "hazmat_suit"); + namespacedKey = new NamespacedKey(SlimefunPlugin.instance(), "hazmat_suit"); } @Override 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 288ca6c69..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 @@ -6,9 +6,9 @@ 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.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 359f9fff8..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 @@ -7,10 +7,10 @@ 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.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.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 6b2f02caa..096941e03 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 @@ -21,9 +21,9 @@ import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable; 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.api.BlockStorage; import me.mrCookieSlime.Slimefun.api.Slimefun; @@ -31,7 +31,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; public class BlockPlacer extends SimpleSlimefunItem { - private ItemSetting> blacklist = new ItemSetting<>("unplaceable-blocks", MaterialCollections.getAllUnbreakableBlocks().stream().map(Material::name).collect(Collectors.toList())); + private final ItemSetting> blacklist = new ItemSetting<>("unplaceable-blocks", MaterialCollections.getAllUnbreakableBlocks().stream().map(Material::name).collect(Collectors.toList())); public BlockPlacer(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { super(category, item, recipeType, recipe); 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 cbb7bd53c..43ac95fc8 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 @@ -10,6 +10,7 @@ import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; +import org.bukkit.block.BlockState; import org.bukkit.block.Chest; import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; @@ -22,10 +23,11 @@ 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 io.papermc.lib.PaperLib; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; -import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem; import me.mrCookieSlime.Slimefun.api.BlockStorage; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; @@ -98,7 +100,7 @@ public class Composter extends SimpleSlimefunItem implements Re pushItem(b, output.clone()); }); - tasks.execute(SlimefunPlugin.instance); + tasks.execute(SlimefunPlugin.instance()); } else { SlimefunPlugin.getLocalization().sendMessage(p, "machines.wrong-item", true); @@ -129,10 +131,14 @@ public class Composter extends SimpleSlimefunItem implements Re if (id != null && id.equals("OUTPUT_CHEST")) { // Found the output chest! Now, let's check if we can fit the product in it. - Inventory inv = ((Chest) potentialOutput.getState()).getInventory(); + BlockState state = PaperLib.getBlockState(potentialOutput, false).getState(); - if (InvUtils.fits(inv, output)) { - return Optional.of(inv); + if (state instanceof Chest) { + Inventory inv = ((Chest) state).getInventory(); + + if (InvUtils.fits(inv, output)) { + return Optional.of(inv); + } } } } 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 e866be381..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 @@ -19,10 +19,10 @@ 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.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; -import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem; 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/EnhancedFurnace.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/EnhancedFurnace.java index 24012fc56..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; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/HardenedGlass.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/HardenedGlass.java new file mode 100644 index 000000000..8c947e937 --- /dev/null +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/HardenedGlass.java @@ -0,0 +1,28 @@ +package io.github.thebusybiscuit.slimefun4.implementation.items.blocks; + +import org.bukkit.entity.Wither; +import org.bukkit.entity.WitherSkull; +import org.bukkit.inventory.ItemStack; + +import io.github.thebusybiscuit.slimefun4.core.attributes.WitherProof; +import me.mrCookieSlime.Slimefun.Lists.RecipeType; +import me.mrCookieSlime.Slimefun.Objects.Category; +import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; + +/** + * {@link HardenedGlass} is a special kind of block which cannot be destroyed by explosions. + * It is partially {@link WitherProof}, as it cannot be destroyed through explosions caused by + * a {@link WitherSkull}. However the {@link Wither} is still able to destroy it directly. + * + * @author TheBusyBiscuit + * + * @see WitherProofBlock + * + */ +public class HardenedGlass extends WitherProofBlock { + + public HardenedGlass(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput) { + super(category, item, recipeType, recipe, recipeOutput); + } + +} 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 ff09249af..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 @@ -13,13 +13,13 @@ 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.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.api.BlockStorage; 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 613a72fc4..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 @@ -3,9 +3,9 @@ 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.api.SlimefunItemStack; public class RainbowBlock extends SimpleSlimefunItem { 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 d64ef794d..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 @@ -10,10 +10,10 @@ 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.api.SlimefunItemStack; public class RepairedSpawner extends SimpleSlimefunItem { 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 688d4571c..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 @@ -5,9 +5,9 @@ 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.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/CargoConnectorNode.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoConnectorNode.java index 16da4bca6..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 @@ -7,9 +7,9 @@ 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.api.SlimefunItemStack; public class CargoConnectorNode extends SimpleSlimefunItem { 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 29ff47e5b..bd1e20633 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 @@ -46,8 +46,6 @@ public class CargoManager extends SlimefunItem { }, new BlockUseHandler() { - private String visualizerKey = "visualizer"; - @Override public void onRightClick(PlayerRightClickEvent e) { Optional block = e.getClickedBlock(); @@ -56,12 +54,12 @@ public class CargoManager extends SlimefunItem { Player p = e.getPlayer(); Block b = block.get(); - if (BlockStorage.getLocationInfo(b.getLocation(), visualizerKey) == null) { - BlockStorage.addBlockInfo(b, visualizerKey, "disabled"); + if (BlockStorage.getLocationInfo(b.getLocation(), "visualizer") == null) { + BlockStorage.addBlockInfo(b, "visualizer", "disabled"); p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&cCargo Net Visualizer: " + "&4\u2718")); } else { - BlockStorage.addBlockInfo(b, visualizerKey, null); + BlockStorage.addBlockInfo(b, "visualizer", null); p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&cCargo Net Visualizer: " + "&2\u2714")); } } 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 4f31246ec..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 @@ -11,8 +11,8 @@ 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.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,12 +166,11 @@ public class ReactorAccessPort extends SlimefunItem { } private BlockMenu getReactor(Location l) { - Location reactorL = new Location(l.getWorld(), l.getX(), l.getY() - 3, l.getZ()); - - SlimefunItem item = BlockStorage.check(reactorL.getBlock()); + Location location = new Location(l.getWorld(), l.getX(), l.getY() - 3, l.getZ()); + SlimefunItem item = BlockStorage.check(location.getBlock()); if (item instanceof Reactor) { - return BlockStorage.getInventory(reactorL); + return BlockStorage.getInventory(location); } return null; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/AbstractEnergyProvider.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/AbstractEnergyProvider.java index 8a7700f03..b6f9252b5 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/AbstractEnergyProvider.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/AbstractEnergyProvider.java @@ -5,17 +5,19 @@ import java.util.HashSet; import java.util.List; import java.util.Set; +import org.bukkit.Location; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import io.github.thebusybiscuit.cscorelib2.chat.ChatColors; import io.github.thebusybiscuit.cscorelib2.math.DoubleHandler; -import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetComponent; +import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetProvider; import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem; import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNetComponentType; import io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors.Reactor; import io.github.thebusybiscuit.slimefun4.utils.NumberUtils; +import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; @@ -34,7 +36,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; * @see Reactor * */ -public abstract class AbstractEnergyProvider extends SlimefunItem implements InventoryBlock, RecipeDisplayItem, EnergyNetComponent { +public abstract class AbstractEnergyProvider extends SlimefunItem implements InventoryBlock, RecipeDisplayItem, EnergyNetProvider { protected final Set fuelTypes = new HashSet<>(); @@ -79,13 +81,48 @@ public abstract class AbstractEnergyProvider extends SlimefunItem implements Inv return EnergyNetComponentType.GENERATOR; } - protected abstract GeneratorTicker onTick(); + /** + * @deprecated Please implement the methods + * {@link #getGeneratedOutput(org.bukkit.Location, me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config)} + * and {@link #willExplode(org.bukkit.Location, me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config)} + * instead + * + * @return A {@link GeneratorTicker} + */ + @Deprecated + protected GeneratorTicker onTick() { + return null; + } + + @Override + public int getGeneratedOutput(Location l, Config data) { + if (generatorTicker != null) { + return (int) generatorTicker.generateEnergy(l, this, data); + } + else { + return 0; + } + } + + @Override + public boolean willExplode(Location l, Config data) { + if (generatorTicker != null) { + return generatorTicker.explode(l); + } + else { + return false; + } + } @Override public void preRegister() { super.preRegister(); - addItemHandler(onTick()); + GeneratorTicker ticker = onTick(); + + if (ticker != null) { + addItemHandler(ticker); + } } public void registerFuel(MachineFuel fuel) { 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 437f1e4d4..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 @@ -9,9 +9,9 @@ import org.bukkit.inventory.ItemStack; import io.github.thebusybiscuit.cscorelib2.math.DoubleHandler; 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.api.SlimefunItemStack; import me.mrCookieSlime.Slimefun.api.energy.ChargableBlock; 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 f7042c789..5513058bc 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 @@ -6,23 +6,25 @@ 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.attributes.EnergyNetProvider; import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler; import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNetComponentType; 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.GeneratorTicker; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; -public abstract class SolarGenerator extends SimpleSlimefunItem implements EnergyNetComponent { +public class SolarGenerator extends SlimefunItem implements EnergyNetProvider { - private static final int DEFAULT_NIGHT_ENERGY = 0; + private final int dayEnergy; + private final int nightEnergy; - public SolarGenerator(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { + public SolarGenerator(Category category, int dayEnergy, int nightEnergy, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { super(category, item, recipeType, recipe); + + this.dayEnergy = dayEnergy; + this.nightEnergy = nightEnergy; } /** @@ -31,19 +33,18 @@ public abstract class SolarGenerator extends SimpleSlimefunItem * * @return The amount of energy generated at daylight */ - public abstract double getDayEnergy(); + public int getDayEnergy() { + return dayEnergy; + } /** * This method returns the amount of energy that this {@link SolarGenerator} * produces during the night. * - * This is 0 by default. - * * @return The amount of energy generated at night time */ - public double getNightEnergy() { - // Override this as necessary for highly advanced Solar Generators - return DEFAULT_NIGHT_ENERGY; + public int getNightEnergy() { + return nightEnergy; } @Override @@ -57,40 +58,29 @@ public abstract class SolarGenerator extends SimpleSlimefunItem } @Override - public GeneratorTicker getItemHandler() { - return new GeneratorTicker() { + public int getGeneratedOutput(Location l, Config data) { + World world = l.getWorld(); - @Override - public double generateEnergy(Location l, SlimefunItem item, Config data) { - World world = l.getWorld(); + if (world.getEnvironment() != Environment.NORMAL) { + return 0; + } - if (world.getEnvironment() != Environment.NORMAL) { - return 0; - } + boolean isDaytime = isDaytime(world); - boolean isDaytime = isDaytime(world); + // Performance optimization for daytime-only solar generators + if (!isDaytime && getNightEnergy() < 0.1) { + return 0; + } - // 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 (!world.isChunkLoaded(l.getBlockX() >> 4, l.getBlockZ() >> 4) || l.getBlock().getLightFromSky() != 15) { - return 0; - } + if (isDaytime) { + return getDayEnergy(); + } - if (isDaytime) { - return getDayEnergy(); - } - - return getNightEnergy(); - } - - @Override - public boolean explode(Location l) { - return false; - } - }; + return getNightEnergy(); } /** diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AbstractEntityAssembler.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AbstractEntityAssembler.java new file mode 100644 index 000000000..083d9a741 --- /dev/null +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AbstractEntityAssembler.java @@ -0,0 +1,293 @@ +package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import io.github.thebusybiscuit.cscorelib2.item.CustomItem; +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.Lists.RecipeType; +import me.mrCookieSlime.Slimefun.Objects.Category; +import me.mrCookieSlime.Slimefun.Objects.SlimefunBlockHandler; +import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; +import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.UnregisterReason; +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.energy.ChargableBlock; +import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; +import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset; +import me.mrCookieSlime.Slimefun.api.inventory.DirtyChestMenu; +import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow; + +/** + * This is an abstract super class for Entity Assemblers. + * + * @author TheBusyBiscuit + * + * @see WitherAssembler + * @see IronGolemAssembler + * + */ +public abstract class AbstractEntityAssembler extends SimpleSlimefunItem implements EnergyNetComponent { + + private final int[] border = { 0, 2, 3, 4, 5, 6, 8, 12, 14, 21, 23, 30, 32, 39, 40, 41 }; + private final int[] inputSlots = { 19, 28, 25, 34 }; + + private final int[] headSlots = { 19, 28 }; + private final int[] headBorder = { 9, 10, 11, 18, 20, 27, 29, 36, 37, 38 }; + + private final int[] bodySlots = { 25, 34 }; + private final int[] bodyBorder = { 15, 16, 17, 24, 26, 33, 35, 42, 43, 44 }; + + private int lifetime = 0; + + public AbstractEntityAssembler(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { + super(category, item, recipeType, recipe); + + new BlockMenuPreset(getID(), item.getImmutableMeta().getDisplayName().orElse("Entity Assembler")) { + + @Override + public void init() { + for (int i : border) { + addItem(i, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler()); + } + + for (int i : headBorder) { + addItem(i, new CustomItem(getHeadBorder(), " "), ChestMenuUtils.getEmptyClickHandler()); + } + + for (int i : bodyBorder) { + addItem(i, new CustomItem(getBodyBorder(), " "), ChestMenuUtils.getEmptyClickHandler()); + } + + constructMenu(this); + } + + @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(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); + return false; + }); + } + else { + 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); + return false; + }); + } + + 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(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)); + newInstance(menu, b); + return false; + }); + } + + @Override + public boolean canOpen(Block b, Player p) { + return p.hasPermission("slimefun.inventory.bypass") || SlimefunPlugin.getProtectionManager().hasPermission(p, b.getLocation(), ProtectableAction.ACCESS_INVENTORIES); + } + + @Override + public int[] getSlotsAccessedByItemTransport(ItemTransportFlow flow) { + if (flow == ItemTransportFlow.INSERT) { + return inputSlots; + } + else { + return new int[0]; + } + } + + @Override + public int[] getSlotsAccessedByItemTransport(DirtyChestMenu menu, ItemTransportFlow flow, ItemStack item) { + if (flow == ItemTransportFlow.INSERT && item != null) { + if (item.getType() == getBody().getType()) { + return bodySlots; + } + + if (item.getType() == getHead().getType()) { + return headSlots; + } + } + + return new int[0]; + } + }; + + registerBlockHandler(getID(), new SlimefunBlockHandler() { + + @Override + public void onPlace(Player p, Block b, SlimefunItem item) { + BlockStorage.addBlockInfo(b, "offset", "3.0"); + BlockStorage.addBlockInfo(b, "enabled", String.valueOf(false)); + } + + @Override + public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) { + if (reason == UnregisterReason.EXPLODE) { + return false; + } + + BlockMenu inv = BlockStorage.getInventory(b); + + if (inv != null) { + for (int slot : bodySlots) { + if (inv.getItemInSlot(slot) != null) { + b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot)); + inv.replaceExistingItem(slot, null); + } + } + + for (int slot : headSlots) { + if (inv.getItemInSlot(slot) != null) { + b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot)); + inv.replaceExistingItem(slot, null); + } + } + } + + return true; + } + }); + } + + @Override + public BlockTicker getItemHandler() { + return new BlockTicker() { + + @Override + public void tick(Block b, SlimefunItem sf, Config data) { + if (String.valueOf(false).equals(BlockStorage.getLocationInfo(b.getLocation(), "enabled"))) { + return; + } + + if (lifetime % 60 == 0 && ChargableBlock.getCharge(b) >= getEnergyConsumption()) { + BlockMenu menu = BlockStorage.getInventory(b); + + boolean hasBody = findResource(menu, getBody(), bodySlots); + boolean hasHead = findResource(menu, getHead(), headSlots); + + if (hasBody && hasHead) { + consumeResources(menu); + + ChargableBlock.addCharge(b, -getEnergyConsumption()); + double offset = Double.parseDouble(BlockStorage.getLocationInfo(b.getLocation(), "offset")); + + Slimefun.runSync(() -> { + Location loc = new Location(b.getWorld(), b.getX() + 0.5D, b.getY() + offset, b.getZ() + 0.5D); + b.getWorld().spawnEntity(loc, EntityType.WITHER); + }); + } + } + } + + @Override + public void uniqueTick() { + lifetime++; + } + + @Override + public boolean isSynchronized() { + return false; + } + }; + } + + private boolean findResource(BlockMenu menu, ItemStack item, int[] slots) { + Material resource = item.getType(); + int required = item.getAmount(); + int found = 0; + + for (int slot : slots) { + if (SlimefunUtils.isItemSimilar(menu.getItemInSlot(slot), new ItemStack(resource), true, false)) { + found += menu.getItemInSlot(slot).getAmount(); + + if (found > required) { + return true; + } + } + } + + return false; + } + + private void consumeResources(BlockMenu inv) { + int bodyCount = getBody().getAmount(); + int headCount = getHead().getAmount(); + + for (int slot : bodySlots) { + if (SlimefunUtils.isItemSimilar(inv.getItemInSlot(slot), new ItemStack(getBody().getType()), true, false)) { + int amount = inv.getItemInSlot(slot).getAmount(); + + if (amount >= bodyCount) { + inv.consumeItem(slot, bodyCount); + break; + } + else { + bodyCount -= amount; + inv.replaceExistingItem(slot, null); + } + } + } + + for (int slot : headSlots) { + if (SlimefunUtils.isItemSimilar(inv.getItemInSlot(slot), new ItemStack(getHead().getType()), true, false)) { + int amount = inv.getItemInSlot(slot).getAmount(); + + if (amount >= headCount) { + inv.consumeItem(slot, headCount); + break; + } + else { + headCount -= amount; + inv.replaceExistingItem(slot, null); + } + } + } + } + + protected void constructMenu(BlockMenuPreset preset) { + preset.addItem(1, new CustomItem(getHead(), "&7Head Slot", "", "&rThis Slot accepts the head type"), ChestMenuUtils.getEmptyClickHandler()); + preset.addItem(7, new CustomItem(getBody(), "&7Body Slot", "", "&rThis Slot accepts the body type"), ChestMenuUtils.getEmptyClickHandler()); + preset.addItem(13, new CustomItem(Material.CLOCK, "&7Cooldown: &b30 Seconds", "", "&rThis Machine takes up to half a Minute to operate", "&rso give it some Time!"), ChestMenuUtils.getEmptyClickHandler()); + } + + @Override + public EnergyNetComponentType getEnergyComponentType() { + return EnergyNetComponentType.CONSUMER; + } + + public abstract int getEnergyConsumption(); + + public abstract ItemStack getHead(); + + public abstract ItemStack getBody(); + + public abstract Material getHeadBorder(); + + public abstract Material getBodyBorder(); + +} 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/IronGolemAssembler.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/IronGolemAssembler.java new file mode 100644 index 000000000..d5532cd3b --- /dev/null +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/IronGolemAssembler.java @@ -0,0 +1,66 @@ +package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines; + +import org.bukkit.Material; +import org.bukkit.entity.IronGolem; +import org.bukkit.inventory.ItemStack; + +import io.github.thebusybiscuit.cscorelib2.item.CustomItem; +import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; +import me.mrCookieSlime.Slimefun.Lists.RecipeType; +import me.mrCookieSlime.Slimefun.Objects.Category; +import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; +import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset; + +/** + * The {@link IronGolemAssembler} is an electrical machine that can automatically spawn + * a {@link IronGolem} if the required ingredients have been provided. + * + * @author TheBusyBiscuit + * + * @see WitherAssembler + * + */ +public class IronGolemAssembler extends AbstractEntityAssembler { + + public IronGolemAssembler(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { + super(category, item, recipeType, recipe); + } + + @Override + public int getCapacity() { + return 4096; + } + + @Override + public int getEnergyConsumption() { + return 2048; + } + + @Override + public ItemStack getHead() { + return new ItemStack(Material.PUMPKIN); + } + + @Override + public Material getHeadBorder() { + return Material.ORANGE_STAINED_GLASS_PANE; + } + + @Override + public ItemStack getBody() { + return new ItemStack(Material.IRON_BLOCK, 4); + } + + @Override + public Material getBodyBorder() { + return Material.WHITE_STAINED_GLASS_PANE; + } + + @Override + protected void constructMenu(BlockMenuPreset preset) { + preset.addItem(1, new CustomItem(getHead(), "&7Pumpkin Slot", "", "&rThis Slot accepts Pumpkins"), ChestMenuUtils.getEmptyClickHandler()); + preset.addItem(7, new CustomItem(getBody(), "&7Iron Block Slot", "", "&rThis Slot accepts Iron Blocks"), ChestMenuUtils.getEmptyClickHandler()); + preset.addItem(13, new CustomItem(Material.CLOCK, "&7Cooldown: &b30 Seconds", "", "&rThis Machine takes up to half a Minute to operate", "&rso give it some Time!"), ChestMenuUtils.getEmptyClickHandler()); + } + +} 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 549d1f938..3cedfb251 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 @@ -1,182 +1,29 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines; -import org.bukkit.Location; import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; import org.bukkit.entity.Wither; import org.bukkit.inventory.ItemStack; import io.github.thebusybiscuit.cscorelib2.item.CustomItem; -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.utils.ChestMenuUtils; -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.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; -import me.mrCookieSlime.Slimefun.api.BlockStorage; -import me.mrCookieSlime.Slimefun.api.Slimefun; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; -import me.mrCookieSlime.Slimefun.api.energy.ChargableBlock; -import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset; -import me.mrCookieSlime.Slimefun.api.inventory.DirtyChestMenu; -import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow; /** * The {@link WitherAssembler} is an electrical machine that can automatically spawn * a {@link Wither} if the required ingredients have been provided. * * @author TheBusyBiscuit + * + * @see IronGolemAssembler * */ -public class WitherAssembler extends SimpleSlimefunItem implements EnergyNetComponent { - - private static final int ENERGY_CONSUMPTION = 4096; - - private final int[] border = { 0, 2, 3, 4, 5, 6, 8, 12, 14, 21, 23, 30, 32, 39, 40, 41 }; - private final int[] skullBorder = { 9, 10, 11, 18, 20, 27, 29, 36, 37, 38 }; - private final int[] sandBorder = { 15, 16, 17, 24, 26, 33, 35, 42, 43, 44 }; - - private int lifetime = 0; +public class WitherAssembler extends AbstractEntityAssembler { public WitherAssembler(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { super(category, item, recipeType, recipe); - - new BlockMenuPreset(getID(), "&5Wither Assembler") { - - @Override - public void init() { - constructMenu(this); - } - - @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.addMenuClickHandler(22, (p, slot, item, action) -> { - BlockStorage.addBlockInfo(b, "enabled", String.valueOf(true)); - newInstance(menu, b); - return false; - }); - } - else { - menu.replaceExistingItem(22, new CustomItem(new ItemStack(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); - return false; - }); - } - - 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.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)); - newInstance(menu, b); - return false; - }); - } - - @Override - public boolean canOpen(Block b, Player p) { - return p.hasPermission("slimefun.inventory.bypass") || SlimefunPlugin.getProtectionManager().hasPermission(p, b.getLocation(), ProtectableAction.ACCESS_INVENTORIES); - } - - @Override - public int[] getSlotsAccessedByItemTransport(ItemTransportFlow flow) { - 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(); - } - else return new int[0]; - } - }; - - registerBlockHandler(getID(), new SlimefunBlockHandler() { - - @Override - public void onPlace(Player p, Block b, SlimefunItem item) { - BlockStorage.addBlockInfo(b, "offset", "3.0"); - BlockStorage.addBlockInfo(b, "enabled", String.valueOf(false)); - } - - @Override - public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) { - if (reason == UnregisterReason.EXPLODE) return false; - BlockMenu inv = BlockStorage.getInventory(b); - - if (inv != null) { - for (int slot : getSoulSandSlots()) { - if (inv.getItemInSlot(slot) != null) { - b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot)); - inv.replaceExistingItem(slot, null); - } - } - - for (int slot : getWitherSkullSlots()) { - if (inv.getItemInSlot(slot) != null) { - b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot)); - inv.replaceExistingItem(slot, null); - } - } - } - return true; - } - }); - } - - private void constructMenu(BlockMenuPreset preset) { - for (int i : border) { - preset.addItem(i, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler()); - } - - for (int i : skullBorder) { - preset.addItem(i, new CustomItem(Material.BLACK_STAINED_GLASS_PANE, " "), ChestMenuUtils.getEmptyClickHandler()); - } - - for (int i : sandBorder) { - preset.addItem(i, new CustomItem(Material.BROWN_STAINED_GLASS_PANE, " "), ChestMenuUtils.getEmptyClickHandler()); - } - - preset.addItem(1, new CustomItem(Material.WITHER_SKELETON_SKULL, "&7Wither Skull Slot", "", "&rThis Slot accepts Wither Skeleton Skulls"), ChestMenuUtils.getEmptyClickHandler()); - preset.addItem(7, new CustomItem(Material.SOUL_SAND, "&7Soul Sand Slot", "", "&rThis Slot accepts Soul Sand"), ChestMenuUtils.getEmptyClickHandler()); - preset.addItem(13, new CustomItem(Material.CLOCK, "&7Cooldown: &b30 Seconds", "", "&rThis Machine takes up to half a Minute to operate", "&rso give it some Time!"), ChestMenuUtils.getEmptyClickHandler()); - } - - public int[] getInputSlots() { - return new int[] { 19, 28, 25, 34 }; - } - - public int[] getWitherSkullSlots() { - return new int[] { 19, 28 }; - } - - public int[] getSoulSandSlots() { - return new int[] { 25, 34 }; - } - - @Override - public EnergyNetComponentType getEnergyComponentType() { - return EnergyNetComponentType.CONSUMER; } @Override @@ -185,93 +32,35 @@ public class WitherAssembler extends SimpleSlimefunItem implements } @Override - public BlockTicker getItemHandler() { - return new BlockTicker() { - - @Override - public void tick(Block b, SlimefunItem sf, Config data) { - if (String.valueOf(false).equals(BlockStorage.getLocationInfo(b.getLocation(), "enabled"))) { - return; - } - - if (lifetime % 60 == 0 && ChargableBlock.getCharge(b) >= ENERGY_CONSUMPTION) { - BlockMenu menu = BlockStorage.getInventory(b); - - boolean soulsand = findResource(menu, Material.SOUL_SAND, 4, getSoulSandSlots()); - boolean skulls = findResource(menu, Material.WITHER_SKELETON_SKULL, 3, getWitherSkullSlots()); - - if (soulsand && skulls) { - consumeResources(menu); - - ChargableBlock.addCharge(b, -ENERGY_CONSUMPTION); - double offset = Double.parseDouble(BlockStorage.getLocationInfo(b.getLocation(), "offset")); - - Slimefun.runSync(() -> b.getWorld().spawnEntity(new Location(b.getWorld(), b.getX() + 0.5D, b.getY() + offset, b.getZ() + 0.5D), EntityType.WITHER)); - } - } - } - - @Override - public void uniqueTick() { - lifetime++; - } - - @Override - public boolean isSynchronized() { - return false; - } - }; + public int getEnergyConsumption() { + return 4096; } - private boolean findResource(BlockMenu menu, Material resource, int required, int[] slots) { - int found = 0; - - for (int slot : slots) { - if (SlimefunUtils.isItemSimilar(menu.getItemInSlot(slot), new ItemStack(resource), true)) { - found += menu.getItemInSlot(slot).getAmount(); - - if (found > required) { - return true; - } - } - } - - return false; + @Override + public ItemStack getHead() { + return new ItemStack(Material.WITHER_SKELETON_SKULL, 3); } - private void consumeResources(BlockMenu inv) { - int soulsand = 4; - int skulls = 3; + @Override + public Material getHeadBorder() { + return Material.BLACK_STAINED_GLASS_PANE; + } - for (int slot : getSoulSandSlots()) { - if (SlimefunUtils.isItemSimilar(inv.getItemInSlot(slot), new ItemStack(Material.SOUL_SAND), true)) { - int amount = inv.getItemInSlot(slot).getAmount(); + @Override + public ItemStack getBody() { + return new ItemStack(Material.SOUL_SAND, 4); + } - if (amount >= soulsand) { - inv.consumeItem(slot, soulsand); - break; - } - else { - soulsand -= amount; - inv.replaceExistingItem(slot, null); - } - } - } + @Override + public Material getBodyBorder() { + return Material.BROWN_STAINED_GLASS_PANE; + } - for (int slot : getWitherSkullSlots()) { - if (SlimefunUtils.isItemSimilar(inv.getItemInSlot(slot), new ItemStack(Material.WITHER_SKELETON_SKULL), true)) { - int amount = inv.getItemInSlot(slot).getAmount(); - - if (amount >= skulls) { - inv.consumeItem(slot, skulls); - break; - } - else { - skulls -= amount; - inv.replaceExistingItem(slot, null); - } - } - } + @Override + protected void constructMenu(BlockMenuPreset preset) { + preset.addItem(1, new CustomItem(getHead(), "&7Wither Skeleton Skull Slot", "", "&rThis Slot accepts Wither Skeleton Skulls"), ChestMenuUtils.getEmptyClickHandler()); + preset.addItem(7, new CustomItem(getBody(), "&7Soul Sand Slot", "", "&rThis Slot accepts Soul Sand"), ChestMenuUtils.getEmptyClickHandler()); + preset.addItem(13, new CustomItem(Material.CLOCK, "&7Cooldown: &b30 Seconds", "", "&rThis Machine takes up to half a Minute to operate", "&rso give it some Time!"), ChestMenuUtils.getEmptyClickHandler()); } } 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 582fd78e5..81e77ce96 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 @@ -29,14 +29,11 @@ import io.github.thebusybiscuit.slimefun4.utils.holograms.SimpleHologram; import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; 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.AGenerator; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineFuel; -import me.mrCookieSlime.Slimefun.Objects.handlers.GeneratorTicker; import me.mrCookieSlime.Slimefun.api.BlockStorage; import me.mrCookieSlime.Slimefun.api.Slimefun; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; -import me.mrCookieSlime.Slimefun.api.energy.ChargableBlock; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset; import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow; @@ -72,6 +69,8 @@ public abstract class Reactor extends AbstractEnergyProvider { // No coolant border private static final int[] border_4 = { 25, 34, 43 }; + private final Set explosionsQueue = new HashSet<>(); + public Reactor(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { super(category, item, recipeType, recipe); @@ -107,7 +106,7 @@ public abstract class Reactor extends AbstractEnergyProvider { BlockMenu port = getAccessPort(b.getLocation()); if (port != null) { - menu.replaceExistingItem(INFO_SLOT, new CustomItem(new ItemStack(Material.GREEN_WOOL), "&7Access Port", "", "&6Detected", "", "&7> Click to view Access Port")); + menu.replaceExistingItem(INFO_SLOT, new CustomItem(Material.GREEN_WOOL, "&7Access Port", "", "&6Detected", "", "&7> Click to view Access Port")); menu.addMenuClickHandler(INFO_SLOT, (p, slot, item, action) -> { port.open(p); newInstance(menu, b); @@ -116,7 +115,7 @@ public abstract class Reactor extends AbstractEnergyProvider { }); } else { - menu.replaceExistingItem(INFO_SLOT, new CustomItem(new ItemStack(Material.RED_WOOL), "&7Access Port", "", "&cNot detected", "", "&7Access Port must be", "&7placed 3 blocks above", "&7a reactor!")); + menu.replaceExistingItem(INFO_SLOT, new CustomItem(Material.RED_WOOL, "&7Access Port", "", "&cNot detected", "", "&7Access Port must be", "&7placed 3 blocks above", "&7a reactor!")); menu.addMenuClickHandler(INFO_SLOT, (p, slot, item, action) -> { newInstance(menu, b); menu.open(p); @@ -261,89 +260,86 @@ public abstract class Reactor extends AbstractEnergyProvider { } @Override - protected GeneratorTicker onTick() { - return new GeneratorTicker() { + public int getGeneratedOutput(Location l, Config data) { + BlockMenu inv = BlockStorage.getInventory(l); + BlockMenu accessPort = getAccessPort(l); - private final Set explosionsQueue = new HashSet<>(); + if (isProcessing(l)) { + extraTick(l); + int timeleft = progress.get(l); - @Override - public double generateEnergy(Location l, SlimefunItem sf, Config data) { - BlockMenu inv = BlockStorage.getInventory(l); - BlockMenu accessPort = getAccessPort(l); - int charge = ChargableBlock.getCharge(l); + if (timeleft > 0) { + int produced = getEnergyProduction(); + int charge = 0; - if (isProcessing(l)) { - extraTick(l); - int timeleft = progress.get(l); + if (data.contains("energy-charge")) { + charge = Integer.parseInt(data.getString("energy-charge")); + } - if (timeleft > 0) { - int produced = getEnergyProduction(); - int space = getCapacity() - charge; + int space = getCapacity() - charge; - if (space >= produced || !ReactorMode.GENERATOR.toString().equals(BlockStorage.getLocationInfo(l, MODE))) { - progress.put(l, timeleft - 1); - checkForWaterBlocks(l); + if (space >= produced || !ReactorMode.GENERATOR.toString().equals(BlockStorage.getLocationInfo(l, MODE))) { + progress.put(l, timeleft - 1); + checkForWaterBlocks(l); - ChestMenuUtils.updateProgressbar(inv, 22, timeleft, processing.get(l).getTicks(), getProgressBar()); + ChestMenuUtils.updateProgressbar(inv, 22, timeleft, processing.get(l).getTicks(), getProgressBar()); - if (needsCooling() && !hasEnoughCoolant(l, inv, accessPort, timeleft)) { - explosionsQueue.add(l); - return 0; - } - } - - if (space >= produced) { - ChargableBlock.addCharge(l, getEnergyProduction()); - return (double) (charge + getEnergyProduction()); - } - else { - return charge; - } - } - else { - createByproduct(l, inv, accessPort); - return charge; + if (needsCooling() && !hasEnoughCoolant(l, inv, accessPort, timeleft)) { + explosionsQueue.add(l); + return 0; } } + + if (space >= produced) { + return getEnergyProduction(); + } else { - burnNextFuel(l, inv, accessPort); - return charge; + return 0; } } - - @Override - public boolean explode(Location l) { - boolean explosion = explosionsQueue.contains(l); - - if (explosion) { - Slimefun.runSync(() -> { - ReactorExplodeEvent event = new ReactorExplodeEvent(l, Reactor.this); - Bukkit.getPluginManager().callEvent(event); - - BlockStorage.getInventory(l).close(); - SimpleHologram.remove(l.getBlock()); - }); - - explosionsQueue.remove(l); - processing.remove(l); - progress.remove(l); - } - - return explosion; + else { + createByproduct(l, inv, accessPort); + return 0; } + } + else { + burnNextFuel(l, inv, accessPort); + return 0; + } + } - private void checkForWaterBlocks(Location l) { - Slimefun.runSync(() -> { - // We will pick a surrounding block at random and see if this is water. - // If it isn't, then we will make it explode. - BlockFace randomNeighbour = WATER_BLOCKS[ThreadLocalRandom.current().nextInt(WATER_BLOCKS.length)]; + @Override + public boolean willExplode(Location l, Config data) { + boolean explosion = explosionsQueue.contains(l); - if (l.getBlock().getRelative(randomNeighbour).getType() != Material.WATER) { - explosionsQueue.add(l); - } - }); + if (explosion) { + Slimefun.runSync(() -> { + ReactorExplodeEvent event = new ReactorExplodeEvent(l, Reactor.this); + Bukkit.getPluginManager().callEvent(event); + + BlockStorage.getInventory(l).close(); + SimpleHologram.remove(l.getBlock()); + }); + + explosionsQueue.remove(l); + processing.remove(l); + progress.remove(l); + } + + return explosion; + } + + private void checkForWaterBlocks(Location l) { + Slimefun.runSync(() -> { + // We will pick a surrounding block at random and see if this is water. + // If it isn't, then we will make it explode. + int index = ThreadLocalRandom.current().nextInt(WATER_BLOCKS.length); + BlockFace randomNeighbour = WATER_BLOCKS[index]; + + if (l.getBlock().getRelative(randomNeighbour).getType() != Material.WATER) { + explosionsQueue.add(l); } - }; + }); } private void createByproduct(Location l, BlockMenu inv, BlockMenu accessPort) { @@ -404,7 +400,8 @@ public abstract class Reactor extends AbstractEnergyProvider { if (accessPort != null) { for (int slot : getCoolantSlots()) { if (SlimefunUtils.isItemSimilar(accessPort.getItemInSlot(slot), getCoolant(), true)) { - accessPort.replaceExistingItem(slot, menu.pushItem(accessPort.getItemInSlot(slot), getCoolantSlots())); + ItemStack remainingItem = menu.pushItem(accessPort.getItemInSlot(slot), getCoolantSlots()); + accessPort.replaceExistingItem(slot, remainingItem); } } } 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 5956b14cf..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 @@ -7,9 +7,9 @@ import org.bukkit.potion.PotionEffectType; 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.api.SlimefunItemStack; /** 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 d57ba3b2f..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 @@ -10,9 +10,9 @@ import io.github.thebusybiscuit.cscorelib2.chat.ChatColors; import io.github.thebusybiscuit.slimefun4.core.handlers.ItemConsumptionHandler; import io.github.thebusybiscuit.slimefun4.core.services.LocalizationService; 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.api.SlimefunItemStack; 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 6e48a99bc..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 @@ -10,9 +10,9 @@ 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.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 36d47bfff..a0e935e5d 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 @@ -4,9 +4,9 @@ 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.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 8377f6ff0..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 @@ -5,9 +5,9 @@ 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.api.Slimefun; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; 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 2b0834283..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 @@ -5,9 +5,9 @@ import org.bukkit.inventory.ItemStack; 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.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 6996a3d87..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 @@ -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()) { 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 1a30b19e4..19975c36a 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 @@ -7,9 +7,9 @@ import org.bukkit.inventory.ItemStack; 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.api.SlimefunItemStack; public class PortableGEOScanner extends SimpleSlimefunItem { @@ -24,9 +24,7 @@ public class PortableGEOScanner extends SimpleSlimefunItem { Optional block = e.getClickedBlock(); e.cancel(); - if (block.isPresent()) { - SlimefunPlugin.getGPSNetwork().getResourceManager().scan(e.getPlayer(), block.get(), 0); - } + block.ifPresent(value -> SlimefunPlugin.getGPSNetwork().getResourceManager().scan(e.getPlayer(), value, 0)); }; } 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 b411cc895..1495378dd 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 @@ -22,12 +22,13 @@ 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 io.papermc.lib.PaperLib; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu; 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.api.BlockStorage; @@ -96,7 +97,7 @@ 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); @@ -119,13 +120,13 @@ public class ElevatorPlate extends SimpleSlimefunItem { ChatComponent line; if (block.getY() == b.getY()) { - line = new ChatComponent("\n" + ChatColor.GRAY + "> " + (floors.size() - i) + ". " + ChatColor.RESET + floor); - line.setHoverEvent(new HoverEvent(ChatColors.color(SlimefunPlugin.getLocalization().getMessage(p, "machines.ELEVATOR.current-floor")), "", ChatColor.RESET + floor, "")); + line = new ChatComponent("\n" + ChatColor.GRAY + "> " + (floors.size() - i) + ". " + ChatColor.BLACK + floor); + line.setHoverEvent(new HoverEvent(ChatColors.color(SlimefunPlugin.getLocalization().getMessage(p, "machines.ELEVATOR.current-floor")), "", ChatColor.WHITE + floor, "")); } else { - line = new ChatComponent("\n" + ChatColor.GRAY.toString() + (floors.size() - i) + ". " + ChatColor.RESET + floor); - 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(() -> { + line = new ChatComponent("\n" + ChatColor.GRAY + (floors.size() - i) + ". " + ChatColor.BLACK + floor); + line.setHoverEvent(new HoverEvent(ChatColors.color(SlimefunPlugin.getLocalization().getMessage(p, "machines.ELEVATOR.click-to-teleport")), "", ChatColor.WHITE + floor, "")); + line.setClickEvent(new ClickEvent(new NamespacedKey(SlimefunPlugin.instance(), DATA_KEY + i), player -> Slimefun.runSync(() -> { users.add(player.getUniqueId()); float yaw = player.getEyeLocation().getYaw() + 180; @@ -134,8 +135,12 @@ public class ElevatorPlate extends SimpleSlimefunItem { yaw = -180 + (yaw - 180); } - player.teleport(new Location(player.getWorld(), block.getX() + 0.5, block.getY() + 0.4, block.getZ() + 0.5, yaw, player.getEyeLocation().getPitch())); - player.sendTitle(ChatColor.RESET + ChatColors.color(floor), " ", 20, 60, 20); + Location destination = new Location(player.getWorld(), block.getX() + 0.5, block.getY() + 0.4, block.getZ() + 0.5, yaw, player.getEyeLocation().getPitch()); + PaperLib.teleportAsync(player, destination).thenAccept(teleported -> { + if (teleported.booleanValue()) { + player.sendTitle(ChatColor.WHITE + ChatColors.color(floor), null, 20, 60, 20); + } + }); }))); } 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 57323e3d7..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 @@ -4,9 +4,9 @@ import org.bukkit.inventory.ItemStack; 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.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 9cba1fbe4..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 @@ -6,9 +6,9 @@ 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.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.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 d96be8f1f..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 @@ -9,11 +9,11 @@ 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.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/magical/InfernalBonemeal.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/InfernalBonemeal.java index 28b7a88d5..f10c86655 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/InfernalBonemeal.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/InfernalBonemeal.java @@ -12,9 +12,9 @@ import org.bukkit.inventory.ItemStack; 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.api.SlimefunItemStack; public class InfernalBonemeal extends SimpleSlimefunItem { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/KnowledgeFlask.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/KnowledgeFlask.java index 72d6fa168..99744102d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/KnowledgeFlask.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/KnowledgeFlask.java @@ -7,9 +7,9 @@ import org.bukkit.inventory.ItemStack; import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils; import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; +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.api.SlimefunItemStack; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/KnowledgeTome.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/KnowledgeTome.java index 7a32c1eae..ed923bc6d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/KnowledgeTome.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/KnowledgeTome.java @@ -17,9 +17,9 @@ import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; import io.github.thebusybiscuit.slimefun4.core.researching.Research; 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.api.SlimefunItemStack; public class KnowledgeTome extends SimpleSlimefunItem { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/MagicEyeOfEnder.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/MagicEyeOfEnder.java index 810d53f31..b8163c176 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/MagicEyeOfEnder.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/MagicEyeOfEnder.java @@ -8,10 +8,10 @@ import org.bukkit.inventory.PlayerInventory; import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; 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.api.SlimefunItemStack; public class MagicEyeOfEnder extends SimpleSlimefunItem { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/MagicalZombiePills.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/MagicalZombiePills.java index 1882e63c7..b14be25e1 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/MagicalZombiePills.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/MagicalZombiePills.java @@ -10,9 +10,9 @@ import org.bukkit.inventory.ItemStack; import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; import io.github.thebusybiscuit.slimefun4.core.handlers.EntityInteractHandler; 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.api.SlimefunItemStack; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/SoulboundRune.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/SoulboundRune.java index eb07c0540..c9f33c4e5 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/SoulboundRune.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/SoulboundRune.java @@ -14,10 +14,10 @@ import org.bukkit.inventory.ItemStack; import io.github.thebusybiscuit.slimefun4.core.attributes.Soulbound; import io.github.thebusybiscuit.slimefun4.core.handlers.ItemDropHandler; 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.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; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/StormStaff.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/StormStaff.java index 0d649de9f..8e14f1ed1 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/StormStaff.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/StormStaff.java @@ -20,9 +20,9 @@ import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction; import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; 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.api.SlimefunItemStack; @@ -37,7 +37,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; */ public class StormStaff extends SimpleSlimefunItem { - private static final NamespacedKey usageKey = new NamespacedKey(SlimefunPlugin.instance, "stormstaff_usage"); + private static final NamespacedKey usageKey = new NamespacedKey(SlimefunPlugin.instance(), "stormstaff_usage"); public static final int MAX_USES = 8; public StormStaff(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/TelepositionScroll.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/TelepositionScroll.java index 4a7f227e4..be4d3ed4f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/TelepositionScroll.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/TelepositionScroll.java @@ -8,9 +8,9 @@ import org.bukkit.inventory.ItemStack; import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; 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.SlimefunItem.SlimefunItem; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/WaterStaff.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/WaterStaff.java index f81147741..ca0f26c6d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/WaterStaff.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/WaterStaff.java @@ -5,9 +5,9 @@ import org.bukkit.inventory.ItemStack; 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.SlimefunItem.SlimefunItem; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/WindStaff.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/WindStaff.java index ddf53c80f..6c07381ac 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/WindStaff.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/WindStaff.java @@ -11,9 +11,9 @@ import org.bukkit.inventory.ItemStack; 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.api.SlimefunItemStack; public class WindStaff extends SimpleSlimefunItem { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/EnderTalisman.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/EnderTalisman.java index 4790a6a1d..ee66d564f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/EnderTalisman.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/EnderTalisman.java @@ -19,7 +19,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; */ class EnderTalisman extends Talisman { - private static final LockedCategory ENDER_TALISMANS_CATEGORY = new LockedCategory(new NamespacedKey(SlimefunPlugin.instance, "ender_talismans"), new CustomItem(SlimefunItems.ENDER_TALISMAN, "&7Talismans - &aTier II"), 3, Talisman.TALISMANS_CATEGORY.getKey()); + private static final LockedCategory ENDER_TALISMANS_CATEGORY = new LockedCategory(new NamespacedKey(SlimefunPlugin.instance(), "ender_talismans"), new CustomItem(SlimefunItems.ENDER_TALISMAN, "&7Talismans - &aTier II"), 3, Talisman.TALISMANS_CATEGORY.getKey()); public EnderTalisman(Talisman parent, SlimefunItemStack item) { super(ENDER_TALISMANS_CATEGORY, item, new ItemStack[] { SlimefunItems.ENDER_LUMP_3, null, SlimefunItems.ENDER_LUMP_3, null, parent.getItem(), null, SlimefunItems.ENDER_LUMP_3, null, SlimefunItems.ENDER_LUMP_3 }, parent.isConsumable(), parent.isEventCancelled(), parent.getMessageSuffix(), parent.getChance(), parent.getEffects()); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/Talisman.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/Talisman.java index e5a945025..e0a58a0da 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/Talisman.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/Talisman.java @@ -31,7 +31,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; public class Talisman extends SlimefunItem { - protected static final Category TALISMANS_CATEGORY = new Category(new NamespacedKey(SlimefunPlugin.instance, "talismans"), new CustomItem(SlimefunItems.COMMON_TALISMAN, "&7Talismans - &aTier I"), 2); + protected static final Category TALISMANS_CATEGORY = new Category(new NamespacedKey(SlimefunPlugin.instance(), "talismans"), new CustomItem(SlimefunItems.COMMON_TALISMAN, "&7Talismans - &aTier I"), 2); private final SlimefunItemStack enderTalisman; @@ -117,7 +117,7 @@ public class Talisman extends SlimefunItem { protected void createEnderTalisman() { EnderTalisman talisman = (EnderTalisman) SlimefunItem.getByItem(getEnderVariant()); - Optional research = Research.getResearch(new NamespacedKey(SlimefunPlugin.instance, "ender_talismans")); + Optional research = Research.getResearch(new NamespacedKey(SlimefunPlugin.instance(), "ender_talismans")); if (talisman != null && research.isPresent()) { talisman.setResearch(research.get()); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/medical/Bandage.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/medical/Bandage.java index 8b9f68f9d..33235a6a3 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/medical/Bandage.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/medical/Bandage.java @@ -11,9 +11,9 @@ 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.api.SlimefunItemStack; public class Bandage extends SimpleSlimefunItem { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/medical/Medicine.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/medical/Medicine.java index 1fa813917..8d42e4b7e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/medical/Medicine.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/medical/Medicine.java @@ -4,9 +4,9 @@ import org.bukkit.inventory.ItemStack; 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.api.SlimefunItemStack; public class Medicine extends SimpleSlimefunItem { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/medical/Rag.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/medical/Rag.java index 772faed29..2d314ee86 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/medical/Rag.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/medical/Rag.java @@ -11,9 +11,9 @@ 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.api.SlimefunItemStack; public class Rag extends SimpleSlimefunItem { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/medical/Splint.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/medical/Splint.java index ec417312c..7518fd402 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/medical/Splint.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/medical/Splint.java @@ -10,9 +10,9 @@ 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.api.SlimefunItemStack; public class Splint extends SimpleSlimefunItem { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/medical/Vitamins.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/medical/Vitamins.java index fc9fd4261..2b7240427 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/medical/Vitamins.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/medical/Vitamins.java @@ -9,9 +9,9 @@ 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.api.SlimefunItemStack; public class Vitamins extends SimpleSlimefunItem { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/BasicCircuitBoard.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/BasicCircuitBoard.java similarity index 72% rename from src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/BasicCircuitBoard.java rename to src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/BasicCircuitBoard.java index d7e6e42aa..ee6d4420a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/BasicCircuitBoard.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/BasicCircuitBoard.java @@ -1,24 +1,32 @@ -package io.github.thebusybiscuit.slimefun4.implementation.items.electric; +package io.github.thebusybiscuit.slimefun4.implementation.items.misc; import org.bukkit.inventory.ItemStack; import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent; import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable; +import io.github.thebusybiscuit.slimefun4.core.attributes.RandomMobDrop; 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.api.SlimefunItemStack; -public class BasicCircuitBoard extends SimpleSlimefunItem implements NotPlaceable { +public class BasicCircuitBoard extends SimpleSlimefunItem implements NotPlaceable, RandomMobDrop { private final ItemSetting dropSetting = new ItemSetting<>("drop-from-golems", true); + private final ItemSetting chance = new ItemSetting<>("golem-drop-chance", 75); public BasicCircuitBoard(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { super(category, item, recipeType, recipe); addItemSetting(dropSetting); + addItemSetting(chance); + } + + @Override + public int getMobDropChance() { + return chance.getValue(); } public boolean isDroppedFromGolems() { @@ -30,4 +38,4 @@ public class BasicCircuitBoard extends SimpleSlimefunItem implem return PlayerRightClickEvent::cancel; } -} +} \ No newline at end of file diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/CoolantCell.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/CoolantCell.java new file mode 100644 index 000000000..347a70d75 --- /dev/null +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/CoolantCell.java @@ -0,0 +1,35 @@ +package io.github.thebusybiscuit.slimefun4.implementation.items.misc; + +import org.bukkit.inventory.ItemStack; + +import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.UnplaceableBlock; +import io.github.thebusybiscuit.slimefun4.implementation.items.cargo.ReactorAccessPort; +import io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors.NetherStarReactor; +import io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors.NuclearReactor; +import io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors.Reactor; +import me.mrCookieSlime.Slimefun.Lists.RecipeType; +import me.mrCookieSlime.Slimefun.Objects.Category; +import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; + +/** + * A {@link CoolantCell} is an {@link ItemStack} that is used to cool a {@link Reactor}. + * + * @author TheBusyBiscuit + * + * @see Reactor + * @see ReactorAccessPort + * @see NuclearReactor + * @see NetherStarReactor + * + */ +public class CoolantCell extends UnplaceableBlock { + + public CoolantCell(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { + super(category, item, recipeType, recipe); + } + + public CoolantCell(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput) { + super(category, item, recipeType, recipe, recipeOutput); + } + +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/AbstractSmeltery.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/AbstractSmeltery.java index 032d3424e..a0b97afd4 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/AbstractSmeltery.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/AbstractSmeltery.java @@ -6,6 +6,7 @@ import org.bukkit.Effect; import org.bukkit.Sound; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; +import org.bukkit.block.BlockState; import org.bukkit.block.Dispenser; import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; @@ -15,6 +16,7 @@ import io.github.thebusybiscuit.cscorelib2.inventory.InvUtils; import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.papermc.lib.PaperLib; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.api.Slimefun; @@ -28,37 +30,41 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; */ abstract class AbstractSmeltery extends MultiBlockMachine { - public AbstractSmeltery(Category category, SlimefunItemStack item, ItemStack[] recipe, ItemStack[] machineRecipes, BlockFace trigger) { - super(category, item, recipe, machineRecipes, trigger); + public AbstractSmeltery(Category category, SlimefunItemStack item, ItemStack[] recipe, BlockFace trigger) { + super(category, item, recipe, trigger); } @Override public void onInteract(Player p, Block b) { Block dispBlock = b.getRelative(BlockFace.DOWN); - Dispenser disp = (Dispenser) dispBlock.getState(); - Inventory inv = disp.getInventory(); - List inputs = RecipeType.getRecipeInputList(this); + BlockState state = PaperLib.getBlockState(dispBlock, false).getState(); - for (int i = 0; i < inputs.size(); i++) { - if (canCraft(inv, inputs, i)) { - ItemStack output = RecipeType.getRecipeOutputList(this, inputs.get(i)).clone(); + if (state instanceof Dispenser) { + Dispenser disp = (Dispenser) state; + Inventory inv = disp.getInventory(); + List inputs = RecipeType.getRecipeInputList(this); - if (Slimefun.hasUnlocked(p, output, true)) { - Inventory outputInv = findOutputInventory(output, dispBlock, inv); + for (int i = 0; i < inputs.size(); i++) { + if (canCraft(inv, inputs, i)) { + ItemStack output = RecipeType.getRecipeOutputList(this, inputs.get(i)).clone(); - if (outputInv != null) { - craft(p, b, inv, inputs.get(i), output, outputInv); - } - else { - SlimefunPlugin.getLocalization().sendMessage(p, "machines.full-inventory", true); + if (Slimefun.hasUnlocked(p, output, true)) { + Inventory outputInv = findOutputInventory(output, dispBlock, inv); + + if (outputInv != null) { + craft(p, b, inv, inputs.get(i), output, outputInv); + } + else { + SlimefunPlugin.getLocalization().sendMessage(p, "machines.full-inventory", true); + } } + + return; } - - return; } - } - SlimefunPlugin.getLocalization().sendMessage(p, "machines.unknown-material", true); + SlimefunPlugin.getLocalization().sendMessage(p, "machines.unknown-material", true); + } } private boolean canCraft(Inventory inv, List inputs, int i) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/ArmorForge.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/ArmorForge.java index f01a0149e..cd97b214f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/ArmorForge.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/ArmorForge.java @@ -6,6 +6,7 @@ import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; +import org.bukkit.block.BlockState; import org.bukkit.block.Dispenser; import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; @@ -16,6 +17,7 @@ import io.github.thebusybiscuit.cscorelib2.item.CustomItem; import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.papermc.lib.PaperLib; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.api.Slimefun; @@ -24,40 +26,40 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; public class ArmorForge extends MultiBlockMachine { public ArmorForge(Category category, SlimefunItemStack item) { - super(category, item, new ItemStack[] { - null, null, null, - null, new ItemStack(Material.ANVIL), null, - null, new CustomItem(Material.DISPENSER, "Dispenser (Facing up)"), null - }, new ItemStack[0], BlockFace.SELF); + super(category, item, new ItemStack[] { null, null, null, null, new ItemStack(Material.ANVIL), null, null, new CustomItem(Material.DISPENSER, "Dispenser (Facing up)"), null }, BlockFace.SELF); } @Override public void onInteract(Player p, Block b) { Block dispBlock = b.getRelative(BlockFace.DOWN); - Dispenser disp = (Dispenser) dispBlock.getState(); - Inventory inv = disp.getInventory(); - List inputs = RecipeType.getRecipeInputList(this); + BlockState state = PaperLib.getBlockState(dispBlock, false).getState(); - for (int i = 0; i < inputs.size(); i++) { - if (isCraftable(inv, inputs.get(i))) { - ItemStack output = RecipeType.getRecipeOutputList(this, inputs.get(i)).clone(); + if (state instanceof Dispenser) { + Dispenser disp = (Dispenser) state; + Inventory inv = disp.getInventory(); + List inputs = RecipeType.getRecipeInputList(this); - if (Slimefun.hasUnlocked(p, output, true)) { - Inventory outputInv = findOutputInventory(output, dispBlock, inv); + for (int i = 0; i < inputs.size(); i++) { + if (isCraftable(inv, inputs.get(i))) { + ItemStack output = RecipeType.getRecipeOutputList(this, inputs.get(i)).clone(); - if (outputInv != null) { - craft(p, output, inv, outputInv); - } - else { - SlimefunPlugin.getLocalization().sendMessage(p, "machines.full-inventory", true); + if (Slimefun.hasUnlocked(p, output, true)) { + Inventory outputInv = findOutputInventory(output, dispBlock, inv); + + if (outputInv != null) { + craft(p, output, inv, outputInv); + } + else { + SlimefunPlugin.getLocalization().sendMessage(p, "machines.full-inventory", true); + } } + + return; } - - return; } - } - SlimefunPlugin.getLocalization().sendMessage(p, "machines.pattern-not-found", true); + SlimefunPlugin.getLocalization().sendMessage(p, "machines.pattern-not-found", true); + } } private boolean isCraftable(Inventory inv, ItemStack[] recipe) { @@ -73,7 +75,7 @@ public class ArmorForge extends MultiBlockMachine { private void craft(Player p, ItemStack output, Inventory inv, Inventory outputInv) { for (int j = 0; j < 9; j++) { ItemStack item = inv.getContents()[j]; - + if (item != null && item.getType() != Material.AIR) { ItemUtils.consumeItem(item, true); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/AutomatedPanningMachine.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/AutomatedPanningMachine.java index aa33cc629..fb7f4ceff 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/AutomatedPanningMachine.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/AutomatedPanningMachine.java @@ -29,7 +29,7 @@ public class AutomatedPanningMachine extends MultiBlockMachine { private final GoldPan netherGoldPan = (GoldPan) SlimefunItems.NETHER_GOLD_PAN.getItem(); public AutomatedPanningMachine(Category category, SlimefunItemStack item) { - super(category, item, new ItemStack[] { null, null, null, null, new ItemStack(Material.OAK_TRAPDOOR), null, null, new ItemStack(Material.CAULDRON), null }, new ItemStack[0], BlockFace.SELF); + super(category, item, new ItemStack[] { null, null, null, null, new ItemStack(Material.OAK_TRAPDOOR), null, null, new ItemStack(Material.CAULDRON), null }, BlockFace.SELF); } @Override @@ -46,7 +46,7 @@ public class AutomatedPanningMachine extends MultiBlockMachine { public void onInteract(Player p, Block b) { ItemStack input = p.getInventory().getItemInMainHand(); - if (SlimefunUtils.isItemSimilar(input, new ItemStack(Material.GRAVEL), true) || SlimefunUtils.isItemSimilar(input, new ItemStack(Material.SOUL_SAND), true)) { + if (SlimefunUtils.isItemSimilar(input, new ItemStack(Material.GRAVEL), true, false) || SlimefunUtils.isItemSimilar(input, new ItemStack(Material.SOUL_SAND), true, false)) { Material material = input.getType(); if (p.getGameMode() != GameMode.CREATIVE) { @@ -76,7 +76,7 @@ public class AutomatedPanningMachine extends MultiBlockMachine { } }); - queue.execute(SlimefunPlugin.instance); + queue.execute(SlimefunPlugin.instance()); } else { SlimefunPlugin.getLocalization().sendMessage(p, "machines.wrong-item", true); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/BackpackCrafter.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/BackpackCrafter.java index 51375c919..6d2786244 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/BackpackCrafter.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/BackpackCrafter.java @@ -26,8 +26,8 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; abstract class BackpackCrafter extends MultiBlockMachine { - public BackpackCrafter(Category category, SlimefunItemStack item, ItemStack[] recipe, ItemStack[] machineRecipes, BlockFace trigger) { - super(category, item, recipe, machineRecipes, trigger); + public BackpackCrafter(Category category, SlimefunItemStack item, ItemStack[] recipe, BlockFace trigger) { + super(category, item, recipe, trigger); } protected Inventory createVirtualInventory(Inventory inv) { @@ -92,9 +92,7 @@ abstract class BackpackCrafter extends MultiBlockMachine { PlayerProfile.fromUUID(UUID.fromString(idSplit[0]), profile -> { Optional optional = profile.getBackpack(Integer.parseInt(idSplit[1])); - if (optional.isPresent()) { - optional.get().setSize(size); - } + optional.ifPresent(playerBackpack -> playerBackpack.setSize(size)); }); return Optional.of(id); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Compressor.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Compressor.java index 90e9b9af0..854e047e0 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Compressor.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Compressor.java @@ -7,6 +7,7 @@ import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; +import org.bukkit.block.BlockState; import org.bukkit.block.Dispenser; import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; @@ -17,6 +18,7 @@ import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.papermc.lib.PaperLib; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.api.Slimefun; @@ -24,61 +26,67 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; public class Compressor extends MultiBlockMachine { - public Compressor(Category category, SlimefunItemStack item) { - super(category, item, - new ItemStack[] {null, null, null, null, new ItemStack(Material.NETHER_BRICK_FENCE), null, new ItemStack(Material.PISTON), new CustomItem(Material.DISPENSER, "Dispenser (Facing up)"), new ItemStack(Material.PISTON)}, - new ItemStack[] { - new CustomItem(SlimefunItems.STONE_CHUNK, 4), new ItemStack(Material.COBBLESTONE), - new ItemStack(Material.FLINT, 8), new ItemStack(Material.COBBLESTONE) - }, - BlockFace.SELF - ); - } - - @Override - public List getDisplayRecipes() { - return recipes.stream().map(items -> items[0]).collect(Collectors.toList()); - } - - @Override - public void onInteract(Player p, Block b) { - Block dispBlock = b.getRelative(BlockFace.DOWN); - Dispenser disp = (Dispenser) dispBlock.getState(); - Inventory inv = disp.getInventory(); - - for (ItemStack item : inv.getContents()) { - for (ItemStack recipeInput : RecipeType.getRecipeInputs(this)) { - if (recipeInput != null && SlimefunUtils.isItemSimilar(item, recipeInput, true)) { - ItemStack output = RecipeType.getRecipeOutput(this, recipeInput); - Inventory outputInv = findOutputInventory(output, dispBlock, inv); - - if (outputInv != null) { - ItemStack removing = item.clone(); - removing.setAmount(recipeInput.getAmount()); - inv.removeItem(removing); + public Compressor(Category category, SlimefunItemStack item) { + super(category, item, new ItemStack[] { null, null, null, null, new ItemStack(Material.NETHER_BRICK_FENCE), null, new ItemStack(Material.PISTON), new CustomItem(Material.DISPENSER, "Dispenser (Facing up)"), new ItemStack(Material.PISTON) }, BlockFace.SELF); + } - craft(p, output, outputInv); - } - else { - SlimefunPlugin.getLocalization().sendMessage(p, "machines.full-inventory", true); - } - - return; - } - } - } - - SlimefunPlugin.getLocalization().sendMessage(p, "machines.unknown-material", true); - } + @Override + protected void registerDefaultRecipes(List recipes) { + recipes.add(new SlimefunItemStack(SlimefunItems.STONE_CHUNK, 4)); + recipes.add(new ItemStack(Material.COBBLESTONE)); + + recipes.add(new ItemStack(Material.FLINT, 8)); + recipes.add(new ItemStack(Material.COBBLESTONE)); + } + + @Override + public List getDisplayRecipes() { + return recipes.stream().map(items -> items[0]).collect(Collectors.toList()); + } + + @Override + public void onInteract(Player p, Block b) { + Block dispBlock = b.getRelative(BlockFace.DOWN); + BlockState state = PaperLib.getBlockState(dispBlock, false).getState(); + + if (state instanceof Dispenser) { + Dispenser disp = (Dispenser) state; + Inventory inv = disp.getInventory(); + + for (ItemStack item : inv.getContents()) { + for (ItemStack recipeInput : RecipeType.getRecipeInputs(this)) { + if (recipeInput != null && SlimefunUtils.isItemSimilar(item, recipeInput, true)) { + ItemStack output = RecipeType.getRecipeOutput(this, recipeInput); + Inventory outputInv = findOutputInventory(output, dispBlock, inv); + + if (outputInv != null) { + ItemStack removing = item.clone(); + removing.setAmount(recipeInput.getAmount()); + inv.removeItem(removing); + + craft(p, output, outputInv); + } + else { + SlimefunPlugin.getLocalization().sendMessage(p, "machines.full-inventory", true); + } + + return; + } + } + } + + SlimefunPlugin.getLocalization().sendMessage(p, "machines.unknown-material", true); + } + } private void craft(Player p, ItemStack output, Inventory outputInv) { for (int i = 0; i < 4; i++) { int j = i; - + Slimefun.runSync(() -> { if (j < 3) { p.getWorld().playSound(p.getLocation(), j == 1 ? Sound.BLOCK_PISTON_CONTRACT : Sound.BLOCK_PISTON_EXTEND, 1F, j == 0 ? 1F : 2F); - } + } else { p.getWorld().playSound(p.getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 1F, 1F); outputInv.addItem(output); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/EnhancedCraftingTable.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/EnhancedCraftingTable.java index de69888a3..97b72b81a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/EnhancedCraftingTable.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/EnhancedCraftingTable.java @@ -6,6 +6,7 @@ import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; +import org.bukkit.block.BlockState; import org.bukkit.block.Dispenser; import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; @@ -15,6 +16,7 @@ import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.implementation.items.backpacks.SlimefunBackpack; import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.papermc.lib.PaperLib; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; @@ -24,28 +26,32 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; public class EnhancedCraftingTable extends BackpackCrafter { public EnhancedCraftingTable(Category category, SlimefunItemStack item) { - super(category, item, new ItemStack[] { null, null, null, null, new ItemStack(Material.CRAFTING_TABLE), null, null, new ItemStack(Material.DISPENSER), null }, new ItemStack[0], BlockFace.SELF); + super(category, item, new ItemStack[] { null, null, null, null, new ItemStack(Material.CRAFTING_TABLE), null, null, new ItemStack(Material.DISPENSER), null }, BlockFace.SELF); } @Override public void onInteract(Player p, Block b) { Block dispenser = b.getRelative(BlockFace.DOWN); - Dispenser disp = (Dispenser) dispenser.getState(); - Inventory inv = disp.getInventory(); + BlockState state = PaperLib.getBlockState(dispenser, false).getState(); - List inputs = RecipeType.getRecipeInputList(this); + if (state instanceof Dispenser) { + Dispenser disp = (Dispenser) state; + Inventory inv = disp.getInventory(); - for (int i = 0; i < inputs.size(); i++) { - if (isCraftable(inv, inputs.get(i))) { - ItemStack output = RecipeType.getRecipeOutputList(this, inputs.get(i)).clone(); - if (Slimefun.hasUnlocked(p, output, true)) { - craft(inv, dispenser, p, b, output); + List inputs = RecipeType.getRecipeInputList(this); + + for (int i = 0; i < inputs.size(); i++) { + if (isCraftable(inv, inputs.get(i))) { + ItemStack output = RecipeType.getRecipeOutputList(this, inputs.get(i)).clone(); + if (Slimefun.hasUnlocked(p, output, true)) { + craft(inv, dispenser, p, b, output); + } + + return; } - - return; } + SlimefunPlugin.getLocalization().sendMessage(p, "machines.pattern-not-found", true); } - SlimefunPlugin.getLocalization().sendMessage(p, "machines.pattern-not-found", true); } private void craft(Inventory inv, Block dispenser, Player p, Block b, ItemStack output) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/GrindStone.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/GrindStone.java index cff7af535..cff9d414e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/GrindStone.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/GrindStone.java @@ -7,6 +7,7 @@ import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; +import org.bukkit.block.BlockState; import org.bukkit.block.Dispenser; import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; @@ -17,67 +18,99 @@ import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.papermc.lib.PaperLib; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; public class GrindStone extends MultiBlockMachine { - public GrindStone(Category category, SlimefunItemStack item) { - super(category, item, - new ItemStack[] {null, null, null, null, new ItemStack(Material.OAK_FENCE), null, null, new CustomItem(Material.DISPENSER, "Dispenser (Facing up)"), null}, - new ItemStack[] { - new ItemStack(Material.BLAZE_ROD), new ItemStack(Material.BLAZE_POWDER, 4), - new ItemStack(Material.BONE), new ItemStack(Material.BONE_MEAL, 4), - new ItemStack(Material.GRAVEL), new ItemStack(Material.FLINT), - new ItemStack(Material.ENDER_EYE), new CustomItem(SlimefunItems.ENDER_LUMP_1, 2), - new ItemStack(Material.COBBLESTONE), new ItemStack(Material.GRAVEL), - new ItemStack(Material.ANDESITE), new ItemStack(Material.GRAVEL), - new ItemStack(Material.DIORITE), new ItemStack(Material.GRAVEL), - new ItemStack(Material.GRANITE), new ItemStack(Material.GRAVEL), - new ItemStack(Material.DIRT), SlimefunItems.STONE_CHUNK, - new ItemStack(Material.SANDSTONE), new ItemStack(Material.SAND, 4), - new ItemStack(Material.RED_SANDSTONE), new ItemStack(Material.RED_SAND, 4), - new ItemStack(Material.PRISMARINE_BRICKS), new ItemStack(Material.PRISMARINE, 2), - new ItemStack(Material.PRISMARINE), new ItemStack(Material.PRISMARINE_SHARD, 4) - }, - BlockFace.SELF - ); - } - - @Override - public List getDisplayRecipes() { - return recipes.stream().map(items -> items[0]).collect(Collectors.toList()); - } - - @Override - public void onInteract(Player p, Block b) { - Block dispBlock = b.getRelative(BlockFace.DOWN); - Dispenser disp = (Dispenser) dispBlock.getState(); - Inventory inv = disp.getInventory(); - - for (ItemStack current : inv.getContents()) { - for (ItemStack convert : RecipeType.getRecipeInputs(this)) { - if (convert != null && SlimefunUtils.isItemSimilar(current, convert, true)) { - ItemStack output = RecipeType.getRecipeOutput(this, convert); - Inventory outputInv = findOutputInventory(output, dispBlock, inv); - - if (outputInv != null) { - ItemStack removing = current.clone(); - removing.setAmount(1); - inv.removeItem(removing); - outputInv.addItem(output); - p.getWorld().playSound(p.getLocation(), Sound.BLOCK_WOODEN_BUTTON_CLICK_ON, 1, 1); - } - else { - SlimefunPlugin.getLocalization().sendMessage(p, "machines.full-inventory", true); - } - - return; - } - } - } - SlimefunPlugin.getLocalization().sendMessage(p, "machines.unknown-material", true); - } + public GrindStone(Category category, SlimefunItemStack item) { + super(category, item, new ItemStack[] { null, null, null, null, new ItemStack(Material.OAK_FENCE), null, null, new CustomItem(Material.DISPENSER, "Dispenser (Facing up)"), null }, BlockFace.SELF); + } + + @Override + protected void registerDefaultRecipes(List recipes) { + recipes.add(new ItemStack(Material.BLAZE_ROD)); + recipes.add(new ItemStack(Material.BLAZE_POWDER, 4)); + + recipes.add(new ItemStack(Material.BONE)); + recipes.add(new ItemStack(Material.BONE_MEAL, 4)); + + recipes.add(new ItemStack(Material.BONE_BLOCK)); + recipes.add(new ItemStack(Material.BONE_MEAL, 9)); + + recipes.add(new ItemStack(Material.GRAVEL)); + recipes.add(new ItemStack(Material.FLINT)); + + recipes.add(new ItemStack(Material.ENDER_EYE)); + recipes.add(new SlimefunItemStack(SlimefunItems.ENDER_LUMP_1, 2)); + + recipes.add(new ItemStack(Material.COBBLESTONE)); + recipes.add(new ItemStack(Material.GRAVEL)); + + recipes.add(new ItemStack(Material.ANDESITE)); + recipes.add(new ItemStack(Material.GRAVEL)); + + recipes.add(new ItemStack(Material.DIORITE)); + recipes.add(new ItemStack(Material.GRAVEL)); + + recipes.add(new ItemStack(Material.GRANITE)); + recipes.add(new ItemStack(Material.GRAVEL)); + + recipes.add(new ItemStack(Material.DIRT)); + recipes.add(SlimefunItems.STONE_CHUNK); + + recipes.add(new ItemStack(Material.SANDSTONE)); + recipes.add(new ItemStack(Material.SAND, 4)); + + recipes.add(new ItemStack(Material.RED_SANDSTONE)); + recipes.add(new ItemStack(Material.RED_SAND, 4)); + + recipes.add(new ItemStack(Material.PRISMARINE_BRICKS)); + recipes.add(new ItemStack(Material.PRISMARINE, 2)); + + recipes.add(new ItemStack(Material.PRISMARINE)); + recipes.add(new ItemStack(Material.PRISMARINE_SHARD, 4)); + } + + @Override + public List getDisplayRecipes() { + return recipes.stream().map(items -> items[0]).collect(Collectors.toList()); + } + + @Override + public void onInteract(Player p, Block b) { + Block dispBlock = b.getRelative(BlockFace.DOWN); + BlockState state = PaperLib.getBlockState(dispBlock, false).getState(); + + if (state instanceof Dispenser) { + Dispenser disp = (Dispenser) state; + Inventory inv = disp.getInventory(); + + for (ItemStack current : inv.getContents()) { + for (ItemStack convert : RecipeType.getRecipeInputs(this)) { + if (convert != null && SlimefunUtils.isItemSimilar(current, convert, true)) { + ItemStack output = RecipeType.getRecipeOutput(this, convert); + Inventory outputInv = findOutputInventory(output, dispBlock, inv); + + if (outputInv != null) { + ItemStack removing = current.clone(); + removing.setAmount(1); + inv.removeItem(removing); + outputInv.addItem(output); + p.getWorld().playSound(p.getLocation(), Sound.BLOCK_WOODEN_BUTTON_CLICK_ON, 1, 1); + } + else { + SlimefunPlugin.getLocalization().sendMessage(p, "machines.full-inventory", true); + } + + return; + } + } + } + SlimefunPlugin.getLocalization().sendMessage(p, "machines.unknown-material", true); + } + } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Juicer.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Juicer.java index 3d5ae8cba..abd6e6f4d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Juicer.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Juicer.java @@ -8,6 +8,7 @@ import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; +import org.bukkit.block.BlockState; import org.bukkit.block.Dispenser; import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; @@ -17,53 +18,56 @@ import io.github.thebusybiscuit.cscorelib2.item.CustomItem; import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.papermc.lib.PaperLib; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; public class Juicer extends MultiBlockMachine { - public Juicer(Category category, SlimefunItemStack item) { - super(category, item, - new ItemStack[] {null, new ItemStack(Material.GLASS), null, null, new ItemStack(Material.NETHER_BRICK_FENCE), null, null, new CustomItem(Material.DISPENSER, "Dispenser (Facing up)"), null}, - new ItemStack[0], - BlockFace.SELF - ); - } - - @Override - public List getDisplayRecipes() { - return recipes.stream().map(items -> items[0]).collect(Collectors.toList()); - } - - @Override - public void onInteract(Player p, Block b) { - Block dispBlock = b.getRelative(BlockFace.DOWN); - Dispenser disp = (Dispenser) dispBlock.getState(); - Inventory inv = disp.getInventory(); - - for (ItemStack current : inv.getContents()) { - for (ItemStack convert : RecipeType.getRecipeInputs(this)) { - if (convert != null && SlimefunUtils.isItemSimilar(current, convert, true)) { - ItemStack adding = RecipeType.getRecipeOutput(this, convert); - Inventory outputInv = findOutputInventory(adding, dispBlock, inv); - - if (outputInv != null) { - ItemStack removing = current.clone(); - removing.setAmount(1); - inv.removeItem(removing); - outputInv.addItem(adding); - p.getWorld().playSound(b.getLocation(), Sound.ENTITY_PLAYER_SPLASH, 1F, 1F); - p.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, Material.HAY_BLOCK); - } - else SlimefunPlugin.getLocalization().sendMessage(p, "machines.full-inventory", true); - - return; - } - } - } - - SlimefunPlugin.getLocalization().sendMessage(p, "machines.unknown-material", true); - } + public Juicer(Category category, SlimefunItemStack item) { + super(category, item, new ItemStack[] { null, new ItemStack(Material.GLASS), null, null, new ItemStack(Material.NETHER_BRICK_FENCE), null, null, new CustomItem(Material.DISPENSER, "Dispenser (Facing up)"), null }, BlockFace.SELF); + } + + @Override + public List getDisplayRecipes() { + return recipes.stream().map(items -> items[0]).collect(Collectors.toList()); + } + + @Override + public void onInteract(Player p, Block b) { + Block dispBlock = b.getRelative(BlockFace.DOWN); + BlockState state = PaperLib.getBlockState(dispBlock, false).getState(); + + if (state instanceof Dispenser) { + Dispenser disp = (Dispenser) state; + Inventory inv = disp.getInventory(); + + for (ItemStack current : inv.getContents()) { + for (ItemStack convert : RecipeType.getRecipeInputs(this)) { + if (convert != null && SlimefunUtils.isItemSimilar(current, convert, true)) { + ItemStack adding = RecipeType.getRecipeOutput(this, convert); + Inventory outputInv = findOutputInventory(adding, dispBlock, inv); + + if (outputInv != null) { + ItemStack removing = current.clone(); + removing.setAmount(1); + inv.removeItem(removing); + outputInv.addItem(adding); + p.getWorld().playSound(b.getLocation(), Sound.ENTITY_PLAYER_SPLASH, 1F, 1F); + p.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, Material.HAY_BLOCK); + } + else { + SlimefunPlugin.getLocalization().sendMessage(p, "machines.full-inventory", true); + } + + return; + } + } + } + + SlimefunPlugin.getLocalization().sendMessage(p, "machines.unknown-material", true); + } + } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/MagicWorkbench.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/MagicWorkbench.java index bc853dbdd..1b0de4047 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/MagicWorkbench.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/MagicWorkbench.java @@ -2,12 +2,12 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks; import java.util.List; -import org.bukkit.Bukkit; import org.bukkit.Effect; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; +import org.bukkit.block.BlockState; import org.bukkit.block.Dispenser; import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; @@ -17,6 +17,7 @@ import io.github.thebusybiscuit.cscorelib2.item.CustomItem; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.implementation.items.backpacks.SlimefunBackpack; import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.papermc.lib.PaperLib; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; @@ -26,7 +27,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; public class MagicWorkbench extends BackpackCrafter { public MagicWorkbench(Category category, SlimefunItemStack item) { - super(category, item, new ItemStack[] { null, null, null, null, null, null, new ItemStack(Material.BOOKSHELF), new ItemStack(Material.CRAFTING_TABLE), new ItemStack(Material.DISPENSER) }, new ItemStack[0], BlockFace.UP); + super(category, item, new ItemStack[] { null, null, null, null, null, null, new ItemStack(Material.BOOKSHELF), new ItemStack(Material.CRAFTING_TABLE), new ItemStack(Material.DISPENSER) }, BlockFace.UP); } @Override @@ -38,21 +39,27 @@ public class MagicWorkbench extends BackpackCrafter { return; } - Inventory inv = ((Dispenser) dispenser.getState()).getInventory(); - List inputs = RecipeType.getRecipeInputList(this); + BlockState state = PaperLib.getBlockState(dispenser, false).getState(); - for (int i = 0; i < inputs.size(); i++) { - if (isCraftable(inv, inputs.get(i))) { - ItemStack output = RecipeType.getRecipeOutputList(this, inputs.get(i)).clone(); + if (state instanceof Dispenser) { + Dispenser disp = (Dispenser) state; + Inventory inv = disp.getInventory(); + List inputs = RecipeType.getRecipeInputList(this); - if (Slimefun.hasUnlocked(p, output, true)) { - craft(inv, dispenser, p, b, output); + for (int i = 0; i < inputs.size(); i++) { + if (isCraftable(inv, inputs.get(i))) { + ItemStack output = RecipeType.getRecipeOutputList(this, inputs.get(i)).clone(); + + if (Slimefun.hasUnlocked(p, output, true)) { + craft(inv, dispenser, p, b, output); + } + + return; } - - return; } + + SlimefunPlugin.getLocalization().sendMessage(p, "machines.pattern-not-found", true); } - SlimefunPlugin.getLocalization().sendMessage(p, "machines.pattern-not-found", true); } private void craft(Inventory inv, Block dispenser, Player p, Block b, ItemStack output) { @@ -68,20 +75,26 @@ public class MagicWorkbench extends BackpackCrafter { for (int j = 0; j < 9; j++) { if (inv.getContents()[j] != null && inv.getContents()[j].getType() != Material.AIR) { - if (inv.getContents()[j].getAmount() > 1) inv.setItem(j, new CustomItem(inv.getContents()[j], inv.getContents()[j].getAmount() - 1)); - else inv.setItem(j, null); + if (inv.getContents()[j].getAmount() > 1) { + inv.setItem(j, new CustomItem(inv.getContents()[j], inv.getContents()[j].getAmount() - 1)); + } + else { + inv.setItem(j, null); + } } } startAnimation(p, b, outputInv, output); } - else SlimefunPlugin.getLocalization().sendMessage(p, "machines.full-inventory", true); + else { + SlimefunPlugin.getLocalization().sendMessage(p, "machines.full-inventory", true); + } } private void startAnimation(Player p, Block b, Inventory inv, ItemStack output) { for (int j = 0; j < 4; j++) { int current = j; - Bukkit.getScheduler().runTaskLater(SlimefunPlugin.instance, () -> { + Slimefun.runSync(() -> { p.getWorld().playEffect(b.getLocation(), Effect.MOBSPAWNER_FLAMES, 1); p.getWorld().playEffect(b.getLocation(), Effect.ENDER_SIGNAL, 1); @@ -99,10 +112,18 @@ public class MagicWorkbench extends BackpackCrafter { private Block locateDispenser(Block b) { Block block = null; - if (b.getRelative(1, 0, 0).getType() == Material.DISPENSER) block = b.getRelative(1, 0, 0); - else if (b.getRelative(0, 0, 1).getType() == Material.DISPENSER) block = b.getRelative(0, 0, 1); - else if (b.getRelative(-1, 0, 0).getType() == Material.DISPENSER) block = b.getRelative(-1, 0, 0); - else if (b.getRelative(0, 0, -1).getType() == Material.DISPENSER) block = b.getRelative(0, 0, -1); + if (b.getRelative(1, 0, 0).getType() == Material.DISPENSER) { + block = b.getRelative(1, 0, 0); + } + else if (b.getRelative(0, 0, 1).getType() == Material.DISPENSER) { + block = b.getRelative(0, 0, 1); + } + else if (b.getRelative(-1, 0, 0).getType() == Material.DISPENSER) { + block = b.getRelative(-1, 0, 0); + } + else if (b.getRelative(0, 0, -1).getType() == Material.DISPENSER) { + block = b.getRelative(0, 0, -1); + } return block; } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/MakeshiftSmeltery.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/MakeshiftSmeltery.java index 513b8b3e3..83b044271 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/MakeshiftSmeltery.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/MakeshiftSmeltery.java @@ -18,7 +18,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; public class MakeshiftSmeltery extends AbstractSmeltery { public MakeshiftSmeltery(Category category, SlimefunItemStack item) { - super(category, item, new ItemStack[] { null, new ItemStack(Material.OAK_FENCE), null, new ItemStack(Material.BRICKS), new CustomItem(Material.DISPENSER, "Dispenser (Facing up)"), new ItemStack(Material.BRICKS), null, new ItemStack(Material.FLINT_AND_STEEL), null }, new ItemStack[0], BlockFace.DOWN); + super(category, item, new ItemStack[] { null, new ItemStack(Material.OAK_FENCE), null, new ItemStack(Material.BRICKS), new CustomItem(Material.DISPENSER, "Dispenser (Facing up)"), new ItemStack(Material.BRICKS), null, new ItemStack(Material.FLINT_AND_STEEL), null }, BlockFace.DOWN); } @Override diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/OreCrusher.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/OreCrusher.java index 85337c638..9d07221a0 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/OreCrusher.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/OreCrusher.java @@ -8,6 +8,7 @@ import org.bukkit.Effect; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; +import org.bukkit.block.BlockState; import org.bukkit.block.Dispenser; import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; @@ -20,6 +21,7 @@ import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.papermc.lib.PaperLib; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; @@ -30,11 +32,32 @@ public class OreCrusher extends MultiBlockMachine { private final DoubleOreSetting doubleOres = new DoubleOreSetting(); public OreCrusher(Category category, SlimefunItemStack item) { - super(category, item, new ItemStack[] { null, null, null, null, new ItemStack(Material.NETHER_BRICK_FENCE), null, new ItemStack(Material.IRON_BARS), new CustomItem(Material.DISPENSER, "Dispenser (Facing up)"), new ItemStack(Material.IRON_BARS) }, new ItemStack[] { new ItemStack(Material.COBBLESTONE, 8), new ItemStack(Material.SAND, 1), SlimefunItems.GOLD_4K, SlimefunItems.GOLD_DUST, new ItemStack(Material.GRAVEL), new ItemStack(Material.SAND), new ItemStack(Material.MAGMA_BLOCK, 4), SlimefunItems.SULFATE }, BlockFace.SELF); + super(category, item, new ItemStack[] { null, null, null, null, new ItemStack(Material.NETHER_BRICK_FENCE), null, new ItemStack(Material.IRON_BARS), new CustomItem(Material.DISPENSER, "Dispenser (Facing up)"), new ItemStack(Material.IRON_BARS) }, BlockFace.SELF); addItemSetting(doubleOres); } + @Override + protected void registerDefaultRecipes(List recipes) { + recipes.add(new ItemStack(Material.COBBLESTONE, 8)); + recipes.add(new ItemStack(Material.SAND, 1)); + + recipes.add(SlimefunItems.GOLD_4K); + recipes.add(SlimefunItems.GOLD_DUST); + + recipes.add(new ItemStack(Material.GRAVEL)); + recipes.add(new ItemStack(Material.SAND)); + + recipes.add(new ItemStack(Material.MAGMA_BLOCK, 4)); + recipes.add(SlimefunItems.SULFATE); + + recipes.add(SlimefunItems.CARBON); + recipes.add(new ItemStack(Material.COAL, 8)); + + recipes.add(SlimefunItems.COMPRESSED_CARBON); + recipes.add(new SlimefunItemStack(SlimefunItems.CARBON, 4)); + } + public boolean isOreDoublingEnabled() { return doubleOres.getValue(); } @@ -62,29 +85,35 @@ public class OreCrusher extends MultiBlockMachine { @Override public void onInteract(Player p, Block b) { Block dispBlock = b.getRelative(BlockFace.DOWN); - Dispenser disp = (Dispenser) dispBlock.getState(); - Inventory inv = disp.getInventory(); + BlockState state = PaperLib.getBlockState(dispBlock, false).getState(); - for (ItemStack current : inv.getContents()) { - for (ItemStack convert : RecipeType.getRecipeInputs(this)) { - if (convert != null && SlimefunUtils.isItemSimilar(current, convert, true)) { - ItemStack adding = RecipeType.getRecipeOutput(this, convert); - Inventory outputInv = findOutputInventory(adding, dispBlock, inv); - if (outputInv != null) { - ItemStack removing = current.clone(); - removing.setAmount(convert.getAmount()); - inv.removeItem(removing); - outputInv.addItem(adding); - p.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, 1); + if (state instanceof Dispenser) { + Dispenser disp = (Dispenser) state; + Inventory inv = disp.getInventory(); + + for (ItemStack current : inv.getContents()) { + for (ItemStack convert : RecipeType.getRecipeInputs(this)) { + if (convert != null && SlimefunUtils.isItemSimilar(current, convert, true)) { + ItemStack adding = RecipeType.getRecipeOutput(this, convert); + Inventory outputInv = findOutputInventory(adding, dispBlock, inv); + if (outputInv != null) { + ItemStack removing = current.clone(); + removing.setAmount(convert.getAmount()); + inv.removeItem(removing); + outputInv.addItem(adding); + p.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, 1); + } + else { + SlimefunPlugin.getLocalization().sendMessage(p, "machines.full-inventory", true); + } + + return; } - else SlimefunPlugin.getLocalization().sendMessage(p, "machines.full-inventory", true); - - return; } } - } - SlimefunPlugin.getLocalization().sendMessage(p, "machines.unknown-material", true); + SlimefunPlugin.getLocalization().sendMessage(p, "machines.unknown-material", true); + } } private class DoubleOreSetting extends ItemSetting { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/OreWasher.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/OreWasher.java index 719646aad..73e2a4fe3 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/OreWasher.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/OreWasher.java @@ -9,6 +9,7 @@ import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; +import org.bukkit.block.BlockState; import org.bukkit.block.Dispenser; import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; @@ -18,6 +19,7 @@ import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.papermc.lib.PaperLib; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; @@ -27,7 +29,7 @@ public class OreWasher extends MultiBlockMachine { private final ItemStack[] dusts; public OreWasher(Category category, SlimefunItemStack item) { - super(category, item, new ItemStack[] { null, new ItemStack(Material.DISPENSER), null, null, new ItemStack(Material.OAK_FENCE), null, null, new ItemStack(Material.CAULDRON), null }, new ItemStack[0], BlockFace.SELF); + super(category, item, new ItemStack[] { null, new ItemStack(Material.DISPENSER), null, null, new ItemStack(Material.OAK_FENCE), null, null, new ItemStack(Material.CAULDRON), null }, BlockFace.SELF); legacyMode = SlimefunPlugin.getCfg().getBoolean("options.legacy-ore-washer"); dusts = new ItemStack[] { SlimefunItems.IRON_DUST, SlimefunItems.GOLD_DUST, SlimefunItems.COPPER_DUST, SlimefunItems.TIN_DUST, SlimefunItems.ZINC_DUST, SlimefunItems.ALUMINUM_DUST, SlimefunItems.MAGNESIUM_DUST, SlimefunItems.LEAD_DUST, SlimefunItems.SILVER_DUST }; @@ -41,57 +43,62 @@ public class OreWasher extends MultiBlockMachine { @Override public void onInteract(Player p, Block b) { Block dispBlock = b.getRelative(BlockFace.UP); - Dispenser disp = (Dispenser) dispBlock.getState(); - Inventory inv = disp.getInventory(); + BlockState state = PaperLib.getBlockState(dispBlock, false).getState(); - for (ItemStack input : inv.getContents()) { - if (input != null) { - if (SlimefunUtils.isItemSimilar(input, SlimefunItems.SIFTED_ORE, true)) { - ItemStack output = getRandomDust(); - Inventory outputInv = null; + if (state instanceof Dispenser) { + Dispenser disp = (Dispenser) state; + Inventory inv = disp.getInventory(); - if (!legacyMode) { - // This is a fancy way of checking if there is empty space in the inv; by checking if an - // unobtainable item could fit in it. - // However, due to the way the method findValidOutputInv() functions, the dummyAdding will never - // actually be added to the real inventory, - // so it really doesn't matter what item the ItemStack is made by. SlimefunItems.DEBUG_FISH - // however, signals that it's - // not supposed to be given to the player. - ItemStack dummyAdding = SlimefunItems.DEBUG_FISH; - outputInv = findOutputInventory(dummyAdding, dispBlock, inv); + for (ItemStack input : inv.getContents()) { + if (input != null) { + if (SlimefunUtils.isItemSimilar(input, SlimefunItems.SIFTED_ORE, true)) { + ItemStack output = getRandomDust(); + Inventory outputInv = null; + + if (!legacyMode) { + // This is a fancy way of checking if there is empty space in the inv; by checking if an + // unobtainable item could fit in it. + // However, due to the way the method findValidOutputInv() functions, the dummyAdding will + // never + // actually be added to the real inventory, + // so it really doesn't matter what item the ItemStack is made by. SlimefunItems.DEBUG_FISH + // however, signals that it's + // not supposed to be given to the player. + ItemStack dummyAdding = SlimefunItems.DEBUG_FISH; + outputInv = findOutputInventory(dummyAdding, dispBlock, inv); + } + else { + outputInv = findOutputInventory(output, dispBlock, inv); + } + + removeItem(p, b, inv, outputInv, input, output, 1); + + if (outputInv != null) { + outputInv.addItem(SlimefunItems.STONE_CHUNK); + } + + return; } - else { - outputInv = findOutputInventory(output, dispBlock, inv); + else if (SlimefunUtils.isItemSimilar(input, new ItemStack(Material.SAND, 2), false)) { + ItemStack output = SlimefunItems.SALT; + Inventory outputInv = findOutputInventory(output, dispBlock, inv); + + removeItem(p, b, inv, outputInv, input, output, 2); + + return; } + else if (SlimefunUtils.isItemSimilar(input, SlimefunItems.PULVERIZED_ORE, true)) { + ItemStack output = SlimefunItems.PURE_ORE_CLUSTER; + Inventory outputInv = findOutputInventory(output, dispBlock, inv); - removeItem(p, b, inv, outputInv, input, output, 1); + removeItem(p, b, inv, outputInv, input, output, 1); - if (outputInv != null) { - outputInv.addItem(SlimefunItems.STONE_CHUNK); + return; } - - return; - } - else if (SlimefunUtils.isItemSimilar(input, new ItemStack(Material.SAND, 2), false)) { - ItemStack output = SlimefunItems.SALT; - Inventory outputInv = findOutputInventory(output, dispBlock, inv); - - removeItem(p, b, inv, outputInv, input, output, 2); - - return; - } - else if (SlimefunUtils.isItemSimilar(input, SlimefunItems.PULVERIZED_ORE, true)) { - ItemStack output = SlimefunItems.PURE_ORE_CLUSTER; - Inventory outputInv = findOutputInventory(output, dispBlock, inv); - - removeItem(p, b, inv, outputInv, input, output, 1); - - return; } } + SlimefunPlugin.getLocalization().sendMessage(p, "machines.unknown-material", true); } - SlimefunPlugin.getLocalization().sendMessage(p, "machines.unknown-material", true); } private void removeItem(Player p, Block b, Inventory inputInv, Inventory outputInv, ItemStack input, ItemStack output, int amount) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/PressureChamber.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/PressureChamber.java index 50f919e5d..b10c5fcbc 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/PressureChamber.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/PressureChamber.java @@ -3,12 +3,12 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks; import java.util.List; import java.util.stream.Collectors; -import org.bukkit.Bukkit; import org.bukkit.Effect; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; +import org.bukkit.block.BlockState; import org.bukkit.block.Dispenser; import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; @@ -19,18 +19,17 @@ import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import io.papermc.lib.PaperLib; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; +import me.mrCookieSlime.Slimefun.api.Slimefun; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; public class PressureChamber extends MultiBlockMachine { - + public PressureChamber(Category category, SlimefunItemStack item) { - super(category, item, new ItemStack[] { - SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_14) ? new ItemStack(Material.SMOOTH_STONE_SLAB) : new ItemStack(Material.STONE_SLAB), new CustomItem(Material.DISPENSER, "Dispenser (Facing down)"), SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_14) ? new ItemStack(Material.SMOOTH_STONE_SLAB) : new ItemStack(Material.STONE_SLAB), - new ItemStack(Material.PISTON), new ItemStack(Material.GLASS), new ItemStack(Material.PISTON), - new ItemStack(Material.PISTON), new ItemStack(Material.CAULDRON), new ItemStack(Material.PISTON) - }, new ItemStack[0], BlockFace.UP); + super(category, item, new ItemStack[] { SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_14) ? new ItemStack(Material.SMOOTH_STONE_SLAB) : new ItemStack(Material.STONE_SLAB), new CustomItem(Material.DISPENSER, "Dispenser (Facing down)"), SlimefunPlugin.getMinecraftVersion() + .isAtLeast(MinecraftVersion.MINECRAFT_1_14) ? new ItemStack(Material.SMOOTH_STONE_SLAB) : new ItemStack(Material.STONE_SLAB), new ItemStack(Material.PISTON), new ItemStack(Material.GLASS), new ItemStack(Material.PISTON), new ItemStack(Material.PISTON), new ItemStack(Material.CAULDRON), new ItemStack(Material.PISTON) }, BlockFace.UP); } @Override @@ -41,36 +40,42 @@ public class PressureChamber extends MultiBlockMachine { @Override public void onInteract(Player p, Block b) { Block dispBlock = b.getRelative(BlockFace.UP).getRelative(BlockFace.UP); - Dispenser disp = (Dispenser) dispBlock.getState(); - Inventory inv = disp.getInventory(); + BlockState state = PaperLib.getBlockState(dispBlock, false).getState(); - for (ItemStack current : inv.getContents()) { - for (ItemStack convert : RecipeType.getRecipeInputs(this)) { - if (convert != null && SlimefunUtils.isItemSimilar(current, convert, true)) { - ItemStack output = RecipeType.getRecipeOutput(this, convert); - Inventory outputInv = findOutputInventory(output, dispBlock, inv); + if (state instanceof Dispenser) { + Dispenser disp = (Dispenser) state; + Inventory inv = disp.getInventory(); - if (outputInv != null) { - ItemStack removing = current.clone(); - removing.setAmount(convert.getAmount()); - inv.removeItem(removing); + for (ItemStack current : inv.getContents()) { + for (ItemStack convert : RecipeType.getRecipeInputs(this)) { + if (convert != null && SlimefunUtils.isItemSimilar(current, convert, true)) { + ItemStack output = RecipeType.getRecipeOutput(this, convert); + Inventory outputInv = findOutputInventory(output, dispBlock, inv); - craft(p, b, output, outputInv); + if (outputInv != null) { + ItemStack removing = current.clone(); + removing.setAmount(convert.getAmount()); + inv.removeItem(removing); + + craft(p, b, output, outputInv); + } + else { + SlimefunPlugin.getLocalization().sendMessage(p, "machines.full-inventory", true); + } + + return; } - else SlimefunPlugin.getLocalization().sendMessage(p, "machines.full-inventory", true); - - return; } } + SlimefunPlugin.getLocalization().sendMessage(p, "machines.unknown-material", true); } - SlimefunPlugin.getLocalization().sendMessage(p, "machines.unknown-material", true); } private void craft(Player p, Block b, ItemStack output, Inventory outputInv) { for (int i = 0; i < 4; i++) { int j = i; - Bukkit.getScheduler().runTaskLater(SlimefunPlugin.instance, () -> { + Slimefun.runSync(() -> { p.getWorld().playSound(b.getLocation(), Sound.ENTITY_TNT_PRIMED, 1, 1); p.getWorld().playEffect(b.getRelative(BlockFace.UP).getLocation(), Effect.SMOKE, 4); p.getWorld().playEffect(b.getRelative(BlockFace.UP).getLocation(), Effect.SMOKE, 4); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Smeltery.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Smeltery.java index 0fd03ccd1..5adce87a3 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Smeltery.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Smeltery.java @@ -11,6 +11,7 @@ import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; +import org.bukkit.block.BlockState; import org.bukkit.block.Dropper; import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; @@ -22,6 +23,7 @@ import io.github.thebusybiscuit.cscorelib2.item.CustomItem; import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; +import io.papermc.lib.PaperLib; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.api.BlockStorage; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; @@ -32,11 +34,17 @@ public class Smeltery extends AbstractSmeltery { private final ItemSetting fireBreakingChance = new ItemSetting<>("fire-breaking-chance", 34); public Smeltery(Category category, SlimefunItemStack item) { - super(category, item, new ItemStack[] { null, new ItemStack(Material.NETHER_BRICK_FENCE), null, new ItemStack(Material.NETHER_BRICKS), new CustomItem(Material.DISPENSER, "Dispenser (Facing up)"), new ItemStack(Material.NETHER_BRICKS), null, new ItemStack(Material.FLINT_AND_STEEL), null }, new ItemStack[] { SlimefunItems.IRON_DUST, new ItemStack(Material.IRON_INGOT) }, BlockFace.DOWN); + super(category, item, new ItemStack[] { null, new ItemStack(Material.NETHER_BRICK_FENCE), null, new ItemStack(Material.NETHER_BRICKS), new CustomItem(Material.DISPENSER, "Dispenser (Facing up)"), new ItemStack(Material.NETHER_BRICKS), null, new ItemStack(Material.FLINT_AND_STEEL), null }, BlockFace.DOWN); addItemSetting(fireBreakingChance); } + @Override + protected void registerDefaultRecipes(List recipes) { + recipes.add(SlimefunItems.IRON_DUST); + recipes.add(new ItemStack(Material.IRON_INGOT)); + } + @Override public List getDisplayRecipes() { List items = new ArrayList<>(); @@ -97,7 +105,11 @@ public class Smeltery extends AbstractSmeltery { private Inventory findIgnitionChamber(Block b) { for (BlockFace face : faces) { if (b.getRelative(face).getType() == Material.DROPPER && BlockStorage.check(b.getRelative(face), "IGNITION_CHAMBER")) { - return ((Dropper) b.getRelative(face).getState()).getInventory(); + BlockState state = PaperLib.getBlockState(b.getRelative(face), false).getState(); + + if (state instanceof Dropper) { + return ((Dropper) state).getInventory(); + } } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java index 05916a9b5..22caf32c7 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java @@ -36,7 +36,7 @@ public class TableSaw extends MultiBlockMachine { private final List displayedRecipes = new ArrayList<>(); public TableSaw(Category category, SlimefunItemStack item) { - super(category, item, new ItemStack[] { null, null, null, new ItemStack(Material.SMOOTH_STONE_SLAB), new ItemStack(Material.STONECUTTER), new ItemStack(Material.SMOOTH_STONE_SLAB), null, new ItemStack(Material.IRON_BLOCK), null }, new ItemStack[0], BlockFace.SELF); + super(category, item, new ItemStack[] { null, null, null, new ItemStack(Material.SMOOTH_STONE_SLAB), new ItemStack(Material.STONECUTTER), new ItemStack(Material.SMOOTH_STONE_SLAB), null, new ItemStack(Material.IRON_BLOCK), null }, BlockFace.SELF); for (Material log : Tag.LOGS.getValues()) { Optional planks = MaterialConverter.getPlanksFromLog(log); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/ActiveMiner.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/ActiveMiner.java index 557953ef6..36f42092b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/ActiveMiner.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/ActiveMiner.java @@ -11,6 +11,7 @@ import org.bukkit.Particle; import org.bukkit.Sound; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; +import org.bukkit.block.BlockState; import org.bukkit.block.Chest; import org.bukkit.block.data.type.Piston; import org.bukkit.block.data.type.PistonHead; @@ -24,6 +25,7 @@ import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils; import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction; import io.github.thebusybiscuit.cscorelib2.scheduling.TaskQueue; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; +import io.papermc.lib.PaperLib; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineFuel; import me.mrCookieSlime.Slimefun.api.Slimefun; @@ -149,7 +151,7 @@ class ActiveMiner implements Runnable { queue.thenRun(2, () -> setPistonState(pistons[1], false)); queue.thenRun(1, this); - queue.execute(SlimefunPlugin.instance); + queue.execute(SlimefunPlugin.instance()); } @Override @@ -202,7 +204,7 @@ class ActiveMiner implements Runnable { } }); - queue.execute(SlimefunPlugin.instance); + queue.execute(SlimefunPlugin.instance()); } /** @@ -251,14 +253,22 @@ class ActiveMiner implements Runnable { // Check if there is enough fuel to run if (fuel > 0) { if (chest.getType() == Material.CHEST) { - Inventory inv = ((Chest) chest.getState()).getBlockInventory(); + BlockState state = PaperLib.getBlockState(chest, false).getState(); - if (InvUtils.fits(inv, item)) { - inv.addItem(item); - return true; + if (state instanceof Chest) { + Inventory inv = ((Chest) state).getBlockInventory(); + + if (InvUtils.fits(inv, item)) { + inv.addItem(item); + return true; + } + else { + stop("machines.INDUSTRIAL_MINER.chest-full"); + } } else { - stop("machines.INDUSTRIAL_MINER.chest-full"); + // I won't question how this happened... + stop("machines.INDUSTRIAL_MINER.destroyed"); } } else { @@ -280,20 +290,24 @@ class ActiveMiner implements Runnable { */ private int consumeFuel() { if (chest.getType() == Material.CHEST) { - Inventory inv = ((Chest) chest.getState()).getBlockInventory(); + BlockState state = PaperLib.getBlockState(chest, false).getState(); - for (int i = 0; i < inv.getSize(); i++) { - for (MachineFuel fuelType : miner.fuelTypes) { - ItemStack item = inv.getContents()[i]; + if (state instanceof Chest) { + Inventory inv = ((Chest) state).getBlockInventory(); - if (fuelType.test(item)) { - ItemUtils.consumeItem(item, false); + for (int i = 0; i < inv.getSize(); i++) { + for (MachineFuel fuelType : miner.fuelTypes) { + ItemStack item = inv.getContents()[i]; - if (miner instanceof AdvancedIndustrialMiner) { - inv.addItem(new ItemStack(Material.BUCKET)); + if (fuelType.test(item)) { + ItemUtils.consumeItem(item, false); + + if (miner instanceof AdvancedIndustrialMiner) { + inv.addItem(new ItemStack(Material.BUCKET)); + } + + return fuelType.getTicks(); } - - return fuelType.getTicks(); } } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/IndustrialMiner.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/IndustrialMiner.java index 7caf4b073..deb98ba23 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/IndustrialMiner.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/IndustrialMiner.java @@ -49,7 +49,7 @@ public class IndustrialMiner extends MultiBlockMachine { private final boolean silkTouch; public IndustrialMiner(Category category, SlimefunItemStack item, Material baseMaterial, boolean silkTouch, int range) { - super(category, item, new ItemStack[] { null, null, null, new CustomItem(Material.PISTON, "Piston (facing up)"), new ItemStack(Material.CHEST), new CustomItem(Material.PISTON, "Piston (facing up)"), new ItemStack(baseMaterial), new ItemStack(SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_14) ? Material.BLAST_FURNACE : Material.FURNACE), new ItemStack(baseMaterial) }, new ItemStack[0], BlockFace.UP); + super(category, item, new ItemStack[] { null, null, null, new CustomItem(Material.PISTON, "Piston (facing up)"), new ItemStack(Material.CHEST), new CustomItem(Material.PISTON, "Piston (facing up)"), new ItemStack(baseMaterial), new ItemStack(SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_14) ? Material.BLAST_FURNACE : Material.FURNACE), new ItemStack(baseMaterial) }, BlockFace.UP); this.range = range; this.silkTouch = silkTouch; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/seasonal/ChristmasPresent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/seasonal/ChristmasPresent.java index a408deb6e..bf0ffe8c7 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/seasonal/ChristmasPresent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/seasonal/ChristmasPresent.java @@ -8,10 +8,10 @@ import org.bukkit.inventory.ItemStack; import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils; import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable; import io.github.thebusybiscuit.slimefun4.core.handlers.BlockPlaceHandler; +import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; import io.github.thebusybiscuit.slimefun4.utils.FireworkUtils; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; -import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; public class ChristmasPresent extends SimpleSlimefunItem implements NotPlaceable { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/seasonal/EasterEgg.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/seasonal/EasterEgg.java index 5073842d7..14660476a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/seasonal/EasterEgg.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/seasonal/EasterEgg.java @@ -8,10 +8,10 @@ import org.bukkit.inventory.ItemStack; import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils; import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; +import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; import io.github.thebusybiscuit.slimefun4.utils.FireworkUtils; 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.SlimefunItemStack; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ExplosiveTool.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ExplosiveTool.java index 770bcfe17..2ad1cb1b2 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ExplosiveTool.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ExplosiveTool.java @@ -21,10 +21,10 @@ import io.github.thebusybiscuit.slimefun4.core.attributes.DamageableItem; import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable; import io.github.thebusybiscuit.slimefun4.core.handlers.BlockBreakHandler; 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.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.api.BlockStorage; @@ -38,6 +38,7 @@ class ExplosiveTool extends SimpleSlimefunItem implements Not public ExplosiveTool(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { super(category, item, recipeType, recipe); + addItemSetting(damageOnUse, callExplosionEvent); } @@ -54,6 +55,7 @@ class ExplosiveTool extends SimpleSlimefunItem implements Not public boolean onBlockBreak(BlockBreakEvent e, ItemStack item, int fortune, List drops) { if (isItem(item)) { Player p = e.getPlayer(); + if (Slimefun.hasUnlocked(p, ExplosiveTool.this, true)) { Block b = e.getBlock(); @@ -61,21 +63,7 @@ class ExplosiveTool extends SimpleSlimefunItem implements Not b.getWorld().playSound(b.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 0.2F, 1F); List blocks = findBlocks(b); - if (callExplosionEvent.getValue().booleanValue()) { - BlockExplodeEvent blockExplodeEvent = new BlockExplodeEvent(b, blocks, 0); - Bukkit.getServer().getPluginManager().callEvent(blockExplodeEvent); - - if (!blockExplodeEvent.isCancelled()) { - for (Block block : blockExplodeEvent.blockList()) { - breakBlock(p, item, block, fortune, drops); - } - } - } - else { - for (Block block : blocks) { - breakBlock(p, item, block, fortune, drops); - } - } + breakBlocks(p, item, b, blocks, fortune, drops); } return true; @@ -87,6 +75,24 @@ class ExplosiveTool extends SimpleSlimefunItem implements Not }; } + private void breakBlocks(Player p, ItemStack item, Block b, List blocks, int fortune, List drops) { + if (callExplosionEvent.getValue().booleanValue()) { + BlockExplodeEvent blockExplodeEvent = new BlockExplodeEvent(b, blocks, 0); + Bukkit.getServer().getPluginManager().callEvent(blockExplodeEvent); + + if (!blockExplodeEvent.isCancelled()) { + for (Block block : blockExplodeEvent.blockList()) { + breakBlock(p, item, block, fortune, drops); + } + } + } + else { + for (Block block : blocks) { + breakBlock(p, item, block, fortune, drops); + } + } + } + private List findBlocks(Block b) { List blocks = new ArrayList<>(26); @@ -112,7 +118,7 @@ class ExplosiveTool extends SimpleSlimefunItem implements Not } protected void breakBlock(Player p, ItemStack item, Block b, int fortune, List drops) { - if (b.getType() != Material.AIR && !b.isLiquid() && !MaterialCollections.getAllUnbreakableBlocks().contains(b.getType()) && SlimefunPlugin.getProtectionManager().hasPermission(p, b.getLocation(), ProtectableAction.BREAK_BLOCK)) { + if (!b.isEmpty() && !b.isLiquid() && !MaterialCollections.getAllUnbreakableBlocks().contains(b.getType()) && SlimefunPlugin.getProtectionManager().hasPermission(p, b.getLocation(), ProtectableAction.BREAK_BLOCK)) { SlimefunPlugin.getProtectionManager().logAction(p, b, ProtectableAction.BREAK_BLOCK); b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, b.getType()); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/GoldPan.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/GoldPan.java index 23a8f6136..2e7c09c60 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/GoldPan.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/GoldPan.java @@ -18,11 +18,11 @@ import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem; import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; +import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.ElectricGoldPan; import io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.AutomatedPanningMachine; 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.SlimefunItemStack; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/GrapplingHook.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/GrapplingHook.java index aa78365d4..8d0c68682 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/GrapplingHook.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/GrapplingHook.java @@ -15,9 +15,9 @@ import org.bukkit.util.Vector; import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; 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.api.SlimefunItemStack; public class GrapplingHook extends SimpleSlimefunItem { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/HerculesPickaxe.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/HerculesPickaxe.java index 7292a16b0..ddcee83ca 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/HerculesPickaxe.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/HerculesPickaxe.java @@ -9,9 +9,9 @@ import org.bukkit.inventory.ItemStack; import io.github.thebusybiscuit.cscorelib2.item.CustomItem; import io.github.thebusybiscuit.slimefun4.core.handlers.BlockBreakHandler; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; +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.api.Slimefun; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/LumberAxe.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/LumberAxe.java index 5e35de377..77610b2a1 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/LumberAxe.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/LumberAxe.java @@ -19,9 +19,9 @@ import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable; import io.github.thebusybiscuit.slimefun4.core.handlers.BlockBreakHandler; 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.api.Slimefun; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PickaxeOfContainment.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PickaxeOfContainment.java index 2580a8abe..c86507d3d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PickaxeOfContainment.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PickaxeOfContainment.java @@ -4,19 +4,22 @@ import java.util.List; import org.bukkit.Material; import org.bukkit.block.Block; +import org.bukkit.block.BlockState; import org.bukkit.block.CreatureSpawner; +import org.bukkit.entity.EntityType; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import io.github.thebusybiscuit.slimefun4.core.handlers.BlockBreakHandler; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.BrokenSpawner; import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.RepairedSpawner; import io.github.thebusybiscuit.slimefun4.utils.ChatUtils; +import io.papermc.lib.PaperLib; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; -import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem; import me.mrCookieSlime.Slimefun.api.BlockStorage; import me.mrCookieSlime.Slimefun.api.Slimefun; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; @@ -65,7 +68,10 @@ public class PickaxeOfContainment extends SimpleSlimefunItem return true; } else { - if (e.getBlock().getType() == Material.SPAWNER) e.setDropItems(false); + if (e.getBlock().getType() == Material.SPAWNER) { + e.setDropItems(false); + } + return false; } } @@ -84,15 +90,24 @@ public class PickaxeOfContainment extends SimpleSlimefunItem ItemMeta im = spawner.getItemMeta(); List lore = im.getLore(); - for (int i = 0; i < lore.size(); i++) { - if (lore.get(i).contains("")) { - lore.set(i, lore.get(i).replace("", ChatUtils.humanize(((CreatureSpawner) b.getState()).getSpawnedType().toString()))); + BlockState state = PaperLib.getBlockState(b, false).getState(); + + if (state instanceof CreatureSpawner) { + EntityType entityType = ((CreatureSpawner) state).getSpawnedType(); + + for (int i = 0; i < lore.size(); i++) { + if (lore.get(i).contains("")) { + lore.set(i, lore.get(i).replace("", ChatUtils.humanize(entityType.name()))); + break; + } } + + im.setLore(lore); + spawner.setItemMeta(im); + return spawner; } - im.setLore(lore); - spawner.setItemMeta(im); - return spawner; + return new ItemStack(Material.SPAWNER); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PickaxeOfTheSeeker.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PickaxeOfTheSeeker.java index 204b5719e..82ae021d1 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PickaxeOfTheSeeker.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PickaxeOfTheSeeker.java @@ -10,9 +10,9 @@ import io.github.thebusybiscuit.cscorelib2.materials.MaterialCollections; import io.github.thebusybiscuit.slimefun4.core.attributes.DamageableItem; 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.api.SlimefunItemStack; public class PickaxeOfTheSeeker extends SimpleSlimefunItem implements DamageableItem { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PickaxeOfVeinMining.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PickaxeOfVeinMining.java index 9862f4dcf..e2ed14c78 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PickaxeOfVeinMining.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PickaxeOfVeinMining.java @@ -17,9 +17,9 @@ import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction; import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; import io.github.thebusybiscuit.slimefun4.core.handlers.BlockBreakHandler; 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.api.Slimefun; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PortableCrafter.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PortableCrafter.java index ce223f020..4a9d02af4 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PortableCrafter.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PortableCrafter.java @@ -6,9 +6,9 @@ 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.api.SlimefunItemStack; public class PortableCrafter extends SimpleSlimefunItem implements NotPlaceable { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PortableDustbin.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PortableDustbin.java index cf43a17c9..9d785b3bf 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PortableDustbin.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PortableDustbin.java @@ -8,9 +8,9 @@ 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.api.SlimefunItemStack; public class PortableDustbin extends SimpleSlimefunItem implements NotPlaceable { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/SmeltersPickaxe.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/SmeltersPickaxe.java index 5fdc56a50..bbd13af58 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/SmeltersPickaxe.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/SmeltersPickaxe.java @@ -14,9 +14,9 @@ import io.github.thebusybiscuit.cscorelib2.materials.MaterialCollections; import io.github.thebusybiscuit.slimefun4.core.attributes.DamageableItem; import io.github.thebusybiscuit.slimefun4.core.handlers.BlockBreakHandler; 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.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/tools/TapeMeasure.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/TapeMeasure.java new file mode 100644 index 000000000..919ddd8c1 --- /dev/null +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/TapeMeasure.java @@ -0,0 +1,115 @@ +package io.github.thebusybiscuit.slimefun4.implementation.items.tools; + +import java.text.DecimalFormat; +import java.util.Optional; +import java.util.UUID; + +import org.bukkit.Location; +import org.bukkit.NamespacedKey; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.persistence.PersistentDataType; + +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; + +import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable; +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.api.SlimefunItemStack; + +/** + * The {@link TapeMeasure} is used to measure the distance between two {@link Block Blocks}. + * + * @author TheBusyBiscuit + * + */ +public class TapeMeasure extends SimpleSlimefunItem implements NotPlaceable { + + private final NamespacedKey key = new NamespacedKey(SlimefunPlugin.instance(), "anchor"); + private final DecimalFormat format = new DecimalFormat("##.###"); + + public TapeMeasure(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { + super(category, item, recipeType, recipe); + } + + @Override + public ItemUseHandler getItemHandler() { + return e -> { + e.cancel(); + + if (e.getClickedBlock().isPresent()) { + Block block = e.getClickedBlock().get(); + + if (e.getPlayer().isSneaking()) { + setAnchor(e.getPlayer(), e.getItem(), block); + } + else { + measure(e.getPlayer(), e.getItem(), block); + } + } + }; + } + + private void setAnchor(Player p, ItemStack item, Block block) { + ItemMeta meta = item.getItemMeta(); + + JsonObject json = new JsonObject(); + json.addProperty("world", block.getWorld().getUID().toString()); + json.addProperty("x", block.getX()); + json.addProperty("y", block.getY()); + json.addProperty("z", block.getZ()); + + meta.getPersistentDataContainer().set(key, PersistentDataType.STRING, json.toString()); + + String anchor = block.getX() + " | " + block.getY() + " | " + block.getZ(); + SlimefunPlugin.getLocalization().sendMessage(p, "messages.tape-measure.anchor-set", msg -> msg.replace("%anchor%", anchor)); + + item.setItemMeta(meta); + + } + + private Optional getAnchor(Player p, ItemStack item) { + ItemMeta meta = item.getItemMeta(); + + String data = meta.getPersistentDataContainer().get(key, PersistentDataType.STRING); + + if (data != null) { + JsonObject json = new JsonParser().parse(data).getAsJsonObject(); + + UUID uuid = UUID.fromString(json.get("world").getAsString()); + + if (p.getWorld().getUID().equals(uuid)) { + int x = json.get("x").getAsInt(); + int y = json.get("y").getAsInt(); + int z = json.get("z").getAsInt(); + Location loc = new Location(p.getWorld(), x, y, z); + return Optional.of(loc); + } + else { + SlimefunPlugin.getLocalization().sendMessage(p, "messages.tape-measure.wrong-world"); + return Optional.empty(); + } + } + else { + SlimefunPlugin.getLocalization().sendMessage(p, "messages.tape-measure.no-anchor"); + return Optional.empty(); + } + } + + private void measure(Player p, ItemStack item, Block block) { + Optional anchor = getAnchor(p, item); + + if (anchor.isPresent()) { + Location loc = anchor.get(); + double distance = loc.distance(block.getLocation()); + SlimefunPlugin.getLocalization().sendMessage(p, "messages.tape-measure.distance", msg -> msg.replace("%distance%", format.format(distance))); + } + } + +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/SeismicAxe.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/SeismicAxe.java index 9305abdac..3f8bd137a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/SeismicAxe.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/SeismicAxe.java @@ -23,9 +23,9 @@ import io.github.thebusybiscuit.slimefun4.core.attributes.DamageableItem; import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable; 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.api.SlimefunItemStack; /** @@ -63,7 +63,7 @@ public class SeismicAxe extends SimpleSlimefunItem implements No FallingBlock block = ground.getWorld().spawnFallingBlock(loc, ground.getBlockData()); block.setDropItem(false); block.setVelocity(new Vector(0, 0.4 + i * 0.01, 0)); - block.setMetadata("seismic_axe", new FixedMetadataValue(SlimefunPlugin.instance, "fake_block")); + block.setMetadata("seismic_axe", new FixedMetadataValue(SlimefunPlugin.instance(), "fake_block")); } for (Entity n : ground.getChunk().getEntities()) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/SwordOfBeheading.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/SwordOfBeheading.java index 92c2b4222..cd4affd3e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/SwordOfBeheading.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/SwordOfBeheading.java @@ -15,9 +15,9 @@ import org.bukkit.inventory.meta.SkullMeta; import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; import io.github.thebusybiscuit.slimefun4.core.handlers.EntityKillHandler; +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.api.SlimefunItemStack; public class SwordOfBeheading extends SimpleSlimefunItem { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ButcherAndroidListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ButcherAndroidListener.java index f90df4ddf..78dda0ec3 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ButcherAndroidListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ButcherAndroidListener.java @@ -61,7 +61,7 @@ public class ButcherAndroidListener implements Listener { }, 1L); // Removing metadata to prevent memory leaks - e.getEntity().removeMetadata(METADATA_KEY, SlimefunPlugin.instance); + e.getEntity().removeMetadata(METADATA_KEY, SlimefunPlugin.instance()); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/DebugFishListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/DebugFishListener.java index 1a3a886e9..a463f2324 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/DebugFishListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/DebugFishListener.java @@ -15,6 +15,7 @@ import org.bukkit.inventory.EquipmentSlot; import io.github.thebusybiscuit.cscorelib2.chat.ChatColors; import io.github.thebusybiscuit.cscorelib2.skull.SkullBlock; import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetComponent; +import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetProvider; import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNet; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; @@ -101,8 +102,8 @@ public class DebugFishListener implements Listener { p.sendMessage(ChatColors.color("&dTicking: " + greenCheckmark)); p.sendMessage(ChatColors.color(" &dAsync: &e" + (item.getBlockTicker().isSynchronized() ? redCross : greenCheckmark))); } - else if (item.getEnergyTicker() != null) { - p.sendMessage(ChatColors.color("&dTicking: &3Indirect")); + else if (item instanceof EnergyNetProvider) { + p.sendMessage(ChatColors.color("&dTicking: &3Indirect (Generator)")); } else { p.sendMessage(ChatColors.color("&dTicking: " + redCross)); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/DispenserListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/DispenserListener.java index cdd6cbafb..75c9f60d3 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/DispenserListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/DispenserListener.java @@ -3,6 +3,7 @@ package io.github.thebusybiscuit.slimefun4.implementation.listeners; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; +import org.bukkit.block.BlockState; import org.bukkit.block.Dispenser; import org.bukkit.block.data.Directional; import org.bukkit.event.EventHandler; @@ -11,6 +12,7 @@ import org.bukkit.event.block.BlockDispenseEvent; import io.github.thebusybiscuit.slimefun4.core.handlers.BlockDispenseHandler; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; +import io.papermc.lib.PaperLib; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; import me.mrCookieSlime.Slimefun.api.BlockStorage; @@ -39,10 +41,14 @@ public class DispenserListener implements Listener { if (machine != null) { machine.callItemHandler(BlockDispenseHandler.class, handler -> { - Dispenser dispenser = (Dispenser) b.getState(); - BlockFace face = ((Directional) b.getBlockData()).getFacing(); - Block block = b.getRelative(face); - handler.onBlockDispense(e, dispenser, block, machine); + BlockState state = PaperLib.getBlockState(b, false).getState(); + + if (state instanceof Dispenser) { + Dispenser dispenser = (Dispenser) state; + BlockFace face = ((Directional) b.getBlockData()).getFacing(); + Block block = b.getRelative(face); + handler.onBlockDispense(e, dispenser, block, machine); + } }); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/EnhancedFurnaceListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/EnhancedFurnaceListener.java index 8cc56d8eb..fcfb83f4f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/EnhancedFurnaceListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/EnhancedFurnaceListener.java @@ -2,17 +2,20 @@ package io.github.thebusybiscuit.slimefun4.implementation.listeners; import java.util.Optional; +import org.bukkit.Material; +import org.bukkit.block.BlockState; import org.bukkit.block.Furnace; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.inventory.FurnaceBurnEvent; import org.bukkit.event.inventory.FurnaceSmeltEvent; +import org.bukkit.inventory.FurnaceInventory; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.cscorelib2.item.CustomItem; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.EnhancedFurnace; +import io.papermc.lib.PaperLib; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; import me.mrCookieSlime.Slimefun.api.BlockStorage; @@ -33,31 +36,44 @@ public class EnhancedFurnaceListener implements Listener { @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onFuelBurn(FurnaceBurnEvent e) { + if (e.getBlock().getType() != Material.FURNACE) { + // We don't care about Smokers, Blast Furnaces and all that fancy stuff + return; + } + SlimefunItem furnace = BlockStorage.check(e.getBlock()); if (furnace instanceof EnhancedFurnace && ((EnhancedFurnace) furnace).getFuelEfficiency() > 0) { int burnTime = e.getBurnTime(); int newBurnTime = ((EnhancedFurnace) furnace).getFuelEfficiency() * burnTime; - e.setBurnTime(Math.min(newBurnTime, Short.MAX_VALUE)); + + e.setBurnTime(Math.min(newBurnTime, Short.MAX_VALUE - 1)); } } @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onItemSmelt(FurnaceSmeltEvent e) { + if (e.getBlock().getType() != Material.FURNACE) { + // We don't care about Smokers, Blast Furnaces and all that fancy stuff + return; + } + SlimefunItem sfItem = BlockStorage.check(e.getBlock()); if (sfItem instanceof EnhancedFurnace) { - Furnace furnace = (Furnace) e.getBlock().getState(); - int amount = furnace.getInventory().getSmelting().getType().toString().endsWith("_ORE") ? ((EnhancedFurnace) sfItem).getOutput() : 1; - Optional result = Optional.ofNullable(furnace.getInventory().getResult()); + BlockState state = PaperLib.getBlockState(e.getBlock(), false).getState(); - if (!result.isPresent()) { - result = SlimefunPlugin.getMinecraftRecipeService().getFurnaceOutput(furnace.getInventory().getSmelting()); - } + if (state instanceof Furnace) { + FurnaceInventory inventory = ((Furnace) state).getInventory(); + int amount = inventory.getSmelting().getType().toString().endsWith("_ORE") ? ((EnhancedFurnace) sfItem).getOutput() : 1; + Optional result = SlimefunPlugin.getMinecraftRecipeService().getFurnaceOutput(inventory.getSmelting()); - if (result.isPresent()) { - ItemStack item = result.get(); - furnace.getInventory().setResult(new CustomItem(item, Math.min(item.getAmount() + amount, item.getMaxStackSize()))); + if (result.isPresent()) { + ItemStack item = result.get(); + int previous = inventory.getResult() != null ? inventory.getResult().getAmount() : 0; + amount = Math.min(item.getMaxStackSize() - previous, amount); + e.setResult(new ItemStack(item.getType(), amount)); + } } } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ExplosionsListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ExplosionsListener.java index 80e3dc330..0306e8d0d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ExplosionsListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ExplosionsListener.java @@ -9,7 +9,7 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityExplodeEvent; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun4.core.attributes.WitherProof; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import me.mrCookieSlime.Slimefun.Objects.SlimefunBlockHandler; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; @@ -29,19 +29,16 @@ public class ExplosionsListener implements Listener { while (blocks.hasNext()) { Block block = blocks.next(); - String id = BlockStorage.checkID(block); - if (id != null) { + SlimefunItem item = BlockStorage.check(block); + if (item != null) { blocks.remove(); - // Hardened Glass and WitherProof blocks cannot be destroyed by explosions - if (!id.equals(SlimefunItems.HARDENED_GLASS.getItemId()) && !SlimefunPlugin.getRegistry().getWitherProofBlocks().containsKey(id)) { + if (!(item instanceof WitherProof)) { + SlimefunBlockHandler blockHandler = SlimefunPlugin.getRegistry().getBlockHandlers().get(item.getID()); boolean success = true; - SlimefunItem sfItem = SlimefunItem.getByID(id); - - SlimefunBlockHandler blockHandler = SlimefunPlugin.getRegistry().getBlockHandlers().get(sfItem.getID()); if (blockHandler != null) { - success = blockHandler.onBreak(null, block, sfItem, UnregisterReason.EXPLODE); + success = blockHandler.onBreak(null, block, item, UnregisterReason.EXPLODE); } if (success) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/MobDropListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/MobDropListener.java index 0d511e58a..ad90481bd 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/MobDropListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/MobDropListener.java @@ -1,7 +1,7 @@ package io.github.thebusybiscuit.slimefun4.implementation.listeners; -import java.util.List; import java.util.Set; +import java.util.concurrent.ThreadLocalRandom; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -10,20 +10,28 @@ import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.inventory.ItemStack; +import io.github.thebusybiscuit.slimefun4.core.attributes.RandomMobDrop; import io.github.thebusybiscuit.slimefun4.core.handlers.EntityKillHandler; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.BasicCircuitBoard; +import io.github.thebusybiscuit.slimefun4.implementation.items.misc.BasicCircuitBoard; +import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; import me.mrCookieSlime.Slimefun.api.Slimefun; +/** + * This {@link Listener} is responsible for handling any custom mob drops. + * These drops can also be randomized using the interface {@link RandomMobDrop}, otherwise + * they will be handled via {@link RecipeType}. + * + * @author TheBusyBiscuit + * + * @see RandomMobDrop + * + */ public class MobDropListener implements Listener { - private final BasicCircuitBoard circuitBoard; - - public MobDropListener(SlimefunPlugin plugin, BasicCircuitBoard circuitBoard) { + public MobDropListener(SlimefunPlugin plugin) { plugin.getServer().getPluginManager().registerEvents(this, plugin); - - this.circuitBoard = circuitBoard; } @EventHandler @@ -32,9 +40,14 @@ public class MobDropListener implements Listener { Player p = e.getEntity().getKiller(); ItemStack item = p.getInventory().getItemInMainHand(); - Set customDrops = SlimefunPlugin.getRegistry().getMobDrops(e.getEntityType()); + Set customDrops = SlimefunPlugin.getRegistry().getMobDrops().get(e.getEntityType()); + if (customDrops != null && !customDrops.isEmpty()) { - addDrops(p, customDrops, e.getDrops()); + for (ItemStack drop : customDrops) { + if (canDrop(p, drop)) { + e.getDrops().add(drop.clone()); + } + } } if (item.getType() != Material.AIR) { @@ -47,15 +60,30 @@ public class MobDropListener implements Listener { } } - private void addDrops(Player p, Set customDrops, List drops) { - for (ItemStack drop : customDrops) { - if (Slimefun.hasUnlocked(p, drop, true)) { - if (circuitBoard != null && circuitBoard.isItem(drop) && !circuitBoard.isDroppedFromGolems()) { - continue; - } + private boolean canDrop(Player p, ItemStack item) { + SlimefunItem sfi = SlimefunItem.getByItem(item); - drops.add(drop.clone()); + if (sfi == null) { + return true; + } + else if (Slimefun.hasUnlocked(p, sfi, true)) { + + if (sfi instanceof RandomMobDrop) { + int random = ThreadLocalRandom.current().nextInt(100); + + if (((RandomMobDrop) sfi).getMobDropChance() <= random) { + return false; + } } + + if (sfi instanceof BasicCircuitBoard) { + return ((BasicCircuitBoard) sfi).isDroppedFromGolems(); + } + + return true; + } + else { + return false; } } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/PlayerProfileListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/PlayerProfileListener.java index f88b582c0..7911b117e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/PlayerProfileListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/PlayerProfileListener.java @@ -31,9 +31,7 @@ public class PlayerProfileListener implements Listener { Optional profile = PlayerProfile.find(e.getPlayer()); // if we still have a profile of this Player in memory, delete it - if (profile.isPresent()) { - profile.get().markForDeletion(); - } + profile.ifPresent(PlayerProfile::markForDeletion); } @EventHandler(ignoreCancelled = true) @@ -41,9 +39,7 @@ public class PlayerProfileListener implements Listener { Optional profile = PlayerProfile.find(e.getPlayer()); // if we still have a profile of this Player in memory, delete it - if (profile.isPresent()) { - profile.get().markForDeletion(); - } + profile.ifPresent(PlayerProfile::markForDeletion); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SeismicAxeListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SeismicAxeListener.java index 4b5aae5fd..50b3e6384 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SeismicAxeListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SeismicAxeListener.java @@ -35,7 +35,7 @@ public class SeismicAxeListener implements Listener { if (e.getEntity().getType() == EntityType.FALLING_BLOCK && e.getEntity().hasMetadata("seismic_axe")) { e.setCancelled(true); - e.getEntity().removeMetadata("seismic_axe", SlimefunPlugin.instance); + e.getEntity().removeMetadata("seismic_axe", SlimefunPlugin.instance()); e.getEntity().remove(); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/WitherListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/WitherListener.java index f60400221..0e8eb526d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/WitherListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/WitherListener.java @@ -7,7 +7,9 @@ import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityChangeBlockEvent; import io.github.thebusybiscuit.slimefun4.core.attributes.WitherProof; +import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; +import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; import me.mrCookieSlime.Slimefun.api.BlockStorage; /** @@ -28,15 +30,12 @@ public class WitherListener implements Listener { @EventHandler(ignoreCancelled = true) public void onWitherDestroy(EntityChangeBlockEvent e) { if (e.getEntity().getType() == EntityType.WITHER) { - String id = BlockStorage.checkID(e.getBlock()); + SlimefunItem item = BlockStorage.check(e.getBlock()); - if (id != null) { - WitherProof witherproof = SlimefunPlugin.getRegistry().getWitherProofBlocks().get(id); - - if (witherproof != null) { - e.setCancelled(true); - witherproof.onAttack(e.getBlock(), (Wither) e.getEntity()); - } + // Hardened Glass is excluded from here + if (item instanceof WitherProof && !item.getID().equals(SlimefunItems.HARDENED_GLASS.getItemId())) { + e.setCancelled(true); + ((WitherProof) item).onAttack(e.getBlock(), (Wither) e.getEntity()); } } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/resources/NetherIceResource.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/resources/NetherIceResource.java index 5a1e0f7c8..994b20290 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/resources/NetherIceResource.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/resources/NetherIceResource.java @@ -11,7 +11,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; class NetherIceResource implements GEOResource { - private final NamespacedKey key = new NamespacedKey(SlimefunPlugin.instance, "nether_ice"); + private final NamespacedKey key = new NamespacedKey(SlimefunPlugin.instance(), "nether_ice"); @Override public int getDefaultSupply(Environment environment, Biome biome) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/resources/OilResource.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/resources/OilResource.java index 44ff1a090..f40777c83 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/resources/OilResource.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/resources/OilResource.java @@ -11,7 +11,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; class OilResource implements GEOResource { - private final NamespacedKey key = new NamespacedKey(SlimefunPlugin.instance, "oil"); + private final NamespacedKey key = new NamespacedKey(SlimefunPlugin.instance(), "oil"); @Override public int getDefaultSupply(Environment environment, Biome biome) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/resources/SaltResource.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/resources/SaltResource.java index 5a4cabb61..a93014bab 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/resources/SaltResource.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/resources/SaltResource.java @@ -11,7 +11,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; class SaltResource implements GEOResource { - private final NamespacedKey key = new NamespacedKey(SlimefunPlugin.instance, "salt"); + private final NamespacedKey key = new NamespacedKey(SlimefunPlugin.instance(), "salt"); @Override public int getDefaultSupply(Environment environment, Biome biome) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/resources/UraniumResource.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/resources/UraniumResource.java index a98010ac1..b85528480 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/resources/UraniumResource.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/resources/UraniumResource.java @@ -11,7 +11,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; class UraniumResource implements GEOResource { - private final NamespacedKey key = new NamespacedKey(SlimefunPlugin.instance, "uranium"); + private final NamespacedKey key = new NamespacedKey(SlimefunPlugin.instance(), "uranium"); @Override public int getDefaultSupply(Environment envionment, Biome biome) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/DefaultCategories.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/DefaultCategories.java index c18221bc3..c90bc6e43 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/DefaultCategories.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/DefaultCategories.java @@ -32,35 +32,35 @@ import me.mrCookieSlime.Slimefun.Objects.Category; class DefaultCategories { // Standard Categories - protected final Category weapons = new Category(new NamespacedKey(SlimefunPlugin.instance, "weapons"), new CustomItem(SlimefunItems.BLADE_OF_VAMPIRES, "&7Weapons"), 1); - protected final Category tools = new Category(new NamespacedKey(SlimefunPlugin.instance, "tools"), new CustomItem(SlimefunItems.SMELTERS_PICKAXE, "&7Tools"), 1); - protected final Category usefulItems = new Category(new NamespacedKey(SlimefunPlugin.instance, "items"), new CustomItem(SlimefunItems.BACKPACK_MEDIUM, "&7Useful Items"), 1); - protected final Category basicMachines = new Category(new NamespacedKey(SlimefunPlugin.instance, "basic_machines"), new CustomItem(Material.CRAFTING_TABLE, "&7Basic Machines"), 1); - protected final Category food = new Category(new NamespacedKey(SlimefunPlugin.instance, "food"), new CustomItem(SlimefunItems.FORTUNE_COOKIE, "&7Food"), 2); - protected final Category armor = new Category(new NamespacedKey(SlimefunPlugin.instance, "armor"), new CustomItem(SlimefunItems.DAMASCUS_STEEL_CHESTPLATE, "&7Armor"), 2); + protected final Category weapons = new Category(new NamespacedKey(SlimefunPlugin.instance(), "weapons"), new CustomItem(SlimefunItems.BLADE_OF_VAMPIRES, "&7Weapons"), 1); + protected final Category tools = new Category(new NamespacedKey(SlimefunPlugin.instance(), "tools"), new CustomItem(SlimefunItems.SMELTERS_PICKAXE, "&7Tools"), 1); + protected final Category usefulItems = new Category(new NamespacedKey(SlimefunPlugin.instance(), "items"), new CustomItem(SlimefunItems.BACKPACK_MEDIUM, "&7Useful Items"), 1); + protected final Category basicMachines = new Category(new NamespacedKey(SlimefunPlugin.instance(), "basic_machines"), new CustomItem(SlimefunItems.ENHANCED_CRAFTING_TABLE, "&7Basic Machines"), 1); + protected final Category food = new Category(new NamespacedKey(SlimefunPlugin.instance(), "food"), new CustomItem(SlimefunItems.FORTUNE_COOKIE, "&7Food"), 2); + protected final Category armor = new Category(new NamespacedKey(SlimefunPlugin.instance(), "armor"), new CustomItem(SlimefunItems.DAMASCUS_STEEL_CHESTPLATE, "&7Armor"), 2); // Magical - protected final Category magicalResources = new Category(new NamespacedKey(SlimefunPlugin.instance, "magical_items"), new CustomItem(SlimefunItems.ENDER_RUNE, "&7Magical Items"), 2); - protected final Category magicalGadgets = new Category(new NamespacedKey(SlimefunPlugin.instance, "magical_gadgets"), new CustomItem(SlimefunItems.INFUSED_ELYTRA, "&7Magical Gadgets"), 3); - protected final Category magicalArmor = new Category(new NamespacedKey(SlimefunPlugin.instance, "magical_armor"), new CustomItem(SlimefunItems.ENDER_HELMET, "&7Magical Armor"), 2); + protected final Category magicalResources = new Category(new NamespacedKey(SlimefunPlugin.instance(), "magical_items"), new CustomItem(SlimefunItems.ENDER_RUNE, "&7Magical Items"), 2); + protected final Category magicalGadgets = new Category(new NamespacedKey(SlimefunPlugin.instance(), "magical_gadgets"), new CustomItem(SlimefunItems.INFUSED_ELYTRA, "&7Magical Gadgets"), 3); + protected final Category magicalArmor = new Category(new NamespacedKey(SlimefunPlugin.instance(), "magical_armor"), new CustomItem(SlimefunItems.ENDER_HELMET, "&7Magical Armor"), 2); // Resources and tech stuff - protected final Category misc = new Category(new NamespacedKey(SlimefunPlugin.instance, "misc"), new CustomItem(SlimefunItems.TIN_CAN, "&7Miscellaneous"), 2); - protected final Category technicalComponents = new Category(new NamespacedKey(SlimefunPlugin.instance, "tech_misc"), new CustomItem(SlimefunItems.HEATING_COIL, "&7Technical Components"), 2); - protected final Category technicalGadgets = new Category(new NamespacedKey(SlimefunPlugin.instance, "technical_gadgets"), new CustomItem(SlimefunItems.STEEL_JETPACK, "&7Technical Gadgets"), 3); - protected final Category resources = new Category(new NamespacedKey(SlimefunPlugin.instance, "resources"), new CustomItem(SlimefunItems.SYNTHETIC_SAPPHIRE, "&7Resources"), 1); + protected final Category misc = new Category(new NamespacedKey(SlimefunPlugin.instance(), "misc"), new CustomItem(SlimefunItems.TIN_CAN, "&7Miscellaneous"), 2); + protected final Category technicalComponents = new Category(new NamespacedKey(SlimefunPlugin.instance(), "tech_misc"), new CustomItem(SlimefunItems.HEATING_COIL, "&7Technical Components"), 2); + protected final Category technicalGadgets = new Category(new NamespacedKey(SlimefunPlugin.instance(), "technical_gadgets"), new CustomItem(SlimefunItems.STEEL_JETPACK, "&7Technical Gadgets"), 3); + protected final Category resources = new Category(new NamespacedKey(SlimefunPlugin.instance(), "resources"), new CustomItem(SlimefunItems.SYNTHETIC_SAPPHIRE, "&7Resources"), 1); // Locked Categories - protected final LockedCategory electricity = new LockedCategory(new NamespacedKey(SlimefunPlugin.instance, "electricity"), new CustomItem(SlimefunItems.NUCLEAR_REACTOR, "&bEnergy and Electricity"), 4, basicMachines.getKey()); - protected final LockedCategory androids = new LockedCategory(new NamespacedKey(SlimefunPlugin.instance, "androids"), new CustomItem(SlimefunItems.PROGRAMMABLE_ANDROID, "&cProgrammable Androids"), 4, basicMachines.getKey()); - protected final Category cargo = new LockedCategory(new NamespacedKey(SlimefunPlugin.instance, "cargo"), new CustomItem(SlimefunItems.CARGO_MANAGER, "&cCargo Management"), 4, basicMachines.getKey()); - protected final LockedCategory gps = new LockedCategory(new NamespacedKey(SlimefunPlugin.instance, "gps"), new CustomItem(SlimefunItems.GPS_TRANSMITTER, "&bGPS-based Machines"), 4, basicMachines.getKey()); + protected final LockedCategory electricity = new LockedCategory(new NamespacedKey(SlimefunPlugin.instance(), "electricity"), new CustomItem(SlimefunItems.NUCLEAR_REACTOR, "&bEnergy and Electricity"), 4, basicMachines.getKey()); + protected final LockedCategory androids = new LockedCategory(new NamespacedKey(SlimefunPlugin.instance(), "androids"), new CustomItem(SlimefunItems.PROGRAMMABLE_ANDROID, "&cProgrammable Androids"), 4, basicMachines.getKey()); + protected final Category cargo = new LockedCategory(new NamespacedKey(SlimefunPlugin.instance(), "cargo"), new CustomItem(SlimefunItems.CARGO_MANAGER, "&cCargo Management"), 4, basicMachines.getKey()); + protected final LockedCategory gps = new LockedCategory(new NamespacedKey(SlimefunPlugin.instance(), "gps"), new CustomItem(SlimefunItems.GPS_TRANSMITTER, "&bGPS-based Machines"), 4, basicMachines.getKey()); // Seasonal Categories - protected final SeasonalCategory christmas = new SeasonalCategory(new NamespacedKey(SlimefunPlugin.instance, "christmas"), Month.DECEMBER, 1, new CustomItem(SlimefunUtils.getCustomHead("215ba31cde2671b8f176de6a9ffd008035f0590d63ee240be6e8921cd2037a45"), ChatUtils.christmas("Christmas") + " &7(December only)")); - protected final SeasonalCategory valentinesDay = new SeasonalCategory(new NamespacedKey(SlimefunPlugin.instance, "valentines_day"), Month.FEBRUARY, 2, new CustomItem(SlimefunUtils.getCustomHead("55d89431d14bfef2060461b4a3565614dc51115c001fae2508e8684bc0ae6a80"), "&dValentine's Day" + " &7(14th February)")); - protected final SeasonalCategory easter = new SeasonalCategory(new NamespacedKey(SlimefunPlugin.instance, "easter"), Month.APRIL, 2, new CustomItem(HeadTexture.EASTER_EGG.getAsItemStack(), "&6Easter" + " &7(April)")); - protected final SeasonalCategory birthday = new SeasonalCategory(new NamespacedKey(SlimefunPlugin.instance, "birthday"), Month.OCTOBER, 1, new CustomItem(Material.FIREWORK_ROCKET, "&a&lTheBusyBiscuit's Birthday &7(26th October)")); - protected final SeasonalCategory halloween = new SeasonalCategory(new NamespacedKey(SlimefunPlugin.instance, "halloween"), Month.OCTOBER, 1, new CustomItem(Material.JACK_O_LANTERN, "&6&lHalloween &7(31st October)")); + protected final SeasonalCategory christmas = new SeasonalCategory(new NamespacedKey(SlimefunPlugin.instance(), "christmas"), Month.DECEMBER, 1, new CustomItem(SlimefunUtils.getCustomHead("215ba31cde2671b8f176de6a9ffd008035f0590d63ee240be6e8921cd2037a45"), ChatUtils.christmas("Christmas") + " &7(December only)")); + protected final SeasonalCategory valentinesDay = new SeasonalCategory(new NamespacedKey(SlimefunPlugin.instance(), "valentines_day"), Month.FEBRUARY, 2, new CustomItem(SlimefunUtils.getCustomHead("55d89431d14bfef2060461b4a3565614dc51115c001fae2508e8684bc0ae6a80"), "&dValentine's Day" + " &7(14th February)")); + protected final SeasonalCategory easter = new SeasonalCategory(new NamespacedKey(SlimefunPlugin.instance(), "easter"), Month.APRIL, 2, new CustomItem(HeadTexture.EASTER_EGG.getAsItemStack(), "&6Easter" + " &7(April)")); + protected final SeasonalCategory birthday = new SeasonalCategory(new NamespacedKey(SlimefunPlugin.instance(), "birthday"), Month.OCTOBER, 1, new CustomItem(Material.FIREWORK_ROCKET, "&a&lTheBusyBiscuit's Birthday &7(26th October)")); + protected final SeasonalCategory halloween = new SeasonalCategory(new NamespacedKey(SlimefunPlugin.instance(), "halloween"), Month.OCTOBER, 1, new CustomItem(Material.JACK_O_LANTERN, "&6&lHalloween &7(31st October)")); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/PostSetup.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/PostSetup.java index 1a541a456..e5cedb8c8 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/PostSetup.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/PostSetup.java @@ -217,9 +217,13 @@ public final class PostSetup { } for (SlimefunItem item : SlimefunPlugin.getRegistry().getEnabledSlimefunItems()) { - if (item instanceof AContainer && ((AContainer) item).getMachineIdentifier().equals("ELECTRIC_SMELTERY")) { - List recipes = ((AContainer) item).getMachineRecipes(); - Collections.sort(recipes, Comparator.comparingInt(recipe -> recipe == null ? 0 : -recipe.getInput().length)); + if (item instanceof AContainer) { + AContainer machine = (AContainer) item; + + if (machine.getMachineIdentifier().equals("ELECTRIC_SMELTERY")) { + List recipes = machine.getMachineRecipes(); + Collections.sort(recipes, Comparator.comparingInt(recipe -> recipe == null ? 0 : -recipe.getInput().length)); + } } } } @@ -254,8 +258,12 @@ public final class PostSetup { private static void registerMachineRecipe(String machine, int seconds, ItemStack[] input, ItemStack[] output) { for (SlimefunItem item : SlimefunPlugin.getRegistry().getEnabledSlimefunItems()) { - if (item instanceof AContainer && ((AContainer) item).getMachineIdentifier().equals(machine)) { - ((AContainer) item).registerRecipe(seconds, input, output); + if (item instanceof AContainer) { + AContainer container = (AContainer) item; + + if (container.getMachineIdentifier().equals(machine)) { + container.registerRecipe(seconds, input, output); + } } } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/ResearchSetup.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/ResearchSetup.java index b35b05e7e..45573046e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/ResearchSetup.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/ResearchSetup.java @@ -270,10 +270,12 @@ public final class ResearchSetup { register("climbing_pick", 259, "Block Raider", 20, SlimefunItems.CLIMBING_PICK); register("enchantment_rune", 260, "Ancient Enchanting", 24, SlimefunItems.MAGICAL_GLASS, SlimefunItems.ENCHANTMENT_RUNE); register("lead_clothing", 261, "Lead Clothing", 14, SlimefunItems.REINFORCED_CLOTH); + register("tape_measure", 262, "Tape Measure", 7, SlimefunItems.TAPE_MEASURE); + register("iron_golem_assembler", 263, "Automated Iron Golems", 30, SlimefunItems.IRON_GOLEM_ASSEMBLER); } private static void register(String key, int id, String name, int defaultCost, ItemStack... items) { - Research research = new Research(new NamespacedKey(SlimefunPlugin.instance, key), id, name, defaultCost); + Research research = new Research(new NamespacedKey(SlimefunPlugin.instance(), key), id, name, defaultCost); for (ItemStack item : items) { SlimefunItem sfItem = SlimefunItem.getByItem(item); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java index 944166587..7bdc3e54e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java @@ -10,6 +10,7 @@ import org.bukkit.inventory.meta.PotionMeta; import org.bukkit.potion.PotionData; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; +import org.bukkit.potion.PotionType; import io.github.thebusybiscuit.cscorelib2.item.CustomItem; import io.github.thebusybiscuit.cscorelib2.materials.MaterialCollections; @@ -44,6 +45,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.BrokenSpaw import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.Composter; import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.Crucible; import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.EnhancedFurnace; +import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.HardenedGlass; import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.HologramProjector; import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.InfusedHopper; import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.RainbowBlock; @@ -57,7 +59,6 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.cargo.CargoManage import io.github.thebusybiscuit.slimefun4.implementation.items.cargo.CargoOutputNode; import io.github.thebusybiscuit.slimefun4.implementation.items.cargo.ReactorAccessPort; import io.github.thebusybiscuit.slimefun4.implementation.items.cargo.TrashCan; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.BasicCircuitBoard; import io.github.thebusybiscuit.slimefun4.implementation.items.electric.Capacitor; import io.github.thebusybiscuit.slimefun4.implementation.items.electric.EnergyRegulator; import io.github.thebusybiscuit.slimefun4.implementation.items.electric.gadgets.JetBoots; @@ -96,6 +97,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.FoodFabricator; import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.Freezer; import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.HeatedPressureChamber; +import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.IronGolemAssembler; import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.Refinery; import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.TreeGrowthAccelerator; import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.WitherAssembler; @@ -140,6 +142,8 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.medical.Medicine; import io.github.thebusybiscuit.slimefun4.implementation.items.medical.Rag; import io.github.thebusybiscuit.slimefun4.implementation.items.medical.Splint; import io.github.thebusybiscuit.slimefun4.implementation.items.medical.Vitamins; +import io.github.thebusybiscuit.slimefun4.implementation.items.misc.BasicCircuitBoard; +import io.github.thebusybiscuit.slimefun4.implementation.items.misc.CoolantCell; import io.github.thebusybiscuit.slimefun4.implementation.items.misc.OrganicFertilizer; import io.github.thebusybiscuit.slimefun4.implementation.items.misc.OrganicFood; import io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.ArmorForge; @@ -173,6 +177,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.tools.PickaxeOfVe import io.github.thebusybiscuit.slimefun4.implementation.items.tools.PortableCrafter; import io.github.thebusybiscuit.slimefun4.implementation.items.tools.PortableDustbin; import io.github.thebusybiscuit.slimefun4.implementation.items.tools.SmeltersPickaxe; +import io.github.thebusybiscuit.slimefun4.implementation.items.tools.TapeMeasure; import io.github.thebusybiscuit.slimefun4.implementation.items.weapons.ExplosiveBow; import io.github.thebusybiscuit.slimefun4.implementation.items.weapons.IcyBow; import io.github.thebusybiscuit.slimefun4.implementation.items.weapons.SeismicAxe; @@ -183,7 +188,6 @@ 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; -import org.bukkit.potion.PotionType; /** * This static utility class holds the recipes of all items. @@ -1118,7 +1122,7 @@ public final class SlimefunItemSetup { new ItemStack[] {SlimefunItems.ENDER_LUMP_3, SlimefunItems.AIR_RUNE, SlimefunItems.ENDER_LUMP_3, SlimefunItems.EARTH_RUNE, SlimefunItems.NECROTIC_SKULL, SlimefunItems.FIRE_RUNE, SlimefunItems.ENDER_LUMP_3, SlimefunItems.WATER_RUNE, SlimefunItems.ENDER_LUMP_3}) .register(plugin); - new SoulboundBackpack(36, categories.usefulItems, SlimefunItems.BOUND_BACKPACK, RecipeType.MAGIC_WORKBENCH, + new SoulboundBackpack(36, categories.magicalGadgets, SlimefunItems.BOUND_BACKPACK, RecipeType.MAGIC_WORKBENCH, new ItemStack[] {SlimefunItems.ENDER_LUMP_2, null, SlimefunItems.ENDER_LUMP_2, SlimefunItems.ESSENCE_OF_AFTERLIFE, SlimefunItems.WOVEN_BACKPACK, SlimefunItems.ESSENCE_OF_AFTERLIFE, SlimefunItems.ENDER_LUMP_2, null, SlimefunItems.ENDER_LUMP_2}) .register(plugin); @@ -1453,7 +1457,7 @@ public final class SlimefunItemSetup { new ItemStack[] {new CustomItem(SlimefunItems.REINFORCED_ALLOY_INGOT, 8), null, null, null, null, null, null, null, null}) .register(plugin); - new SlimefunItem(categories.technicalComponents, SlimefunItems.HARDENED_GLASS, RecipeType.ENHANCED_CRAFTING_TABLE, + new HardenedGlass(categories.technicalComponents, SlimefunItems.HARDENED_GLASS, RecipeType.ENHANCED_CRAFTING_TABLE, new ItemStack[] {new ItemStack(Material.GLASS), new ItemStack(Material.GLASS), new ItemStack(Material.GLASS), new ItemStack(Material.GLASS), SlimefunItems.REINFORCED_PLATE, new ItemStack(Material.GLASS), new ItemStack(Material.GLASS), new ItemStack(Material.GLASS), new ItemStack(Material.GLASS)}, new CustomItem(SlimefunItems.HARDENED_GLASS, 16)) .register(plugin); @@ -1509,50 +1513,21 @@ public final class SlimefunItemSetup { new ItemStack[] {SlimefunItems.CARBONADO, SlimefunItems.REDSTONE_ALLOY, SlimefunItems.CARBONADO, new ItemStack(Material.REDSTONE), SlimefunItems.LARGE_CAPACITOR, new ItemStack(Material.REDSTONE), SlimefunItems.CARBONADO, SlimefunItems.REDSTONE_ALLOY, SlimefunItems.CARBONADO}) .register(plugin); - new SolarGenerator(categories.electricity, SlimefunItems.SOLAR_GENERATOR, RecipeType.ENHANCED_CRAFTING_TABLE, - new ItemStack[] {SlimefunItems.SOLAR_PANEL, SlimefunItems.SOLAR_PANEL, SlimefunItems.SOLAR_PANEL, SlimefunItems.ALUMINUM_INGOT, SlimefunItems.ELECTRIC_MOTOR, SlimefunItems.ALUMINUM_INGOT, null, SlimefunItems.ALUMINUM_INGOT, null}) { + new SolarGenerator(categories.electricity, 2, 0, SlimefunItems.SOLAR_GENERATOR, RecipeType.ENHANCED_CRAFTING_TABLE, + new ItemStack[] {SlimefunItems.SOLAR_PANEL, SlimefunItems.SOLAR_PANEL, SlimefunItems.SOLAR_PANEL, SlimefunItems.ALUMINUM_INGOT, SlimefunItems.ELECTRIC_MOTOR, SlimefunItems.ALUMINUM_INGOT, null, SlimefunItems.ALUMINUM_INGOT, null}) + .register(plugin); - @Override - public double getDayEnergy() { - return 2; - } - - }.register(plugin); + new SolarGenerator(categories.electricity, 8, 0, SlimefunItems.SOLAR_GENERATOR_2, RecipeType.ENHANCED_CRAFTING_TABLE, + new ItemStack[] {SlimefunItems.SOLAR_GENERATOR, SlimefunItems.ALUMINUM_INGOT, SlimefunItems.SOLAR_GENERATOR, SlimefunItems.ALUMINUM_INGOT, new ItemStack(Material.REDSTONE), SlimefunItems.ALUMINUM_INGOT, SlimefunItems.SOLAR_GENERATOR, SlimefunItems.ALUMINUM_INGOT, SlimefunItems.SOLAR_GENERATOR}) + .register(plugin); - new SolarGenerator(categories.electricity, SlimefunItems.SOLAR_GENERATOR_2, RecipeType.ENHANCED_CRAFTING_TABLE, - new ItemStack[] {SlimefunItems.SOLAR_GENERATOR, SlimefunItems.ALUMINUM_INGOT, SlimefunItems.SOLAR_GENERATOR, SlimefunItems.ALUMINUM_INGOT, new ItemStack(Material.REDSTONE), SlimefunItems.ALUMINUM_INGOT, SlimefunItems.SOLAR_GENERATOR, SlimefunItems.ALUMINUM_INGOT, SlimefunItems.SOLAR_GENERATOR}) { + new SolarGenerator(categories.electricity, 32, 0, SlimefunItems.SOLAR_GENERATOR_3, RecipeType.ENHANCED_CRAFTING_TABLE, + new ItemStack[] {SlimefunItems.SOLAR_GENERATOR_2, SlimefunItems.ALUMINUM_INGOT, SlimefunItems.SOLAR_GENERATOR_2, SlimefunItems.ALUMINUM_INGOT, SlimefunItems.CARBONADO, SlimefunItems.ALUMINUM_INGOT, SlimefunItems.SOLAR_GENERATOR_2, SlimefunItems.ALUMINUM_INGOT, SlimefunItems.SOLAR_GENERATOR_2}) + .register(plugin); - @Override - public double getDayEnergy() { - return 8; - } - - }.register(plugin); - - new SolarGenerator(categories.electricity, SlimefunItems.SOLAR_GENERATOR_3, RecipeType.ENHANCED_CRAFTING_TABLE, - new ItemStack[] {SlimefunItems.SOLAR_GENERATOR_2, SlimefunItems.ALUMINUM_INGOT, SlimefunItems.SOLAR_GENERATOR_2, SlimefunItems.ALUMINUM_INGOT, SlimefunItems.CARBONADO, SlimefunItems.ALUMINUM_INGOT, SlimefunItems.SOLAR_GENERATOR_2, SlimefunItems.ALUMINUM_INGOT, SlimefunItems.SOLAR_GENERATOR_2}) { - - @Override - public double getDayEnergy() { - return 32; - } - - }.register(plugin); - - new SolarGenerator(categories.electricity, SlimefunItems.SOLAR_GENERATOR_4, RecipeType.ENHANCED_CRAFTING_TABLE, - new ItemStack[] {SlimefunItems.SOLAR_GENERATOR_3, SlimefunItems.BLISTERING_INGOT_3, SlimefunItems.SOLAR_GENERATOR_3, SlimefunItems.BLISTERING_INGOT_3, SlimefunItems.ELECTRO_MAGNET, SlimefunItems.BLISTERING_INGOT_3, SlimefunItems.SOLAR_GENERATOR_3, SlimefunItems.BLISTERING_INGOT_3, SlimefunItems.SOLAR_GENERATOR_3}) { - - @Override - public double getDayEnergy() { - return 128; - } - - @Override - public double getNightEnergy() { - return 64; - } - - }.register(plugin); + new SolarGenerator(categories.electricity, 128, 64, SlimefunItems.SOLAR_GENERATOR_4, RecipeType.ENHANCED_CRAFTING_TABLE, + new ItemStack[] {SlimefunItems.SOLAR_GENERATOR_3, SlimefunItems.BLISTERING_INGOT_3, SlimefunItems.SOLAR_GENERATOR_3, SlimefunItems.BLISTERING_INGOT_3, SlimefunItems.ELECTRO_MAGNET, SlimefunItems.BLISTERING_INGOT_3, SlimefunItems.SOLAR_GENERATOR_3, SlimefunItems.BLISTERING_INGOT_3, SlimefunItems.SOLAR_GENERATOR_3}) + .register(plugin); new ChargingBench(categories.electricity, SlimefunItems.CHARGING_BENCH, RecipeType.ENHANCED_CRAFTING_TABLE, new ItemStack[] {null, SlimefunItems.ELECTRO_MAGNET, null, SlimefunItems.BATTERY, new ItemStack(Material.CRAFTING_TABLE), SlimefunItems.BATTERY, null, SlimefunItems.SMALL_CAPACITOR, null}) @@ -3047,12 +3022,13 @@ public final class SlimefunItemSetup { }.register(plugin); - new SlimefunItem(categories.technicalComponents, SlimefunItems.REACTOR_COOLANT_CELL, RecipeType.FREEZER, + new CoolantCell(categories.technicalComponents, SlimefunItems.REACTOR_COOLANT_CELL, RecipeType.FREEZER, new ItemStack[] {new ItemStack(Material.BLUE_ICE), null, null, null, null, null, null, null, null}) .register(plugin); - new SlimefunItem(categories.technicalComponents, SlimefunItems.NETHER_ICE_COOLANT_CELL, RecipeType.HEATED_PRESSURE_CHAMBER, - new ItemStack[] {SlimefunItems.ENRICHED_NETHER_ICE, null, null, null, null, null, null, null, null}) + new CoolantCell(categories.technicalComponents, SlimefunItems.NETHER_ICE_COOLANT_CELL, RecipeType.HEATED_PRESSURE_CHAMBER, + new ItemStack[] {SlimefunItems.ENRICHED_NETHER_ICE, null, null, null, null, null, null, null, null}, + new SlimefunItemStack(SlimefunItems.NETHER_ICE_COOLANT_CELL, 4)) .register(plugin); new RadioactiveItem(categories.resources, Radioactivity.HIGH, SlimefunItems.NEPTUNIUM, RecipeType.NUCLEAR_REACTOR, @@ -3253,9 +3229,19 @@ public final class SlimefunItemSetup { }.register(plugin); + new IronGolemAssembler(categories.electricity, SlimefunItems.IRON_GOLEM_ASSEMBLER, RecipeType.ENHANCED_CRAFTING_TABLE, + new ItemStack[] {SlimefunItems.BLISTERING_INGOT_3, SlimefunItems.ADVANCED_CIRCUIT_BOARD, SlimefunItems.BLISTERING_INGOT_3, new ItemStack(Material.IRON_BLOCK), SlimefunItems.ANDROID_MEMORY_CORE, new ItemStack(Material.IRON_BLOCK), SlimefunItems.ELECTRIC_MOTOR, SlimefunItems.REINFORCED_ALLOY_INGOT, SlimefunItems.CARBONADO_EDGED_CAPACITOR}) + .register(plugin); + new WitherAssembler(categories.electricity, SlimefunItems.WITHER_ASSEMBLER, RecipeType.ENHANCED_CRAFTING_TABLE, new ItemStack[] {SlimefunItems.BLISTERING_INGOT_3, new ItemStack(Material.NETHER_STAR), SlimefunItems.BLISTERING_INGOT_3, SlimefunItems.WITHER_PROOF_OBSIDIAN, SlimefunItems.ANDROID_MEMORY_CORE, SlimefunItems.WITHER_PROOF_OBSIDIAN, SlimefunItems.ELECTRIC_MOTOR, SlimefunItems.REINFORCED_ALLOY_INGOT, SlimefunItems.CARBONADO_EDGED_CAPACITOR}) .register(plugin); + + if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_14)) { + new TapeMeasure(categories.usefulItems, SlimefunItems.TAPE_MEASURE, RecipeType.ENHANCED_CRAFTING_TABLE, + new ItemStack[] {SlimefunItems.SILICON, new ItemStack(Material.YELLOW_DYE), SlimefunItems.SILICON, new ItemStack(Material.YELLOW_DYE), new ItemStack(Material.STRING), new ItemStack(Material.YELLOW_DYE), SlimefunItems.GILDED_IRON, new ItemStack(Material.YELLOW_DYE), SlimefunItems.SILICON}) + .register(plugin); + } } private static void registerArmorSet(Category category, ItemStack baseComponent, ItemStack[] items, String idSyntax, boolean vanilla, SlimefunAddon addon) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/AncientAltarTask.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/AncientAltarTask.java index 29cc8a153..837a34a5f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/AncientAltarTask.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/AncientAltarTask.java @@ -129,7 +129,7 @@ public class AncientAltarTask implements Runnable { itemLock.remove(item); item.remove(); - item.removeMetadata("no_pickup", SlimefunPlugin.instance); + item.removeMetadata("no_pickup", SlimefunPlugin.instance()); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/ArmorTask.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/ArmorTask.java index 51175dbd8..e0412b9c2 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/ArmorTask.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/ArmorTask.java @@ -77,7 +77,8 @@ public class ArmorTask implements Runnable { if (armorpiece.hasDiverged(item)) { SlimefunItem sfItem = SlimefunItem.getByItem(item); - if (!(sfItem instanceof SlimefunArmorPiece) || !Slimefun.hasUnlocked(p, sfItem, true)) { + if (!(sfItem instanceof SlimefunArmorPiece)) { + // If it isn't actually Armor, then we won't care about it. sfItem = null; } @@ -86,9 +87,13 @@ public class ArmorTask implements Runnable { if (item != null && armorpiece.getItem().isPresent()) { Slimefun.runSync(() -> { - for (PotionEffect effect : armorpiece.getItem().get().getPotionEffects()) { - p.removePotionEffect(effect.getType()); - p.addPotionEffect(effect); + SlimefunArmorPiece slimefunArmor = armorpiece.getItem().get(); + + if (Slimefun.hasUnlocked(p, slimefunArmor, true)) { + for (PotionEffect effect : slimefunArmor.getPotionEffects()) { + p.removePotionEffect(effect.getType()); + p.addPotionEffect(effect); + } } }); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/PlayerTask.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/PlayerTask.java index 0a77c0f14..7f9f49fcc 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/PlayerTask.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/PlayerTask.java @@ -19,11 +19,11 @@ abstract class PlayerTask implements Runnable { } public void schedule(long delay) { - setID(Bukkit.getScheduler().scheduleSyncDelayedTask(SlimefunPlugin.instance, this, delay)); + setID(Bukkit.getScheduler().scheduleSyncDelayedTask(SlimefunPlugin.instance(), this, delay)); } public void scheduleRepeating(long delay, long interval) { - setID(Bukkit.getScheduler().scheduleSyncRepeatingTask(SlimefunPlugin.instance, this, delay, interval)); + setID(Bukkit.getScheduler().scheduleSyncRepeatingTask(SlimefunPlugin.instance(), this, delay, interval)); } @Override diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/TickerTask.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/TickerTask.java index e13d9c236..d80bc6e1c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/TickerTask.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/TickerTask.java @@ -32,6 +32,7 @@ public class TickerTask implements Runnable { private final Map deletionQueue = new ConcurrentHashMap<>(); private final Map bugs = new ConcurrentHashMap<>(); + private int tickRate; private boolean halted = false; private boolean running = false; @@ -100,16 +101,20 @@ public class TickerTask implements Runnable { if (item != null && item.getBlockTicker() != null) { try { - long timestamp = SlimefunPlugin.getProfiler().newEntry(); - Block b = l.getBlock(); - item.getBlockTicker().update(); - if (item.getBlockTicker().isSynchronized()) { - // We are ignoring the timestamp from above because synchronized actions - // are always ran with a 50ms delay (1 game tick) - Slimefun.runSync(() -> tickBlock(l, b, item, data, System.nanoTime())); + SlimefunPlugin.getProfiler().scheduleEntries(1); + item.getBlockTicker().update(); + // We are inserting a new timestamp because synchronized + // actions are always ran with a 50ms delay (1 game tick) + Slimefun.runSync(() -> { + Block b = l.getBlock(); + tickBlock(l, b, item, data, System.nanoTime()); + }); } else { + long timestamp = SlimefunPlugin.getProfiler().newEntry(); + item.getBlockTicker().update(); + Block b = l.getBlock(); tickBlock(l, b, item, data, timestamp); } @@ -150,7 +155,7 @@ public class TickerTask implements Runnable { bugs.remove(position); BlockStorage._integrated_removeBlockInfo(l, true); - Bukkit.getScheduler().scheduleSyncDelayedTask(SlimefunPlugin.instance, () -> l.getBlock().setType(Material.AIR)); + Bukkit.getScheduler().scheduleSyncDelayedTask(SlimefunPlugin.instance(), () -> l.getBlock().setType(Material.AIR)); } else { bugs.put(position, errors); @@ -179,6 +184,8 @@ public class TickerTask implements Runnable { } public void start(SlimefunPlugin plugin) { + this.tickRate = SlimefunPlugin.getCfg().getInt("URID.custom-ticker-delay"); + plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, () -> { try { run(); @@ -187,7 +194,11 @@ public class TickerTask implements Runnable { plugin.getLogger().log(Level.SEVERE, x, () -> "An Exception was caught while ticking the Block Tickers Task for Slimefun v" + SlimefunPlugin.getVersion()); abortTick(); } - }, 100L, SlimefunPlugin.getCfg().getInt("URID.custom-ticker-delay")); + }, 100L, tickRate); + } + + public int getTickRate() { + return tickRate; } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ChatUtils.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ChatUtils.java index f1c5725bf..143b7b3f5 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ChatUtils.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ChatUtils.java @@ -48,7 +48,7 @@ public final class ChatUtils { } public static void awaitInput(Player p, Consumer callback) { - ChatInput.waitForPlayer(SlimefunPlugin.instance, p, callback); + ChatInput.waitForPlayer(SlimefunPlugin.instance(), p, callback); } /** diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/NumberUtils.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/NumberUtils.java index dbf6a0c74..6bbb7837e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/NumberUtils.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/NumberUtils.java @@ -74,7 +74,7 @@ public final class NumberUtils { } String number = roundDecimalNumber(nanoseconds / 1000000.0); - String[] parts = PatternUtils.NUMBER_SEPERATOR.split(number); + String[] parts = PatternUtils.NUMBER_SEPARATOR.split(number); if (parts.length == 1) { return parts[0] + "ms"; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/PatternUtils.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/PatternUtils.java index cf61255d9..5922adeee 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/PatternUtils.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/PatternUtils.java @@ -26,6 +26,5 @@ public final class PatternUtils { public static final Pattern ALPHANUMERIC = Pattern.compile("[A-Fa-f0-9]+"); public static final Pattern NUMERIC = Pattern.compile("[0-9]+"); - public static final Pattern NUMBER_SEPERATOR = Pattern.compile(",|\\."); - + public static final Pattern NUMBER_SEPARATOR = Pattern.compile("[,.]"); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java index 99e233fab..e73acbb3c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java @@ -45,7 +45,7 @@ public final class SlimefunUtils { private static final String EMERALDENCHANTS_LORE = ChatColor.YELLOW.toString() + ChatColor.YELLOW.toString() + ChatColor.GRAY.toString(); private static final String NO_PICKUP_METADATA = "no_pickup"; - private static final NamespacedKey SOULBOUND_KEY = new NamespacedKey(SlimefunPlugin.instance, "soulbound"); + private static final NamespacedKey SOULBOUND_KEY = new NamespacedKey(SlimefunPlugin.instance(), "soulbound"); private static final String SOULBOUND_LORE = ChatColor.GRAY + "Soulbound"; private SlimefunUtils() {} @@ -72,7 +72,7 @@ public final class SlimefunUtils { * The context in which this {@link Item} was flagged */ public static void markAsNoPickup(Item item, String context) { - item.setMetadata(NO_PICKUP_METADATA, new FixedMetadataValue(SlimefunPlugin.instance, context)); + item.setMetadata(NO_PICKUP_METADATA, new FixedMetadataValue(SlimefunPlugin.instance(), context)); } /** @@ -188,7 +188,7 @@ public final class SlimefunUtils { * @return An {@link ItemStack} with this Head texture */ public static ItemStack getCustomHead(String texture) { - if (SlimefunPlugin.instance == null) { + if (SlimefunPlugin.instance() == null) { throw new PrematureCodeException("You cannot instantiate a custom head before Slimefun was loaded."); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/holograms/SimpleHologram.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/holograms/SimpleHologram.java index 20e5e9b29..796f50fc3 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/holograms/SimpleHologram.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/holograms/SimpleHologram.java @@ -40,13 +40,17 @@ public final class SimpleHologram { Location l = new Location(b.getWorld(), b.getX() + 0.5, b.getY() + 0.7F, b.getZ() + 0.5); for (Entity n : l.getChunk().getEntities()) { - if (n instanceof ArmorStand && n.getCustomName() != null && l.distanceSquared(n.getLocation()) < 0.4D) { + if (n instanceof ArmorStand && l.distanceSquared(n.getLocation()) < 0.4D && n.getCustomName() != null) { return (ArmorStand) n; } } - if (!createIfNoneExists) return null; - else return create(l); + if (!createIfNoneExists) { + return null; + } + else { + return create(l); + } } public static ArmorStand create(Location l) { diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Lists/RecipeType.java b/src/main/java/me/mrCookieSlime/Slimefun/Lists/RecipeType.java index 646bb5c01..fab7fceed 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Lists/RecipeType.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/Lists/RecipeType.java @@ -28,34 +28,34 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; public class RecipeType implements Keyed { - public static final RecipeType MULTIBLOCK = new RecipeType(new NamespacedKey(SlimefunPlugin.instance, "multiblock"), new CustomItem(Material.BRICKS, "&bMultiBlock", "", "&a&oBuild it in the World")); - public static final RecipeType ARMOR_FORGE = new RecipeType(new NamespacedKey(SlimefunPlugin.instance, "armor_forge"), SlimefunItems.ARMOR_FORGE, "", "&a&oCraft it in an Armor Forge"); - public static final RecipeType GRIND_STONE = new RecipeType(new NamespacedKey(SlimefunPlugin.instance, "grind_stone"), SlimefunItems.GRIND_STONE, "", "&a&oGrind it using the Grind Stone"); - public static final RecipeType SMELTERY = new RecipeType(new NamespacedKey(SlimefunPlugin.instance, "smeltery"), SlimefunItems.SMELTERY, "", "&a&oSmelt it using a Smeltery"); - public static final RecipeType ORE_CRUSHER = new RecipeType(new NamespacedKey(SlimefunPlugin.instance, "ore_crusher"), SlimefunItems.ORE_CRUSHER, "", "&a&oCrush it using the Ore Crusher"); - public static final RecipeType GOLD_PAN = new RecipeType(new NamespacedKey(SlimefunPlugin.instance, "gold_pan"), SlimefunItems.GOLD_PAN, "", "&a&oUse a Gold Pan on Gravel to obtain this Item"); - public static final RecipeType COMPRESSOR = new RecipeType(new NamespacedKey(SlimefunPlugin.instance, "compressor"), SlimefunItems.COMPRESSOR, "", "&a&oCompress it using the Compressor"); - public static final RecipeType PRESSURE_CHAMBER = new RecipeType(new NamespacedKey(SlimefunPlugin.instance, "pressure_chamber"), SlimefunItems.PRESSURE_CHAMBER, "", "&a&oCompress it using the Pressure Chamber"); - public static final RecipeType MAGIC_WORKBENCH = new RecipeType(new NamespacedKey(SlimefunPlugin.instance, "magic_workbench"), SlimefunItems.MAGIC_WORKBENCH, "", "&a&oCraft it in a Magic Workbench"); - public static final RecipeType ORE_WASHER = new RecipeType(new NamespacedKey(SlimefunPlugin.instance, "ore_washer"), SlimefunItems.ORE_WASHER, "", "&a&oWash it in an Ore Washer"); - public static final RecipeType ENHANCED_CRAFTING_TABLE = new RecipeType(new NamespacedKey(SlimefunPlugin.instance, "enhanced_crafting_table"), SlimefunItems.ENHANCED_CRAFTING_TABLE, "", "&a&oA regular Crafting Table cannot", "&a&ohold this massive Amount of Power..."); - public static final RecipeType JUICER = new RecipeType(new NamespacedKey(SlimefunPlugin.instance, "juicer"), SlimefunItems.JUICER, "", "&a&oUsed for Juice Creation"); + public static final RecipeType MULTIBLOCK = new RecipeType(new NamespacedKey(SlimefunPlugin.instance(), "multiblock"), new CustomItem(Material.BRICKS, "&bMultiBlock", "", "&a&oBuild it in the World")); + public static final RecipeType ARMOR_FORGE = new RecipeType(new NamespacedKey(SlimefunPlugin.instance(), "armor_forge"), SlimefunItems.ARMOR_FORGE, "", "&a&oCraft it in an Armor Forge"); + public static final RecipeType GRIND_STONE = new RecipeType(new NamespacedKey(SlimefunPlugin.instance(), "grind_stone"), SlimefunItems.GRIND_STONE, "", "&a&oGrind it using the Grind Stone"); + public static final RecipeType SMELTERY = new RecipeType(new NamespacedKey(SlimefunPlugin.instance(), "smeltery"), SlimefunItems.SMELTERY, "", "&a&oSmelt it using a Smeltery"); + public static final RecipeType ORE_CRUSHER = new RecipeType(new NamespacedKey(SlimefunPlugin.instance(), "ore_crusher"), SlimefunItems.ORE_CRUSHER, "", "&a&oCrush it using the Ore Crusher"); + public static final RecipeType GOLD_PAN = new RecipeType(new NamespacedKey(SlimefunPlugin.instance(), "gold_pan"), SlimefunItems.GOLD_PAN, "", "&a&oUse a Gold Pan on Gravel to obtain this Item"); + public static final RecipeType COMPRESSOR = new RecipeType(new NamespacedKey(SlimefunPlugin.instance(), "compressor"), SlimefunItems.COMPRESSOR, "", "&a&oCompress it using the Compressor"); + public static final RecipeType PRESSURE_CHAMBER = new RecipeType(new NamespacedKey(SlimefunPlugin.instance(), "pressure_chamber"), SlimefunItems.PRESSURE_CHAMBER, "", "&a&oCompress it using the Pressure Chamber"); + public static final RecipeType MAGIC_WORKBENCH = new RecipeType(new NamespacedKey(SlimefunPlugin.instance(), "magic_workbench"), SlimefunItems.MAGIC_WORKBENCH, "", "&a&oCraft it in a Magic Workbench"); + public static final RecipeType ORE_WASHER = new RecipeType(new NamespacedKey(SlimefunPlugin.instance(), "ore_washer"), SlimefunItems.ORE_WASHER, "", "&a&oWash it in an Ore Washer"); + public static final RecipeType ENHANCED_CRAFTING_TABLE = new RecipeType(new NamespacedKey(SlimefunPlugin.instance(), "enhanced_crafting_table"), SlimefunItems.ENHANCED_CRAFTING_TABLE, "", "&a&oA regular Crafting Table cannot", "&a&ohold this massive Amount of Power..."); + public static final RecipeType JUICER = new RecipeType(new NamespacedKey(SlimefunPlugin.instance(), "juicer"), SlimefunItems.JUICER, "", "&a&oUsed for Juice Creation"); - public static final RecipeType ANCIENT_ALTAR = new RecipeType(new NamespacedKey(SlimefunPlugin.instance, "ancient_altar"), SlimefunItems.ANCIENT_ALTAR, (recipe, output) -> { + public static final RecipeType ANCIENT_ALTAR = new RecipeType(new NamespacedKey(SlimefunPlugin.instance(), "ancient_altar"), SlimefunItems.ANCIENT_ALTAR, (recipe, output) -> { AltarRecipe altarRecipe = new AltarRecipe(Arrays.asList(recipe), output); SlimefunPlugin.getAncientAltarListener().getRecipes().add(altarRecipe); }); - public static final RecipeType MOB_DROP = new RecipeType(new NamespacedKey(SlimefunPlugin.instance, "mob_drop"), new CustomItem(Material.IRON_SWORD, "&bMob Drop"), RecipeType::registerMobDrop, "", "&rKill the specified Mob to obtain this Item"); + public static final RecipeType MOB_DROP = new RecipeType(new NamespacedKey(SlimefunPlugin.instance(), "mob_drop"), new CustomItem(Material.IRON_SWORD, "&bMob Drop"), RecipeType::registerMobDrop, "", "&rKill the specified Mob to obtain this Item"); - public static final RecipeType HEATED_PRESSURE_CHAMBER = new RecipeType(new NamespacedKey(SlimefunPlugin.instance, "heated_pressure_chamber"), SlimefunItems.HEATED_PRESSURE_CHAMBER); - public static final RecipeType FOOD_FABRICATOR = new RecipeType(new NamespacedKey(SlimefunPlugin.instance, "food_fabricator"), SlimefunItems.FOOD_FABRICATOR); - public static final RecipeType FOOD_COMPOSTER = new RecipeType(new NamespacedKey(SlimefunPlugin.instance, "food_composter"), SlimefunItems.FOOD_COMPOSTER); - public static final RecipeType FREEZER = new RecipeType(new NamespacedKey(SlimefunPlugin.instance, "freezer"), SlimefunItems.FREEZER); - public static final RecipeType REFINERY = new RecipeType(new NamespacedKey(SlimefunPlugin.instance, "refinery"), SlimefunItems.REFINERY); + public static final RecipeType HEATED_PRESSURE_CHAMBER = new RecipeType(new NamespacedKey(SlimefunPlugin.instance(), "heated_pressure_chamber"), SlimefunItems.HEATED_PRESSURE_CHAMBER); + public static final RecipeType FOOD_FABRICATOR = new RecipeType(new NamespacedKey(SlimefunPlugin.instance(), "food_fabricator"), SlimefunItems.FOOD_FABRICATOR); + public static final RecipeType FOOD_COMPOSTER = new RecipeType(new NamespacedKey(SlimefunPlugin.instance(), "food_composter"), SlimefunItems.FOOD_COMPOSTER); + public static final RecipeType FREEZER = new RecipeType(new NamespacedKey(SlimefunPlugin.instance(), "freezer"), SlimefunItems.FREEZER); + public static final RecipeType REFINERY = new RecipeType(new NamespacedKey(SlimefunPlugin.instance(), "refinery"), SlimefunItems.REFINERY); - public static final RecipeType GEO_MINER = new RecipeType(new NamespacedKey(SlimefunPlugin.instance, "geo_miner"), SlimefunItems.GEO_MINER); - public static final RecipeType NUCLEAR_REACTOR = new RecipeType(new NamespacedKey(SlimefunPlugin.instance, "nuclear_reactor"), SlimefunItems.NUCLEAR_REACTOR); + public static final RecipeType GEO_MINER = new RecipeType(new NamespacedKey(SlimefunPlugin.instance(), "geo_miner"), SlimefunItems.GEO_MINER); + public static final RecipeType NUCLEAR_REACTOR = new RecipeType(new NamespacedKey(SlimefunPlugin.instance(), "nuclear_reactor"), SlimefunItems.NUCLEAR_REACTOR); public static final RecipeType NULL = new RecipeType(); @@ -67,7 +67,7 @@ public class RecipeType implements Keyed { private RecipeType() { this.item = null; this.machine = ""; - this.key = new NamespacedKey(SlimefunPlugin.instance, "null"); + this.key = new NamespacedKey(SlimefunPlugin.instance(), "null"); } public RecipeType(ItemStack item, String machine) { @@ -75,10 +75,10 @@ public class RecipeType implements Keyed { this.machine = machine; if (machine.length() > 0) { - this.key = new NamespacedKey(SlimefunPlugin.instance, machine.toLowerCase(Locale.ROOT)); + this.key = new NamespacedKey(SlimefunPlugin.instance(), machine.toLowerCase(Locale.ROOT)); } else { - this.key = new NamespacedKey(SlimefunPlugin.instance, "unknown"); + this.key = new NamespacedKey(SlimefunPlugin.instance(), "unknown"); } } @@ -149,22 +149,27 @@ public class RecipeType implements Keyed { SlimefunPlugin.getRegistry().getMobDrops().put(entity, dropping); } - @Deprecated public static List getRecipeInputs(MultiBlockMachine machine) { - if (machine == null) return new ArrayList<>(); + if (machine == null) { + return new ArrayList<>(); + } + List recipes = machine.getRecipes(); List convertible = new ArrayList<>(); for (int i = 0; i < recipes.size(); i++) { - if (i % 2 == 0) convertible.add(recipes.get(i)[0]); + if (i % 2 == 0) { + convertible.add(recipes.get(i)[0]); + } } return convertible; } - @Deprecated public static List getRecipeInputList(MultiBlockMachine machine) { - if (machine == null) return new ArrayList<>(); + if (machine == null) { + return new ArrayList<>(); + } List recipes = machine.getRecipes(); List convertible = new ArrayList<>(); @@ -190,13 +195,11 @@ public class RecipeType implements Keyed { return convertible; } - @Deprecated public static ItemStack getRecipeOutput(MultiBlockMachine machine, ItemStack input) { List recipes = machine.getRecipes(); return recipes.get(((getRecipeInputs(machine).indexOf(input) * 2) + 1))[0].clone(); } - @Deprecated public static ItemStack getRecipeOutputList(MultiBlockMachine machine, ItemStack[] input) { List recipes = machine.getRecipes(); return recipes.get((recipes.indexOf(input) + 1))[0]; diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/Category.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/Category.java index 2d10efc09..c6db50881 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/Category.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/Objects/Category.java @@ -75,6 +75,7 @@ public class Category implements Keyed { ItemMeta meta = item.getItemMeta(); meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES); meta.addItemFlags(ItemFlag.HIDE_ENCHANTS); + meta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS); this.item.setItemMeta(meta); this.tier = tier; } @@ -132,7 +133,10 @@ public class Category implements Keyed { public ItemStack getItem(Player p) { return new CustomItem(item, meta -> { String name = SlimefunPlugin.getLocalization().getCategoryName(p, getKey()); - if (name == null) name = item.getItemMeta().getDisplayName(); + + if (name == null) { + name = item.getItemMeta().getDisplayName(); + } if (this instanceof SeasonalCategory) { meta.setDisplayName(ChatColor.GOLD + name); @@ -199,6 +203,7 @@ public class Category implements Keyed { * * @param p * The {@link Player} to check for + * * @return Whether this {@link Category} will be hidden to the given {@link Player} */ public boolean isHidden(Player p) { @@ -211,4 +216,14 @@ public class Category implements Keyed { return true; } + /** + * This method returns whether this {@link Category} has been registered yet. + * More specifically: Whether {@link #register()} was called or not. + * + * @return Whether this {@link Category} has been registered + */ + public boolean isRegistered() { + return SlimefunPlugin.getRegistry().getCategories().contains(this); + } + } diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/Research.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/Research.java deleted file mode 100644 index eeb6ab35d..000000000 --- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/Research.java +++ /dev/null @@ -1,15 +0,0 @@ -package me.mrCookieSlime.Slimefun.Objects; - -import org.bukkit.NamespacedKey; - -/** - * @deprecated Moved to io.github.thebusybiscuit.slimefun4.core.researching.Research - * - */ -@Deprecated -public class Research extends io.github.thebusybiscuit.slimefun4.core.researching.Research { - - public Research(NamespacedKey key, int id, String name, int cost) { - super(key, id, name, cost); - } -} \ No newline at end of file diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/ChargableItem.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/ChargableItem.java deleted file mode 100644 index 2d1bddbbb..000000000 --- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/ChargableItem.java +++ /dev/null @@ -1,31 +0,0 @@ -package me.mrCookieSlime.Slimefun.Objects.SlimefunItem; - -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.api.SlimefunItemStack; -import me.mrCookieSlime.Slimefun.api.energy.ItemEnergy; - -/** - * This class is deprecated. - * - * @deprecated Please implement the {@link Rechargeable} interface from now on. - * - * @author TheBusyBiscuit - * - */ -@Deprecated -public class ChargableItem extends SlimefunItem implements Rechargeable { - - public ChargableItem(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { - super(category, item, recipeType, recipe); - } - - @Override - public float getMaxItemCharge(ItemStack item) { - return ItemEnergy.getMaxEnergy(item); - } - -} diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/SlimefunItem.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/SlimefunItem.java index 32f22f887..aebb38afd 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/SlimefunItem.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/SlimefunItem.java @@ -24,13 +24,14 @@ import io.github.thebusybiscuit.slimefun4.api.exceptions.IdConflictException; import io.github.thebusybiscuit.slimefun4.api.exceptions.IncompatibleItemHandlerException; import io.github.thebusybiscuit.slimefun4.api.exceptions.MissingDependencyException; import io.github.thebusybiscuit.slimefun4.api.exceptions.UnregisteredItemException; +import io.github.thebusybiscuit.slimefun4.api.exceptions.WrongItemStackException; import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; import io.github.thebusybiscuit.slimefun4.api.items.ItemState; import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetComponent; +import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetProvider; import io.github.thebusybiscuit.slimefun4.core.attributes.Placeable; import io.github.thebusybiscuit.slimefun4.core.attributes.Radioactive; import io.github.thebusybiscuit.slimefun4.core.attributes.Rechargeable; -import io.github.thebusybiscuit.slimefun4.core.attributes.WitherProof; import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide; import io.github.thebusybiscuit.slimefun4.core.researching.Research; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; @@ -73,7 +74,7 @@ public class SlimefunItem implements Placeable { private boolean ticking = false; private BlockTicker blockTicker; - private GeneratorTicker generatorTicker; + protected GeneratorTicker generatorTicker; /** * This creates a new {@link SlimefunItem} from the given arguments. @@ -319,7 +320,11 @@ public class SlimefunItem implements Placeable { return blockTicker; } - // We should maybe refactor this and move it to a subclass + /** + * @deprecated The interface {@link EnergyNetProvider} should be implemented instead + * @return A {@link GeneratorTicker} + */ + @Deprecated public GeneratorTicker getEnergyTicker() { return generatorTicker; } @@ -377,17 +382,17 @@ public class SlimefunItem implements Placeable { SlimefunPlugin.getRegistry().getRadioactiveItems().add(this); } - if (this instanceof WitherProof) { - SlimefunPlugin.getRegistry().getWitherProofBlocks().put(id, (WitherProof) this); - } - if (this instanceof EnergyNetComponent && !SlimefunPlugin.getRegistry().getEnergyCapacities().containsKey(getID())) { - ((EnergyNetComponent) this).registerComponent(id); + int capacity = ((EnergyNetComponent) this).getCapacity(); + + if (capacity > 0) { + SlimefunPlugin.getRegistry().getEnergyCapacities().put(id, capacity); + } } if (SlimefunPlugin.getItemCfg().getBoolean(id + ".enabled")) { - if (!SlimefunPlugin.getRegistry().getCategories().contains(category)) { + if (!category.isRegistered()) { category.register(); } @@ -409,6 +414,10 @@ public class SlimefunItem implements Placeable { state = ItemState.DISABLED; } + if (item instanceof SlimefunItemStack && isItemStackImmutable()) { + ((SlimefunItemStack) item).lock(); + } + postRegister(); if (SlimefunPlugin.getRegistry().isAutoLoadingEnabled() && state == ItemState.ENABLED) { @@ -442,6 +451,20 @@ public class SlimefunItem implements Placeable { } } + /** + * This method returns whether the original {@link SlimefunItemStack} of this + * {@link SlimefunItem} is immutable. + * + * If true is returned, then any changes to the original {@link SlimefunItemStack} + * will be rejected with a {@link WrongItemStackException}. + * This ensures integrity so developers don't accidentally damage the wrong {@link ItemStack}. + * + * @return Whether the original {@link SlimefunItemStack} is immutable. + */ + protected boolean isItemStackImmutable() { + return true; + } + /** * This method checks recursively for all {@link Class} parents to look for any {@link Deprecated} * elements. diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AGenerator.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AGenerator.java index e745b3ecb..874fe3c4a 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AGenerator.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AGenerator.java @@ -23,8 +23,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.SlimefunItem; -import me.mrCookieSlime.Slimefun.Objects.handlers.GeneratorTicker; import me.mrCookieSlime.Slimefun.api.BlockStorage; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; import me.mrCookieSlime.Slimefun.api.energy.ChargableBlock; @@ -58,8 +56,12 @@ public abstract class AGenerator extends AbstractEnergyProvider { @Override public int[] getSlotsAccessedByItemTransport(ItemTransportFlow flow) { - if (flow == ItemTransportFlow.INSERT) return getInputSlots(); - else return getOutputSlots(); + if (flow == ItemTransportFlow.INSERT) { + return getInputSlots(); + } + else { + return getOutputSlots(); + } } }; @@ -80,6 +82,7 @@ public abstract class AGenerator extends AbstractEnergyProvider { } } } + progress.remove(b.getLocation()); processing.remove(b.getLocation()); return true; @@ -138,71 +141,60 @@ public abstract class AGenerator extends AbstractEnergyProvider { } @Override - protected GeneratorTicker onTick() { - return new GeneratorTicker() { + public int getGeneratedOutput(Location l, Config data) { + BlockMenu inv = BlockStorage.getInventory(l); + boolean chargeable = getCapacity() > 0; - @Override - public double generateEnergy(Location l, SlimefunItem sf, Config data) { - BlockMenu inv = BlockStorage.getInventory(l); - boolean chargeable = getCapacity() > 0; - int charge = chargeable ? ChargableBlock.getCharge(l) : 0; + if (isProcessing(l)) { + int timeleft = progress.get(l); - if (isProcessing(l)) { - int timeleft = progress.get(l); + if (timeleft > 0) { + ChestMenuUtils.updateProgressbar(inv, 22, timeleft, processing.get(l).getTicks(), getProgressBar()); - if (timeleft > 0) { - ChestMenuUtils.updateProgressbar(inv, 22, timeleft, processing.get(l).getTicks(), getProgressBar()); + if (chargeable) { + int charge = ChargableBlock.getCharge(l); - if (chargeable) { - if (getCapacity() - charge >= getEnergyProduction()) { - ChargableBlock.addCharge(l, getEnergyProduction()); - progress.put(l, timeleft - 1); - return (double) (charge + getEnergyProduction()); - } - - return charge; - } - else { - progress.put(l, timeleft - 1); - return getEnergyProduction(); - } + if (getCapacity() - charge >= getEnergyProduction()) { + progress.put(l, timeleft - 1); + return getEnergyProduction(); } - else { - ItemStack fuel = processing.get(l).getInput(); - if (isBucket(fuel)) { - inv.pushItem(new ItemStack(Material.BUCKET), getOutputSlots()); - } - - inv.replaceExistingItem(22, new CustomItem(Material.BLACK_STAINED_GLASS_PANE, " ")); - - progress.remove(l); - processing.remove(l); - return charge; - } + return 0; } else { - Map found = new HashMap<>(); - MachineFuel fuel = findRecipe(inv, found); - - if (fuel != null) { - for (Map.Entry entry : found.entrySet()) { - inv.consumeItem(entry.getKey(), entry.getValue()); - } - - processing.put(l, fuel); - progress.put(l, fuel.getTicks()); - } - - return charge; + progress.put(l, timeleft - 1); + return getEnergyProduction(); } } + else { + ItemStack fuel = processing.get(l).getInput(); - @Override - public boolean explode(Location l) { - return false; + if (isBucket(fuel)) { + inv.pushItem(new ItemStack(Material.BUCKET), getOutputSlots()); + } + + inv.replaceExistingItem(22, new CustomItem(Material.BLACK_STAINED_GLASS_PANE, " ")); + + progress.remove(l); + processing.remove(l); + return 0; } - }; + } + else { + Map found = new HashMap<>(); + MachineFuel fuel = findRecipe(inv, found); + + if (fuel != null) { + for (Map.Entry entry : found.entrySet()) { + inv.consumeItem(entry.getKey(), entry.getValue()); + } + + processing.put(l, fuel); + progress.put(l, fuel.getTicks()); + } + + return 0; + } } private boolean isBucket(ItemStack item) { diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/MachineRecipe.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/MachineRecipe.java index c573ffa66..94678a387 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/MachineRecipe.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/MachineRecipe.java @@ -5,8 +5,8 @@ import org.bukkit.inventory.ItemStack; public class MachineRecipe { private int ticks; - private ItemStack[] input; - private ItemStack[] output; + private final ItemStack[] input; + private final ItemStack[] output; public MachineRecipe(int seconds, ItemStack[] input, ItemStack[] output) { this.ticks = seconds * 2; diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/handlers/BlockBreakHandler.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/handlers/BlockBreakHandler.java deleted file mode 100644 index 2b43d181d..000000000 --- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/handlers/BlockBreakHandler.java +++ /dev/null @@ -1,9 +0,0 @@ -package me.mrCookieSlime.Slimefun.Objects.handlers; - -/** - * @deprecated Moved to {@link io.github.thebusybiscuit.slimefun4.core.handlers.BlockBreakHandler} - */ -@Deprecated -public interface BlockBreakHandler extends io.github.thebusybiscuit.slimefun4.core.handlers.BlockBreakHandler { - -} diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/handlers/GeneratorTicker.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/handlers/GeneratorTicker.java index 325cbe961..a941888bf 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/handlers/GeneratorTicker.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/Objects/handlers/GeneratorTicker.java @@ -6,11 +6,17 @@ import org.bukkit.Location; import io.github.thebusybiscuit.slimefun4.api.exceptions.IncompatibleItemHandlerException; import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetComponent; +import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetProvider; import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable; import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNetComponentType; import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; +/** + * @deprecated Please implement the {@link EnergyNetProvider} interface instead. + * + */ +@Deprecated public abstract class GeneratorTicker implements ItemHandler { public abstract double generateEnergy(Location l, SlimefunItem item, Config data); diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/handlers/ItemUseHandler.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/handlers/ItemUseHandler.java deleted file mode 100644 index 13c5653b2..000000000 --- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/handlers/ItemUseHandler.java +++ /dev/null @@ -1,9 +0,0 @@ -package me.mrCookieSlime.Slimefun.Objects.handlers; - -/** - * @deprecated Moved to {@link io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler} - */ -@Deprecated -public interface ItemUseHandler extends io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler { - -} diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/handlers/MultiBlockInteractionHandler.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/handlers/MultiBlockInteractionHandler.java deleted file mode 100644 index 226f52ea3..000000000 --- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/handlers/MultiBlockInteractionHandler.java +++ /dev/null @@ -1,9 +0,0 @@ -package me.mrCookieSlime.Slimefun.Objects.handlers; - -/** - * @deprecated Moved to {@link io.github.thebusybiscuit.slimefun4.core.handlers.MultiBlockInteractionHandler} - */ -@Deprecated -public interface MultiBlockInteractionHandler extends io.github.thebusybiscuit.slimefun4.core.handlers.MultiBlockInteractionHandler { - -} diff --git a/src/main/java/me/mrCookieSlime/Slimefun/SlimefunPlugin.java b/src/main/java/me/mrCookieSlime/Slimefun/SlimefunPlugin.java deleted file mode 100644 index 36e8dc9e1..000000000 --- a/src/main/java/me/mrCookieSlime/Slimefun/SlimefunPlugin.java +++ /dev/null @@ -1,161 +0,0 @@ -package me.mrCookieSlime.Slimefun; - -import java.util.Set; - -import org.bukkit.plugin.Plugin; - -import io.github.thebusybiscuit.cscorelib2.config.Config; -import io.github.thebusybiscuit.cscorelib2.protection.ProtectionManager; -import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; -import io.github.thebusybiscuit.slimefun4.api.gps.GPSNetwork; -import io.github.thebusybiscuit.slimefun4.core.SlimefunRegistry; -import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand; -import io.github.thebusybiscuit.slimefun4.core.networks.NetworkManager; -import io.github.thebusybiscuit.slimefun4.core.services.BlockDataService; -import io.github.thebusybiscuit.slimefun4.core.services.CustomItemDataService; -import io.github.thebusybiscuit.slimefun4.core.services.CustomTextureService; -import io.github.thebusybiscuit.slimefun4.core.services.LocalizationService; -import io.github.thebusybiscuit.slimefun4.core.services.MinecraftRecipeService; -import io.github.thebusybiscuit.slimefun4.core.services.PerWorldSettingsService; -import io.github.thebusybiscuit.slimefun4.core.services.PermissionsService; -import io.github.thebusybiscuit.slimefun4.core.services.UpdaterService; -import io.github.thebusybiscuit.slimefun4.core.services.github.GitHubService; -import io.github.thebusybiscuit.slimefun4.core.services.plugins.ThirdPartyPluginService; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.AncientAltarListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.BackpackListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.BlockListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.BlockPhysicsListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.CargoNodeListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.CoolerListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.DeathpointListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.DebugFishListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.DispenserListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.EnhancedFurnaceListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.ExplosionsListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.FireworksListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.GadgetsListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.GrapplingHookListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.SlimefunBowListener; -import io.github.thebusybiscuit.slimefun4.implementation.tasks.TickerTask; -import me.mrCookieSlime.CSCoreLibPlugin.CSCoreLib; - -/** - * @deprecated This class has been moved to {@link io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin} - * - * @author TheBusyBiscuit - * - */ -@Deprecated -public final class SlimefunPlugin { - - private SlimefunPlugin() {} - - public static Config getCfg() { - return io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin.getCfg(); - } - - public static Config getResearchCfg() { - return io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin.getResearchCfg(); - } - - public static Config getItemCfg() { - return io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin.getItemCfg(); - } - - public static GPSNetwork getGPSNetwork() { - return io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin.getGPSNetwork(); - } - - public static TickerTask getTicker() { - return io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin.getTickerTask(); - } - - public static String getVersion() { - return io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin.getVersion(); - } - - public static ProtectionManager getProtectionManager() { - return io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin.getProtectionManager(); - } - - public static LocalizationService getLocal() { - return io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin.getLocalization(); - } - - public static MinecraftRecipeService getMinecraftRecipes() { - return io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin.getMinecraftRecipeService(); - } - - public static CustomItemDataService getItemDataService() { - return io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin.getItemDataService(); - } - - public static CustomTextureService getItemTextureService() { - return io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin.getItemTextureService(); - } - - public static PermissionsService getPermissionsService() { - return io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin.getPermissionsService(); - } - - public static BlockDataService getBlockDataService() { - return io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin.getBlockDataService(); - } - - public static ThirdPartyPluginService getThirdPartySupportService() { - return io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin.getThirdPartySupportService(); - } - - public static PerWorldSettingsService getWorldSettingsService() { - return io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin.getWorldSettingsService(); - } - - public static UpdaterService getUpdater() { - return io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin.getUpdater(); - } - - public static GitHubService getGitHubService() { - return io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin.getGitHubService(); - } - - public static SlimefunRegistry getRegistry() { - return io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin.getRegistry(); - } - - public static NetworkManager getNetworkManager() { - return io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin.getNetworkManager(); - } - - public static AncientAltarListener getAncientAltarListener() { - return io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin.getAncientAltarListener(); - } - - public static GrapplingHookListener getGrapplingHookListener() { - return io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin.getGrapplingHookListener(); - } - - public static BackpackListener getBackpackListener() { - return io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin.getBackpackListener(); - } - - public static SlimefunBowListener getBowListener() { - return io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin.getBowListener(); - } - - public static Set getInstalledAddons() { - return io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin.getInstalledAddons(); - } - - public static SlimefunCommand getCommand() { - return io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin.getCommand(); - } - - public static MinecraftVersion getMinecraftVersion() { - return io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin.getMinecraftVersion(); - } - - public static String getCSCoreLibVersion() { - return CSCoreLib.getLib().getDescription().getVersion(); - } - -} diff --git a/src/main/java/me/mrCookieSlime/Slimefun/api/Slimefun.java b/src/main/java/me/mrCookieSlime/Slimefun/api/Slimefun.java index 97b5c1b65..b7d7af302 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/api/Slimefun.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/api/Slimefun.java @@ -4,7 +4,6 @@ import java.util.Optional; import java.util.logging.Logger; import org.bukkit.Bukkit; -import org.bukkit.NamespacedKey; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.scheduler.BukkitTask; @@ -14,7 +13,6 @@ import io.github.thebusybiscuit.slimefun4.api.items.ItemState; import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.implementation.items.VanillaItem; -import me.mrCookieSlime.Slimefun.Objects.Research; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; /** @@ -29,49 +27,7 @@ public final class Slimefun { private Slimefun() {} public static Logger getLogger() { - return SlimefunPlugin.instance.getLogger(); - } - - /** - * Registers a research. - * - * @deprecated The Research class was moved, this method is no longer valid. Please use - * {@link io.github.thebusybiscuit.slimefun4.core.researching.Research#register()} instead. - * - * @param research - * The research - * @param items - * The items - */ - @Deprecated - public static void registerResearch(Research research, ItemStack... items) { - for (ItemStack item : items) { - research.addItems(SlimefunItem.getByItem(item)); - } - - research.register(); - } - - /** - * Registers a research. - * - * @deprecated The Research class was moved, this method is no longer valid. Please use - * {@link io.github.thebusybiscuit.slimefun4.core.researching.Research#register()} instead. - * - * @param key - * The key - * @param id - * The id - * @param name - * The name - * @param cost - * The default cost - * @param items - * The items - */ - @Deprecated - public static void registerResearch(NamespacedKey key, int id, String name, int cost, ItemStack... items) { - registerResearch(new Research(key, id, name, cost), items); + return SlimefunPlugin.instance().getLogger(); } /** @@ -231,11 +187,11 @@ public final class Slimefun { return null; } - if (SlimefunPlugin.instance == null || !SlimefunPlugin.instance.isEnabled()) { + if (SlimefunPlugin.instance() == null || !SlimefunPlugin.instance().isEnabled()) { return null; } - return Bukkit.getScheduler().runTask(SlimefunPlugin.instance, r); + return Bukkit.getScheduler().runTask(SlimefunPlugin.instance(), r); } public static BukkitTask runSync(Runnable r, long delay) { @@ -244,10 +200,10 @@ public final class Slimefun { return null; } - if (SlimefunPlugin.instance == null || !SlimefunPlugin.instance.isEnabled()) { + if (SlimefunPlugin.instance() == null || !SlimefunPlugin.instance().isEnabled()) { return null; } - return Bukkit.getScheduler().runTaskLater(SlimefunPlugin.instance, r, delay); + return Bukkit.getScheduler().runTaskLater(SlimefunPlugin.instance(), r, delay); } } \ No newline at end of file diff --git a/src/main/java/me/mrCookieSlime/Slimefun/api/SlimefunItemStack.java b/src/main/java/me/mrCookieSlime/Slimefun/api/SlimefunItemStack.java index 6ea97ce8f..22c1ebd9a 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/api/SlimefunItemStack.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/api/SlimefunItemStack.java @@ -24,6 +24,7 @@ import io.github.thebusybiscuit.cscorelib2.item.ImmutableItemMeta; import io.github.thebusybiscuit.cscorelib2.skull.SkullItem; import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; import io.github.thebusybiscuit.slimefun4.api.exceptions.PrematureCodeException; +import io.github.thebusybiscuit.slimefun4.api.exceptions.WrongItemStackException; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.utils.HeadTexture; import io.github.thebusybiscuit.slimefun4.utils.PatternUtils; @@ -34,6 +35,7 @@ public class SlimefunItemStack extends CustomItem { private String id; private ImmutableItemMeta immutableMeta; + private boolean locked = false; private String texture = null; public SlimefunItemStack(String id, Material type, String name, String... lore) { @@ -148,7 +150,7 @@ public class SlimefunItemStack extends CustomItem { Validate.notNull(id, "The Item id must never be null!"); Validate.isTrue(id.equals(id.toUpperCase(Locale.ROOT)), "Slimefun Item Ids must be uppercase! (e.g. 'MY_ITEM_ID')"); - if (SlimefunPlugin.instance == null) { + if (SlimefunPlugin.instance() == null) { throw new PrematureCodeException("A SlimefunItemStack must never be be created before your Plugin was enabled."); } @@ -206,11 +208,34 @@ public class SlimefunItemStack extends CustomItem { @Override public boolean setItemMeta(ItemMeta meta) { + validate(); immutableMeta = new ImmutableItemMeta(meta); return super.setItemMeta(meta); } + @Override + public void setType(Material type) { + validate(); + super.setType(type); + } + + @Override + public void setAmount(int amount) { + validate(); + super.setAmount(amount); + } + + private void validate() { + if (locked) { + throw new WrongItemStackException(id + " is not mutable."); + } + } + + public void lock() { + locked = true; + } + @Override public ItemStack clone() { return new SlimefunItemStack(id, this); diff --git a/src/main/java/me/mrCookieSlime/Slimefun/api/energy/ChargableBlock.java b/src/main/java/me/mrCookieSlime/Slimefun/api/energy/ChargableBlock.java index 8dd461328..3a93118c0 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/api/energy/ChargableBlock.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/api/energy/ChargableBlock.java @@ -6,7 +6,9 @@ import org.bukkit.block.Block; import io.github.thebusybiscuit.cscorelib2.skull.SkullBlock; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; +import io.github.thebusybiscuit.slimefun4.implementation.items.electric.Capacitor; import io.github.thebusybiscuit.slimefun4.utils.HeadTexture; +import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; import me.mrCookieSlime.Slimefun.api.BlockStorage; import me.mrCookieSlime.Slimefun.api.Slimefun; @@ -46,10 +48,6 @@ public final class ChargableBlock { } } - public static void setCharge(Block b, int charge) { - setCharge(b.getLocation(), charge); - } - public static void setCharge(Location l, int charge) { if (charge < 0) { charge = 0; @@ -62,7 +60,9 @@ public final class ChargableBlock { } } - BlockStorage.addBlockInfo(l, KEY, String.valueOf(charge), false); + if (charge != getCharge(l)) { + BlockStorage.addBlockInfo(l, KEY, String.valueOf(charge), false); + } } public static void setUnsafeCharge(Location l, int charge, boolean updateTexture) { @@ -96,16 +96,16 @@ public final class ChargableBlock { if (availableSpace > 0 && addedCharge > 0) { if (availableSpace > addedCharge) { charge += addedCharge; - setCharge(l, charge); rest = 0; } else { rest = addedCharge - availableSpace; charge = capacity; - setCharge(l, charge); } - if (SlimefunPlugin.getRegistry().getEnergyCapacitors().contains(id)) { + setCharge(l, charge); + + if (SlimefunItem.getByID(id) instanceof Capacitor) { updateCapacitor(l, charge, capacity); } } @@ -113,7 +113,7 @@ public final class ChargableBlock { charge += addedCharge; setCharge(l, charge); - if (SlimefunPlugin.getRegistry().getEnergyCapacitors().contains(id)) { + if (SlimefunItem.getByID(id) instanceof Capacitor) { updateCapacitor(l, charge, capacity); } } diff --git a/src/main/java/me/mrCookieSlime/Slimefun/api/energy/ItemEnergy.java b/src/main/java/me/mrCookieSlime/Slimefun/api/energy/ItemEnergy.java deleted file mode 100644 index a668d0ad1..000000000 --- a/src/main/java/me/mrCookieSlime/Slimefun/api/energy/ItemEnergy.java +++ /dev/null @@ -1,118 +0,0 @@ -package me.mrCookieSlime.Slimefun.api.energy; - -import java.math.BigDecimal; -import java.math.RoundingMode; -import java.util.List; - -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; - -import io.github.thebusybiscuit.cscorelib2.chat.ChatColors; -import io.github.thebusybiscuit.slimefun4.core.attributes.Rechargeable; -import io.github.thebusybiscuit.slimefun4.utils.PatternUtils; -import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; - -/** - * @deprecated Please implement {@link Rechargeable} on your {@link SlimefunItem} instead. - * - * @author TheBusyBiscuit - * - */ -@Deprecated -public final class ItemEnergy { - - // We should find a replacement for this class - // Perhaps we could also use PersistentData here too? - private ItemEnergy() {} - - // "&c&o&8\u21E8 &e\u26A1 &70 / 50 J" - - public static float getStoredEnergy(ItemStack item) { - if (item == null || item.getType() == Material.AIR || item.getAmount() < 1) return 0F; - if (!item.hasItemMeta() || !item.getItemMeta().hasLore()) return 0F; - - for (String line : item.getItemMeta().getLore()) { - if (line.startsWith(ChatColors.color("&c&o&8\u21E8 &e\u26A1 &7")) && line.contains(" / ") && line.endsWith(" J")) { - return Float.parseFloat(PatternUtils.SLASH_SEPARATOR.split(line)[0].replace(ChatColors.color("&c&o&8\u21E8 &e\u26A1 &7"), "")); - } - } - - return 0F; - } - - public static float getMaxEnergy(ItemStack item) { - if (item == null || item.getType() == Material.AIR || item.getAmount() < 1) return 0F; - if (!item.hasItemMeta() || !item.getItemMeta().hasLore()) return 0F; - - for (String line : item.getItemMeta().getLore()) { - if (line.startsWith(ChatColors.color("&c&o&8\u21E8 &e\u26A1 &7")) && line.contains(" / ") && line.endsWith(" J")) { - return Float.parseFloat(PatternUtils.SLASH_SEPARATOR.split(line)[1].replace(" J", "")); - } - } - - return 0F; - } - - public static float addStoredEnergy(ItemStack item, float energy) { - if (item == null || item.getType() == Material.AIR || item.getAmount() < 1) return 0F; - if (!item.hasItemMeta() || !item.getItemMeta().hasLore()) return 0; - - float rest = 0F; - float capacity = getMaxEnergy(item); - - if ((int) capacity == 0) { - return rest; - } - - float stored = getStoredEnergy(item); - - if (stored + energy > capacity) { - rest = (stored + energy) - capacity; - stored = capacity; - } - else if (stored + energy < 0) { - stored = 0F; - } - else { - stored = stored + energy; - } - - List lore = item.getItemMeta().getLore(); - - int index = -1; - for (int i = 0; i < lore.size(); i++) { - String line = lore.get(i); - - if (line.startsWith(ChatColors.color("&c&o&8\u21E8 &e\u26A1 &7")) && line.contains(" / ") && line.endsWith(" J")) { - index = i; - break; - } - } - - BigDecimal decimal = BigDecimal.valueOf(stored).setScale(2, RoundingMode.HALF_UP); - - lore.set(index, ChatColors.color("&c&o&8\u21E8 &e\u26A1 &7") + decimal.floatValue() + " / " + capacity + " J"); - - ItemMeta im = item.getItemMeta(); - im.setLore(lore); - item.setItemMeta(im); - return rest; - } - - public static ItemStack chargeItem(ItemStack item, float energy) { - addStoredEnergy(item, energy); - return item; - } - - public static void chargeInventory(Player p, float energy) { - p.getInventory().setItemInMainHand(chargeItem(p.getInventory().getItemInMainHand(), energy)); - p.getInventory().setItemInOffHand(chargeItem(p.getInventory().getItemInOffHand(), energy)); - p.getInventory().setHelmet(chargeItem(p.getInventory().getHelmet(), energy)); - p.getInventory().setChestplate(chargeItem(p.getInventory().getChestplate(), energy)); - p.getInventory().setLeggings(chargeItem(p.getInventory().getLeggings(), energy)); - p.getInventory().setBoots(chargeItem(p.getInventory().getBoots(), energy)); - } - -} diff --git a/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/BlockMenuPreset.java b/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/BlockMenuPreset.java index ce50bdb17..4cf2a02cf 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/BlockMenuPreset.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/BlockMenuPreset.java @@ -25,7 +25,7 @@ public abstract class BlockMenuPreset extends ChestMenu { // -1 means "automatically update according to the contents" private int size = -1; - private boolean universal; + private final boolean universal; private boolean locked; private ItemManipulationEvent event; diff --git a/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/DirtyChestMenu.java b/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/DirtyChestMenu.java index f89bef612..f00223c45 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/DirtyChestMenu.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/DirtyChestMenu.java @@ -143,8 +143,8 @@ public class DirtyChestMenu extends ChestMenu { public static class SaveHandler implements MenuOpeningHandler { - private DirtyChestMenu menu; - private MenuOpeningHandler handler; + private final DirtyChestMenu menu; + private final MenuOpeningHandler handler; public SaveHandler(DirtyChestMenu menu, MenuOpeningHandler handler) { this.menu = menu; diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 3ff862a3d..eca44c177 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -6,7 +6,7 @@ options: auto-update: true backwards-compatibility: true - chat-prefix: '&a&lSlimefun 4 &7>' + chat-prefix: '&a&lSlimefun 4&7> ' armor-update-interval: 10 enable-armor-effects: true auto-save-delay-in-minutes: 10 @@ -40,6 +40,9 @@ items: backpacks: true soulbound: true +metrics: + auto-update: true + research-ranks: - Chicken - Cow diff --git a/src/main/resources/languages/categories_hu.yml b/src/main/resources/languages/categories_hu.yml index c02ce2fcb..812f254a8 100644 --- a/src/main/resources/languages/categories_hu.yml +++ b/src/main/resources/languages/categories_hu.yml @@ -23,3 +23,4 @@ slimefun: easter: Húsvét (Április) birthday: TheBusyBiscuit születésnapja (Október 26.) halloween: Halloween (Október 31.) + androids: Programozható Androidok diff --git a/src/main/resources/languages/categories_id.yml b/src/main/resources/languages/categories_id.yml index d6a335dc6..447af2e93 100644 --- a/src/main/resources/languages/categories_id.yml +++ b/src/main/resources/languages/categories_id.yml @@ -2,10 +2,10 @@ slimefun: weapons: Senjata tools: Peralatan - items: Alat Penting + items: Barang yang Berguna food: Makanan basic_machines: Mesin Dasar - electricity: Energi Dan Listrik + electricity: Energi dan Listrik gps: Mesin - Mesin GPS armor: Baju Zirah magical_items: Benda Sihir @@ -13,13 +13,14 @@ slimefun: misc: Lain - Lain technical_gadgets: Alat Teknis resources: Sumber Daya - cargo: Pengatur Muatan + cargo: Manajemen Kargo tech_misc: Komponen Teknis magical_armor: Pakaian Sihir talismans: Jimat (Tingkat I) ender_talismans: Jimat Ender (Tingkat II) christmas: Natal (Desember) valentines_day: Hari Valentine (14 Februari) - easter: Easter (April) + easter: Paskah (April) birthday: Ulang Tahun TheBusyBiscuit (26 Oktober) halloween: Halloween (31 Oktober) + androids: Mesin Berprogram diff --git a/src/main/resources/languages/categories_pl.yml b/src/main/resources/languages/categories_pl.yml index 503164073..47bda5b42 100644 --- a/src/main/resources/languages/categories_pl.yml +++ b/src/main/resources/languages/categories_pl.yml @@ -23,3 +23,4 @@ slimefun: easter: Wielkanoc (Kwiecień) birthday: Urodziny TheBusyBiscuit (26 Października) halloween: Halloween (31 Października) + androids: Programowalne Androidy diff --git a/src/main/resources/languages/messages_en.yml b/src/main/resources/languages/messages_en.yml index db8b32017..6418f7c4f 100644 --- a/src/main/resources/languages/messages_en.yml +++ b/src/main/resources/languages/messages_en.yml @@ -139,6 +139,12 @@ messages: research: start: '&7The Ancient Spirits whisper mysterious words into your ear!' progress: '&7You start to wonder about &b%research% &e(%progress%)' + + tape-measure: + no-anchor: '&cYou need to set an anchor before you can start to measure!' + wrong-world: '&cYour anchor seems to be in a different world!' + distance: '&7Measurement taken. &eDistance: %distance%' + anchor-set: '&aSuccessfully set the anchor:&e %anchor%' fire-extinguish: '&7You have extinguished yourself' cannot-place: '&cYou cannot place that block there!' diff --git a/src/main/resources/languages/messages_pl.yml b/src/main/resources/languages/messages_pl.yml index 23aa33300..1cff0f74c 100644 --- a/src/main/resources/languages/messages_pl.yml +++ b/src/main/resources/languages/messages_pl.yml @@ -1,184 +1,132 @@ --- -android: - scripts: - already-uploaded: "&4Ten skrypt został już przesłany." - enter-name: - - - - "&eProszę wpisać nazwę dla tego skryptu" - instructions: - ATTACK_ANIMALS: "&4Atakuj &c(Zwierzęta)" - ATTACK_ANIMALS_ADULT: "&4Atakuj &c(Zwierzęta &7[Dorosłe]&c)" - ATTACK_MOBS: "&4Atakuj &c(Wrogie Moby)" - ATTACK_MOBS_ANIMALS: "&4Atakuj &c(Wrogie Moby i Zwierzęta)" - CATCH_FISH: "&bŁów ryby" - CHOP_TREE: "&cTnij drzewo i posadź sadzonkę" - DIG_DOWN: "&bKop w dół" - DIG_FORWARD: "&bKop do przodu" - DIG_UP: "&bKop w górę" - FARM_DOWN: "&bZbieraj i posadź z powrotem &7(Blok pod spodem)" - FARM_EXOTIC_DOWN: "&bZaawansowanie zbieraj i posadź z powrotem &7(Blok pod spodem)" - FARM_EXOTIC_FORWARD: "&6Zaawansowanie zbieraj i posadź z powrotem" - FARM_FORWARD: "&bZbieraj i posadź z powrotem" - GO_DOWN: "&7Idź w dół" - GO_FORWARD: "&7Idź do przodu" - GO_UP: "&7Idź do góry" - INTERFACE_FUEL: "&cOtrzymaj paliwo z Interfejsu w obecnym kierunku" - INTERFACE_ITEMS: "&9Wyślij zawartość ekwipunku do Interfejsu w obecnym kierunku" - MOVE_AND_DIG_DOWN: "&bIdź i kop w dół" - MOVE_AND_DIG_FORWARD: "&bIdź i kop do przodu" - MOVE_AND_DIG_UP: "&bIdź i kop w górę" - REPEAT: "&9 Powtórz skrypt" - START: "&2Uruchom skrypt" - TURN_LEFT: "&7Skręć w lewo" - TURN_RIGHT: "&7Skręć w prawo" - WAIT: "&ePoczekaj 0.5s" - rating: - already: "&4Oceniłeś już ten skrypt!" - own: "&4Nie możesz ocenić własnego skryptu!" - uploaded: - - "&bPrzesyłanie..." - - "&aPomyślnie przesłano twój skrypt!" - started: "&7Twój Android wznowił swój skrypt" - stopped: "&7Twój Android wstrzymał swój skrypt" -anvil: - not-working: "&4Nie możesz używać przedmiotów Slimefun w kowadle!" -backpack: - already-open: "&cPrzepraszamy, ten plecak jest otwarty gdzie indziej!" - no-stack: "&cNie możesz stakować plecaków" commands: + help: Pokazuje ten ekran pomocy + cheat: Daje graczowi przedmioty Slimefun. give: Daj graczowi przedmioty Slimefun guide: Daje ci przewodnik Slimefun - help: Pokazuje ten ekran pomocy + timings: Informacje o opóźnieniu na twoim serwerze + teleporter: Zobacz punkty lokalizacji innych graczy + versions: Wyświetla listę wszystkich zainstalowanych dodatków + search: Przeszukuje twój przewodnik dla podanego terminu open_guide: Otwiera przewodnik Slimefun bez korzystania z książki + stats: Pokazuje niektóre statystyki dotyczące gracza research: description: Odblokuj/Zresetuj badania dla gracza reset: "&cZresetowano wiedzę gracza %player%" reset-target: "&c Twoja wiedza została zresetowana" - search: Przeszukuje twój przewodnik dla podanego terminu - stats: Pokazuje niektóre statystyki dotyczące gracza - teleporter: Zobacz punkty lokalizacji innych graczy - timings: Informacje o opóźnieniu na twoim serwerze - versions: Wyświetla listę wszystkich zainstalowanych dodatków - cheat: Daje graczowi przedmioty Slimefun. -gps: - deathpoint: "&4Punkt śmierci &7%date%" - geo: - scan-required: "&4Wymagany jest skan GEO-Skan! &cNajpierw zeskanuj ten fragment - za pomocą skanera GEO!" - insufficient-complexity: - - "&4Niewystarczająca złożoność sieci GPS: &c%complexity%" - - "&4a) Nie masz jeszcze skonfigurowanej sieci GPS" - - "&4b) Twoja sieć GPS nie jest wystarczająco złożona" - waypoint: - added: "&aPomyślnie dodano nowy punkt trasy" - max: "&4Osiągnięto maksymalną liczbę punktów trasy" - new: "&eProszę wpisać nazwę swojego nowego punktu trasy na czacie. &7(Kody kolorów - są obsługiwane!)" guide: - cheat: - no-multiblocks: "&4Nie możesz otrzymać Multibloków, musisz je zbudować!" - credits: - commit: Rejestracja zmian - commits: Rejestracje zmian - profile-link: Kliknij, aby odwiedzić ich profil na GitHub - roles: - developer: "&6Developer" - resourcepack: "&cArtysta paczki zasobów" - translator: "&9Tłumacz" - wiki: "&3Edytor Wiki" - languages: - select: Kliknij, aby wybrać ten język - select-default: Kliknij, aby wybrać domyślny język - selected-language: 'Aktualnie wybrane:' - translations: - lore: Kliknij, aby dodać własne tłumaczenie - name: "&aCzegoś brakuje?" - updated: "&aTwój język został pomyślnie ustawiony na: &b%lang%" - pages: - next: Kolejna strona - previous: Poprzednia strona search: + message: "&bCo chcesz wyszukać?" + name: "&7Szukaj..." + tooltip: "&bKliknij, aby wyszukać przedmiot" + inventory: 'Wyszukiwanie dla: % item%' lore: - "&bCo chcesz wyszukać?" - "&7Wpisz wyszukiwane hasło na czacie" - message: "&bCo chcesz wyszukać?" - name: "&7Szukaj..." + cheat: + no-multiblocks: "&4Nie możesz otrzymać Multibloków, musisz je zbudować!" + languages: + updated: "&aTwój język został pomyślnie ustawiony na: &b%lang%" + translations: + name: "&aCzegoś brakuje?" + lore: Kliknij, aby dodać własne tłumaczenie + select: Kliknij, aby wybrać ten język + select-default: Kliknij, aby wybrać domyślny język + selected-language: 'Aktualnie wybrane:' title: - addons: Dodatki dla Slimefun4 - bugs: Zgłaszanie błędów - credits: Autorzy Slimefun4 - languages: Wybierz preferowany język main: Przewodnik Slimefun settings: Ustawienia i informacje + languages: Wybierz preferowany język + credits: Autorzy Slimefun4 wiki: Wiki Slimefun4 + addons: Dodatki dla Slimefun4 + bugs: Zgłaszanie błędów + source: Kod Źródłowy + credits: + commit: Rejestracja zmian + commits: Rejestracje zmian + roles: + developer: "&6Developer" + wiki: "&3Edytor Wiki" + resourcepack: "&cArtysta paczki zasobów" + translator: "&9Tłumacz" + profile-link: Kliknij, aby odwiedzić ich profil na GitHub + pages: + previous: Poprzednia strona + next: Kolejna strona tooltips: open-category: Kliknij, aby otworzyć versions-notice: Jest to bardzo ważne przy zgłaszaniu błędów! -inventory: - no-access: "&4Nie masz dostępu do tego bloku" -languages: - cs: Czeski - de: Niemiecki - default: Domyślny serwera - el: Grecki - en: Język angielski - es: Hiszpański - fr: Francuski - he: Hebrajski - hu: Węgierski - id: Indonezyjski - it: Włoski - lv: Łotewski - nl: Holenderski - pl: Polski - pt: Portugalski (Portugalia) - pt-BR: Portugalski (Brazylia) - ru: Rosyjski - sk: Słowacki - sv: Szwedzki - vi: Wietnamski - zh-CN: Chiński (Chiny) - zh-TW: Chiński (Tajwan) -machines: - ANCIENT_ALTAR: - not-enough-pedestals: "&4Ołtarz nie jest otoczony potrzebną ilością cokołów &c(%pedestals% - / 8)" - unknown-catalyst: "&4Nieznany katalizator! &cZamiast tego użyj prawidłowego przepisu!" - unknown-recipe: "&4Nieznany przepis! &cZamiast tego użyj prawidłowego przepisu!" - ANCIENT_PEDESTAL: - obstructed: "&4Piedestał jest zablokowany! &cUsuń wszystko nad piedestałem!" - CARGO_NODES: - must-be-placed: "&4Musi być umieszczony na skrzyni lub maszynie!" - ELEVATOR: - click-to-teleport: "&eKliknij &7aby teleportować się na to piętro:" - current-floor: "&eTo jest piętro, na którym aktualnie jesteś:" - enter-name: "&7Wprowadź żądaną nazwę piętra na czacie. &r(Kody kolorów są obsługiwane!)" - named: "&2Pomyślnie nazwano podłogę: &r% floor%" - no-destinations: "&4Nie znaleziono miejsc docelowych" - pick-a-floor: "&3- Wybierz piętro-" - full-inventory: "&eEkwipunek jest pełny!" - HOLOGRAM_PROJECTOR: - enter-text: "&7Wprowadź żądany tekst hologramu na czacie. &r(Kody kolorów są obsługiwane!)" - ignition-chamber-no-flint: "&cDo Komory Zapłonowej brakuje Krzesiwa." - in-use: "&cEkwipunek tego bloku jest na razie otworzony przez innego gracza." - pattern-not-found: "&ePrzepraszamy, nie można rozpoznać tego przepisu. Umieść przedmioty - we właściwym wzorze w Dozowniku." - TELEPORTER: - cancelled: "&4Teleportacja anulowana!" - invulnerability: "&b&l Otrzymałeś(-aś) 30 sekund Niewrażliwości!" - teleported: "&3Przeteleportowano!" - teleporting: "&3Teleportuje..." - unknown-material: "&ePrzepraszamy, nie można rozpoznać przedmiotu w tym Dozowniku. - Proszę włożyć coś, co znam." - wrong-item: "&ePrzepraszamy, nie można rozpoznać przedmiotu, którym kliknąłeś(-aś) - mnie prawym przyciskiem myszy. Sprawdź przepisy i zobacz, jakich przedmiotów możesz - użyć." + wiki: Zobacz ten przedmiot na oficjalnej stronie Wiki Slimefun + recipes: + machine: Przepisy wykonane w tym urządzeniu + miner: Zasoby, które możesz uzyskać za pomocą tego Górnika + generator: Dostępne rodzaje paliwa + gold-pan: Zasoby, które możesz zdobyć + back: + title: Wstecz + guide: Wróć Do Przewodnika Slimefun + settings: Wróć Do Panelu Ustawień + locked: Zablokowany + locked-category: + - Aby odblokować tę kategorię, będziesz + - Musisz odblokować wszystkie przedmioty z + - Następujące kategorie messages: - cannot-place: "&cNie możesz umieścić tam tego bloku!" - diet-cookie: "&eZaczynasz czuć się bardzo lekko..." + not-researched: "&4Nie masz wystarczającej wiedzy, aby to zrozumieć" + not-enough-xp: "&4Nie masz wystarczająco doświadczenia, aby to odblokować" + unlocked: '&bOdblokowano &7"%research%"' + only-players: "&4To polecenie dotyczy tylko graczy" + unknown-player: "&4Nieznany gracz: &c%player%" + no-permission: "&4Brak uprawnień" + usage: "&4Użycie: &c%usage%" + not-online: "&4%player% &cnie jest online!" + not-valid-item: "&4%item% &cnie jest poprawnym przedmiotem!" + not-valid-amount: "&4%amount% &cnie jest prawidłową ilością: ilość musi być większa + od 0!" + given-item: '&bOtrzymano &a%amount% &7"%item%&7"' + give-item: '&bDodano przedmiot do plecaka gracza %player%: &a%amount% &7"%item%&7"' + not-valid-research: "&4%research% &cnie jest poprawnym Badaniem!" + give-research: '&bOdblokowano badanie &7"%research%&7" dla gracza %player%' + hungry: "&cJesteś zbyt głodny, żeby to zrobić!" + mode-change: "&bTryb urządzenia %device% został zmieniony na: &9%mode%" disabled-in-world: "&4&lTen przedmiot został wyłączony na tym świecie" disabled-item: "&4&l Ten przedmiot został wyłączony! Jak to w ogóle dostałeś(-aś)?" + no-tome-yourself: "&cNie możesz używać &4Księgi wiedzy &cna samym sobie..." + multimeter: "&bZmagazynowana energia: &3%stored% &b/ &3%capacity%" + talisman: + anvil: "&a&oTwój talizman uratował twoje narzędzie przed złamaniem" + miner: "&a&oTwój talizman podwoił twoje znaleziska" + hunter: "&a&oTwój talizman podwoił twoje znaleziska" + lava: "&a&oTwój talizman uratował cię przed spaleniem na śmierć" + water: "&a&oTwój talizman uratował cię przed utonięciem" + angel: "&a&oTwój talizman uratował cię przed odniesieniem obrażeń od upadku" + fire: "&a&oTwój talizman uratował cię przed spaleniem na śmierć" + magician: "&a&oTwój talizman dał ci dodatkowe zaklęcie" + traveller: "&a&oTwój talizman dał ci przyspieszenie prędkości" + warrior: "&a&oTwój talizman na pewien czas poprawił twoją siłę" + knight: "&a&oTwój talizman dał ci 5 sekund regeneracji" + whirlwind: "&a&oTwój talizman odbił pocisk" + wizard: "&a&oTwój talizman zapewnił ci lepszy poziom Szczęścia, ale może także + obniżył niektóre inne poziomy zaklinania" + soulbound-rune: + fail: "&cMożesz powiązać tylko jeden przedmiot ze swoją duszą na raz." + success: "&aPomyślnie powiązałeś(-aś) ten przedmiot ze swoją duszą! Zatrzymasz + go, gdy umrzesz." + research: + start: "&7Starożytne duchy szepczą ci do ucha tajemnicze słowa!" + progress: "&7 Zaczynasz się zastanawiać nad &b%research% &e(%progress%)" fire-extinguish: "&7Ty masz zgasły siebie." + cannot-place: "&cNie możesz umieścić tam tego bloku!" + no-pvp: "&c Nie możesz tutaj bić innych graczy!" + radiation: "&4Zostałeś(-aś) narażony na śmiertelne promieniowanie! &c Pozbądź się + radioaktywnego przedmiotu lub załóż kombinezon materiałów niebezpiecznych!" + opening-guide: "&bOtwieranie przewodnika, może to potrwać kilka sekund..." + opening-backpack: "&bOtwieranie plecaka, może to potrwać kilka sekund..." + no-iron-golem-heal: "&cTo nie jest sztabka żelaza. Nie możesz tego użyć do leczenia + Żelaznych Golemów!" + link-prompt: "&eKliknij tutaj:" + diet-cookie: "&eZaczynasz czuć się bardzo lekko..." fortune-cookie: - "&7Pomóż mi, jestem uwięziony w fabryce ciastek z wróżbami!" - "&7Jutro umrzesz... przez Creepera" @@ -192,56 +140,150 @@ messages: - "&742. Odpowiedź to 42." - "&7Walshy dziennie pomoże uniknąć kłopotów." - "&7Nigdy nie kop prosto w dół!" - give-item: '&bDodano przedmiot do plecaka gracza %player%: &a%amount% &7"%item%&7"' - given-item: '&bOtrzymano &a%amount% &7"%item%&7"' - hungry: "&cJesteś zbyt głodny, żeby to zrobić!" - link-prompt: "&eKliknij tutaj:" - mode-change: "&bTryb urządzenia %device% został zmieniony na: &9%mode%" - multimeter: "&bZmagazynowana energia: &3%stored% &b/ &3%capacity%" - no-iron-golem-heal: "&cTo nie jest sztabka żelaza. Nie możesz tego użyć do leczenia - Żelaznych Golemów!" - no-permission: "&4Brak uprawnień" - no-pvp: "&c Nie możesz tutaj bić innych graczy!" - not-enough-xp: "&4Nie masz wystarczająco doświadczenia, aby to odblokować" - no-tome-yourself: "&cNie możesz używać &4Księgi wiedzy &cna samym sobie..." - not-online: "&4%player% &cnie jest online!" - not-researched: "&4Nie masz wystarczającej wiedzy, aby to zrozumieć" - not-valid-amount: "&4%amount% &cnie jest prawidłową ilością: ilość musi być większa - od 0!" - not-valid-item: "&4%item% &cnie jest poprawnym przedmiotem!" - not-valid-research: "&4%research% &cnie jest poprawnym Badaniem!" - only-players: "&4To polecenie dotyczy tylko graczy" - opening-backpack: "&bOtwieranie plecaka, może to potrwać kilka sekund..." - opening-guide: "&bOtwieranie przewodnika, może to potrwać kilka sekund..." - radiation: "&4Zostałeś(-aś) narażony na śmiertelne promieniowanie! &c Pozbądź się - radioaktywnego przedmiotu lub załóż kombinezon materiałów niebezpiecznych!" - research: - progress: "&7 Zaczynasz się zastanawiać nad &b%research% &e(%progress%)" - start: "&7Starożytne duchy szepczą ci do ucha tajemnicze słowa!" - soulbound-rune: - fail: "&cMożesz powiązać tylko jeden przedmiot ze swoją duszą na raz." - success: "&aPomyślnie powiązałeś(-aś) ten przedmiot ze swoją duszą! Zatrzymasz - go, gdy umrzesz." - talisman: - angel: "&a&oTwój talizman uratował cię przed odniesieniem obrażeń od upadku" - anvil: "&a&oTwój talizman uratował twoje narzędzie przed złamaniem" - fire: "&a&oTwój talizman uratował cię przed spaleniem na śmierć" - hunter: "&a&oTwój talizman podwoił twoje znaleziska" - knight: "&a&oTwój talizman dał ci 5 sekund regeneracji" - lava: "&a&oTwój talizman uratował cię przed spaleniem na śmierć" - magician: "&a&oTwój talizman dał ci dodatkowe zaklęcie" - miner: "&a&oTwój talizman podwoił twoje znaleziska" - traveller: "&a&oTwój talizman dał ci przyspieszenie prędkości" - warrior: "&a&oTwój talizman na pewien czas poprawił twoją siłę" - water: "&a&oTwój talizman uratował cię przed utonięciem" - whirlwind: "&a&oTwój talizman odbił pocisk" - wizard: "&a&oTwój talizman zapewnił ci lepszy poziom Szczęścia, ale może także - obniżył niektóre inne poziomy zaklinania" - unknown-player: "&4Nieznany gracz: &c%player%" - unlocked: '&bOdblokowano &7"%research%"' - usage: "&4Użycie: &c%usage%" - give-research: '&bOdblokowano badanie &7"%research%&7" dla gracza %player%' -miner: - no-ores: "&eNie można znaleźć żadnych rud w pobliżu!" +machines: + pattern-not-found: "&ePrzepraszamy, nie można rozpoznać tego przepisu. Umieść przedmioty + we właściwym wzorze w Dozowniku." + unknown-material: "&ePrzepraszamy, nie można rozpoznać przedmiotu w tym Dozowniku. + Proszę włożyć coś, co znam." + wrong-item: "&ePrzepraszamy, nie można rozpoznać przedmiotu, którym kliknąłeś(-aś) + mnie prawym przyciskiem myszy. Sprawdź przepisy i zobacz, jakich przedmiotów możesz + użyć." + full-inventory: "&eEkwipunek jest pełny!" + in-use: "&cEkwipunek tego bloku jest na razie otworzony przez innego gracza." + ignition-chamber-no-flint: "&cDo Komory Zapłonowej brakuje Krzesiwa." + ANCIENT_ALTAR: + not-enough-pedestals: "&4Ołtarz nie jest otoczony potrzebną ilością cokołów &c(%pedestals% + / 8)" + unknown-catalyst: "&4Nieznany katalizator! &cZamiast tego użyj prawidłowego przepisu!" + unknown-recipe: "&4Nieznany przepis! &cZamiast tego użyj prawidłowego przepisu!" + ANCIENT_PEDESTAL: + obstructed: "&4Piedestał jest zablokowany! &cUsuń wszystko nad piedestałem!" + HOLOGRAM_PROJECTOR: + enter-text: "&7Wprowadź żądany tekst hologramu na czacie. &r(Kody kolorów są obsługiwane!)" + inventory-title: Edytor hologramów + ELEVATOR: + no-destinations: "&4Nie znaleziono miejsc docelowych" + pick-a-floor: "&3- Wybierz piętro-" + current-floor: "&eTo jest piętro, na którym aktualnie jesteś:" + click-to-teleport: "&eKliknij &7aby teleportować się na to piętro:" + enter-name: "&7Wprowadź żądaną nazwę piętra na czacie. &r(Kody kolorów są obsługiwane!)" + named: "&2Pomyślnie nazwano podłogę: &r% floor%" + TELEPORTER: + teleporting: "&3Teleportuje..." + teleported: "&3Przeteleportowano!" + cancelled: "&4Teleportacja anulowana!" + invulnerability: "&b&l Otrzymałeś(-aś) 30 sekund Niewrażliwości!" + gui: + title: Twoje punkty trasy + tooltip: Kliknij, aby się teleportować + time: Szacowany czas + CARGO_NODES: + must-be-placed: "&4Musi być umieszczony na skrzyni lub maszynie!" + GPS_CONTROL_PANEL: + title: GPS - Panel sterowania + transmitters: Transmiter Przegląd + waypoints: Waypoint Przegląd +anvil: + not-working: "&4Nie możesz używać przedmiotów Slimefun w kowadle!" +backpack: + already-open: "&cPrzepraszamy, ten plecak jest otwarty gdzie indziej!" + no-stack: "&cNie możesz stakować plecaków" workbench: not-enhanced: "&4Nie można używać przedmiotów Slimefun w zwykłym stole warsztatowym" +gps: + deathpoint: "&4Punkt śmierci &7%date%" + waypoint: + new: "&eProszę wpisać nazwę swojego nowego punktu trasy na czacie. &7(Kody kolorów + są obsługiwane!)" + added: "&aPomyślnie dodano nowy punkt trasy" + max: "&4Osiągnięto maksymalną liczbę punktów trasy" + insufficient-complexity: + - "&4Niewystarczająca złożoność sieci GPS: &c%complexity%" + - "&4a) Nie masz jeszcze skonfigurowanej sieci GPS" + - "&4b) Twoja sieć GPS nie jest wystarczająco złożona" + geo: + scan-required: "&4Wymagany jest skan GEO-Skan! &cNajpierw zeskanuj ten fragment + za pomocą skanera GEO!" +inventory: + no-access: "&4Nie masz dostępu do tego bloku" +android: + started: "&7Twój Android wznowił swój skrypt" + stopped: "&7Twój Android wstrzymał swój skrypt" + scripts: + already-uploaded: "&4Ten skrypt został już przesłany." + instructions: + START: "&2Uruchom skrypt" + REPEAT: "&9 Powtórz skrypt" + WAIT: "&ePoczekaj 0.5s" + GO_FORWARD: "&7Idź do przodu" + GO_UP: "&7Idź do góry" + GO_DOWN: "&7Idź w dół" + TURN_LEFT: "&7Skręć w lewo" + TURN_RIGHT: "&7Skręć w prawo" + DIG_UP: "&bKop w górę" + DIG_FORWARD: "&bKop do przodu" + DIG_DOWN: "&bKop w dół" + MOVE_AND_DIG_UP: "&bIdź i kop w górę" + MOVE_AND_DIG_FORWARD: "&bIdź i kop do przodu" + MOVE_AND_DIG_DOWN: "&bIdź i kop w dół" + ATTACK_MOBS_ANIMALS: "&4Atakuj &c(Wrogie Moby i Zwierzęta)" + ATTACK_MOBS: "&4Atakuj &c(Wrogie Moby)" + ATTACK_ANIMALS: "&4Atakuj &c(Zwierzęta)" + ATTACK_ANIMALS_ADULT: "&4Atakuj &c(Zwierzęta &7[Dorosłe]&c)" + CHOP_TREE: "&cTnij drzewo i posadź sadzonkę" + CATCH_FISH: "&bŁów ryby" + FARM_FORWARD: "&bZbieraj i posadź z powrotem" + FARM_DOWN: "&bZbieraj i posadź z powrotem &7(Blok pod spodem)" + FARM_EXOTIC_FORWARD: "&6Zaawansowanie zbieraj i posadź z powrotem" + FARM_EXOTIC_DOWN: "&bZaawansowanie zbieraj i posadź z powrotem &7(Blok pod spodem)" + INTERFACE_ITEMS: "&9Wyślij zawartość ekwipunku do Interfejsu w obecnym kierunku" + INTERFACE_FUEL: "&cOtrzymaj paliwo z Interfejsu w obecnym kierunku" + enter-name: + - + - "&eProszę wpisać nazwę dla tego skryptu" + uploaded: + - "&bPrzesyłanie..." + - "&aPomyślnie przesłano twój skrypt!" + rating: + own: "&4Nie możesz ocenić własnego skryptu!" + already: "&4Oceniłeś już ten skrypt!" + editor: Edytor skryptów +languages: + default: Domyślny serwera + en: Język angielski + de: Niemiecki + fr: Francuski + it: Włoski + es: Hiszpański + pl: Polski + sv: Szwedzki + nl: Holenderski + cs: Czeski + hu: Węgierski + lv: Łotewski + ru: Rosyjski + sk: Słowacki + zh-TW: Chiński (Tajwan) + vi: Wietnamski + id: Indonezyjski + zh-CN: Chiński (Chiny) + el: Grecki + he: Hebrajski + pt-BR: Portugalski (Brazylia) + ar: Arabski (Arabic) + af: Afrykański (Afrikaans) + da: Duński (Danish) + fi: Fiński (Finnish) + uk: Ukraiński (Ukrainian) + ms: Malajski (Malay) + 'no': Norweski + ja: Japonia + fa: Perski + th: Tajski + ro: Rumuński + pt: Portugalski (Portugalia) + bg: Bułgarski + ko: Koreański + tr: Turecki +miner: + no-ores: "&eNie można znaleźć żadnych rud w pobliżu!" diff --git a/src/main/resources/languages/recipes_hu.yml b/src/main/resources/languages/recipes_hu.yml index 4ded3545d..1992ade71 100644 --- a/src/main/resources/languages/recipes_hu.yml +++ b/src/main/resources/languages/recipes_hu.yml @@ -1,145 +1,107 @@ --- -minecraft: - blasting: - lore: - - Olvaszd meg ezt a tárgyat egy Kohóban, - - hogy elkészítsd a kívánt tárgyat - name: Kohó Recept - campfire: - lore: - - Olvaszd meg ezt a tárgyat egy Tábortűzön, - - hogy elkészítsd a kívánt tárgyat - name: Tábortűz Recept - furnace: - lore: - - Olvaszd meg ezt a tárgyat egy Kemencében, - - hogy elkészítsd a kívánt tárgyat - name: Kemence Recept - shaped: - lore: - - Készítsd el ezt a Tárgyat az ábra alapján - - egy Normális Barkácsasztal segítségével. - - A forma fontos. - name: Barkácsrecept Forma - shapeless: - lore: - - Készítsd el ezt a Tárgyat az ábra alapján - - egy Normális Barkácsasztal segítségével. - - Ez a Recept forma nélküli. - name: Forma Nélküli Barkácsrecept - smoking: - lore: - - Olvaszd meg ezt a tárgyat egy Füstölőben, - - hogy elkészítsd a kívánt tárgyat - name: Füstölő Recept - stonecutting: - lore: - - Készítsd el ezt a Tárgyat az ábra alapján - - egy Kővágó segítségével - name: Kővágó Recept slimefun: - ancient_altar: + multiblock: + name: Multiblock lore: - - Készítsd el ezt a Tárgyat az ábra alapján - - egy Ancient Altar segítségével. - - Keress utána az Ancient Altar-nak a további információkért - name: Ancient Altar - armor_forge: - lore: - - Készítsd el ezt a Tárgyat az ábra alapján - - egy Armor Forge segítségével - name: Armor Forge - compressor: - lore: - - Készítsd el ezt a Tárgyat az ábra alapján - - egy Compressor segítségével - name: Compressor + - Építsd meg a látott szerkezetet + - az ábra alapján. Ez nem barkácsolás. enhanced_crafting_table: + name: Enhanced Crafting Table lore: - Készítsd el ezt a Tárgyat az ábra alapján - egy Enhanced Crafting Table-ben. - A normális Barkácsasztal nem lesz elegendő! - name: Enhanced Crafting Table - food_composter: + armor_forge: + name: Armor Forge lore: - Készítsd el ezt a Tárgyat az ábra alapján - - egy Food Composter segítségével - name: Food Composter - food_fabricator: - lore: - - Készítsd el ezt a Tárgyat az ábra alapján - - egy Food Fabricator segítségével - name: Food Fabricator - freezer: - lore: - - Készítsd el ezt a Tárgyat az ábra alapján - - egy Freezer segítségével - name: Freezer - geo_miner: - lore: - - Ez a tárgy összegyűjthető - - egy GEO Miner segítségével - name: GEO Miner - gold_pan: - lore: - - Használd az Gold Pan-t, - - hogy megszerezd ezt a tárgyat - name: Gold Pan + - egy Armor Forge segítségével grind_stone: + name: Grind Stone lore: - Készítsd el ezt a Tárgyat az ábra alapján - egy Grind Stone segítségével - name: Grind Stone - heated_pressure_chamber: - lore: - - Készítsd el ezt a Tárgyat az ábra alapján - - egy Heated Pressure Chamber segítségével - name: Heated Pressure Chamber - juicer: - lore: - - Készítsd el ezt a Gyümölcslevet az ábra alapján - - egy Juicer segítségével - name: Juicer - magic_workbench: - lore: - - Készítsd el ezt a Tárgyat az ábra alapján - - egy Magic Workbench segítségével - name: Magic Workbench - mob_drop: - lore: - - Öld meg ezt az Élőlényt, - - hogy megszerezd ezt a tárgyat - name: Mob Drop - multiblock: - lore: - - Építsd meg a látott szerkezetet - - az ábra alapján. Ez nem barkácsolás. - name: Multiblock - nuclear_reactor: - lore: - - Ez a tárgy mellékterméke - - a Nuclear Reactor működésének - name: Nuclear Reactor - ore_crusher: - lore: - - Készítsd el ezt a Tárgyat az ábra alapján - - egy Ore Crusher segítségével - name: Ore Crusher - ore_washer: - lore: - - Készítsd el ezt a Tárgyat az ábra alapján - - egy Ore Washer segítségével - name: Ore Washer - pressure_chamber: - lore: - - Készítsd el ezt a Tárgyat az ábra alapján - - egy Pressure Chamber segítségével - name: Pressure Chamber smeltery: + name: Smeltery lore: - Készítsd el ezt a Tárgyat az ábra alapján - egy Smeltery segítségével - name: Smeltery + ore_crusher: + name: Ore Crusher + lore: + - Készítsd el ezt a Tárgyat az ábra alapján + - egy Ore Crusher segítségével + mob_drop: + name: Mob Drop + lore: + - Öld meg ezt az Élőlényt, + - hogy megszerezd ezt a tárgyat + gold_pan: + name: Gold Pan + lore: + - Használd az Gold Pan-t, + - hogy megszerezd ezt a tárgyat + compressor: + name: Compressor + lore: + - Készítsd el ezt a Tárgyat az ábra alapján + - egy Compressor segítségével + pressure_chamber: + name: Pressure Chamber + lore: + - Készítsd el ezt a Tárgyat az ábra alapján + - egy Pressure Chamber segítségével + ore_washer: + name: Ore Washer + lore: + - Készítsd el ezt a Tárgyat az ábra alapján + - egy Ore Washer segítségével + juicer: + name: Juicer + lore: + - Készítsd el ezt a Gyümölcslevet az ábra alapján + - egy Juicer segítségével + magic_workbench: + name: Magic Workbench + lore: + - Készítsd el ezt a Tárgyat az ábra alapján + - egy Magic Workbench segítségével + ancient_altar: + name: Ancient Altar + lore: + - Készítsd el ezt a Tárgyat az ábra alapján + - egy Ancient Altar segítségével. + - Keress utána az Ancient Altar-nak a további információkért + heated_pressure_chamber: + name: Heated Pressure Chamber + lore: + - Készítsd el ezt a Tárgyat az ábra alapján + - egy Heated Pressure Chamber segítségével + food_fabricator: + name: Food Fabricator + lore: + - Készítsd el ezt a Tárgyat az ábra alapján + - egy Food Fabricator segítségével + food_composter: + name: Food Composter + lore: + - Készítsd el ezt a Tárgyat az ábra alapján + - egy Food Composter segítségével + freezer: + name: Freezer + lore: + - Készítsd el ezt a Tárgyat az ábra alapján + - egy Freezer segítségével + geo_miner: + name: GEO Miner + lore: + - Ez a tárgy összegyűjthető + - egy GEO Miner segítségével + nuclear_reactor: + name: Nuclear Reactor + lore: + - Ez a tárgy mellékterméke + - a Nuclear Reactor működésének oil_pump: name: Oil Pump lore: @@ -156,3 +118,46 @@ slimefun: lore: - Készítsd el ezt a Tárgyat az ábra alapján - egy Refinery segítségével +minecraft: + shaped: + name: Barkácsrecept Forma + lore: + - Készítsd el ezt a Tárgyat az ábra alapján + - egy Normális Barkácsasztal segítségével. + - A forma fontos. + shapeless: + name: Forma Nélküli Barkácsrecept + lore: + - Készítsd el ezt a Tárgyat az ábra alapján + - egy Normális Barkácsasztal segítségével. + - Ez a Recept forma nélküli. + furnace: + name: Kemence Recept + lore: + - Olvaszd meg ezt a tárgyat egy Kemencében, + - hogy elkészítsd a kívánt tárgyat + blasting: + name: Kohó Recept + lore: + - Olvaszd meg ezt a tárgyat egy Kohóban, + - hogy elkészítsd a kívánt tárgyat + smoking: + name: Füstölő Recept + lore: + - Olvaszd meg ezt a tárgyat egy Füstölőben, + - hogy elkészítsd a kívánt tárgyat + campfire: + name: Tábortűz Recept + lore: + - Olvaszd meg ezt a tárgyat egy Tábortűzön, + - hogy elkészítsd a kívánt tárgyat + stonecutting: + name: Kővágó Recept + lore: + - Készítsd el ezt a Tárgyat az ábra alapján + - egy Kővágó segítségével + smithing: + name: Kovácsasztal Recept + lore: + - Készítsd el ezt a Tárgyat az ábra alapján + - egy Kovácsasztal segítségével diff --git a/src/main/resources/languages/recipes_ja.yml b/src/main/resources/languages/recipes_ja.yml index c7ceb72c6..3a482d34f 100644 --- a/src/main/resources/languages/recipes_ja.yml +++ b/src/main/resources/languages/recipes_ja.yml @@ -1,158 +1,163 @@ --- -minecraft: - blasting: - lore: - - このアイテムの精錬に使用する - - '機械: 溶鉱炉' - name: 溶鉱炉での精錬 - campfire: - lore: - - このアイテムの精錬に使用する - - '機械: 焚き火' - name: 焚き火 - furnace: - lore: - - このアイテムの精錬に使用する - - '機械: かまど' - name: かまどでの精錬 - shaped: - lore: - - このアイテムの作成に使用する - - '機械: 作業台' - - 並べ方は固定 - name: 定形レシピ - shapeless: - lore: - - このアイテムの作成に使用する - - '機械: 作業台' - - 並べ方は自由 - name: 不定形レシピ - smoking: - lore: - - このアイテムの燻製に使用する - - '機械: 燻製器' - name: 燻製器 - stonecutting: - lore: - - このアイテムの作成に使用する - - '機械: 石切台' - name: 石切台 slimefun: - ancient_altar: + multiblock: + name: マルチブロック lore: - - このアイテムの作成に使用する - - '機械: Ancient Altar' - - 詳細はAncient Altarに記載 - name: Ancient Altar - armor_forge: - lore: - - このアイテムの作成に使用する - - '機械: Armor Forge' - name: Armor Forge - compressor: - lore: - - このアイテムの作成に使用する - - '機械: Compressor' - name: Compressor + - 図面通りに設置して建造する。 + - クラフトではありません! enhanced_crafting_table: + name: Enhanced Crafting Table lore: - このアイテムの作成に使用する - '機械: Enhanced Crafting Table' - 通常の作業台では不十分です! - name: Enhanced Crafting Table - food_composter: + armor_forge: + name: Armor Forge lore: - このアイテムの作成に使用する - - '機械: Food Composter' - name: Food Composter - food_fabricator: - lore: - - このアイテムの作成に使用する - - '機械: Food Fabricator' - name: Food Fabricator - freezer: - lore: - - このアイテムの作成に使用する - - '機械: Freezer' - name: Freezer - geo_miner: - lore: - - このアイテムの採掘に使用する - - '機械: GEO Miner' - name: GEO Miner - gold_pan: - lore: - - このアイテムの入手に使用する - - '機械: Gold Pan' - name: Gold Pan + - '機械: Armor Forge' grind_stone: + name: Grind Stone lore: - このアイテムの作成に使用する - '機械: Grind Stone' - name: Grind Stone - heated_pressure_chamber: + smeltery: + name: Smeltery lore: - このアイテムの作成に使用する - - '機械: Heated Pressure Chamber' - name: Heated Pressure Chamber - juicer: - lore: - - このジュースの作成に使用する - - '機械: Juicer' - name: Juicer - magic_workbench: - lore: - - このアイテムの作成に使用する - - '機械: Magic Workbench' - name: Magic Workbench - mob_drop: - lore: - - モブを倒して - - 入手するアイテム - name: モブドロップ - multiblock: - lore: - - 図面通りに設置して - - 建造する。クラフトではありません! - name: マルチブロック - nuclear_reactor: - lore: - - このアイテムを副産物として入手できる - - '機械: Nuclear Reactor' - name: Nuclear Reactor - oil_pump: - lore: - - このアイテムの収集に使用する - - '機械: Oil Pump' - name: Oil Pump + - '機械: Smeltery' ore_crusher: + name: Ore Crusher lore: - このアイテムの作成に使用する - '機械: Ore Crusher' - name: Ore Crusher + mob_drop: + name: モブドロップ + lore: + - モブを倒して + - 入手するアイテム + gold_pan: + name: Gold Pan + lore: + - このアイテムの入手に使用する + - '機械: Gold Pan' + compressor: + name: Compressor + lore: + - このアイテムの作成に使用する + - '機械: Compressor' + pressure_chamber: + name: Pressure Chamber + lore: + - このアイテムの作成に使用する + - '機械: Pressure Chamber' ore_washer: + name: Ore Washer lore: - このアイテムの作成に使用する - '機械: Ore Washer' - name: Ore Washer + juicer: + name: Juicer + lore: + - このジュースの作成に使用する + - '機械: Juicer' + magic_workbench: + name: Magic Workbench + lore: + - このアイテムの作成に使用する + - '機械: Magic Workbench' + ancient_altar: + name: Ancient Altar + lore: + - このアイテムの作成に使用する + - '機械: Ancient Altar' + - 詳細はAncient Altarに記載 + heated_pressure_chamber: + name: Heated Pressure Chamber + lore: + - このアイテムの作成に使用する + - '機械: Heated Pressure Chamber' + food_fabricator: + name: Food Fabricator + lore: + - このアイテムの作成に使用する + - '機械: Food Fabricator' + food_composter: + name: Food Composter + lore: + - このアイテムの作成に使用する + - '機械: Food Composter' + freezer: + name: Freezer + lore: + - このアイテムの作成に使用する + - '機械: Freezer' + geo_miner: + name: GEO Miner + lore: + - このアイテムの採掘に使用する + - '機械: GEO Miner' + nuclear_reactor: + name: Nuclear Reactor + lore: + - このアイテムを副産物として入手できる + - '機械: Nuclear Reactor' + oil_pump: + name: Oil Pump + lore: + - このアイテムの収集に使用する + - '機械: Oil Pump' pickaxe_of_containment: + name: Pickaxe of Containment lore: - このブロックを入手するには - Pickaxe of Containmentを - 使用してスポナーを採掘する - name: Pickaxe of Containment - pressure_chamber: - lore: - - このアイテムの作成に使用する - - '機械: Pressure Chamber' - name: Pressure Chamber refinery: + name: Refinery lore: - このアイテムの作成に使用する - '機械: Refinery' - name: Refinery - smeltery: +minecraft: + shaped: + name: 定形レシピ lore: - このアイテムの作成に使用する - - '機械: Smeltery' - name: Smeltery + - '機械: 作業台' + - 並べ方は固定 + shapeless: + name: 不定形レシピ + lore: + - このアイテムの作成に使用する + - '機械: 作業台' + - 並べ方は自由 + furnace: + name: かまどでの精錬 + lore: + - このアイテムの精錬に使用する + - '機械: かまど' + blasting: + name: 溶鉱炉での精錬 + lore: + - このアイテムの精錬に使用する + - '機械: 溶鉱炉' + smoking: + name: 燻製器 + lore: + - このアイテムの燻製に使用する + - '機械: 燻製器' + campfire: + name: 焚き火 + lore: + - このアイテムの精錬に使用する + - '機械: 焚き火' + stonecutting: + name: 石切台 + lore: + - このアイテムの作成に使用する + - '機械: 石切台' + smithing: + name: 鍛冶台 + lore: + - このアイテムの作成に使用する + - '機械: 鍛冶台' diff --git a/src/main/resources/languages/researches_en.yml b/src/main/resources/languages/researches_en.yml index 0eb6daa45..a7fd0f8f0 100644 --- a/src/main/resources/languages/researches_en.yml +++ b/src/main/resources/languages/researches_en.yml @@ -238,3 +238,5 @@ slimefun: climbing_pick: Block Raider enchantment_rune: Ancient Enchanting lead_clothing: Lead Clothing + tape_measure: Tape Measure + iron_golem_assembler: Automated Iron Golems diff --git a/src/main/resources/languages/researches_hu.yml b/src/main/resources/languages/researches_hu.yml index 21165e6ea..6ae319fe9 100644 --- a/src/main/resources/languages/researches_hu.yml +++ b/src/main/resources/languages/researches_hu.yml @@ -1,234 +1,238 @@ --- slimefun: - 24k_gold_block: Aranyváros - advanced_android: Speciális Androidok - advanced_butcher_android: Fejlett Androidok - Hentes - advanced_circuit_board: Fejlett Áramköri Lap - advanced_electric_smeltery: Fejlett Elektromos Olvasztómű - advanced_farmer_android: Fejlett Androidok - Farmer - advanced_fisherman_android: Fejlett Androidok - Halász - advanced_output_node: Speciális Kimeneti Csomópont - alloys: Speciális Ötvözetek - ancient_altar: Ősi Oltár - ancient_runes: Elemi Rúnák - android_interfaces: Android Csatlakozási Felületek - android_memory_core: Memóriamag - angel_talisman: Az Angyal Talizmánja - animal_growth_accelerator: Az állatok Növekedésének Manipulálása - anvil_talisman: Az Üllő Talizmánja - armored_jetboots: Páncélozott Sugárhajtású Csizmák - armored_jetpack: Páncélozott Jetpack + walking_sticks: Sétapálcák + portable_crafter: Hordozható Barkácsoló + fortune_cookie: Szerencsesüti + portable_dustbin: Hordozható Kuka + meat_jerky: Pácolt Hús armor_forge: Páncél Barkácsolás - auto_anvil: Automatikus Üllő - auto_breeder: Automatizált Etetés - auto_drier: Egy Száraz Nap - auto_enchanting: Automatikus Fejlesztés és Fejlesztés Törlés - automated_crafting_chamber: Automatizált Barkácsolás - automated_panning_machine: Automatizált Aranymosó - automatic_ignition_chamber: Automatikus Gyújtókamra - backpacks: Hátizsákok + glowstone_armor: Izzókő Páncél + lumps: Rögök és Varázslat + ender_backpack: Ender Hátizsák + ender_armor: Ender Páncél + magic_eye_of_ender: Varázslatos Ender Szeme + magic_sugar: Varázscukor + monster_jerky: Pácolt Szörnyhús + slime_armor: Nyálka Páncél + sword_of_beheading: Lefejezés Kardja basic_circuit_board: Alapvető Áramköri Lap + advanced_circuit_board: Fejlett Áramköri Lap + smeltery: Kohó + steel: Acélkor + misc_power_items: Fontos energiával kapcsolatos tárgyak battery: Az első Akkumulátorod - better_carbon_press: Továbbfejlesztett Szénprés - better_crop_growth_accelerator: Továbbfejlesztett Növény Növekedés Gyorsító - better_electric_crucibles: Forró Olvasztótégelyek - better_electric_furnace: Továbbfejlesztett Elektromos Kemence - better_food_fabricator: Továbbfejlesztett Élelmiszergyártás - better_freezer: Továbbfejlesztett Fagyasztó - better_gps_transmitters: Továbbfejlesztett Transzmitterek - better_heated_pressure_chamber: Továbbfejlesztett Fűtött Nyomású Kamra - better_solar_generators: Továbbfejlesztett Napelemes Generátorok - bio_reactor: Bioreaktor - blade_of_vampires: Vámpírok Pengéje - blistering_ingots: Hólyagos Radioaktivitás - block_placer: Blokk Lehelyező - boosted_uranium: Soha Véget Nem Érő Kör - boots_of_the_stomper: A Taposás Cipője - bound_armor: Lélekhez Kötött Páncél - bound_backpack: Lélekhez Kötött Tárolás - bound_tools: Lélélekhez Kötött Eszközök - bound_weapons: Lélekhez Kötött Fegyverek - bronze: Bronzkészítés - butcher_androids: Hentes Androidok + steel_plate: Acéllemez + steel_thruster: Acélhajtómű + parachute: Ejtőernyő + grappling_hook: Vasmacska + jetpacks: Jetpackek + multitools: Többfunkciós Eszközök + solar_panel_and_helmet: Napenergia + elemental_staff: Elemi Pálcák + grind_stone: Köszörűkő cactus_armor: Kaktusz Ruha - capacitors: 1. Szintű Kondenzátorok - carbonado: Fekete Gyémántok - carbonado_furnace: Karbonádó Szélű Kemence - carbonado_tools: Felső Szintű Gépek - carbon_press: Szénprés - cargo_basics: Szállítmány Alapjai - cargo_nodes: Szállítmány Beállítása - chainmail_armor: Lánc Páncél - charging_bench: Töltőpad - coal_generator: Széngenerátor - cobalt_pickaxe: Gyors Csákány - combustion_reactor: Égésreaktor - common_talisman: Gyakori Talizmán - composter: Föld Komposztáló + gold_pan: Aranymosó + magical_book_cover: Varázslatos Könyvkötés + slimefun_metals: Új Fémek + ore_crusher: Érc Duplázás + bronze: Bronzkészítés + alloys: Speciális Ötvözetek compressor_and_carbon: Szénkészítés - cooler: Hordozható Italok - copper_wire: Hígított Vezetőképesség - crop_growth_accelerator: Növény Növekedés Gyorsító - crucible: Olvasztótégely - crushed_ore: Ércek Tisztítása + gilded_iron_armor: Aranyozott Vaspáncél + synthetic_diamond: Szintetikus Gyémántok + pressure_chamber: Nyomáskamra + synthetic_sapphire: Szintetikus Zafírok damascus_steel: Damaszkuszi Acél damascus_steel_armor: Damaszkuszi Acél Páncél - diet_cookie: Diétás Süti - duct_tape: Szövetbetétes Ragasztószalag - electric_crucible: Elektromos Olvasztótégely - electric_furnaces: Erős Kemence - electric_ingot_machines: Elektromos Öntvénygyártás + reinforced_alloy: Megerősített Ötvözet + carbonado: Fekete Gyémántok + magic_workbench: Varázslatos Barkácsasztal + wind_staff: Szél Pálca + reinforced_armor: Megerősített Páncél + ore_washer: Ércmosó + gold_carats: Tiszta Arany + silicon: Szilícium-völgy + fire_staff: Tűz Pálca + smelters_pickaxe: Olvasztó Csákány + common_talisman: Gyakori Talizmán + anvil_talisman: Az Üllő Talizmánja + miner_talisman: A Bányász Talizmánja + hunter_talisman: A Vadász Talizmánja + lava_talisman: A Láva Járó Talizmánja + water_talisman: A Vízlélegzés Talizmánja + angel_talisman: Az Angyal Talizmánja + fire_talisman: A Tűzoltó Talizmánja + lava_crystal: Tüzes Helyzet + magician_talisman: A Bűvész Talizmánja + traveller_talisman: Az Utazó Talizmánja + warrior_talisman: A Harcos Talizmánja + knight_talisman: A Lovag Talizmánja + gilded_iron: Fényes Vas + synthetic_emerald: Hamis Drágakő + chainmail_armor: Lánc Páncél + whirlwind_talisman: A Forgószél Talizmánja + wizard_talisman: A Varázsló Talizmánja + lumber_axe: Fadöntő Fejsze + hazmat_suit: Vegyvédelmi Ruha + uranium: Radioaktív + crushed_ore: Ércek Tisztítása + redstone_alloy: Redstone Ötvözet + carbonado_tools: Felső Szintű Gépek + first_aid: Elsősegély + gold_armor: Fényes Páncél + night_vision_googles: Éjjellátó Szemüvegek + pickaxe_of_containment: Csomagtartó Csákány + hercules_pickaxe: Herkules Csákány + table_saw: Asztali Fűrész + slime_steel_armor: Nyálkás Acél Páncél + blade_of_vampires: Vámpírok Pengéje + water_staff: Víz Pálca + 24k_gold_block: Aranyváros + composter: Föld Komposztáló + farmer_shoes: Farmer Cipők + explosive_tools: Robbanóeszközök + automated_panning_machine: Automatizált Aranymosó + boots_of_the_stomper: A Taposás Cipője + pickaxe_of_the_seeker: A Kutatók Csákánya + backpacks: Hátizsákok + woven_backpack: Szőtt Hátizsák + crucible: Olvasztótégely + gilded_backpack: Aranyozott Hátizsák + armored_jetpack: Páncélozott Jetpack + ender_talismans: Ender Talizmánok + nickel_and_cobalt: Még több Érc + magnet: Mágneses Fémek + infused_magnet: Infúziós Mágnesek + cobalt_pickaxe: Gyors Csákány + essence_of_afterlife: Szellemidézés + bound_backpack: Lélekhez Kötött Tárolás + jetboots: Sugárhajtású Csizma + armored_jetboots: Páncélozott Sugárhajtású Csizmák + seismic_axe: Szeizmikus Fejsze + pickaxe_of_vein_mining: 'Ér Bányász Csákány ' + bound_weapons: Lélekhez Kötött Fegyverek + bound_tools: Lélélekhez Kötött Eszközök + bound_armor: Lélekhez Kötött Páncél + juicer: Ízletes Italok + repaired_spawner: Spawnerek Javítása + enhanced_furnace: Továbbfejlesztett Kemence + more_enhanced_furnaces: Jobb Kemencék + high_tier_enhanced_furnaces: Magas Szintű Kemence + reinforced_furnace: Megerősített Kemence + carbonado_furnace: Karbonádó Szélű Kemence electric_motor: Felmelegítés + block_placer: Blokk Lehelyező + scroll_of_dimensional_teleposition: Megfordítva a dolgokat + special_bows: Robin Hood + tome_of_knowledge_sharing: Megosztás a barátokkal + flask_of_knowledge: XP Tároló + hardened_glass: Robbanások Ellen + golden_apple_juice: Arany Főzet + cooler: Hordozható Italok + ancient_altar: Ősi Oltár + wither_proof_obsidian: Wither-Védett Obszidián + ancient_runes: Elemi Rúnák + special_runes: Lila Rúnák + infernal_bonemeal: Pokoli Csontliszt + rainbow_blocks: Szivárvány Blokkok + infused_hopper: Pokoli Tölcsér + wither_proof_glass: Wither-Védett Üveg + duct_tape: Szövetbetétes Ragasztószalag + plastic_sheet: Műanyag + android_memory_core: Memóriamag + oil: Olaj + fuel: Üzemanyag + hologram_projector: Hologramok + capacitors: 1. Szintű Kondenzátorok + high_tier_capacitors: 2. Szintű Kondenzátorok + solar_generators: Napenergia Erőmű + electric_furnaces: Erős Kemence electric_ore_grinding: Zúzás és Őrlés - electric_press: Elektromos Prés - electric_smeltery: Elektromos Olvasztó - elemental_staff: Elemi Pálcák + heated_pressure_chamber: Fűtött Nyomáskamra + coal_generator: Széngenerátor + bio_reactor: Bioreaktor + auto_enchanting: Automatikus Fejlesztés és Fejlesztés Törlés + auto_anvil: Automatikus Üllő + multimeter: Teljesítménymérés + gps_setup: Alapvető GPS Beállítás + gps_emergency_transmitter: GPS Vészhelyzeti Útpont + programmable_androids: Programozható Androidok + android_interfaces: Android Csatlakozási Felületek + geo_scanner: GEO-Vizsgálatok + combustion_reactor: Égésreaktor + teleporter: Teleportáló Alapelemek + teleporter_activation_plates: Teleportáló Aktiválás + better_solar_generators: Továbbfejlesztett Napelemes Generátorok + better_gps_transmitters: Továbbfejlesztett Transzmitterek elevator: Liftek - elytra: Kitinszárnyak + energized_solar_generator: Teljes-Munkaidős Napenergia + energized_gps_transmitter: Legfelső Szintű Transzmitter + energy_regulator: Energiahálózatok 101 + butcher_androids: Hentes Androidok + organic_food: Bioélelmiszerek + auto_breeder: Automatizált Etetés + advanced_android: Speciális Androidok + advanced_butcher_android: Fejlett Androidok - Hentes + advanced_fisherman_android: Fejlett Androidok - Halász + animal_growth_accelerator: Az állatok Növekedésének Manipulálása + xp_collector: XP Gyűjtő + organic_fertilizer: Organikus Trágya + crop_growth_accelerator: Növény Növekedés Gyorsító + better_crop_growth_accelerator: Továbbfejlesztett Növény Növekedés Gyorsító + reactor_essentials: Reaktor Alapjai + nuclear_reactor: Atomerőmű + freezer: Fagyasztó Úr + cargo_basics: Szállítmány Alapjai + cargo_nodes: Szállítmány Beállítása + electric_ingot_machines: Elektromos Öntvénygyártás + high_tier_electric_ingot_machines: Szupergyors Öntvénygyártás + automated_crafting_chamber: Automatizált Barkácsolás + better_food_fabricator: Továbbfejlesztett Élelmiszergyártás + reactor_access_port: Reaktor Kölcsönhatás + fluid_pump: Folyadék Szivattyú + better_freezer: Továbbfejlesztett Fagyasztó + boosted_uranium: Soha Véget Nem Érő Kör + trash_can: Szemetes + advanced_output_node: Speciális Kimeneti Csomópont + carbon_press: Szénprés + electric_smeltery: Elektromos Olvasztó + better_electric_furnace: Továbbfejlesztett Elektromos Kemence + better_carbon_press: Továbbfejlesztett Szénprés empowered_android: Felhatalmazott Androidok empowered_butcher_android: Felhatalmazott Androidok - Hentes empowered_fisherman_android: Felhatalmazott Androidok - Halász - ender_armor: Ender Páncél - ender_backpack: Ender Hátizsák - ender_talismans: Ender Talizmánok - energized_gps_transmitter: Legfelső Szintű Transzmitter - energized_solar_generator: Teljes-Munkaidős Napenergia - energy_regulator: Energiahálózatok 101 - enhanced_furnace: Továbbfejlesztett Kemence - essence_of_afterlife: Szellemidézés - explosive_tools: Robbanóeszközök - farmer_shoes: Farmer Cipők - fire_staff: Tűz Pálca - fire_talisman: A Tűzoltó Talizmánja - first_aid: Elsősegély - flask_of_knowledge: XP Tároló - fluid_pump: Folyadék Szivattyú - fortune_cookie: Szerencsesüti - freezer: Fagyasztó Úr - fuel: Üzemanyag - geo_miner: GEO-Bányász - geo_scanner: GEO-Vizsgálatok - gilded_backpack: Aranyozott Hátizsák - gilded_iron: Fényes Vas - gilded_iron_armor: Aranyozott Vaspáncél - glowstone_armor: Izzókő Páncél - gold_armor: Fényes Páncél - gold_carats: Tiszta Arany - golden_apple_juice: Arany Főzet - gold_pan: Aranymosó - gps_emergency_transmitter: GPS Vészhelyzeti Útpont - gps_setup: Alapvető GPS Beállítás - grappling_hook: Vasmacska - grind_stone: Köszörűkő - hardened_glass: Robbanások Ellen - hazmat_suit: Vegyvédelmi Ruha - heated_pressure_chamber: Fűtött Nyomáskamra - hercules_pickaxe: Herkules Csákány - high_tier_capacitors: 2. Szintű Kondenzátorok high_tier_carbon_press: Végleges Szénprés - high_tier_electric_ingot_machines: Szupergyors Öntvénygyártás - high_tier_enhanced_furnaces: Magas Szintű Kemence - hologram_projector: Hologramok - hunter_talisman: A Vadász Talizmánja - infernal_bonemeal: Pokoli Csontliszt - infused_hopper: Pokoli Tölcsér - infused_magnet: Infúziós Mágnesek - jetboots: Sugárhajtású Csizma - jetpacks: Jetpackek - juicer: Ízletes Italok - kelp_cookie: Ízletes Moszat - knight_talisman: A Lovag Talizmánja - lava_crystal: Tüzes Helyzet + wither_assembler: Automatizált Wither Ölő + better_heated_pressure_chamber: Továbbfejlesztett Fűtött Nyomású Kamra + elytra: Kitinszárnyak + special_elytras: Speciális Kitinszárnyak + electric_crucible: Elektromos Olvasztótégely + better_electric_crucibles: Forró Olvasztótégelyek + advanced_electric_smeltery: Fejlett Elektromos Olvasztómű + advanced_farmer_android: Fejlett Androidok - Farmer lava_generator: Lávagenerátor - lava_talisman: A Láva Járó Talizmánja - lightning_rune: Villám Rúna - lumber_axe: Fadöntő Fejsze - lumps: Rögök és Varázslat - magical_book_cover: Varázslatos Könyvkötés - magic_eye_of_ender: Varázslatos Ender Szeme - magician_talisman: A Bűvész Talizmánja - magic_sugar: Varázscukor - magic_workbench: Varázslatos Barkácsasztal - magnesium_generator: Energia Magnéziumból - magnet: Mágneses Fémek - meat_jerky: Pácolt Hús - miner_talisman: A Bányász Talizmánja - misc_power_items: Fontos energiával kapcsolatos tárgyak - monster_jerky: Pácolt Szörnyhús - more_enhanced_furnaces: Jobb Kemencék - multimeter: Teljesítménymérés - multitools: Többfunkciós Eszközök - nether_gold_pan: Nether Aranymosó nether_ice: Nether Jéghűtő nether_star_reactor: Nethercsillag Reaktor - nickel_and_cobalt: Még több Érc - night_vision_googles: Éjjellátó Szemüvegek - nuclear_reactor: Atomerőmű - oil: Olaj - ore_crusher: Érc Duplázás - ore_washer: Ércmosó - organic_fertilizer: Organikus Trágya - organic_food: Bioélelmiszerek + blistering_ingots: Hólyagos Radioaktivitás + automatic_ignition_chamber: Automatikus Gyújtókamra output_chest: Alapvető Gépek Kimeneti Láda - parachute: Ejtőernyő - pickaxe_of_containment: Csomagtartó Csákány - pickaxe_of_the_seeker: A Kutatók Csákánya - pickaxe_of_vein_mining: 'Ér Bányász Csákány ' - plastic_sheet: Műanyag - portable_crafter: Hordozható Barkácsoló - portable_dustbin: Hordozható Kuka - pressure_chamber: Nyomáskamra - programmable_androids: Programozható Androidok + copper_wire: Hígított Vezetőképesség radiant_backpack: Sugárzó Hátizsák - rainbow_blocks: Szivárvány Blokkok - reactor_access_port: Reaktor Kölcsönhatás - reactor_essentials: Reaktor Alapjai - redstone_alloy: Redstone Ötvözet - reinforced_alloy: Megerősített Ötvözet - reinforced_armor: Megerősített Páncél - reinforced_furnace: Megerősített Kemence - repaired_spawner: Spawnerek Javítása - scroll_of_dimensional_teleposition: Megfordítva a dolgokat - seismic_axe: Szeizmikus Fejsze - silicon: Szilícium-völgy - slime_armor: Nyálka Páncél - slimefun_metals: Új Fémek - slime_steel_armor: Nyálkás Acél Páncél - smelters_pickaxe: Olvasztó Csákány - smeltery: Kohó - solar_generators: Napenergia Erőmű - solar_panel_and_helmet: Napenergia - soulbound_rune: Lélekhez Kötött Rúna - special_bows: Robin Hood - special_elytras: Speciális Kitinszárnyak - special_runes: Lila Rúnák - steel: Acélkor - steel_plate: Acéllemez - steel_thruster: Acélhajtómű + auto_drier: Egy Száraz Nap + diet_cookie: Diétás Süti storm_staff: Vihar Pálca - sword_of_beheading: Lefejezés Kardja - synthetic_diamond: Szintetikus Gyémántok - synthetic_emerald: Hamis Drágakő - synthetic_sapphire: Szintetikus Zafírok - table_saw: Asztali Fűrész - teleporter: Teleportáló Alapelemek - teleporter_activation_plates: Teleportáló Aktiválás - tome_of_knowledge_sharing: Megosztás a barátokkal + soulbound_rune: Lélekhez Kötött Rúna + geo_miner: GEO-Bányász + lightning_rune: Villám Rúna totem_of_undying: Életmentés Toteme - trash_can: Szemetes - traveller_talisman: Az Utazó Talizmánja - uranium: Radioaktív - walking_sticks: Sétapálcák - warrior_talisman: A Harcos Talizmánja - water_staff: Víz Pálca - water_talisman: A Vízlélegzés Talizmánja - whirlwind_talisman: A Forgószél Talizmánja - wind_staff: Szél Pálca - wither_assembler: Automatizált Wither Ölő - wither_proof_glass: Wither-Védett Üveg - wither_proof_obsidian: Wither-Védett Obszidián - wizard_talisman: A Varázsló Talizmánja - woven_backpack: Szőtt Hátizsák - xp_collector: XP Gyűjtő + charging_bench: Töltőpad + nether_gold_pan: Nether Aranymosó + electric_press: Elektromos Prés + magnesium_generator: Energia Magnéziumból + kelp_cookie: Ízletes Moszat makeshift_smeltery: Improvizált Olvasztó tree_growth_accelerator: Gyorsabb Fák + industrial_miner: Ipari Bányászat + advanced_industrial_miner: Jobb Bányászat + magical_zombie_pills: Zombi Átváltoztató + auto_brewer: Ipari Sörgyár diff --git a/src/main/resources/languages/researches_pl.yml b/src/main/resources/languages/researches_pl.yml new file mode 100644 index 000000000..e31a805d3 --- /dev/null +++ b/src/main/resources/languages/researches_pl.yml @@ -0,0 +1,234 @@ +--- +slimefun: + walking_sticks: Ruchomy Patyk + portable_crafter: Przenośny Stół Rzemieślniczy + fortune_cookie: Ciastko z wróżbą + portable_dustbin: Przenośny Kosz + meat_jerky: Suszone Mięso + armor_forge: Tworzenie Zbroji + glowstone_armor: Jasnopyłowa Zbroja + lumps: Grudki i Magia + ender_backpack: Plecak Endu + ender_armor: Zbroja Endu + magic_eye_of_ender: Magiczne Oko Endera + magic_sugar: Magiczny Cukier + monster_jerky: 'Potworne Mięso ' + slime_armor: Szlamowa Zbroja + sword_of_beheading: Miecz Odcinania Głów + basic_circuit_board: Podstawowa Płyta Drukowana + advanced_circuit_board: Zaawansowana Płyta Drukowana + smeltery: Wytapiacz + steel: Epoka Stali + misc_power_items: Ważne przedmioty związane z prądem + battery: Twoja pierwsza bateria + steel_plate: Stalowa Blacha + steel_thruster: Stalowy Ster Strumieniowy + parachute: Spadochron + grappling_hook: Hak do Chwytania + jetpacks: Plecaki Odrzutowe + multitools: Narzędzia Wielofunkcyjne + solar_panel_and_helmet: Energia Słoneczna + elemental_staff: Drążki Żywiołów + grind_stone: Kamień Szliferski + cactus_armor: Kaktusowy Garnitur + gold_pan: Złota Patelnia + magical_book_cover: Magiczna Oprawa do Książek + slimefun_metals: Nowe Metale + ore_crusher: Kruszarka Rud + bronze: Tworzenie Bronzu + alloys: Zaawansowane Stopy + compressor_and_carbon: Tworzenie Węgla + gilded_iron_armor: Pozłacana Żelazna Zbroja + synthetic_diamond: Diamenty Syntetyczne + pressure_chamber: Komora Ciśnieniowa + synthetic_sapphire: Szafiry Syntetyczne + damascus_steel: Stal Damasceńska + damascus_steel_armor: Zbroja ze Stali Damasceńskiej + reinforced_alloy: Wzmocniony Stop + carbonado: Czarne Diamenty + magic_workbench: Magiczny Stół Rzemieślniczy + wind_staff: Laska Wiatru + reinforced_armor: Wzmocniona Zbroja + ore_washer: Zmywacz Rud + gold_carats: Czyste Złoto + silicon: Dolina Krzemowa + fire_staff: Laska Ognia + smelters_pickaxe: Kilof Hutniczy + common_talisman: Pospolity Talizman + anvil_talisman: Talizman Kowadła + miner_talisman: Talizman Górnika + hunter_talisman: Talizman Łowcy + lava_talisman: Talizman Chodzącego po Lawie + water_talisman: Talizman Oddychacza pod Wodą + angel_talisman: Talizman Anioła + fire_talisman: Talizman Strażaka + lava_crystal: Ogniowa Sytuacja + magician_talisman: Talizman Maga + traveller_talisman: Talizman Podróżnika + warrior_talisman: Talizman Wojownika + knight_talisman: Talizman Rycerza + gilded_iron: Błyszczące Żelazo + synthetic_emerald: Fałszywy Klejnot + chainmail_armor: Kolczuga + whirlwind_talisman: Talizman Wiatru + wizard_talisman: Talizman Czarnoksiężnika + lumber_axe: Siekiera Drwala + hazmat_suit: Kombinezon Materiałów Niebezpiecznych + uranium: Radioaktywny + crushed_ore: Oczyszczanie Rud + redstone_alloy: Stop Czerwonego Proszku + carbonado_tools: Maszyny na Najwyższym Poziomie + first_aid: Pierwsza Pomoc + gold_armor: Błyszcząca Zbroja + night_vision_googles: Gogle Noktowizyjne + pickaxe_of_containment: Kilof Przechowywania + hercules_pickaxe: Kilof Herkulesa + table_saw: Piła Stołowa + slime_steel_armor: Szlamowy Pancerz Stalowy + blade_of_vampires: Ostrze Wampirów + water_staff: Laska Wody + 24k_gold_block: Miasto ze Złota + composter: Kompostowanie Ziemi + farmer_shoes: Buty Rolnika + explosive_tools: Narzędzia Wybuchowe + automated_panning_machine: Zautomatyzowana Złota Patelnia + boots_of_the_stomper: Buty Stompera + pickaxe_of_the_seeker: Kilof Poszukiwacza + backpacks: Plecaki + woven_backpack: Pleciony Plecak + crucible: Tygiel + gilded_backpack: Pozłacany Plecak + armored_jetpack: Opancerzony Plecak Odrzutowy + ender_talismans: Talizmany Endera + nickel_and_cobalt: Jeszcze więcej Rud + magnet: Metale Magnetyczne + infused_magnet: Natchnione Magnesy + cobalt_pickaxe: Kobaltowy Kilof + essence_of_afterlife: Nekromancja + bound_backpack: Plecak Soulbound + jetboots: Buty Odrzutowe + armored_jetboots: Opancerzone Buty Odrzutowe + seismic_axe: Sejsmiczny Topór + pickaxe_of_vein_mining: Kilof z Żyły Górnictwa + bound_weapons: Bronie Soulbound + bound_tools: Narzędzia Soulbound + bound_armor: Soulbound Zbroja + juicer: Pyszne Drinki + repaired_spawner: Naprawianie Spawnerów + enhanced_furnace: Ulepszony Piec + more_enhanced_furnaces: Lepsze Piece + high_tier_enhanced_furnaces: Piec Wysokopoziomowy + reinforced_furnace: Wzmocniony Piec + carbonado_furnace: Karbonado Ostry Piec + electric_motor: Podgrzewać + block_placer: Blok Kładący + scroll_of_dimensional_teleposition: Odwracając rzeczy dookoła + special_bows: Robin Hood + tome_of_knowledge_sharing: Podziel się z Znajomym + flask_of_knowledge: Przechowywacz Expa + hardened_glass: Wytrzymałość na Wybuchy + golden_apple_juice: Złota Mikstura + cooler: Przenośna Chłodnica + ancient_altar: Starożytny Ołtarz + wither_proof_obsidian: Wither-Ochronne Obsydian + ancient_runes: Runy Żywiołów + special_runes: Fioletowe Runy + infernal_bonemeal: Piekielna Mączka Kostna + rainbow_blocks: Tęczowy Blok + infused_hopper: Lej Infused + wither_proof_glass: Wither-Ochronne Szkło + duct_tape: Taśma Klejąca + plastic_sheet: Plastik + android_memory_core: Rdzeń Pamięci + oil: Olej + fuel: Paliwo + hologram_projector: Projektor Hologramów + capacitors: Poziom 1 Kondensator + high_tier_capacitors: Poziom 2 Kondensator + solar_generators: Generator Słoneczny + electric_furnaces: Elektryczny Piec + electric_ore_grinding: Elektryczna Szlifierka Rudy + heated_pressure_chamber: Ogrzewana Komora Ciśnieniowa + coal_generator: Generator Węgla + bio_reactor: Bio-Reaktor + auto_enchanting: Automatyczne zaczarowanie i odczarowywanie + auto_anvil: Automatyczne Kowadło + multimeter: Pomiar Mocy + gps_setup: Podstawowa Konfiguracja GPS + gps_emergency_transmitter: Awaryjny punkt GPS + programmable_androids: Programowalne Androidy + android_interfaces: Interfejsyjny Android + geo_scanner: GEO-Skaner + combustion_reactor: Reaktor Spalania + teleporter: Komponenty Podstawowe Teleportera + teleporter_activation_plates: Aktywacja Teleportera + better_solar_generators: Ulepszony Słoneczny Generator + better_gps_transmitters: Ulepszony Transmiter + elevator: Windy + energized_solar_generator: Pełny-Czas Energia Słoneczna + energized_gps_transmitter: Transmiter Najwyższego Poziomu + energy_regulator: Regulator Energii + butcher_androids: Rzeźnik Android + organic_food: Organiczne Jedzenie + auto_breeder: Zautomatyzowane Karmienie + advanced_android: Zaawansowane Androidy + advanced_butcher_android: Zaawansowany Android - Rzeźnik + advanced_fisherman_android: Zaawansowany Android - Rybak + animal_growth_accelerator: Manipulacja Wzrostem Zwierząt + xp_collector: Kolekcjoner Expa + organic_fertilizer: Organiczny Nawóz + crop_growth_accelerator: Przyspieszenie Wzrostu Upraw + better_crop_growth_accelerator: Upgraded Crop Growth Accelerator + reactor_essentials: Podstawowy Reaktor + nuclear_reactor: Elektrownia Atomowa + freezer: Zamrażarka + cargo_basics: Podstawy Ładunku + cargo_nodes: Konfiguracja Ładunku + electric_ingot_machines: Elektryczna Fabryka Sztabek + high_tier_electric_ingot_machines: Super Szybka Produkcja Sztabek + automated_crafting_chamber: Automatyczny Stół Rzemieślniczy + better_food_fabricator: Ulepszone Wytwarzanie Żywności + reactor_access_port: Interakcja Reaktora + fluid_pump: Pompa Płynu + better_freezer: Ulepszona Zamrażarka + boosted_uranium: Niekończący się krąg + trash_can: Kosz + advanced_output_node: Zaawansowany Węzeł Wyjściowy + carbon_press: Prasa do Karbonado + electric_smeltery: Elektryczny Wytapiacz + better_electric_furnace: Ulepszony Elektryczny Piec + better_carbon_press: Ulepszona Prasa do Karbonado + empowered_android: 'Wzmocniony Android ' + empowered_butcher_android: Wzmocniony Android - Rzeźnik + empowered_fisherman_android: Wzmocniony Android - Rybak + high_tier_carbon_press: Ostateczna Prasa Węglowa + wither_assembler: Automatyczny Zabijacz Withera + better_heated_pressure_chamber: Ulepszona Ogrzewana Komora Ciśnieniowa + elytra: Elytra + special_elytras: Specjalna Elytra + electric_crucible: Naelektryzowany Tygiel + better_electric_crucibles: Gorące Tygle + advanced_electric_smeltery: Zaawansowana Huta Elektryczna + advanced_farmer_android: Zaawansowany Android - Farmer + lava_generator: Generator Lawy + nether_ice: Piekielny Lód Chłodzący + nether_star_reactor: Piekielny Reaktor + blistering_ingots: Pękająca Promieniotwórczość + automatic_ignition_chamber: Automatyczna Komora Zapłonowa + output_chest: Podstawowa Skrzynia Wyjściowa Maszyn + copper_wire: Zmniejszona Przewodność + radiant_backpack: Radioaktywny Plecak + auto_drier: Suchy Dzień + diet_cookie: Dietetyczne Ciasteczko + storm_staff: Laska Burzowa + soulbound_rune: Soulbound Rune + geo_miner: GEO-Górnik + lightning_rune: Błyskawiczna Runa + totem_of_undying: Totem Nieśmiertelności + charging_bench: Stół do Ładowania + nether_gold_pan: Piekielna Złota Patelnia + electric_press: Prasa Elektryczna + magnesium_generator: Moc z Magnezu + kelp_cookie: Ciastko z Wodorostów + makeshift_smeltery: Improwizowana huta + tree_growth_accelerator: Szybsze drzewa diff --git a/src/main/resources/languages/researches_tl.yml b/src/main/resources/languages/researches_tl.yml index 224a6c1bb..b03a65186 100644 --- a/src/main/resources/languages/researches_tl.yml +++ b/src/main/resources/languages/researches_tl.yml @@ -1,17 +1,17 @@ --- slimefun: - walking_sticks: Mga Lumalakad na Tusok + walking_sticks: Walking Sticks portable_crafter: Portable Crafter fortune_cookie: Fortune Cookie portable_dustbin: Portable Dustbin meat_jerky: Meat Jerky armor_forge: Armor Crafting glowstone_armor: Glowstone Armor - lumps: Tipak at Mahika + lumps: Lumps and Magic ender_backpack: Ender Backpack ender_armor: Ender Armor - magic_eye_of_ender: Ang Mahiwagang Mata ng Ender - magic_sugar: Mahiwagang Asukal + magic_eye_of_ender: Magic Eye of Ender + magic_sugar: Magic Sugar monster_jerky: Monster Jerky slime_armor: Slime Armor sword_of_beheading: Espada sa Pagpugot ng Ulo diff --git a/src/main/resources/languages/resources_hu.yml b/src/main/resources/languages/resources_hu.yml index 7f35f3c57..6e46c219d 100644 --- a/src/main/resources/languages/resources_hu.yml +++ b/src/main/resources/languages/resources_hu.yml @@ -1,7 +1,7 @@ --- tooltips: results: GEO-Vizsgálat Eredmények - chunk: Vizsgált Chunkok + chunk: Vizsgált Chunk world: Világ unit: Egység units: Egységek diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/TestCategories.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/TestCategories.java index 01fdc202b..bd4bf5d7e 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/TestCategories.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/TestCategories.java @@ -49,7 +49,7 @@ public class TestCategories { Category category = new Category(new NamespacedKey(plugin, "getter_test"), new CustomItem(Material.DIAMOND_AXE, "&6Testing")); Assertions.assertEquals(3, category.getTier()); - Assertions.assertEquals(new NamespacedKey(SlimefunPlugin.instance, "getter_test"), category.getKey()); + Assertions.assertEquals(new NamespacedKey(SlimefunPlugin.instance(), "getter_test"), category.getKey()); Assertions.assertEquals("Testing", category.getUnlocalizedName()); Assertions.assertEquals(0, category.getItems().size()); } diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestBackpackListener.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestBackpackListener.java index 47f7d276a..a7c6dd4f1 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestBackpackListener.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestBackpackListener.java @@ -41,7 +41,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; public class TestBackpackListener { - private static int BACKPACK_SIZE = 27; + private static final int BACKPACK_SIZE = 27; private static ServerMock server; private static SlimefunPlugin plugin; private static BackpackListener listener;