Added Mod#getConfigFolder

This commit is contained in:
Anuken 2024-04-15 12:54:07 -04:00
parent 663209b23e
commit b7fab3839a
2 changed files with 15 additions and 4 deletions

View File

@ -6,6 +6,11 @@ import mindustry.*;
public abstract class Mod{
/** @return the folder where configuration files for this mod should go.*/
public Fi getConfigFolder(){
return Vars.mods.getConfigFolder(this);
}
/** @return the config file for this plugin, as the file 'mods/[plugin-name]/config.json'.*/
public Fi getConfig(){
return Vars.mods.getConfig(this);
@ -26,7 +31,7 @@ public abstract class Mod{
}
/** Register any commands to be used on the client side, e.g. sent from an in-game player.. */
/** Register any commands to be used on the client side, e.g. sent from an in-game player. */
public void registerClientCommands(CommandHandler handler){
}

View File

@ -62,12 +62,18 @@ public class Mods implements Loadable{
return mainLoader;
}
/** Returns a file named 'config.json' in a special folder for the specified plugin.
/** @return the folder where configuration files for this mod should go. The folder may not exist yet; call mkdirs() before writing to it.
* Call this in init(). */
public Fi getConfig(Mod mod){
public Fi getConfigFolder(Mod mod){
ModMeta load = metas.get(mod.getClass());
if(load == null) throw new IllegalArgumentException("Mod is not loaded yet (or missing)!");
return modDirectory.child(load.name).child("config.json");
return modDirectory.child(load.name);
}
/** @return a file named 'config.json' in the config folder for the specified mod.
* Call this in init(). */
public Fi getConfig(Mod mod){
return getConfigFolder(mod).child("config.json");
}
/** Returns a list of files per mod subdirectory. */