mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-19 19:25:48 +00:00
Fixes #2183
This commit is contained in:
parent
cafa66b1a8
commit
56b78eac61
@ -34,6 +34,7 @@
|
||||
* Fixed #2176
|
||||
* Fixed #2103
|
||||
* Fixed #2184
|
||||
* Fixed #2183
|
||||
|
||||
## Release Candidate 15 (01 Aug 2020)
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Material;
|
||||
@ -33,7 +33,7 @@ import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset;
|
||||
public abstract class CropGrowthAccelerator extends SlimefunItem implements InventoryBlock, EnergyNetComponent {
|
||||
|
||||
private final int[] border = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 };
|
||||
private final Set<Material> crops = new HashSet<>();
|
||||
private final Set<Material> crops = EnumSet.noneOf(Material.class);
|
||||
|
||||
// We wanna strip the Slimefun Item id here
|
||||
private static final ItemStack organicFertilizer = new ItemStackWrapper(SlimefunItems.FERTILIZER);
|
||||
|
@ -1,7 +1,7 @@
|
||||
package io.github.thebusybiscuit.slimefun4.implementation.listeners;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Random;
|
||||
@ -35,7 +35,7 @@ import me.mrCookieSlime.Slimefun.api.Slimefun;
|
||||
public class BlockListener implements Listener {
|
||||
|
||||
// Materials that require a Block under it, e.g. Pressure Plates
|
||||
private final Set<Material> sensitiveMaterials = new HashSet<>();
|
||||
private final Set<Material> sensitiveMaterials = EnumSet.noneOf(Material.class);
|
||||
|
||||
public BlockListener(SlimefunPlugin plugin) {
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
@ -82,10 +82,7 @@ public class BlockListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onBlockUnregister(BlockBreakEvent e) {
|
||||
if (hasSensitiveBlockAbove(e.getPlayer(), e.getBlock())) {
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
checkForSensitiveBlockAbove(e.getPlayer(), e.getBlock());
|
||||
|
||||
SlimefunItem sfItem = BlockStorage.check(e.getBlock());
|
||||
ItemStack item = e.getPlayer().getInventory().getItemInMainHand();
|
||||
@ -142,7 +139,17 @@ public class BlockListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean hasSensitiveBlockAbove(Player p, Block b) {
|
||||
/**
|
||||
* This method checks for a sensitive {@link Block}.
|
||||
* Sensitive {@link Block Blocks} are pressure plates or saplings, which should be broken
|
||||
* when the block beneath is broken as well.
|
||||
*
|
||||
* @param p
|
||||
* The {@link Player} who broke this {@link Block}
|
||||
* @param b
|
||||
* The {@link Block} that was broken
|
||||
*/
|
||||
private void checkForSensitiveBlockAbove(Player p, Block b) {
|
||||
Block blockAbove = b.getRelative(BlockFace.UP);
|
||||
|
||||
if (sensitiveMaterials.contains(blockAbove.getType())) {
|
||||
@ -156,14 +163,13 @@ public class BlockListener implements Listener {
|
||||
blockAbove.getWorld().dropItemNaturally(blockAbove.getLocation(), BlockStorage.retrieve(blockAbove));
|
||||
blockAbove.setType(Material.AIR);
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
blockAbove.getWorld().dropItemNaturally(blockAbove.getLocation(), BlockStorage.retrieve(blockAbove));
|
||||
blockAbove.setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private int getBonusDropsWithFortune(ItemStack item, Block b) {
|
||||
|
Loading…
Reference in New Issue
Block a user