Fixes some problems in the plugin destroyed sign check

This commit is contained in:
Kristian Knarvik 2022-11-12 01:27:46 +01:00
parent 4fee628469
commit cf66113ac1

View File

@ -8,8 +8,9 @@ import net.knarcraft.paidsigns.formatting.PaidSignsTranslatableMessage;
import net.knarcraft.paidsigns.manager.EconomyManager;
import net.knarcraft.paidsigns.manager.TrackedSignManager;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.block.data.type.Sign;
import org.bukkit.block.Sign;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@ -120,12 +121,13 @@ public class SignListener implements Listener {
}
performPaidSignTransaction(paidSign, player, event);
Location signLocation = event.getBlock().getLocation();
if (!event.isCancelled()) {
//Immediately refund if a plugin destroyed the sign within 5 ticks of the creation
Bukkit.getScheduler().scheduleSyncDelayedTask(PaidSigns.getInstance(), () -> {
Block block = event.getBlock();
if (!(block.getBlockData() instanceof Sign)) {
Block block = signLocation.getBlock();
if (!(block.getState() instanceof Sign)) {
try {
TrackedSignManager.removeTrackedSign(block.getLocation(), true, true);
} catch (IOException e) {