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

Improve fishing #2289

Closed
wants to merge 3 commits into from
Closed

Improve fishing #2289

wants to merge 3 commits into from

Conversation

TheLimeGlass
Copy link
Collaborator

@TheLimeGlass TheLimeGlass commented Jul 23, 2019

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:

on fishing states caught entity and caught fish:
	launch a trailing large ball firework coloured red, purple and lime at entity timed 0
	message "&aCongrats you caught something!" to player

# A fun grappling hook.
on fishing failure and in ground:
	player is holding a fishing rod
	name of player's tool is "&6Grappling hook"
	push player direction from player to fishing hook at speed 2.5

on fish:
	message "You just did something relating to fishing! %fishing state%" to player 

@TheLimeGlass
Copy link
Collaborator Author

TheLimeGlass commented Jul 23, 2019

Also I found a memory leak within the EventValueExpression or EnumUtils class, this is probably critical, but when broadcasting the %fishing state% there, it adds up the name of the state every single time. It's not getting a new String list somewhere everytime a new call from the classinfo is ran through it. This probably exists on the other simple enums that utilize this EnumUtil.
https://imgur.com/ueDfC3U
Exists in teleport cause too
teleport cause: https://imgur.com/oIGoCgN
As you know events happen alot, and this can become really bad.
Behavior was different in terms of how it broadcasted because one was used with the event syntax, which is why it stacked in a single string for the first one.

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.

@bensku

@TheLimeGlass
Copy link
Collaborator Author

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.

#1415

Copy link
Member

@FranKusmiruk FranKusmiruk left a 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> {
Copy link
Member

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.

Copy link
Collaborator Author

@TheLimeGlass TheLimeGlass Jul 26, 2019

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.

Copy link
Member

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.

Copy link
Member

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> {
Copy link
Member

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)) {
Copy link
Member

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.

Copy link
Collaborator Author

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);
Copy link
Member

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.

Copy link
Collaborator Author

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

Copy link
Contributor

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

Copy link
Member

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.

@FranKusmiruk
Copy link
Member

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.

This problem can be circumvented by registering the entity as a classinfo, though that might be a bit overkill for the matter.

@Blueyescat
Copy link
Contributor

Blueyescat commented Jul 25, 2019

Use INSERT VERSION for @Sinces...

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

@TheLimeGlass
Copy link
Collaborator Author

TheLimeGlass commented Jul 26, 2019

Use INSERT VERSION for @Sinces...

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

on ground and in the ground are not close enough to conflict, and that is the point of using the english.lang so Skript can determine which classinfo type matches.

One is also a condition and the other is a type.

@Blueyescat
Copy link
Contributor

Use INSERT VERSION for @Sinces...
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

on ground and in the ground are not close enough to conflict, and that is the point of using the english.lang so Skript can determine which classinfo type matches.

One is also a condition and the other is a type.

That is not the subject.

Copy link
Member

@bensku bensku left a 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);
Copy link
Member

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> {
Copy link
Member

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.

@FranKusmiruk FranKusmiruk added the enhancement Feature request, an issue about something that could be improved, or a PR improving something. label Sep 17, 2019
@ShaneBeee
Copy link
Contributor

ShaneBeee commented Feb 28, 2020

I'm just wondering where we're at with this?
I see there have been a few requested changes, but no action on this PR in about 5 months.

@TheLimeGlass we're you planning on updating based on the requested changes?

@ShaneBeee
Copy link
Contributor

Closing due to inactivity.

@ShaneBeee ShaneBeee closed this May 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature request, an issue about something that could be improved, or a PR improving something.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants