1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-19 19:25:48 +00:00
This commit is contained in:
TheBusyBiscuit 2021-01-23 14:25:10 +01:00
parent 83c2c6a915
commit 389a2978c0
3 changed files with 8 additions and 18 deletions

View File

@ -47,6 +47,7 @@
* Fixed some backpack opening issues
* Fixed Infused Hopper picking up items with a max pickup delay
* Fixed duplication issues related to holograms/armorstands
* Fixed #2754
## Release Candidate 19 (11 Jan 2021)

View File

@ -23,7 +23,7 @@
<maven.compiler.target>1.8</maven.compiler.target>
<!-- Spigot properties -->
<spigot.version>1.16.4</spigot.version>
<spigot.version>1.16.5</spigot.version>
<spigot.javadocs>https://hub.spigotmc.org/javadocs/spigot/</spigot.javadocs>
<!-- Default settings for sonarcloud.io -->

View File

@ -2,15 +2,14 @@ package io.github.thebusybiscuit.slimefun4.implementation.listeners;
import javax.annotation.Nonnull;
import org.bukkit.block.Block;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
import io.github.thebusybiscuit.slimefun4.utils.itemstack.ItemStackWrapper;
import io.github.thebusybiscuit.slimefun4.implementation.items.cargo.CargoNode;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
/**
@ -28,25 +27,15 @@ public class CargoNodeListener implements Listener {
@EventHandler(ignoreCancelled = true)
public void onCargoNodePlace(BlockPlaceEvent e) {
if (e.getBlock().getY() != e.getBlockAgainst().getY() && isCargoNode(e.getItemInHand())) {
Block b = e.getBlock();
if ((b.getY() != e.getBlockAgainst().getY() || !b.isEmpty()) && isCargoNode(e.getItemInHand())) {
SlimefunPlugin.getLocalization().sendMessage(e.getPlayer(), "machines.CARGO_NODES.must-be-placed", true);
e.setCancelled(true);
}
}
private boolean isCargoNode(@Nonnull ItemStack item) {
if (SlimefunPlugin.getRegistry().isBackwardsCompatible()) {
ItemStackWrapper wrapper = new ItemStackWrapper(item);
return SlimefunUtils.isItemSimilar(wrapper, SlimefunItems.CARGO_INPUT_NODE, false) || SlimefunUtils.isItemSimilar(wrapper, SlimefunItems.CARGO_OUTPUT_NODE, false) || SlimefunUtils.isItemSimilar(wrapper, SlimefunItems.CARGO_OUTPUT_NODE_2, false);
}
SlimefunItem sfItem = SlimefunItem.getByItem(item);
if (sfItem == null) {
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 SlimefunItem.getByItem(item) instanceof CargoNode;
}
}