Player Interaction Help

Discussion in 'Plugin Development' started by SpectrumCrafter, Nov 16, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    SpectrumCrafter

    OK, so I have been trying to do something like, when my stick (Custom Item stack that IS already made) right clicks an Iron Door to teleport someone into another world at a specific place. Also, how to I make the itemstack have its on own name? (Like renaming it on an anvil)

    Question:

    (1 <SOLVED>

    Im trying to make an even handler where when the player right clicks an iron door with my custom ItemStack then something will happen. But I keep getting an error on line where its public void -->onPlayerInteraction<-- that keeps coming up wrong
    help!

    Code (open)
    package test;

    import java.util.logging.Logger;

    import org.bukkit.Material;
    import org.bukkit.block.Block;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.event.block.Action;
    import org.bukkit.event.player.PlayerInteractEvent;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.inventory.PlayerInventory;
    import org.bukkit.plugin.PluginDescriptionFile;
    import org.bukkit.plugin.java.JavaPlugin;


    public class test extends JavaPlugin{

    public final Logger logger = Logger.getLogger("Minecraft");
    public static test plugin;


    @Override
    public void onDisable(){
    PluginDescriptionFile pdfFile = this.getDescription();
    this.logger.info("[" + pdfFile.getName() + "]" + " Version: " + pdfFile.getVersion() + " Has been Disabled!");
    }


    @Override
    public void onEnable(){

    PluginDescriptionFile pdfFile = this.getDescription();
    this.logger.info("[" + pdfFile.getName() + "]" + " Version: " + pdfFile.getVersion() + " Has been Enabled!");
    this.logger.info("Remember to check for updates at http://dev.bukkit.org/bukkit-plugins/punishwarnand/pages/main/");
    getConfig().options().copyDefaults(true);
    saveConfig();

    }

    public boolean onCommand(CommandSender sender, Command cmd, String commandLabel,
    String[] args) {
    Player p = (Player) sender;
    PlayerInventory inv = p.getInventory();

    ItemStack is = new ItemStack(Material.STICK);

    if(commandLabel.equalsIgnoreCase("test"))
    {
    inv.addItem(is);
    }
    @EventHandler
    public void onPlayerInteract(PlayerInteractEvent e){
    if (e.getAction().equals(Action.RIGHT_CLICK_BLOCK))
    {
    Block block = e.getClickedBlock();
    Player pl = e.getPlayer();
    if (block.getType().equals(Material.STONE_BUTTON))
    {
    //Code Here
    }
    }
    }


    return false;
    }
    }


    (2

    How do I (when the stick is right clicked on the door) make the player teleport to what world and exact coordinates I want them to?

    (3

    So lets say when you click the iron door, I want to give you another stick fro my custom ItemStack. How do I make that ItemStack have its own custome stick name?
     
  2. Offline

    iFamasssxD

    You cannot create another method inside a method. Call it outside of the onCommand.
     
  3. Offline

    SpectrumCrafter

    :eek: HOW did I miss that!?!??!?!??! Hahahah im an idiot, oh well. Thank you for answering my first question
     
Thread Status:
Not open for further replies.

Share This Page