[Solved] Help with config files

Discussion in 'Spigot Plugin Development' started by Folf, May 29, 2015.

  1. Im creating a config at the first time and I get a error on start the server
    Code (Text):

    [22:57:52 INFO]: [CraftingThings] Enabling CraftingThings v1.0
    [22:57:52 WARN]: [CraftingThings] Default system encoding may have misread confi
    g.yml from plugin jar
    [22:57:52 ERROR]: [CraftingThings] Cannot load configuration from jar
    org.bukkit.configuration.InvalidConfigurationException: while scanning an anchor

     in 'string', line 26, column 6:
        Tag: &f[┬ºeCraftingThings┬ºf]
             ^
    expected alphabetic or numeric character, but found [(91)
     in 'string', line 26, column 8:
        Tag: &f[┬ºeCraftingThings┬ºf]
               ^

            at org.bukkit.configuration.file.YamlConfiguration.loadFromString(YamlCo
    nfiguration.java:57) ~[spigot.jar:git-Spigot-1.7.9-R0.2-208-ge0f2e95]
            at org.bukkit.plugin.java.JavaPlugin.reloadConfig(JavaPlugin.java:209) [
    spigot.jar:git-Spigot-1.7.9-R0.2-208-ge0f2e95]
            at org.bukkit.plugin.java.JavaPlugin.getConfig(JavaPlugin.java:157) [spi
    got.jar:git-Spigot-1.7.9-R0.2-208-ge0f2e95]
            at me.check_plys.craftingthings.Main.horsearmouriron(Main.java:96) [Craf
    ting.jar:?]
            at me.check_plys.craftingthings.Main.onEnable(Main.java:31) [Crafting.ja
    r:?]
            at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:316) [sp
    igot.jar:git-Spigot-1.7.9-R0.2-208-ge0f2e95]
            at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader
    .java:332) [spigot.jar:git-Spigot-1.7.9-R0.2-208-ge0f2e95]
            at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManage
    r.java:412) [spigot.jar:git-Spigot-1.7.9-R0.2-208-ge0f2e95]
            at org.bukkit.craftbukkit.v1_7_R4.CraftServer.loadPlugin(CraftServer.jav
    a:476) [spigot.jar:git-Spigot-1.7.9-R0.2-208-ge0f2e95]
            at org.bukkit.craftbukkit.v1_7_R4.CraftServer.enablePlugins(CraftServer.
    java:394) [spigot.jar:git-Spigot-1.7.9-R0.2-208-ge0f2e95]
            at org.bukkit.craftbukkit.v1_7_R4.CraftServer.reload(CraftServer.java:86
    6) [spigot.jar:git-Spigot-1.7.9-R0.2-208-ge0f2e95]
            at org.bukkit.Bukkit.reload(Bukkit.java:301) [spigot.jar:git-Spigot-1.7.
    9-R0.2-208-ge0f2e95]
            at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:
    23) [spigot.jar:git-Spigot-1.7.9-R0.2-208-ge0f2e95]
            at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:18
    1) [spigot.jar:git-Spigot-1.7.9-R0.2-208-ge0f2e95]
            at org.bukkit.craftbukkit.v1_7_R4.CraftServer.dispatchCommand(CraftServe
    r.java:767) [spigot.jar:git-Spigot-1.7.9-R0.2-208-ge0f2e95]
            at org.bukkit.craftbukkit.v1_7_R4.CraftServer.dispatchServerCommand(Craf
    tServer.java:753) [spigot.jar:git-Spigot-1.7.9-R0.2-208-ge0f2e95]
            at net.minecraft.server.v1_7_R4.DedicatedServer.aB(DedicatedServer.java:
    326) [spigot.jar:git-Spigot-1.7.9-R0.2-208-ge0f2e95]
            at net.minecraft.server.v1_7_R4.DedicatedServer.v(DedicatedServer.java:2
    90) [spigot.jar:git-Spigot-1.7.9-R0.2-208-ge0f2e95]
            at net.minecraft.server.v1_7_R4.MinecraftServer.u(MinecraftServer.java:5
    84) [spigot.jar:git-Spigot-1.7.9-R0.2-208-ge0f2e95]
            at net.minecraft.server.v1_7_R4.MinecraftServer.run(MinecraftServer.java
    :490) [spigot.jar:git-Spigot-1.7.9-R0.2-208-ge0f2e95]
            at net.minecraft.server.v1_7_R4.ThreadServerApplication.run(SourceFile:6
    28) [spigot.jar:git-Spigot-1.7.9-R0.2-208-ge0f2e95]
    Caused by: org.yaml.snakeyaml.scanner.ScannerException: while scanning an anchor
    ; expected alphabetic or numeric character, but found [(91);  in 'string', line
    26, column 8:
        Tag: &f[┬ºeCraftingThings┬ºf]
               ^
            at org.yaml.snakeyaml.scanner.ScannerImpl.scanAnchor(ScannerImpl.java:14
    46) ~[spigot.jar:git-Spigot-1.7.9-R0.2-208-ge0f2e95]
            at org.yaml.snakeyaml.scanner.ScannerImpl.fetchAnchor(ScannerImpl.java:9
    39) ~[spigot.jar:git-Spigot-1.7.9-R0.2-208-ge0f2e95]
            at org.yaml.snakeyaml.scanner.ScannerImpl.fetchMoreTokens(ScannerImpl.ja
    va:370) ~[spigot.jar:git-Spigot-1.7.9-R0.2-208-ge0f2e95]
            at org.yaml.snakeyaml.scanner.ScannerImpl.checkToken(ScannerImpl.java:22
    6) ~[spigot.jar:git-Spigot-1.7.9-R0.2-208-ge0f2e95]
            at org.yaml.snakeyaml.parser.ParserImpl$ParseBlockMappingValue.produce(P
    arserImpl.java:586) ~[spigot.jar:git-Spigot-1.7.9-R0.2-208-ge0f2e95]
            at org.yaml.snakeyaml.parser.ParserImpl.peekEvent(ParserImpl.java:158) ~
    [spigot.jar:git-Spigot-1.7.9-R0.2-208-ge0f2e95]
            at org.yaml.snakeyaml.parser.ParserImpl.checkEvent(ParserImpl.java:143)
    ~[spigot.jar:git-Spigot-1.7.9-R0.2-208-ge0f2e95]
            at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:132) ~
    [spigot.jar:git-Spigot-1.7.9-R0.2-208-ge0f2e95]
            at org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java
    :237) ~[spigot.jar:git-Spigot-1.7.9-R0.2-208-ge0f2e95]
            at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:159) ~
    [spigot.jar:git-Spigot-1.7.9-R0.2-208-ge0f2e95]
            at org.yaml.snakeyaml.composer.Composer.composeDocument(Composer.java:12
    2) ~[spigot.jar:git-Spigot-1.7.9-R0.2-208-ge0f2e95]
            at org.yaml.snakeyaml.composer.Composer.getSingleNode(Composer.java:105)
     ~[spigot.jar:git-Spigot-1.7.9-R0.2-208-ge0f2e95]
            at org.yaml.snakeyaml.constructor.BaseConstructor.getSingleData(BaseCons
    tructor.java:120) ~[spigot.jar:git-Spigot-1.7.9-R0.2-208-ge0f2e95]
            at org.yaml.snakeyaml.Yaml.loadFromReader(Yaml.java:481) ~[spigot.jar:gi
    t-Spigot-1.7.9-R0.2-208-ge0f2e95]
            at org.yaml.snakeyaml.Yaml.load(Yaml.java:400) ~[spigot.jar:git-Spigot-1
    .7.9-R0.2-208-ge0f2e95]
            at org.bukkit.configuration.file.YamlConfiguration.loadFromString(YamlCo
    nfiguration.java:55) ~[spigot.jar:git-Spigot-1.7.9-R0.2-208-ge0f2e95]
            ... 20 more
     

    The error is on "&" in my code I put
    Code (Text):

    .replace("&", "§")
     
    But it not fix the problem

    Please help
     
  2. Inkzzz

    Resource Staff

    You want to use these around the string ''
     
  3. We can't help you if you don't post you're code.
     
  4. If the string has special characters you should put it between single commas:

    Your .yml should be like that:

    Code (Text):
    Tag: '&fHello!'
     
  5. Inkzzz

    Resource Staff

    Known as apostrophes.
     
    • Funny Funny x 1
  6. Just use ChatColor.translateAlternativeColorCodes('&', string);
     
  7. You would also want to store & in the config instead and whenever being sent or used just translate it then.
     
  8. Code (Text):

        public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
            final Player p = (Player)sender;
            if (cmd.getName().equalsIgnoreCase("ct")){
             
                if (args[0].equals("help"))
              if    (p.hasPermission("craftingthings.help"))
                  p.sendMessage(getConfig().getString("Tag").replace("&", "§").replace("Å", " ") + getConfig().getString("HelpMessage").replace("&", "§").replace("Å", " "));
              else
             
              p.sendMessage(getConfig().getString("Tag").replace("&", "§") + getConfig().getString("NoPermissionMessage").replace("&", "§").replace("Å", " "));
            }
            return true;
           
        }
     
     
  9. Yeah sorry I didn't remember the name xD
     
  10. you should put if(p.hasPermission() || p.isOp()) instead of just if(p.hasPermission())
     
  11. Tanks for help
     
    #12 Folf, May 29, 2015
    Last edited: May 29, 2015
  12. do
    Code (Text):
    p.sendMessage(ChatColor.translateAlternativeColorCodes('&', getConfig().getString("Tag") + " " + getConfig().getString("HelpMessage"));
    instead of
    Code (Text):
    p.sendMessage(getConfig().getString("Tag").replace("&", "§").replace("Å", " ") + getConfig().getString("HelpMessage").replace("&", "§").replace("Å", " "));
     
  13. Good idea. I not remembered
     
  14. Working
    Code (Text):

    # Plugin Developed by: __________   __        __
    #                     |__________|  \ \      / /
    #                         | |        \ \    / /
    #                         | |         \ \  / /
    #                         | |          \ \/ /
    #                         | |          / /\ \
    #                         | |         / /  \ \
    #                         |_|        /_/    \_\ Craft Network
    #
    #
    # Enable Crafts:
    #
    # Enable Saddle Craft?
    EnableSaddleCraft: true
    #                 _
    #                | |
    #                | |
    #             ___| |___
    # DISKS CRAFT \       /
    #              \     /
    #               \   /
    #                \_/          
    EnableDisk11Craft: true
    # Messages:
    #      This will show in all messages

    Tag: '&f[&eCraftingThings&f]'

    #      This will show if a player try to use a command without permission

    NoPermissionMessage: '&4No Permission'

    #      This will show if a player use "/ct help" command
    #      Download the craft template on plugin page or use default link provided (in the same page)

    HelpMessage: '&1Se all commands here http://domain.com/crafts'
     
     
  15. That's redundant.
     
    • Agree Agree x 2