Getting name and creating map onEnable() problem.

Discussion in 'Plugin Development' started by PlayFriik, Dec 31, 2014.

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

    PlayFriik

    Hello, I am trying to create a map in onEnable() method (also, getting the world name from config), but it gives me IndexOutOfBoundsException error. I know the timing is wrong, but I need advice how to fix the timing..? I mean how I would make the map after config generation..
    Code:
        public void onEnable() {
            getLobbyName.addAll(mapsSection);
            String lobbyNameToString = getLobbyName.get(0);
    
            WorldCreator wc = new WorldCreator(lobbyNameToString);
            Bukkit.createWorld(wc);
            Bukkit.getWorld(lobbyNameToString).setSpawnLocation(0, 100, 0);
            Bukkit.getWorld(lobbyNameToString).setGameRuleValue("doMobSpawning", "false");
            Bukkit.getWorld(lobbyNameToString).setGameRuleValue("doFireTick", "false");
        }
     
  2. Offline

    Rocoty

    And the error...?
     
  3. Offline

    PlayFriik

    I said it already..? IndexOutOfBoundsException error.

    Code:
            getLobbyName.addAll(mapsSection);
            String lobbyNameToString = getLobbyName.get(0);
    
            WorldCreator wc = new WorldCreator(lobbyNameToString);
    These lines are causing it.. :/
    @Rocoty
     
  4. Offline

    Rocoty

    @PlayFriik Okay...I have no clue what your error says other than IndexOutOfBoundsException. In most cases it's much more desirable to copy and paste the whole error message and stack trace rather than just telling us what type of error it is.

    Assuming the error happens on line 3 in the most recent snippet, it would seem you are trying to access the first element in a List, but that List is empty.
     
  5. Offline

    PlayFriik

    Yeah, I know, I think the timing is wrong, because if plugin starts then ofcourse everything is empty. ;)
    I am just wondering how I would get the timing right? Should I make different methods, or BukkitRunnable with 1 second after enable?
    @Rocoty
     
  6. Offline

    Rocoty

    @PlayFriik I don't know. There would be no way for me to know at the moment. What is getLobbyName? Where is it declared? Where is it initialised? Where is it populated? You might as well post your whole code.
     
Thread Status:
Not open for further replies.

Share This Page