Solved Server doesn't create config.yml

Discussion in 'Plugin Development' started by Cammeritz, Feb 16, 2014.

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

    Cammeritz

    Hay Guys,

    i have a huge problem. My server/plugin isn't creating the config.yml and the plugin don't works.

    Here is my Main.class:

    Code:java
    1. package de.Cammeritz.Surf;
    2.  
    3.  
    4. import java.io.FileNotFoundException;
    5.  
    6. import org.bukkit.configuration.file.FileConfiguration;
    7. import org.bukkit.configuration.file.YamlConfiguration;
    8. import org.bukkit.plugin.PluginManager;
    9. import org.bukkit.plugin.java.JavaPlugin;
    10.  
    11. import de.Cammeritz.Surf.Commands.SurfCommand;
    12. import de.Cammeritz.Surf.Listener.QuitListener;
    13. import de.Cammeritz.Surf.Listener.WaterJumpListener;
    14.  
    15.  
    16. public class Surf extends JavaPlugin {
    17.  
    18. public String prefix = "§b[§6Surf§b]";
    19.  
    20. public void onEnable() {
    21.  
    22.  
    23. System.out.println("#############################################");
    24. System.out.println("[Surf] by: " + getDescription().getAuthors());
    25. System.out.println("[Surf] version: " + getDescription().getVersion());
    26. System.out.println("[Surf] thanks for choosing my Plugin <3");
    27. System.out.println("#############################################");
    28.  
    29. getCommand("surf").setExecutor(new SurfCommand(this));
    30.  
    31. PluginManager pm = getServer().getPluginManager();
    32.  
    33. pm.registerEvents(new QuitListener(), this);
    34. pm.registerEvents(new BedrockListener(this), this);
    35. pm.registerEvents(new WaterJumpListener(this), this);
    36.  
    37. try {
    38. getConfig().addDefault("errors.youarenotingame", "&cYou can't leave &6Surf &cif you aren't ingame!");
    39. getConfig().addDefault("errors.youarealreadyingame", "&cYou can't join &6Surf &cif you're already ingame!");
    40. getConfig().addDefault("messages.join", "&bYou joined &6Surf&b!");
    41. getConfig().addDefault("messages.leave", "&bYou left &6Surf&b!");
    42. getConfig().addDefault("messages.commands", "&7Lists all available commands");
    43. getConfig().addDefault("messages.info", "&7Gives you information how to Play");
    44. getConfig().addDefault("messages.howto", new String[]{
    45. "&7This is &6Surf&7.",
    46. "&7Surf is a kind of PvP Plugin with some features.",
    47. "&7You battle against your enemies.",
    48. "&7If you run into water it would catapult you up!",
    49. "&7If you run over &cBedrock &7you will get an Item!",
    50. "&7You're weapons are changing! (Changing Kits)",
    51. "&7The maps are also changing!",
    52. "&7You can join &6Surf &7by doing /surf join.",
    53. "&7You can leave &6Surf &7by doing /surf leave.",
    54. "&7Have Fun :)"
    55. });
    56. getConfig().addDefault("arena.coords.x", "");
    57. getConfig().addDefault("arena.coords.y", "");
    58. getConfig().addDefault("arena.coords.z", "");
    59. getConfig().addDefault("arena.coords.yaw", "");
    60. getConfig().addDefault("arena.coords.pitch", "");
    61. getConfig().addDefault("arena.coords.world", "");
    62. getConfig().addDefault("messages.command.join", "&7Join Surf");
    63. getConfig().addDefault("messages.command.leave", "&7Leave Surf");
    64. getConfig().addDefault("messages.command.info", "&7How to Play Surf");
    65. getConfig().addDefault("messages.command.help", "&7Help");
    66. getConfig().addDefault("messages.command.reload", "&7Reload's the config");
    67. getConfig().addDefault("water.sound", "true");
    68. getConfig().addDefault("water.jumpheight", "3.00");
    69. getConfig().addDefault("bedrock.ids", new String[]{
    70. "276",
    71. "267"
    72. });
    73. getConfig().options().copyDefaults(true);
    74. saveConfig();
    75. } catch (Exception e) {
    76. e.printStackTrace();
    77. System.out.println("[Surf] Error while creating config!");
    78. }
    79.  
    80.  
    81. }
    82.  
    83. public void onDisable() {
    84.  
    85. System.out.println("#############################################");
    86. System.out.println("[Surf] by: " + getDescription().getAuthors());
    87. System.out.println("[Surf] version: " + getDescription().getVersion());
    88. System.out.println("[Surf] thanks for choosing my Plugin <3");
    89. System.out.println("#############################################");
    90.  
    91. }
    92.  
    93.  
    94.  
    95. }
    96.  


    The getConfig().options().copyDefaults(true); isn't working or the Server isn't able to create a new Yaml file :O Need Help.

    Thanks to everyone who helps :)
     
  2. Offline

    knrd2

    i have some tip for you. create config.yml in main dir of plugin ( in dir where you have plugin.yml ).
    and:
    Code:java
    1. public void onEnable(){
    2. this.saveDefaultConfig();
    3. this.reloadConfig();
    4. }
     
  3. Offline

    Cammeritz

    No Support?

    - Fixed

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 6, 2016
Thread Status:
Not open for further replies.

Share This Page