Jubaroo

Wurm Unlimited Properties Example

Oct 26th, 2017
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.         for (String name : properties.stringPropertyNames()) {
  2.             try {
  3.                 String value = properties.getProperty(name);
  4.                 switch (name) {
  5.                     case "debug":
  6.                     case "classname":
  7.                     case "classpath":
  8.                     case "sharedClassLoader":
  9.                         break; //ignore
  10.                     default:
  11.                         if (name.startsWith("casttime")) {
  12.                             String[] split = value.split(",");
  13.                             String spellname = split[0];
  14.                             int newVal = Integer.parseInt(split[1]);
  15.                             spellCastTimes.put(spellname, newVal);
  16.                         } else if (name.startsWith("cost")) {
  17.                             String[] split = value.split(",");
  18.                             String spellname = split[0];
  19.                             int newVal = Integer.parseInt(split[1]);
  20.                             spellCosts.put(spellname, newVal);
  21.                         } else if (name.startsWith("difficulty")) {
  22.                             String[] split = value.split(",");
  23.                             String spellname = split[0];
  24.                             int newVal = Integer.parseInt(split[1]);
  25.                             spellDifficulties.put(spellname, newVal);
  26.                         } else if (name.startsWith("faith")) {
  27.                             String[] split = value.split(",");
  28.                             String spellname = split[0];
  29.                             int newVal = Integer.parseInt(split[1]);
  30.                             spellFaithRequirements.put(spellname, newVal);
  31.                         } else if (name.startsWith("cooldown")) {
  32.                             String[] split = value.split(",");
  33.                             String spellname = split[0];
  34.                             long newVal = Long.parseLong(split[1]);
  35.                             spellCooldowns.put(spellname, newVal);
  36.                         } else if (name.startsWith("addspell")) {
  37.                             String[] split = value.split(";");
  38.                             String spellname = split[0];
  39.                             List<String> deityList = Arrays.asList(split[1].split(","));
  40.                             addSpells.put(spellname, deityList);
  41.                         } else if (name.startsWith("removespell")) {
  42.                             String[] split = value.split(";");
  43.                             String spellname = split[0];
  44.                             List<String> deityList = Arrays.asList(split[1].split(","));
  45.                             removeSpells.put(spellname, deityList);
  46.                         } else {
  47.                             //Debug("Unknown config property: " + name);
  48.                         }
  49.                 }
  50.             } catch (Exception e) {
  51.                 Debug("Error processing property " + name);
  52.                 e.printStackTrace();
  53.             }
  54.         }
Add Comment
Please, Sign In to add comment