Filled [Completed] Mention player Chat Plugin

Discussion in 'Archived: Plugin Requests' started by DailyLove, Sep 8, 2013.

  1. Offline

    DailyLove

    Plugin category: Chat-Related

    Suggested name: Mentioneer

    What I want: I need a plugin so that say I type in chat 'DailyLove' it turns to '&a@DailyLove&r' in chat and also makes a sound to that player mentioned in chat Preferably the NOTE_PIANO sound.

    Hopefully it will tag and work with everyone if they are on the server. Say There are 4 players online, player1, player2, player3, and player4. If you type those 4 names in chat they change into '&a@playername&r'

    Hopefully it will work flawlessly and mention players that are only online at the time.

    Ideas for commands: No commands needed for this plugin.

    Ideas for permissions: mentioneer.see: Whether that player can see tagged usernames or not. (Optional)

    When I'd like it by: Next Few days.

    Thank you
     
  2. Offline

    bobacadodl

    Code:
        @EventHandler
        public void onChat(AsyncPlayerChatEvent e){
            for(Player on:Bukkit.getServer().getOnlinePlayers()){
                if(on.equals(e.getPlayer()))continue;
                if(e.getMessage().contains(on.getName())){
     
                    e.setMessage(e.getMessage().replaceAll(on.getName(), ChatColor.GREEN+"@"+on.getName()+ChatColor.RESET));
                    on.playNote(on.getLocation(), Instrument.PIANO, Note.natural(1, Tone.A));
                }
            }
        }
    something like that
     
  3. Offline

    DailyLove

    Is it possible if I can get the full class code?
    Is it possible if I can get the whole java class code?

    Will I need two classes? One for the listener and another for the main?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 4, 2016
  4. Offline

    RingOfStorms

    You don't need two. But you can have anywhere from '1-a crap ton' of classes depending on how you want to code it.
     
  5. Offline

    DailyLove

    Is it possible if any of you can make the plugin for me? Please and thank you. RingOfStorms bobacadodl

    -Daily
     
  6. Offline

    jacklin213

  7. Offline

    DailyLove


    I've used ChatAlerts what I'm asking for is basically like that but I want the color customizable or to &a and not have to type the @. Say they type a name it adds the @ automatically and sounds the person. jacklin213
     
  8. Offline

    negative_codezZ

    We will communicate over Skype. My Skype user is "negative_coderzZ".
     
  9. Offline

    jacklin213

    oh i c, ill see if anyone else wants to do this , i have exams atm and if you wanted to know yes i do have the source to the plugin but its not pretty http://github.com/jacklin213/chatalert
     
  10. Offline

    negative_codezZ

    Wait what? I just coded
    Code:java
    1. package me.negative_codezZ.tagger;
    2.  
    3. import org.bukkit.Bukkit;
    4. import org.bukkit.ChatColor;
    5. import org.bukkit.Instrument;
    6. import org.bukkit.Note;
    7. import org.bukkit.Note.Tone;
    8. import org.bukkit.entity.Player;
    9. import org.bukkit.event.EventHandler;
    10. import org.bukkit.event.Listener;
    11. import org.bukkit.event.player.AsyncPlayerChatEvent;
    12. import org.bukkit.plugin.java.JavaPlugin;
    13.  
    14. public class main extends JavaPlugin implements Listener{
    15.  
    16. @EventHandler
    17. public void onChat(AsyncPlayerChatEvent e){
    18. for(Player on:Bukkit.getServer().getOnlinePlayers()){
    19. Player p = e.getPlayer();
    20. p.chat(ChatColor.translateAlternateColorCodes('&', getConfig().getString("Replace name to").replace("%name", p.getName())));
    21. on.playNote(on.getLocation(), Instrument.PIANO, Note.natural(1, Tone.A));
    22. }
    23. }
    24.  
    25. public void onEnable() {
    26. getConfig().options().copyDefaults(true);
    27. saveDefaultConfig();
    28. Bukkit.getServer().getPluginManager().registerEvents(this, this);
    29. }
    30.  
    31. }
    32.  

    and then it just spammed chat with me saying &a@negative_codezZ&r. Why? Any dev? In addition, it took out the rest of the text. The original message was "Hello negative_codezZ".
     
  11. Offline

    AndyMcB1

    bobacadodl likes this.
  12. Offline

    negative_codezZ

    Problem with that? I find it working all the time and it is the main class.

    <Removed double post Bumping is allowed only every 24 hours - Necrodoom>
     
    timtower likes this.
  13. Offline

    AndyMcB1

  14. Offline

    DailyLove

  15. Offline

    timtower Administrator Administrator Moderator

    You are looping through all players and saying at every player your own name, try to modify the chat message instead of sending more chat events that are creating an infinite loop
     
    klosjaarrr likes this.
  16. Offline

    negative_codezZ

    I already fixed that problem but thanks. The issue now is that if in chat I type "Hello negative_codezZ" it will only send the message "&a@negative_codezZ&r" and not "Hello &a@negative_codezZ&r". How do I fix that timtower?
     
  17. Offline

    timtower Administrator Administrator Moderator

    Try replacing the the name instead of making the name the only thing in the thing ( more help will go by PM )
     
  18. Offline

    jacklin213

    And lower case 'M' :p
    Code:java
    1. String message = event.getMessage();
    2. Player p = event.getPlayer();
    3. message.replace("%name", ChatColor.translateAlternateColorCodes('&', getConfig().getString("Replace name to")));
    4. p.chat(message);
    5.  
     
  19. Offline

    negative_codezZ

    I finished this plugin long ago! :p But thanks!
     
  20. Offline

    jacklin213

    ah
     

Share This Page