--- /dev/null
+package com.swabunga.spell.engine;\r
+\r
+import java.io.File;\r
+import java.io.FileNotFoundException;\r
+import java.io.FileOutputStream;\r
+import java.io.IOException;\r
+import java.io.InputStream;\r
+import java.net.URL;\r
+import java.util.Properties;\r
+\r
+\r
+/**\r
+ * @author aim4min\r
+ *\r
+ * To change this generated comment edit the template variable "typecomment":\r
+ * Window>Preferences>Java>Templates.\r
+ * To enable and disable the creation of type comments go to\r
+ * Window>Preferences>Java>Code Generation.\r
+ */\r
+public class PropertyConfiguration extends Configuration {\r
+\r
+ public Properties prop;\r
+ public URL filename;\r
+ \r
+ public PropertyConfiguration() {\r
+ prop = new Properties();\r
+ try {\r
+/*\r
+ //original initalization code\r
+ filename = getClass().getClassLoader().getResource("com/swabunga/spell/engine/configuration.properties");\r
+ InputStream in = filename.openStream();\r
+ prop.load(in);\r
+*/\r
+ // new constructor code so that this works within JAR files (Howard Kistler)\r
+ InputStream is = this.getClass().getResourceAsStream("configuration.properties");\r
+ prop.load(is);\r
+ } catch (Exception e) {\r
+ System.out.println("Could not load Properties file :\n" + e);\r
+ }\r
+ }\r
+\r
+ /**\r
+ * @see com.swabunga.spell.engine.Configuration#getBoolean(String)\r
+ */\r
+ public boolean getBoolean(String key) {\r
+// return Boolean.getBoolean(prop.getProperty(key));\r
+// original breaks inside applets due to security, this version works fine (Howard Kistler)\r
+ return prop.getProperty(key).equalsIgnoreCase("true");\r
+ }\r
+\r
+ /**\r
+ * @see com.swabunga.spell.engine.Configuration#getInteger(String)\r
+ */\r
+ public int getInteger(String key) {\r
+ return Integer.parseInt(prop.getProperty(key));\r
+ }\r
+\r
+ /**\r
+ * @see com.swabunga.spell.engine.Configuration#setBoolean(String, boolean)\r
+ */\r
+ public void setBoolean(String key, boolean value) {\r
+ String string = null;\r
+ if (value)\r
+ string = "true";\r
+ else\r
+ string = "false";\r
+ \r
+ prop.setProperty(key, string);\r
+ save();\r
+ }\r
+\r
+ /**\r
+ * @see com.swabunga.spell.engine.Configuration#setInteger(String, int)\r
+ */\r
+ public void setInteger(String key, int value) {\r
+ prop.setProperty(key,Integer.toString(value));\r
+ save();\r
+ }\r
+ \r
+ public void save() {\r
+ try {\r
+ File file = new File(filename.getFile());\r
+ FileOutputStream fout = new FileOutputStream(file);\r
+ prop.store(fout,"HEADER");\r
+ } catch (FileNotFoundException e) {\r
+ } catch (IOException e) {\r
+ }\r
+ }\r
+\r
+}\r