[URGENT] Chat Event Problems

Discussion in 'Plugin Development' started by Henryjake121, Nov 17, 2013.

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

    Henryjake121

    Hey there, I am creating a plugin that modifies the chat format, and more.
    I set the chat format, but it does not work in-game.
    Code:java
    1. public void onChatEvent(AsyncPlayerChatEvent e){
    2. Player p = e.getPlayer();
    3. // Unrelated stuff
    4. else{
    5. e.setFormat("§r" + ChatColor.translateAlternateColorCodes("&".charAt(0), plugin.getConfig().getString("chat-format")).replaceAll("%s", "%1$s").replaceAll("%m", "%2$s"));
    6. }
    7. }

    and the related config snippet...
    Code:
    chat-format: '&f%s&7: &f%m'
    The other functions in the chat event work, but setting the chat format does not.

    Could someone help me?
     
  2. Offline

    Garris0n

    Events registered? EventHandler annotation? And just use '&'.
     
  3. Offline

    Henryjake121

    Yes, I have both of those.
     
  4. Offline

    Garris0n

    Well, first of all what is the code attempting to do, and second it appears your "unrelated stuff" might be related, so please post the entire listener.
     
  5. Offline

    Henryjake121

    @Garris0n

    Code:java
    1. String mm=ChatColor.translateAlternateColorCodes("&".charAt(0), plugin.getConfig().getString("chat-format")).replaceAll("%s", p.getName());
    2. String lm=ChatColor.translateAlternateColorCodes("&".charAt(0), plugin.getConfig().getString("chat-locked-message")).replaceAll("%s", p.getName());
    3. if(plugin.mp.contains(p.getName())){
    4. try {
    5. e.setCancelled(true);
    6. p.sendMessage(mm);
    7. } catch(Exception ex) {
    8. e.setMessage("");
    9. p.sendMessage(mm);
    10. plugin.logger.warning("Couldn't cancel the Chat Event!");
    11. }
    12. }
    13. else if(plugin.lc == true){
    14. try{
    15. e.setCancelled(true);
    16. p.sendMessage(lm);
    17. } catch(Exception ex){
    18. e.setMessage("");
    19. p.sendMessage(lm);
    20. plugin.logger.warning("Couldn't cancel the Chat Event!");
    21. }
    22. }
     
Thread Status:
Not open for further replies.

Share This Page