Solved Why is it returning "[]"

Discussion in 'Plugin Development' started by Funergy, May 2, 2014.

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

    Funergy

    I'm trying to get all the arenas but its returning []
    this is the code
    Code:
    package com.Funergy.cubox;
     
    import java.util.List;
     
    import org.bukkit.Location;
    import org.bukkit.entity.Player;
     
    public class Gamemanager {
        private main plugin;
        public Gamemanager(main plugin) {
            this.plugin = plugin;
        }
       
        public void CreateArena(String name,Player p){
            if(!plugin.getConfig().contains("Arenas."+name)){
                p.sendMessage("§bCubox§f» §cSuccesfully created §2"+name);
            plugin.getConfig().createSection("Arenas."+name);
            plugin.saveConfig();
            }else{
                p.sendMessage("There is already a arena called "+name);
               
            }
           
        }
        public void SetLocation(String arenaname,Integer i,Location loc,Player p){
            if(plugin.getConfig().contains("Arenas."+arenaname)){
                p.sendMessage("§bCubox§f» §cYou have succesfully set the§2"+ i +"§cof arena §2"+arenaname);
            plugin.getConfig().set("Arenas."+arenaname+".LocationX"+i,loc.getX());
            plugin.getConfig().set("Arenas."+arenaname+".LocationY"+i,loc.getY());
            plugin.getConfig().set("Arenas."+arenaname+".LocationZ"+i,loc.getZ());
            plugin.saveConfig();
            }else{
            p.sendMessage("§cThere isn't an arena called that!");   
            }
           
           
        }
        public void GetLocation(String arenaname,Integer i, Location loc, Player p){
            plugin.getConfig().get("Arenas."+arenaname+".Location"+1);
        }
        public void DeleteArena(String name,Player p){
            if(plugin.getConfig().contains("Arenas."+name)){
                p.sendMessage("§bCubox§f» §cSuccesfully deleted §2"+name);
            plugin.getConfig().set("Arenas."+name+".LocationX1",null);
            plugin.getConfig().set("Arenas."+name+".LocationY1",null);
            plugin.getConfig().set("Arenas."+name+".LocationZ1",null);
           
            plugin.getConfig().set("Arenas."+name+".LocationX1",null);
            plugin.getConfig().set("Arenas."+name+".LocationY1",null);
            plugin.getConfig().set("Arenas."+name+".LocationZ1",null);
            plugin.getConfig().getConfigurationSection("Arenas.").set(name, null);
            plugin.saveConfig();
            }else{
                p.sendMessage("There is no arena called "+name);
               
            }
        }
        public String list(){
            List<String> list = plugin.getConfig().getStringList("Arenas");
            String  s = list.toString();
        return s;
        }
     
    }
    
     
  2. Offline

    1Achmed1

    Why are you using § in code? You should use
    ChatColor.RED or .DARK_GREEN

    And your grammar in messages is horribly inconsistent, especially around a vs. an
     
  3. Offline

    AoH_Ruthless

    Funergy
    That's because the string list is null..
     
  4. Offline

    XDdrummer

    The arena is null.. You have to define the arenas in the config.. The Arenas don't create themselves, lol.
    Well, they could, if you add it in the code, but you didn't, from what I'm seeing.

    Also, you really shouldn't be using §. Let me show you an example:
    Instead of
    Code:java
    1. p.sendMessage("§bCubox§f» §cSuccesfully created §2"+name);
    you should use
    Code:java
    1. p.sendMessage(ChatColor.LIGHT_RED + "Cubox" + ChatColor.WHITE + "»" + ChatColor.LIGHT_RED + "Succesfully created "+ ChatColor.GREEN + name);
    although this seems less efficient.
     
  5. Offline

    Funergy

    1Achmed1 XDdrummer Why do you guys answer OFF TOPIC. The text lines are just for now I will change them later! Your not my mom...

    You have eyes?
    Code:
     plugin.getConfig().createSection("Arenas."+name);
    look, my config... so it actually works....
    Code:
    Arenas:
      Royal:
        LocationX1: -210.09481440056817
        LocationY1: 65.15364580593328
        LocationZ1: -99.14086513578503
        LocationX2: -208.33660131422073
        LocationY2: 63.30106867953327
        LocationZ2: -92.42805667538651
    
    #Fixed
    The answer was. and none of you guys helped me. so no thanks
    Code:
    Set<String> list = plugin.getConfig().getConfigurationSection("Arenas").getKeys(false);
            String s = list.toString();
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  6. Offline

    1Achmed1

    arse hole.
     
  7. Offline

    kennethbgoodin

    You're responding pretty rudely to people offering you help. It's no one's fault but your own if you don't understand what you're doing.

    You should store the List in a String array, not a single String.

    Your method names should follow camelCase, by the way. getLocation(), rather than GetLocation(). It's standard Java convention, and allows easier debugging when you're aware that you're working with a method, and not a class.
     
Thread Status:
Not open for further replies.

Share This Page