Better handle empty group / player names due to bad region data.

Fixes WORLDGUARD-3182.
This commit is contained in:
sk89q 2014-11-10 23:59:57 -08:00
parent dac09c64c8
commit 41f520845a
2 changed files with 11 additions and 11 deletions

View File

@ -27,7 +27,6 @@
import java.util.UUID;
import java.util.concurrent.CopyOnWriteArraySet;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
/**
@ -63,9 +62,10 @@ public GroupDomain(String[] groups) {
*/
public void addGroup(String name) {
checkNotNull(name);
checkArgument(!name.trim().isEmpty(), "Can't add empty group name");
setDirty(true);
groups.add(name.trim().toLowerCase());
if (!name.trim().isEmpty()) {
setDirty(true);
groups.add(name.trim().toLowerCase());
}
}
/**

View File

@ -27,7 +27,6 @@
import java.util.UUID;
import java.util.concurrent.CopyOnWriteArraySet;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
/**
@ -65,12 +64,13 @@ public PlayerDomain(String[] names) {
*/
public void addPlayer(String name) {
checkNotNull(name);
checkArgument(!name.trim().isEmpty(), "Can't add empty player name");
setDirty(true);
names.add(name.trim().toLowerCase());
// Trim because some names contain spaces (previously valid Minecraft
// names) and we cannot store these correctly in the SQL storage
// implementations
if (!name.trim().isEmpty()) {
setDirty(true);
names.add(name.trim().toLowerCase());
// Trim because some names contain spaces (previously valid Minecraft
// names) and we cannot store these correctly in the SQL storage
// implementations
}
}
/**