mirror of
https://github.com/PaperMC/Paper.git
synced 2025-07-31 20:22:05 -07:00
Add api to resolve components (#7648)
This commit is contained in:
@@ -567,7 +567,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+import net.kyori.adventure.text.serializer.plain.PlainComponentSerializer;
|
||||
+import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||
+import org.bukkit.Bukkit;
|
||||
+import org.bukkit.command.CommandSender;
|
||||
+import org.bukkit.entity.Entity;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import org.jetbrains.annotations.Nullable;
|
||||
+
|
||||
+import java.io.IOException;
|
||||
+
|
||||
+/**
|
||||
+ * Paper API-specific methods for working with {@link Component}s and related.
|
||||
@@ -578,6 +583,66 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Resolves a component with a specific command sender and subject.
|
||||
+ * <p>
|
||||
+ * Note that in Vanilla, elevated permissions are usually required to use
|
||||
+ * '@' selectors in various component types, but this method should not
|
||||
+ * check such permissions from the sender.
|
||||
+ * <p>
|
||||
+ * A {@link CommandSender} argument is required to resolve:
|
||||
+ * <ul>
|
||||
+ * <li>{@link net.kyori.adventure.text.NBTComponent}</li>
|
||||
+ * <li>{@link net.kyori.adventure.text.ScoreComponent}</li>
|
||||
+ * <li>{@link net.kyori.adventure.text.SelectorComponent}</li>
|
||||
+ * </ul>
|
||||
+ * A {@link Entity} argument is optional to help resolve:
|
||||
+ * <ul>
|
||||
+ * <li>{@link net.kyori.adventure.text.ScoreComponent}</li>
|
||||
+ * </ul>
|
||||
+ * {@link net.kyori.adventure.text.TranslatableComponent}s don't require any extra arguments.
|
||||
+ *
|
||||
+ * @param input the component to resolve
|
||||
+ * @param context the command sender to resolve with
|
||||
+ * @param scoreboardSubject the scoreboard subject to use (for use with {@link net.kyori.adventure.text.ScoreComponent}s)
|
||||
+ * @return the resolved component
|
||||
+ * @throws IOException if a syntax error tripped during resolving
|
||||
+ */
|
||||
+ public static @NotNull Component resolveWithContext(@NotNull Component input, @Nullable CommandSender context, @Nullable Entity scoreboardSubject) throws IOException {
|
||||
+ return resolveWithContext(input, context, scoreboardSubject, true);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Resolves a component with a specific command sender and subject.
|
||||
+ * <p>
|
||||
+ * Note that in Vanilla, elevated permissions are required to use
|
||||
+ * '@' selectors in various component types. If the boolean {@code bypassPermissions}
|
||||
+ * argument is {@code false}, the {@link CommandSender} argument will be used to query
|
||||
+ * those permissions.
|
||||
+ * <p>
|
||||
+ * A {@link CommandSender} argument is required to resolve:
|
||||
+ * <ul>
|
||||
+ * <li>{@link net.kyori.adventure.text.NBTComponent}</li>
|
||||
+ * <li>{@link net.kyori.adventure.text.ScoreComponent}</li>
|
||||
+ * <li>{@link net.kyori.adventure.text.SelectorComponent}</li>
|
||||
+ * </ul>
|
||||
+ * A {@link Entity} argument is optional to help resolve:
|
||||
+ * <ul>
|
||||
+ * <li>{@link net.kyori.adventure.text.ScoreComponent}</li>
|
||||
+ * </ul>
|
||||
+ * {@link net.kyori.adventure.text.TranslatableComponent}s don't require any extra arguments.
|
||||
+ *
|
||||
+ * @param input the component to resolve
|
||||
+ * @param context the command sender to resolve with
|
||||
+ * @param scoreboardSubject the scoreboard subject to use (for use with {@link net.kyori.adventure.text.ScoreComponent}s)
|
||||
+ * @param bypassPermissions true to bypass permissions checks for resolving components
|
||||
+ * @return the resolved component
|
||||
+ * @throws IOException if a syntax error tripped during resolving
|
||||
+ */
|
||||
+ public static @NotNull Component resolveWithContext(@NotNull Component input, @Nullable CommandSender context, @Nullable Entity scoreboardSubject, boolean bypassPermissions) throws IOException {
|
||||
+ return Bukkit.getUnsafe().resolveWithContext(input, context, scoreboardSubject, bypassPermissions);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Return a component flattener that can use game data to resolve extra information about components.
|
||||
+ *
|
||||
+ * @return a component flattener
|
||||
@@ -1317,6 +1382,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ @Deprecated(forRemoval = true) net.kyori.adventure.text.serializer.gson.GsonComponentSerializer gsonComponentSerializer();
|
||||
+ @Deprecated(forRemoval = true) net.kyori.adventure.text.serializer.gson.GsonComponentSerializer colorDownsamplingGsonComponentSerializer();
|
||||
+ @Deprecated(forRemoval = true) net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer legacyComponentSerializer();
|
||||
+ net.kyori.adventure.text.Component resolveWithContext(net.kyori.adventure.text.Component component, org.bukkit.command.CommandSender context, org.bukkit.entity.Entity scoreboardSubject, boolean bypassPermissions) throws java.io.IOException;
|
||||
+ // Paper end
|
||||
|
||||
Material toLegacy(Material material);
|
||||
|
@@ -2838,7 +2838,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
--- a/src/main/java/org/bukkit/UnsafeValues.java
|
||||
+++ b/src/main/java/org/bukkit/UnsafeValues.java
|
||||
@@ -0,0 +0,0 @@ public interface UnsafeValues {
|
||||
@Deprecated(forRemoval = true) net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer legacyComponentSerializer();
|
||||
net.kyori.adventure.text.Component resolveWithContext(net.kyori.adventure.text.Component component, org.bukkit.command.CommandSender context, org.bukkit.entity.Entity scoreboardSubject, boolean bypassPermissions) throws java.io.IOException;
|
||||
// Paper end
|
||||
|
||||
+ void reportTimings(); // Paper
|
||||
|
Reference in New Issue
Block a user