Skip to content

new sign transaction event - #6071

Merged
JRoy merged 25 commits into
EssentialsX:2.xfrom
sumsar1812:task/new-sign-transaction-events
Mar 24, 2025
Merged

new sign transaction event#6071
JRoy merged 25 commits into
EssentialsX:2.xfrom
sumsar1812:task/new-sign-transaction-events

Conversation

@sumsar1812

Copy link
Copy Markdown
Contributor
  • Added new SignTransactionEvent to notify external plugins about sign transactions
  • Fixing checkstyle errors and moving event to aligning with other event location.

Information

The feature request is here:
#6070
https://gyazo.com/ba209d0b4dd4e4a032e1e0a390e37157

This PR closes#6070.

Details

Proposed feature:

This feature would introduce one new event for external plugins to listen to.
This event is called SignTransactionEvent and is fired when a user buys or sells something from a sign.
The event includes information about the type of transaction(buy/sell), the item bought/sold, how much it was bought/sold for and the sign it was bought at, the event is cancelable.

Environments tested:

OS: Windows 10

Java version: java version "17.0.7"

  • Most recent Paper version (1.XX.Y, git-Paper-BUILD)
  • CraftBukkit/Spigot/Paper 1.12.2
  • CraftBukkit 1.8.8

Demonstration:

https://gyazo.com/b3ab1a544ae3da83c9dd84556a7db415 - gif in 1.8
https://gyazo.com/ddf184d52fe0144690a49e19de0b2c40 - works in 1.12
https://gyazo.com/b68c7554c5ceb455aaa14fc6b4827c1b - works in 1.21
Code used to test it
https://pastebin.com/rcDJbX6s

@JRoyJRoy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need to declare a HandlerList for the SignTransactionEvent and override the getHandlers method + add a static getHandlerList method which also returns it.

otherwise i just left a few slight style/doc changes.

Comment threadEssentials/src/main/java/net/ess3/api/events/SignTransactionEvent.java Outdated
Comment threadEssentials/src/main/java/net/ess3/api/events/SignTransactionEvent.java Outdated
Comment threadEssentials/src/main/java/net/ess3/api/events/SignTransactionEvent.java Outdated
Comment threadEssentials/src/main/java/net/ess3/api/events/SignTransactionEvent.java Outdated
Comment threadEssentials/src/main/java/net/ess3/api/events/SignTransactionEvent.java Outdated
Comment threadEssentials/src/main/java/net/ess3/api/events/SignTransactionEvent.java Outdated
Comment threadEssentials/src/main/java/net/ess3/api/events/SignTransactionEvent.java Outdated
Comment threadEssentials/src/main/java/com/earth2me/essentials/signs/SignBuy.java Outdated
Comment threadEssentials/src/main/java/com/earth2me/essentials/signs/SignSell.java Outdated
@sumsar1812

sumsar1812 commented Feb 28, 2025

Copy link
Copy Markdown
ContributorAuthor

you need to declare a HandlerList for the SignTransactionEvent and override the getHandlers method + add a static getHandlerList method which also returns it.

otherwise i just left a few slight style/doc changes.

Are the handerlist not inherited by the other event ? So it should not be needed to declare it again, otherwise I think the event wouldn't have worked.

sumsar1812and others added 11 commits February 28, 2025 18:44
….java
Co-authored-by: Josh Roy <10731363+JRoy@users.noreply.github.com>
…l.java
Co-authored-by: Josh Roy <10731363+JRoy@users.noreply.github.com>
…ent.java
Co-authored-by: Josh Roy <10731363+JRoy@users.noreply.github.com>
…ent.java
Co-authored-by: Josh Roy <10731363+JRoy@users.noreply.github.com>
…ent.java
Co-authored-by: Josh Roy <10731363+JRoy@users.noreply.github.com>
…ent.java
Co-authored-by: Josh Roy <10731363+JRoy@users.noreply.github.com>
…ent.java
Co-authored-by: Josh Roy <10731363+JRoy@users.noreply.github.com>
…ent.java
Co-authored-by: Josh Roy <10731363+JRoy@users.noreply.github.com>
…ent.java
Co-authored-by: Josh Roy <10731363+JRoy@users.noreply.github.com>
…ent.java
Co-authored-by: Josh Roy <10731363+JRoy@users.noreply.github.com>
@sumsar1812

sumsar1812 commented Feb 28, 2025

Copy link
Copy Markdown
ContributorAuthor

