diff --git a/CHANGELOG.md b/CHANGELOG.md
index 479ad0b8f..7c3ecac3a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,7 +2,7 @@
**Table of contents**
-- [Release Candidate 17 (TBD)](#release-candidate-17-tbd)
+- [Release Candidate 17 (17 Oct 2020)](#release-candidate-17-17-oct-2020)
- [Release Candidate 16 (07 Sep 2020)](#release-candidate-16-07-sep-2020)
- [Release Candidate 15 (01 Aug 2020)](#release-candidate-15-01-aug-2020)
- [Release Candidate 14 (12 Jul 2020)](#release-candidate-14-12-jul-2020)
@@ -22,7 +22,7 @@
-## Release Candidate 17 (TBD)
+## Release Candidate 17 (17 Oct 2020)
#### Additions
* Added /sf charge
@@ -39,6 +39,11 @@
* Added "slimefun.gps.bypass" permission to open GPS devices anywhere
* (API) Added custom tags for developers
* The range of the Seeker Pickaxe is now configurable
+* Added Energy Connector
+* Blackstone can now be turned into lava using a Crucible
+* Basalt can now be turned into lava using a Crucible
+* Added "Tainted Sheep" (You can dye a Sheep using Strange Nether Goo)
+* Added mcMMO support/integration
#### Changes
* Improved Auto-Updater (Multi-Threading and more)
@@ -80,6 +85,14 @@
* Fixed #2450
* Fixed Steel Thrusters being used to milk cows
* Fixed #2424
+* Fixed #2468
+* Fixed #2414
+* Fixed #2454
+* Fixed #2457
+* Fixed #2411
+* Fixed #2423
+* Fixed #2452
+* Fixed a dupe bug with mcMMO
## Release Candidate 16 (07 Sep 2020)
https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#16
diff --git a/pom.xml b/pom.xml
index 217f7b2a1..06d6812a0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -64,6 +64,10 @@
worldedit-repo
https://maven.sk89q.com/repo/
+
+ codemc-repo
+ https://repo.codemc.org/repository/maven-public
+
placeholderapi-repo
https://repo.extendedclip.com/content/repositories/placeholderapi/
@@ -311,7 +315,7 @@
com.github.seeseemelk
MockBukkit-v1.16
- 0.10.2
+ 0.13.0
test
@@ -368,6 +372,32 @@
de.schlichtherle
truezip
+
+ net.java.truevfs
+ truevfs-profile-default_2.13
+
+
+
+
+ com.gmail.nossr50.mcMMO
+ mcMMO
+ 2.1.149
+ provided
+
+
+
+
+ org.jetbrains
+ annotations
+
+
+ com.sk89q.worldguard
+ worldguard-core
+
+
+ com.sk89q.worldguard
+ worldguard-legacy
+
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 2abcada1d..7dbffa628 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/ErrorReport.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/ErrorReport.java
@@ -81,7 +81,7 @@ public class ErrorReport {
}
stream.println("Slimefun Data:");
- stream.println(" ID: " + item.getID());
+ stream.println(" ID: " + item.getId());
stream.println(" Inventory: " + BlockStorage.getStorage(l.getWorld()).hasInventory(l));
stream.println(" Data: " + BlockStorage.getBlockInfoAsJson(l));
stream.println();
@@ -92,7 +92,7 @@ public class ErrorReport {
public ErrorReport(T throwable, SlimefunItem item) {
this(throwable, item.getAddon(), stream -> {
stream.println("SlimefunItem:");
- stream.println(" ID: " + item.getID());
+ stream.println(" ID: " + item.getId());
stream.println(" Plugin: " + (item.getAddon() == null ? "Unknown" : item.getAddon().getName()));
stream.println();
});
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/HashedArmorpiece.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/HashedArmorpiece.java
index 15b25a0bc..f1efceeb6 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/HashedArmorpiece.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/HashedArmorpiece.java
@@ -102,7 +102,7 @@ public final class HashedArmorpiece {
@Override
public String toString() {
- return "HashedArmorpiece {hash=" + hash + ",item=" + item.map(SlimefunItem::getID).orElse("null") + '}';
+ return "HashedArmorpiece {hash=" + hash + ",item=" + item.map(SlimefunItem::getId).orElse("null") + '}';
}
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemSetting.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemSetting.java
index 68266f5d2..e51ff0bcb 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemSetting.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemSetting.java
@@ -139,15 +139,15 @@ public class ItemSetting {
*/
@SuppressWarnings("unchecked")
public void load(@Nonnull SlimefunItem item) {
- SlimefunPlugin.getItemCfg().setDefaultValue(item.getID() + '.' + getKey(), getDefaultValue());
- Object configuredValue = SlimefunPlugin.getItemCfg().getValue(item.getID() + '.' + getKey());
+ SlimefunPlugin.getItemCfg().setDefaultValue(item.getId() + '.' + getKey(), getDefaultValue());
+ Object configuredValue = SlimefunPlugin.getItemCfg().getValue(item.getId() + '.' + getKey());
if (defaultValue.getClass().isInstance(configuredValue)) {
if (validateInput((T) configuredValue)) {
this.value = (T) configuredValue;
} else {
Slimefun.getLogger().log(Level.WARNING, "Slimefun has found an invalid config setting in your Items.yml!");
- Slimefun.getLogger().log(Level.WARNING, " at \"{0}.{1}\"", new Object[] { item.getID(), getKey() });
+ Slimefun.getLogger().log(Level.WARNING, " at \"{0}.{1}\"", new Object[] { item.getId(), getKey() });
Slimefun.getLogger().log(Level.WARNING, "{0} is not a valid input!", configuredValue);
Slimefun.getLogger().log(Level.WARNING, getErrorMessage());
}
@@ -157,7 +157,7 @@ public class ItemSetting {
Slimefun.getLogger().log(Level.WARNING, "Slimefun has found an invalid config setting in your Items.yml!");
Slimefun.getLogger().log(Level.WARNING, "Please only use settings that are valid.");
- Slimefun.getLogger().log(Level.WARNING, " at \"{0}.{1}\"", new Object[] { item.getID(), getKey() });
+ Slimefun.getLogger().log(Level.WARNING, " at \"{0}.{1}\"", new Object[] { item.getId(), getKey() });
Slimefun.getLogger().log(Level.WARNING, "Expected \"{0}\" but found: \"{1}\"", new Object[] { defaultValue.getClass().getSimpleName(), found });
}
}
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 06123f1e3..6d2e1504d 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
@@ -66,6 +66,12 @@ public interface EnergyNetComponent extends ItemAttribute {
*/
default int getCharge(@Nonnull Location l) {
Validate.notNull(l, "Location was null!");
+
+ // Emergency fallback, this cannot hold a charge, so we'll just return zero
+ if (!isChargeable()) {
+ return 0;
+ }
+
String charge = BlockStorage.getLocationInfo(l, "energy-charge");
if (charge != null) {
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SlimefunTabCompleter.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SlimefunTabCompleter.java
index b061f475e..e22d222ec 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SlimefunTabCompleter.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SlimefunTabCompleter.java
@@ -99,7 +99,7 @@ class SlimefunTabCompleter implements TabCompleter {
List list = new ArrayList<>(items.size());
for (SlimefunItem item : items) {
- list.add(item.getID());
+ list.add(item.getId());
}
return list;
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/multiblocks/MultiBlock.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/multiblocks/MultiBlock.java
index 83bb966b2..61d96ebf9 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/multiblocks/MultiBlock.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/multiblocks/MultiBlock.java
@@ -119,7 +119,7 @@ public class MultiBlock {
@Override
public int hashCode() {
- return Objects.hash(item.getID(), blocks, trigger, isSymmetric);
+ return Objects.hash(item.getId(), blocks, trigger, isSymmetric);
}
private boolean compareBlocks(Material a, @Nullable Material b) {
@@ -161,6 +161,6 @@ public class MultiBlock {
@Override
public String toString() {
- return "MultiBlock (" + item.getID() + ") {" + Arrays.toString(blocks) + "}";
+ return "MultiBlock (" + item.getId() + ") {" + Arrays.toString(blocks) + "}";
}
}
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 c009dbab2..02eea2d4b 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
@@ -70,6 +70,7 @@ public class EnergyNet extends Network {
return null;
} else {
switch (component.getEnergyComponentType()) {
+ case CONNECTOR:
case CAPACITOR:
return NetworkComponent.CONNECTOR;
case CONSUMER:
@@ -272,6 +273,20 @@ public class EnergyNet extends Network {
return null;
}
+ /**
+ * This attempts to get an {@link EnergyNet} from a given {@link Location}.
+ * If no suitable {@link EnergyNet} could be found, {@code null} will be returned.
+ *
+ * @param l
+ * The target {@link Location}
+ *
+ * @return The {@link EnergyNet} at that {@link Location}, or {@code null}
+ */
+ @Nullable
+ public static EnergyNet getNetworkFromLocation(@Nonnull Location l) {
+ return SlimefunPlugin.getNetworkManager().getNetworkFromLocation(l, EnergyNet.class).orElse(null);
+ }
+
/**
* This attempts to get an {@link EnergyNet} from a given {@link Location}.
* If no suitable {@link EnergyNet} could be found, a new one will be created.
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/energy/EnergyNetComponentType.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/energy/EnergyNetComponentType.java
index fe62f19ad..ef05a8466 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/energy/EnergyNetComponentType.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/energy/EnergyNetComponentType.java
@@ -4,6 +4,7 @@ import org.bukkit.block.Block;
import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetComponent;
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.Capacitor;
+import io.github.thebusybiscuit.slimefun4.implementation.items.electric.EnergyConnector;
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors.Reactor;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AGenerator;
@@ -13,6 +14,7 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AGenerator;
* can have.
*
* @author TheBusyBiscuit
+ * @author Linox
*
* @see EnergyNetComponent
* @see EnergyNet
@@ -38,6 +40,12 @@ public enum EnergyNetComponentType {
*/
CONSUMER,
+ /**
+ * A Connector transmits energy through the network.
+ * Also see: {@link EnergyConnector}
+ */
+ CONNECTOR,
+
/**
* A fallback value to use when a {@link Block} cannot be classified as any of the
* other options.
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/CustomTextureService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/CustomTextureService.java
index d5ce5225b..b94cecf1d 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/CustomTextureService.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/CustomTextureService.java
@@ -64,9 +64,9 @@ public class CustomTextureService {
for (SlimefunItem item : items) {
if (item != null) {
- config.setDefaultValue(item.getID(), 0);
+ config.setDefaultValue(item.getId(), 0);
- if (config.getInt(item.getID()) != 0) {
+ if (config.getInt(item.getId()) != 0) {
modified = true;
}
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/PerWorldSettingsService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/PerWorldSettingsService.java
index 9c76ef6c7..8e11d9563 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/PerWorldSettingsService.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/PerWorldSettingsService.java
@@ -85,7 +85,7 @@ public class PerWorldSettingsService {
return false;
}
- return !items.contains(item.getID());
+ return !items.contains(item.getId());
}
/**
@@ -105,9 +105,9 @@ public class PerWorldSettingsService {
Set items = disabledItems.computeIfAbsent(world.getUID(), id -> loadWorldFromConfig(world));
if (enabled) {
- items.remove(item.getID());
+ items.remove(item.getId());
} else {
- items.add(item.getID());
+ items.add(item.getId());
}
}
@@ -178,7 +178,7 @@ public class PerWorldSettingsService {
for (SlimefunItem item : SlimefunPlugin.getRegistry().getEnabledSlimefunItems()) {
if (item != null) {
String addon = item.getAddon().getName().toLowerCase(Locale.ROOT);
- config.setValue(addon + '.' + item.getID(), !items.contains(item.getID()));
+ config.setValue(addon + '.' + item.getId(), !items.contains(item.getId()));
}
}
@@ -222,7 +222,7 @@ public class PerWorldSettingsService {
if (item != null) {
String addon = item.getAddon().getName().toLowerCase(Locale.ROOT);
config.setDefaultValue(addon + ".enabled", true);
- config.setDefaultValue(addon + '.' + item.getID(), true);
+ config.setDefaultValue(addon + '.' + item.getId(), true);
// Whether the entire addon has been disabled
boolean isAddonDisabled = config.getBoolean(addon + ".enabled");
@@ -232,8 +232,8 @@ public class PerWorldSettingsService {
blacklist.add(worldName);
}
- if (!isAddonDisabled || !config.getBoolean(addon + '.' + item.getID())) {
- items.add(item.getID());
+ if (!isAddonDisabled || !config.getBoolean(addon + '.' + item.getId())) {
+ items.add(item.getId());
}
}
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/PermissionsService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/PermissionsService.java
index 63b2fbe62..920896ab2 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/PermissionsService.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/PermissionsService.java
@@ -41,12 +41,12 @@ public class PermissionsService {
public void register(@Nonnull Iterable items, boolean save) {
for (SlimefunItem item : items) {
if (item != null) {
- String path = item.getID() + ".permission";
+ String path = item.getId() + ".permission";
config.setDefaultValue(path, "none");
- config.setDefaultValue(item.getID() + ".lore", new String[] { "&rYou do not have the permission", "&rto access this item." });
+ config.setDefaultValue(item.getId() + ".lore", new String[] { "&rYou do not have the permission", "&rto access this item." });
- permissions.put(item.getID(), config.getString(path));
+ permissions.put(item.getId(), config.getString(path));
}
}
@@ -72,7 +72,7 @@ public class PermissionsService {
return true;
}
- String permission = permissions.get(item.getID());
+ String permission = permissions.get(item.getId());
return permission == null || permission.equals("none") || p.hasPermission(permission);
}
@@ -89,7 +89,7 @@ public class PermissionsService {
@Nonnull
public Optional getPermission(@Nonnull SlimefunItem item) {
Validate.notNull(item, "Cannot get permissions for null");
- String permission = permissions.get(item.getID());
+ String permission = permissions.get(item.getId());
if (permission == null || permission.equals("none")) {
return Optional.empty();
@@ -108,7 +108,7 @@ public class PermissionsService {
*/
public void setPermission(@Nonnull SlimefunItem item, @Nullable String permission) {
Validate.notNull(item, "You cannot set the permission for null");
- permissions.put(item.getID(), permission != null ? permission : "none");
+ permissions.put(item.getId(), permission != null ? permission : "none");
}
/**
@@ -124,7 +124,7 @@ public class PermissionsService {
@Nonnull
public List getLore(@Nonnull SlimefunItem item) {
- List lore = config.getStringList(item.getID() + ".lore");
+ List lore = config.getStringList(item.getId() + ".lore");
return lore == null ? Arrays.asList("LORE NOT FOUND") : lore;
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/plugins/ClearLagHook.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/plugins/ClearLagIntegration.java
similarity index 75%
rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/services/plugins/ClearLagHook.java
rename to src/main/java/io/github/thebusybiscuit/slimefun4/core/services/plugins/ClearLagIntegration.java
index 3722fcfd6..212bb1f3f 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/plugins/ClearLagHook.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/plugins/ClearLagIntegration.java
@@ -11,11 +11,19 @@ import org.bukkit.event.Listener;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
+import me.minebuilders.clearlag.Clearlag;
import me.minebuilders.clearlag.events.EntityRemoveEvent;
-class ClearLagHook implements Listener {
+/**
+ * This handles all integrations with {@link Clearlag}.
+ * We don't want it to clear our altar items.
+ *
+ * @author TheBusyBiscuit
+ *
+ */
+class ClearLagIntegration implements Listener {
- ClearLagHook(@Nonnull SlimefunPlugin plugin) {
+ ClearLagIntegration(@Nonnull SlimefunPlugin plugin) {
plugin.getServer().getPluginManager().registerEvents(this, plugin);
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/plugins/EmeraldEnchantsCategory.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/plugins/EmeraldEnchantsCategory.java
index ecd2fd7b0..486c59af8 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/plugins/EmeraldEnchantsCategory.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/plugins/EmeraldEnchantsCategory.java
@@ -12,6 +12,7 @@ import io.github.thebusybiscuit.slimefun4.core.categories.FlexCategory;
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout;
import me.mrCookieSlime.EmeraldEnchants.EnchantmentGuide;
+@Deprecated
class EmeraldEnchantsCategory extends FlexCategory {
public EmeraldEnchantsCategory(@Nonnull NamespacedKey key) {
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/plugins/McMMOIntegration.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/plugins/McMMOIntegration.java
new file mode 100644
index 000000000..553627469
--- /dev/null
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/plugins/McMMOIntegration.java
@@ -0,0 +1,60 @@
+package io.github.thebusybiscuit.slimefun4.core.services.plugins;
+
+import javax.annotation.Nonnull;
+
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.EventPriority;
+import org.bukkit.event.Listener;
+import org.bukkit.inventory.ItemStack;
+
+import com.gmail.nossr50.mcMMO;
+import com.gmail.nossr50.events.skills.salvage.McMMOPlayerSalvageCheckEvent;
+
+import io.github.thebusybiscuit.slimefun4.api.events.BlockPlacerPlaceEvent;
+import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
+import io.github.thebusybiscuit.slimefun4.implementation.items.VanillaItem;
+import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
+
+/**
+ * This handles all integrations with {@link mcMMO}.
+ *
+ * @author TheBusyBiscuit
+ *
+ */
+class McMMOIntegration implements Listener {
+
+ McMMOIntegration(@Nonnull SlimefunPlugin plugin) {
+ plugin.getServer().getPluginManager().registerEvents(this, plugin);
+ }
+
+ @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
+ public void onBlockPlacerPlace(BlockPlacerPlaceEvent e) {
+ // This registers blocks placed by the BlockPlacer as "player-placed"
+ mcMMO.getPlaceStore().setTrue(e.getBlock());
+ }
+
+ @EventHandler(ignoreCancelled = true)
+ public void onItemSalvage(McMMOPlayerSalvageCheckEvent e) {
+ // Prevent Slimefun items from being salvaged
+ if (!isSalvageable(e.getSalvageItem())) {
+ e.setCancelled(true);
+ SlimefunPlugin.getLocalization().sendMessage(e.getPlayer(), "anvil.mcmmo-salvaging");
+ }
+ }
+
+ /**
+ * This method checks if an {@link ItemStack} can be salvaged or not.
+ * We basically don't want players to salvage any {@link SlimefunItem} unless
+ * it is a {@link VanillaItem}.
+ *
+ * @param item
+ * The {@link ItemStack} to check
+ *
+ * @return Whether this item can be safely salvaged
+ */
+ private boolean isSalvageable(@Nonnull ItemStack item) {
+ SlimefunItem sfItem = SlimefunItem.getByItem(item);
+ return sfItem == null || sfItem instanceof VanillaItem;
+ }
+
+}
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/PlaceholderAPIIntegration.java
similarity index 93%
rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/services/plugins/PlaceholderAPIHook.java
rename to src/main/java/io/github/thebusybiscuit/slimefun4/core/services/plugins/PlaceholderAPIIntegration.java
index 892729663..d49426458 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/PlaceholderAPIIntegration.java
@@ -13,14 +13,21 @@ import org.bukkit.entity.Player;
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
import io.github.thebusybiscuit.slimefun4.core.researching.Research;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
+import me.clip.placeholderapi.PlaceholderAPI;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
-class PlaceholderAPIHook extends PlaceholderExpansion {
+/**
+ * This is our integration for {@link PlaceholderAPI}.
+ *
+ * @author TheBusyBiscuit
+ *
+ */
+class PlaceholderAPIIntegration extends PlaceholderExpansion {
private final String version;
private final String author;
- public PlaceholderAPIHook(@Nonnull SlimefunPlugin plugin) {
+ public PlaceholderAPIIntegration(@Nonnull SlimefunPlugin plugin) {
this.version = plugin.getDescription().getVersion();
this.author = plugin.getDescription().getAuthors().toString();
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/plugins/ThirdPartyPluginService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/plugins/ThirdPartyPluginService.java
index 877aac6b1..4bf85071f 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/plugins/ThirdPartyPluginService.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/plugins/ThirdPartyPluginService.java
@@ -5,12 +5,16 @@ import java.util.function.Function;
import java.util.logging.Level;
import javax.annotation.Nonnull;
+import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.NamespacedKey;
import org.bukkit.block.Block;
+import org.bukkit.event.Event;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
+import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
+
import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
import io.github.thebusybiscuit.slimefun4.core.categories.FlexCategory;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
@@ -31,25 +35,41 @@ public class ThirdPartyPluginService {
private final SlimefunPlugin plugin;
+ private boolean initialized = false;
private boolean isExoticGardenInstalled = false;
private boolean isChestTerminalInstalled = false;
private boolean isEmeraldEnchantsInstalled = false;
- private boolean isCoreProtectInstalled = false;
- private boolean isPlaceholderAPIInstalled = false;
+ private boolean isMcMMOInstalled = false;
- // Overridden if ExoticGarden is loaded
+ /**
+ * This gets overridden if ExoticGarden is loaded
+ */
private Function> exoticGardenIntegration = b -> Optional.empty();
+ /**
+ * This initializes the {@link ThirdPartyPluginService}
+ *
+ * @param plugin
+ * Our instance of {@link SlimefunPlugin}
+ */
public ThirdPartyPluginService(@Nonnull SlimefunPlugin plugin) {
this.plugin = plugin;
}
+ /**
+ * This method initializes all third party integrations.
+ */
public void start() {
+ if (initialized) {
+ throw new UnsupportedOperationException("Third Party Integrations have already been initialized!");
+ }
+
+ initialized = true;
+
if (isPluginInstalled("PlaceholderAPI")) {
try {
- PlaceholderAPIHook hook = new PlaceholderAPIHook(plugin);
+ PlaceholderAPIIntegration hook = new PlaceholderAPIIntegration(plugin);
hook.register();
- isPlaceholderAPIInstalled = true;
} catch (Exception | LinkageError x) {
String version = plugin.getServer().getPluginManager().getPlugin("PlaceholderAPI").getDescription().getVersion();
@@ -69,7 +89,7 @@ public class ThirdPartyPluginService {
if (isPluginInstalled("WorldEdit")) {
try {
Class.forName("com.sk89q.worldedit.extent.Extent");
- new WorldEditHook();
+ new WorldEditIntegration();
} catch (Exception | LinkageError x) {
String version = plugin.getServer().getPluginManager().getPlugin("WorldEdit").getDescription().getVersion();
@@ -78,6 +98,21 @@ public class ThirdPartyPluginService {
}
}
+ // mcMMO Integration
+ if (isPluginInstalled("mcMMO")) {
+ try {
+ // This makes sure that the FakeEvent interface is present.
+ // Class.forName("com.gmail.nossr50.events.fake.FakeEvent");
+
+ new McMMOIntegration(plugin);
+ isMcMMOInstalled = true;
+ } catch (Exception | LinkageError x) {
+ String version = plugin.getServer().getPluginManager().getPlugin("mcMMO").getDescription().getVersion();
+ Slimefun.getLogger().log(Level.WARNING, "Maybe consider updating mcMMO or Slimefun?");
+ Slimefun.getLogger().log(Level.WARNING, x, () -> "Failed to hook into mcMMO v" + version);
+ }
+ }
+
/*
* These Items are not marked as soft-dependencies and
* therefore need to be loaded after the Server has finished
@@ -85,7 +120,7 @@ public class ThirdPartyPluginService {
*/
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> {
if (isPluginInstalled("ClearLag")) {
- new ClearLagHook(plugin);
+ new ClearLagIntegration(plugin);
}
isChestTerminalInstalled = isPluginInstalled("ChestTerminal");
@@ -101,6 +136,7 @@ public class ThirdPartyPluginService {
}
}
+ @ParametersAreNonnullByDefault
public void loadExoticGarden(Plugin plugin, Function> method) {
if (plugin.getName().equals("ExoticGarden")) {
isExoticGardenInstalled = true;
@@ -120,16 +156,22 @@ public class ThirdPartyPluginService {
return isEmeraldEnchantsInstalled;
}
- public boolean isCoreProtectInstalled() {
- return isCoreProtectInstalled;
- }
-
- public boolean isPlaceholderAPIInstalled() {
- return isPlaceholderAPIInstalled;
- }
-
public Optional harvestExoticGardenPlant(Block block) {
return exoticGardenIntegration.apply(block);
}
+ /**
+ * This checks if one of our third party integrations faked an {@link Event}.
+ * Faked {@link Event Events} should be ignored in our logic.
+ *
+ * @param event
+ * The {@link Event} to test
+ *
+ * @return Whether this is a fake event
+ */
+ public boolean isEventFaked(@Nonnull Event event) {
+ // TODO: Change this to FakeEvent once the new mcMMO build was released
+ return isMcMMOInstalled && event instanceof FakeBlockBreakEvent;
+ }
+
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/plugins/WorldEditHook.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/plugins/WorldEditIntegration.java
similarity index 86%
rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/services/plugins/WorldEditHook.java
rename to src/main/java/io/github/thebusybiscuit/slimefun4/core/services/plugins/WorldEditIntegration.java
index 3b134df92..38af34726 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/plugins/WorldEditHook.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/plugins/WorldEditIntegration.java
@@ -14,9 +14,16 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
import me.mrCookieSlime.Slimefun.api.BlockStorage;
-class WorldEditHook {
+/**
+ * This handles all integrations with {@link WorldEdit}.
+ * If an are is cleared, we also wanna clear all Slimefun-related block data.
+ *
+ * @author TheBusyBiscuit
+ *
+ */
+class WorldEditIntegration {
- WorldEditHook() {
+ WorldEditIntegration() {
WorldEdit.getInstance().getEventBus().register(this);
}
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 c89707a9b..8a4e68d0d 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
@@ -46,7 +46,7 @@ class ProfiledBlock {
}
public String getId() {
- return item.getID();
+ return item.getId();
}
public SlimefunAddon getAddon() {
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 7381abae3..5a0d92d9a 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
@@ -344,7 +344,7 @@ public class SlimefunProfiler {
public String getTime(@Nonnull SlimefunItem item) {
Validate.notNull("Cannot get timings for a null SlimefunItem");
- long time = getByItem().getOrDefault(item.getID(), 0L);
+ long time = getByItem().getOrDefault(item.getId(), 0L);
return NumberUtils.getAsMillis(time);
}
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 0ba5e2a14..92a58d15f 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java
@@ -672,12 +672,12 @@ public final class SlimefunItems {
public static final SlimefunItemStack BIO_REACTOR = new SlimefunItemStack("BIO_REACTOR", Material.LIME_TERRACOTTA, "&2Bio Reactor", "", LoreBuilder.machine(MachineTier.AVERAGE, MachineType.GENERATOR), LoreBuilder.powerBuffer(128), LoreBuilder.powerPerSecond(8));
public static final SlimefunItemStack MULTIMETER = new SlimefunItemStack("MULTIMETER", Material.CLOCK, "&eMultimeter", "", "&fMeasures the Amount of stored", "&fEnergy in a Block");
- public static final SlimefunItemStack SMALL_CAPACITOR = new SlimefunItemStack("SMALL_CAPACITOR", HeadTexture.CAPACITOR_25, "&aSmall Energy Capacitor", "", LoreBuilder.machine(MachineTier.BASIC, MachineType.CAPACITOR), "&8\u21E8 &e\u26A1 &7128 J Capacity");
- public static final SlimefunItemStack MEDIUM_CAPACITOR = new SlimefunItemStack("MEDIUM_CAPACITOR", HeadTexture.CAPACITOR_25, "&aMedium Energy Capacitor", "", LoreBuilder.machine(MachineTier.AVERAGE, MachineType.CAPACITOR), "&8\u21E8 &e\u26A1 &7512 J Capacity");
- public static final SlimefunItemStack BIG_CAPACITOR = new SlimefunItemStack("BIG_CAPACITOR", HeadTexture.CAPACITOR_25, "&aBig Energy Capacitor", "", LoreBuilder.machine(MachineTier.MEDIUM, MachineType.CAPACITOR), "&8\u21E8 &e\u26A1 &71024 J Capacity");
- public static final SlimefunItemStack LARGE_CAPACITOR = new SlimefunItemStack("LARGE_CAPACITOR", HeadTexture.CAPACITOR_25, "&aLarge Energy Capacitor", "", LoreBuilder.machine(MachineTier.GOOD, MachineType.CAPACITOR), "&8\u21E8 &e\u26A1 &78192 J Capacity");
- public static final SlimefunItemStack CARBONADO_EDGED_CAPACITOR = new SlimefunItemStack("CARBONADO_EDGED_CAPACITOR", HeadTexture.CAPACITOR_25, "&aCarbonado Edged Energy Capacitor", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.CAPACITOR), "&8\u21E8 &e\u26A1 &765536 J Capacity");
- public static final SlimefunItemStack ENERGIZED_CAPACITOR = new SlimefunItemStack("ENERGIZED_CAPACITOR", HeadTexture.CAPACITOR_25, "&aEnergized Energy Capacitor", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.CAPACITOR), "&8\u21E8 &e\u26A1 &7524288 J Capacity");
+ public static final SlimefunItemStack SMALL_CAPACITOR = new SlimefunItemStack("SMALL_CAPACITOR", HeadTexture.CAPACITOR_25, "&aSmall Energy Capacitor", LoreBuilder.range(6), "", LoreBuilder.machine(MachineTier.BASIC, MachineType.CAPACITOR), "&8\u21E8 &e\u26A1 &7128 J Capacity");
+ public static final SlimefunItemStack MEDIUM_CAPACITOR = new SlimefunItemStack("MEDIUM_CAPACITOR", HeadTexture.CAPACITOR_25, "&aMedium Energy Capacitor", LoreBuilder.range(6), "", LoreBuilder.machine(MachineTier.AVERAGE, MachineType.CAPACITOR), "&8\u21E8 &e\u26A1 &7512 J Capacity");
+ public static final SlimefunItemStack BIG_CAPACITOR = new SlimefunItemStack("BIG_CAPACITOR", HeadTexture.CAPACITOR_25, "&aBig Energy Capacitor", LoreBuilder.range(6), "", LoreBuilder.machine(MachineTier.MEDIUM, MachineType.CAPACITOR), "&8\u21E8 &e\u26A1 &71024 J Capacity");
+ public static final SlimefunItemStack LARGE_CAPACITOR = new SlimefunItemStack("LARGE_CAPACITOR", HeadTexture.CAPACITOR_25, "&aLarge Energy Capacitor", LoreBuilder.range(6), "", LoreBuilder.machine(MachineTier.GOOD, MachineType.CAPACITOR), "&8\u21E8 &e\u26A1 &78192 J Capacity");
+ public static final SlimefunItemStack CARBONADO_EDGED_CAPACITOR = new SlimefunItemStack("CARBONADO_EDGED_CAPACITOR", HeadTexture.CAPACITOR_25, "&aCarbonado Edged Energy Capacitor", LoreBuilder.range(6), "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.CAPACITOR), "&8\u21E8 &e\u26A1 &765536 J Capacity");
+ public static final SlimefunItemStack ENERGIZED_CAPACITOR = new SlimefunItemStack("ENERGIZED_CAPACITOR", HeadTexture.CAPACITOR_25, "&aEnergized Energy Capacitor", LoreBuilder.range(6), "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.CAPACITOR), "&8\u21E8 &e\u26A1 &7524288 J Capacity");
/* Robots */
public static final SlimefunItemStack PROGRAMMABLE_ANDROID = new SlimefunItemStack("PROGRAMMABLE_ANDROID", HeadTexture.PROGRAMMABLE_ANDROID, "&cProgrammable Android &7(Normal)", "", "&8\u21E8 &7Function: None", "&8\u21E8 &7Fuel Efficiency: 1.0x");
@@ -750,6 +750,7 @@ public final class SlimefunItems {
public static final SlimefunItemStack BLISTERING_INGOT_3 = new SlimefunItemStack("BLISTERING_INGOT_3", Material.GOLD_INGOT, "&6Blistering Ingot", "", LoreBuilder.radioactive(Radioactivity.VERY_HIGH), LoreBuilder.HAZMAT_SUIT_REQUIRED);
public static final SlimefunItemStack ENERGY_REGULATOR = new SlimefunItemStack("ENERGY_REGULATOR", HeadTexture.ENERGY_REGULATOR, "&6Energy Regulator", "", "&fCore Component of an Energy Network");
+ public static final SlimefunItemStack ENERGY_CONNECTOR = new SlimefunItemStack("ENERGY_CONNECTOR", HeadTexture.ENERGY_CONNECTOR, "&eEnergy Connector", LoreBuilder.range(6), "", "&fPlace this between machines", "&fand generators to connect them", "&fto your regulator.");
public static final SlimefunItemStack DEBUG_FISH = new SlimefunItemStack("DEBUG_FISH", Material.SALMON, "&3How much is the Fish?", "", "&eRight Click &fany Block to view it's BlockData", "&eLeft Click &fto break a Block", "&eShift + Left Click &fany Block to erase it's BlockData", "&eShift + Right Click &fto place a Placeholder Block");
public static final SlimefunItemStack NETHER_ICE = new SlimefunItemStack("NETHER_ICE", HeadTexture.NETHER_ICE, "&eNether Ice", "", LoreBuilder.radioactive(Radioactivity.MODERATE), LoreBuilder.HAZMAT_SUIT_REQUIRED);
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 b2656d623..781d46bb0 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java
@@ -89,10 +89,15 @@ import io.github.thebusybiscuit.slimefun4.implementation.listeners.SlimefunItemL
import io.github.thebusybiscuit.slimefun4.implementation.listeners.SoulboundListener;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.TalismanListener;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.VampireBladeListener;
-import io.github.thebusybiscuit.slimefun4.implementation.listeners.VanillaMachinesListener;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.VillagerTradingListener;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.WitherListener;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.WorldListener;
+import io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting.AnvilListener;
+import io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting.BrewingStandListener;
+import io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting.CartographyTableListener;
+import io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting.CauldronListener;
+import io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting.CraftingTableListener;
+import io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting.GrindstoneListener;
import io.github.thebusybiscuit.slimefun4.implementation.resources.GEOResourcesSetup;
import io.github.thebusybiscuit.slimefun4.implementation.setup.PostSetup;
import io.github.thebusybiscuit.slimefun4.implementation.setup.ResearchSetup;
@@ -176,9 +181,14 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
command.register();
registry.load(config);
} else if (getServer().getPluginManager().isPluginEnabled("CS-CoreLib")) {
+ getLogger().log(Level.INFO, "CS-CoreLib was detected!");
long timestamp = System.nanoTime();
PaperLib.suggestPaper(this);
+ if (PaperLib.isPaper()) {
+ getLogger().log(Level.INFO, "Paper was detected! Performance optimizations have been applied.");
+ }
+
// We wanna ensure that the Server uses a compatible version of Minecraft
if (isVersionUnsupported()) {
getServer().getPluginManager().disablePlugin(this);
@@ -270,7 +280,10 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
autoSavingService.start(this, config.getInt("options.auto-save-delay-in-minutes"));
ticker.start(this);
+
+ getLogger().log(Level.INFO, "Loading Third-Party plugin integrations...");
thirdPartySupportService.start();
+
gitHubService.start(this);
// Hooray!
@@ -445,7 +458,6 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
new DeathpointListener(this);
new ExplosionsListener(this);
new DebugFishListener(this);
- new VanillaMachinesListener(this);
new FireworksListener(this);
new WitherListener(this);
new IronGolemListener(this);
@@ -453,6 +465,15 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
new MobDropListener(this);
new VillagerTradingListener(this);
new ElytraCrashListener(this);
+ new CraftingTableListener(this);
+ new AnvilListener(this);
+ new BrewingStandListener(this);
+ new CauldronListener(this);
+
+ if (minecraftVersion.isAtLeast(MinecraftVersion.MINECRAFT_1_14)) {
+ new GrindstoneListener(this);
+ new CartographyTableListener(this);
+ }
if (minecraftVersion.isAtLeast(MinecraftVersion.MINECRAFT_1_15)) {
new BeeListener(this);
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 0a26c0a7f..59b081e82 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
@@ -208,7 +208,7 @@ public class BookSlimefunGuide implements SlimefunGuideImplementation {
}
private void addSlimefunItem(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/items/altar/AncientPedestal.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/altar/AncientPedestal.java
index a9dec8dcf..80cc207cd 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
@@ -53,7 +53,7 @@ public class AncientPedestal extends SimpleSlimefunItem {
public AncientPedestal(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput) {
super(category, item, recipeType, recipe, recipeOutput);
- SlimefunItem.registerBlockHandler(getID(), (p, b, tool, reason) -> {
+ SlimefunItem.registerBlockHandler(getId(), (p, b, tool, reason) -> {
Optional- entity = getPlacedItem(b);
if (entity.isPresent()) {
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 fb4c80a3d..b57b449e4 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
@@ -81,7 +81,7 @@ public class ProgrammableAndroid extends SlimefunItem implements InventoryBlock,
texture = item.getSkullTexture().orElse(null);
registerDefaultFuelTypes();
- new BlockMenuPreset(getID(), "Programmable Android") {
+ new BlockMenuPreset(getId(), "Programmable Android") {
@Override
public void init() {
@@ -131,7 +131,7 @@ public class ProgrammableAndroid extends SlimefunItem implements InventoryBlock,
}
};
- registerBlockHandler(getID(), (p, b, stack, reason) -> {
+ registerBlockHandler(getId(), (p, b, stack, reason) -> {
boolean allow = reason == UnregisterReason.PLAYER_BREAK && (BlockStorage.getLocationInfo(b.getLocation(), "owner").equals(p.getUniqueId().toString()) || p.hasPermission("slimefun.android.bypass"));
if (allow) {
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 2bf0fbbea..810cdf699 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
@@ -153,7 +153,7 @@ public class BlockPlacer extends SlimefunItem {
block.setType(item.getType());
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, item.getType());
- BlockStorage.store(block, sfItem.getID());
+ BlockStorage.store(block, sfItem.getId());
handler.onBlockPlacerPlace(e);
if (dispenser.getInventory().containsAtLeast(item, 2)) {
@@ -168,7 +168,7 @@ public class BlockPlacer extends SlimefunItem {
block.setType(item.getType());
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, item.getType());
- BlockStorage.store(block, sfItem.getID());
+ BlockStorage.store(block, sfItem.getId());
if (dispenser.getInventory().containsAtLeast(item, 2)) {
dispenser.getInventory().removeItem(new CustomItem(item, 1));
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 ee8f5c6df..73cd1902f 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
@@ -18,6 +18,7 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction;
+import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion;
import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem;
import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
@@ -72,6 +73,14 @@ public class Crucible extends SimpleSlimefunItem implements Rec
items.add(new ItemStack(Material.LAVA_BUCKET));
}
+ if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_16)) {
+ items.add(new ItemStack(Material.BLACKSTONE, 8));
+ items.add(new ItemStack(Material.LAVA_BUCKET));
+
+ items.add(new ItemStack(Material.BASALT, 12));
+ items.add(new ItemStack(Material.LAVA_BUCKET));
+ }
+
return items;
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AbstractCargoNode.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AbstractCargoNode.java
index d7fbabe69..e1d43bfc0 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AbstractCargoNode.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AbstractCargoNode.java
@@ -51,7 +51,7 @@ abstract class AbstractCargoNode extends SlimefunItem {
});
- new BlockMenuPreset(getID(), ChatUtils.removeColorCodes(item.getItemMeta().getDisplayName())) {
+ new BlockMenuPreset(getId(), ChatUtils.removeColorCodes(item.getItemMeta().getDisplayName())) {
@Override
public void init() {
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AbstractFilterNode.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AbstractFilterNode.java
index 991cfbc27..2a45af496 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AbstractFilterNode.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AbstractFilterNode.java
@@ -32,7 +32,7 @@ abstract class AbstractFilterNode extends AbstractCargoNode {
public AbstractFilterNode(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput) {
super(category, item, recipeType, recipe, recipeOutput);
- registerBlockHandler(getID(), (p, b, stack, reason) -> {
+ registerBlockHandler(getId(), (p, b, stack, reason) -> {
BlockMenu inv = BlockStorage.getInventory(b);
if (inv != null) {
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 a28646581..dabde12f6 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
@@ -1,5 +1,7 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.cargo;
+import javax.annotation.Nonnull;
+
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@@ -18,9 +20,14 @@ public class CargoConnectorNode extends SimpleSlimefunItem {
super(category, item, recipeType, recipe, recipeOutput);
}
+ @Nonnull
@Override
public BlockUseHandler getItemHandler() {
return e -> {
+ if (!e.getClickedBlock().isPresent()) {
+ return;
+ }
+
Player p = e.getPlayer();
Block b = e.getClickedBlock().get();
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 7e64e252d..be0a3496b 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
@@ -24,7 +24,7 @@ public class CargoManager extends SlimefunItem {
public CargoManager(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, recipeType, recipe);
- registerBlockHandler(getID(), (p, b, tool, reason) -> {
+ registerBlockHandler(getId(), (p, b, tool, reason) -> {
SimpleHologram.remove(b);
return true;
});
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 fb07d176e..58a380771 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
@@ -35,7 +35,7 @@ public class ReactorAccessPort extends SlimefunItem {
public ReactorAccessPort(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, recipeType, recipe);
- new BlockMenuPreset(getID(), "&2Reactor Access Port") {
+ new BlockMenuPreset(getId(), "&2Reactor Access Port") {
@Override
public void init() {
@@ -94,7 +94,7 @@ public class ReactorAccessPort extends SlimefunItem {
}
};
- registerBlockHandler(getID(), (p, b, tool, reason) -> {
+ registerBlockHandler(getId(), (p, b, tool, reason) -> {
BlockMenu inv = BlockStorage.getInventory(b);
if (inv != 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 cc16f0db6..b7767796b 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
@@ -8,6 +8,7 @@ import java.util.Set;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
+import org.apache.commons.lang.Validate;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
@@ -89,11 +90,12 @@ public abstract class AbstractEnergyProvider extends SlimefunItem implements Inv
}
public void registerFuel(@Nonnull MachineFuel fuel) {
+ Validate.notNull(fuel, "Machine Fuel cannot be null!");
fuelTypes.add(fuel);
}
@Nonnull
- public Set getFuelTypes() {
+ public Set getFuelTypes2() {
return fuelTypes;
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/EnergyConnector.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/EnergyConnector.java
new file mode 100644
index 000000000..ca93c9482
--- /dev/null
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/EnergyConnector.java
@@ -0,0 +1,64 @@
+package io.github.thebusybiscuit.slimefun4.implementation.items.electric;
+
+import javax.annotation.Nonnull;
+
+import org.bukkit.block.Block;
+import org.bukkit.entity.Player;
+import org.bukkit.inventory.ItemStack;
+
+import io.github.thebusybiscuit.cscorelib2.chat.ChatColors;
+import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetComponent;
+import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler;
+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.SimpleSlimefunItem;
+import me.mrCookieSlime.Slimefun.Lists.RecipeType;
+import me.mrCookieSlime.Slimefun.Objects.Category;
+import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
+
+/**
+ * This {@link EnergyNetComponent} is a connector for the {@link EnergyNet} networks.
+ * They work similar to {@link Capacitor capacitors}.
+ *
+ * @author Linox
+ *
+ * @see EnergyNet
+ * @see EnergyNetComponent
+ *
+ */
+public class EnergyConnector extends SimpleSlimefunItem implements EnergyNetComponent {
+
+ public EnergyConnector(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput) {
+ super(category, item, recipeType, recipe, recipeOutput);
+ }
+
+ @Nonnull
+ @Override
+ public BlockUseHandler getItemHandler() {
+ return e -> {
+ if (!e.getClickedBlock().isPresent()) {
+ return;
+ }
+
+ Player p = e.getPlayer();
+ Block b = e.getClickedBlock().get();
+
+ if (EnergyNet.getNetworkFromLocation(b.getLocation()) != null) {
+ p.sendMessage(ChatColors.color("&7Connected: " + "&2\u2714"));
+ } else {
+ p.sendMessage(ChatColors.color("&7Connected: " + "&4\u2718"));
+ }
+ };
+ }
+
+ @Nonnull
+ @Override
+ public EnergyNetComponentType getEnergyComponentType() {
+ return EnergyNetComponentType.CONNECTOR;
+ }
+
+ @Override
+ public int getCapacity() {
+ return 0;
+ }
+}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/EnergyRegulator.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/EnergyRegulator.java
index abd0e4876..6a3711aa4 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/EnergyRegulator.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/EnergyRegulator.java
@@ -34,7 +34,7 @@ public class EnergyRegulator extends SlimefunItem {
public EnergyRegulator(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, recipeType, recipe);
- SlimefunItem.registerBlockHandler(getID(), (p, b, stack, reason) -> {
+ SlimefunItem.registerBlockHandler(getId(), (p, b, stack, reason) -> {
SimpleHologram.remove(b);
return true;
});
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/CoalGenerator.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/CoalGenerator.java
index 1f0499a61..886164817 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/CoalGenerator.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/CoalGenerator.java
@@ -74,7 +74,7 @@ public abstract class CoalGenerator extends AGenerator {
}
// Signs
- for (Material mat : Tag.SIGNS.getValues()) {
+ for (Material mat : Tag.STANDING_SIGNS.getValues()) {
registerFuel(new MachineFuel(2, new ItemStack(mat)));
}
}
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
index 664b43a0c..ccd858373 100644
--- 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
@@ -62,7 +62,7 @@ public abstract class AbstractEntityAssembler extends SimpleSl
public AbstractEntityAssembler(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, recipeType, recipe);
- new BlockMenuPreset(getID(), item.getImmutableMeta().getDisplayName().orElse("Entity Assembler")) {
+ new BlockMenuPreset(getId(), item.getImmutableMeta().getDisplayName().orElse("Entity Assembler")) {
@Override
public void init() {
@@ -117,7 +117,7 @@ public abstract class AbstractEntityAssembler extends SimpleSl
};
addItemHandler(onPlace());
- registerBlockHandler(getID(), (p, b, stack, reason) -> {
+ registerBlockHandler(getId(), (p, b, stack, reason) -> {
if (reason == UnregisterReason.EXPLODE) {
return false;
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AbstractGrowthAccelerator.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AbstractGrowthAccelerator.java
index cc82d8a0d..2b08fa441 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AbstractGrowthAccelerator.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AbstractGrowthAccelerator.java
@@ -28,7 +28,7 @@ public abstract class AbstractGrowthAccelerator extends SlimefunItem implements
createPreset(this, this::constructMenu);
- registerBlockHandler(getID(), (p, b, tool, reason) -> {
+ registerBlockHandler(getId(), (p, b, tool, reason) -> {
BlockMenu inv = BlockStorage.getInventory(b);
if (inv != null) {
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoBreeder.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoBreeder.java
index b607e2a17..e448155e7 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoBreeder.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoBreeder.java
@@ -39,7 +39,7 @@ public class AutoBreeder extends SlimefunItem implements InventoryBlock, EnergyN
createPreset(this, this::constructMenu);
- registerBlockHandler(getID(), (p, b, tool, reason) -> {
+ registerBlockHandler(getId(), (p, b, tool, reason) -> {
BlockMenu inv = BlockStorage.getInventory(b);
if (inv != null) {
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutomatedCraftingChamber.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutomatedCraftingChamber.java
index 99f34d638..268736c13 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutomatedCraftingChamber.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutomatedCraftingChamber.java
@@ -52,7 +52,7 @@ public abstract class AutomatedCraftingChamber extends SlimefunItem implements I
public AutomatedCraftingChamber(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, recipeType, recipe);
- new BlockMenuPreset(getID(), "&6Automated Crafting Chamber") {
+ new BlockMenuPreset(getId(), "&6Automated Crafting Chamber") {
@Override
public void init() {
@@ -120,7 +120,7 @@ public abstract class AutomatedCraftingChamber extends SlimefunItem implements I
};
addItemHandler(onPlace());
- registerBlockHandler(getID(), (p, b, stack, reason) -> {
+ registerBlockHandler(getId(), (p, b, stack, reason) -> {
BlockMenu inv = BlockStorage.getInventory(b);
if (inv != null) {
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricSmeltery.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricSmeltery.java
index 5e7671af1..1f3393bd9 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricSmeltery.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricSmeltery.java
@@ -44,7 +44,7 @@ public abstract class ElectricSmeltery extends AContainer {
public ElectricSmeltery(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, recipeType, recipe);
- new BlockMenuPreset(getID(), getItemName()) {
+ new BlockMenuPreset(getId(), getItemName()) {
@Override
public void init() {
@@ -99,7 +99,7 @@ public abstract class ElectricSmeltery extends AContainer {
}
};
- registerBlockHandler(getID(), (p, b, tool, reason) -> {
+ registerBlockHandler(getId(), (p, b, tool, reason) -> {
BlockMenu inv = BlockStorage.getInventory(b);
if (inv != null) {
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectrifiedCrucible.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectrifiedCrucible.java
index f0d7c128d..e26b0c9ea 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectrifiedCrucible.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectrifiedCrucible.java
@@ -4,6 +4,8 @@ import org.bukkit.Material;
import org.bukkit.Tag;
import org.bukkit.inventory.ItemStack;
+import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion;
+import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
@@ -29,6 +31,11 @@ public abstract class ElectrifiedCrucible extends AContainer {
for (Material leaves : Tag.LEAVES.getValues()) {
registerRecipe(10, new ItemStack[] { new ItemStack(Material.BUCKET), new ItemStack(leaves, 16) }, new ItemStack[] { new ItemStack(Material.WATER_BUCKET) });
}
+
+ if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_16)) {
+ registerRecipe(10, new ItemStack[] { new ItemStack(Material.BUCKET), new ItemStack(Material.BLACKSTONE, 8) }, new ItemStack[] { new ItemStack(Material.LAVA_BUCKET) });
+ registerRecipe(10, new ItemStack[] { new ItemStack(Material.BUCKET), new ItemStack(Material.BASALT, 12) }, new ItemStack[] { new ItemStack(Material.LAVA_BUCKET) });
+ }
}
@Override
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 c2a0a9044..d5a2168ee 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
@@ -54,7 +54,7 @@ public class FluidPump extends SimpleSlimefunItem implements Invent
createPreset(this, this::constructMenu);
- registerBlockHandler(getID(), (p, b, stack, reason) -> {
+ registerBlockHandler(getId(), (p, b, stack, reason) -> {
BlockMenu inv = BlockStorage.getInventory(b);
if (inv != null) {
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/HeatedPressureChamber.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/HeatedPressureChamber.java
index 69e2ee900..fac111195 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/HeatedPressureChamber.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/HeatedPressureChamber.java
@@ -28,7 +28,7 @@ public abstract class HeatedPressureChamber extends AContainer {
public HeatedPressureChamber(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, recipeType, recipe);
- new BlockMenuPreset(getID(), getItemName()) {
+ new BlockMenuPreset(getId(), getItemName()) {
@Override
public void init() {
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/XPCollector.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/XPCollector.java
index fcd6df495..ea96f836a 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/XPCollector.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/XPCollector.java
@@ -38,7 +38,7 @@ public class XPCollector extends SlimefunItem implements InventoryBlock, EnergyN
createPreset(this, this::constructMenu);
addItemHandler(onPlace());
- registerBlockHandler(getID(), (p, b, stack, reason) -> {
+ registerBlockHandler(getId(), (p, b, stack, reason) -> {
BlockMenu inv = BlockStorage.getInventory(b);
if (inv != null) {
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 16e101de8..010cee0ad 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
@@ -80,7 +80,7 @@ public abstract class Reactor extends AbstractEnergyProvider {
public Reactor(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, recipeType, recipe);
- new BlockMenuPreset(getID(), getInventoryTitle()) {
+ new BlockMenuPreset(getId(), getInventoryTitle()) {
@Override
public void init() {
@@ -107,7 +107,7 @@ public abstract class Reactor extends AbstractEnergyProvider {
}
};
- registerBlockHandler(getID(), (p, b, tool, reason) -> {
+ registerBlockHandler(getId(), (p, b, tool, reason) -> {
BlockMenu inv = BlockStorage.getInventory(b);
if (inv != null) {
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOMiner.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOMiner.java
index 70ca06c60..637d5b941 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOMiner.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOMiner.java
@@ -41,7 +41,7 @@ public abstract class GEOMiner extends AContainer implements RecipeDisplayItem {
super(category, item, recipeType, recipe);
addItemHandler(onPlace());
- registerBlockHandler(getID(), (p, b, stack, reason) -> {
+ registerBlockHandler(getId(), (p, b, stack, reason) -> {
SimpleHologram.remove(b);
BlockMenu inv = BlockStorage.getInventory(b);
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 899d4db6a..11ccc1763 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
@@ -34,7 +34,7 @@ public abstract class OilPump extends AContainer implements RecipeDisplayItem {
oil = SlimefunPlugin.getRegistry().getGEOResources().get(new NamespacedKey(SlimefunPlugin.instance(), "oil")).orElse(null);
- new BlockMenuPreset(getID(), getInventoryTitle()) {
+ new BlockMenuPreset(getId(), getInventoryTitle()) {
@Override
public void init() {
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 78c8f9c80..aeffe8f77 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
@@ -87,7 +87,7 @@ public class ElevatorPlate extends SimpleSlimefunItem {
Block block = b.getWorld().getBlockAt(b.getX(), y, b.getZ());
- if (block.getType() == getItem().getType() && BlockStorage.check(block, getID())) {
+ if (block.getType() == getItem().getType() && BlockStorage.check(block, getId())) {
floors.add(block);
}
}
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 0bb9da670..30d03c851 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
@@ -28,7 +28,7 @@ public abstract class GPSTransmitter extends SimpleSlimefunItem imp
this.capacity = 4 << (2 * tier);
addItemHandler(onPlace());
- registerBlockHandler(getID(), (p, b, stack, reason) -> {
+ registerBlockHandler(getId(), (p, b, stack, reason) -> {
UUID owner = UUID.fromString(BlockStorage.getLocationInfo(b.getLocation(), "owner"));
SlimefunPlugin.getGPSNetwork().updateTransmitter(b.getLocation(), owner, false);
return true;
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 a77cee59f..bbca533ed 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
@@ -75,7 +75,7 @@ public class Talisman extends SlimefunItem {
lore.add(line);
}
- enderTalisman = new SlimefunItemStack("ENDER_" + getID(), getItem().getType(), name, lore.toArray(new String[0]));
+ enderTalisman = new SlimefunItemStack("ENDER_" + getId(), getItem().getType(), name, lore.toArray(new String[0]));
} else {
enderTalisman = null;
}
@@ -108,7 +108,7 @@ public class Talisman extends SlimefunItem {
@Override
public void postRegister() {
EnderTalisman talisman = new EnderTalisman(this, getEnderVariant());
- talisman.register(addon);
+ talisman.register(getAddon());
}
@Override
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/StrangeNetherGoo.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/StrangeNetherGoo.java
index a1b0ab966..f5f79532f 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/StrangeNetherGoo.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/misc/StrangeNetherGoo.java
@@ -1,14 +1,25 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.misc;
+import javax.annotation.Nonnull;
+import java.util.Optional;
+
+import org.bukkit.ChatColor;
+import org.bukkit.DyeColor;
+import org.bukkit.GameMode;
import org.bukkit.Tag;
import org.bukkit.block.Block;
import org.bukkit.entity.Piglin;
+import org.bukkit.entity.Sheep;
import org.bukkit.inventory.ItemStack;
+import org.bukkit.potion.PotionEffect;
+import org.bukkit.potion.PotionEffectType;
+import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils;
import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting;
import io.github.thebusybiscuit.slimefun4.api.items.settings.IntRangeSetting;
-import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler;
import io.github.thebusybiscuit.slimefun4.core.attributes.PiglinBarterDrop;
+import io.github.thebusybiscuit.slimefun4.core.handlers.EntityInteractHandler;
+import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler;
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
import io.github.thebusybiscuit.slimefun4.implementation.items.magical.VillagerRune;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
@@ -16,9 +27,6 @@ import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
-import javax.annotation.Nonnull;
-import java.util.Optional;
-
/**
* This {@link SlimefunItem} can only be obtained via bartering with a {@link Piglin}, its
* only current uses is the recipe for crafting the {@link VillagerRune}.
@@ -37,6 +45,7 @@ public class StrangeNetherGoo extends SimpleSlimefunItem impleme
super(category, item, recipeType, recipe);
addItemSetting(chance);
+ addItemHandler(onRightClickEntity());
}
@Override
@@ -56,4 +65,27 @@ public class StrangeNetherGoo extends SimpleSlimefunItem impleme
};
}
+ private EntityInteractHandler onRightClickEntity() {
+ return (e, item, hand) -> {
+ if (e.getRightClicked() instanceof Sheep) {
+ Sheep s = (Sheep) e.getRightClicked();
+
+ if (s.getCustomName() != null) {
+ e.setCancelled(true);
+ return;
+ }
+
+ if (e.getPlayer().getGameMode() != GameMode.CREATIVE) {
+ ItemUtils.consumeItem(item, false);
+ }
+
+ // Give Sheep color, name and effect
+ s.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 60, 2));
+ s.setColor(DyeColor.PURPLE);
+ s.setCustomName(ChatColor.DARK_PURPLE + "Tainted Sheep");
+ e.setCancelled(true);
+
+ }
+ };
+ }
}
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 88a1673b8..065c7277e 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
@@ -45,7 +45,7 @@ public class ChristmasPresent extends SimpleSlimefunItem impl
e.setCancelled(true);
if (e.getPlayer().getGameMode() != GameMode.CREATIVE) {
- ItemUtils.consumeItem(item, false);
+ ItemUtils.consumeItem(e.getItemInHand(), false);
}
FireworkUtils.launchRandom(e.getPlayer(), 3);
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 ada035c21..d452896f3 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
@@ -127,7 +127,7 @@ class ExplosiveTool extends SimpleSlimefunItem implements NotPla
SlimefunItem sfItem = BlockStorage.check(b);
if (sfItem != null && !sfItem.useVanillaBlockBreaking()) {
- SlimefunBlockHandler handler = SlimefunPlugin.getRegistry().getBlockHandlers().get(sfItem.getID());
+ SlimefunBlockHandler handler = SlimefunPlugin.getRegistry().getBlockHandlers().get(sfItem.getId());
if (handler != null && !handler.onBreak(p, b, sfItem, UnregisterReason.PLAYER_BREAK)) {
drops.add(BlockStorage.retrieve(b));
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java
index db808b7b4..559a7a94b 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java
@@ -104,12 +104,12 @@ public class AncientAltarListener implements Listener {
return;
}
- String id = slimefunBlock.get().getID();
+ String id = slimefunBlock.get().getId();
- if (id.equals(pedestalItem.getID())) {
+ if (id.equals(pedestalItem.getId())) {
e.cancel();
usePedestal(b, e.getPlayer());
- } else if (id.equals(altarItem.getID())) {
+ } else if (id.equals(altarItem.getId())) {
if (!Slimefun.hasUnlocked(e.getPlayer(), altarItem, true) || altarsInUse.contains(b.getLocation())) {
e.cancel();
return;
@@ -259,7 +259,7 @@ public class AncientAltarListener implements Listener {
if (pedestal.getType() == Material.DISPENSER) {
String id = BlockStorage.checkID(pedestal);
- if (id != null && id.equals(pedestalItem.getID())) {
+ if (id != null && id.equals(pedestalItem.getId())) {
SlimefunPlugin.getLocalization().sendMessage(e.getPlayer(), "messages.cannot-place", true);
e.setCancelled(true);
}
@@ -270,28 +270,28 @@ public class AncientAltarListener implements Listener {
private List getPedestals(@Nonnull Block altar) {
List list = new ArrayList<>();
- if (BlockStorage.check(altar.getRelative(2, 0, -2), pedestalItem.getID())) {
+ if (BlockStorage.check(altar.getRelative(2, 0, -2), pedestalItem.getId())) {
list.add(altar.getRelative(2, 0, -2));
}
- if (BlockStorage.check(altar.getRelative(3, 0, 0), pedestalItem.getID())) {
+ if (BlockStorage.check(altar.getRelative(3, 0, 0), pedestalItem.getId())) {
list.add(altar.getRelative(3, 0, 0));
}
- if (BlockStorage.check(altar.getRelative(2, 0, 2), pedestalItem.getID())) {
+ if (BlockStorage.check(altar.getRelative(2, 0, 2), pedestalItem.getId())) {
list.add(altar.getRelative(2, 0, 2));
}
- if (BlockStorage.check(altar.getRelative(0, 0, 3), pedestalItem.getID())) {
+ if (BlockStorage.check(altar.getRelative(0, 0, 3), pedestalItem.getId())) {
list.add(altar.getRelative(0, 0, 3));
}
- if (BlockStorage.check(altar.getRelative(-2, 0, 2), pedestalItem.getID())) {
+ if (BlockStorage.check(altar.getRelative(-2, 0, 2), pedestalItem.getId())) {
list.add(altar.getRelative(-2, 0, 2));
}
- if (BlockStorage.check(altar.getRelative(-3, 0, 0), pedestalItem.getID())) {
+ if (BlockStorage.check(altar.getRelative(-3, 0, 0), pedestalItem.getId())) {
list.add(altar.getRelative(-3, 0, 0));
}
- if (BlockStorage.check(altar.getRelative(-2, 0, -2), pedestalItem.getID())) {
+ if (BlockStorage.check(altar.getRelative(-2, 0, -2), pedestalItem.getId())) {
list.add(altar.getRelative(-2, 0, -2));
}
- if (BlockStorage.check(altar.getRelative(0, 0, -3), pedestalItem.getID())) {
+ if (BlockStorage.check(altar.getRelative(0, 0, -3), pedestalItem.getId())) {
list.add(altar.getRelative(0, 0, -3));
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java
index 625a7911c..815cb6c6e 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java
@@ -39,6 +39,7 @@ import me.mrCookieSlime.Slimefun.api.Slimefun;
* and {@link BlockBreakEvent}.
*
* @author TheBusyBiscuit
+ * @author Linox
*
* @see BlockPlaceHandler
* @see BlockBreakHandler
@@ -51,32 +52,42 @@ public class BlockListener implements Listener {
plugin.getServer().getPluginManager().registerEvents(this, plugin);
}
- @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
- public void onBlockPlace(BlockPlaceEvent e) {
+ @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
+ public void onBlockPlaceExisting(BlockPlaceEvent e) {
+ // This prevents Players from placing a block where another block already exists
+ // While this can cause ghost blocks it also prevents them from replacing grass
+ // or saplings etc...
if (BlockStorage.hasBlockInfo(e.getBlock())) {
e.setCancelled(true);
- return;
}
+ }
+ @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
+ public void onBlockPlace(BlockPlaceEvent e) {
ItemStack item = e.getItemInHand();
-
SlimefunItem sfItem = SlimefunItem.getByItem(item);
- if (sfItem != null && Slimefun.isEnabled(e.getPlayer(), sfItem, true) && !(sfItem instanceof NotPlaceable)) {
+
+ if (sfItem != null && !(sfItem instanceof NotPlaceable) && Slimefun.isEnabled(e.getPlayer(), sfItem, true)) {
if (!Slimefun.hasUnlocked(e.getPlayer(), sfItem, true)) {
e.setCancelled(true);
} else {
if (SlimefunPlugin.getBlockDataService().isTileEntity(e.getBlock().getType())) {
- SlimefunPlugin.getBlockDataService().setBlockData(e.getBlock(), sfItem.getID());
+ SlimefunPlugin.getBlockDataService().setBlockData(e.getBlock(), sfItem.getId());
}
- BlockStorage.addBlockInfo(e.getBlock(), "id", sfItem.getID(), true);
+ BlockStorage.addBlockInfo(e.getBlock(), "id", sfItem.getId(), true);
sfItem.callItemHandler(BlockPlaceHandler.class, handler -> handler.onPlayerPlace(e));
}
}
}
- @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
+ @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent e) {
+ if (SlimefunPlugin.getThirdPartySupportService().isEventFaked(e)) {
+ // This is a "fake" event, we can ignore it.
+ return;
+ }
+
checkForSensitiveBlockAbove(e.getPlayer(), e.getBlock());
ItemStack item = e.getPlayer().getInventory().getItemInMainHand();
@@ -94,6 +105,7 @@ public class BlockListener implements Listener {
dropItems(e, drops);
}
+ @ParametersAreNonnullByDefault
private void callToolHandler(BlockBreakEvent e, ItemStack item, int fortune, List drops) {
SlimefunItem tool = SlimefunItem.getByItem(item);
@@ -106,6 +118,7 @@ public class BlockListener implements Listener {
}
}
+ @ParametersAreNonnullByDefault
private void callBlockHandler(BlockBreakEvent e, ItemStack item, int fortune, List drops) {
SlimefunItem sfItem = BlockStorage.check(e.getBlock());
@@ -118,7 +131,7 @@ public class BlockListener implements Listener {
}
if (sfItem != null && !sfItem.useVanillaBlockBreaking()) {
- SlimefunBlockHandler blockHandler = SlimefunPlugin.getRegistry().getBlockHandlers().get(sfItem.getID());
+ SlimefunBlockHandler blockHandler = SlimefunPlugin.getRegistry().getBlockHandlers().get(sfItem.getId());
if (blockHandler != null) {
if (!blockHandler.onBreak(e.getPlayer(), e.getBlock(), sfItem, UnregisterReason.PLAYER_BREAK)) {
@@ -167,7 +180,7 @@ public class BlockListener implements Listener {
SlimefunItem sfItem = BlockStorage.check(blockAbove);
if (sfItem != null && !sfItem.useVanillaBlockBreaking()) {
- SlimefunBlockHandler blockHandler = SlimefunPlugin.getRegistry().getBlockHandlers().get(sfItem.getID());
+ SlimefunBlockHandler blockHandler = SlimefunPlugin.getRegistry().getBlockHandlers().get(sfItem.getId());
if (blockHandler != null) {
if (blockHandler.onBreak(p, blockAbove, sfItem, UnregisterReason.PLAYER_BREAK)) {
@@ -183,16 +196,19 @@ public class BlockListener implements Listener {
}
private int getBonusDropsWithFortune(@Nullable ItemStack item, @Nonnull Block b) {
- int fortune = 1;
+ int amount = 1;
- if (item != null && item.getEnchantments().containsKey(Enchantment.LOOT_BONUS_BLOCKS) && !item.getEnchantments().containsKey(Enchantment.SILK_TOUCH)) {
- Random random = ThreadLocalRandom.current();
+ if (item != null) {
int fortuneLevel = item.getEnchantmentLevel(Enchantment.LOOT_BONUS_BLOCKS);
- fortune = Math.max(1, random.nextInt(fortuneLevel + 2) - 1);
- fortune = (b.getType() == Material.LAPIS_ORE ? 4 + random.nextInt(5) : 1) * (fortune + 1);
+ if (fortuneLevel > 0 && !item.containsEnchantment(Enchantment.SILK_TOUCH)) {
+ Random random = ThreadLocalRandom.current();
+
+ amount = Math.max(1, random.nextInt(fortuneLevel + 2) - 1);
+ amount = (b.getType() == Material.LAPIS_ORE ? 4 + random.nextInt(5) : 1) * (amount + 1);
+ }
}
- return fortune;
+ return amount;
}
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/CargoNodeListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/CargoNodeListener.java
index 67ca488cc..d28b8475a 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/CargoNodeListener.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/CargoNodeListener.java
@@ -47,6 +47,6 @@ public class CargoNodeListener implements Listener {
return false;
}
- return sfItem.getID().equals(SlimefunItems.CARGO_INPUT_NODE.getItemId()) || sfItem.getID().equals(SlimefunItems.CARGO_OUTPUT_NODE.getItemId()) || sfItem.getID().equals(SlimefunItems.CARGO_OUTPUT_NODE_2.getItemId());
+ return sfItem.getId().equals(SlimefunItems.CARGO_INPUT_NODE.getItemId()) || sfItem.getId().equals(SlimefunItems.CARGO_OUTPUT_NODE.getItemId()) || sfItem.getId().equals(SlimefunItems.CARGO_OUTPUT_NODE_2.getItemId());
}
}
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 1a4fd5b5b..c2d39a904 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
@@ -104,7 +104,7 @@ public class DebugFishListener implements Listener {
p.sendMessage(" ");
p.sendMessage(ChatColors.color("&d" + b.getType() + " &e@ X: " + b.getX() + " Y: " + b.getY() + " Z: " + b.getZ()));
- p.sendMessage(ChatColors.color("&dId: " + "&e" + item.getID()));
+ p.sendMessage(ChatColors.color("&dId: " + "&e" + item.getId()));
p.sendMessage(ChatColors.color("&dPlugin: " + "&e" + item.getAddon().getName()));
if (b.getState() instanceof Skull) {
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 854e04fcb..c527cc7c5 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
@@ -36,7 +36,7 @@ public class ExplosionsListener implements Listener {
blocks.remove();
if (!(item instanceof WitherProof)) {
- SlimefunBlockHandler blockHandler = SlimefunPlugin.getRegistry().getBlockHandlers().get(item.getID());
+ SlimefunBlockHandler blockHandler = SlimefunPlugin.getRegistry().getBlockHandlers().get(item.getId());
boolean success = true;
if (blockHandler != null) {
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/PiglinListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/PiglinListener.java
index 2add2f695..61c6b86a1 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/PiglinListener.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/PiglinListener.java
@@ -94,7 +94,7 @@ public class PiglinListener implements Listener {
int chance = ((PiglinBarterDrop) sfi).getBarteringLootChance();
if (chance < 1 || chance >= 100) {
- sfi.warn("The Piglin Bartering chance must be between 1-99% on item: " + sfi.getID());
+ sfi.warn("The Piglin Bartering chance must be between 1-99% on item: " + sfi.getId());
} else if (chance > ThreadLocalRandom.current().nextInt(100)) {
e.getItemDrop().setItemStack(sfi.getRecipeOutput());
return;
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunBootsListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunBootsListener.java
index 55c19435d..777b7c141 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunBootsListener.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunBootsListener.java
@@ -65,7 +65,7 @@ public class SlimefunBootsListener implements Listener {
if (boots instanceof StomperBoots) {
e.setCancelled(true);
((StomperBoots) boots).stomp(e);
- } else if (boots.getID().equals("SLIME_BOOTS") || boots.getID().equals("SLIME_STEEL_BOOTS")) {
+ } else if (boots.getId().equals("SLIME_BOOTS") || boots.getId().equals("SLIME_STEEL_BOOTS")) {
e.setCancelled(true);
}
}
@@ -75,7 +75,7 @@ public class SlimefunBootsListener implements Listener {
Player p = (Player) e.getEntity();
SlimefunItem boots = SlimefunItem.getByItem(p.getInventory().getBoots());
- if (boots != null && boots.getID().equals("ENDER_BOOTS") && Slimefun.hasUnlocked(p, boots, true)) {
+ if (boots != null && boots.getId().equals("ENDER_BOOTS") && Slimefun.hasUnlocked(p, boots, true)) {
e.setCancelled(true);
}
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunItemListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunItemListener.java
index 2b54a4cd2..59ca7b6a6 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunItemListener.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunItemListener.java
@@ -96,7 +96,7 @@ public class SlimefunItemListener implements Listener {
boolean interactable = optional.get().callItemHandler(BlockUseHandler.class, handler -> handler.onRightClick(event));
if (!interactable) {
- String id = optional.get().getID();
+ String id = optional.get().getId();
Player p = e.getPlayer();
if (BlockMenuPreset.isInventory(id)) {
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/VanillaMachinesListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/VanillaMachinesListener.java
deleted file mode 100644
index e4e5b49ee..000000000
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/VanillaMachinesListener.java
+++ /dev/null
@@ -1,158 +0,0 @@
-package io.github.thebusybiscuit.slimefun4.implementation.listeners;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
-import org.bukkit.block.BrewingStand;
-import org.bukkit.entity.Player;
-import org.bukkit.event.Event.Result;
-import org.bukkit.event.EventHandler;
-import org.bukkit.event.Listener;
-import org.bukkit.event.inventory.CraftItemEvent;
-import org.bukkit.event.inventory.InventoryAction;
-import org.bukkit.event.inventory.InventoryClickEvent;
-import org.bukkit.event.inventory.InventoryType;
-import org.bukkit.event.inventory.PrepareItemCraftEvent;
-import org.bukkit.inventory.Inventory;
-import org.bukkit.inventory.ItemStack;
-
-import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion;
-import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
-import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
-import io.github.thebusybiscuit.slimefun4.implementation.items.VanillaItem;
-import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
-
-/**
- * This {@link Listener} prevents any {@link SlimefunItem} from being used in a vanilla
- * machine like the workbench, grindstone, brewing stand or an anvil.
- *
- * @author TheBusyBiscuit
- * @author NathanAdhitya
- * @author Steve
- * @author VoidAngel
- *
- */
-public class VanillaMachinesListener implements Listener {
-
- public VanillaMachinesListener(@Nonnull SlimefunPlugin plugin) {
- plugin.getServer().getPluginManager().registerEvents(this, plugin);
- }
-
- @EventHandler(ignoreCancelled = true)
- public void onGrindstone(InventoryClickEvent e) {
- // The Grindstone was only ever added in MC 1.14
- if (!SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_14)) {
- return;
- }
-
- if (e.getRawSlot() == 2 && e.getWhoClicked() instanceof Player && e.getInventory().getType() == InventoryType.GRINDSTONE) {
- ItemStack item1 = e.getInventory().getContents()[0];
- ItemStack item2 = e.getInventory().getContents()[1];
-
- if (checkForUnallowedItems(item1, item2)) {
- e.setResult(Result.DENY);
- }
- }
-
- }
-
- @EventHandler
- public void onCraft(CraftItemEvent e) {
- for (ItemStack item : e.getInventory().getContents()) {
- SlimefunItem sfItem = SlimefunItem.getByItem(item);
-
- if (sfItem != null && !sfItem.isUseableInWorkbench()) {
- e.setResult(Result.DENY);
- SlimefunPlugin.getLocalization().sendMessage((Player) e.getWhoClicked(), "workbench.not-enhanced", true);
- break;
- }
- }
- }
-
- @EventHandler
- public void onPrepareCraft(PrepareItemCraftEvent e) {
- if (e.getInventory().getResult() != null) {
- for (ItemStack item : e.getInventory().getContents()) {
- SlimefunItem sfItem = SlimefunItem.getByItem(item);
-
- if (sfItem != null && !sfItem.isUseableInWorkbench()) {
- e.getInventory().setResult(null);
- break;
- }
- }
- }
- }
-
- @EventHandler(ignoreCancelled = true)
- public void onAnvil(InventoryClickEvent e) {
- if (e.getRawSlot() == 2 && e.getInventory().getType() == InventoryType.ANVIL && e.getWhoClicked() instanceof Player) {
- ItemStack item1 = e.getInventory().getContents()[0];
- ItemStack item2 = e.getInventory().getContents()[1];
-
- if (checkForUnallowedItems(item1, item2)) {
- e.setResult(Result.DENY);
- SlimefunPlugin.getLocalization().sendMessage((Player) e.getWhoClicked(), "anvil.not-working", true);
- }
- }
- }
-
- @EventHandler(ignoreCancelled = true)
- public void onCartographyTable(InventoryClickEvent e) {
- // The Cartography Table was only ever added in MC 1.14
- if (!SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_14)) {
- return;
- }
-
- if (e.getRawSlot() == 2 && e.getInventory().getType() == InventoryType.CARTOGRAPHY && e.getWhoClicked() instanceof Player) {
- ItemStack item1 = e.getInventory().getContents()[0];
- ItemStack item2 = e.getInventory().getContents()[1];
-
- if (checkForUnallowedItems(item1, item2)) {
- e.setResult(Result.DENY);
- SlimefunPlugin.getLocalization().sendMessage((Player) e.getWhoClicked(), "cartography_table.not-working", true);
- }
- }
- }
-
- @EventHandler(ignoreCancelled = true)
- public void onPreBrew(InventoryClickEvent e) {
- Inventory clickedInventory = e.getClickedInventory();
- Inventory topInventory = e.getView().getTopInventory();
-
- if (clickedInventory != null && topInventory.getType() == InventoryType.BREWING && topInventory.getHolder() instanceof BrewingStand) {
- if (e.getAction() == InventoryAction.HOTBAR_SWAP) {
- e.setCancelled(true);
- return;
- }
-
- if (clickedInventory.getType() == InventoryType.BREWING) {
- e.setCancelled(isUnallowed(SlimefunItem.getByItem(e.getCursor())));
- } else {
- e.setCancelled(isUnallowed(SlimefunItem.getByItem(e.getCurrentItem())));
- }
-
- if (e.getResult() == Result.DENY) {
- SlimefunPlugin.getLocalization().sendMessage((Player) e.getWhoClicked(), "brewing_stand.not-working", true);
- }
- }
- }
-
- private boolean checkForUnallowedItems(@Nullable ItemStack item1, @Nullable ItemStack item2) {
- if (SlimefunGuide.isGuideItem(item1) || SlimefunGuide.isGuideItem(item2)) {
- return true;
- } else {
- SlimefunItem sfItem1 = SlimefunItem.getByItem(item1);
- SlimefunItem sfItem2 = SlimefunItem.getByItem(item2);
-
- if (isUnallowed(sfItem1) || isUnallowed(sfItem2)) {
- return true;
- }
- }
-
- return false;
- }
-
- private boolean isUnallowed(@Nullable SlimefunItem item) {
- return item != null && !(item instanceof VanillaItem) && !item.isDisabled();
- }
-}
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 998f6dbdd..4626b2ede 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
@@ -35,7 +35,7 @@ public class WitherListener implements Listener {
SlimefunItem item = BlockStorage.check(e.getBlock());
// Hardened Glass is excluded from here
- if (item instanceof WitherProof && !item.getID().equals(SlimefunItems.HARDENED_GLASS.getItemId())) {
+ 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/listeners/crafting/AnvilListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/AnvilListener.java
new file mode 100644
index 000000000..4df3a82eb
--- /dev/null
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/AnvilListener.java
@@ -0,0 +1,43 @@
+package io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting;
+
+import javax.annotation.Nonnull;
+
+import org.bukkit.block.BrewingStand;
+import org.bukkit.entity.Player;
+import org.bukkit.event.Event.Result;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.inventory.InventoryClickEvent;
+import org.bukkit.event.inventory.InventoryType;
+import org.bukkit.inventory.ItemStack;
+
+import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
+import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
+
+/**
+ * This {@link Listener} prevents any {@link SlimefunItem} from being used in a
+ * {@link BrewingStand}.
+ *
+ * @author TheBusyBiscuit
+ *
+ */
+public class AnvilListener implements SlimefunCraftingListener {
+
+ public AnvilListener(@Nonnull SlimefunPlugin plugin) {
+ plugin.getServer().getPluginManager().registerEvents(this, plugin);
+ }
+
+ @EventHandler(ignoreCancelled = true)
+ public void onAnvil(InventoryClickEvent e) {
+ if (e.getRawSlot() == 2 && e.getInventory().getType() == InventoryType.ANVIL && e.getWhoClicked() instanceof Player) {
+ ItemStack item1 = e.getInventory().getContents()[0];
+ ItemStack item2 = e.getInventory().getContents()[1];
+
+ if (hasUnallowedItems(item1, item2)) {
+ e.setResult(Result.DENY);
+ SlimefunPlugin.getLocalization().sendMessage((Player) e.getWhoClicked(), "anvil.not-working", true);
+ }
+ }
+ }
+
+}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/BrewingStandListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/BrewingStandListener.java
new file mode 100644
index 000000000..60a4594af
--- /dev/null
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/BrewingStandListener.java
@@ -0,0 +1,55 @@
+package io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting;
+
+import javax.annotation.Nonnull;
+
+import org.bukkit.block.BrewingStand;
+import org.bukkit.entity.Player;
+import org.bukkit.event.Event.Result;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.inventory.InventoryAction;
+import org.bukkit.event.inventory.InventoryClickEvent;
+import org.bukkit.event.inventory.InventoryType;
+import org.bukkit.inventory.Inventory;
+
+import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
+import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
+
+/**
+ * This {@link Listener} prevents any {@link SlimefunItem} from being used in a
+ * {@link BrewingStand}.
+ *
+ * @author VoidAngel
+ * @author SoSeDiK
+ *
+ */
+public class BrewingStandListener implements SlimefunCraftingListener {
+
+ public BrewingStandListener(@Nonnull SlimefunPlugin plugin) {
+ plugin.getServer().getPluginManager().registerEvents(this, plugin);
+ }
+
+ @EventHandler(ignoreCancelled = true)
+ public void onPreBrew(InventoryClickEvent e) {
+ Inventory clickedInventory = e.getClickedInventory();
+ Inventory topInventory = e.getView().getTopInventory();
+
+ if (clickedInventory != null && topInventory.getType() == InventoryType.BREWING && topInventory.getHolder() instanceof BrewingStand) {
+ if (e.getAction() == InventoryAction.HOTBAR_SWAP) {
+ e.setCancelled(true);
+ return;
+ }
+
+ if (clickedInventory.getType() == InventoryType.BREWING) {
+ e.setCancelled(isUnallowed(SlimefunItem.getByItem(e.getCursor())));
+ } else {
+ e.setCancelled(isUnallowed(SlimefunItem.getByItem(e.getCurrentItem())));
+ }
+
+ if (e.getResult() == Result.DENY) {
+ SlimefunPlugin.getLocalization().sendMessage((Player) e.getWhoClicked(), "brewing_stand.not-working", true);
+ }
+ }
+ }
+
+}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/CartographyTableListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/CartographyTableListener.java
new file mode 100644
index 000000000..9586fdeb2
--- /dev/null
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/CartographyTableListener.java
@@ -0,0 +1,42 @@
+package io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting;
+
+import javax.annotation.Nonnull;
+
+import org.bukkit.entity.Player;
+import org.bukkit.event.Event.Result;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.inventory.InventoryClickEvent;
+import org.bukkit.event.inventory.InventoryType;
+import org.bukkit.inventory.ItemStack;
+
+import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
+import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
+
+/**
+ * This {@link Listener} prevents any {@link SlimefunItem} from being used in a
+ * cartography table.
+ *
+ * @author poma123
+ *
+ */
+public class CartographyTableListener implements SlimefunCraftingListener {
+
+ public CartographyTableListener(@Nonnull SlimefunPlugin plugin) {
+ plugin.getServer().getPluginManager().registerEvents(this, plugin);
+ }
+
+ @EventHandler(ignoreCancelled = true)
+ public void onCartographyTable(InventoryClickEvent e) {
+ if (e.getRawSlot() == 2 && e.getInventory().getType() == InventoryType.CARTOGRAPHY && e.getWhoClicked() instanceof Player) {
+ ItemStack item1 = e.getInventory().getContents()[0];
+ ItemStack item2 = e.getInventory().getContents()[1];
+
+ if (hasUnallowedItems(item1, item2)) {
+ e.setResult(Result.DENY);
+ SlimefunPlugin.getLocalization().sendMessage((Player) e.getWhoClicked(), "cartography_table.not-working", true);
+ }
+ }
+ }
+
+}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/CauldronListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/CauldronListener.java
new file mode 100644
index 000000000..8fd51fc8a
--- /dev/null
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/CauldronListener.java
@@ -0,0 +1,52 @@
+package io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting;
+
+import javax.annotation.Nonnull;
+
+import org.bukkit.Material;
+import org.bukkit.block.Block;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.EventPriority;
+import org.bukkit.event.Listener;
+import org.bukkit.event.block.Action;
+import org.bukkit.event.player.PlayerInteractEvent;
+import org.bukkit.inventory.ItemStack;
+
+import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
+import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag;
+import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
+
+/**
+ * This {@link Listener} prevents any {@link SlimefunItem} from being used in a
+ * Cauldron.
+ * This is mainly used to prevent the discoloring of leather armor.
+ *
+ * @author TheBusyBiscuit
+ *
+ */
+public class CauldronListener implements SlimefunCraftingListener {
+
+ public CauldronListener(@Nonnull SlimefunPlugin plugin) {
+ plugin.getServer().getPluginManager().registerEvents(this, plugin);
+ }
+
+ @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
+ public void onCauldronUse(PlayerInteractEvent e) {
+ if (e.getAction() == Action.RIGHT_CLICK_BLOCK) {
+ Block block = e.getClickedBlock();
+
+ if (block.getType() == Material.CAULDRON) {
+ ItemStack item = e.getItem();
+
+ if (item != null && SlimefunTag.LEATHER_ARMOR.isTagged(item.getType())) {
+ SlimefunItem sfItem = SlimefunItem.getByItem(item);
+
+ if (isUnallowed(sfItem)) {
+ e.setCancelled(true);
+ SlimefunPlugin.getLocalization().sendMessage(e.getPlayer(), "cauldron.no-discoloring");
+ }
+ }
+ }
+ }
+ }
+
+}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/CraftingTableListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/CraftingTableListener.java
new file mode 100644
index 000000000..e18b64d11
--- /dev/null
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/CraftingTableListener.java
@@ -0,0 +1,56 @@
+package io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting;
+
+import javax.annotation.Nonnull;
+
+import org.bukkit.entity.Player;
+import org.bukkit.event.Event.Result;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.inventory.CraftItemEvent;
+import org.bukkit.event.inventory.PrepareItemCraftEvent;
+import org.bukkit.inventory.ItemStack;
+
+import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
+import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
+
+/**
+ * This {@link Listener} prevents any {@link SlimefunItem} from being used in a
+ * crafting table.
+ *
+ * @author TheBusyBiscuit
+ *
+ */
+public class CraftingTableListener implements SlimefunCraftingListener {
+
+ public CraftingTableListener(@Nonnull SlimefunPlugin plugin) {
+ plugin.getServer().getPluginManager().registerEvents(this, plugin);
+ }
+
+ @EventHandler
+ public void onCraft(CraftItemEvent e) {
+ for (ItemStack item : e.getInventory().getContents()) {
+ SlimefunItem sfItem = SlimefunItem.getByItem(item);
+
+ if (sfItem != null && !sfItem.isUseableInWorkbench()) {
+ e.setResult(Result.DENY);
+ SlimefunPlugin.getLocalization().sendMessage((Player) e.getWhoClicked(), "workbench.not-enhanced", true);
+ break;
+ }
+ }
+ }
+
+ @EventHandler
+ public void onPrepareCraft(PrepareItemCraftEvent e) {
+ if (e.getInventory().getResult() != null) {
+ for (ItemStack item : e.getInventory().getContents()) {
+ SlimefunItem sfItem = SlimefunItem.getByItem(item);
+
+ if (sfItem != null && !sfItem.isUseableInWorkbench()) {
+ e.getInventory().setResult(null);
+ break;
+ }
+ }
+ }
+ }
+
+}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/GrindstoneListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/GrindstoneListener.java
new file mode 100644
index 000000000..36db7e6eb
--- /dev/null
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/GrindstoneListener.java
@@ -0,0 +1,42 @@
+package io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting;
+
+import javax.annotation.Nonnull;
+
+import org.bukkit.entity.Player;
+import org.bukkit.event.Event.Result;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.inventory.InventoryClickEvent;
+import org.bukkit.event.inventory.InventoryType;
+import org.bukkit.inventory.ItemStack;
+
+import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
+import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
+
+/**
+ * This {@link Listener} prevents any {@link SlimefunItem} from being used in a
+ * cartography table.
+ *
+ * @author NathanAdhitya
+ *
+ */
+public class GrindstoneListener implements SlimefunCraftingListener {
+
+ public GrindstoneListener(@Nonnull SlimefunPlugin plugin) {
+ plugin.getServer().getPluginManager().registerEvents(this, plugin);
+ }
+
+ @EventHandler(ignoreCancelled = true)
+ public void onGrindstone(InventoryClickEvent e) {
+ if (e.getRawSlot() == 2 && e.getWhoClicked() instanceof Player && e.getInventory().getType() == InventoryType.GRINDSTONE) {
+ ItemStack item1 = e.getInventory().getContents()[0];
+ ItemStack item2 = e.getInventory().getContents()[1];
+
+ if (hasUnallowedItems(item1, item2)) {
+ e.setResult(Result.DENY);
+ }
+ }
+
+ }
+
+}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/SlimefunCraftingListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/SlimefunCraftingListener.java
new file mode 100644
index 000000000..6fdba5ab0
--- /dev/null
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/SlimefunCraftingListener.java
@@ -0,0 +1,42 @@
+package io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting;
+
+import javax.annotation.Nullable;
+
+import org.bukkit.event.Listener;
+import org.bukkit.inventory.ItemStack;
+
+import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
+import io.github.thebusybiscuit.slimefun4.implementation.items.VanillaItem;
+import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
+
+interface SlimefunCraftingListener extends Listener {
+
+ default boolean hasUnallowedItems(@Nullable ItemStack item1, @Nullable ItemStack item2) {
+ if (SlimefunGuide.isGuideItem(item1) || SlimefunGuide.isGuideItem(item2)) {
+ return true;
+ } else {
+ SlimefunItem sfItem1 = SlimefunItem.getByItem(item1);
+ SlimefunItem sfItem2 = SlimefunItem.getByItem(item2);
+
+ if (isUnallowed(sfItem1) || isUnallowed(sfItem2)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ default boolean isUnallowed(@Nullable ItemStack item) {
+ if (item == null) {
+ return false;
+ }
+
+ SlimefunItem sfItem = SlimefunItem.getByItem(item);
+ return !(sfItem instanceof VanillaItem) && !sfItem.isDisabled();
+ }
+
+ default boolean isUnallowed(@Nullable SlimefunItem item) {
+ return item != null && !(item instanceof VanillaItem) && !item.isDisabled();
+ }
+
+}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/package-info.java
new file mode 100644
index 000000000..8c8f08ecc
--- /dev/null
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/crafting/package-info.java
@@ -0,0 +1,5 @@
+/**
+ * This package holds every {@link org.bukkit.event.Listener} which is responsible for preventing that a
+ * {@link me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem} is used in an unallowed crafting operation
+ */
+package io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting;
\ No newline at end of file
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 491061bfe..e39b73470 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
@@ -247,7 +247,7 @@ public final class PostSetup {
private static boolean isDust(@Nonnull ItemStack item) {
SlimefunItem sfItem = SlimefunItem.getByItem(item);
- return sfItem != null && sfItem.getID().endsWith("_DUST");
+ return sfItem != null && sfItem.getId().endsWith("_DUST");
}
private static void registerMachineRecipe(String machine, int seconds, ItemStack[] input, ItemStack[] 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 1408e7f0c..9e1aefef2 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
@@ -15,9 +15,8 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
* This static setup class is used to register all default implementations of
* {@link Research} on startup.
*
- * @author TheBusyBiscuit
- *
* @see Research
+ * @see SlimefunItems
*
*/
public final class ResearchSetup {
@@ -279,6 +278,7 @@ public final class ResearchSetup {
register("even_higher_tier_capacitors", 266, "Tier 3 Capacitors", 40, SlimefunItems.ENERGIZED_CAPACITOR);
register("caveman_talisman", 267, "Talisman of the Caveman", 20, SlimefunItems.TALISMAN_CAVEMAN);
register("elytra_cap", 268, "Crash Gear", 20, SlimefunItems.ELYTRA_CAP);
+ register("energy_connectors", 269, "Wired Connections", 12, SlimefunItems.ENERGY_CONNECTOR);
}
@ParametersAreNonnullByDefault
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 2107be891..4a401e158 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
@@ -64,6 +64,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.cargo.CargoOutput
import io.github.thebusybiscuit.slimefun4.implementation.items.cargo.ReactorAccessPort;
import io.github.thebusybiscuit.slimefun4.implementation.items.cargo.TrashCan;
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.Capacitor;
+import io.github.thebusybiscuit.slimefun4.implementation.items.electric.EnergyConnector;
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.EnergyRegulator;
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.gadgets.JetBoots;
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.gadgets.Jetpack;
@@ -202,8 +203,6 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
/**
* This static utility class holds the recipes of all items.
* This is the place where all items from Slimefun are registered.
- *
- * @author TheBusyBiscuit
*
*/
public final class SlimefunItemSetup {
@@ -1507,13 +1506,18 @@ public final class SlimefunItemSetup {
new ItemStack[] {SlimefunItems.SILVER_INGOT, SlimefunItems.DAMASCUS_STEEL_INGOT, SlimefunItems.SILVER_INGOT, SlimefunItems.DAMASCUS_STEEL_INGOT, SlimefunItems.ELECTRIC_MOTOR, SlimefunItems.DAMASCUS_STEEL_INGOT, SlimefunItems.SILVER_INGOT, SlimefunItems.DAMASCUS_STEEL_INGOT, SlimefunItems.SILVER_INGOT})
.register(plugin);
+ new EnergyConnector(categories.electricity, SlimefunItems.ENERGY_CONNECTOR, RecipeType.ENHANCED_CRAFTING_TABLE,
+ new ItemStack[] {SlimefunItems.CARBON, SlimefunItems.COPPER_WIRE, SlimefunItems.CARBON, SlimefunItems.COPPER_WIRE, new ItemStack(Material.REDSTONE_BLOCK), SlimefunItems.COPPER_WIRE, SlimefunItems.CARBON, SlimefunItems.COPPER_WIRE, SlimefunItems.CARBON},
+ new SlimefunItemStack(SlimefunItems.ENERGY_CONNECTOR, 8))
+ .register(plugin);
+
new SlimefunItem(categories.misc, SlimefunItems.DUCT_TAPE, RecipeType.ENHANCED_CRAFTING_TABLE,
new ItemStack[] {SlimefunItems.ALUMINUM_DUST, SlimefunItems.ALUMINUM_DUST, SlimefunItems.ALUMINUM_DUST, new ItemStack(Material.SLIME_BALL), new ItemStack(Material.WHITE_WOOL), new ItemStack(Material.SLIME_BALL), new ItemStack(Material.PAPER), new ItemStack(Material.PAPER), new ItemStack(Material.PAPER)},
new SlimefunItemStack(SlimefunItems.DUCT_TAPE, 2))
.register(plugin);
new Capacitor(categories.electricity, 128, SlimefunItems.SMALL_CAPACITOR, RecipeType.ENHANCED_CRAFTING_TABLE,
- new ItemStack[] {SlimefunItems.DURALUMIN_INGOT, SlimefunItems.REDSTONE_ALLOY, SlimefunItems.DURALUMIN_INGOT, new ItemStack(Material.REDSTONE), SlimefunItems.SULFATE, new ItemStack(Material.REDSTONE), SlimefunItems.DURALUMIN_INGOT, SlimefunItems.REDSTONE_ALLOY, SlimefunItems.DURALUMIN_INGOT})
+ new ItemStack[] {SlimefunItems.DURALUMIN_INGOT, SlimefunItems.SULFATE, SlimefunItems.DURALUMIN_INGOT, SlimefunItems.REDSTONE_ALLOY, SlimefunItems.ENERGY_CONNECTOR, SlimefunItems.REDSTONE_ALLOY, SlimefunItems.DURALUMIN_INGOT, new ItemStack(Material.REDSTONE), SlimefunItems.DURALUMIN_INGOT})
.register(plugin);
new Capacitor(categories.electricity, 512, SlimefunItems.MEDIUM_CAPACITOR, RecipeType.ENHANCED_CRAFTING_TABLE,
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 af2e747e5..1b8e09969 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
@@ -187,7 +187,7 @@ public class TickerTask implements Runnable {
new ErrorReport<>(x, l, item);
bugs.put(position, errors);
} else if (errors == 4) {
- Slimefun.getLogger().log(Level.SEVERE, "X: {0} Y: {1} Z: {2} ({3})", new Object[] { l.getBlockX(), l.getBlockY(), l.getBlockZ(), item.getID() });
+ Slimefun.getLogger().log(Level.SEVERE, "X: {0} Y: {1} Z: {2} ({3})", new Object[] { l.getBlockX(), l.getBlockY(), l.getBlockZ(), item.getId() });
Slimefun.getLogger().log(Level.SEVERE, "has thrown 4 error messages in the last 4 Ticks, the Block has been terminated.");
Slimefun.getLogger().log(Level.SEVERE, "Check your /plugins/Slimefun/error-reports/ folder for details.");
Slimefun.getLogger().log(Level.SEVERE, " ");
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/HeadTexture.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/HeadTexture.java
index 6d9cf0bc0..ea095a5d7 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/HeadTexture.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/HeadTexture.java
@@ -62,6 +62,7 @@ public enum HeadTexture {
FUEL_BUCKET("a84ddca766725b8b97413f259c3f7668070f6ae55483a90c8e5525394f9c099"),
ELECTRIC_PRESS("8d5cf92bc79ec19f4106441affff1406a1367010dcafb197dd94cfca1a6de0fc"),
ENERGY_REGULATOR("d78f2b7e5e75639ea7fb796c35d364c4df28b4243e66b76277aadcd6261337"),
+ ENERGY_CONNECTOR("1085e098756b995b00241644089c55a8f9acde35b9a37785d5e057a923613b"),
NETHER_ICE("3ce2dad9baf7eaba7e80d4d0f9fac0aab01a76b12fb71c3d2af2a16fdd4c7383"),
ENRICHED_NETHER_ICE("7c818aa13aabc7294838d21caac057e97bd8c89641a0c0f8a55442ff4e27"),
NETHER_ICE_COOLANT_CELL("8d3cd412555f897016213e5d6c7431b448b9e5644e1b19ec51b5316f35840e0"),
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/LoreBuilder.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/LoreBuilder.java
index 5ee60be57..79d66f24e 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/LoreBuilder.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/LoreBuilder.java
@@ -4,6 +4,8 @@ import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.Locale;
+import javax.annotation.Nonnull;
+
import io.github.thebusybiscuit.slimefun4.core.attributes.MachineTier;
import io.github.thebusybiscuit.slimefun4.core.attributes.MachineType;
import io.github.thebusybiscuit.slimefun4.core.attributes.Radioactivity;
@@ -31,40 +33,54 @@ public final class LoreBuilder {
private LoreBuilder() {}
- public static String radioactive(Radioactivity radioactivity) {
+ @Nonnull
+ public static String radioactive(@Nonnull Radioactivity radioactivity) {
return radioactivity.getLore();
}
- public static String machine(MachineTier tier, MachineType type) {
+ @Nonnull
+ public static String machine(@Nonnull MachineTier tier, @Nonnull MachineType type) {
return tier + " " + type;
}
+ @Nonnull
public static String speed(float speed) {
return "&8\u21E8 &b\u26A1 &7Speed: &b" + speed + 'x';
}
+ @Nonnull
public static String powerBuffer(int power) {
return power(power, " Buffer");
}
+ @Nonnull
public static String powerPerSecond(int power) {
return power(power, "/s");
}
- public static String power(int power, String suffix) {
+ @Nonnull
+ public static String power(int power, @Nonnull String suffix) {
return "&8\u21E8 &e\u26A1 &7" + power + " J" + suffix;
}
+ @Nonnull
public static String powerCharged(int charge, int capacity) {
return "&8\u21E8 &e\u26A1 &7" + charge + " / " + capacity + " J";
}
- public static String material(String material) {
+ @Nonnull
+ public static String material(@Nonnull String material) {
return "&8\u21E8 &7Material: &b" + material;
}
+ @Nonnull
public static String hunger(double value) {
return "&7&oRestores &b&o" + hungerFormat.format(value) + " &7&oHunger";
}
+ @Nonnull
+ public static String range(int blocks) {
+ return "&7Range: &c" + blocks + " blocks";
+ }
+
}
diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java
index 98e0340b5..844baf8ec 100644
--- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java
+++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/tags/SlimefunTag.java
@@ -63,6 +63,11 @@ public enum SlimefunTag implements Tag {
*/
MUSHROOMS,
+ /**
+ * All leather armor materials
+ */
+ LEATHER_ARMOR,
+
/**
* Every glass variant, includes both blocks and panes.
* Also stained glass and stained glass panes.
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 95cda4cb6..335b3fccc 100644
--- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/SlimefunItem.java
+++ b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/SlimefunItem.java
@@ -51,25 +51,66 @@ import me.mrCookieSlime.Slimefun.Objects.handlers.BlockTicker;
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemHandler;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
+/**
+ * A {@link SlimefunItem} is a custom item registered by a {@link SlimefunAddon}.
+ * This class defines the behaviours of the item, you can assign an {@link ItemHandler}
+ * to give the item functionality.
+ * In contrast to that the {@link SlimefunItemStack} defines the look and feel of the item.
+ *
+ * Remember to call {@link #register(SlimefunAddon)} on your {@link SlimefunItem} for it
+ * to appear in the {@link SlimefunGuide}.
+ *
+ * @author TheBusyBiscuit
+ * @author Poslovitch
+ *
+ * @see SlimefunItemStack
+ * @see SlimefunAddon
+ *
+ */
public class SlimefunItem implements Placeable {
+ /**
+ * This is our item id.
+ */
+ private final String id;
+
+ /**
+ * This is the original {@link ItemStack} that represents this item.
+ * It is immutable and should always be cloned, never used directly.
+ */
+ private final ItemStack itemStackTemplate;
+
+ /**
+ * This is a reference to the {@link SlimefunAddon} that registered this
+ * {@link SlimefunItem}, if the item has not been registered yet, it will be null.
+ */
+ private SlimefunAddon addon;
+
+ /**
+ * This is the state of this {@link SlimefunItem}.
+ */
private ItemState state = ItemState.UNREGISTERED;
- protected String id;
- protected SlimefunAddon addon;
- protected ItemStack item;
- protected Category category;
- protected ItemStack[] recipe;
- protected RecipeType recipeType;
+ /**
+ * This is the {@link Category} in which this {@link SlimefunItem} can be found.
+ */
+ private Category category;
+
+ /**
+ * This is a reference to the associated {@link Research}, can be null.
+ */
+ private Research research;
+
+ private ItemStack[] recipe;
+ private RecipeType recipeType;
protected ItemStack recipeOutput;
- protected Research research;
protected boolean enchantable = true;
protected boolean disenchantable = true;
protected boolean hidden = false;
protected boolean useableInWorkbench = false;
- private Optional wikiLink = Optional.empty();
+ private Optional wikiURL = Optional.empty();
private final OptionalMap, ItemHandler> itemhandlers = new OptionalMap<>(HashMap::new);
private final Set> itemSettings = new HashSet<>();
@@ -113,7 +154,7 @@ public class SlimefunItem implements Placeable {
Validate.notNull(recipeType, "'recipeType' is not allowed to be null!");
this.category = category;
- this.item = item;
+ this.itemStackTemplate = item;
this.id = item.getItemId();
this.recipeType = recipeType;
this.recipe = recipe;
@@ -128,19 +169,32 @@ public class SlimefunItem implements Placeable {
Validate.notNull(recipeType, "'recipeType' is not allowed to be null!");
this.category = category;
- this.item = item;
+ this.itemStackTemplate = item;
this.id = id;
this.recipeType = recipeType;
this.recipe = recipe;
}
+ /**
+ * Returns the identifier of this {@link SlimefunItem}.
+ *
+ * @deprecated This method has been renamed to {@link #getId()}.
+ *
+ * @return the identifier of this {@link SlimefunItem}
+ */
+ @Nonnull
+ @Deprecated
+ public final String getID() {
+ return getId();
+ }
+
/**
* Returns the identifier of this {@link SlimefunItem}.
*
* @return the identifier of this {@link SlimefunItem}
*/
@Nonnull
- public final String getID() {
+ public final String getId() {
return id;
}
@@ -166,7 +220,7 @@ public class SlimefunItem implements Placeable {
*/
@Nonnull
public ItemStack getItem() {
- return item;
+ return itemStackTemplate;
}
/**
@@ -195,7 +249,7 @@ public class SlimefunItem implements Placeable {
*/
@Nonnull
public ItemStack getRecipeOutput() {
- return recipeOutput != null ? recipeOutput.clone() : item.clone();
+ return recipeOutput != null ? recipeOutput.clone() : itemStackTemplate.clone();
}
/**
@@ -229,11 +283,12 @@ public class SlimefunItem implements Placeable {
* The key of this {@link ItemSetting}
* @param c
* The {@link Class} of the type of value stored by this setting
+ *
* @return An {@link Optional} describing the result
*/
@SuppressWarnings("unchecked")
@Nonnull
- public Optional> getItemSetting(String key, Class c) {
+ public Optional> getItemSetting(@Nonnull String key, @Nonnull Class c) {
for (ItemSetting> setting : itemSettings) {
if (setting.getKey().equals(key) && setting.isType(c)) {
return Optional.of((ItemSetting) setting);
@@ -315,10 +370,10 @@ public class SlimefunItem implements Placeable {
*
* @return The {@link SlimefunAddon} that registered this {@link SlimefunItem}
*/
+ @Nonnull
public SlimefunAddon getAddon() {
if (addon == null) {
- error("getAddon() cannot be called before registering the item", new UnregisteredItemException(this));
- return null;
+ throw new UnregisteredItemException(this);
}
return addon;
@@ -343,17 +398,11 @@ public class SlimefunItem implements Placeable {
this.addon = addon;
try {
- if (!addon.hasDependency("Slimefun")) {
- throw new MissingDependencyException(addon, "Slimefun");
- }
+ checkDependencies(addon);
+ checkForConflicts();
preRegister();
- SlimefunItem conflicting = getByID(id);
- if (conflicting != null) {
- throw new IdConflictException(this, conflicting);
- }
-
if (recipe == null || recipe.length < 9) {
recipe = new ItemStack[] { null, null, null, null, null, null, null, null, null };
}
@@ -402,8 +451,8 @@ public class SlimefunItem implements Placeable {
}
// Lock the SlimefunItemStack from any accidental manipulations
- if (item instanceof SlimefunItemStack && isItemStackImmutable()) {
- ((SlimefunItemStack) item).lock();
+ if (itemStackTemplate instanceof SlimefunItemStack && isItemStackImmutable()) {
+ ((SlimefunItemStack) itemStackTemplate).lock();
}
postRegister();
@@ -430,7 +479,7 @@ public class SlimefunItem implements Placeable {
category.register();
}
- // Send out deprecation warnings for any classes or intefaces
+ // Send out deprecation warnings for any classes or interfaces
checkForDeprecations(getClass());
// Add it to the list of enabled items
@@ -480,6 +529,29 @@ public class SlimefunItem implements Placeable {
return true;
}
+ /**
+ * This method checks if the dependencies have been set up correctly.
+ *
+ * @param addon
+ * The {@link SlimefunAddon} trying to register this {@link SlimefunItem}
+ */
+ private void checkDependencies(@Nonnull SlimefunAddon addon) {
+ if (!addon.hasDependency("Slimefun")) {
+ throw new MissingDependencyException(addon, "Slimefun");
+ }
+ }
+
+ /**
+ * This method checks for id conflicts.
+ */
+ private void checkForConflicts() {
+ SlimefunItem conflictingItem = getByID(id);
+
+ if (conflictingItem != null) {
+ throw new IdConflictException(this, conflictingItem);
+ }
+ }
+
/**
* This method checks recursively for all {@link Class} parents to look for any {@link Deprecated}
* elements.
@@ -623,21 +695,21 @@ public class SlimefunItem implements Placeable {
// If the given item is a SlimefunitemStack, simply compare the id
if (item instanceof SlimefunItemStack) {
- return getID().equals(((SlimefunItemStack) item).getItemId());
+ return getId().equals(((SlimefunItemStack) item).getItemId());
}
if (item.hasItemMeta()) {
Optional itemId = SlimefunPlugin.getItemDataService().getItemData(item);
if (itemId.isPresent()) {
- return getID().equals(itemId.get());
+ return getId().equals(itemId.get());
}
}
// Backwards compatibility
if (SlimefunPlugin.getRegistry().isBackwardsCompatible()) {
boolean loreInsensitive = this instanceof Rechargeable || this instanceof SlimefunBackpack || id.equals("BROKEN_SPAWNER") || id.equals("REINFORCED_SPAWNER");
- return SlimefunUtils.isItemSimilar(item, this.item, !loreInsensitive);
+ return SlimefunUtils.isItemSimilar(item, this.itemStackTemplate, !loreInsensitive);
} else {
return false;
}
@@ -679,7 +751,7 @@ public class SlimefunItem implements Placeable {
// Tickers are a special case (at the moment at least)
if (handler instanceof BlockTicker) {
ticking = true;
- SlimefunPlugin.getRegistry().getTickerBlocks().add(getID());
+ SlimefunPlugin.getRegistry().getTickerBlocks().add(getId());
blockTicker = (BlockTicker) handler;
}
}
@@ -747,7 +819,7 @@ public class SlimefunItem implements Placeable {
*/
public final void addOficialWikipage(@Nonnull String page) {
Validate.notNull(page, "Wiki page cannot be null.");
- wikiLink = Optional.of("https://github.com/Slimefun/Slimefun4/wiki/" + page);
+ wikiURL = Optional.of("https://github.com/Slimefun/Slimefun4/wiki/" + page);
}
/**
@@ -760,7 +832,7 @@ public class SlimefunItem implements Placeable {
*/
@Nonnull
public Optional getWikipage() {
- return wikiLink;
+ return wikiURL;
}
/**
@@ -771,15 +843,15 @@ public class SlimefunItem implements Placeable {
*/
@Nonnull
public final String getItemName() {
- if (item instanceof SlimefunItemStack) {
- Optional name = ((SlimefunItemStack) item).getImmutableMeta().getDisplayName();
+ if (itemStackTemplate instanceof SlimefunItemStack) {
+ Optional name = ((SlimefunItemStack) itemStackTemplate).getImmutableMeta().getDisplayName();
if (name.isPresent()) {
return name.get();
}
}
- return ItemUtils.getItemName(item);
+ return ItemUtils.getItemName(itemStackTemplate);
}
/**
@@ -841,7 +913,7 @@ public class SlimefunItem implements Placeable {
@Override
public Collection getDrops() {
- return Arrays.asList(item.clone());
+ return Arrays.asList(itemStackTemplate.clone());
}
@Override
@@ -937,7 +1009,7 @@ public class SlimefunItem implements Placeable {
if (sfi.isItem(wrapper)) {
// If we have to loop all items for the given item, then at least
// set the id via PersistentDataAPI for future performance boosts
- SlimefunPlugin.getItemDataService().setItemData(item, sfi.getID());
+ SlimefunPlugin.getItemDataService().setItemData(item, sfi.getId());
return sfi;
}
diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AContainer.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AContainer.java
index 0aa832c74..daf180de3 100644
--- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AContainer.java
+++ b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AContainer.java
@@ -5,6 +5,8 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import javax.annotation.ParametersAreNonnullByDefault;
+
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.block.Block;
@@ -45,12 +47,13 @@ public abstract class AContainer extends SlimefunItem implements InventoryBlock,
protected final List recipes = new ArrayList<>();
+ @ParametersAreNonnullByDefault
public AContainer(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, recipeType, recipe);
createPreset(this, getInventoryTitle(), this::constructMenu);
- registerBlockHandler(id, (p, b, tool, reason) -> {
+ registerBlockHandler(item.getItemId(), (p, b, tool, reason) -> {
BlockMenu inv = BlockStorage.getInventory(b);
if (inv != null) {
@@ -66,6 +69,7 @@ public abstract class AContainer extends SlimefunItem implements InventoryBlock,
registerDefaultRecipes();
}
+ @ParametersAreNonnullByDefault
public AContainer(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput) {
this(category, item, recipeType, recipe);
this.recipeOutput = recipeOutput;
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 8ce0163af..43287a3d3 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
@@ -3,6 +3,8 @@ package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems;
import java.util.HashMap;
import java.util.Map;
+import javax.annotation.ParametersAreNonnullByDefault;
+
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
@@ -40,10 +42,11 @@ public abstract class AGenerator extends AbstractEnergyProvider {
private static final int[] border_in = { 9, 10, 11, 12, 18, 21, 27, 28, 29, 30 };
private static final int[] border_out = { 14, 15, 16, 17, 23, 26, 32, 33, 34, 35 };
+ @ParametersAreNonnullByDefault
public AGenerator(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, recipeType, recipe);
- new BlockMenuPreset(id, getInventoryTitle()) {
+ new BlockMenuPreset(item.getItemId(), getInventoryTitle()) {
@Override
public void init() {
@@ -65,7 +68,7 @@ public abstract class AGenerator extends AbstractEnergyProvider {
}
};
- registerBlockHandler(id, (p, b, tool, reason) -> {
+ registerBlockHandler(item.getItemId(), (p, b, tool, reason) -> {
BlockMenu inv = BlockStorage.getInventory(b);
if (inv != null) {
diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/interfaces/InventoryBlock.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/interfaces/InventoryBlock.java
index ba6191644..8de896dc1 100644
--- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/interfaces/InventoryBlock.java
+++ b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/interfaces/InventoryBlock.java
@@ -43,7 +43,7 @@ public interface InventoryBlock {
}
default void createPreset(SlimefunItem item, String title, Consumer setup) {
- new BlockMenuPreset(item.getID(), title) {
+ new BlockMenuPreset(item.getId(), title) {
@Override
public void init() {
diff --git a/src/main/java/me/mrCookieSlime/Slimefun/api/BlockStorage.java b/src/main/java/me/mrCookieSlime/Slimefun/api/BlockStorage.java
index f94f9bf64..94b7a2297 100644
--- a/src/main/java/me/mrCookieSlime/Slimefun/api/BlockStorage.java
+++ b/src/main/java/me/mrCookieSlime/Slimefun/api/BlockStorage.java
@@ -356,7 +356,7 @@ public class BlockStorage {
SlimefunItem sfitem = SlimefunItem.getByItem(item);
if (sfitem != null) {
- addBlockInfo(block, "id", sfitem.getID(), true);
+ addBlockInfo(block, "id", sfitem.getId(), true);
}
}
diff --git a/src/main/resources/languages/messages_en.yml b/src/main/resources/languages/messages_en.yml
index ba59a468f..c2097f97b 100644
--- a/src/main/resources/languages/messages_en.yml
+++ b/src/main/resources/languages/messages_en.yml
@@ -261,6 +261,7 @@ machines:
anvil:
not-working: '&4You cannot use Slimefun items in an anvil!'
+ mcmmo-salvaging: '&4You cannot salvage Slimefun items!'
brewing_stand:
not-working: '&4You cannot use Slimefun items in a brewing stand!'
@@ -278,6 +279,9 @@ backpack:
workbench:
not-enhanced: '&4You cannot use Slimefun items in a normal workbench'
+cauldron:
+ no-discoloring: '&4You cannot discolor Slimefun Armor'
+
gps:
deathpoint: '&4Deathpoint &7%date%'
waypoint:
diff --git a/src/main/resources/languages/messages_fr.yml b/src/main/resources/languages/messages_fr.yml
index 80d93db36..797238f77 100644
--- a/src/main/resources/languages/messages_fr.yml
+++ b/src/main/resources/languages/messages_fr.yml
@@ -255,6 +255,7 @@ machines:
anvil:
not-working: "&4Vous ne pouvez pas utiliser des objets Slimefun dans une enclume
!"
+ mcmmo-salvaging: "&4Vous ne pouvez pas recycler des objets Slimefun !"
backpack:
already-open: "&cDésolé, ce Backpack est ouvert quelque part ailleurs !"
no-stack: "&cVous ne pouvez pas stack les Backpacks"
@@ -340,6 +341,7 @@ languages:
zh-CN: Chinois (Chine)
el: Grec
he: Hébreu
+ pt: Portugais (Portugal)
ar: Arabe
af: Afrikaans
da: Danois
@@ -351,7 +353,6 @@ languages:
fa: Persan
th: Thaï
ro: Roumain
- pt: Portugais (Portugal)
pt-BR: Portugais (Brésil)
bg: Bulgare
ko: Coréen
@@ -369,5 +370,7 @@ villagers:
cartography_table:
not-working: "&4Vous ne pouvez pas utiliser d'objets Slimefun dans une table de
cartographie !"
+cauldron:
+ no-discoloring: "&4Vous ne pouvez pas décolorer une armure Slimefun"
miner:
no-ores: "&eDésolé, je n'ai pas pu trouver de minerai à proximité !"
diff --git a/src/main/resources/languages/messages_ja.yml b/src/main/resources/languages/messages_ja.yml
index ec99efcc2..c34c65548 100644
--- a/src/main/resources/languages/messages_ja.yml
+++ b/src/main/resources/languages/messages_ja.yml
@@ -228,6 +228,7 @@ machines:
finished: "&eIndustrial Minerの稼働完了!合計で%ores%個の鉱石を入手しました!"
anvil:
not-working: "&4Slimefunアイテムは金床を利用できません!"
+ mcmmo-salvaging: "&4Slimefunアイテムはサルベージできません!"
backpack:
already-open: "&cこのバックパックはどこかで使用中です!"
no-stack: "&cバックパックはスタックされていると使用できません!"
@@ -312,7 +313,6 @@ languages:
el: ギリシャ語
he: ヘブライ語
pt: ポルトガル語(ポルトガル)
- pt-BR: ポルトガル語(ブラジル)
ar: アラビア語
af: アフリカーンス語
da: デンマーク語
@@ -324,6 +324,7 @@ languages:
fa: ペルシア語
th: タイ語
ro: ルーマニア語
+ pt-BR: ポルトガル語(ブラジル)
bg: ブルガリア語
ko: 韓国語
tr: トルコ語
@@ -338,5 +339,7 @@ villagers:
no-trading: "&4Slimefunアイテムは村人との取引に使用できません!"
cartography_table:
not-working: "&4Slimefunアイテムは製図台を使用できません!"
+cauldron:
+ no-discoloring: "&4Slimefunアイテムの脱色はできません"
miner:
no-ores: "&e周辺には鉱石が見つかりませんでした!"
diff --git a/src/main/resources/languages/messages_ru.yml b/src/main/resources/languages/messages_ru.yml
index f1989d92a..addbf80bb 100644
--- a/src/main/resources/languages/messages_ru.yml
+++ b/src/main/resources/languages/messages_ru.yml
@@ -20,6 +20,10 @@ commands:
player-never-joined: "&4Игрок с таким ником не найден!"
backpack-does-not-exist: "&4Указанный рюкзак не существует!"
restored-backpack-given: "&aРюкзак был восстановлен и добавлен в Ваш инвентарь!"
+ charge:
+ description: Заряжает предмет, который Вы держите
+ charge-success: Предмет заряжен!
+ not-rechargeable: Этот предмет не может быть заряжен!
guide:
search:
message: "&bЧто бы Вы хотели найти?"
@@ -83,6 +87,7 @@ guide:
miner: Ресурсы, добываемые этим шахтёром
generator: Доступные виды топлива
gold-pan: Ресурсы, которые Вы можете получить
+ climbing-pick: Поверхности для карабканья
back:
title: Назад
guide: Вернуться к руководству Slimefun
@@ -129,6 +134,7 @@ messages:
whirlwind: "&a&oВаш талисман отразил снаряд"
wizard: "&a&oТалисман повысил уровень зачарования «Удача», но мог также ухудшить
другие зачарования"
+ caveman: "&a&oВаш талисман выдал Вам «Спешку»"
soulbound-rune:
fail: "&cВы можете привязать к себе только один предмет за раз."
success: "&aВы успешно привязали этот предмет к себе! Он останется при Вас после
@@ -177,6 +183,10 @@ messages:
multi-tool:
mode-change: "&bРежим «%device%» изменён на: &9%mode%"
not-shears: "&cМультиинструмент не может быть использован в качестве ножниц!"
+ climbing-pick:
+ dual-wielding: "&4Вы должны держать кирку для скалолазания в обеих руках!"
+ wrong-material: "&cВы не можете карабкаться по этой поверхности. Проверьте руководство
+ Slimefun для большей информации!"
mode-change: "&b%device% | Режим изменён на: &9%mode%"
machines:
pattern-not-found: "&eК сожалению, не удалось распознать этот рецепт. Пожалуйста,
@@ -320,6 +330,7 @@ languages:
zh-CN: Китайский (Китай)
el: Греческий
he: Иврит
+ pt: Португальский (Португалия)
pt-BR: Португальский (Бразилия)
ar: Арабский
af: Бурский
@@ -332,7 +343,6 @@ languages:
fa: Персидский
th: Тайский
ro: Румынский
- pt: Португальский (Португалия)
bg: Болгарский
ko: Корейский
tr: Турецкий
@@ -345,5 +355,7 @@ brewing_stand:
not-working: "&4Вы не можете использовать Slimefun предметы в варочной стойке!"
villagers:
no-trading: "&4Вы не можете торговаться с крестьянами Slimefun предметами!"
+cartography_table:
+ not-working: "&4Вы не можете использовать Slimefun предметы в столе картографа!"
miner:
no-ores: "&eК сожалению, не удалось найти какую-либо руду поблизости!"
diff --git a/src/main/resources/languages/messages_tl.yml b/src/main/resources/languages/messages_tl.yml
index fa284c8f7..cb9531d74 100644
--- a/src/main/resources/languages/messages_tl.yml
+++ b/src/main/resources/languages/messages_tl.yml
@@ -21,6 +21,10 @@ commands:
backpack-does-not-exist: "&4Ang tinukoy na backpack ay hindi umiiral!"
restored-backpack-given: "&aAng iyong backpack ay naibalik at naidagdag sa iyong
imbentaryo!"
+ charge:
+ description: I-chacharge ang item ng iyong hinahawakan.
+ charge-success: Na-charge na ang item!
+ not-rechargeable: Hindi puedeng i-charge ang item na ito.
guide:
search:
message: "&bAno ang hinahanap mo?"
@@ -53,6 +57,7 @@ guide:
addons: Ang mga Addons para sa Slimefun4
bugs: Mga Bug Reports
source: Ang Source Code
+ versions: Mga na-install na versions
credits:
commit: Commit
commits: Mga Commits
@@ -62,6 +67,12 @@ guide:
resourcepack: "&cResourcepack Artist"
translator: "&9Translator"
profile-link: I-click ito upang bisitahin ang kanilang profile sa GitHub.
+ open: Pindutin ito upang makita ang aming mga nag-ambag
+ description:
+ - "&7Ang Slimefun ay isang proyekto na bukas na mapagkukunan"
+ - "&7at pinapanatili ng isang malaking pamayanan ng mga tao."
+ - "&7Mga hanggang &e%contributors% &7na mga tao ang tumutulong sa"
+ - "&7Slimefun sa buong lahat ng mga taong ito."
pages:
previous: Nakaraang pahina.
next: Susunod na pahina.
@@ -74,6 +85,7 @@ guide:
miner: Mga mapagkukunan na maaari mong makuha sa Miner na ito.
generator: Magagamit na mga uri ng gasolina.
gold-pan: Mga mapagkukunan na maaari mong makuha.
+ climbing-pick: Mga ibabaw na maaari mong akyatin
back:
title: Balik
guide: Bumalik sa Slimefun Guide
@@ -175,6 +187,11 @@ messages:
multi-tool:
mode-change: "&b%device% napalitan ang mode sa: &9%mode%"
not-shears: "&cBawal gamitin ang Multi-Tool bilang shears!"
+ climbing-pick:
+ dual-wielding: "&4Kailangan mong hawakan ang Climbing Picks ng dalawang kamay
+ upang magamit ito!"
+ wrong-material: "&cHindi ka maaaring umakyat sa ibabaw na ito. Suriin ang iyong
+ Slimefun Guide para sa karagdagang impormasyon!"
mode-change: "&b%device% mode ay pinalitan ng: &9%mode%"
machines:
pattern-not-found: "&ePasensiya na, hindi ko maintindihan ang Recipe na ito. Pakilagay
@@ -239,6 +256,7 @@ machines:
%ores% ore(s)!"
anvil:
not-working: "&4Hindi puwedeng gamitin ang mga Slimefun Aytem sa isang Anvil!"
+ mcmmo-salvaging: "&4Bawal i-salvage ang mga Slimefun items!"
backpack:
already-open: "&cSorry, ang backpack na ito ay nakabukas na sa ibang lugar!"
no-stack: "&cHindi puwedeng i-stack ang mga Backpack."
@@ -349,3 +367,7 @@ brewing_stand:
not-working: "&4Hindi ka maaaring gumamit ng mga Item ng Slimefun sa Brewing Stand!"
villagers:
no-trading: "&4Hindi ka maaaring mag-trade ng mga Slimefun Items sa mga villagers!"
+cartography_table:
+ not-working: "&4Hindi mo puedeng gamitin ang mga Slimefun items sa cartography table!"
+cauldron:
+ no-discoloring: "&4Hindi mo puedeng i-discolor ang Slimefun Armor."
diff --git a/src/main/resources/languages/researches_en.yml b/src/main/resources/languages/researches_en.yml
index b197c8cd8..4afff5344 100644
--- a/src/main/resources/languages/researches_en.yml
+++ b/src/main/resources/languages/researches_en.yml
@@ -169,6 +169,7 @@ slimefun:
energized_solar_generator: Full-Time Solar Power
energized_gps_transmitter: Top Tier Transmitter
energy_regulator: Energy Networks 101
+ energy_connectors: Wired Connections
butcher_androids: Butcher Androids
organic_food: Organic Food
auto_breeder: Automated Feeding
diff --git a/src/main/resources/languages/researches_ja.yml b/src/main/resources/languages/researches_ja.yml
index 7b2c59fda..27fccbf1a 100644
--- a/src/main/resources/languages/researches_ja.yml
+++ b/src/main/resources/languages/researches_ja.yml
@@ -246,3 +246,4 @@ slimefun:
caveman_talisman: 洞窟暮らしのタリスマン
even_higher_tier_capacitors: キャパシタⅢ
elytra_cap: 衝撃緩和装備
+ energy_connectors: 有線接続
diff --git a/src/main/resources/languages/researches_ru.yml b/src/main/resources/languages/researches_ru.yml
index ee494c173..991111a09 100644
--- a/src/main/resources/languages/researches_ru.yml
+++ b/src/main/resources/languages/researches_ru.yml
@@ -240,3 +240,10 @@ slimefun:
lead_clothing: Свинцовое обмундирование
tape_measure: Рулетка
iron_golem_assembler: Образователь железных големов
+ climbing_pick: Покоритель поверхностей
+ shulker_shell: Синтетические шалкеры
+ villager_rune: Сбрасывание торговли
+ caveman_talisman: Талисман шахтёра
+ even_higher_tier_capacitors: Большой накопитель энергии
+ elytra_cap: Противоударная экипировка
+ energy_connectors: Проводные соединения
diff --git a/src/main/resources/languages/researches_tl.yml b/src/main/resources/languages/researches_tl.yml
index a3d68ee89..de6c28d36 100644
--- a/src/main/resources/languages/researches_tl.yml
+++ b/src/main/resources/languages/researches_tl.yml
@@ -240,3 +240,10 @@ slimefun:
lead_clothing: Lead Clothing
tape_measure: Tape Measure
iron_golem_assembler: Automated Iron Golems
+ climbing_pick: Block Raider
+ shulker_shell: Synthetic Shulkers
+ villager_rune: Reset Villager Trades
+ caveman_talisman: Talisman of the Caveman
+ even_higher_tier_capacitors: Tier 3 Capacitors
+ elytra_cap: Crash Gear
+ energy_connectors: Wired Connections
diff --git a/src/main/resources/languages/researches_tr.yml b/src/main/resources/languages/researches_tr.yml
index cb141f0e2..3c68ccd73 100644
--- a/src/main/resources/languages/researches_tr.yml
+++ b/src/main/resources/languages/researches_tr.yml
@@ -246,3 +246,4 @@ slimefun:
caveman_talisman: Mağara Adamı Tılsımı
even_higher_tier_capacitors: Seviye 3 Kapasitörler
elytra_cap: İniş Takımı
+ energy_connectors: Kablolu Bağlantı
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index f0aaf77fd..ab969be2b 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -5,7 +5,7 @@ description: Slimefun basically turns your entire Server into a FTB modpack with
website: https://github.com/Slimefun
main: io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin
-softdepend: [CS-CoreLib, PlaceholderAPI, WorldEdit, EmeraldEnchants]
+softdepend: [CS-CoreLib, PlaceholderAPI, WorldEdit, EmeraldEnchants, mcMMO]
api-version: '1.13'
diff --git a/src/main/resources/tags/explosive_shovel_blocks.json b/src/main/resources/tags/explosive_shovel_blocks.json
index da0f980ff..41b4d4d29 100644
--- a/src/main/resources/tags/explosive_shovel_blocks.json
+++ b/src/main/resources/tags/explosive_shovel_blocks.json
@@ -1,10 +1,14 @@
{
"values" : [
"#minecraft:sand",
- "#minecraft:dirt_like",
"#slimefun:concrete_powders",
- "minecraft:farmland",
+ "minecraft:dirt",
+ "minecraft:coarse_dirt",
+ "minecraft:grass_block",
"minecraft:grass_path",
+ "minecraft:farmland",
+ "minecraft:podzol",
+ "minecraft:mycelium",
"minecraft:snow",
"minecraft:snow_block",
"minecraft:gravel",
diff --git a/src/main/resources/tags/leather_armor.json b/src/main/resources/tags/leather_armor.json
new file mode 100644
index 000000000..9001f3385
--- /dev/null
+++ b/src/main/resources/tags/leather_armor.json
@@ -0,0 +1,8 @@
+{
+ "values" : [
+ "minecraft:leather_helmet",
+ "minecraft:leather_chestplate",
+ "minecraft:leather_leggings",
+ "minecraft:leather_boots"
+ ]
+}
diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestAnvilListener.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestAnvilListener.java
new file mode 100644
index 000000000..ba3784350
--- /dev/null
+++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestAnvilListener.java
@@ -0,0 +1,80 @@
+package io.github.thebusybiscuit.slimefun4.testing.tests.listeners;
+
+import org.bukkit.Material;
+import org.bukkit.entity.Player;
+import org.bukkit.event.Event.Result;
+import org.bukkit.event.inventory.ClickType;
+import org.bukkit.event.inventory.InventoryAction;
+import org.bukkit.event.inventory.InventoryClickEvent;
+import org.bukkit.event.inventory.InventoryType;
+import org.bukkit.event.inventory.InventoryType.SlotType;
+import org.bukkit.inventory.Inventory;
+import org.bukkit.inventory.InventoryView;
+import org.bukkit.inventory.ItemStack;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+import be.seeseemelk.mockbukkit.MockBukkit;
+import be.seeseemelk.mockbukkit.ServerMock;
+import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
+import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
+import io.github.thebusybiscuit.slimefun4.implementation.items.VanillaItem;
+import io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting.AnvilListener;
+import io.github.thebusybiscuit.slimefun4.testing.TestUtilities;
+import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
+
+public class TestAnvilListener {
+
+ private static SlimefunPlugin plugin;
+ private static AnvilListener listener;
+ private static ServerMock server;
+
+ @BeforeAll
+ public static void load() {
+ server = MockBukkit.mock();
+ plugin = MockBukkit.load(SlimefunPlugin.class);
+ listener = new AnvilListener(plugin);
+ }
+
+ @AfterAll
+ public static void unload() {
+ MockBukkit.unmock();
+ }
+
+ private InventoryClickEvent mockAnvilEvent(ItemStack item) {
+ Player player = server.addPlayer();
+ Inventory inv = TestUtilities.mockInventory(InventoryType.ANVIL, item, null, new ItemStack(Material.IRON_CHESTPLATE));
+ InventoryView view = player.openInventory(inv);
+ InventoryClickEvent event = new InventoryClickEvent(view, SlotType.CONTAINER, 2, ClickType.LEFT, InventoryAction.PICKUP_ONE);
+
+ listener.onAnvil(event);
+ return event;
+ }
+
+ @Test
+ public void testAnvilWithoutSlimefunItems() {
+ InventoryClickEvent event = mockAnvilEvent(new ItemStack(Material.IRON_SWORD));
+ Assertions.assertEquals(Result.DEFAULT, event.getResult());
+ }
+
+ @Test
+ public void testAnvilWithSlimefunItem() {
+ SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MOCKED_IRON_SWORD", new CustomItem(Material.IRON_SWORD, "&6Mock"));
+ item.register(plugin);
+
+ InventoryClickEvent event = mockAnvilEvent(item.getItem());
+ Assertions.assertEquals(Result.DENY, event.getResult());
+ }
+
+ @Test
+ public void testAnvilWithVanillaItem() {
+ VanillaItem item = TestUtilities.mockVanillaItem(plugin, Material.IRON_SWORD, true);
+ item.register(plugin);
+
+ InventoryClickEvent event = mockAnvilEvent(item.getItem());
+ Assertions.assertEquals(Result.DEFAULT, event.getResult());
+ }
+
+}
diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestBrewingStandListener.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestBrewingStandListener.java
new file mode 100644
index 000000000..708261165
--- /dev/null
+++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestBrewingStandListener.java
@@ -0,0 +1,84 @@
+package io.github.thebusybiscuit.slimefun4.testing.tests.listeners;
+
+import org.bukkit.Material;
+import org.bukkit.block.BrewingStand;
+import org.bukkit.entity.Player;
+import org.bukkit.event.Event.Result;
+import org.bukkit.event.inventory.ClickType;
+import org.bukkit.event.inventory.InventoryAction;
+import org.bukkit.event.inventory.InventoryClickEvent;
+import org.bukkit.event.inventory.InventoryType;
+import org.bukkit.event.inventory.InventoryType.SlotType;
+import org.bukkit.inventory.Inventory;
+import org.bukkit.inventory.InventoryView;
+import org.bukkit.inventory.ItemStack;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.mockito.Mockito;
+
+import be.seeseemelk.mockbukkit.MockBukkit;
+import be.seeseemelk.mockbukkit.ServerMock;
+import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
+import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
+import io.github.thebusybiscuit.slimefun4.implementation.items.VanillaItem;
+import io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting.BrewingStandListener;
+import io.github.thebusybiscuit.slimefun4.testing.TestUtilities;
+import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
+
+public class TestBrewingStandListener {
+
+ private static SlimefunPlugin plugin;
+ private static BrewingStandListener listener;
+ private static ServerMock server;
+
+ @BeforeAll
+ public static void load() {
+ server = MockBukkit.mock();
+ plugin = MockBukkit.load(SlimefunPlugin.class);
+ listener = new BrewingStandListener(plugin);
+ }
+
+ @AfterAll
+ public static void unload() {
+ MockBukkit.unmock();
+ }
+
+ private InventoryClickEvent mockBrewingEvent(ItemStack item) {
+ Player player = server.addPlayer();
+ Inventory inv = TestUtilities.mockInventory(InventoryType.BREWING);
+ Mockito.when(inv.getHolder()).thenReturn(Mockito.mock(BrewingStand.class));
+ Mockito.when(inv.getSize()).thenReturn(5);
+
+ InventoryView view = player.openInventory(inv);
+ view.setCursor(item);
+ InventoryClickEvent event = new InventoryClickEvent(view, SlotType.CONTAINER, 1, ClickType.LEFT, InventoryAction.PICKUP_ONE);
+ listener.onPreBrew(event);
+ return event;
+ }
+
+ @Test
+ public void testBrewingWithoutSlimefunItems() {
+ InventoryClickEvent event = mockBrewingEvent(new ItemStack(Material.BLAZE_POWDER));
+ Assertions.assertEquals(Result.ALLOW, event.getResult());
+ }
+
+ @Test
+ public void testBrewingWithSlimefunItem() {
+ SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MOCK_POWDER", new CustomItem(Material.BLAZE_POWDER, "&6Magic Mock Powder"));
+ item.register(plugin);
+
+ InventoryClickEvent event = mockBrewingEvent(item.getItem());
+ Assertions.assertEquals(Result.DENY, event.getResult());
+ }
+
+ @Test
+ public void testBrewingWithVanillaItem() {
+ VanillaItem item = TestUtilities.mockVanillaItem(plugin, Material.BLAZE_POWDER, true);
+ item.register(plugin);
+
+ InventoryClickEvent event = mockBrewingEvent(item.getItem());
+ Assertions.assertEquals(Result.ALLOW, event.getResult());
+ }
+}
diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestCartographyTableListener.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestCartographyTableListener.java
new file mode 100644
index 000000000..d32e217b7
--- /dev/null
+++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestCartographyTableListener.java
@@ -0,0 +1,74 @@
+package io.github.thebusybiscuit.slimefun4.testing.tests.listeners;
+
+import org.bukkit.Material;
+import org.bukkit.entity.Player;
+import org.bukkit.event.Event.Result;
+import org.bukkit.event.inventory.ClickType;
+import org.bukkit.event.inventory.InventoryAction;
+import org.bukkit.event.inventory.InventoryClickEvent;
+import org.bukkit.event.inventory.InventoryType;
+import org.bukkit.event.inventory.InventoryType.SlotType;
+import org.bukkit.inventory.Inventory;
+import org.bukkit.inventory.InventoryView;
+import org.bukkit.inventory.ItemStack;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+import be.seeseemelk.mockbukkit.MockBukkit;
+import be.seeseemelk.mockbukkit.ServerMock;
+import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
+import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
+import io.github.thebusybiscuit.slimefun4.implementation.items.VanillaItem;
+import io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting.CartographyTableListener;
+import io.github.thebusybiscuit.slimefun4.testing.TestUtilities;
+import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
+
+public class TestCartographyTableListener {
+
+ private static SlimefunPlugin plugin;
+ private static CartographyTableListener listener;
+ private static ServerMock server;
+
+ @BeforeAll
+ public static void load() {
+ server = MockBukkit.mock();
+ plugin = MockBukkit.load(SlimefunPlugin.class);
+ listener = new CartographyTableListener(plugin);
+ }
+
+ @AfterAll
+ public static void unload() {
+ MockBukkit.unmock();
+ }
+
+ private InventoryClickEvent mockCartographyTableEvent(ItemStack item) {
+ Player player = server.addPlayer();
+ Inventory inv = TestUtilities.mockInventory(InventoryType.CARTOGRAPHY, new ItemStack(Material.FILLED_MAP), item, new ItemStack(Material.FILLED_MAP));
+ InventoryView view = player.openInventory(inv);
+ InventoryClickEvent event = new InventoryClickEvent(view, SlotType.CONTAINER, 2, ClickType.LEFT, InventoryAction.PICKUP_ONE);
+
+ listener.onCartographyTable(event);
+ return event;
+ }
+
+ @Test
+ public void testCartographyTableWithSlimefunItem() {
+ SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MOCKED_PAPER", new CustomItem(Material.PAPER, "&6Mock"));
+ item.register(plugin);
+
+ InventoryClickEvent event = mockCartographyTableEvent(item.getItem());
+ Assertions.assertEquals(Result.DENY, event.getResult());
+ }
+
+ @Test
+ public void testCartographyTableWithVanillaItem() {
+ VanillaItem item = TestUtilities.mockVanillaItem(plugin, Material.PAPER, true);
+ item.register(plugin);
+
+ InventoryClickEvent event = mockCartographyTableEvent(item.getItem());
+ Assertions.assertEquals(Result.DEFAULT, event.getResult());
+ }
+
+}
diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestCauldronListener.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestCauldronListener.java
new file mode 100644
index 000000000..dbe1ad358
--- /dev/null
+++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestCauldronListener.java
@@ -0,0 +1,106 @@
+package io.github.thebusybiscuit.slimefun4.testing.tests.listeners;
+
+import org.bukkit.Material;
+import org.bukkit.block.Block;
+import org.bukkit.block.BlockFace;
+import org.bukkit.entity.Player;
+import org.bukkit.event.Event.Result;
+import org.bukkit.event.block.Action;
+import org.bukkit.event.player.PlayerInteractEvent;
+import org.bukkit.inventory.EquipmentSlot;
+import org.bukkit.inventory.ItemStack;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+import be.seeseemelk.mockbukkit.MockBukkit;
+import be.seeseemelk.mockbukkit.ServerMock;
+import be.seeseemelk.mockbukkit.block.BlockMock;
+import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
+import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
+import io.github.thebusybiscuit.slimefun4.implementation.items.VanillaItem;
+import io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting.CauldronListener;
+import io.github.thebusybiscuit.slimefun4.testing.TestUtilities;
+import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
+
+class TestCauldronListener {
+
+ private static SlimefunPlugin plugin;
+ private static CauldronListener listener;
+ private static ServerMock server;
+
+ @BeforeAll
+ public static void load() {
+ server = MockBukkit.mock();
+ plugin = MockBukkit.load(SlimefunPlugin.class);
+ listener = new CauldronListener(plugin);
+ }
+
+ @AfterAll
+ public static void unload() {
+ MockBukkit.unmock();
+ }
+
+ private PlayerInteractEvent mockCauldronEvent(ItemStack item) {
+ Player player = server.addPlayer();
+ Block block = new BlockMock(Material.CAULDRON);
+ PlayerInteractEvent event = new PlayerInteractEvent(player, Action.RIGHT_CLICK_BLOCK, item, block, BlockFace.UP, EquipmentSlot.HAND);
+
+ listener.onCauldronUse(event);
+ return event;
+ }
+
+ @Test
+ @DisplayName("Test Cauldron handling null")
+ void testCauldronWithNull() {
+ PlayerInteractEvent event = mockCauldronEvent(null);
+ Assertions.assertEquals(Result.DEFAULT, event.useItemInHand());
+ }
+
+ @Test
+ @DisplayName("Test Cauldron working as normal with unrelated items")
+ void testCauldronWithNormalItem() {
+ PlayerInteractEvent event = mockCauldronEvent(new ItemStack(Material.GOLD_BLOCK));
+ Assertions.assertEquals(Result.DEFAULT, event.useItemInHand());
+ }
+
+ @Test
+ @DisplayName("Test Cauldron working as normal with normal leather armor")
+ void testCauldronWithNormalLeatherArmor() {
+ PlayerInteractEvent event = mockCauldronEvent(new ItemStack(Material.LEATHER_BOOTS));
+ Assertions.assertEquals(Result.DEFAULT, event.useItemInHand());
+ }
+
+ @Test
+ @DisplayName("Test Cauldron working as normal with non-leather slimefun items")
+ void testCauldronWithSlimefunItem() {
+ SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "CAULDRON_TEST_MOCK", new CustomItem(Material.GOLDEN_APPLE, "&6Mock"));
+ item.register(plugin);
+
+ PlayerInteractEvent event = mockCauldronEvent(item.getItem());
+ Assertions.assertEquals(Result.DEFAULT, event.useItemInHand());
+ }
+
+ @Test
+ @DisplayName("Test Cauldron being cancelled with slimefun leather armor")
+ void testCauldronWithSlimefunLeatherArmor() {
+ SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "CAULDRON_TEST_MOCK_LEATHER", new CustomItem(Material.LEATHER_BOOTS, "&6Mock"));
+ item.register(plugin);
+
+ PlayerInteractEvent event = mockCauldronEvent(item.getItem());
+ Assertions.assertEquals(Result.DENY, event.useItemInHand());
+ }
+
+ @Test
+ @DisplayName("Test Cauldron working as normal with vanilla slimefun leather armor")
+ void testCauldronWithVanillaLeatherArmor() {
+ VanillaItem item = TestUtilities.mockVanillaItem(plugin, Material.LEATHER_CHESTPLATE, true);
+ item.register(plugin);
+
+ PlayerInteractEvent event = mockCauldronEvent(item.getItem());
+ Assertions.assertEquals(Result.DEFAULT, event.useItemInHand());
+ }
+
+}
diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestCraftingTableListener.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestCraftingTableListener.java
new file mode 100644
index 000000000..03f543411
--- /dev/null
+++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestCraftingTableListener.java
@@ -0,0 +1,149 @@
+package io.github.thebusybiscuit.slimefun4.testing.tests.listeners;
+
+import org.apache.commons.lang.mutable.MutableObject;
+import org.bukkit.Material;
+import org.bukkit.NamespacedKey;
+import org.bukkit.entity.Player;
+import org.bukkit.event.Event.Result;
+import org.bukkit.event.inventory.ClickType;
+import org.bukkit.event.inventory.CraftItemEvent;
+import org.bukkit.event.inventory.InventoryAction;
+import org.bukkit.event.inventory.InventoryType.SlotType;
+import org.bukkit.event.inventory.PrepareItemCraftEvent;
+import org.bukkit.inventory.CraftingInventory;
+import org.bukkit.inventory.InventoryView;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.inventory.Recipe;
+import org.bukkit.inventory.ShapedRecipe;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.mockito.Mockito;
+
+import be.seeseemelk.mockbukkit.MockBukkit;
+import be.seeseemelk.mockbukkit.ServerMock;
+import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
+import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
+import io.github.thebusybiscuit.slimefun4.implementation.items.VanillaItem;
+import io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting.CraftingTableListener;
+import io.github.thebusybiscuit.slimefun4.testing.TestUtilities;
+import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
+
+public class TestCraftingTableListener {
+
+ private static SlimefunPlugin plugin;
+ private static CraftingTableListener listener;
+ private static ServerMock server;
+
+ @BeforeAll
+ public static void load() {
+ server = MockBukkit.mock();
+ plugin = MockBukkit.load(SlimefunPlugin.class);
+ listener = new CraftingTableListener(plugin);
+ }
+
+ @AfterAll
+ public static void unload() {
+ MockBukkit.unmock();
+ }
+
+ private CraftItemEvent mockCraftingEvent(ItemStack item) {
+ Recipe recipe = new ShapedRecipe(new NamespacedKey(plugin, "test_recipe"), new ItemStack(Material.EMERALD));
+ Player player = server.addPlayer();
+
+ CraftingInventory inv = Mockito.mock(CraftingInventory.class);
+ Mockito.when(inv.getContents()).thenReturn(new ItemStack[] { item, null, null, null, null, null, null, null, null });
+
+ InventoryView view = player.openInventory(inv);
+ CraftItemEvent event = new CraftItemEvent(recipe, view, SlotType.RESULT, 9, ClickType.LEFT, InventoryAction.PICKUP_ALL);
+
+ listener.onCraft(event);
+ return event;
+ }
+
+ private PrepareItemCraftEvent mockPreCraftingEvent(ItemStack item) {
+ Player player = server.addPlayer();
+
+ CraftingInventory inv = Mockito.mock(CraftingInventory.class);
+ MutableObject result = new MutableObject(new ItemStack(Material.EMERALD));
+
+ Mockito.doAnswer(invocation -> {
+ ItemStack argument = invocation.getArgument(0);
+ result.setValue(argument);
+ return null;
+ }).when(inv).setResult(Mockito.any());
+
+ Mockito.when(inv.getResult()).thenAnswer(invocation -> result.getValue());
+ Mockito.when(inv.getContents()).thenReturn(new ItemStack[] { null, null, item, null, null, null, null, null, null });
+
+ InventoryView view = player.openInventory(inv);
+ PrepareItemCraftEvent event = new PrepareItemCraftEvent(inv, view, false);
+
+ listener.onPrepareCraft(event);
+ return event;
+ }
+
+ @Test
+ public void testCraftEventWithoutSlimefunItems() {
+ CraftItemEvent event = mockCraftingEvent(new ItemStack(Material.DIAMOND));
+ Assertions.assertEquals(Result.DEFAULT, event.getResult());
+ }
+
+ @Test
+ public void testCraftEventWithSlimefunItem() {
+ SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MOCK_DIAMOND", new CustomItem(Material.DIAMOND, "&cMock Diamond"));
+ item.register(plugin);
+
+ CraftItemEvent event = mockCraftingEvent(item.getItem());
+ Assertions.assertEquals(Result.DENY, event.getResult());
+ }
+
+ @Test
+ public void testCraftEventWithChangingSlimefunItem() {
+ SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "CHANGING_ITEM", new CustomItem(Material.DIAMOND, "&dChanging Diamond"));
+ item.register(plugin);
+
+ item.setUseableInWorkbench(true);
+ CraftItemEvent event = mockCraftingEvent(item.getItem());
+ Assertions.assertEquals(Result.DEFAULT, event.getResult());
+
+ item.setUseableInWorkbench(false);
+ CraftItemEvent event2 = mockCraftingEvent(item.getItem());
+ Assertions.assertEquals(Result.DENY, event2.getResult());
+ }
+
+ @Test
+ public void testCraftEventWithVanillaItem() {
+ VanillaItem item = TestUtilities.mockVanillaItem(plugin, Material.DIAMOND, true);
+ item.register(plugin);
+
+ CraftItemEvent event = mockCraftingEvent(item.getItem());
+ Assertions.assertEquals(Result.DEFAULT, event.getResult());
+ }
+
+ @Test
+ public void testPreCraftEventWithoutSlimefunItems() {
+ PrepareItemCraftEvent event = mockPreCraftingEvent(new ItemStack(Material.DIAMOND));
+ Assertions.assertNotNull(event.getInventory().getResult());
+ }
+
+ @Test
+ public void testPreCraftEventWithSlimefunItem() {
+ SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MOCK_DIAMOND2", new CustomItem(Material.DIAMOND, "&cMock Diamond"));
+ item.register(plugin);
+
+ PrepareItemCraftEvent event = mockPreCraftingEvent(item.getItem());
+ Assertions.assertNull(event.getInventory().getResult());
+ }
+
+ @Test
+ public void testPreCraftEventWithVanillaItem() {
+ VanillaItem item = TestUtilities.mockVanillaItem(plugin, Material.GOLD_INGOT, true);
+ item.register(plugin);
+
+ PrepareItemCraftEvent event = mockPreCraftingEvent(item.getItem());
+ Assertions.assertNotNull(event.getInventory().getResult());
+ }
+
+}
diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestGrindstoneListener.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestGrindstoneListener.java
new file mode 100644
index 000000000..19a74a5dc
--- /dev/null
+++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestGrindstoneListener.java
@@ -0,0 +1,91 @@
+package io.github.thebusybiscuit.slimefun4.testing.tests.listeners;
+
+import org.bukkit.Material;
+import org.bukkit.entity.Player;
+import org.bukkit.event.Event.Result;
+import org.bukkit.event.inventory.ClickType;
+import org.bukkit.event.inventory.InventoryAction;
+import org.bukkit.event.inventory.InventoryClickEvent;
+import org.bukkit.event.inventory.InventoryType;
+import org.bukkit.event.inventory.InventoryType.SlotType;
+import org.bukkit.inventory.Inventory;
+import org.bukkit.inventory.InventoryView;
+import org.bukkit.inventory.ItemStack;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.EnumSource;
+
+import be.seeseemelk.mockbukkit.MockBukkit;
+import be.seeseemelk.mockbukkit.ServerMock;
+import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
+import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
+import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout;
+import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
+import io.github.thebusybiscuit.slimefun4.implementation.items.VanillaItem;
+import io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting.GrindstoneListener;
+import io.github.thebusybiscuit.slimefun4.testing.TestUtilities;
+import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
+
+public class TestGrindstoneListener {
+
+ private static SlimefunPlugin plugin;
+ private static GrindstoneListener listener;
+ private static ServerMock server;
+
+ @BeforeAll
+ public static void load() {
+ server = MockBukkit.mock();
+ plugin = MockBukkit.load(SlimefunPlugin.class);
+ listener = new GrindstoneListener(plugin);
+ }
+
+ @AfterAll
+ public static void unload() {
+ MockBukkit.unmock();
+ }
+
+ private InventoryClickEvent mockGrindStoneEvent(ItemStack item) {
+ Player player = server.addPlayer();
+ Inventory inv = TestUtilities.mockInventory(InventoryType.GRINDSTONE, item, null);
+ InventoryView view = player.openInventory(inv);
+ InventoryClickEvent event = new InventoryClickEvent(view, SlotType.CONTAINER, 2, ClickType.LEFT, InventoryAction.PICKUP_ONE);
+
+ listener.onGrindstone(event);
+ return event;
+ }
+
+ @Test
+ public void testGrindStoneWithoutSlimefunItems() {
+ InventoryClickEvent event = mockGrindStoneEvent(new ItemStack(Material.ENCHANTED_BOOK));
+ Assertions.assertEquals(Result.DEFAULT, event.getResult());
+ }
+
+ @Test
+ public void testGrindStoneWithSlimefunItem() {
+ SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "ENCHANTED_MOCK_BOOK", new CustomItem(Material.ENCHANTED_BOOK, "&6Mock"));
+ item.register(plugin);
+
+ InventoryClickEvent event = mockGrindStoneEvent(item.getItem());
+ Assertions.assertEquals(Result.DENY, event.getResult());
+ }
+
+ @Test
+ public void testGrindStoneWithVanillaItem() {
+ VanillaItem item = TestUtilities.mockVanillaItem(plugin, Material.ENCHANTED_BOOK, true);
+ item.register(plugin);
+
+ InventoryClickEvent event = mockGrindStoneEvent(item.getItem());
+ Assertions.assertEquals(Result.DEFAULT, event.getResult());
+ }
+
+ @ParameterizedTest
+ @EnumSource(SlimefunGuideLayout.class)
+ public void testGrindStoneWithSlimefunGuide(SlimefunGuideLayout layout) {
+ InventoryClickEvent event = mockGrindStoneEvent(SlimefunGuide.getItem(layout));
+ Assertions.assertEquals(Result.DENY, event.getResult());
+ }
+
+}
diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestItemPickupListener.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestItemPickupListener.java
index 7ee7b04f8..55e58b067 100644
--- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestItemPickupListener.java
+++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestItemPickupListener.java
@@ -19,7 +19,7 @@ import org.junit.jupiter.params.provider.ValueSource;
import be.seeseemelk.mockbukkit.MockBukkit;
import be.seeseemelk.mockbukkit.ServerMock;
import be.seeseemelk.mockbukkit.entity.ItemEntityMock;
-import be.seeseemelk.mockbukkit.inventory.ChestInventoryMock;
+import be.seeseemelk.mockbukkit.inventory.HopperInventoryMock;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import io.github.thebusybiscuit.slimefun4.implementation.items.altar.AncientPedestal;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.ItemPickupListener;
@@ -63,7 +63,7 @@ class TestItemPickupListener {
@ParameterizedTest
@ValueSource(booleans = { true, false })
void testNoPickupFlagForInventories(boolean flag) {
- Inventory inventory = new ChestInventoryMock(null, 5);
+ Inventory inventory = new HopperInventoryMock(null);
Item item = new ItemEntityMock(server, UUID.randomUUID(), new ItemStack(Material.COMPASS));
if (flag) {
@@ -107,7 +107,7 @@ class TestItemPickupListener {
@ParameterizedTest
@ValueSource(booleans = { true, false })
void testAltarProbeForInventories(boolean flag) {
- Inventory inventory = new ChestInventoryMock(null, 5);
+ Inventory inventory = new HopperInventoryMock(null);
ItemStack stack;
if (flag) {
diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestVanillaMachinesListener.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestVanillaMachinesListener.java
deleted file mode 100644
index b87f39a25..000000000
--- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestVanillaMachinesListener.java
+++ /dev/null
@@ -1,302 +0,0 @@
-package io.github.thebusybiscuit.slimefun4.testing.tests.listeners;
-
-import org.apache.commons.lang.mutable.MutableObject;
-import org.bukkit.Material;
-import org.bukkit.NamespacedKey;
-import org.bukkit.block.BrewingStand;
-import org.bukkit.entity.Player;
-import org.bukkit.event.Event.Result;
-import org.bukkit.event.inventory.ClickType;
-import org.bukkit.event.inventory.CraftItemEvent;
-import org.bukkit.event.inventory.InventoryAction;
-import org.bukkit.event.inventory.InventoryClickEvent;
-import org.bukkit.event.inventory.InventoryType;
-import org.bukkit.event.inventory.InventoryType.SlotType;
-import org.bukkit.event.inventory.PrepareItemCraftEvent;
-import org.bukkit.inventory.CraftingInventory;
-import org.bukkit.inventory.Inventory;
-import org.bukkit.inventory.InventoryView;
-import org.bukkit.inventory.ItemStack;
-import org.bukkit.inventory.Recipe;
-import org.bukkit.inventory.ShapedRecipe;
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.EnumSource;
-import org.mockito.Mockito;
-
-import be.seeseemelk.mockbukkit.MockBukkit;
-import be.seeseemelk.mockbukkit.ServerMock;
-import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
-import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
-import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout;
-import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
-import io.github.thebusybiscuit.slimefun4.implementation.items.VanillaItem;
-import io.github.thebusybiscuit.slimefun4.implementation.listeners.VanillaMachinesListener;
-import io.github.thebusybiscuit.slimefun4.testing.TestUtilities;
-import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
-
-public class TestVanillaMachinesListener {
-
- private static SlimefunPlugin plugin;
- private static VanillaMachinesListener listener;
- private static ServerMock server;
-
- @BeforeAll
- public static void load() {
- server = MockBukkit.mock();
- plugin = MockBukkit.load(SlimefunPlugin.class);
- listener = new VanillaMachinesListener(plugin);
- }
-
- @AfterAll
- public static void unload() {
- MockBukkit.unmock();
- }
-
- private InventoryClickEvent mockGrindStoneEvent(ItemStack item) {
- Player player = server.addPlayer();
- Inventory inv = TestUtilities.mockInventory(InventoryType.GRINDSTONE, item, null);
- InventoryView view = player.openInventory(inv);
- InventoryClickEvent event = new InventoryClickEvent(view, SlotType.CONTAINER, 2, ClickType.LEFT, InventoryAction.PICKUP_ONE);
-
- listener.onGrindstone(event);
- return event;
- }
-
- private InventoryClickEvent mockAnvilEvent(ItemStack item) {
- Player player = server.addPlayer();
- Inventory inv = TestUtilities.mockInventory(InventoryType.ANVIL, item, null, new ItemStack(Material.IRON_CHESTPLATE));
- InventoryView view = player.openInventory(inv);
- InventoryClickEvent event = new InventoryClickEvent(view, SlotType.CONTAINER, 2, ClickType.LEFT, InventoryAction.PICKUP_ONE);
-
- listener.onAnvil(event);
- return event;
- }
-
- private InventoryClickEvent mockCartographyTableEvent(ItemStack item) {
- Player player = server.addPlayer();
- Inventory inv = TestUtilities.mockInventory(InventoryType.CARTOGRAPHY, new ItemStack(Material.FILLED_MAP), item, new ItemStack(Material.FILLED_MAP));
- InventoryView view = player.openInventory(inv);
- InventoryClickEvent event = new InventoryClickEvent(view, SlotType.CONTAINER, 2, ClickType.LEFT, InventoryAction.PICKUP_ONE);
-
- listener.onCartographyTable(event);
- return event;
- }
-
- private InventoryClickEvent mockBrewingEvent(ItemStack item) {
- Player player = server.addPlayer();
- Inventory inv = TestUtilities.mockInventory(InventoryType.BREWING);
- Mockito.when(inv.getHolder()).thenReturn(Mockito.mock(BrewingStand.class));
- Mockito.when(inv.getSize()).thenReturn(5);
-
- InventoryView view = player.openInventory(inv);
- view.setCursor(item);
- InventoryClickEvent event = new InventoryClickEvent(view, SlotType.CONTAINER, 1, ClickType.LEFT, InventoryAction.PICKUP_ONE);
- listener.onPreBrew(event);
- return event;
- }
-
- private CraftItemEvent mockCraftingEvent(ItemStack item) {
- Recipe recipe = new ShapedRecipe(new NamespacedKey(plugin, "test_recipe"), new ItemStack(Material.EMERALD));
- Player player = server.addPlayer();
-
- CraftingInventory inv = Mockito.mock(CraftingInventory.class);
- Mockito.when(inv.getContents()).thenReturn(new ItemStack[] { item, null, null, null, null, null, null, null, null });
-
- InventoryView view = player.openInventory(inv);
- CraftItemEvent event = new CraftItemEvent(recipe, view, SlotType.RESULT, 9, ClickType.LEFT, InventoryAction.PICKUP_ALL);
-
- listener.onCraft(event);
- return event;
- }
-
- private PrepareItemCraftEvent mockPreCraftingEvent(ItemStack item) {
- Player player = server.addPlayer();
-
- CraftingInventory inv = Mockito.mock(CraftingInventory.class);
- MutableObject result = new MutableObject(new ItemStack(Material.EMERALD));
-
- Mockito.doAnswer(invocation -> {
- ItemStack argument = invocation.getArgument(0);
- result.setValue(argument);
- return null;
- }).when(inv).setResult(Mockito.any());
-
- Mockito.when(inv.getResult()).thenAnswer(invocation -> result.getValue());
- Mockito.when(inv.getContents()).thenReturn(new ItemStack[] { null, null, item, null, null, null, null, null, null });
-
- InventoryView view = player.openInventory(inv);
- PrepareItemCraftEvent event = new PrepareItemCraftEvent(inv, view, false);
-
- listener.onPrepareCraft(event);
- return event;
- }
-
- @Test
- public void testGrindStoneWithoutSlimefunItems() {
- InventoryClickEvent event = mockGrindStoneEvent(new ItemStack(Material.ENCHANTED_BOOK));
- Assertions.assertEquals(Result.DEFAULT, event.getResult());
- }
-
- @Test
- public void testGrindStoneWithSlimefunItem() {
- SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "ENCHANTED_MOCK_BOOK", new CustomItem(Material.ENCHANTED_BOOK, "&6Mock"));
- item.register(plugin);
-
- InventoryClickEvent event = mockGrindStoneEvent(item.getItem());
- Assertions.assertEquals(Result.DENY, event.getResult());
- }
-
- @Test
- public void testGrindStoneWithVanillaItem() {
- VanillaItem item = TestUtilities.mockVanillaItem(plugin, Material.ENCHANTED_BOOK, true);
- item.register(plugin);
-
- InventoryClickEvent event = mockGrindStoneEvent(item.getItem());
- Assertions.assertEquals(Result.DEFAULT, event.getResult());
- }
-
- @ParameterizedTest
- @EnumSource(SlimefunGuideLayout.class)
- public void testGrindStoneWithSlimefunGuide(SlimefunGuideLayout layout) {
- InventoryClickEvent event = mockGrindStoneEvent(SlimefunGuide.getItem(layout));
- Assertions.assertEquals(Result.DENY, event.getResult());
- }
-
- @Test
- public void testCraftEventWithoutSlimefunItems() {
- CraftItemEvent event = mockCraftingEvent(new ItemStack(Material.DIAMOND));
- Assertions.assertEquals(Result.DEFAULT, event.getResult());
- }
-
- @Test
- public void testCraftEventWithSlimefunItem() {
- SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MOCK_DIAMOND", new CustomItem(Material.DIAMOND, "&cMock Diamond"));
- item.register(plugin);
-
- CraftItemEvent event = mockCraftingEvent(item.getItem());
- Assertions.assertEquals(Result.DENY, event.getResult());
- }
-
- @Test
- public void testCraftEventWithChangingSlimefunItem() {
- SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "CHANGING_ITEM", new CustomItem(Material.DIAMOND, "&dChanging Diamond"));
- item.register(plugin);
-
- item.setUseableInWorkbench(true);
- CraftItemEvent event = mockCraftingEvent(item.getItem());
- Assertions.assertEquals(Result.DEFAULT, event.getResult());
-
- item.setUseableInWorkbench(false);
- CraftItemEvent event2 = mockCraftingEvent(item.getItem());
- Assertions.assertEquals(Result.DENY, event2.getResult());
- }
-
- @Test
- public void testCraftEventWithVanillaItem() {
- VanillaItem item = TestUtilities.mockVanillaItem(plugin, Material.DIAMOND, true);
- item.register(plugin);
-
- CraftItemEvent event = mockCraftingEvent(item.getItem());
- Assertions.assertEquals(Result.DEFAULT, event.getResult());
- }
-
- @Test
- public void testPreCraftEventWithoutSlimefunItems() {
- PrepareItemCraftEvent event = mockPreCraftingEvent(new ItemStack(Material.DIAMOND));
- Assertions.assertNotNull(event.getInventory().getResult());
- }
-
- @Test
- public void testPreCraftEventWithSlimefunItem() {
- SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MOCK_DIAMOND2", new CustomItem(Material.DIAMOND, "&cMock Diamond"));
- item.register(plugin);
-
- PrepareItemCraftEvent event = mockPreCraftingEvent(item.getItem());
- Assertions.assertNull(event.getInventory().getResult());
- }
-
- @Test
- public void testPreCraftEventWithVanillaItem() {
- VanillaItem item = TestUtilities.mockVanillaItem(plugin, Material.GOLD_INGOT, true);
- item.register(plugin);
-
- PrepareItemCraftEvent event = mockPreCraftingEvent(item.getItem());
- Assertions.assertNotNull(event.getInventory().getResult());
- }
-
- @Test
- public void testAnvilWithoutSlimefunItems() {
- InventoryClickEvent event = mockAnvilEvent(new ItemStack(Material.IRON_SWORD));
- Assertions.assertEquals(Result.DEFAULT, event.getResult());
- }
-
- @Test
- public void testAnvilWithSlimefunItem() {
- SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MOCKED_IRON_SWORD", new CustomItem(Material.IRON_SWORD, "&6Mock"));
- item.register(plugin);
-
- InventoryClickEvent event = mockAnvilEvent(item.getItem());
- Assertions.assertEquals(Result.DENY, event.getResult());
- }
-
- @Test
- public void testAnvilWithVanillaItem() {
- VanillaItem item = TestUtilities.mockVanillaItem(plugin, Material.IRON_SWORD, true);
- item.register(plugin);
-
- InventoryClickEvent event = mockAnvilEvent(item.getItem());
- Assertions.assertEquals(Result.DEFAULT, event.getResult());
- }
-
- @Test
- public void testCartographyTableWithoutSlimefunItems() {
- InventoryClickEvent event = mockCartographyTableEvent(new ItemStack(Material.PAPER));
- Assertions.assertEquals(Result.DEFAULT, event.getResult());
- }
-
- @Test
- public void testCartographyTableWithSlimefunItem() {
- SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MOCKED_PAPER", new CustomItem(Material.PAPER, "&6Mock"));
- item.register(plugin);
-
- InventoryClickEvent event = mockCartographyTableEvent(item.getItem());
- Assertions.assertEquals(Result.DENY, event.getResult());
- }
-
- @Test
- public void testCartographyTableWithVanillaItem() {
- VanillaItem item = TestUtilities.mockVanillaItem(plugin, Material.PAPER, true);
- item.register(plugin);
-
- InventoryClickEvent event = mockCartographyTableEvent(item.getItem());
- Assertions.assertEquals(Result.DEFAULT, event.getResult());
- }
-
- @Test
- public void testBrewingWithoutSlimefunItems() {
- InventoryClickEvent event = mockBrewingEvent(new ItemStack(Material.BLAZE_POWDER));
- Assertions.assertEquals(Result.ALLOW, event.getResult());
- }
-
- @Test
- public void testBrewingWithSlimefunItem() {
- SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MOCK_POWDER", new CustomItem(Material.BLAZE_POWDER, "&6Magic Mock Powder"));
- item.register(plugin);
-
- InventoryClickEvent event = mockBrewingEvent(item.getItem());
- Assertions.assertEquals(Result.DENY, event.getResult());
- }
-
- @Test
- public void testBrewingWithVanillaItem() {
- VanillaItem item = TestUtilities.mockVanillaItem(plugin, Material.BLAZE_POWDER, true);
- item.register(plugin);
-
- InventoryClickEvent event = mockBrewingEvent(item.getItem());
- Assertions.assertEquals(Result.ALLOW, event.getResult());
- }
-}
diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/registration/TestSlimefunItemRegistration.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/registration/TestSlimefunItemRegistration.java
index 9fa917323..3d67f32e5 100644
--- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/registration/TestSlimefunItemRegistration.java
+++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/registration/TestSlimefunItemRegistration.java
@@ -50,7 +50,7 @@ public class TestSlimefunItemRegistration {
Assertions.assertEquals(ItemState.ENABLED, item.getState());
Assertions.assertFalse(item.isDisabled());
- Assertions.assertEquals(id, item.getID());
+ Assertions.assertEquals(id, item.getId());
Assertions.assertEquals(item, SlimefunItem.getByID(id));
}
@@ -176,7 +176,7 @@ public class TestSlimefunItemRegistration {
Assertions.assertFalse(sfItem.isItem(new CustomItem(Material.BEACON, "&cItem Test")));
}
- Assertions.assertEquals(sfItem, SlimefunItem.getByItem(new SlimefunItemStack(sfItem.getID(), item)));
+ Assertions.assertEquals(sfItem, SlimefunItem.getByItem(new SlimefunItemStack(sfItem.getId(), item)));
}
@Test
diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/services/TextCustomTextureService.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/services/TextCustomTextureService.java
index 44801d46f..ea248be8e 100644
--- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/services/TextCustomTextureService.java
+++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/services/TextCustomTextureService.java
@@ -60,17 +60,17 @@ class TextCustomTextureService {
SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "TEXTURE_TEST", new ItemStack(Material.LANTERN));
String version = "Unit Test v1.0";
- config.setValue(item.getID(), 300);
+ config.setValue(item.getId(), 300);
config.setValue("version", version);
service.register(Arrays.asList(item), false);
Assertions.assertTrue(service.isActive());
Assertions.assertEquals(version, service.getVersion());
- Assertions.assertEquals(300, service.getModelData(item.getID()));
+ Assertions.assertEquals(300, service.getModelData(item.getId()));
ItemStack stack = new ItemStack(Material.DIAMOND);
- service.setTexture(stack, item.getID());
+ service.setTexture(stack, item.getId());
Assertions.assertTrue(stack.getItemMeta().hasCustomModelData());
Assertions.assertEquals(300, stack.getItemMeta().getCustomModelData());