mirror of
https://github.com/GeyserMC/Floodgate.git
synced 2025-12-31 12:46:53 +00:00
Translate player messages
This commit is contained in:
@@ -33,14 +33,15 @@ import org.geysermc.floodgate.platform.command.CommandMessage;
|
||||
* Messages (or part of messages) that are used in two or more commands and thus are 'commonly used'
|
||||
*/
|
||||
public enum CommonCommandMessage implements CommandMessage {
|
||||
NOT_A_PLAYER("Please head over to your Minecraft Account and link from there."),
|
||||
CHECK_CONSOLE("Please check the console for more info!"),
|
||||
IS_LINKED_ERROR("&cError while checking if the given player is linked. " + CHECK_CONSOLE);
|
||||
NOT_A_PLAYER("floodgate.commands.not_a_player"),
|
||||
CHECK_CONSOLE("floodgate.commands.check_console"),
|
||||
// TODO used to also have console check
|
||||
IS_LINKED_ERROR("floodgate.commands.is_linked_error");
|
||||
|
||||
@Getter private final String message;
|
||||
|
||||
CommonCommandMessage(String message) {
|
||||
this.message = message.replace('&', COLOR_CHAR);
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -146,26 +146,22 @@ public final class LinkAccountCommand implements Command {
|
||||
}
|
||||
|
||||
public enum Message implements CommandMessage {
|
||||
ALREADY_LINKED("&cYour account is already linked!\n" +
|
||||
"&cIf you want to link to a different account, run &6/unlinkaccount&c and try it again."
|
||||
),
|
||||
JAVA_USAGE("&cUsage: /linkaccount <gamertag>"),
|
||||
LINK_REQUEST_CREATED("&aLog in as {} on Bedrock and run &6/linkaccount {} {}\n" +
|
||||
"&cWarning: Any progress on your Bedrock account will not be carried over! Save any items in your inventory first.\n" +
|
||||
"&cIf you change your mind you can run &6/unlinkaccount&c to get your progess back."
|
||||
),
|
||||
BEDROCK_USAGE("&cStart the process from Java! Usage: /linkaccount <gamertag>"),
|
||||
LINK_REQUEST_EXPIRED("&cThe code you entered is expired! Run &6/linkaccount&c again on your Java account"),
|
||||
LINK_REQUEST_COMPLETED("You are successfully linked to {}!\nIf you want to undo this run /unlinkaccount"),
|
||||
LINK_REQUEST_ERROR("&cAn error occurred while linking. " + CommonCommandMessage.CHECK_CONSOLE),
|
||||
INVALID_CODE("&cInvalid code! Please check your code or run the &6/linkaccount&c command again on your Java account."),
|
||||
NO_LINK_REQUESTED("&cThis player has not requested an account link! Please log in on Java and request one with &6/linkaccount"),
|
||||
LINK_REQUEST_DISABLED("&cLinking is not enabled on this server.");
|
||||
ALREADY_LINKED("floodgate.command.link_account.already_linked"),
|
||||
JAVA_USAGE("floodgate.command.link_account.java_usage"),
|
||||
LINK_REQUEST_CREATED("floodgate.command.link_account.link_request_created"),
|
||||
BEDROCK_USAGE("floodgate.command.link_account.bedrock_usage"),
|
||||
LINK_REQUEST_EXPIRED("floodgate.command.link_account.link_request_expired"),
|
||||
LINK_REQUEST_COMPLETED("floodgate.command.link_account.link_request_completed"),
|
||||
// TODO this also used to have another message
|
||||
LINK_REQUEST_ERROR("floodgate.command.link_request.error"),
|
||||
INVALID_CODE("floodgate.command.link_account.invalid_code"),
|
||||
NO_LINK_REQUESTED("floodgate.command.link_account.no_link_requested"),
|
||||
LINK_REQUEST_DISABLED("floodgate.command.link_request.disabled");
|
||||
|
||||
@Getter private final String message;
|
||||
|
||||
Message(String message) {
|
||||
this.message = message.replace('&', COLOR_CHAR);
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,15 +90,16 @@ public final class UnlinkAccountCommand implements Command {
|
||||
}
|
||||
|
||||
public enum Message implements CommandMessage {
|
||||
NOT_LINKED("&cYour account isn't linked"),
|
||||
UNLINK_SUCCESS("&cUnlink successful! Rejoin to return to your Bedrock account"),
|
||||
UNLINK_ERROR("&cAn error occurred while unlinking player! " + CommonCommandMessage.CHECK_CONSOLE),
|
||||
LINKING_NOT_ENABLED("&cLinking is not enabled on this server");
|
||||
NOT_LINKED("floodgate.command.unlink_account.not_linked"),
|
||||
UNLINK_SUCCESS("floodgate.command.unlink_account.unlink_success"),
|
||||
// TODO also used to have CHECK_CONSOLE
|
||||
UNLINK_ERROR("floodgate.command.unlink_account.error"),
|
||||
LINKING_NOT_ENABLED("floodgate.command.unlink_account.disabled");
|
||||
|
||||
@Getter private final String message;
|
||||
|
||||
Message(String message) {
|
||||
this.message = message.replace('&', COLOR_CHAR);
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,18 +38,19 @@ import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
|
||||
/**
|
||||
* Manages translations for strings in Floodgate
|
||||
*/
|
||||
public class LanguageManager {
|
||||
private final Map<String, Properties> LOCALE_MAPPINGS = new HashMap<>();
|
||||
|
||||
private final FloodgateLogger logger;
|
||||
|
||||
/**
|
||||
* The locale used in console and as a fallback
|
||||
*/
|
||||
private String defaultLocale;
|
||||
|
||||
private final Map<String, Properties> LOCALE_MAPPINGS = new HashMap<>();
|
||||
|
||||
private final FloodgateLogger logger;
|
||||
|
||||
public LanguageManager(FloodgateLogger logger) {
|
||||
this.logger = logger;
|
||||
}
|
||||
@@ -62,14 +63,16 @@ public class LanguageManager {
|
||||
public void initialize(FloodgateConfig config) {
|
||||
loadFloodgateLocale("en_US"); // Fallback
|
||||
|
||||
if (config.getDefaultLocale() != null && isValidLanguage(formatLocale(config.getDefaultLocale()))) {
|
||||
if (config.getDefaultLocale() != null &&
|
||||
isValidLanguage(formatLocale(config.getDefaultLocale()))) {
|
||||
loadFloodgateLocale(formatLocale(config.getDefaultLocale()));
|
||||
defaultLocale = formatLocale(config.getDefaultLocale());
|
||||
} else {
|
||||
String systemLocale = formatLocale(Locale.getDefault().getLanguage() + "_" + Locale.getDefault().getCountry());
|
||||
String systemLocale = formatLocale(Locale.getDefault().getLanguage() + "_" +
|
||||
Locale.getDefault().getCountry());
|
||||
if (isValidLanguage(systemLocale)) {
|
||||
loadFloodgateLocale(systemLocale);
|
||||
defaultLocale = formatLocale(systemLocale);
|
||||
defaultLocale = systemLocale;
|
||||
} else {
|
||||
defaultLocale = "en_US";
|
||||
}
|
||||
@@ -77,7 +80,7 @@ public class LanguageManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a Geyser locale from resources, if the file doesn't exist it just logs a warning
|
||||
* Loads a Floodgate locale from resources; if the file doesn't exist it just logs a warning
|
||||
*
|
||||
* @param locale Locale to load
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user