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

[i18n] Remaining GlowServer messages #883

Merged
merged 13 commits into from Mar 27, 2018
109 changes: 70 additions & 39 deletions src/main/java/net/glowstone/GlowServer.java
Expand Up @@ -118,8 +118,10 @@
import net.glowstone.io.anvil.AnvilWorldStorageProvider;
import net.glowstone.map.GlowMapView;
import net.glowstone.net.GameServer;
import net.glowstone.net.GlowSession;
import net.glowstone.net.SessionRegistry;
import net.glowstone.net.message.play.player.AdvancementsMessage;
import net.glowstone.net.message.status.StatusRequestMessage;
import net.glowstone.net.query.QueryServer;
import net.glowstone.net.rcon.RconServer;
import net.glowstone.scheduler.GlowScheduler;
Expand Down Expand Up @@ -623,8 +625,7 @@ public void start() {
logger.info(strings.getString("console.info.proxy"));
}
} else if (!getOnlineMode()) {
logger.warning("The server is running in offline mode! Only do this if you know what "
+ "you're doing.");
logger.warning(strings.getString("console.warn.offline"));
}

int openClMajor = 1;
Expand Down Expand Up @@ -686,7 +687,9 @@ public void start() {
}
} else {
int flops = device.getMaxComputeUnits() * device.getMaxClockFrequency();
logger.info("Found " + device + " with " + flops + " flops");
logger.info(MessageFormat.format(
strings.getString("console.info.opencl.found-device"), device,
flops));
if (flops > maxCpuFlops) {
maxCpuFlops = flops;
logger.info(MessageFormat.format(
Expand Down Expand Up @@ -889,7 +892,7 @@ private void bind() {
try {
latch.await();
} catch (InterruptedException e) {
logger.log(Level.SEVERE, "Bind interrupted! ", e);
logger.log(Level.SEVERE, strings.getString("console.error.rcon.bind-interrupted"), e);
System.exit(1);
}
}
Expand Down Expand Up @@ -920,7 +923,7 @@ public void shutdown() {
return;
}
isShuttingDown = true;
logger.info("The server is shutting down...");
logger.info(strings.getString("console.info.shutdown"));

// Disable plugins
pluginManager.clearPlugins();
Expand All @@ -944,7 +947,8 @@ public void shutdown() {

// Save worlds
for (World world : getWorlds()) {
logger.info("Saving world: " + world.getName());
logger.info(
MessageFormat.format(strings.getString("console.info.save"), world.getName()));
unloadWorld(world, true);
}

Expand Down Expand Up @@ -988,17 +992,21 @@ private void loadConfig() {
File vanillaServerIcon = new File(SERVER_ICON_FILE);
if (vanillaServerIcon.isFile()) {
// Import from Vanilla
logger.info("Importing '" + SERVER_ICON_FILE + "' from Vanilla.");
logger.info(MessageFormat.format(
strings.getString("console.info.icon.import"), SERVER_ICON_FILE));
Files.copy(vanillaServerIcon.toPath(), serverIconFile.toPath());
defaultIcon = new GlowServerIcon(serverIconFile);
}
} catch (Exception e) {
logger.log(Level.WARNING,
"Failed to import '" + SERVER_ICON_FILE + "' from Vanilla", e);
logger.log(Level.WARNING, MessageFormat.format(
strings.getString("console.warn.icon.load-failed.import"),
SERVER_ICON_FILE), e);
}
}
} catch (Exception e) {
logger.log(Level.WARNING, "Failed to load '" + SERVER_ICON_FILE + "'", e);
logger.log(Level.WARNING,
MessageFormat.format(strings.getString("console.warn.icon.load-failed"),
SERVER_ICON_FILE), e);
}
}

Expand Down Expand Up @@ -1071,7 +1079,8 @@ private void loadPlugins() {

File folder = new File(config.getString(Key.PLUGIN_FOLDER));
if (!folder.isDirectory() && !folder.mkdirs()) {
logger.log(Level.SEVERE, "Could not create plugins directory: " + folder);
logger.log(Level.SEVERE,
MessageFormat.format(strings.getString("console.error.plugin.mkdir"), folder));
}

// detect plugin types
Expand All @@ -1091,7 +1100,8 @@ private void loadPlugins() {
plugin.onLoad();
} catch (Exception ex) {
logger.log(Level.SEVERE,
"Error loading " + plugin.getDescription().getFullName(), ex);
MessageFormat.format(strings.getString("console.error.plugin.loading"),
plugin.getDescription().getFullName()), ex);
}
}

Expand All @@ -1114,35 +1124,44 @@ private void loadPlugins() {
}

if (!hasSponge && spongeOnlyPlugins) {
logger.log(Level.WARNING, "SpongeAPI plugins found, but no Sponge bridge present!"
+ " They will be ignored.");
logger.log(Level.WARNING, strings.getString("console.warn.plugin.no-sponge"));
for (File file : getSpongePlugins()) {
logger.log(Level.WARNING, "Ignored SpongeAPI plugin: " + file.getPath());
logger.log(Level.WARNING, MessageFormat.format(
strings.getString("console.warn.plugin.unsupported.sponge"),
file.getPath()));
}
logger.log(Level.WARNING, "Suggestion: install https://github"
+ ".com/GlowstoneMC/Bukkit2Sponge to load these plugins");
logger.log(Level.WARNING,
strings.getString("console.warn.plugin.no-sponge.bukkit2sponge"));
}
}

