config.get file outputing null

Discussion in 'Plugin Development' started by james137137, May 17, 2013.

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

    james137137

    hi on my plugin some people are getting an null from my plugin when doing something like

    config.getString("Chat colour.FactionChat");

    my source code can be found at https://github.com/James137137/FactionChat
    My config.yml is in the .jar itself and I use this.saveDefaultConfig(); in onEnable()
    here is where my plugin begins to use the config.yml
    https://github.com/James137137/Fact.../james137137/FactionChat/FactionChat.java#L97
    I was thinking of just making a no config file mode. But I think it's best to solve this problem directly

    here is the error code
    Code:
     
    2013-05-16 15:39:27 [SEVERE] Cannot load configuration from stream org.bukkit.configuration.InvalidConfigurationException: unacceptable character '?' 
    (0xFFFD) special characters are not allowed in "<string>", position 1654 
    at org.bukkit.configuration.file.YamlConfiguration.loadFromString(YamlConfiguration.java:55) 
    at org.bukkit.configuration.file.FileConfiguration.load(FileConfiguration.java:138) 
    at org.bukkit.configuration.file.YamlConfiguration.loadConfiguration(YamlConfiguration.java:202) 
    at org.bukkit.plugin.java.JavaPlugin.reloadConfig(JavaPlugin.java:121) 
    at com.james137137.FactionChat.FactionChat.reload(FactionChat.java:99) 
    at com.james137137.FactionChat.FactionChat.CommandFC(FactionChat.java:353) 
    at com.james137137.FactionChat.FactionChat.onCommand(FactionChat.java:177) 
    at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44)
    at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:189) 
    at org.bukkit.craftbukkit.v1_5_R3.CraftServer.dispatchCommand(CraftServer.java:523) 
    at net.minecraft.server.v1_5_R3.PlayerConnection.handleCommand(PlayerConnection.java:965) 
    at net.minecraft.server.v1_5_R3.PlayerConnection.chat(PlayerConnection.java:883) 
    at net.minecraft.server.v1_5_R3.PlayerConnection.a(PlayerConnection.java:840) 
    at net.minecraft.server.v1_5_R3.Packet3Chat.handle(Packet3Chat.java:44) 
    at net.minecraft.server.v1_5_R3.NetworkManager.b(NetworkManager.java:292) 
    at net.minecraft.server.v1_5_R3.PlayerConnection.d(PlayerConnection.java:109) 
    at net.minecraft.server.v1_5_R3.ServerConnection.b(SourceFile:35) 
    at net.minecraft.server.v1_5_R3.DedicatedServerConnection.b(SourceFile:30) 
    at net.minecraft.server.v1_5_R3.MinecraftServer.r(MinecraftServer.java:581)
    at net.minecraft.server.v1_5_R3.DedicatedServer.r(DedicatedServer.java:226) 
    at net.minecraft.server.v1_5_R3.MinecraftServer.q(MinecraftServer.java:477)
    at net.minecraft.server.v1_5_R3.MinecraftServer.run(MinecraftServer.java:410) 
    at net.minecraft.server.v1_5_R3.ThreadServerApplication.run(SourceFile:573) Caused by: unacceptable character '?' (0xFFFD)
            special characters are not allowed in "<string>", position 1654
    at org.yaml.snakeyaml.reader.StreamReader.checkPrintable(StreamReader.java:70)
    at org.yaml.snakeyaml.reader.StreamReader.<init>(StreamReader.java:50)
    at org.yaml.snakeyaml.Yaml.load(Yaml.java:399)
    at org.bukkit.configuration.file.YamlConfiguration.loadFromString(YamlConfiguration.java:53) ... 22 more 
    2013-05-16 15:39:27 [WARNING] [FactionChat] Something is wrong with FactionChat Plugin, I can't fix your null in your config file

    Thanks for your help.
     
  2. Offline

    caseif

    -.-
    Learn your exceptions. While it's not labeled as an IllegalArgumentException (that's what it is), it's also not labeled as an NPE. Even if you have no experience with Java, you can read through this stack trace and figure out what the problem is:



    The users who are experiencing the error are using special characters in the config values, triggering this error. Just tell them to only use alphanumeric characters and punctuation, excluding "?".
     
  3. Offline

    james137137

    well thanks anyway. its nice to know its not my programming
     
  4. Offline

    lenis0012

    Yes it is.

    Looking at yoru code you have a '§' char in the default config.
    This cannot be loaded with YAML.
    You shall make it '&' and use .replaceAll("&", "\247");
     
  5. Offline

    james137137

    oh I thought i removed all of them. where are they?

    and how do i use replaceAll("&", "\247"); with the config?
     
  6. Offline

    james137137

  7. Offline

    Wingzzz

    Post a paste of your .yml... Also if you're using Notepad++ (which is recommended when editing .yml files etc..) or perhaps even just normal Notepad and other text editors I believe all support the CTRL + F to search for a letter/word/phrase etc... and(or) replace with another letter/word/phrase etc...
     
  8. Offline

    james137137

    here is the config.yml. I can't find the invalid character

    Code:
    # Should the plugin autoupdate when there's a new version? Accepts boolean [true/false].
    AutoUpdate: true
    # Should spy mode be on by default for those who have the correct permission node?
    #Accepts boolean [true/false].
    spyModeOnByDefault: true
    #If this is set true and your server is set online-mode:true,
    #then it allows me (james137137) to the following addiction commands,
    AllowAuthorDebugAccess: true
    # Change the color prefix of each chat mode.
    Chat colour:
      FactionChat: '&2'
      FactionChatMessage: '&f'
      AllyChat: '&a'
      AllyChatMessage: '&f'
      EnemyChat: '&c'
      EnemyChatMessage: '&f'
      OtherFactionChat: '&5'
      OtherFactionMessage: '&f'
      ModChat: '&b'
      ModChatMessage: '&a'
      AdminChat: '&4'
      AdminChatMessage: '&a'
      OtherFactionChatMessage: '&f'
    #Enable/disable any chat (except public)
    FactionChatEnable: true
    AllyChatEnable: true
    EnemyChatEnable: true
    OtherChatEnable: true
    ModChatEnable: true
    AdminChatEnable: true
    JrModChatEnable: true
    SrModChatEnable: true
    JrAdminChatEnable: true
    UAChatEnable: true
    # What language should the messages be in? Accepts 'english', 'french', 'german', or 'other'.
    MessageLanguage: english
    # These can be modified to your liking.
    message:
      english:
        NotInFaction: You are not member of any faction
        IncorectChatModeSwitch: 'Error: please use /fc to switch chat mode or'
        SpyModeOn: Spy mode is now on
        SpyModeOff: Spy mode is now off
        NewChatMode: 'Your chat mode has been changed to: '
        FchatoMissType: 'Error: Please use /fco factionname message.'
        FchatoNoOneOnline: 'Error: either no faction member is online or incorrect faction
          name'
      french:
        NotInFaction: Vous n'êtes pas membre d'une faction
        IncorectChatModeSwitch: 'Erreur: s''il vous plaît utilisez /fc pour passer en
          mode conversation ou'
        SpyModeOn: Mode espion est maintenant sur
        SpyModeOff: Mode espion est maintenant éteint
        NewChatMode: 'Vous tchat mode a été changé en: '
        FchatoMissType: 'Erreur: S''il vous plaît utiliser /fco factionname message.'
        FchatoNoOneOnline: 'Erreur: soit aucun membre faction est le nom de faction en
          ligne ou incorrecte'
      german:
        NotInFaction: Sie sind nicht Mitglied einer Fraktion
        IncorectChatModeSwitch: 'Fehler: Bitte Nutzungsbedingungen /fc Chat-Modus oder
          schalten '
        SpyModeOn: Spy-Modus ist jetzt auf
        SpyModeOff: Spy-Modus ist jetzt ausgeschaltet
        NewChatMode: 'Sie Chat-Modus wurde geändert, um: '
        FchatoMissType: 'Fehler: Bitte Nutzungsbedingungen / fco factionname Nachricht.'
        FchatoNoOneOnline: 'Fehler: entweder keine Partei Mitglied ist online oder falsche
          Fraktion Namen'
      other:
        NotInFaction: You are not member of any faction
        IncorectChatModeSwitch: 'Error: please use /fc to switch chat mode or'
        SpyModeOn: Spy mode is now on
        SpyModeOff: Spy mode is now off
        NewChatMode: 'You chat mode has been changed to: '
        FchatoMissType: 'Error: Please use /fco factionname message.'
        FchatoNoOneOnline: 'Error: either no faction member is online or incorrect faction
          name'
    
     
  9. Offline

    Wingzzz

    Code:
    # Should the plugin autoupdate when there's a new version? Accepts boolean [true/false].
    # Should spy mode be on by default for those who have the correct permission node?
    # What language should the messages be in? Accepts 'english', 'french', 'german', or 'other'.
    All contain the invalid character '?'... Not sure if them being comments should affect it but might as well give it a shot and remove those...
    Also I don't believe the node
    Code:
    Chat colour:
    will be valid either due to there being a space in between the words... Either merge them or use a dash(-) or underscore(_):
    Code:
    ChatColour:
    # or
    Chat-Colour:
    # or
    Chat_Colour:
     
  10. Offline

    james137137

    ok I have made them changes. The weird thing is it only effect a few people; so far 3 people have reported it.
     
  11. Offline

    Wingzzz

    Did that solve it?
     
  12. Offline

    james137137

Thread Status:
Not open for further replies.

Share This Page