Jump to content

[1.10.2] Custom Config Files


opum2

Recommended Posts

I've figured out how to write to a .txt file in the config directory, but I would like to know: is it easy to make a custom config file with it's own sort of syntax? For example, a .txt file that has it's own formatting and then read the file and create something with that.

 

I am making a server utilities mod with a custom syntax for making certain things. I'm working on ranks and permissions configs first, but I want to make it in a custom syntax. I thought about using JSON, but I want it to be more unique.

 

I tried using the BufferedReader, but not really sure how that works.

 

I've seen other mods do this with .txt files. Just curious if there is any other efficient way to do this? I can get my code later today, but for now, I would like a bit of an explanation.

 

Thanks!

Link to comment
Share on other sites

That is just a Java thing it has nothing to do with forge, yes BufferedReader is what you want. Though you said you wanted your own syntax you will need to figure out how to make it read that syntax correctly and convert it into variables that can be manipulated and used in Java.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

Why do you want to use your own format? Is something wrong with any of the existing ones?

 

There's Forge's builtin configuration format (see

net.minecraftforge.common.config.Configuration

), there's JSON which can be used easily because Google's Gson is provided. There's also Typesafe's Config which is provided because Scala is present. You could also use Java's builtin properties system.

Don't make mods if you don't know Java.

Check out my website: http://shadowfacts.net

Developer of many mods

Link to comment
Share on other sites

Why do you want to use your own format? Is something wrong with any of the existing ones?

 

There's Forge's builtin configuration format (see

net.minecraftforge.common.config.Configuration

), there's JSON which can be used easily because Google's Gson is provided. There's also Typesafe's Config which is provided because Scala is present. You could also use Java's builtin properties system.

 

I make Forge configs all the time. I want to make a custom one for letting people make scripts.

Link to comment
Share on other sites

That is just a Java thing it has nothing to do with forge, yes BufferedReader is what you want. Though you said you wanted your own syntax you will need to figure out how to make it read that syntax correctly and convert it into variables that can be manipulated and used in Java.

 

I know that BufferedReader is a Java thing. Just not sure on how to use it. I want to make it read the file and then add something in game. For example, a player prefix in chat. I want people to enter a certain prefix and then it will show up in chat. I would also like to make permission groups have access to certain commands. Any ideas?

 

Thanks!

Link to comment
Share on other sites

You do not need a custom config format for any of those things.

Do you mean the scripting? Of course he doesn't, but if he wants to it is up to him alternatives have been given.

That is just a Java thing it has nothing to do with forge, yes BufferedReader is what you want. Though you said you wanted your own syntax you will need to figure out how to make it read that syntax correctly and convert it into variables that can be manipulated and used in Java.

 

I know that BufferedReader is a Java thing. Just not sure on how to use it. I want to make it read the file and then add something in game. For example, a player prefix in chat. I want people to enter a certain prefix and then it will show up in chat. I would also like to make permission groups have access to certain commands. Any ideas?

 

Thanks!

The prefix is a normal minecraft thing you would handle that the same way it does, if you dont know how it does that look here

Changing the players permission level has to do with ICommandSender implementation which i do not know how the player interprets the level so look into that.

 

For the reading and having something happen in game i would set tags like in Json look for those then there would be a string or number that you load for that tag ie

"ranks" {
     "owner" {
          "permLevel": 5,
          "prefix": "Owner"
     }
}

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

Do you mean the scripting?
No, I mean what he described in his previous post.

How would you recommend him doing it?

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

How would you recommend him doing it?
Simply using the forge configuration class.

Yes that would work. I don't know the specifics of which would be better, but Configuration provided by forge is easy to use, it is already there, and so far accomplishes everything he wants to do. So I would leave the decision up to him it all comes down to taking the already present way or him making his own.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.