Fix parent set command also adding default

This commit is contained in:
Luck 2017-03-25 20:06:30 +00:00
parent 2573f46f40
commit ebb24aefa1
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
4 changed files with 16 additions and 17 deletions

View File

@ -261,17 +261,17 @@ public class PermissionHolderDelegate implements PermissionHolder {
@Override
public void clearParents() {
master.clearParents();
master.clearParents(true);
}
@Override
public void clearParents(String server) {
master.clearParents(server);
master.clearParents(server, true);
}
@Override
public void clearParents(String server, String world) {
master.clearParents(server, world);
master.clearParents(server, world, true);
}
@Override

View File

@ -58,13 +58,13 @@ public class ParentClear extends SharedSubCommand {
switch (ContextHelper.determine(server, world)) {
case NONE:
holder.clearParents();
holder.clearParents(true);
break;
case SERVER:
holder.clearParents(server);
holder.clearParents(server, true);
break;
case SERVER_AND_WORLD:
holder.clearParents(server, world);
holder.clearParents(server, world, true);
break;
}

View File

@ -75,7 +75,7 @@ public class ParentSet extends SharedSubCommand {
switch (ContextHelper.determine(server, world)) {
case NONE:
holder.clearParents(null, null);
holder.clearParents(null, null, false);
try {
holder.setInheritGroup(group);
@ -88,12 +88,11 @@ public class ParentSet extends SharedSubCommand {
Message.SET_PARENT_SUCCESS.send(sender, holder.getFriendlyName(), group.getDisplayName());
break;
case SERVER:
holder.clearParents(server, null);
holder.clearParents(server, null, false);
try {
holder.setInheritGroup(group, server);
} catch (ObjectAlreadyHasException ignored) {
}
} catch (ObjectAlreadyHasException ignored) {}
if (server.equalsIgnoreCase("global") && holder instanceof User) {
((User) holder).getPrimaryGroup().setStoredValue(group.getName());
@ -102,7 +101,7 @@ public class ParentSet extends SharedSubCommand {
Message.SET_PARENT_SERVER_SUCCESS.send(sender, holder.getFriendlyName(), group.getDisplayName(), server);
break;
case SERVER_AND_WORLD:
holder.clearParents(server, world);
holder.clearParents(server, world, false);
try {
holder.setInheritGroup(group, server, world);

View File

@ -1130,7 +1130,7 @@ public abstract class PermissionHolder {
plugin.getApiProvider().getEventFactory().handleNodeClear(this, before, after);
}
public void clearParents() {
public void clearParents(boolean giveDefault) {
ImmutableSet<Node> before = ImmutableSet.copyOf(getNodes().values());
synchronized (nodes) {
@ -1139,7 +1139,7 @@ public abstract class PermissionHolder {
return;
}
}
if (this instanceof User) {
if (this instanceof User && giveDefault) {
plugin.getUserManager().giveDefaultIfNeeded((User) this, false);
}
invalidateCache();
@ -1147,7 +1147,7 @@ public abstract class PermissionHolder {
plugin.getApiProvider().getEventFactory().handleNodeClear(this, before, after);
}
public void clearParents(String server) {
public void clearParents(String server, boolean giveDefault) {
String finalServer = Optional.ofNullable(server).orElse("global");
ImmutableSet<Node> before = ImmutableSet.copyOf(getNodes().values());
@ -1159,7 +1159,7 @@ public abstract class PermissionHolder {
return;
}
}
if (this instanceof User) {
if (this instanceof User && giveDefault) {
plugin.getUserManager().giveDefaultIfNeeded((User) this, false);
}
invalidateCache();
@ -1167,7 +1167,7 @@ public abstract class PermissionHolder {
plugin.getApiProvider().getEventFactory().handleNodeClear(this, before, after);
}
public void clearParents(String server, String world) {
public void clearParents(String server, String world, boolean giveDefault) {
String finalServer = Optional.ofNullable(server).orElse("global");
String finalWorld = Optional.ofNullable(world).orElse("null");
@ -1182,7 +1182,7 @@ public abstract class PermissionHolder {
return;
}
}
if (this instanceof User) {
if (this instanceof User && giveDefault) {
plugin.getUserManager().giveDefaultIfNeeded((User) this, false);
}
invalidateCache();