Name recognition (similar to Facebook)

Discussion in 'Archived: Plugin Requests' started by Hrd2GtStunned, May 18, 2012.

  1. Offline

    Hrd2GtStunned

    Hey all!

    Lately on my server I've been thinking of a cool plugin.

    It would be a very small, light weight plugin. All it does is whenever someone makes a message in the chat and the message contains a nickname of a player online, it will make it a certain color, definable in a config.

    And maybe add a more advanced part, but I'm not sure if this is possible.
    The name is recognised and made yellowd. Then you can click on the name when in typing modus (just like URLs) and it will bring up info based on the /whois command. So here's a quick example:

    [Owner] Hrd: Hey Aux13, this is an example.


    And then you would be able to click "Aux13" and you will get the same as what you would get if you would type '/whois aux13'.

    I hope you can understand what I mean. The most important is the coloring of the text. I can imagine the clicking of it with the information is (possibly too) hard to do.

    I will be forever thankful towards the person that is kind enough to make this!

    Thanks!
     
  2. Offline

    Father Of Time

    Good afternoon Hrd2GtStunned,

    Well I was painfully bored at work and really liked your concept (often I've had a hard time spotting my name in chat), so I decided to go ahead and make you a function to do what you have asked.

    Code:
        public String HighlightPlayerNames( String message )
        {
            String[] MessageWords = message.split(" ");
            StringBuilder sb = new StringBuilder();
            for( int i = 0; i < MessageWords.Length; i++ )
            {
                String word = MessageWords[i];
                OfflinePlayer offlineplayer = Bukkit.getOfflinePlayer( word );
                if( player != null && offlineplayer.hasPlayedBefore() )
                    sb.append( ChatColor.YELLOW );
     
                sb.append( word );
                sb.append( " " );
            }
            String NewMessage = sb.toString();
            NewMessage = NewMessage.strip();
            return NewMessage;
        }
    
    I wrote this freehand in notepad, so it's probable that it will need tweaking; but what this will do is take in a sentence, break it apart into a collection of each word in the sentence, then take each word and look it up to see if it's a player, and if that player has ever logged onto this server it will highlight that word yellow and put it back into the original string, if not it will simply just add it back to the string. Then once all of the highlighting has occurred it will return the complete string.

    To use this you would simple create a chat event listener, use the "getChatMessage()" to get the message being broadcast, then send that string to this function to get back the "highlighted" version of the string, then use the "setChatMessage" function to replace the none highlighted message with the highlighted.

    I just threw this together in literally 5 minutes, so it's not everything you asked for; but it's a decent starting point for other developers who are willing to do plugin request.

    I hope somebody completes this for you, I like the idea. :D

    Good luck with your project!

    Oh, p.s. Your name, your avatar... are you an old Ultima Online player like myself?
     
    Hrd2GtStunned and Ne0nx3r0 like this.
  3. Offline

    C0nsole

    And about the clicking the name :p
     
  4. Offline

    Father Of Time

    Sadly chat hyperlinks are something new to Minecraft since 1.2.5 and I have no awareness of how it works; I'm not even sure if Bukkit has an API for it yet.

    If you can find any documentation on it here:
    http://jd.bukkit.org/doxygen/dd/d78/interfaceorg_1_1bukkit_1_1OfflinePlayer.html

    be my guest, and I will do what I can to turn it into something useful, but at the moment I don't have enough time to go fishing. :(
     
    Hrd2GtStunned likes this.
  5. Offline

    blizzardly

    I'll look into it, I've been wondering about this myself.
     
    Hrd2GtStunned and Father Of Time like this.
  6. Offline

    Hrd2GtStunned

    Personally, I know nothing about coding. That's why I came here :p. So the code you wrote says nothing to me, but I can surely imagine this comes in handy for people experienced with coding. So thanks for that! Thanks for the quick reply as well :)
    Too bad about the clicking part, maybe someone else knows more about this section?

    And no, sorry. I'm not an Ultima Online player. I think I have played it, but I never owned the game and the name and avatar have nothing to do with Ultima. They both have their own stories :p

    Thanks again for the reply and the effort!

    That would be amazing! Would love to hear from you if there's any progress in it.
    Thanks for the reply as well.


    Both thank you for responding, didn't expect it.

    Sincerely,
    Joshua
     
  7. Offline

    keelar

    I could do the whole name recognition thing, but I'm not sure if it's even possible to clicks links in chat yet, or if it ever will be. I'm couple months behind on the bukkit API so I could be wrong. I think I'll make it just because I'm bored out of my mind atm :p. I'll let you know how it goes.

    EDIT: Finished a beta version. It can be found here: http://dev.bukkit.org/server-mods/highlights/
     
  8. Offline

    Hrd2GtStunned

    Thanks! Will implement it for Beta testing and will let you know how it works out!
     
  9. Offline

    Dreeass

    If the clicking part ever works then please let me know!
     
  10. Offline

    korikisulda

    As far as I'm aware, the link clicking is handled entirely client side...
     
  11. Offline

    Hrd2GtStunned

    Okay so we have tested it a bit, and it works great, apart from the following points.

    - If a symbol is added (e.g. "Hrd2GtStunned." « the period) it is not highlighted
    - It doesn't work for nicknames, which would be nice. Or maybe it can be toggled in the config?

    That's all. Apart from that it works great! Thanks!
     
  12. Offline

    keelar


    I can fix the first problem, and I'll add the second. I'll make another post when it's up.

    Should be fixed. I also added nickname support. I uploaded it but it's still waiting for approval. I'm sure it'll be ready next time you're online.

    NOTE: Nickname highlights do not work with EssentialsChat installed.

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

    Hrd2GtStunned

    Hmm I use EssentialsChat and I have been for quite a while. Don't wanna change it. Isn't there any way to make it available for that too? Would be awesome.

    Anyway, thanks so much for what you have done so far. If we come up with any ideas or whatever, I will let you know! This could become quite a popular plugin.

    Someone just came with a really good idea!

    As you might have experienced, most people don't type full names in Minecraft, but just a short form of it.
    Like me, for instance, they mostly call me "Hrd"

    So the idea is that you add a command, which allows you to set a nickname for yourself, for example: "/hl Hrd", that will also make "Hrd" highlighted when it is mentioned in the chat.

    And then there is also something that has a lower priority, but could make the plugin really popular. It's a client-side mod, that gives you a notification when you have been mentioned. So it bleeps or whatever when your name appears in chat. It could also give you a pop-up like in facebook, but that's not necessary.

    So yeah, that will require some brainstorming, but maybe it's fun? Lol.

    Thanks for all the effort you put in to it anyway!

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

    Hrd2GtStunned

    No further activity?
     
  15. Offline

    makskay

    Coincidentally I'm working on something almost exactly like this. I'm actually attempting to handle the sound notifications server-side, by playing an effect that includes sound at the mentioned player's location. (I'd use a note block sound, but there needs to be a note block near the player for that to work.)

    I'll try and remember to report progress back here if I end up with anything workable.
     
  16. Offline

    Deathmarine

  17. Offline

    Hiddenarrow1000

    Could someone make it so that it makes maybe a ding whenever the word is said...And how about making this a client side mod!!
     
  18. Offline

    HyrulesLegend

    Cool Idea. But I don't think people want their ip's given out. :confused:
     
  19. Offline

    WarmakerT

    Spout would be needed to play a custom sound.
     
  20. Offline

    Omnitv

    No accentually the plugin NoiseNotifications has successfully done so already.
    So when your name is said on the chat it will make a sound like ding!
     
  21. Offline

    WarmakerT

    It uses noteblocks.
     
  22. Offline

    Omnitv

    really???
     
  23. Offline

    WarmakerT

    Yep, read their bukkit dev page. It says it.
     
  24. Offline

    Dark_Balor

    You can play a sound in a World in the wanted location without the need of Spout.
    Of course only a Minecraft sound that already exists.
     
  25. Offline

    WarmakerT

    That's exactly why I said "custom sound" :p
     

Share This Page