Add missing Locale parameter to String.format calls, Fixes getArmorResource functionality on some locaales. (#8463)

This commit is contained in:
Take Weiland authored and GitHub committed 2022-02-15 09:27:10 -08:00
1 parent 21787234f4
commit c3e0b071a2
30 files changed
+107 -80

No files matched your search

@@ -351,7 +351,7 @@ public class ForgeRegistry<V extends IForgeRegistryEntry<V>> implements IForgeRe
idToUse = availabilityMap.nextClearBit(min);
if (idToUse > max)
throw new RuntimeException(String.format("Invalid id %d - maximum id range exceeded.", idToUse));
throw new RuntimeException(String.format(Locale.ENGLISH, "Invalid id %d - maximum id range exceeded.", idToUse));
V oldEntry = getRaw(key);
if (oldEntry == value) // already registered, return prev registration's id
@@ -362,9 +362,9 @@ public class ForgeRegistry<V extends IForgeRegistryEntry<V>> implements IForgeRe
if (oldEntry != null) // duplicate name
{
if (!this.allowOverrides)
throw new IllegalArgumentException(String.format("The name %s has been registered twice, for %s and %s.", key, getRaw(key), value));
throw new IllegalArgumentException(String.format(Locale.ENGLISH, "The name %s has been registered twice, for %s and %s.", key, getRaw(key), value));
if (owner == null)
throw new IllegalStateException(String.format("Could not determine owner for the override on %s. Value: %s", key, value));
throw new IllegalStateException(String.format(Locale.ENGLISH, "Could not determine owner for the override on %s. Value: %s", key, value));
LOGGER.debug(REGISTRIES,"Registry {} Override: {} {} -> {}", this.name, key, oldEntry, value);
idToUse = this.getID(oldEntry);
}
@@ -373,16 +373,16 @@ public class ForgeRegistry<V extends IForgeRegistryEntry<V>> implements IForgeRe
if (foundId != null)
{
V otherThing = this.ids.get(foundId);
throw new IllegalArgumentException(String.format("The object %s{%x} has been registered twice, using the names %s and %s. (Other object at this id is %s{%x})", value, System.identityHashCode(value), getKey(value), key, otherThing, System.identityHashCode(otherThing)));
throw new IllegalArgumentException(String.format(Locale.ENGLISH, "The object %s{%x} has been registered twice, using the names %s and %s. (Other object at this id is %s{%x})", value, System.identityHashCode(value), getKey(value), key, otherThing, System.identityHashCode(otherThing)));
}
if (isLocked())
throw new IllegalStateException(String.format("The object %s (name %s) is being added too late.", value, key));
throw new IllegalStateException(String.format(Locale.ENGLISH, "The object %s (name %s) is being added too late.", value, key));
if (defaultKey != null && defaultKey.equals(key))
{
if (this.defaultValue != null)
throw new IllegalStateException(String.format("Attemped to override already set default value. This is not allowed: The object %s (name %s)", value, key));
throw new IllegalStateException(String.format(Locale.ENGLISH, "Attemped to override already set default value. This is not allowed: The object %s (name %s)", value, key));
this.defaultValue = value;
}
@@ -432,7 +432,7 @@ public class ForgeRegistry<V extends IForgeRegistryEntry<V>> implements IForgeRe
void addAlias(ResourceLocation from, ResourceLocation to)
{
if (this.isLocked())
throw new IllegalStateException(String.format("Attempted to register the alias %s -> %s to late", from, to));
throw new IllegalStateException(String.format(Locale.ENGLISH, "Attempted to register the alias %s -> %s to late", from, to));
if (from.equals(to))
{
@@ -447,7 +447,7 @@ public class ForgeRegistry<V extends IForgeRegistryEntry<V>> implements IForgeRe
void addDummy(ResourceLocation key)
{
if (this.isLocked())
throw new IllegalStateException(String.format("Attempted to register the dummy %s to late", key));
throw new IllegalStateException(String.format(Locale.ENGLISH, "Attempted to register the dummy %s to late", key));
this.dummies.add(key);
LOGGER.trace(REGISTRIES,"Registry {} dummy: {}", this.name, key);
}
@@ -502,23 +502,23 @@ public class ForgeRegistry<V extends IForgeRegistryEntry<V>> implements IForgeRe
// name lookup failed -> obj is not in the obj<->name map
if (name == null)
throw new IllegalStateException(String.format("Registry entry for %s %s, id %d, doesn't yield a name.", registryName, obj, id));
throw new IllegalStateException(String.format(Locale.ENGLISH, "Registry entry for %s %s, id %d, doesn't yield a name.", registryName, obj, id));
// id is too high
if (id > max)
throw new IllegalStateException(String.format("Registry entry for %s %s, name %s uses the too large id %d.", registryName, obj, name, id));
throw new IllegalStateException(String.format(Locale.ENGLISH, "Registry entry for %s %s, name %s uses the too large id %d.", registryName, obj, name, id));
// id -> obj lookup is inconsistent
if (getValue(id) != obj)
throw new IllegalStateException(String.format("Registry entry for id %d, name %s, doesn't yield the expected %s %s.", id, name, registryName, obj));
throw new IllegalStateException(String.format(Locale.ENGLISH, "Registry entry for id %d, name %s, doesn't yield the expected %s %s.", id, name, registryName, obj));
// name -> obj lookup is inconsistent
if (getValue(name) != obj)
throw new IllegalStateException(String.format("Registry entry for name %s, id %d, doesn't yield the expected %s %s.", name, id, registryName, obj));
throw new IllegalStateException(String.format(Locale.ENGLISH, "Registry entry for name %s, id %d, doesn't yield the expected %s %s.", name, id, registryName, obj));
// name -> id lookup is inconsistent
if (getID(name) != id)
throw new IllegalStateException(String.format("Registry entry for name %s doesn't yield the expected id %d.", name, id));
throw new IllegalStateException(String.format(Locale.ENGLISH, "Registry entry for name %s doesn't yield the expected id %d.", name, id));
/*
// entry is blocked, thus should be empty
@@ -245,7 +245,7 @@ public class GameData
public static <K extends IForgeRegistryEntry<K>> K register_impl(K value)
{
Validate.notNull(value, "Attempted to register a null object");
Validate.notNull(value.getRegistryName(), String.format("Attempt to register object without having set a registry name %s (type %s)", value, value.getClass().getName()));
Validate.notNull(value.getRegistryName(), String.format(Locale.ENGLISH, "Attempt to register object without having set a registry name %s (type %s)", value, value.getClass().getName()));
final IForgeRegistry<K> registry = RegistryManager.ACTIVE.getRegistry(value.getRegistryType());
Validate.notNull(registry, "Attempted to registry object without creating registry first: " + value.getRegistryType().getName());
registry.register(value);
@@ -439,11 +439,11 @@ public class GameData
if (block.getRegistryName().getNamespace().equals("minecraft") && !oldContainer.getProperties().equals(newContainer.getProperties()))
{
String oldSequence = oldContainer.getProperties().stream()
.map(s -> String.format("%s={%s}", s.getName(),
.map(s -> String.format(Locale.ENGLISH, "%s={%s}", s.getName(),
s.getPossibleValues().stream().map(Object::toString).collect(Collectors.joining( "," ))))
.collect(Collectors.joining(";"));
String newSequence = newContainer.getProperties().stream()
.map(s -> String.format("%s={%s}", s.getName(),
.map(s -> String.format(Locale.ENGLISH, "%s={%s}", s.getName(),
s.getPossibleValues().stream().map(Object::toString).collect(Collectors.joining( "," ))))
.collect(Collectors.joining(";"));
@@ -634,7 +634,7 @@ public class GameData
PoiType oldType = map.put(state, obj);
if (oldType != null)
{
throw new IllegalStateException(String.format("Point of interest types %s and %s both list %s in their blockstates, this is not allowed. Blockstates can only have one point of interest type each.", oldType, obj, state));
throw new IllegalStateException(String.format(Locale.ENGLISH, "Point of interest types %s and %s both list %s in their blockstates, this is not allowed. Blockstates can only have one point of interest type each.", oldType, obj, state));
}
});
}
@@ -1,6 +1,6 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2021.
* Copyright (c) 2016-2022.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -23,6 +23,7 @@ import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.Collections;
import java.util.LinkedList;
import java.util.Locale;
import java.util.Queue;
import java.util.function.Consumer;
import java.util.function.Predicate;
@@ -92,7 +93,7 @@ class ObjectHolderRef implements Consumer<Predicate<ResourceLocation>>
if (this.injectedObject == null || !isValid())
{
throw new IllegalStateException(String.format("The ObjectHolder annotation cannot apply to a field that does not map to a registry. Ensure the registry was created during the RegistryEvent.NewRegistry event. (found : %s at %s.%s)", field.getType().getName(), field.getDeclaringClass().getName(), field.getName()));
throw new IllegalStateException(String.format(Locale.ENGLISH, "The ObjectHolder annotation cannot apply to a field that does not map to a registry. Ensure the registry was created during the RegistryEvent.NewRegistry event. (found : %s at %s.%s)", field.getType().getName(), field.getDeclaringClass().getName(), field.getName()));
}
field.setAccessible(true);