[Release]EasyModConfig
Featured Replies
Сейчас на странице 0
- Нет пользователей, просматривающих эту страницу
A better way to browse. Learn more.
A full-screen app on your home screen with push notifications, badges and more.
Используя этот сайт, вы соглашаетесь Условия использования.
First of all:
This is NOT a Mod, it is a tool for Mod-Creators.
I made this to sum up every config for a mod into one File. Also it is now reall easy to read from text-files.
Also because it was a great function in the ServerAddon @itsmods
How to use it(Instructions for the File-Layout):
How to add it in your Mod:
/**Searched through the mod_config.ini. *@ param Section The Section where the Variablename is located *@ param VariableName The Variablename *@ param DefaultValue This Value is beeing returned when there is no mod_config.ini or the Section could not be found or the VariableName could not be found */ static public String getServerConfig(String Section, String VariableName, String DefaultValue) { string Path = "admin\\mod_config.ini"; if (!File.Exists(Path)) return DefaultValue; StreamReader sr = new StreamReader(Path); bool InSection = false; for (String line = sr.ReadLine(); line != null; line = sr.ReadLine()) { //***** SEARCHING THE CORRECT SECTION if (!InSection && line.StartsWith("[")) { line = line.Substring(1, line.Length - 2); if (line.CompareTo(Section) != 0) continue; InSection = true; continue; } //***** SEARCHING THE CORRECT SECTION if (!InSection) continue; //***** EXITING WHEN ANOTHER SECTION BEGINS if (InSection && line.StartsWith("[")) { return DefaultValue; } //***** EXITING WHEN ANOTHER SECTION BEGINS //***** SEARCHING FOR THE VARIABLE NAME AND GRABBING THE VALUE if (InSection) { String[] splitted = line.Split('='); if (splitted.Length != 2) continue; if (splitted[0].CompareTo(VariableName) != 0) continue; return splitted[1]; } //***** SEARCHING FOR THE VARIABLE NAME AND GRABBING THE VALUE } return DefaultValue; }int jumpheight=getServerConfig("MyHighJumpMod","JumpHeight","45");