Set version automatically, channel cmd IDs
Added support for using the IDs setting for channel commands
This commit is contained in:
parent
5199482053
commit
ff0d54e00b
6 changed files with 166 additions and 117 deletions
|
@ -1,15 +1,16 @@
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<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">
|
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>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.github.TBMCPlugins.ChromaCore</groupId>
|
<groupId>com.github.TBMCPlugins.ChromaCore</groupId>
|
||||||
<artifactId>CorePOM</artifactId>
|
<artifactId>CorePOM</artifactId>
|
||||||
<version>master-SNAPSHOT</version>
|
<version>master-SNAPSHOT</version>
|
||||||
<relativePath>../CorePOM</relativePath>
|
<relativePath>../CorePOM</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>Chroma-Core</artifactId>
|
<artifactId>Chroma-Core</artifactId>
|
||||||
<name>Chroma-Core</name>
|
<name>Chroma-Core</name>
|
||||||
<description>Chroma-Core</description>
|
<description>Chroma-Core</description>
|
||||||
|
<version>v${noprefix.version}-SNAPSHOT</version>
|
||||||
<build>
|
<build>
|
||||||
<sourceDirectory>src/main/java</sourceDirectory>
|
<sourceDirectory>src/main/java</sourceDirectory>
|
||||||
<resources>
|
<resources>
|
||||||
|
@ -218,6 +219,7 @@
|
||||||
<!-- github server corresponds to entry in ~/.m2/settings.xml -->
|
<!-- github server corresponds to entry in ~/.m2/settings.xml -->
|
||||||
<github.global.server>github</github.global.server>
|
<github.global.server>github</github.global.server>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<noprefix.version>1.0</noprefix.version>
|
||||||
</properties>
|
</properties>
|
||||||
<scm>
|
<scm>
|
||||||
<url>https://github.com/TBMCPlugins/mvn-repo</url>
|
<url>https://github.com/TBMCPlugins/mvn-repo</url>
|
||||||
|
|
|
@ -47,7 +47,12 @@ public class ChannelComponent extends Component<JavaPlugin> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getCommandPath() {
|
public String getCommandPath() {
|
||||||
return channel.ID; //TODO: IDs
|
return channel.ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String[] getCommandPaths() {
|
||||||
|
return channel.IDs.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command2.Subcommand
|
@Command2.Subcommand
|
||||||
|
|
|
@ -322,9 +322,9 @@ public abstract class Command2<TC extends ICommand2<TP>, TP extends Command2Send
|
||||||
var params = new String[method.getParameterCount() - 1];
|
var params = new String[method.getParameterCount() - 1];
|
||||||
ht = getParameterHelp(method, ht, subcommand, params);
|
ht = getParameterHelp(method, ht, subcommand, params);
|
||||||
var sd = new SubcommandData<>(method, command, params, ht);
|
var sd = new SubcommandData<>(method, command, params, ht);
|
||||||
subcommands.put(subcommand, sd); //Result of the above (def) is that it will show the help text
|
registerCommand(path, method.getName(), ann, sd);
|
||||||
for (String alias : ann.aliases())
|
for (String p : command.getCommandPaths())
|
||||||
subcommands.put(commandChar + path + alias, sd);
|
registerCommand(p, method.getName(), ann, sd);
|
||||||
addedSubcommands.add(sd);
|
addedSubcommands.add(sd);
|
||||||
scmdHelpList.add(subcommand);
|
scmdHelpList.add(subcommand);
|
||||||
nosubs = false;
|
nosubs = false;
|
||||||
|
@ -380,6 +380,13 @@ public abstract class Command2<TC extends ICommand2<TP>, TP extends Command2Send
|
||||||
return ht;
|
return ht;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void registerCommand(String path, String methodName, Subcommand ann, SubcommandData<TC> sd) {
|
||||||
|
val subcommand = commandChar + path + getCommandPath(methodName, ' ');
|
||||||
|
subcommands.put(subcommand, sd);
|
||||||
|
for (String alias : ann.aliases())
|
||||||
|
subcommands.put(commandChar + path + alias, sd);
|
||||||
|
}
|
||||||
|
|
||||||
public abstract boolean hasPermission(TP sender, TC command, Method subcommand);
|
public abstract boolean hasPermission(TP sender, TC command, Method subcommand);
|
||||||
|
|
||||||
public String[] getCommandsText() {
|
public String[] getCommandsText() {
|
||||||
|
@ -406,13 +413,19 @@ public abstract class Command2<TC extends ICommand2<TP>, TP extends Command2Send
|
||||||
for (val method : command.getClass().getMethods()) {
|
for (val method : command.getClass().getMethods()) {
|
||||||
val ann = method.getAnnotation(Subcommand.class);
|
val ann = method.getAnnotation(Subcommand.class);
|
||||||
if (ann == null) continue;
|
if (ann == null) continue;
|
||||||
val subcommand = commandChar + path + getCommandPath(method.getName(), ' ');
|
unregisterCommand(path, method.getName(), ann);
|
||||||
subcommands.remove(subcommand);
|
for (String p : command.getCommandPaths())
|
||||||
for (String alias : ann.aliases())
|
unregisterCommand(p, method.getName(), ann);
|
||||||
subcommands.remove(alias);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void unregisterCommand(String path, String methodName, Subcommand ann) {
|
||||||
|
val subcommand = commandChar + path + getCommandPath(methodName, ' ');
|
||||||
|
subcommands.remove(subcommand);
|
||||||
|
for (String alias : ann.aliases())
|
||||||
|
subcommands.remove(commandChar + path + alias);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* It will start with the given replace char.
|
* It will start with the given replace char.
|
||||||
*
|
*
|
||||||
|
|
|
@ -63,6 +63,18 @@ public abstract class ICommand2<TP extends Command2Sender> {
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final String[] EMPTY_PATHS = new String[0];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* All of the command's paths it will be invoked on. Does not include aliases or the default path.
|
||||||
|
* Must be lowercase and must include the full path.
|
||||||
|
*
|
||||||
|
* @return The full command paths that this command should be registered under in addition to the default one.
|
||||||
|
*/
|
||||||
|
public String[] getCommandPaths() {
|
||||||
|
return EMPTY_PATHS;
|
||||||
|
}
|
||||||
|
|
||||||
private String getcmdpath() {
|
private String getcmdpath() {
|
||||||
if (!getClass().isAnnotationPresent(CommandClass.class))
|
if (!getClass().isAnnotationPresent(CommandClass.class))
|
||||||
throw new RuntimeException(
|
throw new RuntimeException(
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
name: ChromaCore
|
name: ChromaCore
|
||||||
main: buttondevteam.core.MainPlugin
|
main: buttondevteam.core.MainPlugin
|
||||||
version: '1.0'
|
version: '${noprefix.version}'
|
||||||
author: NorbiPeti
|
author: NorbiPeti
|
||||||
commands:
|
commands:
|
||||||
updateplugin:
|
updateplugin:
|
||||||
|
|
221
CorePOM/pom.xml
221
CorePOM/pom.xml
|
@ -1,110 +1,127 @@
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
|
||||||
http://maven.apache.org/maven-v4_0_0.xsd">
|
http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<groupId>com.github.TBMCPlugins.ChromaCore</groupId>
|
<groupId>com.github.TBMCPlugins.ChromaCore</groupId>
|
||||||
<artifactId>CorePOM</artifactId>
|
<artifactId>CorePOM</artifactId>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<version>master-SNAPSHOT</version>
|
<version>master-SNAPSHOT</version>
|
||||||
<properties>
|
<properties>
|
||||||
<lombok.version>1.18.10</lombok.version>
|
<lombok.version>1.18.10</lombok.version>
|
||||||
</properties>
|
</properties>
|
||||||
<name>Core POM for Chroma</name>
|
<name>Core POM for Chroma</name>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<pluginManagement>
|
<pluginManagement>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.8.1</version>
|
<version>3.8.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<release>8</release>
|
<release>8</release>
|
||||||
<annotationProcessorPaths>
|
<annotationProcessorPaths>
|
||||||
<annotationProcessorPath>
|
<annotationProcessorPath>
|
||||||
<groupId>com.github.bsideup.jabel</groupId>
|
<groupId>com.github.bsideup.jabel</groupId>
|
||||||
<artifactId>jabel-javac-plugin</artifactId>
|
<artifactId>jabel-javac-plugin</artifactId>
|
||||||
<version>0.2.0</version>
|
<version>0.2.0</version>
|
||||||
</annotationProcessorPath>
|
</annotationProcessorPath>
|
||||||
<annotationProcessorPath>
|
<annotationProcessorPath>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
<version>${lombok.version}</version>
|
<version>${lombok.version}</version>
|
||||||
</annotationProcessorPath>
|
</annotationProcessorPath>
|
||||||
<annotationProcessorPath>
|
<annotationProcessorPath>
|
||||||
<groupId>com.github.TBMCPlugins.ChromaCore</groupId>
|
<groupId>com.github.TBMCPlugins.ChromaCore</groupId>
|
||||||
<artifactId>ButtonProcessor</artifactId>
|
<artifactId>ButtonProcessor</artifactId>
|
||||||
<version>master-SNAPSHOT</version>
|
<version>master-SNAPSHOT</version>
|
||||||
</annotationProcessorPath>
|
</annotationProcessorPath>
|
||||||
</annotationProcessorPaths>
|
</annotationProcessorPaths>
|
||||||
<annotationProcessors> <!-- Order is important, so these lines are needed -->
|
<annotationProcessors> <!-- Order is important, so these lines are needed -->
|
||||||
<annotationProcessor>com.github.bsideup.jabel.JabelJavacProcessor</annotationProcessor>
|
<annotationProcessor>com.github.bsideup.jabel.JabelJavacProcessor</annotationProcessor>
|
||||||
<annotationProcessor>lombok.launch.AnnotationProcessorHider$AnnotationProcessor
|
<annotationProcessor>lombok.launch.AnnotationProcessorHider$AnnotationProcessor
|
||||||
</annotationProcessor>
|
</annotationProcessor>
|
||||||
<annotationProcessor>buttondevteam.buttonproc.ButtonProcessor</annotationProcessor>
|
<annotationProcessor>buttondevteam.buttonproc.ButtonProcessor</annotationProcessor>
|
||||||
</annotationProcessors>
|
</annotationProcessors>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
<configuration>
|
<configuration>
|
||||||
<useSystemClassLoader>false
|
<useSystemClassLoader>false
|
||||||
</useSystemClassLoader> <!-- https://stackoverflow.com/a/53012553/2703239 -->
|
</useSystemClassLoader> <!-- https://stackoverflow.com/a/53012553/2703239 -->
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
<!-- <plugin>
|
||||||
</pluginManagement>
|
<groupId>io.github.1tchy</groupId>
|
||||||
</build>
|
<artifactId>variable-search-replace-plugin</artifactId>
|
||||||
|
<version>1.1</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>replace</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<text>${project.version}</text>
|
||||||
|
<search>^v</search>
|
||||||
|
<variableName>noprefix.version</variableName>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin> -->
|
||||||
|
</plugins>
|
||||||
|
</pluginManagement>
|
||||||
|
</build>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
<id>jitpack.io</id>
|
<id>jitpack.io</id>
|
||||||
<url>https://jitpack.io/</url>
|
<url>https://jitpack.io/</url>
|
||||||
</repository>
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
<version>4.13.1</version>
|
<version>4.13.1</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
|
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
<version>${lombok.version}</version>
|
<version>${lombok.version}</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<profiles>
|
<profiles>
|
||||||
<profile>
|
<profile>
|
||||||
<id>intellij-idea-only</id>
|
<id>intellij-idea-only</id>
|
||||||
<activation>
|
<activation>
|
||||||
<property>
|
<property>
|
||||||
<name>idea.maven.embedder.version</name>
|
<name>idea.maven.embedder.version</name>
|
||||||
</property>
|
</property>
|
||||||
</activation>
|
</activation>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<configuration>
|
<configuration>
|
||||||
<release>11</release>
|
<release>11</release>
|
||||||
<!--
|
<!--
|
||||||
<compilerArgs>
|
<compilerArgs>
|
||||||
<arg>HYPHENHYPHENenable-preview</arg>
|
<arg>HYPHENHYPHENenable-preview</arg>
|
||||||
</compilerArgs>
|
</compilerArgs>
|
||||||
-->
|
-->
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
</profile>
|
</profile>
|
||||||
</profiles>
|
</profiles>
|
||||||
</project>
|
</project>
|
||||||
|
|
Loading…
Reference in a new issue