Configuration Sections (?)

Discussion in 'Plugin Development' started by MordorKing78, Oct 1, 2016.

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

    MordorKing78

    Heyo, I was testing some stuff and then I stumbled upon this problem, I'm trying to make it so when you interact with a block it should iterate trough the config and if a location matches to a location that you right clicked it should open an inventory.

    Well my problem is that I can't seem to get all the locations.

    This is how I store my stuff:
    Show Spoiler
    Code:
    Crates:
      Crate1:
        displayName: Warming up the wheel..
        crateType: horizontal
        openedBy:
        - example_key1
        location:
          X: -177
          Y: 74
          Z: 237
      Crate2:
        displayName: Opening..
        crateType: horizontal
        openedBy:
        - example_key1
        location:
          X: -177
          Y: 72
          Z: 239
      Crate3:
        displayName: Opening..
        crateType: horizontal
        openedBy:
        - example_key1
        location:
          X: -177
          Y: 72
          Z: 235


    This is my current code:
    PHP:
        public boolean isCrate(ConfigurationSection crateLocation locPlayer p){
            for(
    String key crate.getKeys(false)){           
                
    double X crate.getDouble(key ".location.X");
                
    double Y crate.getDouble(key ".location.Y");
                
    double Z crate.getDouble(key ".location.Z");

                
    Location cloc = new Location(p.getWorld(), XYZ);
               
                if(
    loc.equals(cloc)){
                    return 
    true;
                }else{
                    return 
    false;           
                }
            }
            return 
    false;
        }
    on interact
    PHP:
    ConfigurationSection crate plugin.cfg.getConfigurationSection("Crates");

                if(
    plugin.crateMng.isCrate(crateb.getLocation(), p)){
                    
    e.setCancelled(true);
                    
    plugin.crateMng.openCrate(cratep);
                    
    Bukkit.broadcastMessage(plugin.openingCrate.get(p));
                }
     
  2. Offline

    mehboss

    @MordorKing78 try the longer way, only do it for one and see if it works. Let us know if it doesn't :)
     
  3. @MordorKing78 Why not return loc.equals(cloc) instead of checking a Boolean to return a Boolean
     
  4. Offline

    MordorKing78

    @bwfcwalshy Good point, but that wouldnt solve the problem, would it? Ill change it tho
     
Thread Status:
Not open for further replies.

Share This Page