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 changeworld listener #16

Merged

Conversation

456dev
Copy link
Collaborator

@456dev 456dev commented Aug 9, 2023

fixes #15 (probably, i didnt have a foolproof reproduction)

Copy link
Member

@tastybento tastybento left a comment

Choose a reason for hiding this comment

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

The other way I think you could do this is put the game mode changes into a Bukkit.getScheduler().runTask and have them execute a tick afterwards, which will be when they arrive in the next world. But I'm assuming that it will take just a tick (in my experience this is always the case, but...). So your approach is probably cleaner.

} else {
user.setGameMode(GameMode.SURVIVAL);

if (addon.inWorld(user.getLocation())) {
Copy link
Member

Choose a reason for hiding this comment

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

This includes nether and end. So if you are trying to keep it to the same world then you'll need to check some other things too.

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 probably doesn't matter here, since both the to and the from world's are managed by parkour

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

clarified comments a little

public void onPlayerChangeWorld(PlayerChangedWorldEvent event) {
User user = User.getInstance(event.getPlayer());
Location currentLocation = user.getLocation();
if (!addon.inWorld(currentLocation)) {
Copy link
Member

Choose a reason for hiding this comment

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

This includes nether and end.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If a player changes world into any parkour managed world, it should still change gamenode, right?

Copy link
Member

Choose a reason for hiding this comment

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

Yes. I'm just thinking if you need to consider the use case where someone is in the Parkour Nether, but teleports back to the Parkour Overworld. I anticipate Parkour courses that cross dimensions. That's why.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

At the moment, cross dimensional travel is blocked by the teleport event iirc, is that also a bug?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

stopped portal teleports from stopping run, added a check that stops changing the gamemode if you are coming from a parkour world

}
// Check if player is in a parkour course
Optional<Island> course = addon.getIslandsManager().getIslandAt(currentLocation);
if (course.isEmpty()) {
Copy link
Member

Choose a reason for hiding this comment

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

If you use isPresent, then you don't need to check isEmpty or make the local variable "course".

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

remove portals from canceling run, ensure gamemode is only changed in certain teleport events

make it more explicit that IslandEnterEvent checks source world before changing gamemode

non-parkour -> parkour: PlayerChangedWorldEvent set gm
non-parkour -> non-parkour: none
parkour -> parkour:
        same island: PlayerTeleportEvent set gm if not running
        between islands: IslandEnterEvent set gm
parkour -> non-parkour: none
@456dev 456dev requested a review from tastybento August 10, 2023 19:21
@tastybento
Copy link
Member

A few tests fail, but I think they are fixable. I'll merge.

@tastybento tastybento merged commit e89df1d into BentoBoxWorld:develop Aug 11, 2023
1 check failed
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.

Cross world teleports dont always correctly set the gamemode
2 participants