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-28 12:37:13 +01:00
parent 20694c19bd
commit 6df052e4cf
2 changed files with 13 additions and 19 deletions

View File

@ -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)

View File

@ -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,22 +67,14 @@ 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())) {
/* for (ItemStack item : sfItem.getDrops()) {
* We can move the TickerTask synchronization to an async task to if (item != null && !item.getType().isAir()) {
* avoid blocking the main Thread here. block.getWorld().dropItemNaturally(block.getLocation(), item);
*/
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
if (!SlimefunPlugin.getTickerTask().isDeletedSoon(block.getLocation())) {
for (ItemStack item : sfItem.getDrops()) {
if (item != null && !item.getType().isAir()) {
SlimefunPlugin.runSync(() -> 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();