JorelAli / CommandAPI

A Bukkit/Spigot API for the command UI introduced in Minecraft 1.13
https://commandapi.jorel.dev
MIT License
531 stars 68 forks source link

You must be a ... to run this command #105

Closed Loapu closed 4 years ago

Loapu commented 4 years ago

CommandAPI version 3.0

Minecraft version 1.15.2

Describe the bug When I (as a player with OP) try to run my command, it tells me "You must be a cruciuscommand to run this command"

My code This code reproduces the behavior:

public class CruciusCommand
{
    // -------------------------------------------- //
    // FIELDS
    // -------------------------------------------- //

    private Crucius plugin = Crucius.get();
    private LinkedHashMap<String, Argument> arguments = new LinkedHashMap<>();
    private String cmd = "crucius";
    private String[] aliases = { "cr", "cruc" };
    private CommandPermission permission = CommandPermission.fromString("crucius.basecommand");
    private String code = "en";

    // -------------------------------------------- //
    // INSTANCE & CONSTRUCT
    // -------------------------------------------- //

    private static CruciusCommand i;
    public static CruciusCommand get() { return i; }
    public CruciusCommand() {   i = this; }

    // -------------------------------------------- //
    // COMMANDS
    // -------------------------------------------- //

    @SuppressWarnings("Duplicates")
    public void registerCommand()
    {

        // -------------------------------------------- //
        // /crucius
        // -------------------------------------------- //

        new CommandAPICommand(cmd)
            .withAliases(aliases)
            .withPermission(permission)
            .executes((sender, args) ->
            {
                if (sender instanceof Player)
                {
                    Player p = (Player) sender;
                    code = plugin.getConvertedPlayerLocale(p);
                }
                Lang lang = Lang.read(code);
                sender.sendMessage(lang.getMessage(Messages.SPACER_UPPER, new String[]{lang.getMessage(Messages.CRUCIUS).toUpperCase()}));
                sender.sendMessage(lang.getMessage(Messages.INFO1, new String[]{plugin.getDescription().getName(), plugin.getDescription().getVersion()}));
                sender.sendMessage(lang.getMessage(Messages.INFO2, new String[]{"" + plugin.getDescription().getAuthors()}));
                sender.sendMessage(lang.getMessage(Messages.INFO3, new String[]{plugin.getDescription().getWebsite()}));
                if (sender.hasPermission("crucius.basecommand.help"))
                    sender.sendMessage(lang.getMessage(Messages.INFO4, new String[]{"/" + cmd + " help"}));
                sender.sendMessage(lang.getMessage(Messages.SPACER_LOWER, new String[]{lang.getMessage(Messages.CRUCIUS).toUpperCase()}));
            }).register();
...

Expected behavior Let me execute the command

Additional context The same problem persists when I try the command inside the console

JorelAli commented 4 years ago

I'll have a look at this when I can. By any chance, if you have the required permission node (as well as being OP), does it work?

Loapu commented 4 years ago

Does not work either :/ image

JorelAli commented 4 years ago

Thanks for the response - This is a very bizarre bug and it may take some time to figure out why it's doing that

Loapu commented 4 years ago

Don't worry, there is no hurry

JorelAli commented 4 years ago

Odd - I've been unable to replicate this bug. Here's the code I'm using:

new CommandAPICommand("crucius")
    .withAliases(new String[] { "cr", "cruc" })
    .withPermission(CommandPermission.fromString("crucius.basecommand"))
    .executes((sender, args) -> {
        if (sender instanceof Player) {
            Player p = (Player) sender;
            System.out.println("P");
        }
        sender.sendMessage("A");

        if (sender.hasPermission("crucius.basecommand.help")) {
            sender.sendMessage("B");
            }
    }).register();

I'm currently on a server without any permission plugins (e.g. LuckPerms) and I am an operator. I am able to run the command /crucius with no problems, and both "A" and "B" are sent to me. Similarly, this works as intended when running it from the console.

Could it be a LuckPerms related issue?

Loapu commented 4 years ago

Lemme check

JorelAli commented 4 years ago

I installed LuckPerms and ran the command (still being operator and not using LuckPerms to add any permissions) and it still yields the same result (it works as intended).

Loapu commented 4 years ago

Alright, I installed Crucius fresh on a new Spigot 1.15.2 server, the same result. Crucius-0.2.0-pre.7.jar.zip Here is my jar file that I use. The source code is included. I do not know why this error comes up, the console doesn't give an answer either.

JorelAli commented 4 years ago

@Loapu

[18:46:56 ERROR]: Error occurred while enabling Crucius v0.2.0-pre.1 (Is it up to date?)
java.lang.NullPointerException: null
    at java.util.Objects.requireNonNull(Unknown Source) ~[?:1.8.0_251]
    at java.nio.file.Files.copy(Unknown Source) ~[?:1.8.0_251]
    at de.theyphania.crucius.Crucius.loadSettings(Crucius.java:205) ~[?:?]
    at de.theyphania.crucius.Crucius.loadResources(Crucius.java:118) ~[?:?]
    at de.theyphania.crucius.Crucius.onEnableInner(Crucius.java:72) ~[?:?]
    at de.theyphania.crucius.CruciusPlugin.onEnable(CruciusPlugin.java:66) ~[?:?]
    at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263) ~[spigot-1.15.2.jar:git-Spigot-a99063f-fad2494]
    at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:351) [spigot-1.15.2.jar:git-Spigot-a99063f-fad2494]
    at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:480) [spigot-1.15.2.jar:git-Spigot-a99063f-fad2494]
    at org.bukkit.craftbukkit.v1_15_R1.CraftServer.enablePlugin(CraftServer.java:464) [spigot-1.15.2.jar:git-Spigot-a99063f-fad2494]
    at org.bukkit.craftbukkit.v1_15_R1.CraftServer.enablePlugins(CraftServer.java:378) [spigot-1.15.2.jar:git-Spigot-a99063f-fad2494]
    at net.minecraft.server.v1_15_R1.MinecraftServer.a(MinecraftServer.java:457) [spigot-1.15.2.jar:git-Spigot-a99063f-fad2494]
    at net.minecraft.server.v1_15_R1.DedicatedServer.init(DedicatedServer.java:274) [spigot-1.15.2.jar:git-Spigot-a99063f-fad2494]
    at net.minecraft.server.v1_15_R1.MinecraftServer.run(MinecraftServer.java:784) [spigot-1.15.2.jar:git-Spigot-a99063f-fad2494]
    at java.lang.Thread.run(Unknown Source) [?:1.8.0_251]

