- Fix for Users.yml containing only 'users:' causing a crash.

- GroupManager will now generate a fresh Users and Groups yml if either
file is empty.
This commit is contained in:
ElgarL 2011-09-03 16:13:43 +01:00
parent 8f28073b29
commit e3756623a1
4 changed files with 11 additions and 4 deletions

View File

@ -6,3 +6,5 @@ v 1.1:
- Added more helpful output to errors on argument lengths. - Added more helpful output to errors on argument lengths.
- GroupManager will now attempt to select the default world when using commands instead of failing and telling you to use '/manselect <world>'. - GroupManager will now attempt to select the default world when using commands instead of failing and telling you to use '/manselect <world>'.
- Invalid groups assigned to players in users.yml will no longer cause a crash. GM will now set them to the default group instead. - Invalid groups assigned to players in users.yml will no longer cause a crash. GM will now set them to the default group instead.
- Fix for Users.yml containing only 'users:' causing a crash.
- GroupManager will now generate a fresh Users and Groups yml if either file is empty.

View File

@ -578,6 +578,11 @@ public class WorldDataHolder {
// PROCESS USERS FILE // PROCESS USERS FILE
Map<String, Object> allUsersNode = (Map<String, Object>) usersRootDataNode.get("users"); Map<String, Object> allUsersNode = (Map<String, Object>) usersRootDataNode.get("users");
// Stop loading if the file is empty
if (allUsersNode == null)
return ph;
for (String usersKey : allUsersNode.keySet()) { for (String usersKey : allUsersNode.keySet()) {
Map<String, Object> thisUserNode = (Map<String, Object>) allUsersNode.get(usersKey); Map<String, Object> thisUserNode = (Map<String, Object>) allUsersNode.get(usersKey);
User thisUser = ph.createUser(usersKey); User thisUser = ph.createUser(usersKey);

View File

@ -265,7 +265,7 @@ public class WorldsHolder {
File groupsFile = new File(defaultWorldFolder, "groups.yml"); File groupsFile = new File(defaultWorldFolder, "groups.yml");
File usersFile = new File(defaultWorldFolder, "users.yml"); File usersFile = new File(defaultWorldFolder, "users.yml");
File oldDataFile = new File(plugin.getDataFolder(), "data.yml"); File oldDataFile = new File(plugin.getDataFolder(), "data.yml");
if (!groupsFile.exists()) { if (!groupsFile.exists() || groupsFile.length() == 0) {
if (oldDataFile.exists()) { if (oldDataFile.exists()) {
try { try {
Tasks.copy(oldDataFile, groupsFile); Tasks.copy(oldDataFile, groupsFile);
@ -281,7 +281,7 @@ public class WorldsHolder {
} }
} }
} }
if (!usersFile.exists()) { if (!usersFile.exists() || usersFile.length() == 0) {
if (oldDataFile.exists()) { if (oldDataFile.exists()) {
try { try {
Tasks.copy(oldDataFile, usersFile); Tasks.copy(oldDataFile, usersFile);

View File

@ -1,5 +1,5 @@
name: GroupManager name: GroupManager
version: "1.1" version: "1.1 (Phoenix)"
main: org.anjocaido.groupmanager.GroupManager main: org.anjocaido.groupmanager.GroupManager
website: http://www.anjocaido.info/ website: http://www.anjocaido.info/
description: Provides on-the-fly system for Permission system created by Nijikokun. But all in memory, and with flat-file saving schedule. description: Provides on-the-fly system for Permission system created by Nijikokun. But all in memory, and with flat-file saving schedule.