Hi, I'm trying to fix a problem with my Parkour plugin where sign text is sometimes not updated properly by my plugin after making a sign. I've noticed that when this happens the SignChangeEvent is actually being thrown twice when the sign is created (usually only once), and print_r shows the $event properties to be as expected and the same for both calls. I've tried a flag to intercept the second call and ignore it while the first is already dealing with changing the signtext, but it seems that isn't the problem. Any ideas? I'm waiting for the plugin to be accepted, i github as soon as it is... the code boils down to hooking into SignChangeEvent, get the text using $event->getLine(1) etc, check if the player has perms to make parkour... then $event->setLine(1, TextFormat::GREEN . $data[1]) etc to rewrite the sign in color. Sometimes I can even see a flicker of color with the correct sign text before it reverts to black and the new colours and the new text are lost. As I said, everything else in the code before and after writing the sign is executed fine, but twice. Thanks for any ideas you might have on this - I'm leaning towards a Pocketmine sign glitch related to (or identical to?) that which resets sign text to blank or ignores colours which also seemingly happens at random. PocketMine-MP version 1.6dev-24 "[REDACTED]" (API 2.0.0) No other plugins
I thought you were not supposed to use Monitor if you change anything or cancel the event? Should I set to HIGH?
Test it I usually set it to low. I want other plugins to be able to cancel the event before my plugin does anything.
I'm reading up about using @priority, I'm new to PHP and plugin development so learning on the job! Thank a lot, that seems promising although I suppose it also might mean a conflict with EssentialsTP since that's the only other plugin I've installed to test parkour... UPDATE: I've got this at the start of the file class Main extends PluginBase implements Listener { /** * @param SignChangeEvent $event * @priority MONITOR * @ignoreCancelled false */ not sure if that's correct, but with every setting from HIGH to MONITOR, and no other plugins at all I'm still seeing this behaviour :-(
Updating the signs by getting the tile directly (instead of using the event) and setting the text in a scheduleDelayedTask 20 ticks later works nearly perfectly, but it seems like a hack to me :-/