Skip to content

Commit 7633a41

Browse files
authored
Hotfix/internal converters (#50)
* feat(core): add wrapper and primitive type in internal converters * feat(core): version * feat(core&bom): add bom and fix converter
1 parent c419187 commit 7633a41

File tree

7 files changed

+191
-6
lines changed

7 files changed

+191
-6
lines changed

bom/README.md

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# CommandsAPI BOM (Bill of Materials)
2+
3+
This module provides a BOM (Bill of Materials) for CommandsAPI, making it easier to manage consistent versions across all CommandsAPI modules.
4+
5+
## Usage
6+
7+
### Gradle (Kotlin DSL)
8+
9+
```kotlin
10+
dependencies {
11+
// Import the BOM
12+
implementation(platform("fr.traqueur.commands:bom:VERSION"))
13+
14+
// Then add dependencies without specifying versions
15+
implementation("fr.traqueur.commands:core")
16+
implementation("fr.traqueur.commands:platform-spigot")
17+
implementation("fr.traqueur.commands:platform-velocity")
18+
implementation("fr.traqueur.commands:platform-jda")
19+
implementation("fr.traqueur.commands:annotations-addon")
20+
}
21+
```
22+
23+
### Gradle (Groovy DSL)
24+
25+
```groovy
26+
dependencies {
27+
// Import the BOM
28+
implementation platform('fr.traqueur.commands:bom:VERSION')
29+
30+
// Then add dependencies without specifying versions
31+
implementation 'fr.traqueur.commands:core'
32+
implementation 'fr.traqueur.commands:platform-spigot'
33+
implementation 'fr.traqueur.commands:platform-velocity'
34+
implementation 'fr.traqueur.commands:platform-jda'
35+
implementation 'fr.traqueur.commands:annotations-addon'
36+
}
37+
```
38+
39+
### Maven
40+
41+
```xml
42+
<dependencyManagement>
43+
<dependencies>
44+
<dependency>
45+
<groupId>fr.traqueur.commands</groupId>
46+
<artifactId>bom</artifactId>
47+
<version>VERSION</version>
48+
<type>pom</type>
49+
<scope>import</scope>
50+
</dependency>
51+
</dependencies>
52+
</dependencyManagement>
53+
54+
<dependencies>
55+
<!-- Then add dependencies without specifying versions -->
56+
<dependency>
57+
<groupId>fr.traqueur.commands</groupId>
58+
<artifactId>core</artifactId>
59+
</dependency>
60+
<dependency>
61+
<groupId>fr.traqueur.commands</groupId>
62+
<artifactId>platform-spigot</artifactId>
63+
</dependency>
64+
<dependency>
65+
<groupId>fr.traqueur.commands</groupId>
66+
<artifactId>platform-velocity</artifactId>
67+
</dependency>
68+
<dependency>
69+
<groupId>fr.traqueur.commands</groupId>
70+
<artifactId>platform-jda</artifactId>
71+
</dependency>
72+
<dependency>
73+
<groupId>fr.traqueur.commands</groupId>
74+
<artifactId>annotations-addon</artifactId>
75+
</dependency>
76+
</dependencies>
77+
```
78+
79+
## Benefits
80+
81+
Using the BOM provides several advantages:
82+
83+
1. **Version Consistency**: All CommandsAPI modules will use compatible versions
84+
2. **Simplified Dependency Management**: No need to specify versions for each module
85+
3. **Easier Updates**: Update all modules by changing only the BOM version
86+
4. **Reduced Conflicts**: Ensures all modules work together correctly
87+
88+
## Available Modules
89+
90+
The BOM manages versions for the following modules:
91+
92+
- `core` - Core functionality and API
93+
- `platform-spigot` - Spigot/Bukkit platform support
94+
- `platform-velocity` - Velocity proxy platform support
95+
- `platform-jda` - JDA (Discord) platform support
96+
- `annotations-addon` - Annotation-based command registration

bom/build.gradle

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
plugins {
2+
id 'java-platform'
3+
id 'maven-publish'
4+
}
5+
6+
description = 'CommandsAPI BOM (Bill of Materials)'
7+
8+
javaPlatform {
9+
allowDependencies()
10+
}
11+
12+
dependencies {
13+
constraints {
14+
api(project(':core'))
15+
api(project(':spigot'))
16+
api(project(':velocity'))
17+
api(project(':jda'))
18+
api(project(':annotations-addon'))
19+
}
20+
}
21+
22+
publishing {
23+
repositories {
24+
maven {
25+
def repository = System.getProperty('repository.name', 'snapshots')
26+
def repoType = repository.toLowerCase()
27+
28+
name = "groupez${repository.capitalize()}"
29+
url = uri("https://repo.groupez.dev/${repoType}")
30+
31+
credentials {
32+
username = findProperty("${name}Username") ?: System.getenv('MAVEN_USERNAME')
33+
password = findProperty("${name}Password") ?: System.getenv('MAVEN_PASSWORD')
34+
}
35+
36+
authentication {
37+
create("basic", BasicAuthentication)
38+
}
39+
}
40+
}
41+
42+
publications {
43+
create('maven', MavenPublication) {
44+
from components.javaPlatform
45+
46+
groupId = rootProject.group.toString()
47+
artifactId = 'bom'
48+
version = rootProject.version.toString()
49+
50+
pom {
51+
name = 'CommandsAPI BOM'
52+
description = 'CommandsAPI Bill of Materials - Manages consistent versions across CommandsAPI modules'
53+
url = 'https://github.com/Traqueur-dev/CommandsAPI'
54+
55+
licenses {
56+
license {
57+
name = 'MIT License'
58+
url = 'https://opensource.org/licenses/MIT'
59+
}
60+
}
61+
62+
developers {
63+
developer {
64+
id = 'traqueur'
65+
name = 'Traqueur'
66+
}
67+
}
68+
69+
scm {
70+
connection = 'scm:git:git://github.com/Traqueur-dev/CommandsAPI.git'
71+
developerConnection = 'scm:git:ssh://github.com/Traqueur-dev/CommandsAPI.git'
72+
url = 'https://github.com/Traqueur-dev/CommandsAPI'
73+
}
74+
}
75+
}
76+
}
77+
}

build.gradle

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ allprojects {
77
group = 'fr.traqueur.commands'
88
version = property('version')
99

10-
apply {
11-
plugin 'java-library'
10+
if (project.name != 'bom') {
11+
apply {
12+
plugin 'java-library'
13+
}
1214
}
1315

1416
ext.classifier = System.getProperty('archive.classifier')
@@ -27,7 +29,7 @@ allprojects {
2729
}
2830

2931
subprojects {
30-
if (project.name.contains('test-')) {
32+
if (project.name.contains('test-') || project.name == 'bom') {
3133
return;
3234
}
3335

core/src/main/java/fr/traqueur/commands/api/CommandManager.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ public void unregisterCommand(Command<T, S> command, boolean subcommands) {
202202
* @param <C> The type of the argument.
203203
*/
204204
public <C> void registerConverter(Class<C> typeClass, ArgumentConverter<C> converter) {
205-
this.typeConverters.put(typeClass.getSimpleName().toLowerCase(), new ArgumentConverter.Wrapper<>(typeClass, converter));
205+
this.typeConverters.put(typeClass.getName().toLowerCase(), new ArgumentConverter.Wrapper<>(typeClass, converter));
206206
}
207207

208208
/**
@@ -465,9 +465,18 @@ public CommandInvoker<T, S> getInvoker() {
465465
*/
466466
private void registerInternalConverters() {
467467
this.registerConverter(String.class, (s) -> s);
468+
469+
// Register both primitive and wrapper types for DefaultArgumentParser (Spigot/Velocity).
470+
// JDA's ArgumentParser handles primitives internally, but text-based platforms need explicit registration.
471+
// Wrapper types (Integer.class, Long.class, etc.) are registered for compatibility with wrapper usage.
472+
// Primitive types (int.class, long.class, etc.) are registered to support primitive method parameters.
468473
this.registerConverter(Boolean.class, new BooleanArgument<>());
474+
this.registerConverter(boolean.class, new BooleanArgument<>());
469475
this.registerConverter(Integer.class, new IntegerArgument());
476+
this.registerConverter(int.class, new IntegerArgument());
470477
this.registerConverter(Double.class, new DoubleArgument());
478+
this.registerConverter(double.class, new DoubleArgument());
471479
this.registerConverter(Long.class, new LongArgument());
480+
this.registerConverter(long.class, new LongArgument());
472481
}
473482
}

core/src/main/java/fr/traqueur/commands/api/arguments/ArgumentType.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ record Simple(Class<?> clazz) implements ArgumentType {
2424

2525
@Override
2626
public String key() {
27-
return clazz.getSimpleName().toLowerCase();
27+
return clazz.getName().toLowerCase();
2828
}
2929

3030
}

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version=5.0.0
1+
version=5.0.1

settings.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
rootProject.name = 'CommandsAPI'
22

3+
include 'bom'
34
include 'velocity-test-plugin'
45
include 'spigot-test-plugin'
56
include 'spigot'

0 commit comments

Comments
 (0)