Remove SERVER_ONLY command flag functionality

This will throw a warning for players on 1.21.6
This commit is contained in:
Owen1212055
2025-06-06 22:42:24 -04:00
parent 7c2ffd5e57
commit c609d6dc29
4 changed files with 7 additions and 7 deletions

View File

@@ -17,7 +17,8 @@ public enum CommandRegistrationFlag {
@Deprecated(since = "1.21.4")
FLATTEN_ALIASES,
/**
* Prevents this command from being sent to the client.
* @deprecated Removed as it causes a warning to appear on the client now.
*/
@Deprecated(since = "1.21.6", forRemoval = true)
SERVER_ONLY
}

View File

@@ -178,7 +178,7 @@
}
return null;
@@ -392,17 +_,111 @@
@@ -392,17 +_,110 @@
}
public void sendCommands(ServerPlayer player) {
@@ -252,7 +252,6 @@
+ }
+ // Paper end - Brigadier API
+ if (!org.spigotmc.SpigotConfig.sendNamespaced && commandNode.getName().contains(":")) continue; // Spigot
+ if (commandNode.wrappedCached != null && commandNode.wrappedCached.apiCommandMeta != null && commandNode.wrappedCached.apiCommandMeta.serverSideOnly()) continue; // Paper
if (commandNode.canUse(source)) {
ArgumentBuilder<S, ?> argumentBuilder = commandNode.createBuilder();
+ // Paper start

View File

@@ -10,10 +10,10 @@ import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
@NullMarked
public record APICommandMeta(@Nullable PluginMeta pluginMeta, @Nullable String description, List<String> aliases, @Nullable String helpCommandNamespace, boolean serverSideOnly) {
public record APICommandMeta(@Nullable PluginMeta pluginMeta, @Nullable String description, List<String> aliases, @Nullable String helpCommandNamespace) {
public APICommandMeta(final @Nullable PluginMeta pluginMeta, final @Nullable String description) {
this(pluginMeta, description, Collections.emptyList(), null, false);
this(pluginMeta, description, Collections.emptyList(), null);
}
public APICommandMeta {
@@ -26,6 +26,6 @@ public record APICommandMeta(@Nullable PluginMeta pluginMeta, @Nullable String d
}
public APICommandMeta withAliases(List<String> registeredAliases) {
return new APICommandMeta(this.pluginMeta, this.description, List.copyOf(registeredAliases), this.helpCommandNamespace, this.serverSideOnly);
return new APICommandMeta(this.pluginMeta, this.description, List.copyOf(registeredAliases), this.helpCommandNamespace);
}
}

View File

@@ -95,7 +95,7 @@ public class PaperCommands implements Commands, PaperRegistrar<LifecycleEventOwn
}
public @Unmodifiable Set<String> registerWithFlagsInternal(final @Nullable PluginMeta pluginMeta, final String namespace, final @Nullable String helpNamespaceOverride, final LiteralCommandNode<CommandSourceStack> node, final @Nullable String description, final Collection<String> aliases, final Set<CommandRegistrationFlag> flags) {
final APICommandMeta meta = new APICommandMeta(pluginMeta, description, List.of(), helpNamespaceOverride, flags.contains(CommandRegistrationFlag.SERVER_ONLY));
final APICommandMeta meta = new APICommandMeta(pluginMeta, description, List.of(), helpNamespaceOverride);
final String literal = node.getLiteral();
final LiteralCommandNode<CommandSourceStack> pluginLiteral = PaperBrigadier.copyLiteral(namespace + ":" + literal, node);