Solved Getting 'Null' message rather than message specified in config.

Discussion in 'Plugin Development' started by dandwhit, Aug 31, 2014.

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

    dandwhit

    Hi there,
    I started coding this plugin this morning and I have no experience at all with it before. I watched a bit of a tutorial to help me get started and then did the rest.
    So the thing is, the plugin is meant to say something to the player when they run the command /wishes or /500th but instead of saying the message specified in config it says: null. Please find below, the code, plugin.yml and config.yml.
    Thanks for any help,
    Dan
    Code:java
    1. package me.dandwhit.NextShow;
    2.  
    3. import java.util.logging.Logger;
    4.  
    5. import org.bukkit.ChatColor;
    6. import org.bukkit.command.Command;
    7. import org.bukkit.command.CommandSender;
    8. import org.bukkit.entity.Player;
    9. import org.bukkit.plugin.PluginDescriptionFile;
    10. import org.bukkit.plugin.java.JavaPlugin;
    11.  
    12. public class Main extends JavaPlugin{
    13. public static String messageString = "There is no official date for the first showing of wishes, as we are still creating magic! ";
    14.  
    15. Logger log;
    16.  
    17. public void onEnable() {
    18. PluginDescriptionFile pdfFile = this.getDescription();
    19. log = this.getLogger();
    20. log.info(pdfFile.getName() + " Has been started! Version: v " + pdfFile.getVersion());
    21.  
    22.  
    23. setConfig();
    24. }
    25.  
    26. public void setConfig(){
    27. this.saveDefaultConfig();
    28. }
    29.  
    30. public void onDisable() {
    31. getLogger().info("Plugin Disabled");
    32. }
    33.  
    34. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    35. Player player = (Player) sender;
    36. if(cmd.getName().equalsIgnoreCase("wishes")) {
    37. player.sendMessage(ChatColor.RED + "[" + ChatColor.GREEN + "Jiminy Cricket" + ChatColor.RED + "]" + ChatColor.AQUA + ChatColor.BOLD + this.getConfig().getString("wishes"));
    38. }
    39.  
    40. if(cmd.getName().equalsIgnoreCase("500th")) {
    41. this.reloadConfig();
    42. player.sendMessage(ChatColor.GREEN + this.getConfig().getString("wishes"));
    43. }
    44.  
    45. if(cmd.getName().equalsIgnoreCase("nsreload")) {
    46. this.reloadConfig();
    47. player.sendMessage(ChatColor.GOLD + "Config file has been reloaded!");
    48. }
    49. return false;
    50. }
    51.  
    52. }


    Plugin.yml
    Config.yml EDIT: It appears the plugin.yml is the config and vice versa!
     
  2. Offline

    jojo1541

    have you tried quotes in your config?
    like
    Code:
    wishes: "The next showing of wishes will be on: Some date in the near future!"
     
  3. Offline

    dandwhit

    jojo1541 I will now.

    I feel stupid now.... It worked! Thanks!

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

    jojo1541

    if it worked please change your thread to solved.:)
     
Thread Status:
Not open for further replies.

Share This Page