.

Discussion in 'Spigot Plugin Development' started by bys1, May 27, 2016.

Thread Status:
Not open for further replies.
  1. .
     
    #1 bys1, May 27, 2016
    Last edited: May 29, 2016
  2. You should use the async chat event.
     
  3. I'm doing that already.
     
  4. @NinjaStix taught me this way, its a little bit hacky, but works:

    Code (Text):
    e.setMessage("chat format");

            e.setFormat(e.getMessage());
     
  5. Did you even read my code? The problem is that my method returns nothing / empty list
     
  6. Check the console for an exception. If the the message is not broadcasting then something is going wrong inside the method, or before the method is even called. Paste your stack trace, if any.
     
    • Agree Agree x 1
  7. I don't have errors.

    I have tried to debug with messages. The input was String '%displayname%: %message%' and Player bys1
    Before returning you see a broadcast in my method, that doesn't broadcast anything.
     
  8. instead of doing
    Code (Java):
    format = format.replaceFirst("%displayname%","");
    formats.add(player.getDisplayName());
    try this replacing method
    Code (Java):
    format = format.replace("%displayname%", player.getDisplayName());
     
    • Optimistic Optimistic x 1
  9. I think your getting caught in an infinite loop "while (format.indexOf("%") > -1) {" after you test the plugin let the server run for a couple mins. if the server hangs this is the case. I'm sorry I didn't see your reply popup earlier, I somehow missed it I guess.

    EDIT: If this code is in the AsyncPlayerChatEvent then I am thinking it might not hang the server(can't think rn). Try to print a debug message inside the while loop to see if the condition is ever met.

    Sorry if nothing I've typed makes any sense, I am really tired.
     
    #9 NinjaStix, May 28, 2016
    Last edited: May 28, 2016
  10. Your method is pretty unefficient and hard to overview. If you want to replace for example the player name, use @MadMaxCookie 's method.

    If you learned a similar method like yours from a tutorial, you should search for a new one.
     
    #10 Chrisstar56, May 28, 2016
    Last edited: May 28, 2016
    • Agree Agree x 1
  11. expanding idea
    if you are watching or reading tutorial you have to learn code before using it.

    So that you can create your own method more efficient or edible.
     
    • Agree Agree x 2
Thread Status:
Not open for further replies.