mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-19 19:25:48 +00:00
Fixes #2771
This commit is contained in:
parent
20694c19bd
commit
6df052e4cf
@ -56,6 +56,7 @@
|
|||||||
* Fixed #2761
|
* Fixed #2761
|
||||||
* Fixed #2460
|
* Fixed #2460
|
||||||
* Fixed #2760
|
* Fixed #2760
|
||||||
|
* Fixed #2771
|
||||||
|
|
||||||
## Release Candidate 19 (11 Jan 2021)
|
## Release Candidate 19 (11 Jan 2021)
|
||||||
|
|
||||||
|
@ -10,7 +10,6 @@ import javax.annotation.Nonnull;
|
|||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import javax.annotation.ParametersAreNonnullByDefault;
|
import javax.annotation.ParametersAreNonnullByDefault;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
@ -51,10 +50,7 @@ import me.mrCookieSlime.Slimefun.api.Slimefun;
|
|||||||
*/
|
*/
|
||||||
public class BlockListener implements Listener {
|
public class BlockListener implements Listener {
|
||||||
|
|
||||||
private final SlimefunPlugin plugin;
|
|
||||||
|
|
||||||
public BlockListener(@Nonnull SlimefunPlugin plugin) {
|
public BlockListener(@Nonnull SlimefunPlugin plugin) {
|
||||||
this.plugin = plugin;
|
|
||||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,23 +67,15 @@ public class BlockListener implements Listener {
|
|||||||
if (e.getBlockReplacedState().getType().isAir()) {
|
if (e.getBlockReplacedState().getType().isAir()) {
|
||||||
SlimefunItem sfItem = BlockStorage.check(block);
|
SlimefunItem sfItem = BlockStorage.check(block);
|
||||||
|
|
||||||
if (sfItem != null) {
|
if (sfItem != null && !SlimefunPlugin.getTickerTask().isDeletedSoon(block.getLocation())) {
|
||||||
/*
|
|
||||||
* We can move the TickerTask synchronization to an async task to
|
|
||||||
* avoid blocking the main Thread here.
|
|
||||||
*/
|
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
|
||||||
if (!SlimefunPlugin.getTickerTask().isDeletedSoon(block.getLocation())) {
|
|
||||||
for (ItemStack item : sfItem.getDrops()) {
|
for (ItemStack item : sfItem.getDrops()) {
|
||||||
if (item != null && !item.getType().isAir()) {
|
if (item != null && !item.getType().isAir()) {
|
||||||
SlimefunPlugin.runSync(() -> block.getWorld().dropItemNaturally(block.getLocation(), item));
|
block.getWorld().dropItemNaturally(block.getLocation(), item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockStorage.clearBlockInfo(block);
|
BlockStorage.clearBlockInfo(block);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
} else if (BlockStorage.hasBlockInfo(e.getBlock())) {
|
} else if (BlockStorage.hasBlockInfo(e.getBlock())) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
@ -124,6 +112,11 @@ public class BlockListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ignore blocks which we have marked as deleted (Fixes #2771)
|
||||||
|
if (SlimefunPlugin.getTickerTask().isDeletedSoon(e.getBlock().getLocation())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
checkForSensitiveBlockAbove(e.getPlayer(), e.getBlock());
|
checkForSensitiveBlockAbove(e.getPlayer(), e.getBlock());
|
||||||
|
|
||||||
ItemStack item = e.getPlayer().getInventory().getItemInMainHand();
|
ItemStack item = e.getPlayer().getInventory().getItemInMainHand();
|
||||||
|
Loading…
Reference in New Issue
Block a user