Solved Plugin wont create files.

Discussion in 'Plugin Development' started by webbhead, Mar 29, 2016.

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

    webbhead

    Hey, I created my core plugin for my server and everything worked fine until I put it onto the real server. On the test server it created all the files we need however, on my main server, it says I do not have permission to create the files. I am using MCProHosting.. Any Ideas on a fix?
     
  2. Offline

    WolfMage1

    @webbhead can we see the code you're using to create the files?
     
  3. Offline

    webbhead

    Code:
    @EventHandlerpublic void onJoin(PlayerJoinEvent event){
    Player player = event.getPlayer();
    File f = new File(playerFolder, File.separator + player.getUniqueId().toString() + ".yml");
    FileConfiguration playerData = YamlConfiguration.loadConfiguration(f);
    
    
    if(!f.exists()){
    try {
    f.createNewFile();
    } catch (IOException e) {
    
    e.printStackTrace();
    }
    try {
    try {
    try {
    playerData.load(f);
    playerData.set("crystals", 0);
    playerData.set("balance", 0);
    playerData.set("pickaxe.speed", false);
    playerData.set("pickaxe.haste", false);
    playerData.set("pickaxe.nightvision", false);
    playerData.set("pickaxe.explosion", false);
    playerData.set("pickaxe.efficiency", 5);
    playerData.set("pickaxe.fortune", 1);
    playerData.set("prisoncrew", "Crew=null");
    playerData.set("rank.rank", Rank.A.name());
    playerData.set("rank.donorrank", "none");
    playerData.save(f);
    } catch (FileNotFoundException e) {
    e.printStackTrace();
    }
    } catch (IOException e) {
    e.printStackTrace();
    }
    } catch (InvalidConfigurationException e) {
    e.printStackTrace();
    }
    }
    }
    OnEnable:
    Code:
            playerFolder = new File(this.getDataFolder() + File.separator + "player_data");
    
            if (!playerFolder.exists()) {
                playerFolder.mkdirs();
            }
    
            crewFolder = new File(this.getDataFolder() + File.separator + "crew_data");
    
            if (!crewFolder.exists()) {
                crewFolder.mkdirs();
            }
     
  4. Offline

    Zombie_Striker

    @webbhead
    Is this coming from your plugin for from your hosting provider? Is this an issue with your hosting company not allowing you to create these directories?
     
  5. Offline

    WolfMage1

    Why do you have 3 try statements? You can have more than 1 catch block for any try statement.

    Have you tried contacting MCProHosting about it?
     
  6. Offline

    webbhead

    I know I forgot how to do it though lmao.
    It might be the hosting company but it is in the console that says:
    It couldnt create the file because it didn't have permission.
     
  7. Offline

    WolfMage1

    Code:
    try{
    }
    catch(Exception1 e){
    }
    catch(Exception2 e2){
    }
    //etc
    
    //or use multicatch
    
    try{
    }
    catch(Exception1 | Exception2 | Exception3 e){
    }
    
     
  8. Offline

    webbhead

    Thanks :)
     
Thread Status:
Not open for further replies.

Share This Page