java.lang.IllegalArgumentException: Cannot create section at empty path

Discussion in 'Plugin Development' started by CraftyCodez, Mar 13, 2024.

  1. Offline

    CraftyCodez

    Hi all! I've recently been following a tutorial and I've gotten stuck on this one bit with config. I've tried certain debugging and running it in different ways but it still seems to come up with this error in the console every time. Apologies as this is my first time posting so if there is anything that I might be forgetting, please let me know! Thanks for your help.

    This is my Main class:


    Code:
    
    public final class Main extends JavaPlugin {
    
        private ArenaManager arenaManager;
        @Override
        public void onEnable() {
    
            ConfigManager.setupConfig(this);
            arenaManager = new ArenaManager(this);
    
            Bukkit.getPluginManager().registerEvents(new Connectlistener(this),this);
            Bukkit.getPluginManager().registerEvents(new gamelistener(this),this);
    
            Pistol pistol = new Pistol(this);
            PbCraft pb = new PbCraft(this);
            SbCraft sb = new SbCraft(this);
            UpgradeKey uk = new UpgradeKey(this);
            UpgradeKeyGUI ukGUI = new UpgradeKeyGUI(this);
            Shank shank = new Shank(this);
    
    
    
            getCommand("heat").setExecutor(new Commands(this));
    
            Shotgun shotgun = new Shotgun(this);
            Pipe_Bomb Pipe_bomb = new Pipe_Bomb(this);
            Smoke_bomb smokeBomb = new Smoke_bomb(this);
    
            getCommand("hs").setExecutor(new WeaponsGUI(this));
    
    
        }
        public ArenaManager getArenaManager(){
            return arenaManager;
        }
    
        @Override
        public void onDisable() {
            // Plugin shutdown logic
        }
    
    
    
    }
    
    This is arena manager:


    Code:
    
    public class ArenaManager {
    
        private List<Arena> arenas = new ArrayList<>();
    
        public ArenaManager (Main main) {
            FileConfiguration config = main.getConfig();
    
            for (String str : config.getConfigurationSection("arenas.").getKeys(false)) {
                String world = main.getConfig().getString("arenas." + str + ".world");
                arenas.add(new Arena(main, Integer.parseInt(str), new Location(
                        Bukkit.getWorld(main.getConfig().getString("arenas." + str + ".world")),
                        config.getDouble("arenas." + str + ".x"),
                        config.getDouble("arenas." + str + ".y"),
                        config.getDouble("arenas." + str + ".z"),
                        (float) config.getDouble("arenas." + str + ".yaw"),
                        (float) config.getDouble("arenas." + str + ".pitch"))));
    
            }
    
        }
    
    
        public List<Arena> getArenas(){
            return arenas;
        }
        public Arena getArena(Player player){
            for(Arena arena : arenas){
                if(arena.getPlayers().contains(player.getUniqueId())){
                    return arena;
                }
            }
            return null;
        }
        public Arena getArena(int id){
            for(Arena arena : arenas){
                if(arena.getId() == id){
                    return arena;
                }
            }
            return null;
        }
    }
    
    This is the error i'm getting:

    Code:
    13.03 22:18:01 [Server] Server thread/[ERROR] Error occurred while enabling HeatedSurvival v1.0.0 (Is it up to date?)
    13.03 22:18:01 [Server] [INFO] java.lang.IllegalArgumentException: Cannot create section at empty path
    13.03 22:18:01 [Server] [INFO] at com.google.common.base.Preconditions.checkArgument(Preconditions.java:143) ~[guava-32.1.2-jre.jar:?]
    13.03 22:18:01 [Server] [INFO] at org.bukkit.configuration.MemorySection.createSection(MemorySection.java:282) ~[spigot-api-1.20.2-R0.1-SNAPSHOT.jar:?]
    13.03 22:18:01 [Server] [INFO] at org.bukkit.configuration.MemorySection.createSection(MemorySection.java:309) ~[spigot-api-1.20.2-R0.1-SNAPSHOT.jar:?]
    13.03 22:18:01 [Server] [INFO] at org.bukkit.configuration.MemorySection.getConfigurationSection(MemorySection.java:841) ~[spigot-api-1.20.2-R0.1-SNAPSHOT.jar:?]
    13.03 22:18:01 [Server] [INFO] at com.mcbangsy.lousurvivalv2.Mechanics.ArenaManager.<init>(ArenaManager.java:21) ~[?:?]
    13.03 22:18:01 [Server] [INFO] at com.mcbangsy.lousurvivalv2.Main.onEnable(Main.java:20) ~[?:?]
    13.03 22:18:01 [Server] [INFO] at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:266) ~[spigot-api-1.20.2-R0.1-SNAPSHOT.jar:?]
    13.03 22:18:01 [Server] [INFO] at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:342) ~[spigot-api-1.20.2-R0.1-SNAPSHOT.jar:?]
    13.03 22:18:01 [Server] [INFO] at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:480) ~[spigot-api-1.20.2-R0.1-SNAPSHOT.jar:?]
    13.03 22:18:01 [Server] [INFO] at org.bukkit.craftbukkit.v1_20_R2.CraftServer.enablePlugin(CraftServer.java:548) ~[spigot-1.20.2-R0.1-SNAPSHOT.jar:3950-Spigot-2888990-d485cde]
    13.03 22:18:01 [Server] [INFO] at org.bukkit.craftbukkit.v1_20_R2.CraftServer.enablePlugins(CraftServer.java:462) ~[spigot-1.20.2-R0.1-SNAPSHOT.jar:3950-Spigot-2888990-d485cde]
    13.03 22:18:01 [Server] [INFO] at org.bukkit.craftbukkit.v1_20_R2.CraftServer.reload(CraftServer.java:970) ~[spigot-1.20.2-R0.1-SNAPSHOT.jar:3950-Spigot-2888990-d485cde]
    13.03 22:18:01 [Server] [INFO] at org.bukkit.Bukkit.reload(Bukkit.java:834) ~[spigot-api-1.20.2-R0.1-SNAPSHOT.jar:?]
    13.03 22:18:01 [Server] [INFO] at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:27) ~[spigot-api-1.20.2-R0.1-SNAPSHOT.jar:?]
    13.03 22:18:01 [Server] [INFO] at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:149) ~[spigot-api-1.20.2-R0.1-SNAPSHOT.jar:?]
    13.03 22:18:01 [Server] [INFO] at org.bukkit.craftbukkit.v1_20_R2.CraftServer.dispatchCommand(CraftServer.java:879) ~[spigot-1.20.2-R0.1-SNAPSHOT.jar:3950-Spigot-2888990-d485cde]
    13.03 22:18:01 [Server] [INFO] at org.bukkit.craftbukkit.v1_20_R2.command.BukkitCommandWrapper.run(BukkitCommandWrapper.java:50) ~[spigot-1.20.2-R0.1-SNAPSHOT.jar:3950-Spigot-2888990-d485cde]
    13.03 22:18:01 [Server] [INFO] at com.mojang.brigadier.CommandDispatcher.execute(CommandDispatcher.java:265) ~[spigot-1.20.2-R0.1-SNAPSHOT.jar:?]
    13.03 22:18:01 [Server] [INFO] at net.minecraft.commands.CommandDispatcher.performCommand(CommandDispatcher.java:320) ~[spigot-1.20.2-R0.1-SNAPSHOT.jar:3950-Spigot-2888990-d485cde]
    13.03 22:18:01 [Server] [INFO] at net.minecraft.commands.CommandDispatcher.a(CommandDispatcher.java:304) ~[spigot-1.20.2-R0.1-SNAPSHOT.jar:3950-Spigot-2888990-d485cde]
    13.03 22:18:01 [Server] [INFO] at net.minecraft.server.network.PlayerConnection.a(PlayerConnection.java:1828) ~[spigot-1.20.2-R0.1-SNAPSHOT.jar:3950-Spigot-2888990-d485cde]
    13.03 22:18:01 [Server] [INFO] at net.minecraft.server.network.PlayerConnection.lambda$15(PlayerConnection.java:1790) ~[spigot-1.20.2-R0.1-SNAPSHOT.jar:3950-Spigot-2888990-d485cde]
    13.03 22:18:01 [Server] [INFO] at net.minecraft.util.thread.IAsyncTaskHandler.b(SourceFile:67) ~[spigot-1.20.2-R0.1-SNAPSHOT.jar:3950-Spigot-2888990-d485cde]
    13.03 22:18:01 [Server] [INFO] at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768) ~[?:?]
    13.03 22:18:01 [Server] [INFO] at net.minecraft.server.TickTask.run(SourceFile:18) ~[spigot-1.20.2-R0.1-SNAPSHOT.jar:3950-Spigot-2888990-d485cde]
    13.03 22:18:01 [Server] [INFO] at net.minecraft.util.thread.IAsyncTaskHandler.d(SourceFile:156) ~[spigot-1.20.2-R0.1-SNAPSHOT.jar:3950-Spigot-2888990-d485cde]
    13.03 22:18:01 [Server] [INFO] at net.minecraft.util.thread.IAsyncTaskHandlerReentrant.d(SourceFile:23) ~[spigot-1.20.2-R0.1-SNAPSHOT.jar:3950-Spigot-2888990-d485cde]
    13.03 22:18:01 [Server] [INFO] at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:1133) ~[spigot-1.20.2-R0.1-SNAPSHOT.jar:3950-Spigot-2888990-d485cde]
    13.03 22:18:01 [Server] [INFO] at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:1) ~[spigot-1.20.2-R0.1-SNAPSHOT.jar:3950-Spigot-2888990-d485cde]
    13.03 22:18:01 [Server] [INFO] at net.minecraft.util.thread.IAsyncTaskHandler.x(SourceFile:130) ~[spigot-1.20.2-R0.1-SNAPSHOT.jar:3950-Spigot-2888990-d485cde]
    13.03 22:18:01 [Server] [INFO] at net.minecraft.server.MinecraftServer.bg(MinecraftServer.java:1112) ~[spigot-1.20.2-R0.1-SNAPSHOT.jar:3950-Spigot-2888990-d485cde]
    13.03 22:18:01 [Server] [INFO] at net.minecraft.server.MinecraftServer.x(MinecraftServer.java:1105) ~[spigot-1.20.2-R0.1-SNAPSHOT.jar:3950-Spigot-2888990-d485cde]
    13.03 22:18:01 [Server] [INFO] at net.minecraft.util.thread.IAsyncTaskHandler.c(SourceFile:139) ~[spigot-1.20.2-R0.1-SNAPSHOT.jar:3950-Spigot-2888990-d485cde]
    13.03 22:18:01 [Server] [INFO] at net.minecraft.server.MinecraftServer.u_(MinecraftServer.java:1089) ~[spigot-1.20.2-R0.1-SNAPSHOT.jar:3950-Spigot-2888990-d485cde]
    13.03 22:18:01 [Server] [INFO] at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:1000) ~[spigot-1.20.2-R0.1-SNAPSHOT.jar:3950-Spigot-2888990-d485cde]
    13.03 22:18:01 [Server] [INFO] at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:298) ~[spigot-1.20.2-R0.1-SNAPSHOT.jar:3950-Spigot-2888990-d485cde]
    13.03 22:18:01 [Server] [INFO] at java.lang.Thread.run(Thread.java:833) ~[?:?]
     
  2. Online

    timtower Administrator Administrator Moderator

    @CraftyCodez You don't call getConfigurationSection on a key with a dot on the end.
     
  3. Offline

    KathleenCampos

    The error occurred while trying to create a partition using an empty path. Maybe you were trying to access a configuration section that doesn't exist.
    Let's look at your ArenaManager class. The error occurs on this line:
    Code:
    config.getConfigurationSection("arenas." + str + ".world")
    This can happen if the config section with the specified path doesn't exist. The arenas section may be missing or empty in your configuration file.
    Just check if ur confoc file contains the correct sections and values.

    :cool:Now regarding your code. You have [arrow]ConfigManager.setupConfig(this); which is called in the [arrow]OnEnable() method of your main class. This suggests that you are using ConfigManager, but the code for this manager is missing from your given code. Just check if the class is configured correctly and handles configuration as you expect :rolleyes:
     
  4. Online

    timtower Administrator Administrator Moderator

    How do you find the line without knowing the includes?
    Can you explain why it doesn't happen here instead:
    Code:
    for (String str : config.getConfigurationSection("arenas.").getKeys(false)) {
     

Share This Page