Skip to content

Commit

Permalink
windows was a mistake
Browse files Browse the repository at this point in the history
  • Loading branch information
Bawnorton committed Oct 22, 2024
1 parent 23bd8ab commit b01b89b
Show file tree
Hide file tree
Showing 13 changed files with 56 additions and 50 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 2.1.3

- Fix config failing to be located on windows

# 2.1.1

- Use zip reader for more reliable config reading
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ org.gradle.jvmargs=-Xmx4G
fabric_versions=1.20.1, 1.21.1
neoforge_versions=1.21.1

mod_version=2.1.2
mod_version=2.1.3
mod_group=com.bawnorton
mod_id=configurable
mod_name=Configurable
Expand Down
22 changes: 12 additions & 10 deletions src/main/java/com/bawnorton/configurable/ConfigurableMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,20 @@ public static void init() {

Platform.forEachJar(path -> {
//? if neoforge {
/*List<Path> sourceSetSettings = new ArrayList<>();
List<String> sourceSetSettings = new ArrayList<>();
try (ZipFile zipFile = new ZipFile(path.toFile())) {
zipFile.stream()
.filter(entry -> entry.getName().startsWith("configurable/") && !entry.isDirectory())
.forEach(entry -> {
Path filePath = Paths.get(entry.getName());
sourceSetSettings.add(filePath);
});
for (Path sourceSetSetting : sourceSetSettings) {
.forEach(entry -> sourceSetSettings.add(entry.getName()));
for (String sourceSetSetting : sourceSetSettings) {
ConfigurableSettings settings;
try {
try (InputStream is = zipFile.getInputStream(zipFile.getEntry(sourceSetSetting.toString()))) {
ZipEntry entry = zipFile.getEntry(sourceSetSetting);
if(entry == null) {
LOGGER.warn("Could not find configurable setting {} in {}", sourceSetSetting, path);
continue;
}
try (InputStream is = zipFile.getInputStream(entry)) {
settings = GSON.fromJson(new InputStreamReader(is), ConfigurableSettings.class);
}
} catch (IOException e) {
Expand Down Expand Up @@ -92,8 +94,8 @@ public static void init() {
}
}
} catch (IOException ignored) {}
*///?} else {
Path configurable = path.resolve("configurable");
//?} else {
/*Path configurable = path.resolve("configurable");
if (!(Files.exists(configurable) && Files.isDirectory(configurable))) return;
List<Path> sourceSetSettings = new ArrayList<>();
Expand Down Expand Up @@ -133,7 +135,7 @@ public static void init() {
LOGGER.error("Could not create configurable wrapper for \"%s\"".formatted(configName), e);
}
}
//?}
*///?}
});
WRAPPERS.values().forEach(sourceSetWrappers -> sourceSetWrappers.values().forEach(wrapper -> {
wrapper.loadConfig();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

//? if fabric {

import com.google.gson.Gson;
/*import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject;
import javax.annotation.processing.Filer;
Expand Down Expand Up @@ -46,4 +46,4 @@ public String getName() {
return fmj.get("id").getAsString();
}
}
//?}
*///?}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

//? if neoforge {

/*import com.electronwill.nightconfig.core.Config;
import com.electronwill.nightconfig.core.Config;
import com.electronwill.nightconfig.toml.TomlParser;
import javax.annotation.processing.Filer;
import java.io.IOException;
Expand Down Expand Up @@ -42,4 +42,4 @@ public String getName() {
return config.<ArrayList<Config>>get("mods").getFirst().get("modId");
}
}
*///?}
//?}
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ public final class SourceProviders {

public static void registerDefaultSourceProviders() {
//? if fabric
registerSourceProvider(FabricSourceProvider::new);
/*registerSourceProvider(FabricSourceProvider::new);*/
//? if neoforge
/*registerSourceProvider(NeoForgeSourceProvider::new);*/
registerSourceProvider(NeoForgeSourceProvider::new);
}

public static void registerSourceProvider(SourceProviderFactory factory) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ default FieldNamingStrategy defaultFieldNamingStrategy() {
}

//? if !fabric {
/*/^*
/**
* The name of the config this API impl belongs to, this is necessary for non-fabric implementations
* <br>
* <b>THIS DOES NOT SET THE NAME OF THE CONFIG</b>
^/
*/
default String getConfigName() {
throw new UnsupportedOperationException();
}
*///?}
//?}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import org.spongepowered.asm.mixin.Mixin;

//? if fabric {
import com.bawnorton.configurable.ConfigurableMain;
/*import com.bawnorton.configurable.ConfigurableMain;
import com.bawnorton.configurable.load.ConfigurableWrapper;
import com.terraformersmc.modmenu.ModMenu;
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
Expand All @@ -25,10 +25,10 @@ public abstract class ModMenuMixin {
@Shadow @Final private static List<ModMenuApi> apiImplementations;
//?} else {
/*@Shadow private static Map<String, ConfigScreenFactory<?>> configScreenFactories;
/^@Shadow private static Map<String, ConfigScreenFactory<?>> configScreenFactories;
@Shadow private static List<Map<String, ConfigScreenFactory<?>>> delayedScreenFactoryProviders;
*///?}
^///?}
@Inject(
Expand Down Expand Up @@ -59,14 +59,14 @@ public ConfigScreenFactory<?> getModConfigScreenFactory() {
//? if >=1.21 {
apiImplementations.add(api);
//?} else {
/*delayedScreenFactoryProviders.add(api.getProvidedConfigScreenFactories());
*///?}
/^delayedScreenFactoryProviders.add(api.getProvidedConfigScreenFactories());
^///?}
}));
}
}
//?} else {
/*import com.bawnorton.configurable.client.ConfigurableClient;
*///?} else {
import com.bawnorton.configurable.client.ConfigurableClient;

@Mixin(ConfigurableClient.class)
public abstract class ModMenuMixin {}
*///?}
//?}
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
import com.bawnorton.configurable.client.ConfigurableClient;

//? if fabric {
import net.fabricmc.api.ClientModInitializer;
/*import net.fabricmc.api.ClientModInitializer;
public final class ConfigurableClientWrapper implements ClientModInitializer {
@Override
public void onInitializeClient() {
ConfigurableClient.init();
}
}
//?} elif neoforge {
/*import com.bawnorton.configurable.ConfigurableMain;
*///?} elif neoforge {
import com.bawnorton.configurable.ConfigurableMain;
import com.bawnorton.configurable.platform.Platform;
import net.minecraft.client.MinecraftClient;
import net.neoforged.api.distmarker.Dist;
Expand Down Expand Up @@ -43,4 +43,4 @@ public ConfigurableClientWrapper() {
}));
}
}
*///?}
//?}
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,29 @@
import java.util.Map;

