Skip to content

Commit

Permalink
gross workaround to avoid accessing I18n on the dedicated server
Browse files Browse the repository at this point in the history
  • Loading branch information
DaMatrix committed Feb 17, 2022
1 parent 396ac70 commit 290e77a
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,11 @@
import net.minecraftforge.common.config.Config;
import net.minecraftforge.common.config.ConfigManager;
import net.minecraftforge.fml.client.event.ConfigChangedEvent;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.server.command.CommandTreeBase;
import net.minecraftforge.server.permission.DefaultPermissionLevel;
import net.minecraftforge.server.permission.PermissionAPI;
Expand Down Expand Up @@ -463,8 +465,16 @@ public SetConfig(String name, @Nullable Object object, Field field, boolean requ
return name;
}

@SuppressWarnings("deprecation")
@Override public String getUsage(ICommandSender sender) {
return I18n.format("cubicchunks.command.usage.config.set_option", name);
if (FMLCommonHandler.instance().getSide() == Side.CLIENT) {
return I18n.format("cubicchunks.command.usage.config.set_option", name);
} else {
//we have to use this on the dedicated server, as the client I18n class isn't available there...
// unfortunately this could result in a client being sent a string in a language other than their configured locale, but i don't
// see any alternative other than adding separate translation keys for every single config option
return net.minecraft.util.text.translation.I18n.translateToLocalFormatted("cubicchunks.command.usage.config.set_option", name);
}
}

@Override
Expand Down

0 comments on commit 290e77a

Please sign in to comment.