Solved get player array from config

Discussion in 'Plugin Development' started by jkctech, Apr 17, 2014.

Thread Status:
Not open for further replies.
  1. Hello,
    how do i get an array like player list from the config?
    in this fromat: "player, player2" (or if anymoby has a better way please tell XD)
    if that arrays contains the player who joined do something.

    can anybody help me?
     
  2. Offline

    TheMcScavenger

    You can store string lists, and then cast them to players, or you can store string lists, and check for the player's name. I think the easiest way would be to simply store a string list of player names.

    Code:
    @EventHandler(priority = EventPriority.MONITOR)
    public void onPlayerJoin(PlayerJoinEvent event){
        List<String> players = getConfig().getStringList("players");
        if(players.contains(event.getPlayer().getName()){
            // Do Things
        }
    }
     
  3. thanks!, that was what i needed
     
  4. Offline

    TheMcScavenger

    jkctech Please set the thread to solved ;)
     
Thread Status:
Not open for further replies.

Share This Page