#/Heal command fails on startup with nullpointer

1 messages · Page 1 of 1 (latest)

median blaze
#

Error message states:

java.lang.NullPointerException: Cannot invoke "org.bukkit.command.PluginCommand.setExecutor(org.bukkit.command.CommandExecutor)" because the return value of "me.mackaroni.testplugin.TestPlugin.getCommand(String)" is null

for reference this is my onEnable:

public void onEnable() {
  // Plugin startup logic
  Bukkit.getConsoleSender().sendMessage("[TEST PLUGIN]This Plugin Works!");
  Bukkit.getPluginManager().registerEvents(new JoinMessage(), this);

   // THIS SPECIFIC LINE IS THE ISSUE
  this.getCommand("Doctor").setExecutor(new Heal());
}

and my plugin.yml contains

commands:
  Doctor:
#

if needed ig i can upload my full code

#

my Heal() class should return true/false regardless of input

tardy cave
#

give full code

median blaze
#

quick question

#

is this the proper yml placement?

#

cus looking through documentation the null exception happens when the Doctor command cant be found in the yml file but i have it in there

spice bloom
#

you forgot to put your command in your plugins.yml

#

well paper-plugin.yml

median blaze
#
name: TestPlugin
version: 1.0.1
main: me.mackaroni.testplugin.TestPlugin
api-version: '1.20'

commands:
  Doctor:
    description: "Heals player to full"
    usage: "/heal"
#

unless im missing something

#

it is

spice bloom
median blaze
#

yeahh

spice bloom
#

not sure what's wrong, what if you create a normal plugin.yml alongside paper's and put the command there?

median blaze
#

ill try that

#
processResources {
    def props = [version: version]
    inputs.properties props
    filteringCharset 'UTF-8'
    filesMatching('paper-plugin.yml') {
        expand props
    }
}
#

cus this is what my gradle.build refernces

#

idk if that means anything

#

nope

#

made a plugin.yml, copied the code, still an error

spice bloom
#

that's used to replace your plugin's version automatically inside your resources files

spice bloom
#

try maybe with lowercase D

median blaze
#

nope

#

set doctor to lowercase in the getcommand and the plugin.yml

spice bloom
#

I'm not sure what's wrong