I updated the rest though, thanks :)

@JRoy

JRoy commented Mar 24, 2025

Copy link
Copy Markdown
Member

Are the handerlist not inherited by the other event ? So it should not be needed to declare it again, otherwise I think the event wouldn't have worked.

they are not, the static and instance methods need to be explicitly declared otherwise issues occur.

@JRoyJRoy closed this Mar 24, 2025
@JRoyJRoy reopened this Mar 24, 2025
@sumsar1812

Copy link
Copy Markdown
ContributorAuthor

Fair I read up a bit on it and I see you are right, even though it do work it could introduce some inconsistencies(unregistering events when not expecting to, incorrect event matching etc)

@JRoy
JRoy requested a review from CopilotMarch 24, 2025 23:47

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a new event, SignTransactionEvent, to notify external plugins about sign transactions (buy or sell) and also addresses checkstyle errors by moving the event file to align with other event locations.

  • Added a new SignTransactionEvent with data for the item, transaction type, and transaction value.
  • Updated SignSell and SignBuy to fire the new event and handle cancellations appropriately.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

FileDescription
Essentials/src/main/java/net/ess3/api/events/SignTransactionEvent.javaNew event class for sign transactions
Essentials/src/main/java/com/earth2me/essentials/signs/SignSell.javaIntegrates SignTransactionEvent in sign sell logic
Essentials/src/main/java/com/earth2me/essentials/signs/SignBuy.javaIntegrates SignTransactionEvent in sign buy logic

@JRoy
JRoy enabled auto-merge (squash) March 24, 2025 23:51
@JRoy
JRoy merged commit dabe687 into EssentialsX:2.xMar 24, 2025
Euphillya added a commit to Euphillya/Essentials-Folia that referenced this pull request Jun 27, 2025
EssentialsX@40540eb Expose IUser#getLastActivityTime to API (EssentialsX#6101)
EssentialsX@50b696b Adds social spy message type for in EssentialsDiscord (EssentialsX#5620)
EssentialsX@dabe687 Add SignTransactionEvent for buy and sell signs (EssentialsX#6071)
EssentialsX@0cb387f Fix NPE when unlinking offline players (EssentialsX#6111)
EssentialsX@f09541c Update to Minecraft 1.21.5 (EssentialsX#6109)
EssentialsX@c7ff994 Fire GlobalChatEvent even when local chat is disabled (EssentialsX#6113)
EssentialsX@06c886c Fix /baltop on 1.15.2 and below (EssentialsX#6115)
EssentialsX@2bb4438 Fix further trade sign validation mismatches (EssentialsX#6116)
EssentialsX@8455212 Fix /spawnmob on < 1.21.5 (EssentialsX#6121)
EssentialsX@be3e641 New Crowdin updates (EssentialsX#6089)
EssentialsX@3f5b122 Use legacy text for TranslatableException#getMessage (EssentialsX#6134)
EssentialsX@fe43017 Fix heer typo in messages_en.properties (EssentialsX#6135)
EssentialsX@a58db23 Update English source strings with fixes from Crowdin (EssentialsX#6140)
EssentialsX@d137031 Improve config comments & ordering (EssentialsX#6108)
EssentialsX@3b0c229 New Crowdin updates (EssentialsX#6131)
EssentialsX@3fe1495 Fix unexpected behavior with essentials.home.bed & essentials.sethome.bed permissions (EssentialsX#5991)
EssentialsX@aebe851 Fix double messages when deleting a non-existent home (EssentialsX#6150)
EssentialsX@3a5c7c4 Revert changes to /home and /sethome that break bed interactions (EssentialsX#6151)
EssentialsX@3d28d82 Release 2.21.1
EssentialsX@e836747 Prepare for 2.21.2 dev builds (EssentialsX#6128)
EssentialsX@d42347f Fix sending message during /editsign paste if SignChangeEvent is cancelled (EssentialsX#6136)
EssentialsX@997f600 Update adventure dependencies (EssentialsX#6163)
EssentialsX@4057326 Update to Minecraft 1.21.6
EssentialsX@2796399 Add 1.21.6 Mobs
EssentialsX@31ea903 Move tests to MockBukkit
EssentialsX@ff1b8b8 Add 1.21.6 Aliases
rewsdjad1 pushed a commit to rewsdjad1/EssentialsXPlus that referenced this pull request Aug 13, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Event for buying and selling from signs

3 participants

@sumsar1812@JRoy