mirror of
https://github.com/YuzuZensai/Minikura.git
synced 2026-01-31 14:57:49 +00:00
✨ feat: Velocity plugin
This commit is contained in:
38
plugins/MinikuraVelocity/.gitignore
vendored
Normal file
38
plugins/MinikuraVelocity/.gitignore
vendored
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
target/
|
||||||
|
!.mvn/wrapper/maven-wrapper.jar
|
||||||
|
!**/src/main/**/target/
|
||||||
|
!**/src/test/**/target/
|
||||||
|
|
||||||
|
### IntelliJ IDEA ###
|
||||||
|
.idea/modules.xml
|
||||||
|
.idea/jarRepositories.xml
|
||||||
|
.idea/compiler.xml
|
||||||
|
.idea/libraries/
|
||||||
|
*.iws
|
||||||
|
*.iml
|
||||||
|
*.ipr
|
||||||
|
|
||||||
|
### Eclipse ###
|
||||||
|
.apt_generated
|
||||||
|
.classpath
|
||||||
|
.factorypath
|
||||||
|
.project
|
||||||
|
.settings
|
||||||
|
.springBeans
|
||||||
|
.sts4-cache
|
||||||
|
|
||||||
|
### NetBeans ###
|
||||||
|
/nbproject/private/
|
||||||
|
/nbbuild/
|
||||||
|
/dist/
|
||||||
|
/nbdist/
|
||||||
|
/.nb-gradle/
|
||||||
|
build/
|
||||||
|
!**/src/main/**/build/
|
||||||
|
!**/src/test/**/build/
|
||||||
|
|
||||||
|
### VS Code ###
|
||||||
|
.vscode/
|
||||||
|
|
||||||
|
### Mac OS ###
|
||||||
|
.DS_Store
|
||||||
32
plugins/MinikuraVelocity/.run/minikura-velocity.run.xml
Normal file
32
plugins/MinikuraVelocity/.run/minikura-velocity.run.xml
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<component name="ProjectRunConfigurationManager">
|
||||||
|
<configuration default="false" name="minikura-velocity" type="MavenRunConfiguration" factoryName="Maven" nameIsGenerated="true">
|
||||||
|
<MavenSettings>
|
||||||
|
<option name="myGeneralSettings" />
|
||||||
|
<option name="myRunnerSettings" />
|
||||||
|
<option name="myRunnerParameters">
|
||||||
|
<MavenRunnerParameters>
|
||||||
|
<option name="cmdOptions" />
|
||||||
|
<option name="profiles">
|
||||||
|
<set />
|
||||||
|
</option>
|
||||||
|
<option name="goals">
|
||||||
|
<list>
|
||||||
|
<option value="package" />
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
<option name="multimoduleDir" />
|
||||||
|
<option name="pomFileName" />
|
||||||
|
<option name="profilesMap">
|
||||||
|
<map />
|
||||||
|
</option>
|
||||||
|
<option name="projectsCmdOptionValues">
|
||||||
|
<list />
|
||||||
|
</option>
|
||||||
|
<option name="resolveToWorkspace" value="false" />
|
||||||
|
<option name="workingDirPath" value="$PROJECT_DIR$" />
|
||||||
|
</MavenRunnerParameters>
|
||||||
|
</option>
|
||||||
|
</MavenSettings>
|
||||||
|
<method v="2" />
|
||||||
|
</configuration>
|
||||||
|
</component>
|
||||||
232
plugins/MinikuraVelocity/dependency-reduced-pom.xml
Normal file
232
plugins/MinikuraVelocity/dependency-reduced-pom.xml
Normal file
@@ -0,0 +1,232 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>cafe.kirameki</groupId>
|
||||||
|
<artifactId>minikura-velocity</artifactId>
|
||||||
|
<name>minikura-velocity</name>
|
||||||
|
<version>1.0</version>
|
||||||
|
<build>
|
||||||
|
<sourceDirectory>src/main/kotlin</sourceDirectory>
|
||||||
|
<defaultGoal>clean package</defaultGoal>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<filtering>true</filtering>
|
||||||
|
<directory>${project.basedir}/src/main/resources</directory>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<artifactId>kotlin-maven-plugin</artifactId>
|
||||||
|
<version>${kotlin.version}</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>kapt</id>
|
||||||
|
<goals>
|
||||||
|
<goal>kapt</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<sourceDirs>
|
||||||
|
<sourceDir>src/main/kotlin</sourceDir>
|
||||||
|
<sourceDir>src/main/java</sourceDir>
|
||||||
|
</sourceDirs>
|
||||||
|
<annotationProcessorPaths>
|
||||||
|
<annotationProcessorPath>
|
||||||
|
<groupId>com.velocitypowered</groupId>
|
||||||
|
<artifactId>velocity-api</artifactId>
|
||||||
|
<version>3.4.0-SNAPSHOT</version>
|
||||||
|
</annotationProcessorPath>
|
||||||
|
</annotationProcessorPaths>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>compile</id>
|
||||||
|
<phase>compile</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>compile</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>test-compile</id>
|
||||||
|
<phase>test-compile</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>test-compile</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<configuration>
|
||||||
|
<jvmTarget>1.8</jvmTarget>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
|
<version>3.5.3</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>shade</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.13.0</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>default-compile</id>
|
||||||
|
<phase>none</phase>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>default-testCompile</id>
|
||||||
|
<phase>none</phase>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>compile</id>
|
||||||
|
<phase>compile</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>compile</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>testCompile</id>
|
||||||
|
<phase>test-compile</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>testCompile</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<configuration>
|
||||||
|
<source>${java.version}</source>
|
||||||
|
<target>${java.version}</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>templating-maven-plugin</artifactId>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>filter-src</id>
|
||||||
|
<goals>
|
||||||
|
<goal>filter-sources</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-site-plugin</artifactId>
|
||||||
|
<version>3.12.1</version>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.trajano.wagon</groupId>
|
||||||
|
<artifactId>wagon-git</artifactId>
|
||||||
|
<version>2.0.4</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.maven.doxia</groupId>
|
||||||
|
<artifactId>doxia-module-markdown</artifactId>
|
||||||
|
<version>1.12.0</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-release-plugin</artifactId>
|
||||||
|
<version>3.0.1</version>
|
||||||
|
<configuration>
|
||||||
|
<autoVersionSubmodules>true</autoVersionSubmodules>
|
||||||
|
<tagNameFormat>@{project.version}</tagNameFormat>
|
||||||
|
<scmCommentPrefix>[RELEASE]</scmCommentPrefix>
|
||||||
|
<goals>install deploy site-deploy</goals>
|
||||||
|
<releaseProfiles>release</releaseProfiles>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
<profiles>
|
||||||
|
<profile>
|
||||||
|
<id>release</id>
|
||||||
|
<build>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<filtering>true</filtering>
|
||||||
|
<directory>src/main/resources</directory>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-source-plugin</artifactId>
|
||||||
|
<version>3.3.1</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>attach-sources</id>
|
||||||
|
<goals>
|
||||||
|
<goal>jar-no-fork</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-javadoc-plugin</artifactId>
|
||||||
|
<version>3.6.3</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>attach-javadocs</id>
|
||||||
|
<goals>
|
||||||
|
<goal>jar</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-gpg-plugin</artifactId>
|
||||||
|
<version>3.2.4</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>sign-artifacts</id>
|
||||||
|
<phase>verify</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>sign</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</profile>
|
||||||
|
</profiles>
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>papermc-repo</id>
|
||||||
|
<url>https://repo.papermc.io/repository/maven-public/</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.velocitypowered</groupId>
|
||||||
|
<artifactId>velocity-api</artifactId>
|
||||||
|
<version>3.4.0-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<artifactId>kotlin-test</artifactId>
|
||||||
|
<version>2.1.0</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
<reporting>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-javadoc-plugin</artifactId>
|
||||||
|
<version>3.6.3</version>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</reporting>
|
||||||
|
<properties>
|
||||||
|
<kotlin.version>2.1.0</kotlin.version>
|
||||||
|
<java.version>17</java.version>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
</project>
|
||||||
272
plugins/MinikuraVelocity/pom.xml
Normal file
272
plugins/MinikuraVelocity/pom.xml
Normal file
@@ -0,0 +1,272 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>cafe.kirameki</groupId>
|
||||||
|
<artifactId>minikura-velocity</artifactId>
|
||||||
|
<version>1.0</version>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<name>minikura-velocity</name>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<java.version>17</java.version>
|
||||||
|
<kotlin.version>2.1.0</kotlin.version>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<profiles>
|
||||||
|
<profile>
|
||||||
|
<id>release</id>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-source-plugin</artifactId>
|
||||||
|
<version>3.3.1</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>attach-sources</id>
|
||||||
|
<goals>
|
||||||
|
<goal>jar-no-fork</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-javadoc-plugin</artifactId>
|
||||||
|
<version>3.6.3</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>attach-javadocs</id>
|
||||||
|
<goals>
|
||||||
|
<goal>jar</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-gpg-plugin</artifactId>
|
||||||
|
<version>3.2.4</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>sign-artifacts</id>
|
||||||
|
<phase>verify</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>sign</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/resources</directory>
|
||||||
|
<filtering>true</filtering>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
</build>
|
||||||
|
</profile>
|
||||||
|
</profiles>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<defaultGoal>clean package</defaultGoal>
|
||||||
|
<sourceDirectory>src/main/kotlin</sourceDirectory>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>${project.basedir}/src/main/resources</directory>
|
||||||
|
<filtering>true</filtering>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<artifactId>kotlin-maven-plugin</artifactId>
|
||||||
|
<version>${kotlin.version}</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>kapt</id>
|
||||||
|
<goals>
|
||||||
|
<goal>kapt</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<sourceDirs>
|
||||||
|
<sourceDir>src/main/kotlin</sourceDir>
|
||||||
|
<sourceDir>src/main/java</sourceDir>
|
||||||
|
</sourceDirs>
|
||||||
|
<annotationProcessorPaths>
|
||||||
|
<annotationProcessorPath>
|
||||||
|
<groupId>com.velocitypowered</groupId>
|
||||||
|
<artifactId>velocity-api</artifactId>
|
||||||
|
<version>3.4.0-SNAPSHOT</version>
|
||||||
|
</annotationProcessorPath>
|
||||||
|
</annotationProcessorPaths>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>compile</id>
|
||||||
|
<phase>compile</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>compile</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>test-compile</id>
|
||||||
|
<phase>test-compile</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>test-compile</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<configuration>
|
||||||
|
<jvmTarget>1.8</jvmTarget>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
|
<version>3.5.3</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>shade</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.13.0</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>default-compile</id>
|
||||||
|
<phase>none</phase>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>default-testCompile</id>
|
||||||
|
<phase>none</phase>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>compile</id>
|
||||||
|
<phase>compile</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>compile</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>testCompile</id>
|
||||||
|
<phase>test-compile</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>testCompile</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<configuration>
|
||||||
|
<source>${java.version}</source>
|
||||||
|
<target>${java.version}</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>templating-maven-plugin</artifactId>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>filter-src</id>
|
||||||
|
<goals>
|
||||||
|
<goal>filter-sources</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-site-plugin</artifactId>
|
||||||
|
<version>3.12.1</version>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.trajano.wagon</groupId>
|
||||||
|
<artifactId>wagon-git</artifactId>
|
||||||
|
<version>2.0.4</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.maven.doxia</groupId>
|
||||||
|
<artifactId>doxia-module-markdown</artifactId>
|
||||||
|
<version>1.12.0</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-release-plugin</artifactId>
|
||||||
|
<version>3.0.1</version>
|
||||||
|
<configuration>
|
||||||
|
<autoVersionSubmodules>true</autoVersionSubmodules>
|
||||||
|
<tagNameFormat>@{project.version}</tagNameFormat>
|
||||||
|
<scmCommentPrefix xml:space="preserve">[RELEASE] </scmCommentPrefix>
|
||||||
|
<goals>install deploy site-deploy
|
||||||
|
</goals> <!-- install is here to fix javadoc generation in multi-module projects -->
|
||||||
|
<releaseProfiles>release</releaseProfiles>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<reporting>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-javadoc-plugin</artifactId>
|
||||||
|
<version>3.6.3</version>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</reporting>
|
||||||
|
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>papermc-repo</id>
|
||||||
|
<url>https://repo.papermc.io/repository/maven-public/</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.velocitypowered</groupId>
|
||||||
|
<artifactId>velocity-api</artifactId>
|
||||||
|
<version>3.4.0-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<artifactId>kotlin-stdlib-jdk8</artifactId>
|
||||||
|
<version>${kotlin.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<artifactId>kotlin-stdlib-jdk8</artifactId>
|
||||||
|
<version>${kotlin.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<artifactId>kotlin-test</artifactId>
|
||||||
|
<version>${kotlin.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.java-websocket</groupId>
|
||||||
|
<artifactId>Java-WebSocket</artifactId>
|
||||||
|
<version>1.6.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.squareup.okhttp3</groupId>
|
||||||
|
<artifactId>okhttp</artifactId>
|
||||||
|
<version>4.12.0</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
||||||
@@ -0,0 +1,203 @@
|
|||||||
|
package cafe.kirameki.minikuraVelocity
|
||||||
|
|
||||||
|
import cafe.kirameki.minikuraVelocity.listeners.ServerConnectionHandler
|
||||||
|
import cafe.kirameki.minikuraVelocity.models.ReverseProxyServerData
|
||||||
|
import cafe.kirameki.minikuraVelocity.models.ServerData
|
||||||
|
import cafe.kirameki.minikuraVelocity.store.ServerDataStore
|
||||||
|
import cafe.kirameki.minikuraVelocity.utils.createWebSocketClient
|
||||||
|
import com.google.gson.Gson
|
||||||
|
import com.google.gson.reflect.TypeToken
|
||||||
|
import com.google.inject.Inject
|
||||||
|
import com.velocitypowered.api.command.CommandManager
|
||||||
|
import com.velocitypowered.api.command.CommandMeta
|
||||||
|
import com.velocitypowered.api.command.SimpleCommand
|
||||||
|
import com.velocitypowered.api.event.Subscribe
|
||||||
|
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent
|
||||||
|
import com.velocitypowered.api.plugin.Plugin
|
||||||
|
import com.velocitypowered.api.proxy.ProxyServer
|
||||||
|
import com.velocitypowered.api.proxy.server.RegisteredServer
|
||||||
|
import com.velocitypowered.api.proxy.server.ServerInfo
|
||||||
|
import net.kyori.adventure.text.Component
|
||||||
|
import okhttp3.OkHttpClient
|
||||||
|
import okhttp3.Request
|
||||||
|
import org.slf4j.Logger
|
||||||
|
import java.net.InetSocketAddress
|
||||||
|
import java.util.concurrent.Executors
|
||||||
|
|
||||||
|
@Plugin(id = "minikura-velocity", name = "MinikuraVelocity", version = "1.0")
|
||||||
|
class Main @Inject constructor(private val logger: Logger, private val server: ProxyServer) {
|
||||||
|
private val servers: MutableMap<String, RegisteredServer> = HashMap()
|
||||||
|
private val client = OkHttpClient()
|
||||||
|
private val apiKey: String = System.getenv("MINIKURA_API_KEY") ?: ""
|
||||||
|
private val apiUrl: String = System.getenv("MINIKURA_API_URL") ?: "http://localhost:3000"
|
||||||
|
private val websocketUrl: String = System.getenv("MINIKURA_WEBSOCKET_URL") ?: "ws://localhost:3000/ws"
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
fun onProxyInitialization(event: ProxyInitializeEvent?) {
|
||||||
|
logger.info("Minikura-Velocity is initializing...")
|
||||||
|
|
||||||
|
val client = createWebSocketClient(this, server, websocketUrl)
|
||||||
|
client.connect()
|
||||||
|
|
||||||
|
val commandManager: CommandManager = server.commandManager
|
||||||
|
|
||||||
|
val serversCommandMeta: CommandMeta = commandManager.metaBuilder("servers")
|
||||||
|
.plugin(this)
|
||||||
|
.aliases("listservers", "serverlist")
|
||||||
|
.build()
|
||||||
|
|
||||||
|
val serversCommand = SimpleCommand { p ->
|
||||||
|
val source = p.source()
|
||||||
|
source.sendMessage(Component.text("Available servers:"))
|
||||||
|
for ((name, server) in servers) {
|
||||||
|
source.sendMessage(Component.text(" - $name (${server.serverInfo.address})"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
commandManager.register(serversCommandMeta, serversCommand)
|
||||||
|
|
||||||
|
val refreshCommandMeta: CommandMeta = commandManager.metaBuilder("refresh")
|
||||||
|
.plugin(this)
|
||||||
|
.build()
|
||||||
|
|
||||||
|
val refreshCommand = SimpleCommand { p ->
|
||||||
|
val source = p.source()
|
||||||
|
source.sendMessage(Component.text("Refreshing server list..."))
|
||||||
|
fetchServers()
|
||||||
|
fetchReverseProxyServers()
|
||||||
|
source.sendMessage(Component.text("Server list refreshed successfully!"))
|
||||||
|
}
|
||||||
|
|
||||||
|
commandManager.register(refreshCommandMeta, refreshCommand)
|
||||||
|
|
||||||
|
val migrateCommandMeta: CommandMeta = commandManager.metaBuilder("migrate")
|
||||||
|
.plugin(this)
|
||||||
|
.build()
|
||||||
|
|
||||||
|
val migrateCommand = SimpleCommand { p ->
|
||||||
|
val source = p.source()
|
||||||
|
val args = p.arguments()
|
||||||
|
|
||||||
|
if (args.isEmpty()) {
|
||||||
|
source.sendMessage(Component.text("Please specify a server to migrate players to."))
|
||||||
|
return@SimpleCommand
|
||||||
|
}
|
||||||
|
|
||||||
|
val targetServerName = args[0]
|
||||||
|
val targetServer = ServerDataStore.getReverseProxyServer(targetServerName)
|
||||||
|
|
||||||
|
if (targetServer == null) {
|
||||||
|
source.sendMessage(Component.text("Server '$targetServerName' not found."))
|
||||||
|
return@SimpleCommand
|
||||||
|
}
|
||||||
|
|
||||||
|
migratePlayersToServer(targetServer)
|
||||||
|
source.sendMessage(Component.text("Migrating players to server '$targetServerName'..."))
|
||||||
|
}
|
||||||
|
|
||||||
|
commandManager.register(migrateCommandMeta, migrateCommand)
|
||||||
|
|
||||||
|
val connectionHandler = ServerConnectionHandler(servers, logger)
|
||||||
|
server.eventManager.register(this, connectionHandler)
|
||||||
|
|
||||||
|
fetchServers()
|
||||||
|
fetchReverseProxyServers()
|
||||||
|
|
||||||
|
logger.info("Minikura-Velocity has been initialized.")
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun fetchReverseProxyServers() {
|
||||||
|
val request = Request.Builder()
|
||||||
|
.url("$apiUrl/reverse_proxy_servers")
|
||||||
|
.header("Authorization", "Bearer $apiKey")
|
||||||
|
.build()
|
||||||
|
|
||||||
|
Executors.newSingleThreadExecutor().submit {
|
||||||
|
try {
|
||||||
|
val response = client.newCall(request).execute()
|
||||||
|
if (response.isSuccessful) {
|
||||||
|
val responseBody = response.body?.string()
|
||||||
|
val fetchedServers = parseReverseProxyServersData(responseBody)
|
||||||
|
|
||||||
|
server.scheduler.buildTask(this, Runnable {
|
||||||
|
synchronized(ServerDataStore) {
|
||||||
|
ServerDataStore.clearReverseProxyServers()
|
||||||
|
ServerDataStore.addAllReverseProxyServers(fetchedServers)
|
||||||
|
}
|
||||||
|
}).schedule()
|
||||||
|
} else {
|
||||||
|
logger.error("Failed to fetch reverse proxy servers: ${response.message}")
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
logger.error("Error fetching reverse proxy servers: ${e.message}", e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun fetchServers() {
|
||||||
|
server.allServers.forEach { server.unregisterServer(it.serverInfo) }
|
||||||
|
val request = Request.Builder()
|
||||||
|
.url("$apiUrl/servers")
|
||||||
|
.header("Authorization", "Bearer $apiKey")
|
||||||
|
.build()
|
||||||
|
|
||||||
|
Executors.newSingleThreadExecutor().submit {
|
||||||
|
try {
|
||||||
|
val response = client.newCall(request).execute()
|
||||||
|
if (response.isSuccessful) {
|
||||||
|
val responseBody = response.body?.string()
|
||||||
|
val fetchedServers = parseServersData(responseBody)
|
||||||
|
|
||||||
|
server.scheduler.buildTask(this, Runnable {
|
||||||
|
synchronized(ServerDataStore) {
|
||||||
|
ServerDataStore.clearServers()
|
||||||
|
ServerDataStore.addAllServers(fetchedServers)
|
||||||
|
}
|
||||||
|
populateServers(fetchedServers)
|
||||||
|
}).schedule()
|
||||||
|
} else {
|
||||||
|
logger.error("Failed to fetch servers: ${response.message}")
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
logger.error("Error fetching servers: ${e.message}", e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun parseReverseProxyServersData(responseBody: String?): List<ReverseProxyServerData> {
|
||||||
|
if (responseBody.isNullOrEmpty()) return emptyList()
|
||||||
|
|
||||||
|
val gson = Gson()
|
||||||
|
val reverseProxyServerListType = object : TypeToken<List<ReverseProxyServerData>>() {}.type
|
||||||
|
return gson.fromJson(responseBody, reverseProxyServerListType)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun parseServersData(responseBody: String?): List<ServerData> {
|
||||||
|
if (responseBody.isNullOrEmpty()) return emptyList()
|
||||||
|
|
||||||
|
val gson = Gson()
|
||||||
|
|
||||||
|
val serverListType = object : TypeToken<List<ServerData>>() {}.type
|
||||||
|
return gson.fromJson(responseBody, serverListType)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun populateServers(serversData: List<ServerData>) {
|
||||||
|
servers.clear()
|
||||||
|
|
||||||
|
for (data in serversData) {
|
||||||
|
val serverInfo = ServerInfo(data.name, InetSocketAddress(data.address, data.port))
|
||||||
|
val registeredServer = server.createRawRegisteredServer(serverInfo)
|
||||||
|
servers[data.name] = registeredServer
|
||||||
|
this.server.registerServer(registeredServer.serverInfo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun migratePlayersToServer(targetServer: ReverseProxyServerData) {
|
||||||
|
val targetAddress = InetSocketAddress(targetServer.address, targetServer.port)
|
||||||
|
|
||||||
|
server.allPlayers.forEach { player ->
|
||||||
|
player.transferToHost(targetAddress)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package cafe.kirameki.minikuraVelocity
|
||||||
|
|
||||||
|
import com.velocitypowered.api.proxy.ProxyServer
|
||||||
|
import org.java_websocket.client.WebSocketClient
|
||||||
|
import org.java_websocket.handshake.ServerHandshake
|
||||||
|
import java.net.URI
|
||||||
|
import java.time.Duration
|
||||||
|
|
||||||
|
class MinikuraWebSocketClient(private val plugin: Main, private val server: ProxyServer, serverUri: URI?) : WebSocketClient(serverUri) {
|
||||||
|
override fun onOpen(handshakedata: ServerHandshake) {
|
||||||
|
println("Connected to server")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onMessage(message: String) {
|
||||||
|
println("Received: $message")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onError(ex: Exception) {
|
||||||
|
ex.printStackTrace()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onClose(code: Int, reason: String, remote: Boolean) {
|
||||||
|
println("Disconnected from websocket, reconnecting...")
|
||||||
|
server.scheduler.buildTask(plugin, Runnable { reconnect() }).delay(Duration.ofMillis(5000)).schedule()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
package cafe.kirameki.minikuraVelocity.store
|
||||||
|
|
||||||
|
import cafe.kirameki.minikuraVelocity.models.ReverseProxyServerData
|
||||||
|
import cafe.kirameki.minikuraVelocity.models.ServerData
|
||||||
|
import com.velocitypowered.api.proxy.ProxyServer
|
||||||
|
|
||||||
|
object ServerDataStore {
|
||||||
|
private val servers: MutableList<ServerData> = mutableListOf()
|
||||||
|
private val reverseProxyServers: MutableList<ReverseProxyServerData> = mutableListOf()
|
||||||
|
|
||||||
|
fun initialize(server: ProxyServer) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
fun addServer(serverData: ServerData) {
|
||||||
|
servers.add(serverData)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun addReverseProxyServer(reverseProxyServerData: ReverseProxyServerData) {
|
||||||
|
reverseProxyServers.add(reverseProxyServerData)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun addAllServers(serverData: List<ServerData>) {
|
||||||
|
servers.addAll(serverData)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun addAllReverseProxyServers(reverseProxyServerData: List<ReverseProxyServerData>) {
|
||||||
|
reverseProxyServers.addAll(reverseProxyServerData)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getServer(name: String): ServerData? {
|
||||||
|
return servers.find { it.name == name }
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getReverseProxyServer(name: String): ReverseProxyServerData? {
|
||||||
|
return reverseProxyServers.find { it.name == name }
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getServers(): List<ServerData> {
|
||||||
|
return servers
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getReverseProxyServers(): List<ReverseProxyServerData> {
|
||||||
|
return reverseProxyServers
|
||||||
|
}
|
||||||
|
|
||||||
|
fun clearServers() {
|
||||||
|
servers.clear()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun clearReverseProxyServers() {
|
||||||
|
reverseProxyServers.clear()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package cafe.kirameki.minikuraVelocity.listeners
|
||||||
|
|
||||||
|
import cafe.kirameki.minikuraVelocity.store.ServerDataStore
|
||||||
|
import com.velocitypowered.api.event.Subscribe
|
||||||
|
import com.velocitypowered.api.event.player.PlayerChooseInitialServerEvent
|
||||||
|
import com.velocitypowered.api.proxy.server.RegisteredServer
|
||||||
|
import org.slf4j.Logger
|
||||||
|
|
||||||
|
class ServerConnectionHandler(
|
||||||
|
private val servers: Map<String, RegisteredServer>,
|
||||||
|
private val logger: Logger
|
||||||
|
) {
|
||||||
|
@Subscribe
|
||||||
|
fun onPlayerChooseInitialServer(event: PlayerChooseInitialServerEvent) {
|
||||||
|
val player = event.player
|
||||||
|
val currentServer = event.initialServer;
|
||||||
|
|
||||||
|
val sortedServers = ServerDataStore.getServers()
|
||||||
|
.filter { it.join_priority != null }
|
||||||
|
.sortedBy { it.join_priority }
|
||||||
|
.mapNotNull { servers[it.name] }
|
||||||
|
|
||||||
|
System.out.println("Sorted servers: ${sortedServers.map { it.serverInfo.name }}")
|
||||||
|
|
||||||
|
for (server in sortedServers) {
|
||||||
|
if (server != currentServer) {
|
||||||
|
logger.info("Attempting to connect ${player.username} to server ${server.serverInfo.name}")
|
||||||
|
event.setInitialServer(server)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.warn("No available servers with valid join_priority for ${player.username}")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package cafe.kirameki.minikuraVelocity.models
|
||||||
|
|
||||||
|
data class ReverseProxyServerData(
|
||||||
|
val id: String,
|
||||||
|
val name: String,
|
||||||
|
val description: String?,
|
||||||
|
val address: String,
|
||||||
|
val port: Int,
|
||||||
|
val api_key: String,
|
||||||
|
val created_at: String,
|
||||||
|
val updated_at: String
|
||||||
|
)
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package cafe.kirameki.minikuraVelocity.models
|
||||||
|
|
||||||
|
data class ServerData(
|
||||||
|
val id: String,
|
||||||
|
val name: String,
|
||||||
|
val description: String?,
|
||||||
|
val address: String,
|
||||||
|
val port: Int,
|
||||||
|
val type: String,
|
||||||
|
val join_priority: Int?,
|
||||||
|
val api_key: String,
|
||||||
|
val created_at: String,
|
||||||
|
val updated_at: String
|
||||||
|
)
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package cafe.kirameki.minikuraVelocity.utils
|
||||||
|
|
||||||
|
import cafe.kirameki.minikuraVelocity.Main
|
||||||
|
import cafe.kirameki.minikuraVelocity.MinikuraWebSocketClient
|
||||||
|
import com.velocitypowered.api.proxy.ProxyServer
|
||||||
|
import java.net.URI
|
||||||
|
|
||||||
|
fun createWebSocketClient(plugin: Main, server: ProxyServer, websocketUrl: String): MinikuraWebSocketClient {
|
||||||
|
val uri = URI(websocketUrl)
|
||||||
|
val client = MinikuraWebSocketClient(plugin, server, uri)
|
||||||
|
return client
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user