CloudNet Documentation

repository·nightly·Indexed 19 days ago

https://github.com/cloudnetservice/cloudnet

CloudNet is a cloud network environment technology providing a scalable infrastructure for networked services. It offers a suite of Java/Kotlin libraries—including driver, node, bridge, and wrapper-jvm—to enable the development of plugins and modules. The project includes a comprehensive set of Gradle plugins (such as CloudNetJavaPlugin, CloudNetModulesPlugin, and CloudNetUpdaterPlugin) to standardize build environments, manage dependencies via a Bill of Materials (BOM), and handle API stability markers.

Tokens
7.9K
Snippets
30
Records
37
Agent score
65%

What's inside CloudNet

  1. Understand CloudNet API stability and warnings

    nightly

    When developing with CloudNet, be aware of the following API stability markers and lifecycle rules:

    • @ApiStatus.Internal: These methods can change or be removed without warning, even in patch releases. Avoid using them.
    • @ApiStatus.Experimental: These methods can change or be removed without warning. Note that the implementation is not necessarily experimental, only the API surface.
    • @Deprecated: These methods should be replaced as soon as possible. Check the Javadoc for replacement instructions. They are often paired with @ApiStatus.ScheduledForRemoval which specifies the version of removal.
    • Serialization: Serialized forms of all classes are subject to change. Do not persist CloudNet classes, as future versions may not be compatible.
    • Transitive Dependencies: Dependencies not explicitly exposed might be upgraded in major releases without warning. Do not rely on CloudNet to bundle specific versions of third-party libraries.
  2. Add CloudNet to your Gradle build

    nightly

    To add CloudNet to a Gradle project, ensure mavenCentral() is included in your repositories. You can manage versions centrally using the CloudNet Bill of Materials (BOM) or specify versions directly for individual artifacts. For plugin/module development, the driver artifact is typically used with compileOnly scope.

    repositories {
      // ensure maven central is added
      mavenCentral()
    }
    
    dependencies {
      // optional - you can also specify versions directly
      implementation platform('eu.cloudnetservice.cloudnet:bom:%version%')
      compileOnly 'eu.cloudnetservice.cloudnet:driver'
    
      // without bom
      compileOnly 'eu.cloudnetservice.cloudnet:driver:%version%'
    }
  3. Add CloudNet to your Maven build

    nightly

    To add CloudNet to a Maven project, you can use the bom artifact within <dependencyManagement> to align versions across all CloudNet submodules. The driver artifact should be added to your <dependencies> section, typically with a provided scope.

    <!-- optional - you can also specify versions directly -->
    <dependencyManagement>
      <dependencies>
        <dependency>
          <groupId>eu.cloudnetservice.cloudnet</groupId>
          <artifactId>bom</artifactId>
          <version>%version%</version>
          <type>pom</type>
          <scope>import</scope>
        </dependency>
      </dependencies>
    </dependencyManagement>
    
    <dependencies>
      <dependency>
        <groupId>eu.cloudnetservice.cloudnet</groupId>
        <artifactId>driver</artifactId>
        <version>%version%</version> <!-- only needed when bom is not used -->
        <scope>provided</scope>
      </dependency>
    </dependencies>
  4. Use CloudNet Snapshots

    nightly
    Snapshots are built from the nightly branch and are hosted on the Sonatype central portal snapshot repository: https://central.sonatype.com/repository/maven-snapshots/. To use a snapshot, append the -SNAPSHOT suffix to the version string in your dependency configuration.
  5. How CommandSource works

    nightly

    A CommandSource represents an object capable of receiving messages related to command execution and parsing. It acts as the entry point for commands, determining where command input originates and how permissions are validated for the sender.

    Common implementations include the system console or network-based message receivers. If you need to interact with the system's primary console, you can retrieve its dedicated CommandSource instance via the static console() method.

    // Accessing the system console command source
    CommandSource console = CommandSource.console();
  6. Understand the CommandInfo data structure

    nightly

    The CommandInfo record is used to represent the metadata of a command registered on a CloudNet node.

    Key Concepts:

    • Root Command Focus: A CommandInfo object represents the root command. Subcommands do not have their own CommandInfo objects; instead, all information regarding subcommands (including their syntax) is contained within the root command's usage list.
    • Identification: Commands are uniquely identified by their name. Equality and hashing are based solely on the name field.
    • Usage Syntax: The usage field provides a list of strings containing the correct syntax for the root command and all its possible subcommands.
    // Example of what a CommandInfo represents conceptually
    CommandInfo info = new CommandInfo(
        "server",                               // name
        Set.of("srv", "s"),                  // aliases
        "cloudnet.command.server",             // permission
        "Manage cloudnet servers",             // description
        "https://docs.cloudnet.io/server",     // docsUrl
        List.of("server", "server <id>", "server start <id>") // usage
    );
  7. Use the CloudNet Gradle plugin

    nightly

    The CloudNetPlugin is used for CloudNet development to automate project configuration, including setting the project group to eu.cloudnetservice.cloudnet and the project version to the current CloudNet version. It also manages Javadoc indexing for offline documentation support.

    // Apply the plugin in your build.gradle.kts
    plugins {
        id("eu.cloudnetservice.cloudnet")
    }
  8. Apply the CloudNetPluginsPlugin for plugin development

    nightly

    The CloudNetPluginsPlugin is the entry point for developing CloudNet plugins using Gradle. Applying this plugin automatically configures the project by applying the CloudNetJavaPlugin and registering source processing tasks. This simplifies the build lifecycle for CloudNet-compatible extensions.

    plugins {
        id("eu.cloudnetservice.cloudnet.plugins") // Note: The exact plugin ID should be verified in the plugin marker artifact
    }
  9. Use the CloudNetUpdaterPlugin for managing updates

    nightly

    The CloudNetUpdaterPlugin is a Gradle plugin designed to manage CloudNet update information across a project hierarchy.

    • In Subprojects: It applies the CloudNetJavaPlugin and registers a configuration named updaterData. It also provides a prepareUpdaterData task that prepares data into the project's temporary directory.
    • In the Root Project: It aggregates updater data from all subprojects into an updaterDependencies configuration and provides a genUpdaterInformation task to generate metadata.

    To use this plugin, apply it to your Gradle project. If applied to a multi-module project, it should be applied to the root project to correctly aggregate information from subprojects.

  10. Apply the CloudNetModulesApiPlugin to your Gradle project

    nightly

    The CloudNetModulesApiPlugin is a Gradle plugin used to configure the CloudNet Modules API within a project. Applying this plugin automatically applies the CloudNetJavaApiPlugin and registers the necessary processes for handling sources. This is a high-level entry point for projects intending to integrate with the CloudNet Modules API ecosystem.

    // In your build.gradle.kts
    plugins {
        id("eu.cloudnetservice.cloudnet.modules-api") // Note: The exact plugin ID should be verified in the plugin marker artifact or plugin portal
    }
  11. Apply the CloudNetModulesPlugin for module development

    nightly

    The CloudNetModulesPlugin is used to set up a Gradle project for developing CloudNet modules. When applied, it automatically configures several sub-plugins including CloudNetJavaPlugin, CloudNetUpdaterPlugin, and JuppiterPlugin. It also configures the testImplementation configuration to extend from the moduleLibrary configuration, ensuring module dependencies are available during testing.

    plugins {
        id("eu.cloudnetservice.cloudnet.modules") // Assuming the plugin ID follows standard convention
    }