Don't call NodeAddEvent when adding the default group (#1177)

This commit is contained in:
Luck 2018-08-27 22:06:49 +01:00
parent 066189b486
commit c59f2ab37a
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
2 changed files with 8 additions and 2 deletions

View File

@ -124,7 +124,7 @@ public abstract class AbstractUserManager<T extends User> extends AbstractManage
if (!hasGroup) { if (!hasGroup) {
user.getPrimaryGroup().setStoredValue(NodeFactory.DEFAULT_GROUP_NAME); user.getPrimaryGroup().setStoredValue(NodeFactory.DEFAULT_GROUP_NAME);
user.setPermission(NodeFactory.buildGroupNode(NodeFactory.DEFAULT_GROUP_NAME).build()); user.setPermission(NodeFactory.buildGroupNode(NodeFactory.DEFAULT_GROUP_NAME).build(), false);
work = true; work = true;
} }

View File

@ -536,6 +536,10 @@ public abstract class PermissionHolder {
* @param node the node to set * @param node the node to set
*/ */
public DataMutateResult setPermission(Node node) { public DataMutateResult setPermission(Node node) {
return setPermission(node, true);
}
public DataMutateResult setPermission(Node node, boolean callEvent) {
if (hasPermission(NodeMapType.ENDURING, node, StandardNodeEquality.IGNORE_EXPIRY_TIME_AND_VALUE) != Tristate.UNDEFINED) { if (hasPermission(NodeMapType.ENDURING, node, StandardNodeEquality.IGNORE_EXPIRY_TIME_AND_VALUE) != Tristate.UNDEFINED) {
return DataMutateResult.ALREADY_HAS; return DataMutateResult.ALREADY_HAS;
} }
@ -545,7 +549,9 @@ public abstract class PermissionHolder {
invalidateCache(); invalidateCache();
ImmutableCollection<? extends Node> after = enduringData().immutable().values(); ImmutableCollection<? extends Node> after = enduringData().immutable().values();
this.plugin.getEventFactory().handleNodeAdd(node, this, before, after); if (callEvent) {
this.plugin.getEventFactory().handleNodeAdd(node, this, before, after);
}
return DataMutateResult.SUCCESS; return DataMutateResult.SUCCESS;
} }