Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inner classes can't be used with the annotation system #201

Open
JorelAli opened this issue May 10, 2021 · 0 comments
Open

Inner classes can't be used with the annotation system #201

JorelAli opened this issue May 10, 2021 · 0 comments
Labels
bug Something isn't working for 10.0.0 annotations This feature will be worked on for the 10.0.0 annotations update

Comments

@JorelAli
Copy link
Owner

CommandAPI version
5.11

Minecraft version
1.16.5

Describe the bug
Given a class that actually is inner class:

@Command("weather")
@Permission("assentials.command.weather")
public class WeatherCommand {
    
    @Command("sun")
    @Permission("assentials.command.weather")
    public static class SunShortcut {
        @Default
        public static void run(CommandSender sender) {
            WeatherCommand.doSomething(sender, "clear");
        }
    }
    
      @Default
    public static void doSomething(CommandSender sender, @AMultiLiteralArgument({"clear"}) String literal) {
        // code
    }
}

Registering with the following fails

CommandAPI.registerCommand(WeatherCommand.SunShortcut.class);

You get this:

Task :compileJava
class WeatherCommand clashes with package of same name
public class WeatherCommand {
       ^
SunShortcut$Command.java:1: error: package com.lasttray.plugin.assentials.command.WeatherCommand clashes with class of same name
package com.lasttray.plugin.assentials.command.WeatherCommand;

Using Maven you get a similar issue:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project CommandAPITest: Compilation failure
[ERROR] /D:/eclipseworkspaces/1.13commandapi/commandapi-test-200/target/generated-sources/annotations/WeatherCommand/SunShortcut$Command.java:[14,17] cannot find symbol
[ERROR]   symbol:   variable SunShortcut
[ERROR]   location: class WeatherCommand.SunShortcut$Command
[ERROR] -> [Help 1]

The generated result is mangled:

├── generated-sources
└── annotations
    ├── WeatherCommand
    │   └── SunShortcut$Command.java
    └── WeatherCommand$Command.java

WeatherCommand$Command.java

import dev.jorel.commandapi.CommandAPICommand;
import dev.jorel.commandapi.arguments.MultiLiteralArgument;

// This class was automatically generated by the CommandAPI
public class WeatherCommand$Command {

    @SuppressWarnings("unchecked")
    public static void register() {

        new CommandAPICommand("weather")
            .withPermission("assentials.command.weather")
            .withArguments(new MultiLiteralArgument("clear"))
            .executes((sender, args) -> {
                WeatherCommand.doSomething(sender, (String) args[0]);
            })
            .register();

        }

}

SunShortcut$Command.java

package WeatherCommand;

import dev.jorel.commandapi.CommandAPICommand;

// This class was automatically generated by the CommandAPI
public class SunShortcut$Command {

    @SuppressWarnings("unchecked")
    public static void register() {

        new CommandAPICommand("sun")
            .withPermission("assentials.command.weather")
            .executes((sender, args) -> {
                SunShortcut.run(sender);
            })
            .register();

        }

}
@JorelAli JorelAli added the bug Something isn't working label May 10, 2021
@JorelAli JorelAli changed the title Inner classes can't be used with the command conversion system Inner classes can't be used with the annotation system Jun 13, 2021
@JorelAli JorelAli added the for 10.0.0 annotations This feature will be worked on for the 10.0.0 annotations update label Jun 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working for 10.0.0 annotations This feature will be worked on for the 10.0.0 annotations update
Projects
None yet
Development

No branches or pull requests

1 participant