if (!pluginTypeDetector.canaryPlugins.isEmpty() || !pluginTypeDetector.forgefPlugins
.isEmpty() || !pluginTypeDetector.forgenPlugins.isEmpty()
|| !pluginTypeDetector.unrecognizedPlugins.isEmpty()) {
logger.log(Level.WARNING, "Unsupported plugin types found, will be ignored:");
logger.log(Level.WARNING, strings.getString("console.warn.plugin.unsupported"));

for (File file : pluginTypeDetector.canaryPlugins) {
logger.log(Level.WARNING, "Canary plugin not supported: " + file.getPath());
logger.log(Level.WARNING, MessageFormat.format(
strings.getString("console.warn.plugin.unsupported.canary"),
file.getPath()));
}

for (File file : pluginTypeDetector.forgefPlugins) {
logger.log(Level.WARNING, "Forge plugin not supported: " + file.getPath());
logger.log(Level.WARNING, MessageFormat.format(
strings.getString("console.warn.plugin.unsupported.forge"),
file.getPath()));
}

for (File file : pluginTypeDetector.forgenPlugins) {
logger.log(Level.WARNING, "Forge plugin not supported: " + file.getPath());
logger.log(Level.WARNING, MessageFormat.format(
strings.getString("console.warn.plugin.unsupported.forge"),
file.getPath()));
}

for (File file : pluginTypeDetector.unrecognizedPlugins) {
logger.log(Level.WARNING, "Unrecognized plugin not supported: " + file.getPath());
logger.log(Level.WARNING, MessageFormat.format(
strings.getString("console.warn.plugin.unsupported.other"),
file.getPath()));
}
}

Expand Down Expand Up @@ -1178,17 +1197,18 @@ private void enablePlugins(PluginLoadOrder type) {
pluginManager.addPermission(perm);
} catch (IllegalArgumentException ex) {
getLogger().log(Level.WARNING,
"Plugin " + plugin.getDescription().getFullName()
+ " tried to register permission '" + perm.getName()
+ "' but it's already registered", ex);
MessageFormat.format(strings.getString(
"console.warn.plugin.permission.duplicate"),
plugin.getDescription().getFullName(), perm.getName()), ex);
}
}

try {
pluginManager.enablePlugin(plugin);
} catch (Throwable ex) {
logger.log(Level.SEVERE,
"Error loading " + plugin.getDescription().getFullName(), ex);
MessageFormat.format(strings.getString("console.error.plugin.loading"),
plugin.getDescription().getFullName()), ex);
}
}
}
Expand Down Expand Up @@ -1221,16 +1241,16 @@ private void enablePlugins(PluginLoadOrder type) {
.put(key, ((MemorySection) value).getValues(false)));

List<Permission> perms = Permission
.loadPermissions(data, "Permission node '%s' in permissions config is "
+ "invalid", PermissionDefault.OP);
.loadPermissions(data, strings.getString("console.error.permission.invalid"),
PermissionDefault.OP);

