forked from kolatra/ftb-islands
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewritten and improved data structure:
- Islands have owner property - Multi Dimension support - Islands spawn in the center of each region file
- Loading branch information
1 parent
f6fbdc0
commit 19b3499
Showing
16 changed files
with
500 additions
and
556 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
package com.cricketcraft.ftbisland; | ||
|
||
import java.io.File; | ||
import java.util.ArrayList; | ||
|
||
import net.minecraftforge.common.config.Configuration; | ||
|
||
import cpw.mods.fml.client.event.ConfigChangedEvent; | ||
import cpw.mods.fml.common.eventhandler.SubscribeEvent; | ||
|
||
public class Config { | ||
|
||
private static Configuration config; | ||
|
||
public static void init(File file) { | ||
if (config == null) { | ||
config = new Configuration(file); | ||
loadConfig(); | ||
} | ||
} | ||
|
||
private static void loadConfig() { | ||
FTBIslands.maxIslands = config.getInt( | ||
"Max Islands", | ||
"misc", | ||
100, | ||
1, | ||
1000, | ||
"The maximum amount of islands that can be created. This number will be multiplied by four." | ||
+ " Be careful with high numbers."); | ||
if (!config.hasKey("misc", "Island Type")) { | ||
boolean skyFactory = config | ||
.getBoolean("Sky Factory", "misc", false, "Set this to true if you are playing on Sky Factory."); | ||
boolean platform = config.getBoolean( | ||
"Platform", | ||
"misc", | ||
false, | ||
"Set to true if you want to start on a 3x3 platform, or false for a tree."); | ||
if (skyFactory || !platform) { | ||
FTBIslands.islandType = config.getString( | ||
"Island Type", | ||
"misc", | ||
"tree", | ||
"Set this to the type of platform you want:\n" + " 'grass' A single grass block.\n" | ||
+ " 'tree' A small oak tree on a grass block. This is the standard start.\n" | ||
+ " 'platform' A 3x3 platform with a chest.\n" | ||
+ " 'GoG' An island similar to Garden of Glass from Botania.\n"); | ||
config.moveProperty("misc", "Sky Factory", "forRemoval"); | ||
config.moveProperty("misc", "Platform", "forRemoval"); | ||
config.removeCategory(config.getCategory("forRemoval")); | ||
} | ||
} else { | ||
FTBIslands.islandType = config.getString( | ||
"Island Type", | ||
"misc", | ||
"tree", | ||
"Set this to the type of platform you want:\n" + " 'grass' A single grass block.\n" | ||
+ " 'tree' A small oak tree on a grass block. This is the standard start.\n" | ||
+ " 'platform' A 3x3 platform with a chest.\n" | ||
+ " 'GoG' An island similar to Garden of Glass from Botania.\n"); | ||
ArrayList<String> types = new ArrayList<>(); | ||
types.add("grass"); | ||
types.add("tree"); | ||
types.add("platform"); | ||
types.add("GoG"); | ||
|
||
boolean valid = false; | ||
for (String s : types) { | ||
if (FTBIslands.islandType.equalsIgnoreCase(s)) { | ||
valid = true; | ||
break; | ||
} | ||
} | ||
if (!valid) { | ||
FTBIslands.logger.warn("Invalid island option detected. Using 'platform' as default."); | ||
FTBIslands.islandType = "platform"; | ||
} | ||
} | ||
|
||
if (config.hasChanged()) { | ||
config.save(); | ||
} | ||
} | ||
|
||
@SubscribeEvent | ||
public void onChanged(ConfigChangedEvent.OnConfigChangedEvent event) { | ||
if (event.modID.equalsIgnoreCase(Tags.MODID)) { | ||
loadConfig(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.