PlayerInteractEvent [HELP PLS!] lol

Discussion in 'Plugin Development' started by Jeff.Halbert, Apr 28, 2012.

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

    Jeff.Halbert

    So I'm making a chunk protection system where a player can simply place a fence somewhere and that chunk becomes theirs. No one else can build on that chunk besides the owner. This portion works. I also want to give player the option to add people to their protected chunks, but all without the use of commands. (I'm working towards a command-free vanilla server experience). My idea was this: If a player is standing on one of his protected chunks, he/she could simple rightclick another player with a specified item (i was going for glowstone dust), and they would be added to ownership of the chunk, and could build there aswell. But this is where i'm having issues. The questions I have are:

    1) How do I get the name of the player that was rightclicked?
    2) How do I get the chunk x and z for the chunk they are standing on?
    3) How do I check to make sure that the item in hand was glowstone dust?

    This is what I have so far... it's not much, and If there is a better method than what I'm trying, I am more than happy to take that route. :-D

    [​IMG]
     
  2. Offline

    ZeusAllMighty11

    I'd suggest taking the source code of PreciousStones -- seems like you'd work well with that helping you on errors and what-not.


    As for the third question you asked, here's the code I came up with:
    Code:
    }
    {
    if (itemInHand == MATERIAL.GLOWSTONE_DUST);
    // Do stuff
    } 
    
    As for the first question, I think this will work out...
    Code:
    {
    player p = event.getPlayer().getName();
    getChunkAt(Location);
    }
     
  3. Offline

    Jeff.Halbert

    At first it was a little confusing. But I took your advice and checked out the source from PreciousStones. After a while I decided to just use EntityDamageByEntityEvent instead. Thanks for the help :-D

    [​IMG]
     
Thread Status:
Not open for further replies.

Share This Page