java - Command in my bukkitplugin not working -
now have changed 'commands' 'commands' in plugin.yml error in cmd when run server. error says '.jar file not contain plugin.yml'.
this plugin.yml of now:
name: wand version: 1.0 main: me.pixel.main commands: wand:
and main file currently:
package me.pixel; import java.util.arraylist; import java.util.list; import org.bukkit.chatcolor; import org.bukkit.effect; import org.bukkit.material; import org.bukkit.command.command; import org.bukkit.command.commandsender; import org.bukkit.entity.player; import org.bukkit.event.eventhandler; import org.bukkit.event.listener; import org.bukkit.event.block.action; import org.bukkit.event.player.playerinteractevent; import org.bukkit.inventory.itemstack; import org.bukkit.inventory.meta.itemmeta; import org.bukkit.plugin.java.javaplugin; public class main extends javaplugin implements listener { public main plugin; public list<string> spells = new arraylist<string>(); public gettargets gettargets = new gettargets(); public spark spark = new spark(this); public poisonwave poisonwave = new poisonwave(this); public darkspark darkspark = new darkspark(this); @override public void onenable() { plugin = this; getserver().getpluginmanager().registerevents(this, this); spells.add("spark"); spells.add("poisonwave"); spells.add("darkspark"); } @override public boolean oncommand(commandsender sender, command command, string label, string[] args) { if(label.equalsignorecase("wand")) { if(!(sender instanceof player)) { sender.sendmessage(chatcolor.red + "you need in-game player perform action!"); } else { player p = (player) sender; if(sender.haspermission("wand.wand")) { itemstack stack = new itemstack(material.blaze_rod); itemmeta stackmeta = stack.getitemmeta(); stackmeta.setdisplayname(chatcolor.red + "empire wand"); stack.setitemmeta(stackmeta); p.getinventory().additem(stack); chatutilities.sendmessage(p, "you have got powerful empire wand!"); } else { chatutilities.sendmessage(p, chatcolor.red + "error: no permission!"); } } } return false; } @eventhandler public void onclick(playerinteractevent e) { if((e.getaction() == action.right_click_air) || e.getaction() == action.right_click_block) { player p = e.getplayer(); itemstack stack = p.getiteminhand(); if(stack != null && stack.gettype() == material.blaze_rod && stack.hasitemmeta() && stack.getitemmeta().getdisplayname().equals(chatcolor.red + "empire wand")) { int spellselected = stack.getdurability(); if(spellselected < 2) { stack.setdurability((short) (spellselected + 1)); p.getworld().playeffect(p.getlocation(), effect.step_sound, 119, 30); } else { stack.setdurability((short) 0); } chatutilities.sendmessage(p, "selected: " + spells.get(spellselected)); } } if(e.getaction() == action.left_click_air || e.getaction() == action.left_click_block) { player p = e.getplayer(); itemstack stack = p.getiteminhand(); if(stack != null && stack.gettype() == material.blaze_rod && stack.hasitemmeta() && stack.getitemmeta().getdisplayname().equals(chatcolor.red + "empire wand")) { int spellselected = stack.getdurability(); if(spellselected == 1) { this.spark.oncast(p); } else if (spellselected == 0) { this.poisonwave.oncast(p); } } } } }
the plugin.yml
file case senstitive, name of list of commands needs lowercase (commands
instead of commands
). since have capitalized, bukkit/spigot doesn't register commands resulting in "unknown command. type "/help" help.
" message if test /wand
command (i'm assuming error you're getting, didn't describe problem nor expected behavior, happened when tested code, , correcting name of commands list made command execute).
Comments
Post a Comment