mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-30 14:43:29 +01:00
Fix 'meta settemp' ignoring temporary modifier (#2958)
This commit is contained in:
parent
2e62c98c45
commit
f813122468
@ -45,10 +45,10 @@ import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.util.Predicates;
|
||||
|
||||
import net.luckperms.api.context.MutableContextSet;
|
||||
import net.luckperms.api.model.data.DataMutateResult;
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.model.data.TemporaryNodeMergeStrategy;
|
||||
import net.luckperms.api.node.Node;
|
||||
import net.luckperms.api.node.NodeEqualityPredicate;
|
||||
import net.luckperms.api.node.NodeType;
|
||||
|
||||
import java.time.Duration;
|
||||
@ -80,15 +80,12 @@ public class MetaSetTemp extends GenericChildCommand {
|
||||
}
|
||||
|
||||
Node node = Meta.builder(key, value).withContext(context).expiry(duration).build();
|
||||
// remove temp meta nodes that have the same key and /different/ value (don't want to remove it if we are accumulating/replacing)
|
||||
target.removeIf(DataType.NORMAL, context, NodeType.META.predicate(n -> n.hasExpiry() && n.getMetaKey().equalsIgnoreCase(key) && !n.getMetaValue().equals(value)), false);
|
||||
DataMutateResult.WithMergedNode result = target.setNode(DataType.NORMAL, node, modifier);
|
||||
|
||||
if (target.hasNode(DataType.NORMAL, node, NodeEqualityPredicate.IGNORE_EXPIRY_TIME_AND_VALUE).asBoolean()) {
|
||||
Message.ALREADY_HAS_TEMP_META.send(sender, target, key, value, context);
|
||||
return CommandResult.STATE_ERROR;
|
||||
}
|
||||
|
||||
target.removeIf(DataType.NORMAL, context, NodeType.META.predicate(n -> n.hasExpiry() && n.getMetaKey().equalsIgnoreCase(key)), false);
|
||||
duration = target.setNode(DataType.NORMAL, node, modifier).getMergedNode().getExpiryDuration();
|
||||
|
||||
if (result.getResult().wasSuccessful()) {
|
||||
duration = result.getMergedNode().getExpiryDuration();
|
||||
Message.SET_META_TEMP_SUCCESS.send(sender, key, value, target, duration, context);
|
||||
|
||||
LoggedAction.build().source(sender).target(target)
|
||||
@ -97,6 +94,10 @@ public class MetaSetTemp extends GenericChildCommand {
|
||||
|
||||
StorageAssistant.save(target, sender, plugin);
|
||||
return CommandResult.SUCCESS;
|
||||
} else {
|
||||
Message.ALREADY_HAS_TEMP_META.send(sender, target, key, value, context);
|
||||
return CommandResult.STATE_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user