p.sendMessage("msg") firing twice

Discussion in 'Plugin Development' started by Blares, Oct 19, 2017.

Thread Status:
Not open for further replies.
  1. Offline

    Blares

    I need help. My plugin keeps firing the p.sendmessage twice in game. It cancels the event but the no permission message is firing twice, I really need some help. (Worldgaurd kinda thing)

    Code:
    @EventHandler
    public void onBreakBlock(BlockBreakEvent e) {
    
    Player p = e.getPlayer();
    
    if (p.hasPermission("worldgaurd.break.permission")) {
    
    
    
    }else {
    
    e.setCancelled(true);
    
    p.sendMessage(ChatColor.BOLD + "" + ChatColor.AQUA + "Server" + ChatColor.GRAY + ">> " + ChatColor.RESET + ChatColor.RED + "You don't have permission");
    
    }
    
    }
     
    Last edited by a moderator: Oct 19, 2017
  2. Offline

    timtower Administrator Administrator Moderator

    @Blares Please post your main class and the constructor of this one.
     
  3. Offline

    Blares

    Main

    Code:
    
    @SuppressWarnings("unused")
    public class CoreHub extends JavaPlugin {
    
    public void onEnable() {
    System.out.println("Plugin enabled (!)"); <- I know I don't need it but makes me feel better :D
    
    [here is a list of 10000000 events being registered. So I only put the class I was talking about]
    
    Bukkit.getServer().getPluginManager().registerEvents(new WorldProtection(),this);
    Code:
    
    public class WorldProtection implements Listener {
    
    @EventHandler
    public void onBreakBlock(BlockBreakEvent e) {
    
    Player p = e.getPlayer();
    if (p.hasPermission("worldguard.break")) {
    
    
    
    }else {
    
    e.setCancelled(true);
    p.sendMessage(ChatColor.BOLD + "" + ChatColor.AQUA + "Server" + ChatColor.GRAY + ">> " + ChatColor.RESET + ChatColor.RED + "You don't have permission");}
    
    }
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
  4. Offline

    timtower Administrator Administrator Moderator

    @Blares Please just post the entire onEnable, and make sure it has the formatting. Same for the event class.
     
  5. Offline

    ChessIndustries

    Pretty sure the reason is that world guard is displaying a message, and your plugin is displaying a message. I didn't get to see the actual screenshot of the messages so I may not be correct
    EDIT: Do you have the WorldGuard plugin or not?
     
Thread Status:
Not open for further replies.

Share This Page