Signs

Discussion in 'Plugin Development' started by Stefan, Feb 2, 2011.

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

    Stefan

    Hello,

    I'm trying to log when a player places a sign, besides that I want to get the text the player puts on it.
    However I am not receiving a blockplaced event, and I cannot find an event related to signs.

    Is there any event I could use todo this? or is there no support for it in bukkit at the moment?
     
  2. Offline

    eisental

    I think signs don't trigger blockplaced event at the moment.
     
  3. Offline

    darknesschaos

    you can get if they used an item and if it turned into a block. but getting the text was beyond what I could do unless the player hit it afterwards.
     
  4. Offline

    Archelaus

    If I'm right, the event actually fires before the text is written.
    Signs trigger the itemused event, as they're items that get used.
     
  5. Offline

    eisental

    Shouldn't they also trigger the BlockPlaced event? Is this the way it's going to work?
     
  6. Offline

    darknesschaos

    @RightLegRed is correct, it fires before the text is set.
     
  7. Offline

    lucky456

    If you can use one of the even to get player's current location.
    And then +1 and -1 to x and z coordinator to locate 4 blocks that around player.
    after that, use the if statement to find out which block contain .getType() = "Material.SIGN" to locate the sign in front of you. Thus, you can use .getState() and cast it into a sign to finally get string text on sign.
     
  8. Offline

    Acru

    I just ran into this problem as well while writing a new plugin.

    I think they should trigger a blockplaced as well. If there are already a number of signs near the player, I don't see any way to tell which is the new sign, and iterating though the blocks around the player to find it is inefficient...

    I notice at the same time that doors don't generate a blockplaced message either.

    Is there another way to get notified of block changes that I am not aware of, for such special types of blocks?
    --- merged: Feb 10, 2011 5:57 AM ---
    Perhaps I am wrong here. It may be useful for some but;

    I had a bit of a rethink about the issue, and I noticed in the CraftBukkit source that signs are initially created blank, and later have the text set by the player. Also, the text is only ever set once per sign. (by players)

    What I really need is an event for when the player sets the text of the sign, and be able to check the sign and modify the text at that point. (When a player initially sets only, not when plugins set.)

    As far as I read it, this occurs in CraftBukkit's NetServerHandler.java at:
    public void a(Packet130UpdateSign packet130updatesign)

    Can I request that a new event be created here, passing along with the event the text of the packet (or sign before the update is committed) and allowing it to be modified before the sign is updated?
     
  9. Offline

    Archelaus


    http://leaky.bukkit.org/

    Request the new event there.
     
  10. Offline

    Acru

  11. Offline

    Timberjaw

    I just finished implementing this and submitted a pull request. I have a SIGN_MODIFIED event working in my local CraftBukkit. [​IMG]

    We'll see if the Bukkit devs like my code though. [​IMG]
     
  12. Offline

    Acru

  13. Offline

    Timberjaw

    SIGN_CHANGE has been pulled. CraftBukkit build 311.
     
  14. Offline

    Mhalkyer

    Is 'SIGN_CHANGE' thrown when a sign is placed? I feel like the javadoc on it is a little vague...
     
  15. Offline

    Timberjaw

    @Mhalkyer Not exactly. SIGN_CHANGE is thrown right after the sign is placed; specifically, when the user finishes entering their text for the sign.
     
  16. Offline

    Mhalkyer

    @Timberjaw ok, thanks for the clarification!
     
Thread Status:
Not open for further replies.

Share This Page