@ -15,8 +15,6 @@ import turniplabs.halplibe.helper.BlockHelper;
import turniplabs.halplibe.helper.RecipeHelper ;
import java.io.* ;
import java.net.URISyntaxException ;
import java.net.URL ;
public class IronChestMain implements ModInitializer {
@ -33,10 +31,10 @@ public class IronChestMain implements ModInitializer {
LOGGER . info ( "AFloydIronChest initialized." ) ;
//Config
Toml toml = new Toml ( ) . read ( this . getConfig ( ) ) ;
int ironChestId = toml . getLong ( "ids.ironChestID" ). intValue ( ) ;
int goldChestId = toml . getLong ( "ids.goldChestID" ). intValue ( ) ;
int diamondChestId = toml . getLong ( "ids.diamondChestID" ). intValue ( ) ;
int steelChestId = toml . getLong ( "ids.steelChestID" ). intValue ( ) ;
int ironChestId = toml . getLong ( "ids.ironChestID" , ( long ) 900 ). intValue ( ) ;
int goldChestId = toml . getLong ( "ids.goldChestID" , ( long ) 901 ). intValue ( ) ;
int diamondChestId = toml . getLong ( "ids.diamondChestID" , ( long ) 902 ). intValue ( ) ;
int steelChestId = toml . getLong ( "ids.steelChestID" , ( long ) 903 ). intValue ( ) ;
//Blocks
@ -59,6 +57,7 @@ public class IronChestMain implements ModInitializer {
"steelchesttop.png" , "steelchestbottom.png" ,
"steelchestfront.png" , "steelchestside.png" , "steelchestside.png" , "steelchestside.png" ,
Block . soundMetalFootstep , 5 , 6 , 0 ) ;
//Recipes
RecipeHelper . Crafting . createRecipe ( IronChest , 1 , new Object [ ] {
"AAA" ,
@ -97,18 +96,21 @@ public class IronChestMain implements ModInitializer {
} ) ;
}
public File getConfig ( ) {
public static File getConfig ( ) {
File config = new File ( "config/AstoriaIronChest.toml" ) ;
if ( ! config . exists ( ) ) {
LOGGER . warn ( "Config For afloydironchest Not Found! Creating new config based upon default :)" ) ;
InputStream in ;
OutputStream out ;
try {
in = new FileInputStream ( getDefaultConfig ( ) ) ;
File configDir = new File ( "config" ) ;
if ( ! configDir . exists ( ) )
configDir . mkdir ( ) ;
in = IronChestMain . class . getClassLoader ( ) . getResourceAsStream ( "assets/ironchest/config.toml" ) ;
out = new FileOutputStream ( config ) ;
byte [ ] buffer = new byte [ 1024 ] ;
int length ;
while ( ( length = in . read ( buffer ) ) > 0 ) {
while ( ( length = in . read ( buffer ) ) > 0 ) {
out . write ( buffer , 0 , length ) ;
}
return getConfig ( ) ;
@ -120,18 +122,4 @@ public class IronChestMain implements ModInitializer {
return config ;
}
}
public File getDefaultConfig ( ) {
URL defaultConfig = getClass ( ) . getClassLoader ( ) . getResource ( "assets/ironchest/config.toml" ) ;
if ( defaultConfig = = null ) {
LOGGER . warn ( "Default Config For afloydironchest Not Found! REAL BAD." ) ;
} else {
try {
return new File ( defaultConfig . toURI ( ) ) ;
} catch ( URISyntaxException e ) {
throw new RuntimeException ( e ) ;
}
}
return null ;
}
}
}