for (Permission perm : perms) {
try {
pluginManager.addPermission(perm);
} catch (IllegalArgumentException ex) {
getLogger().log(Level.WARNING,
"Permission config tried to register '" + perm.getName()
+ "' but it's already registered", ex);
getLogger().log(Level.WARNING, MessageFormat.format(
strings.getString("console.warn.permission.duplicate"),
perm.getName()), ex);
}
}
}
Expand All @@ -1257,7 +1277,7 @@ public void reload() {
enablePlugins(PluginLoadOrder.STARTUP);
enablePlugins(PluginLoadOrder.POSTWORLD);
} catch (Exception ex) {
logger.log(Level.SEVERE, "Uncaught error while reloading", ex);
logger.log(Level.SEVERE, strings.getString("console.error.reload"), ex);
}
}

Expand Down Expand Up @@ -1741,7 +1761,9 @@ public boolean dispatchCommand(CommandSender sender,
firstword = firstword.substring(0, firstword.indexOf(' '));
}

sender.sendMessage(ChatColor.GRAY + "Unknown command \"" + firstword + "\", try \"help\"");
sender.sendMessage(
MessageFormat.format(strings.getString("glowstone.command.error.unknown-command"),
ChatColor.GRAY, firstword));
return false;
}

Expand Down Expand Up @@ -1874,9 +1896,11 @@ public OfflinePlayer getOfflinePlayer(String name) {
return getOfflinePlayerAsync(name).get(getProfileLookupTimeout(), TimeUnit.SECONDS);
}
} catch (InterruptedException | ExecutionException ex) {
GlowServer.logger.log(Level.SEVERE, "UUID lookup interrupted: ", ex);
GlowServer.logger.log(Level.SEVERE,
strings.getString("console.error.uuid.interrupted"), ex);
} catch (TimeoutException ex) {
GlowServer.logger.log(Level.WARNING, "UUID lookup timeout: ", ex);
GlowServer.logger.log(Level.WARNING,
strings.getString("console.warn.uuid.timeout"), ex);
}

return getOfflinePlayerFallback(name);
Expand All @@ -1892,9 +1916,11 @@ public OfflinePlayer getOfflinePlayer(UUID uuid) {
return getOfflinePlayerAsync(uuid).get(getProfileLookupTimeout(), TimeUnit.SECONDS);
}
} catch (InterruptedException | ExecutionException ex) {
GlowServer.logger.log(Level.SEVERE, "Profile lookup interrupted: ", ex);
GlowServer.logger.log(Level.SEVERE,
strings.getString("console.error.profile.interrupted"), ex);
} catch (TimeoutException ex) {
GlowServer.logger.log(Level.WARNING, "Profile lookup timeout: ", ex);
GlowServer.logger.log(Level.WARNING,
strings.getString("console.warn.profile.timeout"), ex);
}
return new GlowOfflinePlayer(this, new GlowPlayerProfile(null, uuid));
}
Expand Down Expand Up @@ -2081,7 +2107,8 @@ public GlowWorld createWorld(WorldCreator creator) {
}
if (isGenerationDisabled()) {
logger.warning(
"World generation is disabled! World '" + creator.name() + "' will be empty.");
MessageFormat.format(strings.getString("console.warn.worldgen.disabled"),
creator.name()));
}

