Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

transform to lowercase using Locale.ROOT #21

Merged
merged 1 commit into from
Jul 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/main/java/galena/copperative/config/CommonConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.function.BooleanSupplier;
import java.util.function.Predicate;
Expand Down Expand Up @@ -129,7 +130,7 @@ public CommonConfig(ConfigBuilder builder) {
var property = builder.define("enabled", true);
var targets = ImmutableMap.<OverrideTarget, BooleanSupplier>builder();
for (OverrideTarget target : OverrideTarget.values()) {
var targetProperty = builder.define(target.name().toLowerCase(), true);
var targetProperty = builder.define(target.name().toLowerCase(Locale.ROOT), true);
targets.put(target, targetProperty::get);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import net.minecraftforge.registries.ForgeRegistries;

import javax.annotation.Nullable;
import java.util.Locale;
import java.util.Objects;

public class OverwriteEnabledCondition implements ICondition {
Expand Down Expand Up @@ -47,7 +48,7 @@ public static class Serializer implements IConditionSerializer<OverwriteEnabledC
@Override
public void write(JsonObject json, OverwriteEnabledCondition value) {
json.addProperty("block", value.key.toString());
if (value.target != null) json.addProperty("target", value.target.name().toLowerCase());
if (value.target != null) json.addProperty("target", value.target.name().toLowerCase(Locale.ROOT));
}

@Override
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/galena/copperative/data/CLang.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import net.minecraftforge.registries.RegistryObject;

import java.util.List;
import java.util.Locale;

public class CLang extends CLangProvider {

Expand All @@ -20,7 +21,7 @@ public void withWeatheredPrefix(List<RegistryObject<Block>> blocks, String base)
blocks.forEach(block -> {
if(block.get() instanceof WeatheringCopper copper && copper.getAge() != WeatheringCopper.WeatherState.UNAFFECTED) {
var name = copper.getAge().name();
var prefix = name.substring(0, 1).toUpperCase() + name.substring(1).toLowerCase();
var prefix = name.substring(0, 1).toUpperCase() + name.substring(1).toLowerCase(Locale.ROOT);
addBlock(block, prefix + " " + base);
} else {
addBlock(block, base);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.function.Supplier;

public abstract class CItemModelProvider extends ItemModelProvider {
Expand Down Expand Up @@ -151,7 +152,7 @@ public ItemModelBuilder cogBlock(Block block) {
public String weatherPrefix(Block block) {
if (block instanceof WeatheringCopper it) {
var age = it.getAge();
if (age != WeatheringCopper.WeatherState.UNAFFECTED) return age.name().toLowerCase() + "_";
if (age != WeatheringCopper.WeatherState.UNAFFECTED) return age.name().toLowerCase(Locale.ROOT) + "_";
}
return "";
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/galena/copperative/index/CBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public static <B extends Block> RegistryObject<B> register(String name, Supplier

public static <B extends Block> CopperSet<B> registerConvertedSet(String name, Supplier<B> targetSupplier, Function<WeatherState, B> function, ResourceKey<CreativeModeTab> tab) {
var weathered = Stream.of(WeatherState.EXPOSED, WeatherState.WEATHERED, WeatherState.OXIDIZED).<Supplier<B>>map(weatherState -> {
String prefix = weatherState.name().toLowerCase() + "_";
String prefix = weatherState.name().toLowerCase(Locale.ROOT) + "_";
return register(prefix + name, () -> function.apply(weatherState), tab);
}).toList();
return new CopperSet<>(targetSupplier, weathered);
Expand All @@ -164,7 +164,7 @@ public static <B extends Block> List<RegistryObject<B>> registerWeatheringSet(Un
WeatherState[] wStates = WeatherState.values();
ArrayList<RegistryObject<B>> blocks = new ArrayList<>(4);
for (final WeatherState weatherState : wStates) {
String prefix = weatherState.equals(WeatherState.UNAFFECTED) ? "" : weatherState.name().toLowerCase() + "_";
String prefix = weatherState.equals(WeatherState.UNAFFECTED) ? "" : weatherState.name().toLowerCase(Locale.ROOT) + "_";
Supplier<? extends B> supplier = () -> function.apply(weatherState);
blocks.add(register(name.apply(prefix), supplier, tab));
}
Expand Down