Making player.setDisplayName(); compatible with Essentials

Discussion in 'Plugin Development' started by Nukreeper64, Jan 19, 2015.

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

    Nukreeper64

    I am making a small plugin that places players onto two teams. I used player.setDisplayName(team_prefix + player.getDisplayName()) to add a prefix to the player's name in chat. However, when I use it with essentials, it doesn't display nicknames or groupmanager prefixes. is there a better way to add team based prefixes and still keep nicknames and groupmanager prefixes?
     
  2. Offline

    Ozcr

    Try the Essentials API.
     
    Nukreeper64 likes this.
  3. Offline

    Avery246813579

    Turn off essentials chat in the config.
     
  4. Offline

    Nukreeper64

    @Ozcr, can you show me some resources that would help with using essentials API? So far I have found nothing about how to do what I am trying to do.
     
  5. https://github.com/essentials/Essentials/tree/master/Essentials/src/net/ess3/api
    You can add essentials as a referenced jar in your Java project then add it as a plugin dependency in your plugin.yml. Then check if essentials is enabled by doing this in your onEnable:
    Code:
    if (getServer().getPluginManager().isPluginEnabled("Essentials") {
    // Register your commands and events here.
    } else {
    getLogger().info("Essentials is disabled or not in you plugins folder, disabling plugin.");
    // Disable plugin here.
    }
    I haven't used Essentials API before, so I'm not sure exactly how it works, good luck though. :)
     
  6. Offline

    SuchSwegMuchWow

    @Nukreeper64

    You can disable the nick names in Essentials. It is one of the first config questions
     
  7. Offline

    Nukreeper64

    @CodePlaysMinecraft, so I figured out a workaround, sort of, I am going to use scoreboard teams because essentials chat can have prefixes for those. However, I ran into a problem. How am I supposed to do:
    Code:
    ScoreboardManager manager = Bukkit.getScoreboardManager();
            Scoreboard board = manager.getNewScoreboard();
            Team england = board.registerNewTeam("england");
            Team france = board.registerNewTeam("france");
    within the onEnable method and then later call england.addPlayer(); in my oncommand method when apparently the type "Team" can not be public?

    @SuchSwegMuchWow, as I said in my original post, I want to have both prefixes from my plugin and essentials prefixes.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 13, 2016
  8. @Nukreeper64 Make the teams a static variable:
    Code:
    // Setting the scoreboard and teams.
    Scoreboard sBoard = Bukkit.getScoreboardManager().getNewScoreboard();
    public static Team england = sBoard.registerNewTeam("England");
    public static Team france = sBoard.registerNewTeam("France");
    
    //Make sure that the variables are OUTSIDE of any methods.
    public void Scoreboard() {
    // Your scoreboard stuff here.
    }
     
    Last edited: Jan 21, 2015
    Nukreeper64 likes this.
  9. Offline

    Konato_K

    @CodePlaysMinecraft Yess!! Let's go against Object Oriented Programming! :D Do you know what encapsulation is?
     
  10. @Konato_K Nope. How is the Team being a static variable bad exactly? There aren't any errors that show up, so I'm sure it's fine.
     
Thread Status:
Not open for further replies.

Share This Page