1

I need some plugin coding help D:

TeamCraft-Robbie 5/4/14 8:11 pm
170
5/5/2014 8:13 pm
Hey guys, i am attempting to make a plugin and im getting an error.
First here is my code:
@EventHandler
public void toggle(PlayerInteractEvent event){
Player player = event.getPlayer();

if(player.getInventory().getItemInhand().getItemMeta().getDisplayName() == "MobWand"){
if(event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK){
Player p = event.getPlayer();
Snowball snowball = p.getWorld().spawn(p.getEyeLocation(), Snowball.class);
snowball.setVelocity(p.getLocation().getDirection().multiply(1.5));
snowball.setShooter(p);
This code is suppose to allow a player to shoot a snowball if they interact with an item called "mobwand" in there inventory.

Everything works untill you move the item (mobwand) elseware in the inventory.
For example, i type a command to recieve the item and it works if i click it when it is in the slot that it apears in but the second i move it over a few slots it will stop shooting snowballs!


I understand this is random and specific but if there is anyone out there that can help a noob out i would greatly appreciate it! Thanks in advance!
Posted by
TeamCraft-Robbie
Level 5 : Apprentice Miner
0

  Have something to say?

JoinSign in

4

Otisdiver
05/05/2014 8:13 pm
Level 16 : Journeyman Dragon
NovaGamingBrianYou should just make an itemstack

Like Brian said, I'd try this.

The other problem might be that it doesn't re-check for the item. Maybe try having it say, on the action (clicks a block), check if they're holding an item with (name)
1
iMurder
05/05/2014 7:31 pm
Level 7 : Apprentice Explorer
Please use the code formatting option when posting, as it makes your code a LOT easier to read, compared to just copying it into the post.
1
NovaGamingBrian
05/05/2014 9:16 am
Level 18 : Journeyman Miner
You should just make an itemstack and go to bukkit forums for these things
1
TeamCraft-Robbie
05/04/2014 8:13 pm
Level 5 : Apprentice Miner
P.S the code is correct as in format and everything that i would generally need is there!
Also, there are no errors.
1

Welcome