Jump to content
  • Home
  • Files
  • Docs
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Minecraft Forge
  • Support & Bug Reports
  • Forge 1236 - Config Comments Unexpected Behavior
Currently Supported: 1.16.X (Latest) and 1.15.X (LTS)
Sign in to follow this  
Followers 0
Draco18s

Forge 1236 - Config Comments Unexpected Behavior

By Draco18s, November 24, 2014 in Support & Bug Reports

  • Start new topic

Recommended Posts

Draco18s    2417

Draco18s

Draco18s    2417

  • Reality Controller
  • Draco18s
  • Members
  • 2417
  • 16012 posts
Posted November 24, 2014

Not sure if a bug or Working as Intended (but in an unexpected manner).

 

So I was setting up the configs for a mod I'm working on and figured out I needed to comment a few settings.  So I added comments, similar to how Test1 is set up below.  The comment wasn't saving and no amount of config.save() calls in and around the line would cause it to do so.  The only way I could get it to save was to save the Property to a variable (Test 2).

 

    @EventHandler
    public void preInit(FMLPreInitializationEvent event) {
    	Configuration config = new Configuration(event.getSuggestedConfigurationFile());
    	
    	boolean configBool;
    	int configInt;
    	
    	/*Test 1*/
    	configBool = config.get("Test1", "boolTest", false).getBoolean();
        config.get("Test1", "intTest", 6).comment = "This is a comment on intTest for test 1.\nIt has several lines of comment to avoid text wrap and will not show up in the config file.\nMin 1, Max 12, Default 6.";
        configInt = Math.min(Math.max(config.get("Test1", "intTest", 6).getInt(), 1), 12);
    	
        /*Test 2*/
    	configBool = config.get("Test2", "boolTest", false).getBoolean();
        Property prop = config.get("Test2", "intTest", 6);
        prop.comment = "This is a comment on intTest for test 2.\nIt has several lines of comment to avoid text wrap and will show up in the config file.\nMin 1, Max 12, Default 6.";
        configInt = Math.min(Math.max(prop.getInt(), 1), 12);
    	config.save();
    }

 

And the resulting config file generated:

 

# Configuration file

test1 {
    B:boolTest=false
    I:intTest=6
}


test2 {
    B:boolTest=false

    # This is a comment on intTest for test 2.
    # It has several lines of comment to avoid text wrap and will show up in the config file.
    # Min 1, Max 12, Default 6.
    I:intTest=6
}

 

I realize that Test 2 is better practice (due to caching the Property instead of calling get() twice) but it seems to me that both methods should save the comment to the file, yet the former does not.


Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Share this post


Link to post
Share on other sites

diesieben07    7706

diesieben07

diesieben07    7706

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7706
  • 56508 posts
Posted November 24, 2014

If you call the overloaded version of

get

, which does not take a comment, it assumes "no comment". So if you call

get

the 2nd time it resets the previously set comment.

Share this post


Link to post
Share on other sites

Draco18s    2417

Draco18s

Draco18s    2417

  • Reality Controller
  • Draco18s
  • Members
  • 2417
  • 16012 posts
Posted November 24, 2014

Ah!  I didn't see that there was a comment-passed version.  That makes so much more sense.

 

The JavaDoc window that pops up auto-complete suggestions is not very wide, so anything beyond "string name" gets cut off and I've been using that particular getter for a while now (easily as far back as 1.6.2 if not earlier).

 

Thanks as always, diesieben07!


Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  
Followers 0
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • Pixelovski
      Stuck on "Configuration file X is not correct. Correcting"

      By Pixelovski · Posted 1 minute ago

      Hello, My friends and I just bought a Minecraft hosting to use with forge. And we're encountering problem where the server starts fine, we can connect, but it just keeps spitting out warnings about incorrect config files and it's really annoying and I think it eats up some resources... When we tried forge by itself without any mods there wasn't any issue. When I try to run the server with the exact same files on my pc it works fine. So is there way to just stop the server from trying to correct the config files (or whatever it is that it is doing) or something? Thank you in advance.   Here is the link to the latest log file: https://www.dropbox.com/s/1ni8tko383q4mlg/2021-03-07-10.log?dl=0
    • Nyko
      [1.16.5] overwriting the maximum build height

      By Nyko · Posted 3 minutes ago

      thanks for the info, since the whole thing sounds pretty complicated, I will probably not change it
    • ChocoCookies33
      Description: Exception in server tick loop

      By ChocoCookies33 · Posted 16 minutes ago

      local server set up not working, help is appreciated.  crash-2021-03-07_00.55.37-server.txt
    • LessyDoggy
      Forge 1.12.2 Installing Bug

      By LessyDoggy · Posted 1 hour ago

      So I used forge 1.16.5 but now I cant change it too 1.12.2 no mather what. I have tried Installing client, Installing server and extract but nothing works. I even removed forge 1.16.5 from my computer but I still have that verison on and idk how to change it.
    • Yourskillx2
      !!Keeps crashing during launch!!

      By Yourskillx2 · Posted 2 hours ago

      I have a decent sized mod pack with around 90 mods and every time I go to launch the game, it loads some stuff then crashes with exit code 0, I cannot figure out if its a mod in the pack doing it, like maybe not a release version or if it just doesn't work with Mc like its supposed to.
  • Topics

    • Pixelovski
      0
      Stuck on "Configuration file X is not correct. Correcting"

      By Pixelovski
      Started 1 minute ago

    • Nyko
      4
      [1.16.5] overwriting the maximum build height

      By Nyko
      Started 14 hours ago

    • ChocoCookies33
      0
      Description: Exception in server tick loop

      By ChocoCookies33
      Started 16 minutes ago

    • LessyDoggy
      0
      Forge 1.12.2 Installing Bug

      By LessyDoggy
      Started 1 hour ago

    • Yourskillx2
      0
      !!Keeps crashing during launch!!

      By Yourskillx2
      Started 2 hours ago

  • Who's Online (See full list)

    • Pixelovski
    • Kreepydude
    • loordgek
    • Nyko
    • zlappedx3
    • Helios885
    • ChocoCookies33
    • vemerion
  • All Activity
  • Home
  • Minecraft Forge
  • Support & Bug Reports
  • Forge 1236 - Config Comments Unexpected Behavior
  • Theme

Copyright © 2019 ForgeDevelopment LLC · Ads by Longitude Ads LLC Powered by Invision Community