Factions Prefix Code!

Discussion in 'Plugin Development' started by xXkguyXx, Jun 29, 2015.

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

    xXkguyXx

    Is It Possible To Get A Players Prefix, Then Get It in My Code. So I Basicly Am Coding a Chat Plugin, I want It To Get a Players Faction, How I am Having Trouble. Thanks!
     
  2. Either using the Factions API (if there is any) or splitting and editing the String until you have the players faction prefix
     
  3. Offline

    xXkguyXx

    I Have factions And MassiveCore In My Build Path For The Plugin. Is There AnyWay Like That?
     
  4. Offline

    HenkDeKipGaming

    do you want to make it by yourself?
    because then you could do something like this:
    1. create a config file
    2. save all players in the config file with the faction after it
    example of the config:
    Code:
    players:
      Player1: Faction1
      Player2: Faction2
    
    (3. if you want to make a config add command to add people to your config)
    4. get in what faction the player is
    5. make a player chat event that checks the prefix.
    example of 4 and 5:
    Code:
    public String checkPrefix(Player p) { //checkprefix method
            String prefix;
            if(getConfig().getString("players." + p.getName()).contains("faction1")) {
                prefix = ChatColor.RED + "[faction1]";
            } 
    }
            return prefix;
        }
    //then the player chat event:
    @EventHandler
        public void onChat(AsyncPlayerChatEvent e) { //on chat use checkPrefix method to get player's prefix
            Player p = e.getPlayer();
            String name = p.getDisplayName();
            e.setFormat(checkPrefix(p) + ChatColor.WHITE + name + ": " + e.getMessage());
        }
    
    this might be usefull for you :)
     
  5. Offline

    xXkguyXx

    No no, I Just Want It To Get There Prefix From The Factions Plugin If They Have one
     
  6. Offline

    Googlelover1234

  7. Offline

    xXkguyXx

  8. Offline

    HenkDeKipGaming

    If your problem is solved, please mark this thread as solved.
     
  9. Offline

    xXkguyXx

    IT Isnt.
     
Thread Status:
Not open for further replies.

Share This Page