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

ExpSpawnEvent works before other events. #2915

Closed
vhone opened this issue Apr 9, 2020 · 3 comments
Closed

ExpSpawnEvent works before other events. #2915

vhone opened this issue Apr 9, 2020 · 3 comments
Labels
bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. completed The issue has been fully resolved and the change will be in the next Skript update. priority: low Issues that are not harmful to the experience but are related to useful changes or additions.

Comments

@vhone
Copy link

vhone commented Apr 9, 2020

Description

I would like to add some condition to FishingEvent as the code below.
But the ExpSpawnEvent works ahead of FishEvent, even though the experience is not dropped.
Also, when you catch fish, you get experience, but the ExpSpawnEvent doesn't work.

Steps to Reproduce

options:
	ID: onFishingEvent

on unload:
	loop all fish hooks:
		kill loop-projectile
	delete {{@ID}::*}
	delete {{@ID}.hooker::*}
	
on right click:
	player is holding fishing rod
	set {_pu} to uuid of player
	set {{@ID}::%{_pu}%::used} to true
	
on fishing:
	set {_p} to player
	set {_pu} to uuid of player
	if {{@ID}::%{_pu}%::used} is set:
		clear {{@ID}::%{_pu}%::used}
		if {{@ID}::%{_pu}%::lure} is alive:
			if {{@ID}::%{_pu}%::bite} is set:
				if fxOnFishingCatch( {_p}, {{@ID}::%{_pu}%::lure} ) is false:
					cancel event
				else:
					clear {{@ID}::%{_pu}%::bite}
					clear {{@ID}::%{_pu}%::lure}
					set {{@ID}.hooker::player} to player
			else:
				fxOnFishingFail( {_p}, {{@ID}::%{_pu}%::lure} ) is false
				cancel event
		else:
			fxOnFishingThrow( {_p} ) is false
			cancel event
	else:
		{{@ID}::%{_pu}%::bite} is not set
		if fxOnFishingBite( {_p}, {{@ID}::%{_pu}%::lure} ) is false:
			cancel event
		else:
			set {{@ID}::%{_pu}%::bite} to true
			wait 1.6 seconds
			clear {{@ID}::%{_pu}%::bite}
	
on shoot:
	shooter is holding fishing rod
	set {_pu} to uuid of shooter
	{{@ID}::%{_pu}%::lure} is not alive
	set {{@ID}::%{_pu}%::lure} to projectile

on exp spawn:
	send "ExpSpawnEvent : exp=[%spawned exp%]" to console
	cancel event
	
on item spawn:
	send "ItemSpawnEvent : item=[%event-item%]" to console
	
function fxOnFishingThrow(p:player) :: boolean:
	send "fxOnFishingThrow" to console
	return true

function fxOnFishingFail(p:player,lure:projectile) :: boolean:
	send "fxOnFishingFail" to console
	return true

function fxOnFishingBite(p:player,lure:projectile) :: boolean:
	send "fxOnFishingBite" to console
	return true

function fxOnFishingCatch(p:player,lure:projectile) :: boolean:
	send "fxOnFishingCatch" to console
	return true

Expected Behavior

Throw the fishing rod,
When a fish bites
I caught a fish.

Errors / Screenshots

캡처

Server Information

  • Server version/platform: 1.15.1 paper
  • Skript version: 2.5 alpha3

Additional Context

ExpSpawnEvent works for reasons that are unknown without fishing.
Spawned exp was none.

@Whimsyturtle
Copy link
Member

Hmm... that seems to be the case because the ExperienceSpawnEvent isn't actually a "real" event fired by Paper, but is actually being fired by Skript itself.

es = new ExperienceSpawnEvent(((PlayerFishEvent) e).getExpToDrop(), ((PlayerFishEvent) e).getPlayer().getLocation());

@Whimsyturtle Whimsyturtle added the bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. label Apr 10, 2020
@Whimsyturtle
Copy link
Member

I'm not sure if the ExperienceSpawnEvent can be reworked to fire after the PlayerFishEvent, as that might require a large-ish code rework (not entirely sure)

However, looking at the source code, if you cancel the exp event (which you did in your script), it will also cancel the fish event's exp, so that issue is on your side.

As for the ExperienceSpawnEvent firing even when there's no xp being dropped, I think it's a bit miseleading for Skript users, and it could be reworked to not fire at all if there's no xp being dropped from the various experience event sources.

@Whimsyturtle Whimsyturtle added enhancement Feature request, an issue about something that could be improved, or a PR improving something. and removed bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. labels Apr 10, 2020
@APickledWalrus
Copy link
Member

This is a bug as there is exp being dropped, as can be seen by using event-experience

@APickledWalrus APickledWalrus added bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. priority: low Issues that are not harmful to the experience but are related to useful changes or additions. and removed enhancement Feature request, an issue about something that could be improved, or a PR improving something. labels Aug 18, 2021
@APickledWalrus APickledWalrus added the PR available Issues which have a yet-to-be merged PR resolving it label Aug 18, 2021
@TPGamesNL TPGamesNL added completed The issue has been fully resolved and the change will be in the next Skript update. and removed PR available Issues which have a yet-to-be merged PR resolving it labels Aug 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. completed The issue has been fully resolved and the change will be in the next Skript update. priority: low Issues that are not harmful to the experience but are related to useful changes or additions.
Projects
None yet
Development

No branches or pull requests

4 participants