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

Added translations as primary dimName source #19

Merged
merged 3 commits into from
Mar 14, 2024
Merged
Changes from 1 commit
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
19 changes: 18 additions & 1 deletion src/main/java/journeymap/client/data/WorldData.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.google.common.base.Strings;
import com.google.common.cache.CacheLoader;
import cpw.mods.fml.client.FMLClientHandler;
import gnu.trove.map.hash.TIntObjectHashMap;
import journeymap.client.Constants;
import journeymap.client.JourneymapClient;
import journeymap.client.feature.Feature;
Expand Down Expand Up @@ -46,6 +47,7 @@ public class WorldData extends CacheLoader<Class, WorldData>
{
String name;
int dimension;
static private TIntObjectHashMap<String> dimNames;
AnrDaemon marked this conversation as resolved.
Show resolved Hide resolved
long time;
boolean hardcore;
boolean singlePlayer;
Expand Down Expand Up @@ -285,10 +287,25 @@ public static String getSafeDimensionName(WorldProvider worldProvider)

try
{
return worldProvider.getDimensionName();
if (dimNames == null) {
dimNames = new TIntObjectHashMap<String>();
AnrDaemon marked this conversation as resolved.
Show resolved Hide resolved
}
if (dimNames.containsKey(worldProvider.dimensionId)) {
return dimNames.get(worldProvider.dimensionId);
}

String langKey = String.format("jm.dimension.%1$d.name", worldProvider.dimensionId);
AnrDaemon marked this conversation as resolved.
Show resolved Hide resolved
String dimName = Constants.getString(langKey);
if (dimName.equals(langKey))
AnrDaemon marked this conversation as resolved.
Show resolved Hide resolved
{
dimName = worldProvider.getDimensionName();
}

return dimNames.put(worldProvider.dimensionId, dimName);
}
catch (Exception e)
{
JMLogger.logOnce(String.format("Failed to retrieve dimension %d name: error: %s", worldProvider.dimensionId, e), e);
AnrDaemon marked this conversation as resolved.
Show resolved Hide resolved
return Constants.getString("jm.common.dimension", ForgeHelper.INSTANCE.getDimension(worldProvider));
}
}
Expand Down