Clean-up translation string implementation (#1567)

This commit is contained in:
rtm516 2020-11-21 00:44:33 +00:00 committed by GitHub
parent 67d5993ae1
commit 0268ef7d2b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 21 deletions

View file

@ -32,7 +32,6 @@ import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.renderer.TranslatableComponentRenderer; import net.kyori.adventure.text.renderer.TranslatableComponentRenderer;
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import net.kyori.adventure.translation.TranslationRegistry;
import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.utils.LanguageUtils; import org.geysermc.connector.utils.LanguageUtils;
@ -41,8 +40,7 @@ import java.util.*;
public class MessageTranslator { public class MessageTranslator {
// These are used for handling the translations of the messages // These are used for handling the translations of the messages
private static final TranslationRegistry REGISTRY = new MinecraftTranslationRegistry(); private static final TranslatableComponentRenderer<Locale> RENDERER = TranslatableComponentRenderer.usingTranslationSource(new MinecraftTranslationRegistry());
private static final TranslatableComponentRenderer<Locale> RENDERER = TranslatableComponentRenderer.usingTranslationSource(REGISTRY);
// Store team colors for player names // Store team colors for player names
private static final Map<TeamColor, String> TEAM_COLORS = new HashMap<>(); private static final Map<TeamColor, String> TEAM_COLORS = new HashMap<>();

View file

@ -26,7 +26,7 @@
package org.geysermc.connector.network.translators.chat; package org.geysermc.connector.network.translators.chat;
import net.kyori.adventure.key.Key; import net.kyori.adventure.key.Key;
import net.kyori.adventure.translation.TranslationRegistry; import net.kyori.adventure.translation.Translator;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.checker.nullness.qual.Nullable;
import org.geysermc.connector.utils.LocaleUtils; import org.geysermc.connector.utils.LocaleUtils;
@ -40,10 +40,10 @@ import java.util.regex.Pattern;
* This class is used for mapping a translation key with the already loaded Java locale data * This class is used for mapping a translation key with the already loaded Java locale data
* Used in MessageTranslator.java as part of the KyoriPowered/Adventure library * Used in MessageTranslator.java as part of the KyoriPowered/Adventure library
*/ */
public class MinecraftTranslationRegistry implements TranslationRegistry { public class MinecraftTranslationRegistry implements Translator {
@Override @Override
public @NonNull Key name() { public @NonNull Key name() {
return Key.key("", ""); return Key.key("geyser", "minecraft_translations");
} }
@Override @Override
@ -73,19 +73,4 @@ public class MinecraftTranslationRegistry implements TranslationRegistry {
return new MessageFormat(sb.toString(), locale); return new MessageFormat(sb.toString(), locale);
} }
@Override
public void defaultLocale(@NonNull Locale locale) {
}
@Override
public void register(@NonNull String key, @NonNull Locale locale, @NonNull MessageFormat format) {
}
@Override
public void unregister(@NonNull String key) {
}
} }