Chat color perms?

Discussion in 'Plugin Development' started by ixamxtwig, May 26, 2012.

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

    ixamxtwig

    How is it that you would do a players name in chat based on permissions............ this is what I tryed for the color red.
    Code:
    if (player.hasPermission("permchatcolor.red")) {
                player.sendMessage(ChatColor.RED+"");
            }
    ... So how would I make the players name a different color based soley on perms. I don't need the message to be a different color just the display name.
     
  2. Offline

    Fuzzlr

    If you don't use suffixes, turn the suffix into a color code and insert the suffix before the player in the respective chat configuration plugin
     
  3. Offline

    ixamxtwig

    One, suffixes are behind the player's name (are you thinking prefix) and two, it is supposed to be an overlayer of other chat plugins that just changes the color of the players display name in chat...........
     
  4. Offline

    Fuzzlr

    Permissions usually only lets you define two values, prefix and suffix.
    I suggested that you put the suffix value directly in front of the display name in your chat configuration file. That way, you can still have a prefix.
     
  5. Offline

    ixamxtwig

    No this is a different plugin......... :facepalm: NO I told people that its a plugin. I bet you have apsolutely no idea what that bit of code even means, but I messed up so I was wondering how to make that permission give player's name change.
     
  6. Offline

    Njol

    The following code should work:
    Code:java
    1. public void onJoin(PlayerJoinEvent e) {
    2. Player p = e.getPlayer();
    3. for (ChatColor c : ChatColor.values()) {
    4. if (p.hasPermission("permchatcolor."+c.name().toLowerCase())) {
    5. p.setDisplayName(c+p.getDisplayName());
    6. }
    7. }
    8. }

    This code uses the ChatColor enum, thus you can e.g. give a player the permissions 'permchatcolor.red' and 'permchatcolor.italic' to make his name red and italic.
     
  7. it may fail because of the priorities, permissions are also given inside the login event, so your plugin may get called before the permissions are giving on the monitor level (but still may this get called before, even this is to on the monitor level),iits better to use the schedular to wait 1 tick before checking the permissions
     
  8. Offline

    Njol

    There are like 3 different events for players joining (prelogin, login, join) which are called consecutively, and permissions plugins likely set permissions on lowest priority of the first event where the Player object is available. Thus this should not be problematic except if badly programmed permissions plugins are used.
     
  9. Offline

    ixamxtwig

    Its not working.......... damn.
     
  10. Offline

    Njol

    Can you add some debug messages to the event, e.g. to see whether the event is called at all or if the display name can't be set in on player join.
     
Thread Status:
Not open for further replies.

Share This Page