From 1461651e22822832404273506c4c535568cbac2c Mon Sep 17 00:00:00 2001 From: Luck Date: Tue, 21 Jul 2020 11:25:50 +0100 Subject: [PATCH] Include a wider range of potential contexts in web editor payload (#2470) --- .../java/me/lucko/luckperms/common/web/WebEditor.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/me/lucko/luckperms/common/web/WebEditor.java b/common/src/main/java/me/lucko/luckperms/common/web/WebEditor.java index c4e69f3b8..cb828c336 100644 --- a/common/src/main/java/me/lucko/luckperms/common/web/WebEditor.java +++ b/common/src/main/java/me/lucko/luckperms/common/web/WebEditor.java @@ -31,6 +31,7 @@ import com.google.gson.JsonObject; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.config.ConfigKeys; import me.lucko.luckperms.common.context.ContextSetJsonSerializer; +import me.lucko.luckperms.common.context.contextset.ImmutableContextSetImpl; import me.lucko.luckperms.common.locale.message.Message; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.model.Track; @@ -46,6 +47,7 @@ import net.kyori.text.TextComponent; import net.kyori.text.event.ClickEvent; import net.kyori.text.event.HoverEvent; import net.kyori.text.format.TextColor; +import net.luckperms.api.context.ImmutableContextSet; import okhttp3.Request; import okhttp3.Response; @@ -86,6 +88,12 @@ public final class WebEditor { public static JsonObject formPayload(List holders, List tracks, Sender sender, String cmdLabel, LuckPermsPlugin plugin) { Preconditions.checkArgument(!holders.isEmpty(), "holders is empty"); + ImmutableContextSet.Builder potentialContexts = new ImmutableContextSetImpl.BuilderImpl(); + potentialContexts.addAll(plugin.getContextManager().getPotentialContexts()); + for (PermissionHolder holder : holders) { + holder.normalData().forEach(node -> potentialContexts.addAll(node.getContexts())); + } + // form the payload data return new JObject() .add("metadata", new JObject() @@ -119,7 +127,7 @@ public final class WebEditor { }) ) .consume(o -> { - o.add("potentialContexts", ContextSetJsonSerializer.serializeContextSet(plugin.getContextManager().getPotentialContexts())); + o.add("potentialContexts", ContextSetJsonSerializer.serializeContextSet(potentialContexts.build())); }) .toJson(); }