-
-
Notifications
You must be signed in to change notification settings - Fork 368
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
Improve fishing #2289
Improve fishing #2289
Conversation
Also I found a memory leak within the EventValueExpression or EnumUtils class, this is probably critical, but when broadcasting the This could also be related #2279 I did not fix this in this pull request, as unrelated Experience is already handled via the Experience Util and event by the way. P.S the grappling hook is really fun lol. |
Oh ya, and since there are two entities in this event now, the bug where you have to define the player is present in this now. |
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.
Looks good overall.
@Description("The <a href='../classes.html#entity'>fishing hook</a> involved in a player fishing event.") | ||
@Examples({"on fishing:", "\tteleport player to fishing hook"}) | ||
@Since("2.4") | ||
public class ExprFishingHook extends EventValueExpression<FishHook> { |
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.
I don't really see the utility of this expression, is it just for documentation? You should be able to use the fish hook
or event-fish hook
since it's an entity.
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.
No, that's the point of the EventValueExpression is to be able to actually use it in that way. Doesn't work without doing it this way.
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.
EventValueExpression is mainly (and I think only) used as default expression when registering a class and perhaps adding documentation to a specific event value but that's about it. You can use it this way since the ExprEntity handles it.
Being able to use hook
instead of fish hook
is something I'd rather avoid as well, in case it conflicts with something else in the future.
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.
'fishing' shouldn't be optional. Hook already means a few different things in Skript's source code.
@Description("The <a href='../classes.html#fishingstate'>fishing state</a> of a player fishing event.") | ||
@Examples("fishing state is failed or in ground") | ||
@Since("2.4") | ||
public class ExprFishingState extends EventValueExpression<State> { |
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.
Same thing as the above expression.
if (states == null) | ||
return true; | ||
PlayerFishEvent event = (PlayerFishEvent) e; | ||
for (PlayerFishEvent.State state : states.getArray(event)) { |
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.
You could use the CollectionUtils#contains
method (Skript's CollectionUtils, not Apache's). Doesn't matter that much either way.
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.
Not needed as that would need to go through a separate class.
public String toString(@Nullable Event e, boolean debug) { | ||
if (states == null) | ||
return "fishing"; | ||
return "fishing with states " + states.toString(e, debug); |
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.
The event's syntax doesn't contain with
.
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.
It's a debug message
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.
No, it is string representation of the used code. Yes i know what they are used for
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.
It doesn't necessarily represent source code, but in this case I agree.
This problem can be circumvented by registering the entity as a classinfo, though that might be a bit overkill for the matter. |
Use I don't feel good about fishing states in the event syntax, they don't look like correct English to me (not all of them). Also the enum names needs some work, like "on" alias for in_ground (may break the on ground condition), "fishing" what?, "reeling in", "successfully caught" etc |
One is also a condition and the other is a type. |
That is not the subject. |
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.
Looks good. The issues I have with this have been already pointed out by others.
public String toString(@Nullable Event e, boolean debug) { | ||
if (states == null) | ||
return "fishing"; | ||
return "fishing with states " + states.toString(e, debug); |
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.
It doesn't necessarily represent source code, but in this case I agree.
@Description("The <a href='../classes.html#entity'>fishing hook</a> involved in a player fishing event.") | ||
@Examples({"on fishing:", "\tteleport player to fishing hook"}) | ||
@Since("2.4") | ||
public class ExprFishingHook extends EventValueExpression<FishHook> { |
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.
'fishing' shouldn't be optional. Hook already means a few different things in Skript's source code.
I'm just wondering where we're at with this? @TheLimeGlass we're you planning on updating based on the requested changes? |
Closing due to inactivity. |
Description
Improves fishing by adding fishing state, fishing hook, improved event with the fishing state, and getting of the caught entity.
Tested on Paper 1.14.4-138
Test script and new default example script: