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

CustomArgumentException fromString doesn't support rgb #473

Closed
Zoltus opened this issue Jul 21, 2023 · 4 comments · Fixed by #506
Closed

CustomArgumentException fromString doesn't support rgb #473

Zoltus opened this issue Jul 21, 2023 · 4 comments · Fixed by #506
Assignees
Labels
bug Something isn't working implemented for next release This has been implemented in the current dev build for the next public release

Comments

@Zoltus
Copy link

Zoltus commented Jul 21, 2023

CommandAPI version

9.0.3

Minecraft version

1.20.1

Are you shading the CommandAPI?

Yes

What I did

public class GamemodeArgument extends CustomArgument<GameMode, String> implements IArgument {

    public GamemodeArgument() {
        super(new StringArgument(Lang.NODES_GAMEMODE.getString()), info -> {
            GameMode gm = getGamemode(info.input());
            if (gm == null) {
                throw CustomArgumentException.fromString("§x§F§F§5§1§5§1R§x§F§F§5§E§5§Eo§x§F§F§6§C§6§Cm§x§F§F§7§9§7§9u§x§F§F§8§7§8§7n§x§F§F§9§4§9§4a");
            } else {
                return gm;
            }
        });
    }
}

What actually happened

It does handle the colors the wrong way.

What should have happened

it should output rgb colors

Server logs and CommandAPI config

no logs/errors.

Other

No response

@Zoltus Zoltus added the bug Something isn't working label Jul 21, 2023
@DerEchtePilz DerEchtePilz added the not reproducible Could not reproduce the issue described label Oct 6, 2023
@DerEchtePilz
Copy link
Collaborator

I could not reproduce this error, using CommandAPI 9.2.0 with Minecraft 1.20.1 using this code:

Argument<String> gamemodeArgument = new CustomArgument<>(new StringArgument("gamemode"), info -> {
            String gm = getGamemode(info.input());
            if (gm == null) {
                throw CustomArgument.CustomArgumentException.fromString("§x§F§F§5§1§5§1R§x§F§F§5§E§5§Eo§x§F§F§6§C§6§Cm§x§F§F§7§9§7§9u§x§F§F§8§7§8§7n§x§F§F§9§4§9§4a");
            } else {
                return gm;
            }
        });
        new CommandAPICommand("test")
            .withArguments(gamemodeArgument)
            .executes(info -> {
                info.sender().sendMessage(Component.text().content("This works!").build());
            })
            .register();

private String getGamemode(String input) {
        return (input.equals("s")) ? "survival" : null;
    }

Executing this command in-game and not giving the option s, makes the command output this error:
image

I'd close this for now. If this issue somehow still happens for you, please reply to this!

@Zoltus
Copy link
Author

Zoltus commented Oct 6, 2023

I could not reproduce this error, using CommandAPI 9.2.0 with Minecraft 1.20.1 using this code:

Argument<String> gamemodeArgument = new CustomArgument<>(new StringArgument("gamemode"), info -> {
            String gm = getGamemode(info.input());
            if (gm == null) {
                throw CustomArgument.CustomArgumentException.fromString("§x§F§F§5§1§5§1R§x§F§F§5§E§5§Eo§x§F§F§6§C§6§Cm§x§F§F§7§9§7§9u§x§F§F§8§7§8§7n§x§F§F§9§4§9§4a");
            } else {
                return gm;
            }
        });
        new CommandAPICommand("test")
            .withArguments(gamemodeArgument)
            .executes(info -> {
                info.sender().sendMessage(Component.text().content("This works!").build());
            })
            .register();

private String getGamemode(String input) {
        return (input.equals("s")) ? "survival" : null;
    }

Executing this command in-game and not giving the option s, makes the command output this error: image

I'd close this for now. If this issue somehow still happens for you, please reply to this!

The output you get means you are reproducing the issue, if you check he romuna text colors it's different than in fromString.
It should look like this:

javaw_2023-10-06_23-59-43

@DerEchtePilz DerEchtePilz reopened this Oct 6, 2023
@DerEchtePilz DerEchtePilz removed the not reproducible Could not reproduce the issue described label Oct 6, 2023
@DerEchtePilz DerEchtePilz self-assigned this Oct 7, 2023
@DerEchtePilz
Copy link
Collaborator

