Weird Config Formatting Error

Discussion in 'Plugin Development' started by Tudedude, Jan 14, 2014.

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

    Tudedude

    So, I was developing a plugin with BarAPI and I got everything working, and I made the bar appear onPlayerJoin. I added config support, but when you format it in the config, it comes out with the attached image. My code is:
    Code:java
    1. package io.github.Tudedude100;
    2.  
    3. import me.confuser.barapi.BarAPI;
    4.  
    5. import org.bukkit.Bukkit;
    6. import org.bukkit.command.Command;
    7. import org.bukkit.command.CommandSender;
    8. import org.bukkit.entity.Player;
    9. import org.bukkit.event.EventHandler;
    10. import org.bukkit.event.Listener;
    11. import org.bukkit.event.player.PlayerJoinEvent;
    12. import org.bukkit.plugin.PluginDescriptionFile;
    13. import org.bukkit.plugin.java.JavaPlugin;
    14.  
    15. public class AB extends JavaPlugin implements Listener{
    16.  
    17. public void onEnable(){
    18. PluginDescriptionFile p = this.getDescription();
    19. Bukkit.getServer().getPluginManager().registerEvents(this, this);
    20. getLogger().info("AnnounceBars v" + p.getVersion() + " has been woken up. Goooood morning!");
    21. this.saveDefaultConfig();
    22. saveConfig();
    23. }
    24. public void onDisable(){
    25. getLogger().info("AnnounceBars has gone to sleep. Good night.");
    26. }
    27. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
    28. if(cmd.getName().equalsIgnoreCase("ab")){
    29. PluginDescriptionFile p = this.getDescription();
    30. sender.sendMessage("§6§lAnnounceBars §2v" + p.getVersion()+" §3was developed by §4§lTudedude.\n" +
    31. "§3Current release was last updated at: §21/6/2014 9:30pm §6- §4(-08)\n" +
    32. "§4§lAll plugin functions are automatic. There are no commands.");
    33. return true;
    34. }
    35. return false;
    36. }
    37. @EventHandler
    38. public void onPlayerJoin(PlayerJoinEvent e){
    39. Player p = e.getPlayer();
    40. String abMessage = getConfig().getString("abMessage");
    41. ChatColor.translateAlternateColorCodes('&', abMessage);
    42. BarAPI.hasBar(p);
    43. BarAPI.setHealth(p, 100);
    44. BarAPI.setMessage(p, abMessage);
    45. }
    46. }


    Thank you in advance for any help!
     

    Attached Files:

  2. Offline

    Avery246813579

    What is the abMessage variable created?
     
  3. Have you declared the variable abMessage?
     
  4. Offline

    Tudedude

    Haha, sorry, I believe I grabbed code from in between versions, I will update the code.
    The abMessage string is grabbed from the config.yml file.
     
  5. Offline

    calebbfmv

    Something:
    If you want custom chat colors, why not just do ChatColor.translateAlternateColorCodes('&', String s);
    Actually, that might fix the problem
     
  6. Offline

    Tudedude

  7. Offline

    calebbfmv

    Remove
    .replace("&", "§");
     
  8. Offline

    Tudedude

    I did, I just didn't update the code. I will do that.
     
  9. Offline

    Tudedude

    Bump, still isn't fixed :(
     
Thread Status:
Not open for further replies.

Share This Page