2323import java .nio .charset .StandardCharsets ;
2424import java .util .*;
2525import java .util .concurrent .TimeUnit ;
26+ import java .util .logging .Level ;
2627
2728public class CrowdinOTA implements Distribution {
2829 protected static final String CROWDIN_OTA_HOST = "https://distributions.crowdin.net/daf1a8db40f132ce157c457xrm4/" ;
@@ -37,7 +38,7 @@ public CrowdinOTA(QuickShop plugin) {
3738 Util .getCacheFolder ().mkdirs ();
3839 }
3940
40- private byte [] requestWithCache (@ NotNull String url , @ Nullable File saveTo ) {
41+ private byte [] requestWithCache (@ NotNull String url , @ Nullable File saveTo ) throws IOException {
4142 byte [] data = requestCachePool .getIfPresent (url );
4243 if (data == null ) {
4344 try {
@@ -48,9 +49,6 @@ private byte[] requestWithCache(@NotNull String url, @Nullable File saveTo) {
4849 if (saveTo != null )
4950 response .saveContent (saveTo );
5051 return response .asBytes ();
51- } catch (IOException e ) {
52- e .printStackTrace ();
53- return null ;
5452 } catch (InterruptedException e ) {
5553 e .printStackTrace ();
5654 }
@@ -62,7 +60,13 @@ private byte[] requestWithCache(@NotNull String url, @Nullable File saveTo) {
6260 @ Nullable
6361 public Manifest getManifest () {
6462 String url = CROWDIN_OTA_HOST + "manifest.json" ;
65- String data = new String (requestWithCache (url ,null ), StandardCharsets .UTF_8 );
63+ String data = null ;
64+ try {
65+ data = new String (requestWithCache (url ,null ), StandardCharsets .UTF_8 );
66+ } catch (IOException e ) {
67+ plugin .getLogger ().log (Level .WARNING ,"Failed to download manifest.json, multi-language system won't work" );
68+ return null ;
69+ }
6670 if (StringUtils .isEmpty (data ))
6771 return null ;
6872 return JsonUtil .getGson ().fromJson (data , Manifest .class );
@@ -71,7 +75,13 @@ public Manifest getManifest() {
7175 @ Nullable
7276 public String getManifestJson () {
7377 String url = CROWDIN_OTA_HOST + "manifest.json" ;
74- String data = new String (requestWithCache (url ,null ), StandardCharsets .UTF_8 );
78+ String data ;
79+ try {
80+ data = new String (requestWithCache (url ,null ), StandardCharsets .UTF_8 );
81+ } catch (IOException e ) {
82+ plugin .getLogger ().log (Level .WARNING ,"Failed to download manifest.json, multi-language system won't work" );
83+ return null ;
84+ }
7585 if (StringUtils .isEmpty (data ))
7686 return null ;
7787 return data ;
@@ -143,7 +153,7 @@ public String getFile(String fileCrowdinPath, String crowdinLocale, boolean forc
143153 String url = CROWDIN_OTA_HOST + "content" + fileCrowdinPath .replace ("%locale%" , crowdinLocale );
144154 byte [] bin = requestWithCache (url ,cachedDataFile );
145155 if (bin == null )
146- throw new IOException ("Couldn't download translation from remote server. If you see any error like \" 404 Not Found \" , please report it to QuickShop. " );
156+ throw new IOException ("Couldn't download translation from remote server." );
147157 // update cache index
148158 data = Util .readToString (cachedDataFile );
149159 cacheMetadata .set (pathHash + ".timestamp" , manifest .getTimestamp ());
0 commit comments