Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add thunder changes event #2317

Merged
merged 3 commits into from Feb 5, 2022
Merged

Add thunder changes event #2317

merged 3 commits into from Feb 5, 2022

Conversation

cinthesize
Copy link
Contributor

Added an event for when the thunder changes in a world, weirdly a separate event from WeatherChangeEvent

Adds an event that allows a user to detect when thunder changes in a world
Simple update to adhere better to denizen formatting
@EventHandler
public void onThunderChanges(ThunderChangeEvent event) {
world = new WorldTag(event.getWorld());
thunder = new ElementTag(event.toThunderState());
Copy link
Member

Choose a reason for hiding this comment

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

storing these two fields is redundant, just construct them inside getContext

Copy link
Contributor Author

@cinthesize cinthesize Feb 5, 2022

Choose a reason for hiding this comment

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

Since thunder and world are both only used within getContext, would it be best to just remove the definitions on line 35 and 36 entirely?
EDIT: Realizing now that i'm likely going to need world defined to allow the in <world> addition

Copy link
Member

Choose a reason for hiding this comment

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

those definitions are called fields in java and yes remove them


@Override
public ObjectTag getContext(String name) {
if (name.equals("world")) {
Copy link
Member

Choose a reason for hiding this comment

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

find an event that uses a switch (name) line in getContext - that's the modern format, you copied a reference of the legacy format


// <--[event]
// @Events
// thunder changes|begins|clears (in <world>)
Copy link
Member

Choose a reason for hiding this comment

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

This says (in <world>) but the matches doesn't appear to implement that

Remove `thunder` and `world` fields, replaced the if statements in `getContext` with a switch statement, and added the `in <world>` match that i originally forgot
@cinthesize
Copy link
Contributor Author

Attempted the above corrections, please let me know if I did anything in a weird way lmao

@mcmonkey4eva mcmonkey4eva merged commit 74668a4 into DenizenScript:dev Feb 5, 2022
Sign up for free to 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.

None yet

2 participants