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?
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.
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.
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.
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?
It seems someone already has, though no progress yet. See: http://leaky.bukkit.org/issues/367 Edit: Vote for it, btw!
I just finished implementing this and submitted a pull request. I have a SIGN_MODIFIED event working in my local CraftBukkit. We'll see if the Bukkit devs like my code though.
@Mhalkyer Not exactly. SIGN_CHANGE is thrown right after the sign is placed; specifically, when the user finishes entering their text for the sign.