Duplicate Messages

Discussion in 'Plugin Development' started by jkcclemens, Dec 12, 2011.

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

    jkcclemens

    I've noticed recently that some of my messages duplicate. At first I noticed that in my onEnable(), the initiation message showed twice in console. But now, I'm noticing that new .sendMessage()'s are doing it twice as well.

    Code:
    
    	public void onSignChange(SignChangeEvent event) {
    
    		String line0 = event.getLine(0);
    		String line1 = event.getLine(1);
    		String line2 = event.getLine(2);
    
    		if (line0.equalsIgnoreCase("[setarmor]")) {
    			if (line1 != null) {
    				if (!line1.equalsIgnoreCase("diamond")
    						&& !line1.equalsIgnoreCase("gold")
    						&& !line1.equalsIgnoreCase("iron")
    						&& !line1.equalsIgnoreCase("leather")
    						&& !line1.equalsIgnoreCase("none")) {
    					event.getPlayer().sendMessage(
    							ChatColor.RED + "That is not an allowed material!");
    					event.setLine(1, ChatColor.RED + line1);
    				}
    				if (line2 != null) {
    					try {
    						Integer.parseInt(line2);
    					} catch (Exception e) {
    						event.getPlayer().sendMessage(
    								ChatColor.RED + "That is an invalid number.");
    						event.setLine(2, ChatColor.RED + line2);
    					}
    				}
    
    			}
    		}
    	}
    
    I've been trying to implement a command on a sign, but if you put in an invalid value, it repeats the message like "That is not an allowed material!" twice. I cannot see how it would do that.

    Running on CB 1580 and Bukkit 1066. Debian 6 64bit.

    Any ideas?


    EDIT --
    The whole source is here. In case you'd like too look because so many things are being duplicated, I can't even begin to understand why.
    That part was my bad, had two jars in there. The first problem still stands, however.
     
  2. You aren't cancelling the event.
    event.setCancelled(true);

    Maybe it fires onSignChange twice when you haven't cancelled it?
     
  3. Offline

    Nitnelave

    also check that you don't have a two versions of you plugin loaded ^^
     
  4. Offline

    jkcclemens

    Seems to have solved it. Thanks.
     
  5. Cool. It is still strange that Bukkit fires two onSignChange events...
     
Thread Status:
Not open for further replies.

Share This Page