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
Conversation
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()); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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")) { |
There was a problem hiding this comment.
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>) |
There was a problem hiding this comment.
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
Attempted the above corrections, please let me know if I did anything in a weird way lmao |
Added an event for when the thunder changes in a world, weirdly a separate event from WeatherChangeEvent