Stops the unnecessary saving of the groups file.

It would mark the groups file as changed every time the groups get
loaded from the file. That would cause a unnecessary save after '/as
reload' and after restart/reload of the server.
This commit is contained in:
Thijs Wiefferink 2014-12-07 00:04:46 +01:00
parent 9957e02e65
commit e23ad74744
2 changed files with 5 additions and 5 deletions

View File

@ -483,6 +483,7 @@ public class FileManager {
* Save the group file to disk
*/
public void saveGroupsIsRequired() {
AreaShop.debug("saveGroupsRequired() set");
saveGroupsRequired = true;
}
public boolean isSaveGroupsRequired() {
@ -490,6 +491,7 @@ public class FileManager {
}
public void saveGroupsNow() {
AreaShop.debug("saveGroupsNow() done");
saveGroupsRequired = false;
try {
groupsConfig.save(groupsPath);

View File

@ -23,6 +23,7 @@ public class RegionGroup {
setSetting("name", name);
// Delete duplicates
List<String> members = getMembers();
int previousCount = members.size();
List<String> newMembers = new ArrayList<String>();
while(!members.isEmpty()) {
String member = members.remove(0);
@ -34,8 +35,9 @@ public class RegionGroup {
members.remove(member);
}
}
if(newMembers.size() != members.size()) {
if(newMembers.size() != previousCount) {
setSetting("regions", newMembers);
AreaShop.debug("group save required because of changed member size");
saveRequired();
}
if(getMembers().size() == 0) {
@ -55,8 +57,6 @@ public class RegionGroup {
} else {
members.add(region.getName());
setSetting("regions", members);
region.updateSigns();
region.updateRegionFlags();
return true;
}
}
@ -75,8 +75,6 @@ public class RegionGroup {
} else {
setSetting("regions", members);
}
region.updateSigns();
region.updateRegionFlags();
return result;
}