@@ -461,35 +461,33 @@ public static bool StartServer() {
461
461
}
462
462
463
463
static void DownloadResources ( ) {
464
- if ( ! Directory . Exists ( "./Bot" ) ) {
465
- Directory . CreateDirectory ( "./Bot" ) ;
466
- }
467
- if ( ! File . Exists ( "Bot/Funfacts.txt" ) ) {
468
- ( new WebClient ( ) ) . DownloadFile ( "http://123dmwm.tk/ProCraft/resources/Funfacts.txt" , "Bot/Funfacts.txt" ) ;
469
- }
470
- if ( ! File . Exists ( "Bot/Jokes.txt" ) ) {
471
- ( new WebClient ( ) ) . DownloadFile ( "http://123dmwm.tk/ProCraft/resources/Jokes.txt" , "Bot/Jokes.txt" ) ;
472
- }
473
- if ( ! File . Exists ( "Bot/Protips.txt" ) ) {
474
- ( new WebClient ( ) ) . DownloadFile ( "http://123dmwm.tk/ProCraft/resources/Protips.txt" , "Bot/Protips.txt" ) ;
475
- }
476
- if ( ! File . Exists ( "Bot/Adjectives.txt" ) ) {
477
- ( new WebClient ( ) ) . DownloadFile ( "http://123dmwm.tk/ProCraft/resources/Adjectives.txt" , "Bot/Adjectives.txt" ) ;
478
- }
479
- if ( ! File . Exists ( "Bot/Nouns.txt" ) ) {
480
- ( new WebClient ( ) ) . DownloadFile ( "http://123dmwm.tk/ProCraft/resources/Nouns.txt" , "Bot/Nouns.txt" ) ;
481
- }
482
-
483
- if ( ! File . Exists ( "./MOTDList.txt" ) ) {
484
- ( new WebClient ( ) ) . DownloadFile ( "http://123dmwm.tk/ProCraft/resources/MOTDList.txt" , "MOTDList.txt" ) ;
485
- }
486
-
487
- if ( ! Directory . Exists ( "./fonts" ) ) {
488
- Directory . CreateDirectory ( "./fonts" ) ;
489
- ( new WebClient ( ) ) . DownloadFile ( "http://123dmwm.tk/ProCraft/resources/comicsans.ttf" , "fonts/comicsans.ttf" ) ;
490
- ( new WebClient ( ) ) . DownloadFile ( "http://123dmwm.tk/ProCraft/resources/mcclassic.ttf" , "fonts/mcclassic.ttf" ) ;
491
- ( new WebClient ( ) ) . DownloadFile ( "http://123dmwm.tk/ProCraft/resources/microsoft.ttf" , "fonts/microsoft.ttf" ) ;
492
- ( new WebClient ( ) ) . DownloadFile ( "http://123dmwm.tk/ProCraft/resources/minecraft.ttf" , "fonts/minecraft.ttf" ) ;
464
+ if ( ! Directory . Exists ( "./Bot" ) ) Directory . CreateDirectory ( "./Bot" ) ;
465
+ if ( ! Directory . Exists ( "./fonts" ) ) Directory . CreateDirectory ( "./fonts" ) ;
466
+
467
+ DownloadResource ( "http://123dmwm.tk/ProCraft/resources/Funfacts.txt" , "./Bot/Funfacts.txt" ) ;
468
+ DownloadResource ( "http://123dmwm.tk/ProCraft/resources/Jokes.txt" , "./Bot/Jokes.txt" ) ;
469
+ DownloadResource ( "http://123dmwm.tk/ProCraft/resources/Protips.txt" , "./Bot/Protips.txt" ) ;
470
+ DownloadResource ( "http://123dmwm.tk/ProCraft/resources/Adjectives.txt" , "./Bot/Adjectives.txt" ) ;
471
+ DownloadResource ( "http://123dmwm.tk/ProCraft/resources/Nouns.txt" , "./Bot/Nouns.txt" ) ;
472
+
473
+ DownloadResource ( "http://123dmwm.tk/ProCraft/resources/MOTDList.txt" , "./MOTDList.txt" ) ;
474
+ DownloadResource ( "http://123dmwm.tk/ProCraft/resources/comicsans.ttf" , "./fonts/comicsans.ttf" ) ;
475
+ DownloadResource ( "http://123dmwm.tk/ProCraft/resources/mcclassic.ttf" , "./fonts/mcclassic.ttf" ) ;
476
+ DownloadResource ( "http://123dmwm.tk/ProCraft/resources/microsoft.ttf" , "./fonts/microsoft.ttf" ) ;
477
+ DownloadResource ( "http://123dmwm.tk/ProCraft/resources/minecraft.ttf" , "./fonts/minecraft.ttf" ) ;
478
+ }
479
+
480
+ static void DownloadResource ( string url , string file ) {
481
+ if ( File . Exists ( file ) ) return ;
482
+
483
+ try {
484
+ new WebClient ( ) . DownloadFile ( url , file ) ;
485
+ } catch ( WebException ex ) {
486
+ WebResponse resp = ex . Response ;
487
+ if ( resp != null ) resp . Close ( ) ;
488
+
489
+ Logger . Log ( LogType . Warning , "Error downloading resource {0}: {1}" ,
490
+ file , ex ) ;
493
491
}
494
492
}
495
493
@@ -1095,8 +1093,8 @@ public static string GetRandomString( int chars ) {
1095
1093
[ CanBeNull ]
1096
1094
static IPAddress CheckExternalIP ( )
1097
1095
{
1098
- HttpWebRequest request = HttpUtil . CreateRequest ( IPCheckUri ,
1099
- TimeSpan . FromMilliseconds ( IPCheckTimeout ) ) ;
1096
+ HttpWebRequest request = HttpUtil . CreateRequest ( IPCheckUri ,
1097
+ TimeSpan . FromMilliseconds ( IPCheckTimeout ) ) ;
1100
1098
request . CachePolicy = new RequestCachePolicy ( RequestCacheLevel . BypassCache ) ;
1101
1099
1102
1100
try
0 commit comments