Filled Prefix in Front of PlayerName in Chat, showing XP Level

Discussion in 'Archived: Plugin Requests' started by hassansyyid, Apr 22, 2014.

  1. Offline

    hassansyyid

    Plugin category: Chat Related

    Suggested name: LevelChat

    What I want: I'd like this plugin to simply add a prefix in front of the player name in Chat, showing XP Level.

    For example, if someone is level 8, in chat it'd say:

    [Lvl 8] exampledude: Yay I'm level 8!

    Ideas for commands: None needed.

    Ideas for permissions: None needed.

    When I'd like it by: As soon as possible.

    Thanks in Advance!
     
  2. Offline

    DotDash

    So just in chat? No where else?
     
  3. Offline

    Onlineids

    [quote uid=90931043 name="hassansyyid" post=2434723]Plugin category: <font color="#555555">Chat Related</font>

    Suggested name: LevelChat

    What I want: I'd like this plugin to simply add a prefix in front of the player name in Chat, showing XP Level.

    For example, if someone is level 8, in chat it'd say:

    [Lvl 8] exampledude: Yay I'm level 8!

    Ideas for commands: None needed.

    Ideas for permissions: None needed.

    When I'd like it by: As soon as possible.

    Thanks in Advance![/quote]

    I got this one sec

    [quote uid=90931043 name="hassansyyid" post=2434723]Plugin category: <font color="#555555">Chat Related</font>

    Suggested name: LevelChat

    What I want: I'd like this plugin to simply add a prefix in front of the player name in Chat, showing XP Level.

    For example, if someone is level 8, in chat it'd say:

    [Lvl 8] exampledude: Yay I'm level 8!

    Ideas for commands: None needed.

    Ideas for permissions: None needed.

    When I'd like it by: As soon as possible.

    Thanks in Advance![/quote]

    <Edit by Moderator: Redacted mediafire url>

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

    Deleted user

    Onlineids hassansyyid

    That's very complicated. Instead, use playerLevelChangeEvent and PlayerJoinEvent. Much easier, and much less expensive
     
  5. Offline

    Onlineids

    I didnt use AsyncPlayerChatEvent, use the plugin before you think you know it....
     
  6. Offline

    hassansyyid

    [quote uid=90896908 name="DotDash" post=2434734]So just in chat? No where else?[/quote]

    Yup

    [quote uid=90875889 name="Onlineids" post=2434807]<Edit by Moderator: Redacted mediafire url>

    Hi thanks for the fast response!
    This didn't work correctly: When I used /gamemode it did show the level:
    Gamemode set to survival for [Level 190] HassanS6000
    But in chat nothing happened:
    HassanS6000: This plugin didn't work fully :(
    Could you try fixing it please? Thanks so much already!

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

    Deleted user

    Onlineids
    Even better. You used PlayerMoveEvent. That gets called exponentially for every player online.

    Just use PlayerLevelChangeEvent.

    btw, what would not using AsyncPlayerChatEvent have done for you? You make it sound like using it was bad
     
  8. Offline

    Onlineids

    exponentially for every player online..... is this a joke o.0
     
  9. Offline

    DotDash

  10. Offline

    hassansyyid

    Thanks!

    Thanks for the fast response! Everything is great.. however when a player chats now, the message isn't shown.

    For example, a player pushes "t" and writes something, the output is:

    [190] HassanS6000

    As shown above, none of the message text is shown. Could you try figuring out what's wrong, and how you could possibly fix it?

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

    DotDash

    What other plugins are you using?
     
  12. Offline

    hassansyyid

    Essentials, Vault, MagicSpells, and Quests
     
  13. Offline

    DotDash

    Are there any other prefixes?

    The message should still show
     
  14. Offline

    hassansyyid

    No the message doesn't show. There are no other prefixes. Only the xp level in purple.
     
  15. Offline

    e1kfws7

    DotDash

    You forgot to get the player's message.
    e.getMessage();

    Code:java
    1. @EventHandler
    2. public void onChat(AsyncPlayerChatEvent e) {
    3. Player p = e.getPlayer();
    4. int plvl = p.getLevel();
    5. e.setFormat(ChatColor.DARK_PURPLE + "[" + plvl + "] " + ChatColor.RESET + p.getDisplayName() + ": " + e.getMessage());
    6. }
    7. }


    hassansyyid

    Well, so you don't have to wait here you go.

    https://www.dropbox.com/s/uome8fe1ifr6zu9/LevelChat.jar

    Full code goes to DotDash I just changed the color of the prefix to Green and I set the messages.

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

    hassansyyid

    Thanks! Works perfectly now! :D
     
    e1kfws7 likes this.
  17. Offline

    timtower Administrator Administrator Moderator

    DotDash e1kfws7 setFormat has 2 format values that the server will modify after the monitor eventpriority. No need to hardcode the playername or the message in it. %s twice, first one will be the displayname, second one the message.
     
  18. Offline

    DotDash

    timtower Oh well that'll make it a lot simpler :p
     
    timtower likes this.

Share This Page