Problem/Bug Help with configs

Discussion in 'Bukkit Help' started by zJanny, Jul 28, 2020.

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



    So i made a little plugin where you can claim chunks, to check if the chunk is claimed i do this:

        void HandleBlockBreak(BlockBreakEvent e)
            FileConfiguration config = Main.getPlugin().getConfig();
            int ammount = config.getInt("Neos.Chunks.Ammount");
            for(int i = 0; i < ammount; i++)
                String name_of_owner = config.getString("Neos.Chunks." + ammount + ".chunk.owner");
                double loc_X = config.getDouble("Neos.Chunks." + ammount + ".chunk.location.X");
                double loc_Y = config.getDouble("Neos.Chunks." + ammount + ".chunk.location.Y");
                double loc_Z = config.getDouble("Neos.Chunks." + ammount + ".chunk.location.Z");
                Location loc = new Location(Bukkit.getWorld("world"), loc_X, loc_Y, loc_Z);
                Chunk chunk = Bukkit.getWorld("world").getChunkAt(loc);
                Player me = e.getPlayer();
                Player owner = Bukkit.getPlayer(name_of_owner);
                if(chunk == e.getBlock().getChunk())
                    if(me != owner)
                        boolean claimed = config.getBoolean("Neos.Chunks." + ammount + ".chunk.claimed");
                        me.sendMessage("§cDieses Grundstück gehört dir nicht!");
    The problem is, that i get a nullptr exception error that name cannot be null, even though the name is set in the config and i put the right path in. If i dont get this error, then for some reason it only reads the last entry of the config.

    Like if i have 3 Chunks, it would read only the coords of the 3rd chunk.

    Could someone please help me with this?

    Okay i fixed the issues, the issue was that i used ammount as an integer. I converted it to a string and now it works

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Jul 28, 2020
Thread Status:
Not open for further replies.

Share This Page