How do I fix acces denied message?

Discussion in 'Plugin Development' started by lgplay, Jul 10, 2017.

Thread Status:
Not open for further replies.
  1. PHP:
    [15:43:58 WARN]: java.io.FileNotFoundExceptionC:\Users\lgpla\Desktop\programmieren\java\plugins\sync (Zugriff verweigert)
    [
    15:43:58 WARN]:        at java.io.FileOutputStream.open0(Native Method)
    [
    15:43:58 WARN]:        at java.io.FileOutputStream.open(Unknown Source)
    [
    15:43:58 WARN]:        at java.io.FileOutputStream.<init>(Unknown Source)
    [
    15:43:58 WARN]:        at java.io.FileOutputStream.<init>(Unknown Source)
    [
    15:43:58 WARN]:        at org.bukkit.configuration.file.FileConfiguration.save(FileConfiguration.java:105)
    [
    15:43:58 WARN]:        at ga.lgplay.vanilla.BannManager.Database.save(Database.java:225)
    [
    15:43:58 WARN]:        at ga.lgplay.vanilla.BannManager.Database.<init>(Database.java:47)
    [
    15:43:58 WARN]:        at ga.lgplay.vanilla.BannManager.BannMain.<init>(BannMain.java:21)
    [
    15:43:58 WARN]:        at ga.lgplay.vanilla.main.onEnable(main.java:39)
    [
    15:43:58 WARN]:        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:321)
    [
    15:43:58 WARN]:        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:340)
    [
    15:43:58 WARN]:        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:405)
    [
    15:43:58 WARN]:        at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugin(CraftServer.java:357)
    [
    15:43:58 WARN]:        at org.bukkit.craftbukkit.v1_8_R3.CraftServer.enablePlugins(CraftServer.java:317)
    [
    15:43:58 WARN]:        at org.bukkit.craftbukkit.v1_8_R3.CraftServer.reload(CraftServer.java:741)
    [
    15:43:58 WARN]:        at org.bukkit.Bukkit.reload(Bukkit.java:535)
    [
    15:43:58 WARN]:        at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:25)
    [
    15:43:58 WARN]:        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141)
    [
    15:43:58 WARN]:        at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:641)
    [
    15:43:58 WARN]:        at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchServerCommand(CraftServer.java:627)
    [
    15:43:58 WARN]:        at net.minecraft.server.v1_8_R3.DedicatedServer.aO(DedicatedServer.java:412)
    [
    15:43:58 WARN]:        at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:375)
    [
    15:43:58 WARN]:        at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654)
    [
    15:43:58 WARN]:        at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557)
    [
    15:43:58 WARN]:        at java.lang.Thread.run(Unknown Source)
    My Code
    PHP:
    public Database(main instance) {
            
    plug instance;
            
    = new File("C:/Users/lgpla/Desktop/programmieren/java/plugins/sync/");
            if(!
    f.exists())
                
    f.mkdir();
            
    File file = new File(f,"Banns.yml");
            
    yml YamlConfiguration.loadConfiguration(file);
            
    save();
            
    startAktualisierer();
        }
     
  2. Offline

    timtower Administrator Administrator Moderator

    @lgplay Use relative paths please, no absolute paths.
     
  3. @timtower I can't becouse I make a sync system for different servers like when I have bedwars one server a and bedwars on server b I want that they use the same Yml to save their things i think with relative I can't go out of the server folder
     
  4. Offline

    timtower Administrator Administrator Moderator

    @lgplay Then my guess would be that both servers are trying to access the file, then you will get an access denied.
    What things do you store in the files? Database could be better for this.
     
  5. @timtower when I turn one Server on with that Plugin it don't workes and I don't know anything about databases
    I have thinked that in that way it would be easyer
     
  6. Offline

    Zombie_Striker

    @lgplay
    This will fail one of two ways:
    1. If you do not continually read the config for each server, one server may override the other server and information will be lost.
    2. You continually re-read the config, minimizing the chance for overriding data, but there is a chance both servers will try to access the file at the same time which will throw an exception, stopping one or both servers from saving the data. Depending on how many times you write to the config, this may be a real risk doing this.
    Again, the best way to do this would be to set up a database; as this is the exact reason why you would need a database.
     
  7. @Zombie_Striker I want to make a bann Plugin and when a player get banned the plugin reloads the yml database
    add the UUID to the banned List and save the File and I also have made a Timer wich only reload the banned players so the Risk I think is very shortly but my problem is how to remove the Acces denied error

    Now it works if someone needs it here is how you can save Files who are not in the server Folder

    Config;
    Code:
    BannManager:
      BannDatabasePfad: C://Users/lgpla/Desktop/programmieren/java/plugins/sync/
    
    Plugin Code
    PHP:
    = new File(Config.getBannDatabasePfad()+"Banns.yml");
            if(!
    f.exists())
                try {
                    
    f.createNewFile();
                } catch (
    IOException e) {
                    
    // TODO Auto-generated catch block
                    
    e.printStackTrace();
                }
            
    yml YamlConfiguration.loadConfiguration(f);
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jul 10, 2017
Thread Status:
Not open for further replies.

Share This Page