1

I need some plugin coding help D:

TeamCraft-Robbie's Avatar TeamCraft-Robbie5/4/14 8:11 pm
1 emeralds 147 4
5/5/2014 8:13 pm
Otisdiver's Avatar Otisdiver
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's Avatar
TeamCraft-Robbie
Level 5 : Apprentice Miner
0

Create an account or sign in to comment.

4

1
05/05/2014 8:13 pm
Level 16 : Journeyman Dragon
Otisdiver
Otisdiver's Avatar
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
05/05/2014 7:31 pm
Level 7 : Apprentice Explorer
iMurder
iMurder's Avatar
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
05/05/2014 9:16 am
Level 18 : Journeyman Miner
NovaGamingBrian
NovaGamingBrian's Avatar
You should just make an itemstack and go to bukkit forums for these things
1
05/04/2014 8:13 pm
Level 5 : Apprentice Miner
TeamCraft-Robbie
TeamCraft-Robbie's Avatar
P.S the code is correct as in format and everything that i would generally need is there!
Also, there are no errors.
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome