mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-09 20:31:28 +01:00
Fix incompatibility with plugins that change sign blocks onSignChange; resolves #423
This commit is contained in:
parent
2da4e74261
commit
024f004153
@ -26,6 +26,7 @@ import de.erethon.dungeonsxl.world.DEditWorld;
|
||||
import java.util.List;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -228,6 +229,11 @@ public class GlobalProtectionListener implements Listener {
|
||||
public void onSignChange(SignChangeEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
Block block = event.getBlock();
|
||||
BlockState state = block.getState();
|
||||
if (!(state instanceof Sign)) {
|
||||
return;
|
||||
}
|
||||
|
||||
String[] lines = event.getLines();
|
||||
|
||||
// Group Signs
|
||||
@ -251,12 +257,8 @@ public class GlobalProtectionListener implements Listener {
|
||||
}
|
||||
|
||||
} else if (lines[1].equalsIgnoreCase(LeaveSign.LEAVE_SIGN_TAG)) {
|
||||
if (block.getState() instanceof Sign) {
|
||||
Sign sign = (Sign) block.getState();
|
||||
|
||||
new LeaveSign(plugin.getGlobalProtections().generateId(LeaveSign.class, sign.getWorld()), sign);
|
||||
}
|
||||
|
||||
Sign sign = (Sign) state;
|
||||
new LeaveSign(plugin.getGlobalProtections().generateId(LeaveSign.class, sign.getWorld()), sign);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ import de.erethon.dungeonsxl.world.DEditWorld;
|
||||
import de.erethon.dungeonsxl.world.DGameWorld;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -79,7 +80,12 @@ public class DSignListener implements Listener {
|
||||
String[] lines = event.getLines();
|
||||
Player player = event.getPlayer();
|
||||
Block block = event.getBlock();
|
||||
Sign sign = (Sign) block.getState();
|
||||
BlockState state = block.getState();
|
||||
if (!(state instanceof Sign)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Sign sign = (Sign) state;
|
||||
DEditWorld editWorld = DEditWorld.getByWorld(sign.getWorld());
|
||||
if (editWorld == null) {
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user