mirror of
https://github.com/PaperMC/Velocity.git
synced 2026-02-17 14:37:43 +01:00
Add support for resolving dependencies that require a version range
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (C) 2018 Velocity Contributors
|
||||
*
|
||||
* The Velocity API is licensed under the terms of the MIT License. For more details,
|
||||
* reference the LICENSE file in the api top-level directory.
|
||||
*/
|
||||
|
||||
package com.velocitypowered.api.network;
|
||||
|
||||
import java.net.SocketAddress;
|
||||
|
||||
/**
|
||||
* Represents a network listener for the proxy.
|
||||
*/
|
||||
public interface NetworkEndpoint {
|
||||
/**
|
||||
* The type.
|
||||
*
|
||||
* @return the type
|
||||
*/
|
||||
ListenerType type();
|
||||
|
||||
/**
|
||||
* The address the listener is listening on.
|
||||
*
|
||||
* @return the address
|
||||
*/
|
||||
SocketAddress address();
|
||||
}
|
||||
@@ -26,6 +26,15 @@ public @interface Dependency {
|
||||
*/
|
||||
String id();
|
||||
|
||||
/**
|
||||
* The required version of the dependency. This should be in an NPM-compatible versioning format,
|
||||
* which you can figure from <a href="https://semver.npmjs.com/">npm's SemVer checker</a>. If
|
||||
* not specified, this assumes any version is acceptable.
|
||||
*
|
||||
* @return the version requirement
|
||||
*/
|
||||
String version() default "*";
|
||||
|
||||
/**
|
||||
* Whether or not the dependency is not required to enable this plugin. By default this is
|
||||
* {@code false}, meaning that the dependency is required to enable this plugin.
|
||||
|
||||
@@ -52,8 +52,8 @@ public interface PluginDescription {
|
||||
* @return a String with the plugin version, may be null
|
||||
* @see Plugin#version()
|
||||
*/
|
||||
default @Nullable String version() {
|
||||
return null;
|
||||
default String version() {
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,7 +20,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
public final class PluginDependency {
|
||||
|
||||
private final String id;
|
||||
private final @Nullable String version;
|
||||
private final String version;
|
||||
|
||||
private final boolean optional;
|
||||
|
||||
@@ -30,10 +30,10 @@ public final class PluginDependency {
|
||||
* @param version an optional version
|
||||
* @param optional whether or not this dependency is optional
|
||||
*/
|
||||
public PluginDependency(String id, @Nullable String version, boolean optional) {
|
||||
public PluginDependency(String id, String version, boolean optional) {
|
||||
this.id = checkNotNull(id, "id");
|
||||
checkArgument(!id.isEmpty(), "id cannot be empty");
|
||||
this.version = emptyToNull(version);
|
||||
this.version = checkNotNull(version, "version");
|
||||
this.optional = optional;
|
||||
}
|
||||
|
||||
@@ -47,11 +47,11 @@ public final class PluginDependency {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the version this {@link PluginDependency} should match.
|
||||
* Returns the version this {@link PluginDependency} should match in NPM SemVer range format.
|
||||
*
|
||||
* @return a String with the plugin version, may be {@code null}
|
||||
* @return a String with the plugin version, may be empty if no version requirement is present
|
||||
*/
|
||||
public @Nullable String version() {
|
||||
public String version() {
|
||||
return version;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.velocitypowered.api.command.CommandManager;
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
import com.velocitypowered.api.command.ConsoleCommandSource;
|
||||
import com.velocitypowered.api.event.EventManager;
|
||||
import com.velocitypowered.api.network.NetworkEndpoint;
|
||||
import com.velocitypowered.api.plugin.PluginManager;
|
||||
import com.velocitypowered.api.proxy.config.ProxyConfig;
|
||||
import com.velocitypowered.api.proxy.connection.Player;
|
||||
@@ -179,4 +180,12 @@ public interface ProxyServer extends Audience {
|
||||
* @return the proxy version
|
||||
*/
|
||||
ProxyVersion version();
|
||||
|
||||
/**
|
||||
* Returns all the endpoints the proxy is listening on. This collection is immutable.
|
||||
*
|
||||
* @return all the endpoints the proxy is listening on
|
||||
*/
|
||||
Collection<NetworkEndpoint> endpoints();
|
||||
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
package com.velocitypowered.api.proxy.config;
|
||||
|
||||
import com.google.common.annotations.Beta;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import com.velocitypowered.api.util.Favicon;
|
||||
import java.util.List;
|
||||
@@ -14,8 +15,10 @@ import java.util.Map;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
/**
|
||||
* Exposes certain proxy configuration information that plugins may use.
|
||||
* Exposes certain proxy configuration information that plugins may use. Note that this interface
|
||||
* is in constant flux and should never be considered stable.
|
||||
*/
|
||||
@Beta
|
||||
public interface ProxyConfig {
|
||||
|
||||
/**
|
||||
|
||||
@@ -33,15 +33,15 @@ public final class ProxyVersion {
|
||||
this.version = Preconditions.checkNotNull(version, "version");
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
public String name() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getVendor() {
|
||||
public String vendor() {
|
||||
return vendor;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
public String version() {
|
||||
return version;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user