String builder

Discussion in 'Plugin Development' started by keizermark, Mar 1, 2014.

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

    keizermark

    I was trying to get a list from the config but i realy dont know how to split them up and then check if the player is online or not? Anyone that can help me out?

    Code:
    if (this.Rpgf.getConfig().getConfigurationSection(player.getName()) == null) {
                      player.sendMessage(ChatColor.AQUA + "Je hebt niemand in je vrienden lijst!");
                      return true;
                    }
                    StringBuilder sb = new StringBuilder();
                    for(String Friends : this.Rpgf.getConfig().getConfigurationSection(player.getName() + ".Friends").getKeys(false)){
                        sb.append(Friends + ", ");   
                    }
                   
                    sender.sendMessage(ChatColor.AQUA + "------------=Friend=------------");
                    sender.sendMessage(ChatColor.RED + "Rood " + ChatColor.AQUA + "betekend offline," +  ChatColor.GREEN + "groen" + ChatColor.AQUA +  "betekend online");
                   
                   
                    if(!(sb.toString() == null)) {
                        sender.sendMessage(ChatColor.GREEN + sb.toString() + " is online!");
                       
                    }
     
  2. Offline

    Wruczek

    To check if player is online use
    Code:java
    1. if(Bukkit.getPlayer(NICK) == null){
    2. //Player is offline!
    3. }else{
    4. //Player is online!
    5. }
     
  3. Offline

    keizermark

    Wruczek But how would i get the "NICK"?
     
  4. Offline

    Atakyn

  5. Offline

    keizermark

    But how would i get it out of the stringbuilder?
     
  6. Offline

    ImDeJay

    psuedoe code, wrote in quick reply

    Code:
    List<String> players_from_config = new ArrayList<String>();
     
    players_from_config = getConfig().getStringList("Players");
     
    for(String blah : players_from_config){
    if(this.getServer().getPlayer(blah) != null){
    //do something with the player here
    }
    }
     
  7. Offline

    keizermark

    Thanks guys i found the problem
     
Thread Status:
Not open for further replies.

Share This Page