mirror of
https://github.com/essentials/Essentials.git
synced 2025-08-16 11:37:30 +02:00
Minor optimization for Group loading/clone
This commit is contained in:
@@ -83,7 +83,6 @@ public class GlobalGroups {
|
|||||||
public void load() {
|
public void load() {
|
||||||
|
|
||||||
GGroups = new YamlConfiguration();
|
GGroups = new YamlConfiguration();
|
||||||
groups = new HashMap<String, Group>();
|
|
||||||
|
|
||||||
GroupManager.setLoaded(false);
|
GroupManager.setLoaded(false);
|
||||||
|
|
||||||
@@ -110,7 +109,9 @@ public class GlobalGroups {
|
|||||||
Map<String, Object> allGroups = (Map<String, Object>) GGroups.getConfigurationSection("groups").getValues(false);
|
Map<String, Object> allGroups = (Map<String, Object>) GGroups.getConfigurationSection("groups").getValues(false);
|
||||||
|
|
||||||
// Load each groups permissions list.
|
// Load each groups permissions list.
|
||||||
if (allGroups != null)
|
if (allGroups != null) {
|
||||||
|
// Clear out old groups
|
||||||
|
resetGlobalGroups();
|
||||||
for (String groupName : allGroups.keySet()) {
|
for (String groupName : allGroups.keySet()) {
|
||||||
Group newGroup = new Group(groupName.toLowerCase());
|
Group newGroup = new Group(groupName.toLowerCase());
|
||||||
Object element;
|
Object element;
|
||||||
@@ -144,12 +145,12 @@ public class GlobalGroups {
|
|||||||
// Push a new group
|
// Push a new group
|
||||||
addGroup(newGroup);
|
addGroup(newGroup);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
removeGroupsChangedFlag();
|
removeGroupsChangedFlag();
|
||||||
setTimeStampGroups(GlobalGroupsFile.lastModified());
|
setTimeStampGroups(GlobalGroupsFile.lastModified());
|
||||||
GroupManager.setLoaded(true);
|
GroupManager.setLoaded(true);
|
||||||
//GlobalGroupsFile = null;
|
//GlobalGroupsFile = null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -351,6 +352,13 @@ public class GlobalGroups {
|
|||||||
return groups.keySet();
|
return groups.keySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resets GlobalGroups.
|
||||||
|
*/
|
||||||
|
public void resetGlobalGroups() {
|
||||||
|
this.groups = new HashMap<String, Group>();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return a collection of the groups
|
* @return a collection of the groups
|
||||||
|
@@ -334,11 +334,13 @@ public class WorldDataHolder {
|
|||||||
// transfer new data
|
// transfer new data
|
||||||
resetGroups();
|
resetGroups();
|
||||||
for (Group tempGroup : ph.getGroupList()) {
|
for (Group tempGroup : ph.getGroupList()) {
|
||||||
if (tempGroup.getDataSource() != null) tempGroup.clone(this);
|
tempGroup.clone(this);
|
||||||
}
|
}
|
||||||
this.setDefaultGroup(this.getGroup(ph.getDefaultGroup().getName()));
|
this.setDefaultGroup(this.getGroup(ph.getDefaultGroup().getName()));
|
||||||
this.removeGroupsChangedFlag();
|
this.removeGroupsChangedFlag();
|
||||||
this.timeStampGroups = ph.getTimeStampGroups();
|
this.timeStampGroups = ph.getTimeStampGroups();
|
||||||
|
|
||||||
|
ph = null;
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
Logger.getLogger(WorldDataHolder.class.getName()).log(Level.WARNING, null, ex);
|
Logger.getLogger(WorldDataHolder.class.getName()).log(Level.WARNING, null, ex);
|
||||||
}
|
}
|
||||||
@@ -355,7 +357,7 @@ public class WorldDataHolder {
|
|||||||
WorldDataHolder ph = new WorldDataHolder(this.getName());
|
WorldDataHolder ph = new WorldDataHolder(this.getName());
|
||||||
// copy groups for reference
|
// copy groups for reference
|
||||||
for (Group tempGroup : this.getGroupList()) {
|
for (Group tempGroup : this.getGroupList()) {
|
||||||
if (tempGroup.getDataSource() != null) tempGroup.clone(ph);
|
tempGroup.clone(ph);
|
||||||
}
|
}
|
||||||
// setup the default group before loading user data.
|
// setup the default group before loading user data.
|
||||||
ph.setDefaultGroup(ph.getGroup(this.getDefaultGroup().getName()));
|
ph.setDefaultGroup(ph.getGroup(this.getDefaultGroup().getName()));
|
||||||
@@ -367,6 +369,8 @@ public class WorldDataHolder {
|
|||||||
}
|
}
|
||||||
this.removeUsersChangedFlag();
|
this.removeUsersChangedFlag();
|
||||||
this.timeStampUsers = ph.getTimeStampUsers();
|
this.timeStampUsers = ph.getTimeStampUsers();
|
||||||
|
|
||||||
|
ph = null;
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
Logger.getLogger(WorldDataHolder.class.getName()).log(Level.WARNING, null, ex);
|
Logger.getLogger(WorldDataHolder.class.getName()).log(Level.WARNING, null, ex);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user