I'm recently I started making Minecraft plugins but I occurred some errors such as in this link https://paste.ubuntu.com/p/yHs2pQWf8t/
Main
package org.devoflua.hello;
import org.bukkit.plugin.java.JavaPlugin;
import org.devoflua.hello.commands.HelloCommand;
public class Main extends JavaPlugin {
@Override
public void onEnable() {
System.out.print("Okie");
new HelloCommand(this);
}
}
Command
package org.devoflua.hello.commands;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.devoflua.hello.Main;
public class HelloCommand implements CommandExecutor {
@SuppressWarnings("unused")
private Main plugin;
public HelloCommand(Main plugin) {
this.plugin = plugin;
plugin.getCommand("hello").setExecutor(this);
}
@Override
public boolean onCommand(CommandSender Sender, Command Command, String label, String[] arg) {
if (!(Sender instanceof Player)) {
Sender.sendMessage("Only senders can use this command");
return true;
}
Player p = (Player) Sender;
if (p.hasPermission("hello.use")) {
p.sendMessage("hi");
return true;
} else {
p.sendMessage("You do not have permission to send this message");
}
return false;
}
}
The error comes from the command class from line 16 I believe. I searched on the internet but I found nothing taht could help me fix this problem.
plugin
andplugin.getCommand("hello")
.plugin.yml
that error can occur and also I would not let the class set itself asexecutor
to the commandhello
. So you should do that in the main class.