if (creator.generator() == null) {
Expand Down Expand Up @@ -2510,7 +2537,11 @@ public String getConsoleLogDateFormat() {
}

/**
* Gets the server type.
* Gets the server type (e.g. VANILLA, BUKKIT, FML). The server type is meant to be read by mods
* and thus is not localized server-side. It is output to clients by {@link
* net.glowstone.net.handler.status.StatusRequestHandler#handle(GlowSession,
* StatusRequestMessage)}, but should be ignored by vanilla clients and localized client-side by
* modded clients aware of it.
*
* <p>Currently, this value is set to {@code VANILLA}.
*
Expand Down
55 changes: 36 additions & 19 deletions src/main/resources/strings.properties
Expand Up @@ -4,12 +4,31 @@
# Message names beginning with "console.warn" are for Logger.warn.
# Message names beginning with "glowstone" may be sent to players; the second-level name of the message is usually the
# relevant subpackage of net.glowstone.

console.error.classpath=Error loading classpath!
console.error.import.no-message=Import of {0} failed
console.error.import.with-message=Importing file {0} failed: {1}
console.error.looting-manager=Failed to load looting manager:
console.error.permission.invalid=Permission node ''%s'' in permissions config is invalid
console.error.plugin.loading=Error loading {0}
console.error.plugin.mkdir=Could not create plugins directory: {0}
console.error.profile.interrupted=Profile lookup interrupted:
console.error.rcon.bind-interrupted=Bind interrupted!
console.error.reload=Uncaught error while reloading
console.error.startup=Error during server startup.
console.error.uuid.interrupted=UUID lookup interrupted:
console.info.config-only-done=Configuration files have been loaded, exiting...
console.info.icon.import=Importing ''{0}'' from Vanilla.
console.info.import=Importing {0} from {1}
console.info.native-transport.epoll=Native epoll transport is enabled.
console.info.native-transport.kqueue=Native kqueue transport is enabled.
console.info.opencl.best=Device is best platform so far, on {0}
console.info.opencl.best.version-tiebreaker=Device tied for flops, but had higher version on {0}
console.info.opencl.cpu=No Intel graphics found, best platform is the best CPU platform we could find...
console.info.opencl.found-device=Found {0} with {1} flops
console.info.opencl.intel-gpu=No dGPU found, best platform is the best Intel graphics we could find...
console.info.opencl.no-device=Your system does not meet the OpenCL requirements for Glowstone. See if driver updates are available.
console.info.opencl.required-extensions=Required extensions: [ cl_khr_fp64 ]
console.info.opencl.required-version=Required version: {0}.{1}
console.info.option.help=Available command-line options:\n\
--help, -h, -? Shows this help message and exits.\n\
--version, -v Shows version information and exits.\n\
Expand All @@ -26,24 +45,22 @@ console.info.option.help=Available command-line options:\n\
--max-players, -M <director> Sets the maximum amount of players.\n\
--world-name, -N <name> Sets the main world name.\n\
--log-pattern, -L <pattern> Sets the log file pattern (%D for date).
console.info.config-only-done=Configuration files have been loaded, exiting...
console.info.import=Importing {0} from {1}
console.info.native-transport.epoll=Native epoll transport is enabled.
console.info.native-transport.kqueue=Native kqueue transport is enabled.
console.info.opencl.best=Device is best platform so far, on {0}
console.info.opencl.best.version-tiebreaker=Device tied for flops, but had higher version on {0}
console.info.opencl.cpu=No Intel graphics found, best platform is the best CPU platform we could find...
console.info.opencl.found-device=Found {0} with {1} flops
console.info.opencl.intel-gpu=No dGPU found, best platform is the best Intel graphics we could find...
console.info.opencl.no-device=Your system does not meet the OpenCL requirements for Glowstone. See if driver updates are available.
console.info.opencl.required-extensions=Required extensions: [ cl_khr_fp64 ]
console.info.opencl.required-version=Required version: {0}.{1}
console.info.proxy=Proxy support is enabled.
console.info.proxy.online=Proxy support is enabled, but online mode is enabled.
console.info.ready=Ready for connections.
console.info.version.bukkit=Bukkit version: {0}
console.info.version.glowstone=Glowstone version: {0}
console.info.version.minecraft-client=Minecraft version: {0} protocol {1}
console.warn.icon.load-failed.import=Failed to import ''{0}'' from Vanilla
console.warn.icon.load-failed=Failed to load ''{0}''
console.warn.offline=The server is running in offline mode! Only do this if you know what you''re doing.
console.warn.option.invalid=Ignored invalid option: {0}
console.warn.option.no-value=Ignored option specified without value: {0}
console.warn.permission.duplicate=Permission config tried to register ''{0}'' but it''s already registered
console.warn.plugin.no-sponge=SpongeAPI plugins found, but no Sponge bridge present! They will be ignored.
console.warn.plugin.no-sponge.bukkit2sponge=Suggestion: install https://github.com/GlowstoneMC/Bukkit2Sponge to load these plugins
console.warn.plugin.permission.duplicate=Plugin {0} tried to register permission ''{1}'' but it''s already registered
console.warn.plugin.unsupported=Unsupported plugin types found, will be ignored:
console.warn.plugin.unsupported.canary=Canary plugin not supported: {0}
console.warn.plugin.unsupported.forge=Forge plugin not supported: {0}
console.warn.plugin.unsupported.other=Unrecognized plugin not supported: {0}
console.warn.plugin.unsupported.sponge=Ignored SpongeAPI plugin: {0}
console.warn.profile.timeout=Profile lookup timeout:
console.warn.uuid.timeout=UUID lookup timeout:
console.warn.worldgen.disabled=World generation is disabled! World ''{0}'' will be empty.
glowstone.advancement.title=Advancements in Glowstone
glowstone.command.error.unknown-command={0}Unknown command "{1}", try "help"