Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions common/src/main/java/com/loohp/imageframe/ImageFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ public class ImageFrame extends JavaPlugin {

public static String language;

public static boolean downloadLanguagesOnStartup;

public static SimpleDateFormat dateFormat;

public static String mapItemFormat;
Expand Down Expand Up @@ -325,6 +327,7 @@ public void reloadConfig() {
viaDisableSmoothAnimationForLegacyPlayers = config.getConfiguration().getBoolean("Hooks.ViaVersion.DisableSmoothAnimationForLegacyPlayers");

language = config.getConfiguration().getString("Settings.Language");
downloadLanguagesOnStartup = config.getConfiguration().getBoolean("Settings.DownloadLanguagesOnStartup");

dateFormat = new SimpleDateFormat(config.getConfiguration().getString("Settings.DateFormat"));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ public Set<String> getLoadedLanguages() {
}

public void downloadTranslations() {
if (!ImageFrame.downloadLanguagesOnStartup) {
ImageFrame.plugin.getLogger().info("DownloadLanguagesOnStartup is disabled. Skipped downloading language files from the internet; using the locally installed language files.");
return;
}
try {
File languageHashFile = new File(ImageFrame.plugin.getDataFolder(), "language_hashes.json");
JsonObject languageHashes;
Expand Down Expand Up @@ -129,6 +133,7 @@ public void downloadTranslations() {
new IOException("Unable to save language hashes to " + languageHashFile.getAbsolutePath(), e).printStackTrace();
}
} catch (Throwable e) {
ImageFrame.plugin.getLogger().warning("Failed to fetch language files from the internet. The plugin will use the locally installed language files. If your server cannot reach api.loohpjames.com, or you intend to run it offline, set \"Settings.DownloadLanguagesOnStartup\" to false in config.yml to skip this network request on startup.");
e.printStackTrace();
}
}
Expand Down
4 changes: 4 additions & 0 deletions common/src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ Settings:
#For supported languages, see https://loohpjames.com/imageframe/languages/
#To contribute your language, visit https://crowdin.com/project/imageframe/
Language: "en_us"
#Whether ImageFrame should look for updated language files from the internet on startup
#Set to false to skip the network request and only use the locally installed language files
#Useful if the server cannot reach api.loohpjames.com, or you intend to run the server offline
DownloadLanguagesOnStartup: true
#Date format used where a time based variable is displayed
DateFormat: "dd/MM/yyyy HH:mm:ss zzz"
MapItemFormat: "&f{Name} &7({X}, {Y})"
Expand Down