Fix handling of sign updates at places where they will pop off immediately
1. When placing back a missing sign it could be placed in the middle of the air 2. BlockPhysicsEvent would fire immediately (synchronously) breaking the sign 3. Sign update would break because the sign has not actually been placed
This commit is contained in:
parent
e45c353030
commit
ec7983e126
|
@ -152,11 +152,11 @@ public class RegionSign {
|
|||
Sign signState = null;
|
||||
if(!Materials.isSign(block.getType())) {
|
||||
Material signType = getMaterial();
|
||||
if(!Materials.isSign(signType)) {
|
||||
block.setType(signType);
|
||||
if(!Materials.isSign(block.getType())) {
|
||||
AreaShop.debug("Setting sign", key, "of region", getRegion().getName(), "failed, could not set sign block back");
|
||||
return false;
|
||||
}
|
||||
block.setType(signType);
|
||||
signState = (Sign) block.getState();
|
||||
org.bukkit.material.Sign signData = (org.bukkit.material.Sign)signState.getData();
|
||||
BlockFace signFace = getFacing();
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.bukkit.event.block.BlockPhysicsEvent;
|
|||
import org.bukkit.event.block.SignChangeEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.world.ChunkLoadEvent;
|
||||
import org.bukkit.material.Sign;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
@ -108,14 +109,29 @@ public class SignsFeature extends RegionFeature {
|
|||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onIndirectSignBreak(BlockPhysicsEvent event) {
|
||||
// 1.13+ does not support this anymore, only way would be checking surrounding blocks, which is still not 100% sufficient
|
||||
if(Materials.isSign(event.getBlock().getType())) {
|
||||
// Check if the rent sign is really the same as a saved rent
|
||||
if(SignsFeature.getSignByLocation(event.getBlock().getLocation()) != null) {
|
||||
// Remove the sign so that it does not fall on the floor as an item (next region update will place it back)
|
||||
event.getBlock().setType(Material.AIR);
|
||||
}
|
||||
// Check if the block is a sign
|
||||
if(!Materials.isSign(event.getBlock().getType())) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if still attached to a block
|
||||
Block b = event.getBlock();
|
||||
Sign s = (Sign) b.getState().getData();
|
||||
Block attachedBlock = b.getRelative(s.getAttachedFace());
|
||||
if (attachedBlock.getType() != Material.AIR) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if the rent sign is really the same as a saved rent
|
||||
RegionSign regionSign = SignsFeature.getSignByLocation(event.getBlock().getLocation());
|
||||
if(regionSign == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Remove the sign so that it does not fall on the floor as an item (next region update will place it back)
|
||||
AreaShop.debug("onIndirectSignBreak: Removed block of sign for", regionSign.getRegion().getName(), "at", regionSign.getStringLocation());
|
||||
event.getBlock().setType(Material.AIR);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
|
|
Loading…
Reference in New Issue