Added serverside config to add additional Mods to get synced
This commit is contained in:
parent
ffffeb78ee
commit
4f8840da68
3 changed files with 22 additions and 5 deletions
|
@ -4,6 +4,7 @@ import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
import net.fabricmc.loader.api.FabricLoader;
|
import net.fabricmc.loader.api.FabricLoader;
|
||||||
import ru.bclib.BCLib;
|
import ru.bclib.BCLib;
|
||||||
|
import ru.bclib.api.dataexchange.DataExchangeAPI;
|
||||||
import ru.bclib.api.dataexchange.SyncFileHash;
|
import ru.bclib.api.dataexchange.SyncFileHash;
|
||||||
import ru.bclib.config.ConfigUI;
|
import ru.bclib.config.ConfigUI;
|
||||||
import ru.bclib.config.Configs;
|
import ru.bclib.config.Configs;
|
||||||
|
@ -208,11 +209,21 @@ public class AutoSync {
|
||||||
return syncFolderContent;
|
return syncFolderContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
//we call this from HelloServer to prepare transfer
|
private static boolean didRegisterAdditionalMods = false;
|
||||||
|
//we call this from HelloClient on the Srérver to prepare transfer
|
||||||
protected static void loadSyncFolder() {
|
protected static void loadSyncFolder() {
|
||||||
if (Configs.MAIN_CONFIG.getBoolean(AutoSync.SYNC_CATEGORY, "offersSyncFolders", true)) {
|
if (Configs.SERVER_CONFIG.isOfferingFiles()) {
|
||||||
syncFolderDescriptions.forEach(desc -> desc.loadCache());
|
syncFolderDescriptions.forEach(desc -> desc.loadCache());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!didRegisterAdditionalMods && Configs.SERVER_CONFIG.isOfferingMods()){
|
||||||
|
didRegisterAdditionalMods = true;
|
||||||
|
List<String> modIDs = Configs.SERVER_CONFIG.get(ServerConfig.ADDITIONAL_MODS);
|
||||||
|
if (modIDs != null){
|
||||||
|
modIDs.stream().forEach(modID -> DataExchangeAPI.registerModDependency(modID));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static SyncFolderDescriptor getSyncFolderDescriptor(String folderID) {
|
protected static SyncFolderDescriptor getSyncFolderDescriptor(String folderID) {
|
||||||
|
|
|
@ -7,15 +7,20 @@ import ru.bclib.api.dataexchange.handler.autosync.AutoSync.ClientConfig;
|
||||||
import ru.bclib.api.dataexchange.handler.autosync.AutoSync.ServerConfig;
|
import ru.bclib.api.dataexchange.handler.autosync.AutoSync.ServerConfig;
|
||||||
|
|
||||||
public class Configs {
|
public class Configs {
|
||||||
|
// Client and Server-Config must be the first entries. They are not part of the Auto-Sync process
|
||||||
|
// But will be needed by other Auto-Sync Config-Files
|
||||||
|
@Environment(EnvType.CLIENT)
|
||||||
|
public static final ClientConfig CLIENT_CONFIG = new ClientConfig();
|
||||||
|
public static final ServerConfig SERVER_CONFIG = new ServerConfig();
|
||||||
|
|
||||||
|
|
||||||
public static final PathConfig GENERATOR_CONFIG = new PathConfig(BCLib.MOD_ID, "generator");
|
public static final PathConfig GENERATOR_CONFIG = new PathConfig(BCLib.MOD_ID, "generator");
|
||||||
public static final PathConfig MAIN_CONFIG = new PathConfig(BCLib.MOD_ID, "main", true, true);
|
public static final PathConfig MAIN_CONFIG = new PathConfig(BCLib.MOD_ID, "main", true, true);
|
||||||
public static final String MAIN_PATCH_CATEGORY = "patches";
|
public static final String MAIN_PATCH_CATEGORY = "patches";
|
||||||
|
|
||||||
public static final PathConfig RECIPE_CONFIG = new PathConfig(BCLib.MOD_ID, "recipes");
|
public static final PathConfig RECIPE_CONFIG = new PathConfig(BCLib.MOD_ID, "recipes");
|
||||||
|
|
||||||
@Environment(EnvType.CLIENT)
|
|
||||||
public static final ClientConfig CLIENT_CONFIG = new ClientConfig();
|
|
||||||
public static final ServerConfig SERVER_CONFIG = new ServerConfig();
|
|
||||||
|
|
||||||
public static void save() {
|
public static void save() {
|
||||||
MAIN_CONFIG.saveChanges();
|
MAIN_CONFIG.saveChanges();
|
||||||
|
|
|
@ -241,6 +241,7 @@ public class NamedPathConfig extends PathConfig{
|
||||||
public void set(ConfigToken<List<String>> what, List<String> value) {
|
public void set(ConfigToken<List<String>> what, List<String> value) {
|
||||||
this.setStringArray(what, value);
|
this.setStringArray(what, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<String> _getStringArray(ConfigToken<List<String>> what){
|
private List<String> _getStringArray(ConfigToken<List<String>> what){
|
||||||
return this.getStringArray(what, what.defaultValue);
|
return this.getStringArray(what, what.defaultValue);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue