Provide an IDE pattern hint for plugin IDs (#1712)

* Provide an IDE pattern hint for plugin IDs

* order my imports the right way
This commit is contained in:
Warrior
2026-01-19 13:43:06 +01:00
committed by GitHub
parent 372a3b28bd
commit 21671daebe
3 changed files with 8 additions and 1 deletions

View File

@@ -24,7 +24,8 @@ import org.checkerframework.checker.nullness.qual.Nullable;
*/ */
public final class SerializedPluginDescription { public final class SerializedPluginDescription {
public static final Pattern ID_PATTERN = Pattern.compile("[a-z][a-z0-9-_]{0,63}"); public static final String ID_PATTERN_STRING = "[a-z][a-z0-9-_]{0,63}";
public static final Pattern ID_PATTERN = Pattern.compile(ID_PATTERN_STRING);
// @Nullable is used here to make GSON skip these in the serialized file // @Nullable is used here to make GSON skip these in the serialized file
private final String id; private final String id;

View File

@@ -7,9 +7,11 @@
package com.velocitypowered.api.plugin; package com.velocitypowered.api.plugin;
import com.velocitypowered.api.plugin.ap.SerializedPluginDescription;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; import java.lang.annotation.Target;
import org.intellij.lang.annotations.Pattern;
/** /**
* Indicates that the {@link Plugin} depends on another plugin in order to enable. * Indicates that the {@link Plugin} depends on another plugin in order to enable.
@@ -24,6 +26,7 @@ public @interface Dependency {
* @return The dependency plugin ID * @return The dependency plugin ID
* @see Plugin#id() * @see Plugin#id()
*/ */
@Pattern(SerializedPluginDescription.ID_PATTERN_STRING)
String id(); String id();
/** /**

View File

@@ -7,10 +7,12 @@
package com.velocitypowered.api.plugin; package com.velocitypowered.api.plugin;
import com.velocitypowered.api.plugin.ap.SerializedPluginDescription;
import java.lang.annotation.ElementType; import java.lang.annotation.ElementType;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; import java.lang.annotation.Target;
import org.intellij.lang.annotations.Pattern;
/** /**
* Annotation used to describe a Velocity plugin. * Annotation used to describe a Velocity plugin.
@@ -26,6 +28,7 @@ public @interface Plugin {
* *
* @return the ID for this plugin * @return the ID for this plugin
*/ */
@Pattern(SerializedPluginDescription.ID_PATTERN_STRING)
String id(); String id();
/** /**