mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-12-29 12:37:40 +01:00
Include a wider range of potential contexts in web editor payload (#2470)
This commit is contained in:
parent
ef556f7cf7
commit
1461651e22
@ -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<PermissionHolder> holders, List<Track> 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();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user