Anyone knows why onSignChange is not firing in the code below ? Code: import org.bukkit.ChatColor; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.block.SignChangeEvent; public class BlockListener implements Listener { public Checkpoint plugin; public BlockListener(Checkpoint plugin) { this.plugin = plugin; } public void registerEvents() { plugin.getServer().getPluginManager().registerEvents(this, plugin); } @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onSignChange(SignChangeEvent event) { Player player = event.getPlayer(); System.out.println("[MinrCheckpoint] [DEBUG] Sign created. "); if (event.getLine(1).toLowerCase().contains("checkpoint")) { System.out.println("[MinrCheckpoint] [DEBUG] Checkpoint sign created. "); if (player.isOp()) { player.sendMessage(ChatColor.DARK_GREEN + "Checkpoint created successfully!"); } else { player.sendMessage(ChatColor.RED + "You cannot make checkpoints!"); event.setCancelled(true); return; } } } } Relevant code in Checkpoint.java Code: import java.io.File; import java.util.ArrayList; import java.util.Iterator; import java.util.Map; import java.util.Set; import org.bukkit.ChatColor; import org.bukkit.Server; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.java.JavaPlugin; public class Checkpoint extends JavaPlugin { public String path = "plugins" + File.separator + "MinrCheckpoint" + File.separator; public Server server; public void onEnable() { this.server = this.getServer(); PluginDescriptionFile pdfFile = this.getDescription(); System.out.println("[" + pdfFile.getName() + "] (version " + pdfFile.getVersion() + ") is enabled!"); new BlockListener(this); new PlayerListener(this); } }
The second line is what i need to check. But placing a wall sign containing checkpoint on the 2nd line doesn't print the debug to log and doesn't generate an error either. Could it be that my code is conflicting with another plugin like WorldGuard who also listens for sign changes ? EDIT by Moderator: merged posts, please use the edit button instead of double posting.
Do you have looked if the event is get called? Print out a message to the player, to look if the event is get called.
I updated my code in the first post and added the relevant part of Checkpoint.java. I added an extra debug to console line after the event should be called but it doesn't print anything so the event is not called for some reason.
Did you register the event? Are you calling this? Code: public void registerEvents() { plugin.getServer().getPluginManager().registerEvents(this, plugin); } Edit: Ok you forgot to register the event. Change this: Code: public BlockListener(Checkpoint plugin) { this.plugin = plugin; } to: Code: public BlockListener(Checkpoint plugin) { this.plugin = plugin; this.registerEvents(); }