//? if fabric {
import net.fabricmc.loader.api.FabricLoader;
//?} elif neoforge {
/*import java.util.ServiceLoader;
*///?}
/*import net.fabricmc.loader.api.FabricLoader;
*///?} elif neoforge {
import java.util.ServiceLoader;
//?}

public final class ConfigurableApiImplLoader {
//? if neoforge
/*private static final ServiceLoader<ConfigurableApi> serviceLoader = ServiceLoader.load(ConfigurableApi.class);*/
private static final ServiceLoader<ConfigurableApi> serviceLoader = ServiceLoader.load(ConfigurableApi.class);
private static final Map<String, ConfigurableApi> impls = new HashMap<>();

public static void load() {
//? if fabric {
FabricLoader.getInstance().getEntrypointContainers("configurable", ConfigurableApi.class).forEach(container -> {
/*FabricLoader.getInstance().getEntrypointContainers("configurable", ConfigurableApi.class).forEach(container -> {
String id = container.getProvider().getMetadata().getId();
try {
impls.put(id, container.getEntrypoint());
} catch (Throwable e) {
ConfigurableMain.LOGGER.error("Mod {} provides a broken ConfigurableApi implemenation", id, e);
}
});
//?} elif neoforge {
/*serviceLoader.forEach(apiImpl -> impls.put(apiImpl.getConfigName(), apiImpl));
*///?}
*///?} elif neoforge {
serviceLoader.forEach(apiImpl -> impls.put(apiImpl.getConfigName(), apiImpl));
//?}
}

public static ConfigurableApi getImpl(String name) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@
import com.bawnorton.configurable.ConfigurableMain;

//? if fabric {
import net.fabricmc.api.ModInitializer;
/*import net.fabricmc.api.ModInitializer;
public final class ConfigurableMainWrapper implements ModInitializer {
@Override
public void onInitialize() {
ConfigurableMain.init();
}
}
//?} elif neoforge {
/*import net.neoforged.fml.common.Mod;
*///?} elif neoforge {
import net.neoforged.fml.common.Mod;

@Mod(ConfigurableMain.MOD_ID)
public final class ConfigurableMainWrapper {
public ConfigurableMainWrapper() {
ConfigurableMain.init();
}
}
*///?}
//?}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import java.util.function.Consumer;

//? if fabric {
import net.fabricmc.api.EnvType;
/*import net.fabricmc.api.EnvType;
import net.fabricmc.loader.api.FabricLoader;
import java.util.List;
Expand Down Expand Up @@ -35,8 +35,8 @@ public static boolean isServer() {
}
}
//?} elif neoforge {
/*import net.neoforged.fml.ModContainer;
*///?} elif neoforge {
import net.neoforged.fml.ModContainer;
import net.neoforged.fml.loading.FMLEnvironment;
import net.neoforged.fml.loading.FMLPaths;
import net.neoforged.fml.loading.LoadingModList;
Expand Down Expand Up @@ -80,4 +80,4 @@ public static boolean isServer() {
return FMLEnvironment.dist.isDedicatedServer();
}
}
*///?}
//?}
2 changes: 1 addition & 1 deletion stonecutter.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
id("dev.kikugie.stonecutter")
}
stonecutter active "1.21.1-fabric-yarn" /* [SC] DO NOT EDIT */
stonecutter active "1.21.1-neoforge-yarn" /* [SC] DO NOT EDIT */

stonecutter registerChiseled tasks.register("chiseledBuildAndCollect", stonecutter.chiseled) {
group = "project"
Expand Down

0 comments on commit b01b89b

Please sign in to comment.