GenuineSounds

ModLoader with LinkedProperties

Jun 17th, 2012
197
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.19 KB | None | 0 0
  1. // new imports
  2. import java.util.Collections;
  3. import java.util.Enumeration;
  4. import java.util.LinkedHashSet;
  5. import java.util.Properties;
  6.  
  7. // Put anywhere in ModLoader.java
  8. /**
  9.  * LinkedProperties retains the put order, loads and save
  10.  * no problem and remains perfectly sound and stable.
  11.  */
  12. public static class LinkedProperties extends Properties {
  13.  
  14.     private final LinkedHashSet<Object> keys = new LinkedHashSet<Object>();
  15.  
  16.     public Enumeration<Object> keys() {
  17.         return Collections.<Object> enumeration(keys);
  18.     }
  19.  
  20.     public Object put(Object key, Object value) {
  21.         keys.add(key);
  22.         return super.put(key, value);
  23.     }
  24. }
  25.  
  26. // --------------------------------------------------------------------------------------
  27. //                Changed only one thing in the method marked by comment.
  28. // --------------------------------------------------------------------------------------
  29. private static void setupProperties(Class class1) throws IllegalArgumentException, IllegalAccessException, IOException, SecurityException, NoSuchFieldException, NoSuchAlgorithmException, DigestException {
  30.         LinkedList linkedlist = new LinkedList();
  31.         Properties properties = new LinkedProperties(); // This instead.
Advertisement
Comments
  • User was banned
Add Comment
Please, Sign In to add comment