-
-
Notifications
You must be signed in to change notification settings - Fork 1
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
add changeworld listener #16
Conversation
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 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())) { |
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 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.
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 probably doesn't matter here, since both the to and the from world's are managed by parkour
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.
clarified comments a little
public void onPlayerChangeWorld(PlayerChangedWorldEvent event) { | ||
User user = User.getInstance(event.getPlayer()); | ||
Location currentLocation = user.getLocation(); | ||
if (!addon.inWorld(currentLocation)) { |
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 includes nether and end.
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.
If a player changes world into any parkour managed world, it should still change gamenode, right?
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.
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.
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.
At the moment, cross dimensional travel is blocked by the teleport event iirc, is that also a bug?
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.
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()) { |
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.
If you use isPresent, then you don't need to check isEmpty or make the local variable "course".
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.
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
A few tests fail, but I think they are fixable. I'll merge. |
fixes #15 (probably, i didnt have a foolproof reproduction)