mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-11-18 00:25:32 +01:00
Merge remote branch 'remotes/ess/groupmanager' into essmaster
This commit is contained in:
commit
90c9fe7e65
@ -69,4 +69,5 @@ v 1.5:
|
||||
If the files have been altered (on disc) it will reload, so long as the in-memory data hasn't changed.
|
||||
If the files on Disc have changed AND there have been changes to it's in-memory data it will show a warning.
|
||||
You then MUST issue a '/mansave force' to overwrite the disc files, or a '/manload' to overwrite the memory data.
|
||||
- Fix for an error in checkFullUserPermission caused by players disconnecting mid perms update.
|
||||
- Fix for an error in checkFullUserPermission caused by players disconnecting mid perms update.
|
||||
- Notification of being moved to the default group only happens if it's a demotion/promotion (not on join).
|
@ -83,7 +83,6 @@ public class GlobalGroups {
|
||||
public void load() {
|
||||
|
||||
GGroups = new YamlConfiguration();
|
||||
groups = new HashMap<String, Group>();
|
||||
|
||||
GroupManager.setLoaded(false);
|
||||
|
||||
@ -110,7 +109,9 @@ public class GlobalGroups {
|
||||
Map<String, Object> allGroups = (Map<String, Object>) GGroups.getConfigurationSection("groups").getValues(false);
|
||||
|
||||
// Load each groups permissions list.
|
||||
if (allGroups != null)
|
||||
if (allGroups != null) {
|
||||
// Clear out old groups
|
||||
resetGlobalGroups();
|
||||
for (String groupName : allGroups.keySet()) {
|
||||
Group newGroup = new Group(groupName.toLowerCase());
|
||||
Object element;
|
||||
@ -144,12 +145,12 @@ public class GlobalGroups {
|
||||
// Push a new group
|
||||
addGroup(newGroup);
|
||||
}
|
||||
}
|
||||
|
||||
removeGroupsChangedFlag();
|
||||
setTimeStampGroups(GlobalGroupsFile.lastModified());
|
||||
GroupManager.setLoaded(true);
|
||||
//GlobalGroupsFile = null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -351,6 +352,13 @@ public class GlobalGroups {
|
||||
return groups.keySet();
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets GlobalGroups.
|
||||
*/
|
||||
public void resetGlobalGroups() {
|
||||
this.groups = new HashMap<String, Group>();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return a collection of the groups
|
||||
|
@ -76,8 +76,13 @@ public class Group extends DataUnit implements Cloneable {
|
||||
if (dataSource.groupExists(this.getName())) {
|
||||
return null;
|
||||
}
|
||||
Group clone = getDataSource().createGroup(this.getName());
|
||||
clone.inherits = new ArrayList<String>(this.getInherits());
|
||||
|
||||
Group clone = dataSource.createGroup(this.getName());
|
||||
|
||||
// Don't add inheritance for GlobalGroups
|
||||
if (getDataSource() != null) {
|
||||
clone.inherits = new ArrayList<String>(this.getInherits());
|
||||
}
|
||||
for (String perm : this.getPermissionList()) {
|
||||
clone.addPermission(perm);
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ public class User extends DataUnit implements Cloneable {
|
||||
if (dataSource.getGroup(group) == null) {
|
||||
clone.setGroup(dataSource.getDefaultGroup());
|
||||
} else {
|
||||
clone.setGroup(this.getGroupName());
|
||||
clone.setGroup(dataSource.getGroup(this.getGroupName()));
|
||||
}
|
||||
for (String perm : this.getPermissionList()) {
|
||||
clone.addPermission(perm);
|
||||
@ -117,13 +117,20 @@ public class User extends DataUnit implements Cloneable {
|
||||
getDataSource().addGroup(group);
|
||||
}
|
||||
group = getDataSource().getGroup(group.getName());
|
||||
String oldGroup = this.group;
|
||||
this.group = group.getName();
|
||||
flagAsChanged();
|
||||
if (GroupManager.isLoaded()) {
|
||||
if (GroupManager.BukkitPermissions.player_join = false)
|
||||
GroupManager.BukkitPermissions.updateAllPlayers();
|
||||
|
||||
// Do we notify of the group change?
|
||||
String defaultGroupName = getDataSource().getDefaultGroup().getName();
|
||||
// if we were not in the default group
|
||||
// or we were in the default group and the move is to a different group.
|
||||
boolean notify = (!oldGroup.equalsIgnoreCase(defaultGroupName)) || ((oldGroup.equalsIgnoreCase(defaultGroupName)) && (!this.group.equalsIgnoreCase(defaultGroupName))) ;
|
||||
|
||||
GroupManager.notify(this.getName(), String.format(" moved to the group %s.", group.getName()));
|
||||
if (notify) GroupManager.notify(this.getName(), String.format(" moved to the group %s.", group.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ import org.yaml.snakeyaml.reader.UnicodeReader;
|
||||
public class WorldDataHolder {
|
||||
|
||||
/**
|
||||
*
|
||||
* World name
|
||||
*/
|
||||
protected String name;
|
||||
/**
|
||||
@ -321,24 +321,58 @@ public class WorldDataHolder {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh Group data from file
|
||||
*/
|
||||
public void reloadGroups() {
|
||||
GroupManager.setLoaded(false);
|
||||
try {
|
||||
resetGroups();
|
||||
loadGroups(this, getGroupsFile());
|
||||
// temporary holder in case the load fails.
|
||||
WorldDataHolder ph = new WorldDataHolder(this.getName());
|
||||
|
||||
loadGroups(ph, getGroupsFile());
|
||||
// transfer new data
|
||||
resetGroups();
|
||||
for (Group tempGroup : ph.getGroupList()) {
|
||||
tempGroup.clone(this);
|
||||
}
|
||||
this.setDefaultGroup(this.getGroup(ph.getDefaultGroup().getName()));
|
||||
this.removeGroupsChangedFlag();
|
||||
this.timeStampGroups = ph.getTimeStampGroups();
|
||||
|
||||
ph = null;
|
||||
} catch (Exception ex) {
|
||||
Logger.getLogger(WorldDataHolder.class.getName()).log(Level.SEVERE, null, ex);
|
||||
Logger.getLogger(WorldDataHolder.class.getName()).log(Level.WARNING, null, ex);
|
||||
}
|
||||
GroupManager.setLoaded(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh Users data from file
|
||||
*/
|
||||
public void reloadUsers() {
|
||||
GroupManager.setLoaded(false);
|
||||
try {
|
||||
resetUsers();
|
||||
loadUsers(this, getUsersFile());
|
||||
// temporary holder in case the load fails.
|
||||
WorldDataHolder ph = new WorldDataHolder(this.getName());
|
||||
// copy groups for reference
|
||||
for (Group tempGroup : this.getGroupList()) {
|
||||
tempGroup.clone(ph);
|
||||
}
|
||||
// setup the default group before loading user data.
|
||||
ph.setDefaultGroup(ph.getGroup(this.getDefaultGroup().getName()));
|
||||
loadUsers(ph, getUsersFile());
|
||||
// transfer new data
|
||||
resetUsers();
|
||||
for (User tempUser : ph.getUserList()) {
|
||||
tempUser.clone(this);
|
||||
}
|
||||
this.removeUsersChangedFlag();
|
||||
this.timeStampUsers = ph.getTimeStampUsers();
|
||||
|
||||
ph = null;
|
||||
} catch (Exception ex) {
|
||||
Logger.getLogger(WorldDataHolder.class.getName()).log(Level.SEVERE, null, ex);
|
||||
Logger.getLogger(WorldDataHolder.class.getName()).log(Level.WARNING, null, ex);
|
||||
}
|
||||
GroupManager.setLoaded(true);
|
||||
}
|
||||
@ -523,29 +557,6 @@ public class WorldDataHolder {
|
||||
return ph;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the WorldDataHolder from the files
|
||||
*
|
||||
* @param ph
|
||||
* @param groupsFile
|
||||
* @param usersFile
|
||||
*
|
||||
* @throws FileNotFoundException
|
||||
* @throws IOException
|
||||
*/
|
||||
public static WorldDataHolder Update(WorldDataHolder ph, File groupsFile, File usersFile) throws FileNotFoundException, IOException {
|
||||
|
||||
GroupManager.setLoaded(false);
|
||||
ph.resetGroups();
|
||||
loadGroups(ph, groupsFile);
|
||||
|
||||
ph.resetUsers();
|
||||
loadUsers(ph, usersFile);
|
||||
GroupManager.setLoaded(true);
|
||||
|
||||
return ph;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the WorldDataHolder from the Groups file
|
||||
*
|
||||
@ -591,7 +602,7 @@ public class WorldDataHolder {
|
||||
}
|
||||
if ((Boolean.parseBoolean(thisGroupNode.get("default").toString()))) {
|
||||
if (ph.getDefaultGroup() != null) {
|
||||
GroupManager.logger.warning("The group " + thisGrp.getName() + " is declaring be default where" + ph.getDefaultGroup().getName() + " already was.");
|
||||
GroupManager.logger.warning("The group " + thisGrp.getName() + " is claiming to be default where" + ph.getDefaultGroup().getName() + " already was.");
|
||||
GroupManager.logger.warning("Overriding first request.");
|
||||
}
|
||||
ph.setDefaultGroup(thisGrp);
|
||||
@ -662,7 +673,7 @@ public class WorldDataHolder {
|
||||
ph.removeGroupsChangedFlag();
|
||||
// Update the LastModified time.
|
||||
ph.groupsFile = groupsFile;
|
||||
ph.setTimeStamps();
|
||||
ph.setTimeStampGroups(groupsFile.lastModified());
|
||||
|
||||
//return ph;
|
||||
}
|
||||
@ -769,7 +780,7 @@ public class WorldDataHolder {
|
||||
ph.removeUsersChangedFlag();
|
||||
// Update the LastModified time.
|
||||
ph.usersFile = usersFile;
|
||||
ph.setTimeStamps();
|
||||
ph.setTimeStampUsers(usersFile.lastModified());
|
||||
|
||||
//return ph;
|
||||
}
|
||||
|
@ -200,8 +200,8 @@ public class WorldsHolder {
|
||||
//Check for newer file as no local changes.
|
||||
if (w.getTimeStampGroups() < w.getGroupsFile().lastModified()) {
|
||||
System.out.print("Newer Groups file found (Loading changes)!");
|
||||
// Backup Users file
|
||||
backupFile(w,false);
|
||||
// Backup Groups file
|
||||
backupFile(w,true);
|
||||
w.reloadGroups();
|
||||
}
|
||||
}
|
||||
|
@ -4,12 +4,12 @@ users:
|
||||
subgroups: []
|
||||
permissions: []
|
||||
group: Admin
|
||||
mudzereli:
|
||||
KHobbits:
|
||||
subgroups: []
|
||||
permissions: []
|
||||
group: Builder
|
||||
group: Moderator
|
||||
ElgarL:
|
||||
subgroups: []
|
||||
permissions: []
|
||||
group: Admin
|
||||
group: Owner
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user