82327c1d |
1 | /* |
2 | * Decompiled with CFR 0.151. |
3 | * |
4 | * Could not load the following classes: |
5 | * com.wurmonline.mesh.Tiles$Tile |
6 | */ |
7 | package net.encode.wurmesp.util; |
8 | |
9 | import com.wurmonline.mesh.Tiles; |
10 | import java.awt.Color; |
11 | import java.io.IOException; |
12 | import java.io.InputStream; |
13 | import java.nio.file.Files; |
14 | import java.nio.file.OpenOption; |
15 | import java.nio.file.Path; |
16 | import java.nio.file.Paths; |
17 | import java.util.Properties; |
18 | import net.encode.wurmesp.Unit; |
19 | import net.encode.wurmesp.WurmEspMod; |
20 | |
21 | public class ConfigUtils { |
22 | /* |
23 | * WARNING - Removed try catching itself - possible behaviour change. |
24 | */ |
25 | public static void loadProperties(String name) { |
26 | WurmEspMod.modProperties.clear(); |
27 | InputStream inputStream = null; |
28 | Path path = Paths.get("mods", new String[0]); |
29 | path = path.resolve(name + ".properties"); |
30 | try { |
31 | inputStream = Files.newInputStream(path, new OpenOption[0]); |
32 | WurmEspMod.modProperties.load(inputStream); |
33 | } |
34 | catch (IOException e) { |
35 | e.printStackTrace(); |
36 | } |
37 | finally { |
38 | if (inputStream != null) { |
39 | try { |
40 | inputStream.close(); |
41 | } |
42 | catch (IOException e) { |
43 | e.printStackTrace(); |
44 | } |
45 | } |
46 | } |
47 | } |
48 | |
49 | public static void DoConfig(Properties properties) { |
50 | WurmEspMod.players = Boolean.valueOf(properties.getProperty("players", Boolean.toString(WurmEspMod.players))); |
51 | WurmEspMod.mobs = Boolean.valueOf(properties.getProperty("mobs", Boolean.toString(WurmEspMod.mobs))); |
52 | WurmEspMod.animals = Boolean.valueOf(properties.getProperty("animals", Boolean.toString(WurmEspMod.animals))); |
53 | WurmEspMod.specials = Boolean.valueOf(properties.getProperty("specials", Boolean.toString(WurmEspMod.specials))); |
54 | WurmEspMod.items = Boolean.valueOf(properties.getProperty("items", Boolean.toString(WurmEspMod.items))); |
55 | WurmEspMod.uniques = Boolean.valueOf(properties.getProperty("uniques", Boolean.toString(WurmEspMod.uniques))); |
56 | WurmEspMod.conditioned = Boolean.valueOf(properties.getProperty("conditioned", Boolean.toString(WurmEspMod.conditioned))); |
57 | WurmEspMod.tilescloseby = Boolean.valueOf(properties.getProperty("tilescloseby", Boolean.toString(WurmEspMod.tilescloseby))); |
58 | WurmEspMod.deedsize = Boolean.valueOf(properties.getProperty("deedsize", Boolean.toString(WurmEspMod.deedsize))); |
59 | WurmEspMod.xray = Boolean.valueOf(properties.getProperty("xray", Boolean.toString(WurmEspMod.xray))); |
60 | WurmEspMod.xraythread = Boolean.valueOf(properties.getProperty("xraythread", Boolean.toString(WurmEspMod.xraythread))); |
61 | WurmEspMod.xrayrefreshthread = Boolean.valueOf(properties.getProperty("xrayrefreshthread", Boolean.toString(WurmEspMod.xrayrefreshthread))); |
62 | WurmEspMod.xraydiameter = Integer.parseInt(properties.getProperty("xraydiameter", Integer.toString(WurmEspMod.xraydiameter))); |
63 | WurmEspMod.xrayrefreshrate = Integer.parseInt(properties.getProperty("xrayrefreshrate", Integer.toString(WurmEspMod.xrayrefreshrate))); |
64 | WurmEspMod.tilenotrideable = Integer.parseInt(properties.getProperty("tilenotrideable", Integer.toString(WurmEspMod.tilenotrideable))); |
65 | WurmEspMod.flowerdiameter = Integer.parseInt(properties.getProperty("flowerdiameter", Integer.toString(WurmEspMod.flowerdiameter))); |
66 | WurmEspMod.playsoundspecial = Boolean.valueOf(properties.getProperty("playsoundspecial", Boolean.toString(WurmEspMod.playsoundspecial))); |
67 | WurmEspMod.playsounditem = Boolean.valueOf(properties.getProperty("playsounditem", Boolean.toString(WurmEspMod.playsounditem))); |
68 | WurmEspMod.playsoundunique = Boolean.valueOf(properties.getProperty("playsoundunique", Boolean.toString(WurmEspMod.playsoundunique))); |
69 | WurmEspMod.soundspecial = properties.getProperty("soundspecial", WurmEspMod.soundspecial); |
70 | WurmEspMod.sounditem = properties.getProperty("sounditem", WurmEspMod.sounditem); |
71 | WurmEspMod.soundunique = properties.getProperty("soundunique", WurmEspMod.soundunique); |
72 | WurmEspMod.conditionedcolorsallways = Boolean.valueOf(properties.getProperty("conditionedcolorsallways", Boolean.toString(WurmEspMod.conditionedcolorsallways))); |
73 | WurmEspMod.championmcoloralways = Boolean.valueOf(properties.getProperty("championmcoloralways", Boolean.toString(WurmEspMod.championmcoloralways))); |
74 | Unit.colorPlayers = ConfigUtils.colorStringToFloatA(properties.getProperty("colorPlayers", ConfigUtils.colorFloatAToString(Unit.colorPlayers))); |
75 | Unit.colorPlayersEnemy = ConfigUtils.colorStringToFloatA(properties.getProperty("colorPlayersEnemy", ConfigUtils.colorFloatAToString(Unit.colorPlayersEnemy))); |
76 | Unit.colorMobs = ConfigUtils.colorStringToFloatA(properties.getProperty("colorMobs", ConfigUtils.colorFloatAToString(Unit.colorMobs))); |
77 | Unit.colorMobsAggro = ConfigUtils.colorStringToFloatA(properties.getProperty("colorMobsAggro", ConfigUtils.colorFloatAToString(Unit.colorMobsAggro))); |
78 | Unit.colorSpecials = ConfigUtils.colorStringToFloatA(properties.getProperty("colorSpecials", ConfigUtils.colorFloatAToString(Unit.colorSpecials))); |
79 | Unit.colorSpotted = ConfigUtils.colorStringToFloatA(properties.getProperty("colorSpotted", ConfigUtils.colorFloatAToString(Unit.colorSpotted))); |
80 | Unit.colorUniques = ConfigUtils.colorStringToFloatA(properties.getProperty("colorUniques", ConfigUtils.colorFloatAToString(Unit.colorUniques))); |
81 | Unit.colorAlert = ConfigUtils.colorStringToFloatA(properties.getProperty("colorAlert", ConfigUtils.colorFloatAToString(Unit.colorAlert))); |
82 | Unit.colorAngry = ConfigUtils.colorStringToFloatA(properties.getProperty("colorAngry", ConfigUtils.colorFloatAToString(Unit.colorAngry))); |
83 | Unit.colorChampion = ConfigUtils.colorStringToFloatA(properties.getProperty("colorChampion", ConfigUtils.colorFloatAToString(Unit.colorChampion))); |
84 | Unit.colorDiseased = ConfigUtils.colorStringToFloatA(properties.getProperty("colorDiseased", ConfigUtils.colorFloatAToString(Unit.colorDiseased))); |
85 | Unit.colorFierce = ConfigUtils.colorStringToFloatA(properties.getProperty("colorFierce", ConfigUtils.colorFloatAToString(Unit.colorFierce))); |
86 | Unit.colorGreenish = ConfigUtils.colorStringToFloatA(properties.getProperty("colorGreenish", ConfigUtils.colorFloatAToString(Unit.colorGreenish))); |
87 | Unit.colorHardened = ConfigUtils.colorStringToFloatA(properties.getProperty("colorHardened", ConfigUtils.colorFloatAToString(Unit.colorHardened))); |
88 | Unit.colorLurking = ConfigUtils.colorStringToFloatA(properties.getProperty("colorLurking", ConfigUtils.colorFloatAToString(Unit.colorLurking))); |
89 | Unit.colorRaging = ConfigUtils.colorStringToFloatA(properties.getProperty("colorRaging", ConfigUtils.colorFloatAToString(Unit.colorRaging))); |
90 | Unit.colorScared = ConfigUtils.colorStringToFloatA(properties.getProperty("colorScared", ConfigUtils.colorFloatAToString(Unit.colorScared))); |
91 | Unit.colorSlow = ConfigUtils.colorStringToFloatA(properties.getProperty("colorSlow", ConfigUtils.colorFloatAToString(Unit.colorSlow))); |
92 | Unit.colorSly = ConfigUtils.colorStringToFloatA(properties.getProperty("colorSly", ConfigUtils.colorFloatAToString(Unit.colorSly))); |
93 | String oreColorOreIron = properties.getProperty("oreColorOreIron", "default"); |
94 | if (!oreColorOreIron.equals("default")) { |
95 | XrayColors.addMapping(Tiles.Tile.TILE_CAVE_WALL_ORE_IRON, ConfigUtils.colorStringToFloatA(oreColorOreIron)); |
96 | } else { |
97 | XrayColors.addMapping(Tiles.Tile.TILE_CAVE_WALL_ORE_IRON, Color.RED.darker()); |
98 | } |
99 | String oreColorOreCopper = properties.getProperty("oreColorOreCopper", "default"); |
100 | if (!oreColorOreCopper.equals("default")) { |
101 | XrayColors.addMapping(Tiles.Tile.TILE_CAVE_WALL_ORE_COPPER, ConfigUtils.colorStringToFloatA(oreColorOreCopper)); |
102 | } else { |
103 | XrayColors.addMapping(Tiles.Tile.TILE_CAVE_WALL_ORE_COPPER, Color.GREEN); |
104 | } |
105 | String oreColorOreTin = properties.getProperty("oreColorOreTin", "default"); |
106 | if (!oreColorOreTin.equals("default")) { |
107 | XrayColors.addMapping(Tiles.Tile.TILE_CAVE_WALL_ORE_TIN, ConfigUtils.colorStringToFloatA(oreColorOreTin)); |
108 | } else { |
109 | XrayColors.addMapping(Tiles.Tile.TILE_CAVE_WALL_ORE_TIN, Color.GRAY); |
110 | } |
111 | String oreColorOreGold = properties.getProperty("oreColorOreGold", "default"); |
112 | if (!oreColorOreGold.equals("default")) { |
113 | XrayColors.addMapping(Tiles.Tile.TILE_CAVE_WALL_ORE_GOLD, ConfigUtils.colorStringToFloatA(oreColorOreGold)); |
114 | } else { |
115 | XrayColors.addMapping(Tiles.Tile.TILE_CAVE_WALL_ORE_GOLD, Color.YELLOW.darker()); |
116 | } |
117 | String oreColorOreAdamantine = properties.getProperty("oreColorOreAdamantine", "default"); |
118 | if (!oreColorOreAdamantine.equals("default")) { |
119 | XrayColors.addMapping(Tiles.Tile.TILE_CAVE_WALL_ORE_ADAMANTINE, ConfigUtils.colorStringToFloatA(oreColorOreAdamantine)); |
120 | } else { |
121 | XrayColors.addMapping(Tiles.Tile.TILE_CAVE_WALL_ORE_ADAMANTINE, Color.CYAN); |
122 | } |
123 | String oreColorOreGlimmersteel = properties.getProperty("oreColorOreGlimmersteel", "default"); |
124 | if (!oreColorOreGlimmersteel.equals("default")) { |
125 | XrayColors.addMapping(Tiles.Tile.TILE_CAVE_WALL_ORE_GLIMMERSTEEL, ConfigUtils.colorStringToFloatA(oreColorOreGlimmersteel)); |
126 | } else { |
127 | XrayColors.addMapping(Tiles.Tile.TILE_CAVE_WALL_ORE_GLIMMERSTEEL, Color.YELLOW.brighter()); |
128 | } |
129 | String oreColorOreSilver = properties.getProperty("oreColorOreSilver", "default"); |
130 | if (!oreColorOreSilver.equals("default")) { |
131 | XrayColors.addMapping(Tiles.Tile.TILE_CAVE_WALL_ORE_SILVER, ConfigUtils.colorStringToFloatA(oreColorOreSilver)); |
132 | } else { |
133 | XrayColors.addMapping(Tiles.Tile.TILE_CAVE_WALL_ORE_SILVER, Color.LIGHT_GRAY); |
134 | } |
135 | String oreColorOreLead = properties.getProperty("oreColorOreLead", "default"); |
136 | if (!oreColorOreLead.equals("default")) { |
137 | XrayColors.addMapping(Tiles.Tile.TILE_CAVE_WALL_ORE_LEAD, ConfigUtils.colorStringToFloatA(oreColorOreLead)); |
138 | } else { |
139 | XrayColors.addMapping(Tiles.Tile.TILE_CAVE_WALL_ORE_LEAD, Color.PINK.darker().darker()); |
140 | } |
141 | String oreColorOreZinc = properties.getProperty("oreColorOreZinc", "default"); |
142 | if (!oreColorOreZinc.equals("default")) { |
143 | XrayColors.addMapping(Tiles.Tile.TILE_CAVE_WALL_ORE_ZINC, ConfigUtils.colorStringToFloatA(oreColorOreZinc)); |
144 | } else { |
145 | XrayColors.addMapping(Tiles.Tile.TILE_CAVE_WALL_ORE_ZINC, new Color(235, 235, 235)); |
146 | } |
147 | String oreColorSlate = properties.getProperty("oreColorSlate", "default"); |
148 | if (!oreColorSlate.equals("default")) { |
149 | XrayColors.addMapping(Tiles.Tile.TILE_CAVE_WALL_SLATE, ConfigUtils.colorStringToFloatA(oreColorSlate)); |
150 | } else { |
151 | XrayColors.addMapping(Tiles.Tile.TILE_CAVE_WALL_SLATE, Color.BLACK); |
152 | } |
153 | String oreColorMarble = properties.getProperty("oreColorMarble", "default"); |
154 | if (!oreColorMarble.equals("default")) { |
155 | XrayColors.addMapping(Tiles.Tile.TILE_CAVE_WALL_MARBLE, ConfigUtils.colorStringToFloatA(oreColorMarble)); |
156 | } else { |
157 | XrayColors.addMapping(Tiles.Tile.TILE_CAVE_WALL_MARBLE, Color.WHITE); |
158 | } |
159 | String oreColorSandstone = properties.getProperty("oreColorSandstone", "default"); |
160 | if (!oreColorSandstone.equals("default")) { |
161 | XrayColors.addMapping(Tiles.Tile.TILE_CAVE_WALL_SANDSTONE, ConfigUtils.colorStringToFloatA(oreColorSandstone)); |
162 | } else { |
163 | XrayColors.addMapping(Tiles.Tile.TILE_CAVE_WALL_SANDSTONE, Color.YELLOW.darker().darker()); |
164 | } |
165 | String oreColorRocksalt = properties.getProperty("oreColorRocksalt", "default"); |
166 | if (!oreColorRocksalt.equals("default")) { |
167 | XrayColors.addMapping(Tiles.Tile.TILE_CAVE_WALL_ROCKSALT, ConfigUtils.colorStringToFloatA(oreColorRocksalt)); |
168 | } else { |
169 | XrayColors.addMapping(Tiles.Tile.TILE_CAVE_WALL_ROCKSALT, Color.WHITE.darker()); |
170 | } |
171 | Unit.aggroMOBS = properties.getProperty("aggroMOBS").split(";"); |
172 | Unit.uniqueMOBS = properties.getProperty("uniqueMOBS").split(";"); |
173 | Unit.specialITEMS = properties.getProperty("specialITEMS").split(";"); |
174 | Unit.spottedITEMS = properties.getProperty("spottedITEMS").split(";"); |
175 | Unit.conditionedMOBS = properties.getProperty("conditionedMOBS").split(";"); |
176 | WurmEspMod.tilesFlowerSearch = properties.getProperty("tilesFlowerSearch").split(";"); |
177 | } |
178 | |
179 | private static float[] colorStringToFloatA(String color) { |
180 | String[] colors = color.split(","); |
181 | float[] colorf = new float[]{Float.valueOf(colors[0]).floatValue() / 255.0f, Float.valueOf(colors[1]).floatValue() / 255.0f, Float.valueOf(colors[2]).floatValue() / 255.0f}; |
182 | return colorf; |
183 | } |
184 | |
185 | private static String colorFloatAToString(float[] color) { |
186 | String colors = String.valueOf(color[0] * 255.0f) + "," + String.valueOf(color[1] * 255.0f) + "," + String.valueOf(color[2] * 255.0f); |
187 | return colors; |
188 | } |
189 | } |
190 | |