|
1 | 1 | package com.httymd; |
2 | 2 |
|
3 | | -import com.httymd.util.Utils; |
| 3 | +import java.util.HashMap; |
| 4 | + |
| 5 | +import com.httymd.entity.EntityTameableFlying; |
4 | 6 |
|
5 | 7 | import cpw.mods.fml.common.event.FMLPreInitializationEvent; |
| 8 | +import net.minecraft.entity.EntityList; |
| 9 | +import net.minecraft.entity.EntityLivingBase; |
6 | 10 | import net.minecraftforge.common.config.Configuration; |
7 | 11 |
|
8 | 12 | public class Config { |
9 | 13 |
|
| 14 | + public static String CATEGORYS[] = {"dragons", "testing", "bg2"}; |
| 15 | + private static final String STRING_PREFIX = "config."+HTTYMDMod.ID+":"; |
| 16 | + |
| 17 | + static { |
| 18 | + for(int i = 0; i < CATEGORYS.length; i++) |
| 19 | + CATEGORYS[i] = STRING_PREFIX+"category."+CATEGORYS[i]; |
| 20 | + } |
| 21 | + |
10 | 22 | private final Configuration config; |
11 | | - private static final String STRING_PREFIX = "config."; |
12 | 23 | private int startEntityID = -1; |
| 24 | + ///////////////// |
| 25 | + // Dragons Cat |
| 26 | + ///////////////// |
| 27 | + private boolean verticalDragonRiding = true; |
13 | 28 | private boolean canOwnMultipleDragons = true; |
| 29 | + private boolean feedHealsDragons = true; |
| 30 | + private String forcedTameable = ""; |
| 31 | + ///////////////// |
| 32 | + // Testing Cat |
| 33 | + ///////////////// |
14 | 34 | private boolean debugMode = false; |
15 | 35 | private boolean experimentalMode = false; |
| 36 | + ///////////////// |
| 37 | + // BG2 Cat |
| 38 | + ///////////////// |
| 39 | + private boolean useBG2 = true; |
| 40 | + private boolean useBg2Daggers = true; |
| 41 | + private boolean useBg2ForWarhammer = true; |
| 42 | + |
| 43 | + private HashMap<Class<? extends EntityLivingBase>, Boolean> forcedTameCache = new HashMap<Class<? extends EntityLivingBase>, Boolean>(); |
16 | 44 |
|
17 | 45 | public Config(FMLPreInitializationEvent evt) { |
18 | | - config = new Configuration(evt.getSuggestedConfigurationFile()); |
| 46 | + this.config = new Configuration(evt.getSuggestedConfigurationFile()); |
19 | 47 |
|
20 | | - syncConfig(); |
| 48 | + this.syncConfig(); |
21 | 49 | } |
22 | 50 |
|
23 | | - public void syncConfig() { |
24 | | - |
25 | | - startEntityID = config.getInt("DragonEntityID", Configuration.CATEGORY_GENERAL, startEntityID, -1, 255, |
26 | | - "Overrides the entity ID for dragons to fix problems with manual IDs from other mods.\nSet to -1 for automatic assignment (recommended).\nWarning: wrong values may cause crashes and loss of data! Must restart Minecraft to take effect", |
27 | | - getLocalKey("startEntityID")); |
28 | | - canOwnMultipleDragons = config.getBoolean("MultiDragonOwnership", Configuration.CATEGORY_GENERAL, true, |
29 | | - "Provides ability to own multiple dragons", getLocalKey("multiDragonOwnership")); |
30 | | - debugMode = config.getBoolean("DebugMode", Configuration.CATEGORY_GENERAL, false, |
31 | | - "Enable debug mode, developers recommended", getLocalKey("debugMode")); |
32 | | - experimentalMode = config.getBoolean("ExperimentalMode", Configuration.CATEGORY_GENERAL, false, |
33 | | - "Enable an experimental version (warning: may be less stable)", getLocalKey("experimentalMode")); |
34 | | - |
35 | | - if (config.hasChanged()) |
36 | | - config.save(); |
| 51 | + public Configuration getConfig() { |
| 52 | + return this.config; |
37 | 53 | } |
38 | 54 |
|
39 | 55 | protected String getLocalKey(String ending) { |
40 | | - return Utils.getLocalString(STRING_PREFIX + ending); |
| 56 | + return STRING_PREFIX + ending; |
41 | 57 | } |
42 | | - |
43 | | - public Configuration getConfig() { |
44 | | - return config; |
| 58 | + |
| 59 | + public boolean getVerticalDragonRiding() { |
| 60 | + return this.verticalDragonRiding; |
45 | 61 | } |
46 | 62 |
|
47 | | - public int getStartEntityID() { |
48 | | - return startEntityID; |
| 63 | + public boolean getMultiDragonOwnership() { |
| 64 | + return this.canOwnMultipleDragons; |
49 | 65 | } |
50 | 66 |
|
51 | | - public boolean getMultiDragonOwnership() { |
52 | | - return canOwnMultipleDragons; |
| 67 | + public int getStartEntityID() { |
| 68 | + return this.startEntityID; |
53 | 69 | } |
54 | 70 |
|
55 | 71 | public boolean isDebugMode() { |
56 | | - return debugMode; |
| 72 | + return this.debugMode; |
57 | 73 | } |
58 | 74 |
|
59 | 75 | public boolean isExperimental() { |
60 | | - return experimentalMode; |
| 76 | + return this.experimentalMode; |
| 77 | + } |
| 78 | + |
| 79 | + public boolean canUseBg2() { |
| 80 | + return this.useBG2; |
| 81 | + } |
| 82 | + |
| 83 | + public boolean useBg2Daggers() { |
| 84 | + return this.useBg2Daggers; |
| 85 | + } |
| 86 | + |
| 87 | + public boolean useBg2ForWarhammer() { |
| 88 | + return this.useBg2ForWarhammer; |
| 89 | + } |
| 90 | + |
| 91 | + public boolean isTameable(EntityTameableFlying e) { |
| 92 | + Boolean result = this.forcedTameCache.get(e.getClass()); |
| 93 | + if(result != null) return result.booleanValue(); |
| 94 | + String name = EntityList.getEntityString(e).replace(" ", "").replace(HTTYMDMod.ID+".", "").toLowerCase(); |
| 95 | + String checkStr = this.forcedTameable.replace(" ", "").toLowerCase(); |
| 96 | + result = checkStr.indexOf(name) != -1; |
| 97 | + this.forcedTameCache.put(e.getClass(), result); |
| 98 | + return result; |
| 99 | + } |
| 100 | + |
| 101 | + public boolean canFeedHeal() { |
| 102 | + return this.feedHealsDragons; |
| 103 | + } |
| 104 | + |
| 105 | + public void syncConfig() { |
| 106 | + |
| 107 | + /*this.startEntityID = this.config.getInt("DragonEntityID", Configuration.CATEGORY_GENERAL, this.startEntityID, -1, 255, |
| 108 | + "Overrides the entity ID for dragons to fix problems with manual IDs from other mods.\nSet to -1 for automatic assignment (recommended).\nWarning: wrong values may cause crashes and loss of data! Must restart Minecraft to take effect", |
| 109 | + this.getLocalKey("startEntityID"));*/ |
| 110 | + |
| 111 | + String cat = Configuration.CATEGORY_GENERAL; |
| 112 | + |
| 113 | + cat = CATEGORYS[0]; |
| 114 | + this.verticalDragonRiding = this.config.getBoolean("Vertical Riding", cat, true, "Enable the vertical climb when riding by looking up or down", this.getLocalKey("verticalDragonRiding")); |
| 115 | + this.canOwnMultipleDragons = this.config.getBoolean("Multi Ownership", cat, true, "Provides ability to own multiple dragons", this.getLocalKey("multiOwn")); |
| 116 | + this.feedHealsDragons = this.config.getBoolean("Feed Heals", cat, true, "Determines whether feeding dragons heals them", this.getLocalKey("feedHeals")); |
| 117 | + this.forcedTameable = this.config.getString("Force Tameable", cat, "", "A list of entity names which are forced to be tameable (seperator may be anything ths isn't a space)", this.getLocalKey("forcedTameable")); |
| 118 | + |
| 119 | + cat = CATEGORYS[1]; |
| 120 | + this.debugMode = this.config.getBoolean("Debug Mode", cat, false, "Enable debug mode, developers recommended", this.getLocalKey("debugMode")); |
| 121 | + this.experimentalMode = this.config.getBoolean("Experimental Mode", cat, false, "Enable an experimental version (warning: may be less stable)", this.getLocalKey("experimentalMode")); |
| 122 | + |
| 123 | + cat = CATEGORYS[2]; |
| 124 | + this.useBG2 = this.config.getBoolean("Use BG2", cat, true, "Enables the use of BG2 (if installed)", this.getLocalKey("useBG2")); |
| 125 | + this.useBg2Daggers = this.config.getBoolean("Use BG2 Daggers", cat, true, "Allows you to specifiy whether to use Battlegear 2 to replace HTTYMD dagger behavior with BG2 dagger behavior", this.getLocalKey("useBg2Daggers")); |
| 126 | + this.useBg2ForWarhammer = this.config.getBoolean("Use BG2 Warhammers", cat, true, "Allows you to specifiy whether to use Battlegear 2 for HTTYMD Warhammers", this.getLocalKey("useBg2ForWarhammer")); |
| 127 | + |
| 128 | + if (this.config.hasChanged()) |
| 129 | + this.config.save(); |
61 | 130 | } |
62 | 131 | } |
0 commit comments