Solved problem detecting a boolean in the config

Discussion in 'Spigot Plugin Development' started by Whirss, Sep 30, 2021.

  1. Hello, according to me this should work but nothing happens inside the if :confused:
    [​IMG]
    Code (Java):
    package org.jachi.whirss.thenexus.events;

    import org.bukkit.Bukkit;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.BlockPlaceEvent;
    import org.jachi.whirss.thenexus.Main;

    public class OnPlaceBlock implements Listener {

        private Main main;

        public OnPlaceBlock(Main main) {
            this.main = main;
        }

        @EventHandler
        public void OnPlayerPlaceBlock(BlockPlaceEvent event) {
            Player player = event.getPlayer();
            String worldname = event.getPlayer().getWorld().getName();
            Bukkit.broadcastMessage("test");
            if(main.getWorlds().getBoolean("worlds." + worldname + ".build")) {
                if(player.hasPermission("thenexus.*") ||
                        player.hasPermission("thenexus.worldmanager.bypass") ||
                        player.hasPermission("thenexus.worldmanager.*")){
                    event.setCancelled(false);
                } else {
                    event.setCancelled(true);
                }
            }

        }
    }
     
     
  2. You should describe what you're expecting and what your error is some more.
     
  3. Your boolean is set to false right now, just to make sure.
    If that's not the problem, can you print / check what's is returned from your config? To find out if the reading from your config part has a problem or if it's about your logic.
     
    • Agree Agree x 1
  4. Thanks, this has made me realize that I'm a bit stupid xd
    [​IMG]
     
  5. Yea these things happen sometimes :D Glad I could help you!
     
    • Friendly Friendly x 1