Have you tried moving the command registration to the onLoad() method? In my testing, I registered it there as opposed to the onEnable() method

Loapu commented 4 years ago

So, I moved the command registration to the onLoad() method but it throws the same error. It seems to have a problem with the WrapperCommandSyntaxException ... Crucius-0.2.0-pre.11.jar.zip

And for your error, the JAR-File is inside the zip folder. Renaming won't do it. (If this was what you did because I never had your exception :/)

JorelAli commented 4 years ago

Alright, so I downloaded the zip folder, extracted the .jar file into a 1.15.2 spigot server with the CommandAPI (v3.1, I'll explain a little further down) and LuckPerms (literally fresh install, haven't adjusted permissions or anything).

I logged in and ran the command /crucius. In game, no messages were displayed.

In the console however, the following information was displayed ``` [19:26:48 INFO]: [CommandAPI] Enabling CommandAPI v3.1 [19:26:48 INFO]: [Crucius] Enabling Crucius v0.2.0-pre.8 [19:26:48 INFO]: [Crucius] \\\\\\\\\\\\\\ STARTING PLUGIN ////////////// [19:26:48 INFO]: [Crucius][STARTED] Loading resources... [19:26:48 INFO]: [Crucius][STEP 1/3] Loading plugin directories... [19:26:48 INFO]: [Crucius][STEP 1/3] All directories loaded successfully. [19:26:48 INFO]: [Crucius][STEP 2/3] Loading plugin settings... [19:26:48 ERROR]: [Crucius] Looks like we have a java.lang.NullPointerException here. [19:26:48 ERROR]: [Crucius] Surely it is Janto's fault but here is a bit more detail: [19:26:48 WARN]: java.lang.NullPointerException [19:26:48 WARN]: at java.util.Objects.requireNonNull(Unknown Source) [19:26:48 WARN]: at java.nio.file.Files.copy(Unknown Source) [19:26:48 WARN]: at de.theyphania.crucius.Crucius.loadSettings(Crucius.java:209) [19:26:48 WARN]: at de.theyphania.crucius.Crucius.loadResources(Crucius.java:122) [19:26:48 WARN]: at de.theyphania.crucius.Crucius.onEnableInner(Crucius.java:77) [19:26:48 WARN]: at de.theyphania.crucius.CruciusPlugin.onEnable(CruciusPlugin.java:66) [19:26:48 WARN]: at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263) [19:26:48 WARN]: at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:351) [19:26:48 WARN]: at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:480) [19:26:48 WARN]: at org.bukkit.craftbukkit.v1_15_R1.CraftServer.enablePlugin(CraftServer.java:464) [19:26:48 WARN]: at org.bukkit.craftbukkit.v1_15_R1.CraftServer.enablePlugins(CraftServer.java:378) [19:26:48 WARN]: at net.minecraft.server.v1_15_R1.MinecraftServer.a(MinecraftServer.java:457) [19:26:48 WARN]: at net.minecraft.server.v1_15_R1.DedicatedServer.init(DedicatedServer.java:274) [19:26:48 WARN]: at net.minecraft.server.v1_15_R1.MinecraftServer.run(MinecraftServer.java:784) [19:26:48 WARN]: at java.lang.Thread.run(Unknown Source) [19:26:48 ERROR]: Error occurred while enabling Crucius v0.2.0-pre.8 (Is it up to date?) java.lang.NullPointerException: null at java.util.Objects.requireNonNull(Unknown Source) ~[?:1.8.0_251] at java.nio.file.Files.copy(Unknown Source) ~[?:1.8.0_251] at de.theyphania.crucius.util.Settings.read(Settings.java:169) ~[?:?] at de.theyphania.crucius.Crucius.loadSettings(Crucius.java:217) ~[?:?] at de.theyphania.crucius.Crucius.loadResources(Crucius.java:122) ~[?:?] at de.theyphania.crucius.Crucius.onEnableInner(Crucius.java:77) ~[?:?] at de.theyphania.crucius.CruciusPlugin.onEnable(CruciusPlugin.java:66) ~[?:?] at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263) ~[spigot-1.15.2.jar:git-Spigot-a99063f-fad2494] at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:351) [spigot-1.15.2.jar:git-Spigot-a99063f-fad2494] at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:480) [spigot-1.15.2.jar:git-Spigot-a99063f-fad2494] at org.bukkit.craftbukkit.v1_15_R1.CraftServer.enablePlugin(CraftServer.java:464) [spigot-1.15.2.jar:git-Spigot-a99063f-fad2494] at org.bukkit.craftbukkit.v1_15_R1.CraftServer.enablePlugins(CraftServer.java:378) [spigot-1.15.2.jar:git-Spigot-a99063f-fad2494] at net.minecraft.server.v1_15_R1.MinecraftServer.a(MinecraftServer.java:457) [spigot-1.15.2.jar:git-Spigot-a99063f-fad2494] at net.minecraft.server.v1_15_R1.DedicatedServer.init(DedicatedServer.java:274) [spigot-1.15.2.jar:git-Spigot-a99063f-fad2494] at net.minecraft.server.v1_15_R1.MinecraftServer.run(MinecraftServer.java:784) [spigot-1.15.2.jar:git-Spigot-a99063f-fad2494] at java.lang.Thread.run(Unknown Source) [?:1.8.0_251] [19:26:48 INFO]: Server permissions file permissions.yml is empty, ignoring it [19:26:48 INFO]: Done (12.637s)! For help, type "help" [19:26:48 INFO]: [CommandAPI] Linking permissions to commands: [19:26:48 INFO]: [CommandAPI] crucius.basecommand -> /cr [19:26:48 INFO]: [CommandAPI] crucius.basecommand -> /cruc [19:26:48 INFO]: [CommandAPI] crucius.basecommand -> /crucius [19:26:48 INFO]: [CommandAPI] NONE -> /test [19:28:56 INFO]: UUID of player Skepter is 9a1035b4-90e6-4ab7-8907-698d862a6b0d [19:28:58 INFO]: Skepter[/127.0.0.1:51798] logged in with entity id 193 at ([world]-243.19481689523482, 64.0, 56.247422666494785) [19:29:05 INFO]: Skepter issued server command: /crucius [19:29:05 INFO]: java.lang.NullPointerException [19:29:05 INFO]: at java.util.Objects.requireNonNull(Unknown Source) [19:29:05 INFO]: at java.nio.file.Files.copy(Unknown Source) [19:29:05 INFO]: at de.theyphania.crucius.util.Lang.read(Lang.java:156) [19:29:05 INFO]: at de.theyphania.crucius.util.Lang.read(Lang.java:139) [19:29:05 INFO]: at de.theyphania.crucius.commands.CruciusCommand.lambda$registerCommand$0(CruciusCommand.java:79) [19:29:05 INFO]: at dev.jorel.commandapi.executors.IExecutorNormal.executeWith(IExecutorNormal.java:27) [19:29:05 INFO]: at dev.jorel.commandapi.CustomCommandExecutor.executeNormalExecutor(CustomCommandExecutor.java:82) [19:29:05 INFO]: at dev.jorel.commandapi.CustomCommandExecutor.execute(CustomCommandExecutor.java:60) [19:29:05 INFO]: at dev.jorel.commandapi.CommandAPIHandler.lambda$generateCommand$3(CommandAPIHandler.java:336) [19:29:05 INFO]: at com.mojang.brigadier.CommandDispatcher.execute(CommandDispatcher.java:262) [19:29:05 INFO]: at com.mojang.brigadier.CommandDispatcher.execute(CommandDispatcher.java:176) [19:29:05 INFO]: at net.minecraft.server.v1_15_R1.CommandDispatcher.a(CommandDispatcher.java:179) [19:29:05 INFO]: at org.bukkit.craftbukkit.v1_15_R1.command.VanillaCommandWrapper.execute(VanillaCommandWrapper.java:45) [19:29:05 INFO]: at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:149) [19:29:05 INFO]: at org.bukkit.craftbukkit.v1_15_R1.CraftServer.dispatchCommand(CraftServer.java:723) [19:29:05 INFO]: at net.minecraft.server.v1_15_R1.PlayerConnection.handleCommand(PlayerConnection.java:1658) [19:29:05 INFO]: at net.minecraft.server.v1_15_R1.PlayerConnection.a(PlayerConnection.java:1498) [19:29:05 INFO]: at net.minecraft.server.v1_15_R1.PacketPlayInChat.a(PacketPlayInChat.java:47) [19:29:05 INFO]: at net.minecraft.server.v1_15_R1.PacketPlayInChat.a(PacketPlayInChat.java:1) [19:29:05 INFO]: at net.minecraft.server.v1_15_R1.PlayerConnectionUtils.lambda$0(PlayerConnectionUtils.java:19) [19:29:05 INFO]: at net.minecraft.server.v1_15_R1.TickTask.run(SourceFile:18) [19:29:05 INFO]: at net.minecraft.server.v1_15_R1.IAsyncTaskHandler.executeTask(SourceFile:144) [19:29:05 INFO]: at net.minecraft.server.v1_15_R1.IAsyncTaskHandlerReentrant.executeTask(SourceFile:23) [19:29:05 INFO]: at net.minecraft.server.v1_15_R1.IAsyncTaskHandler.executeNext(SourceFile:118) [19:29:05 INFO]: at net.minecraft.server.v1_15_R1.MinecraftServer.ba(MinecraftServer.java:918) [19:29:05 INFO]: at net.minecraft.server.v1_15_R1.MinecraftServer.executeNext(MinecraftServer.java:911) [19:29:05 INFO]: at net.minecraft.server.v1_15_R1.IAsyncTaskHandler.executeAll(SourceFile:103) [19:29:05 INFO]: at net.minecraft.server.v1_15_R1.MinecraftServer.sleepForTick(MinecraftServer.java:894) [19:29:05 INFO]: at net.minecraft.server.v1_15_R1.MinecraftServer.run(MinecraftServer.java:828) [19:29:05 INFO]: at java.lang.Thread.run(Unknown Source) ```

