package markehme.FactionsPerms.obj;

import java.util.HashMap;
import java.util.Map.Entry;

import markehme.FactionsPerms.FactionsPerms;

/**
 * Each user gets one of these that is defined in the permissions.yml file.
 * These are stored in FactionsPerms.userSet. 
 * @author MarkehMe <mark@markeh.me>
 *
 */
public class PermissionUser {
	public HashMap<String, Boolean> validPerms;
	public HashMap<String, Group> inGroups;
	
	public PermissionUser(String PlayerName, HashMap<String, String> playerpermissions, HashMap<String, String> groups) {
		
		// Store all groups 
		for(Entry<String, Group> entry : FactionsPerms.permissionsSet.entrySet()) {
			//String key = entry.getKey();
			inGroups.put(entry.getKey(), entry.getValue());
		}
		
		// Now apply user specific permissions 
		for(Entry<String, String> entry : playerpermissions.entrySet()) {
			//String key = entry.getKey();
			String value = entry.getValue().toLowerCase();
			
			if(value.startsWith("-")) {
				// Remove existing permission
				validPerms.remove(value.substring(1));
				
				// is a negative permission, so make it a false value 
				validPerms.put(value.substring(1), false);
			} else {
				// Remove existing permission
				validPerms.remove(value);
				
				// is a normal permission, so make a true value 
				validPerms.put(value, true);
			}
		}
	}	
}

@@ -332,32 +332,39 @@
 nUser %7B%0A%09public 
+static 
 HashMap%3CString, 
@@ -392,16 +392,23 @@
 %09public 
+static 
 HashMap%3C
@@ -434,16 +434,52 @@
 oups;%0A%09%0A
+%09public static String playerName;%0A%09%0A
 %09public 
@@ -528,22 +528,23 @@
 String, 
-String
+Boolean
 %3E player
@@ -589,24 +589,54 @@
 roups) %7B%0A%09%09%0A
+%09%09playerName = PlayerName;%0A%09%09%0A
 %09%09// Store a
@@ -878,22 +878,23 @@
 String, 
-String
+Boolean
 %3E entry 
@@ -922,34 +922,32 @@
 ntrySet()) %7B%0A%09%09%09
-//
 String key = ent
@@ -957,21 +957,37 @@
 getKey()
+.toLowerCase()
 ;%0A%09%09%09
+//
 String v
@@ -1009,30 +1009,16 @@
 tValue()
-.toLowerCase()
 ;%0A%09%09%09%0A%09%09
@@ -1021,21 +1021,19 @@
 %09%0A%09%09%09if(
-value
+key
 .startsW
@@ -1100,21 +1100,19 @@
 .remove(
-value
+key
 .substri
@@ -1202,21 +1202,19 @@
 rms.put(
-value
+key
 .substri
@@ -1296,21 +1296,19 @@
 .remove(
-value
+key
 );%0A%09%09%09%09%0A
@@ -1379,21 +1379,19 @@
 rms.put(
-value
+key
 , true);

Use the key - not value!