java - Bukkit Plugin: Can't import command -
i started working on bukkit plugin other day aim return hello in text window when user types in '/hello'. not working, because cannot import command line in eclipse. suggestions? says, "command cannot resolved type"
package me.nickedyerpants; import org.bukkit.command.commandsender; import org.bukkit.plugin.java.javaplugin; public class plugin extends javaplugin{ @override public void onenable(){ //what happens when plugin enabled getlogger().info("first plugin starting up...."); } @override public void ondisable(){ //for when plugin disabled boolean oncommand(commandsender sender, command cmd, string label, string[] args){ if (cmd.getname().equalsignorecase("hello") && sender instanceof player){ player player = (player) sender; player.sendmessage("hello"); } return true; } } }
so code literally bad, you're implementing oncommand
inside ondisable
method, wrong, , class ins't closed properly!
replace whole code this:
package me.nickedyerpants; import org.bukkit.command.command; import org.bukkit.command.commandsender; import org.bukkit.entity.player; import org.bukkit.plugin.java.javaplugin; public class plugin extends javaplugin { @override public void onenable() { //what happens when plugin enabled getlogger().info("first plugin starting up...."); } @override public void ondisable() { //for when plugin disabled } public boolean oncommand(commandsender sender, command cmd, string label, string[] args) { if (cmd.getname().equalsignorecase("hello") && sender instanceof player) { player player = (player) sender; player.sendmessage("hello"); } return true; } }
place methods within class , don't place them inside of method.
Comments
Post a Comment