Skip to content

Commit

Permalink
Fix incompatibility with plugins that change sign blocks onSignChange;
Browse files Browse the repository at this point in the history
…resolves #423
  • Loading branch information
Sataniel98 committed Jun 16, 2018
1 parent 2da4e74 commit 024f004
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
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;
Expand Down Expand Up @@ -228,6 +229,11 @@ public void onInteract(PlayerInteractEvent event) {
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
Expand All @@ -251,12 +257,8 @@ public void onSignChange(SignChangeEvent event) {
}

} 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);
}
}
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/de/erethon/dungeonsxl/sign/DSignListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
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;
Expand Down Expand Up @@ -79,7 +80,12 @@ public void onSignChange(SignChangeEvent event) {
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;
Expand Down

0 comments on commit 024f004

Please sign in to comment.