Essentials icon indicating copy to clipboard operation
Essentials copied to clipboard

Fire SignChangeEvent on /editsign

Open RodneyMKay opened this issue 3 years ago • 2 comments

Information

This lets the /editsign command fire a SignChangeEvent when it's being executed, based on a new config option. It also contains a new translation key for when a plugin cancels the event.

Details

Proposed feature:
Currently essentials doesn't allow the /editsign command to interface with functional signs of other plugins like Craftbook, because they use the SignChangeEvent for recognizing when a sign is created. This adds a config option to let essentials fire this event and make other plugins aware of the change on the sign.

Environments tested:

OS: Windows Java version: OpenJdk 17

  • [x] Most recent Paper version (1.18.1, git-Paper-216)
  • [x] CraftBukkit/Spigot 1.12.2
  • [x] CraftBukkit 1.8.8

Demonstration:
Test setup I wrote a small plugin that has a 50% probability of cancelling the SignChangeEvent and that prints the lines that the event is trying to write in chat.

Tests With the config option set to true and the event being let through: 2022-03-01_19 28 55

With the config option set to true and the event being cancelled ("cancelling event" message is from the test plugin): 2022-03-01_19 29 19

With the config option set to false: 2022-03-01_19 31 45

(sorry that the essentials locale is set to german in the test setup)

RodneyMKay avatar Mar 01 '22 18:03 RodneyMKay

Right 🤦 I did see that Paper has backward compatible versions of the constructor and a method to query the components in string form. The reason I implemented it the way I did is that I was concerned with what would happen when someone for example added a click event to one of the lines when the sign is created, using the paper api. Since that wouldn't be convertible to a string, the event would get lost when we apply the component from the event to the sign using the string methods.

If the above is not a big concern, I'll gladly change it in the way you suggested :)

RodneyMKay avatar Mar 24 '22 21:03 RodneyMKay

Right 🤦 I did see that Paper has backward compatible versions of the constructor and a method to query the components in string form. The reason I implemented it the way I did is that I was concerned with what would happen when someone for example added a click event to one of the lines when the sign is created, using the paper api. Since that wouldn't be convertible to a string, the event would get lost when we apply the component from the event to the sign using the string methods.

If the above is not a big concern, I'll gladly change it in the way you suggested :)

The sign block is passed to the event so the click event would be checked by plugins that way

JRoy avatar Mar 25 '22 00:03 JRoy

@RodneyMKay any progress on this?

JRoy avatar Oct 14 '22 22:10 JRoy

@RodneyMKay do you still intend to make the proposed changes?

SrBedrock avatar Jan 17 '23 12:01 SrBedrock

Superseded by #5304

JRoy avatar Apr 10 '23 00:04 JRoy