So far, I've not been able to replicate the bug potentially related to permissions. The CommandAPI's handling of exceptions is indeed not amazing (exceptions are typically caught really early on and are handled in such a way that they're not outputted into the console), however I don't see anything that would indicate a permission-related issue.


I mentioned I'm running version 3.1 - this shouldn't be a cause of the issue because v3.1 and v3.0 are perfectly compatible with each other (v3.1 literally just adds 1 new argument (which you're not using) and adds more support for overriding suggestions (which you're also not doing)).

Loapu commented 4 years ago
Alright, I've got this output ```bash Loading libraries, please wait... [20:19:22] [Server thread/INFO]: Starting minecraft server version 1.15.2 [20:19:22] [Server thread/INFO]: Loading properties > [20:19:23] [Server thread/INFO]: This server is running CraftBukkit version git-Spigot-a99063f-8ea9b13 (MC: 1.15.2) (Implementing API version 1.15.2-R0.1-SNAPSHOT) > [20:19:23] [Server thread/INFO]: Server Ping Player Sample Count: 12 > [20:19:23] [Server thread/INFO]: Using 4 threads for Netty based IO > [20:19:23] [Server thread/INFO]: Debug logging is disabled > [20:19:23] [Server thread/INFO]: Default game type: SURVIVAL > [20:19:23] [Server thread/INFO]: Generating keypair > [20:19:23] [Server thread/INFO]: Starting Minecraft server on 0.0.0.0:10001 > [20:19:23] [Server thread/INFO]: Using epoll channel type > [20:19:25] [Server thread/WARN]: Initializing Legacy Material Support. Unless you have legacy plugins and/or data this is a bug! > [20:19:32] [Server thread/WARN]: Legacy plugin CommandAPI v3.0 does not specify an api-version. > [20:19:32] [Server thread/INFO]: [CommandAPI] Loading CommandAPI v3.0 > [20:19:32] [Server thread/INFO]: [CommandAPI] Hooked into NMS dev.jorel.commandapi.nms.NMS_1_15 (compatible with 1.15, 1.15.1, 1.15.2) > [20:19:32] [Server thread/WARN]: [CommandAPI] Couldn't hook into the NBTAPI for NBT support. See https://www.spigotmc.org/resources/nbt-api.7939/ > [20:19:32] [Server thread/INFO]: [CommandAPI] Hooked into Spigot successfully for Chat/ChatComponents > [20:19:32] [Server thread/INFO]: [Crucius] Loading Crucius v0.2.0-pre.8 > [20:19:32] [Server thread/INFO]: [CommandAPI] Registering command /crucius > [20:19:32] [Server thread/INFO]: [CommandAPI] Registering alias /cr -> crucius > [20:19:32] [Server thread/INFO]: [CommandAPI] Registering alias /cruc -> crucius > [20:19:32] [Server thread/INFO]: [CommandAPI] Registering command /crucius > [20:19:32] [Server thread/INFO]: [CommandAPI] Registering alias /cr -> crucius > [20:19:32] [Server thread/INFO]: [CommandAPI] Registering alias /cruc -> crucius > [20:19:32] [Server thread/INFO]: Preparing level "world" > [20:19:32] [Server thread/INFO]: Reloading ResourceManager: Default, bukkit > [20:19:33] [Server thread/INFO]: Loaded 6 recipes > [20:19:35] [Server thread/INFO]: -------- World Settings For [world] -------- > [20:19:35] [Server thread/INFO]: Mob Spawn Range: 6 > [20:19:35] [Server thread/INFO]: Experience Merge Radius: 3.0 > [20:19:35] [Server thread/INFO]: Cactus Growth Modifier: 100% > [20:19:35] [Server thread/INFO]: Cane Growth Modifier: 100% > [20:19:35] [Server thread/INFO]: Melon Growth Modifier: 100% > [20:19:35] [Server thread/INFO]: Mushroom Growth Modifier: 100% > [20:19:35] [Server thread/INFO]: Pumpkin Growth Modifier: 100% > [20:19:35] [Server thread/INFO]: Sapling Growth Modifier: 100% > [20:19:35] [Server thread/INFO]: Beetroot Growth Modifier: 100% > [20:19:35] [Server thread/INFO]: Carrot Growth Modifier: 100% > [20:19:35] [Server thread/INFO]: Potato Growth Modifier: 100% > [20:19:35] [Server thread/INFO]: Wheat Growth Modifier: 100% > [20:19:35] [Server thread/INFO]: NetherWart Growth Modifier: 100% > [20:19:35] [Server thread/INFO]: Vine Growth Modifier: 100% > [20:19:35] [Server thread/INFO]: Cocoa Growth Modifier: 100% > [20:19:35] [Server thread/INFO]: Bamboo Growth Modifier: 100% > [20:19:35] [Server thread/INFO]: SweetBerry Growth Modifier: 100% > [20:19:35] [Server thread/INFO]: Kelp Growth Modifier: 100% > [20:19:35] [Server thread/INFO]: Entity Activation Range: An 32 / Mo 32 / Ra 48 / Mi 16 / Tiv true > [20:19:35] [Server thread/INFO]: Entity Tracking Range: Pl 48 / An 48 / Mo 48 / Mi 32 / Other 64 > [20:19:35] [Server thread/INFO]: Hopper Transfer: 8 Hopper Check: 1 Hopper Amount: 1 > [20:19:35] [Server thread/INFO]: Custom Map Seeds: Village: 10387312 Desert: 14357617 Igloo: 14357618 Jungle: 14357619 Swamp: 14357620 Monument: 10387313 Ocean: 14357621 Shipwreck: 165745295 End City: 10387313 Slime: 987234911 > [20:19:35] [Server thread/INFO]: Max TNT Explosions: 100 > [20:19:35] [Server thread/INFO]: Tile Max Tick Time: 50ms Entity max Tick Time: 50ms > [20:19:35] [Server thread/INFO]: View Distance: 10 > [20:19:35] [Server thread/INFO]: Item Merge Radius: 2.5 > [20:19:35] [Server thread/INFO]: Item Despawn Rate: 6000 > [20:19:35] [Server thread/INFO]: Allow Zombie Pigmen to spawn from portal blocks: true > [20:19:35] [Server thread/INFO]: Arrow Despawn Rate: 1200 Trident Respawn Rate:1200 > [20:19:35] [Server thread/INFO]: Zombie Aggressive Towards Villager: true > [20:19:35] [Server thread/INFO]: Nerfing mobs spawned from spawners: false > [20:19:38] [Server thread/INFO]: -------- World Settings For [world_nether] -------- > [20:19:38] [Server thread/INFO]: Mob Spawn Range: 6 > [20:19:38] [Server thread/INFO]: Experience Merge Radius: 3.0 > [20:19:38] [Server thread/INFO]: Cactus Growth Modifier: 100% > [20:19:38] [Server thread/INFO]: Cane Growth Modifier: 100% > [20:19:38] [Server thread/INFO]: Melon Growth Modifier: 100% > [20:19:38] [Server thread/INFO]: Mushroom Growth Modifier: 100% > [20:19:38] [Server thread/INFO]: Pumpkin Growth Modifier: 100% > [20:19:38] [Server thread/INFO]: Sapling Growth Modifier: 100% > [20:19:38] [Server thread/INFO]: Beetroot Growth Modifier: 100% > [20:19:38] [Server thread/INFO]: Carrot Growth Modifier: 100% > [20:19:38] [Server thread/INFO]: Potato Growth Modifier: 100% > [20:19:38] [Server thread/INFO]: Wheat Growth Modifier: 100% > [20:19:38] [Server thread/INFO]: NetherWart Growth Modifier: 100% > [20:19:38] [Server thread/INFO]: Vine Growth Modifier: 100% > [20:19:38] [Server thread/INFO]: Cocoa Growth Modifier: 100% > [20:19:38] [Server thread/INFO]: Bamboo Growth Modifier: 100% > [20:19:38] [Server thread/INFO]: SweetBerry Growth Modifier: 100% > [20:19:38] [Server thread/INFO]: Kelp Growth Modifier: 100% > [20:19:38] [Server thread/INFO]: Entity Activation Range: An 32 / Mo 32 / Ra 48 / Mi 16 / Tiv true > [20:19:38] [Server thread/INFO]: Entity Tracking Range: Pl 48 / An 48 / Mo 48 / Mi 32 / Other 64 > [20:19:38] [Server thread/INFO]: Hopper Transfer: 8 Hopper Check: 1 Hopper Amount: 1 > [20:19:38] [Server thread/INFO]: Custom Map Seeds: Village: 10387312 Desert: 14357617 Igloo: 14357618 Jungle: 14357619 Swamp: 14357620 Monument: 10387313 Ocean: 14357621 Shipwreck: 165745295 End City: 10387313 Slime: 987234911 > [20:19:38] [Server thread/INFO]: Max TNT Explosions: 100 > [20:19:38] [Server thread/INFO]: Tile Max Tick Time: 50ms Entity max Tick Time: 50ms > [20:19:38] [Server thread/INFO]: View Distance: 10 > [20:19:38] [Server thread/INFO]: Item Merge Radius: 2.5 > [20:19:38] [Server thread/INFO]: Item Despawn Rate: 6000 > [20:19:38] [Server thread/INFO]: Allow Zombie Pigmen to spawn from portal blocks: true > [20:19:38] [Server thread/INFO]: Arrow Despawn Rate: 1200 Trident Respawn Rate:1200 > [20:19:38] [Server thread/INFO]: Zombie Aggressive Towards Villager: true > [20:19:38] [Server thread/INFO]: Nerfing mobs spawned from spawners: false > [20:19:38] [Server thread/INFO]: -------- World Settings For [world_the_end] -------- > [20:19:38] [Server thread/INFO]: Mob Spawn Range: 6 > [20:19:38] [Server thread/INFO]: Experience Merge Radius: 3.0 > [20:19:38] [Server thread/INFO]: Cactus Growth Modifier: 100% > [20:19:38] [Server thread/INFO]: Cane Growth Modifier: 100% > [20:19:38] [Server thread/INFO]: Melon Growth Modifier: 100% > [20:19:38] [Server thread/INFO]: Mushroom Growth Modifier: 100% > [20:19:38] [Server thread/INFO]: Pumpkin Growth Modifier: 100% > [20:19:38] [Server thread/INFO]: Sapling Growth Modifier: 100% > [20:19:38] [Server thread/INFO]: Beetroot Growth Modifier: 100% > [20:19:38] [Server thread/INFO]: Carrot Growth Modifier: 100% > [20:19:38] [Server thread/INFO]: Potato Growth Modifier: 100% > [20:19:38] [Server thread/INFO]: Wheat Growth Modifier: 100% > [20:19:38] [Server thread/INFO]: NetherWart Growth Modifier: 100% > [20:19:38] [Server thread/INFO]: Vine Growth Modifier: 100% > [20:19:38] [Server thread/INFO]: Cocoa Growth Modifier: 100% > [20:19:38] [Server thread/INFO]: Bamboo Growth Modifier: 100% > [20:19:38] [Server thread/INFO]: SweetBerry Growth Modifier: 100% > [20:19:38] [Server thread/INFO]: Kelp Growth Modifier: 100% > [20:19:38] [Server thread/INFO]: Entity Activation Range: An 32 / Mo 32 / Ra 48 / Mi 16 / Tiv true > [20:19:38] [Server thread/INFO]: Entity Tracking Range: Pl 48 / An 48 / Mo 48 / Mi 32 / Other 64 > [20:19:38] [Server thread/INFO]: Hopper Transfer: 8 Hopper Check: 1 Hopper Amount: 1 > [20:19:38] [Server thread/INFO]: Custom Map Seeds: Village: 10387312 Desert: 14357617 Igloo: 14357618 Jungle: 14357619 Swamp: 14357620 Monument: 10387313 Ocean: 14357621 Shipwreck: 165745295 End City: 10387313 Slime: 987234911 > [20:19:38] [Server thread/INFO]: Max TNT Explosions: 100 > [20:19:38] [Server thread/INFO]: Tile Max Tick Time: 50ms Entity max Tick Time: 50ms > [20:19:38] [Server thread/INFO]: View Distance: 10 > [20:19:38] [Server thread/INFO]: Item Merge Radius: 2.5 > [20:19:38] [Server thread/INFO]: Item Despawn Rate: 6000 > [20:19:38] [Server thread/INFO]: Allow Zombie Pigmen to spawn from portal blocks: true > [20:19:38] [Server thread/INFO]: Arrow Despawn Rate: 1200 Trident Respawn Rate:1200 > [20:19:38] [Server thread/INFO]: Zombie Aggressive Towards Villager: true > [20:19:38] [Server thread/INFO]: Nerfing mobs spawned from spawners: false > [20:19:38] [Server thread/INFO]: Preparing start region for dimension 'world'/minecraft:overworld > [20:19:39] [Server thread/INFO]: Preparing spawn area: 0% > [20:19:39] [Server thread/INFO]: Preparing spawn area: 0% > [20:19:39] [Server thread/INFO]: Preparing spawn area: 5% > [20:19:42] [Server-Worker-2/INFO]: Preparing spawn area: 83% > [20:19:42] [Server-Worker-5/INFO]: Preparing spawn area: 83% > [20:19:42] [Server-Worker-5/INFO]: Preparing spawn area: 83% > [20:19:42] [Server-Worker-5/INFO]: Preparing spawn area: 83% > [20:19:42] [Server-Worker-6/INFO]: Preparing spawn area: 83% > [20:19:42] [Server-Worker-3/INFO]: Preparing spawn area: 83% > [20:19:43] [Server-Worker-5/INFO]: Preparing spawn area: 91% > [20:19:43] [Server-Worker-7/INFO]: Preparing spawn area: 91% > [20:19:44] [Server-Worker-6/INFO]: Preparing spawn area: 91% > [20:19:44] [Server-Worker-5/INFO]: Preparing spawn area: 94% > [20:19:45] [Server thread/INFO]: Preparing spawn area: 98% > [20:19:45] [Server thread/INFO]: Time elapsed: 6649 ms > [20:19:45] [Server thread/INFO]: Preparing start region for dimension 'world_nether'/minecraft:the_nether > [20:19:46] [Server thread/INFO]: Preparing spawn area: 0% > [20:19:46] [Server thread/INFO]: Preparing spawn area: 0% > [20:19:46] [Server thread/INFO]: Preparing spawn area: 0% > [20:19:46] [Server-Worker-2/INFO]: Preparing spawn area: 83% > [20:19:47] [Server-Worker-3/INFO]: Preparing spawn area: 83% > [20:19:47] [Server-Worker-3/INFO]: Preparing spawn area: 83% > [20:19:48] [Server-Worker-6/INFO]: Preparing spawn area: 90% > [20:19:48] [Server thread/INFO]: Time elapsed: 3378 ms > [20:19:48] [Server thread/INFO]: Preparing start region for dimension 'world_the_end'/minecraft:the_end > [20:19:49] [Server thread/INFO]: Preparing spawn area: 0% > [20:19:49] [Server-Worker-5/INFO]: Preparing spawn area: 83% > [20:19:49] [Server thread/INFO]: Time elapsed: 1001 ms > [20:19:49] [Server thread/INFO]: [CommandAPI] Enabling CommandAPI v3.0 > [20:19:49] [Server thread/INFO]: [Crucius] Enabling Crucius v0.2.0-pre.8 > [20:19:49] [Server thread/INFO]: [Crucius] \\\\\\\\\\\\\\ STARTING PLUGIN ////////////// > [20:19:49] [Server thread/INFO]: [Crucius][STARTED] Loading resources... > [20:19:49] [Server thread/INFO]: [Crucius][STEP 1/3] Loading plugin directories... > [20:19:49] [Server thread/INFO]: [Crucius][STEP 1/3] Crucius directory does not exist and is therefore created. > [20:19:49] [Server thread/INFO]: [Crucius][STEP 1/3] Languages directory does not exist and is therefore created. > [20:19:49] [Server thread/INFO]: [Crucius][STEP 1/3] Settings directory does not exist and is therefore created. > [20:19:49] [Server thread/INFO]: [Crucius][STEP 1/3] Modules directory does not exist and is therefore created. > [20:19:49] [Server thread/INFO]: [Crucius][STEP 1/3] Third Party directory does not exist and is therefore created. > [20:19:49] [Server thread/INFO]: [Crucius][STEP 1/3] All directories loaded successfully. > [20:19:49] [Server thread/INFO]: [Crucius][STEP 2/3] Loading plugin settings... > [20:19:49] [Server thread/INFO]: [Crucius][DEBUG] DEBUG mode is activated. Please be aware of unintended behaviour. Use '/crucius settings debug' to disable it. > [20:19:49] [Server thread/INFO]: [Crucius][STEP 2/3] Successfully loaded 3 settings on version (0.2.0). > [20:19:49] [Server thread/INFO]: [Crucius][STEP 3/3] Loading plugin languages... > [20:19:49] [Server thread/INFO]: [Crucius][DEBUG] .de. > [20:19:49] [Server thread/INFO]: [Crucius][DEBUG] .en. > [20:19:49] [Server thread/INFO]: [Crucius][DEBUG] ////////////// {0} \\\\\\\\\\\\\\ true > [20:19:49] [Server thread/INFO]: [Crucius][DEBUG] ////////////// {0} \\\\\\\\\\\\\\ false > [20:19:49] [Server thread/INFO]: [Crucius][DEBUG] ////////////// {0} \\\\\\\\\\\\\\ true > [20:19:49] [Server thread/INFO]: [Crucius][DEBUG] ////////////// {0} \\\\\\\\\\\\\\ false > [20:19:49] [Server thread/INFO]: [Crucius][DEBUG] ////////////// {0} \\\\\\\\\\\\\\ false > [20:19:49] [Server thread/INFO]: [Crucius][DEBUG] ////////////// {0} \\\\\\\\\\\\\\ false > [20:19:49] [Server thread/INFO]: [Crucius][DEBUG] ////////////// {0} \\\\\\\\\\\\\\ false > [20:19:49] [Server thread/INFO]: [Crucius][STEP 3/3] There are 2 loaded languages: > [20:19:49] [Server thread/INFO]: [Crucius][STEP 3/3] Deutsch (v0.0.6), English (v0.0.6) > [20:19:49] [Server thread/INFO]: [Crucius][FINISHED] All resources loaded successfully. > [20:19:49] [Server thread/INFO]: [Crucius] Registering listener JoinListener (PlayerJoinEvent) > [20:19:49] [Server thread/INFO]: [Crucius] \\\\\\\\\\\\\\ START FINISHED (Time: 38ms) ////////////// > [20:19:49] [Server thread/INFO]: Server permissions file permissions.yml is empty, ignoring it > [20:19:49] [Server thread/INFO]: Done (17.266s)! For help, type "help" > [20:19:49] [Server thread/INFO]: [CommandAPI] Linking permissions to commands: > [20:19:49] [Server thread/INFO]: [CommandAPI] crucius.basecommand -> /cr > [20:19:49] [Server thread/INFO]: [CommandAPI] crucius.basecommand -> /cruc > [20:19:49] [Server thread/INFO]: [CommandAPI] crucius.basecommand -> /crucius > [20:20:09] [User Authenticator #1/INFO]: UUID of player Loapu is eba0f6bf-06ec-4f42-8677-fb2a4c9aa80e > [20:20:10] [Server thread/INFO]: Loapu[/93.207.242.160:9289] logged in with entity id 190 at ([world]-164.65690473476062, 70.0, 37.08016837299017) > [20:20:14] [Server thread/INFO]: [Crucius][DEBUG] ////////////// {0} \\\\\\\\\\\\\\ false > [20:20:20] [Server thread/INFO]: Loapu issued server command: /crucius > [20:25:38] [Server thread/INFO]: Loapu lost connection: Disconnected > [20:25:38] [Server thread/INFO]: Loapu left the game ```

If we try to backtrace a bit we have this line new LiteralMessage("You must be a " + type.getSimpleName().toLowerCase() + " to run this command") inside 1.13-Command-API/1.13CommandAPI/commandapi-core/src/main/java/dev/jorel/commandapi/executors/IExecutorNormal.java.

Could you please take a look at my de.theyphania.crucius.commands.CruciusCommand.java file inside the Sources folder of the plugin jar?

The above mentioned type.getSimpleName().toLowerCase() seems to give out this class name.

Regarding your error, delete the Crucius folder inside your plugin folder. The plugin has to generate the new settings file.

JorelAli commented 4 years ago

Alright, no matter what I do, I can't get your plugin to run without it erroring. Nonetheless, I took a look at IExecutorNormal and have a feeling that it may be retrieving the wrong method to execute a command (although highly unlikely).

I modified the executor interfaces, so hopefully this version works?: CommandAPIv3.1_30_Jun2020(08-39-16PM).zip

Loapu commented 4 years ago

It works as intended. What was the problem?

JorelAli commented 4 years ago

It works as intended. What was the problem?

I'm so glad that works! Thanks so much for your cooperation. Basically, in the CommandAPI, there are multiple different executor types (e.g. .executesPlayer(), .executes(), .executesEntity() etc.). To ensure that the actual sender matches the programmed sender, it uses a sneaky bit of reflection to find the right command sender.

For example, if I registered a command as follows:

new CommandAPICommand("mycommand")
.executesPlayer((player, args) -> { ... })
.register()

Internally, it uses the PlayerCommandExecutor, which has a method void run(Player sender, Object[] args) throws WrapperCommandSyntaxException;. The reflection finds the first method and retrieves its parameter (in this case, Player), thus knowing that the sender must be a player. When you run the command, it checks if you match Player and if so, it runs the command as expected.

However, the bug was it wasn't finding the void run(T sender, Object[] args) method (where T is some CommandSender) and was instead finding something else. I have no idea how it ended up finding something else, but I fixed it in this commit: 749ef9c6b57faf27095302d4a6c8dd183a070317


Once again, thanks so much! This was a very stressful bug to sort out since I couldn't replicate it on my local machine. By pointing this out:

If we try to backtrace a bit we have this line new LiteralMessage("You must be a " + type.getSimpleName().toLowerCase() + " to run this command") inside 1.13-Command-API/1.13CommandAPI/commandapi-core/src/main/java/dev/jorel/commandapi/executors/IExecutorNormal.java. The above mentioned type.getSimpleName().toLowerCase() seems to give out this class name.

You led me straight to the solution. I'll make sure to add you to the acknowledgements section in the documentation!

Loapu commented 4 years ago

I am just glad I could help you ^^ I find your work amazing and hope to see this much more used by future plugins.

marcingold commented 4 years ago

Hi 👋 I'm getting the same error now with the maven dependency 3.0 and Spigot 1.16.1 I saw the bug is already fixed but the only fixed Version is the provided jar file in your answer (btw. with this jar it works as expected) Ist it possible to publish this fix also in the mvn-repo branch? Since i use it as maven dependency, its kinda ugly to add a custom jar file (wich doesn't even have a build version) to the existing build pipeline in my project 😁

Would be nice if u can update it :)

Greetings Marc

EDIT: I added the source, just in case it helps in any way :P

LinkedHashMap<String, Argument> magicArguments = new LinkedHashMap<>();
new CommandAPICommand("magic")
    .withArguments(magicArguments)
    .withPermission(CommandPermission.OP)
    .executes((sender, args) -> {
        sender.sendMessage(Chat.color("Magic is running version v" + this.getDescription().getVersion(), ChatColor.GREEN));
     }).register();
JorelAli commented 4 years ago

Hi, I am in the process of releasing version 3.1 which fixes this. I hope to release it within the next 24 hours