Solved Help with saving and getting Data

Discussion in 'Plugin Help/Development/Requests' started by The_Nesko, Nov 1, 2015.

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

    The_Nesko

    Ok so i'm currently writing a plugin that will allow players to have more inventories in only one chest or block, but i can't figure out the part where i need to get the saved data and use them.I managed to save them and checked the data.yml they are saved correctly and when i get them and use them it get no errors in the code.

    So this is the part where i save the data that i want to use:
    Code:
                //Saving Part
                createdInventories = settings.getData().getInt("Chest location.placeHolder");
                createdInventories++;
                settings.getData().set("Chest location.placeHolder", createdInventories);
                settings.getData().set("Chest location." + createdInventories + ".x" , targetedLocation.getBlockX());
                settings.getData().set("Chest location." + createdInventories + ".y" , targetedLocation.getBlockY());
                settings.getData().set("Chest location." + createdInventories + ".z" , targetedLocation.getBlockZ());
                settings.getData().set("Chest location." + createdInventories + ".world" , targetedLocation.getWorld().getName());          
                settings.saveData();
    

    And this is the part where i'm having the problem:
    Code:
    @EventHandler
        public void onPlayerInteract(PlayerInteractEvent e) {
            if((e.getAction() == Action.RIGHT_CLICK_BLOCK)) {
               
                createdInventories = settings.getData().getInt("Chest location.placeHolder");
               
                for (int i = 0; i <= createdInventories; i++) {
                   
                    double targetX = settings.getData().getDouble("Chest location." + i + ".x");
                    double targetY = settings.getData().getDouble("Chest location." + i + ".y");
                    double targetZ = settings.getData().getDouble("Chest location." + i + ".z");
                    String targetWorldName = settings.getData().getString("Chest location." + i + ".world");
                    World targetWorld = Bukkit.getServer().getWorld(targetWorldName); 
                    Location targetedLocation= new Location(targetWorld, targetX,targetY, targetZ);
                   
                    if (e.getClickedBlock().getLocation() == targetedLocation) {               
                        e.getPlayer().playSound(e.getPlayer().getLocation(), Sound.CHEST_OPEN, 10, 1);
                        e.setCancelled(true);
                        showPage(e.getPlayer());
                    }               
                }                             
            }               
        }
    
    In the console it says that i have the error at line 68 but i don't get what is the problem there.
    Here is the line 68:
    Code:
    World targetWorld = Bukkit.getServer().getWorld(targetWorldName);
    
    If anyone knows how to fix this please help .:)
     
Thread Status:
Not open for further replies.

Share This Page