So I generally fixed this problem on Paper at least.
On Spigot, and I don't know if it's a me-problem, I get an exception.

For now, my progress is on dev/rgb-errors if anyone (or you) wants to try to fix this.
No matter what I do, I get this exception:

[13:12:14] [Server thread/INFO]: [BugTestingCommandAPI] Loading BugTestingCommandAPI v0.0.1
[13:12:14] [Server thread/INFO]: Loaded platform NMS_1_20_R1 > NMS_Common > CommandAPIBukkit
[13:12:14] [Server thread/WARN]: Could not hook into the NBT API for NBT support. Download it from https://www.spigotmc.org/resources/nbt-api.7939/
[13:12:14] [Server thread/INFO]: Hooked into Spigot successfully for Chat/ChatComponents
[13:12:14] [Server thread/WARN]: Could not hook into Adventure for AdventureChat/AdventureChatComponents
[13:12:14] [Server thread/WARN]: Could not hook into Paper for /minecraft:reload. Consider upgrading to Paper: https://papermc.io/
[13:12:14] [Server thread/ERROR]: net/kyori/adventure/text/Component initializing BugTestingCommandAPI v0.0.1 (Is it up to date?)
java.lang.NoClassDefFoundError: net/kyori/adventure/text/Component
        at io.github.derechtepilz.commandapi.CommandAPIBukkit.checkDependencies(CommandAPIBukkit.java:195) ~[?:?]
        at io.github.derechtepilz.commandapi.CommandAPIBukkit.onLoad(CommandAPIBukkit.java:134) ~[?:?]
        at io.github.derechtepilz.commandapi.CommandAPIHandler.onLoad(CommandAPIHandler.java:139) ~[?:?]
        at io.github.derechtepilz.commandapi.CommandAPI.onLoad(CommandAPI.java:122) ~[?:?]
        at io.github.derechtepilz.bugtestingcommandapi.Main.onLoad(Main.java:22) ~[?:?]
        at org.bukkit.craftbukkit.v1_20_R1.CraftServer.loadPlugins(CraftServer.java:440) ~[spigot-1.20.1-R0.1-SNAPSHOT.jar:3871-Spigot-d2eba2c-3f9263b]
        at net.minecraft.server.dedicated.DedicatedServer.e(DedicatedServer.java:219) ~[spigot-1.20.1-R0.1-SNAPSHOT.jar:3871-Spigot-d2eba2c-3f9263b]
        at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:972) ~[spigot-1.20.1-R0.1-SNAPSHOT.jar:3871-Spigot-d2eba2c-3f9263b]
        at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:303) ~[spigot-1.20.1-R0.1-SNAPSHOT.jar:3871-Spigot-d2eba2c-3f9263b]
        at java.lang.Thread.run(Thread.java:833) ~[?:?]
Caused by: java.lang.ClassNotFoundException: net.kyori.adventure.text.Component
        at org.bukkit.plugin.java.PluginClassLoader.loadClass0(PluginClassLoader.java:147) ~[spigot-api-1.20.1-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.plugin.java.PluginClassLoader.loadClass(PluginClassLoader.java:99) ~[spigot-api-1.20.1-R0.1-SNAPSHOT.jar:?]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:520) ~[?:?]
        ... 10 more

From the looks of it, the exception is thrown when the PaperImplementations.java constructor is called.
According to this discord message a NoClassDefFoundError only is thrown when a class that does not exist is used. Imports apparently don't matter.

So, at least for me, this issue is staying active a bit longer as I can't seem to find a solution that doesn't throw an exception (well, I could, but it uses reflection and is not a feasable solution for this problem).
Again, if anyone can figure out what's going on with this, please provide a bit more information, commit to this branch or open a pull request - I have no idea what's going on.

@DerEchtePilz DerEchtePilz added the implemented for next release This has been implemented in the current dev build for the next public release label Nov 23, 2023
@JorelAli
Copy link
Owner

Implemented in CommandAPI 9.3.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working implemented for next release This has been implemented in the current dev build for the next public release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants