Solved Creating Empty Config

Discussion in 'Plugin Development' started by morha13, Jul 2, 2013.

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

    morha13

    hello,
    i have a script that using config file..
    the problome is that its creating the config file but empty.

    main file:
    Code:java
    1. package com.gmail.morha0;
    2.  
    3. import org.bukkit.ChatColor;
    4. import org.bukkit.command.Command;
    5. import org.bukkit.command.CommandSender;
    6. import org.bukkit.entity.Player;
    7. import org.bukkit.plugin.java.JavaPlugin;
    8.  
    9. public class getc extends JavaPlugin{
    10.  
    11.  
    12. public void onEnable() {
    13. getConfig().options().copyDefaults(true);
    14. saveConfig();
    15. }
    16. public void onDisable() {
    17. getConfig().options().copyDefaults(true);
    18. saveConfig();
    19. }
    20.  
    21. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
    22. if(cmd.getName().equalsIgnoreCase("ts")){
    23. Player player = (Player) sender;
    24. player.sendMessage(ChatColor.GOLD + "Our TeamSpeak 3 Server:" + ChatColor.GREEN + getConfig().getInt("ip"));
    25. return true;
    26. }
    27. if(cmd.getName().equalsIgnoreCase("staff")){
    28. Player player = (Player) sender;
    29. player.sendMessage(getConfig().getString("staff"));
    30. saveConfig();
    31. }
    32. return false;
    33. }
    34.  
    35. }
    36.  


    Config File:

    Code:
    staff: PleaseTest
     
  2. Offline

    Alex5657

    1) IP can not be an int. And IP is a string
    2) Do you have the config.yml in your projects jar file?
     
  3. Offline

    morha13

    1) ok
    2) yes..

    Fixed! You Can Lock The Thread!

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 2, 2016
  4. Offline

    iFamasssxD

    On occasions like this it would be very helpful to actually tell people how the problem was solved so others can learn from this as well instead of just saying "FIXED" and being done with it.
     
  5. Offline

    morha13

    ok,
    so i did some staff:
    1. move the Player player = (Player) sender; to the public boolean onCommand... instand of on every command.

    2. after that line: public class getc extends JavaPlugin{
    i added the next 2 line:



    Code:java
    1. public static getc plugin;
    2.  
    3. public final Logger logger = Logger.getLogger("Minecraft");


    i think that what actually fixed it was the adding of the lines..
     
Thread Status:
Not open for further replies.

Share This Page