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

Random teleport improvements #4271

Open
wants to merge 13 commits into
base: 2.x
Choose a base branch
from

Conversation

pop4959
Copy link
Member

@pop4959 pop4959 commented Jun 25, 2021

Supersedes #3538.
Closes #1893, closes #3469, closes #3479.

Various improvements for Essentials' random teleportation feature.

Should be complete as-is, other than potential code clean-up and testing before merging.

Miscellaneous points of interest:

  • #easteregg pre-cache configuration removed (it was hardly in use anyways, and doesn't make any difference after first tp + with multiple locations the number of locations to compute could get very expensive).
  • EssentialsUpgrade to convert old single location random teleport and retain prior behavior.
  • Random respawn with random-respawn and random-respawn-location configuration options.
  • Random teleport signs by adding randomteleport to the enabledSigns list in the config, writing [RandomTeleport] in the first line on the sign, and optionally the name of the location on the second line.
  • Configuration option default-location for default location (where to teleport when typing /tpr with no arguments) that defaults to the current world.
  • Configuration option per-location-permission for per location permissions (essentials.tpr.location.<name>), functioning similarly to how per warp permissions work.
  • /settpr now requires the location name as an argument to set center/ranges for.
  • Can teleport other players with the essentials.tpr.others and the command /tpr <name> <player>.
  • Console can now execute /tpr with the name and player both as required arguments.
  • Fixed an issue where on older versions of the game the default center location would be a block too high.
  • Fixed an issue where events modifying random teleportation parameters would cause incorrect caching.
  • Fixed the issue of random locations below y=0 being considered invalid (world height can be lower now in 1.17).

@pop4959 pop4959 added this to the 2.20.0 milestone Jun 25, 2021
@pop4959 pop4959 added type: enhancement Features and feature requests. module: main Issues or PRs for the main Essentials module module: spawn Issues or PRs for the EssentialsSpawn module type: bugfix PRs that fix bugs in EssentialsX. labels Jun 25, 2021
@JRoy
Copy link
Member

JRoy commented Dec 4, 2021

@pop4959 can you resolve conflicts for this whenever you have time

@pop4959
Copy link
Member Author

pop4959 commented Dec 11, 2021

Updated, would like to see a few more people test this before merging though. Grab a build from actions if you want to try it, and just be sure to backup tpr.yml so you can easily switch back to regular Essentials builds.

@Leahcimkrob
Copy link

You can enter a value after it for tpr, but you can always get by in the farmworld.

@pop4959
Copy link
Member Author

pop4959 commented Dec 12, 2021

You can enter a value after it for tpr, but you can always get by in the farmworld.

Not quite sure what you mean here, can you elaborate?

@Leahcimkrob
Copy link

#4679
I posted that in the discussions. So I got your invitation to test your build. With the / tpr I still got into the farming world, even if I had specified a value such as Nether.

@pop4959
Copy link
Member Author

pop4959 commented Dec 12, 2021

#4679 I posted that in the discussions. So I got your invitation to test your build. With the / tpr I still got into the farming world, even if I had specified a value such as Nether.

Can you provide a list of the worlds you have on your server and your tpr.yml file

@Leahcimkrob
Copy link

Ok i got it.

After a few teleoports with / tpr, I suddenly landed in the Void in the Nether. Can that still be fixed?

@Chris6ix
Copy link

Chris6ix commented May 17, 2022

Hey, just wondering if there are any updates on this?
Just wanted to open a new issue, but saw that the Feature I want was already suggested (and apparently also been worked on) (#3469)
Would be awesome having this :)

Edit: Sadly can't help test because the build artifact is expired :/

@pop4959
Copy link
Member Author

pop4959 commented May 17, 2022

@Chris6ix Updated the build for you :)

This work is for the most part done, probably just a few minor changes here and there, but otherwise just needs to be tested thoroughly before the 2.20 milestone.

@Chris6ix
Copy link

Alright I downloaded it, and I'm going to test it when I got some spare time (Have Exams rn :/ )
Thanks for updating the build :)

Is there anything specific that needs to be tested or something?
I can imagine that the basics have already been tested?

Btw, is there an approximate release date for 2.20?

@pop4959
Copy link
Member Author

pop4959 commented May 18, 2022

Alright I downloaded it, and I'm going to test it when I got some spare time (Have Exams rn :/ ) Thanks for updating the build :)

Is there anything specific that needs to be tested or something? I can imagine that the basics have already been tested?

Btw, is there an approximate release date for 2.20?

No problem. Nothing specific, just making sure multi-world teleports, /tpr, /settpr commands, configuration, etc all appear and behave as expected and are intuitive to use, not buggy, etc. The basics have been tested so ideally try it out on a server and see if you find any issues using it.

There isn't an ETA For 2.20 currently but you can track progress in the milestone here on Github.

@Chris6ix
Copy link

No problem. Nothing specific, just making sure multi-world teleports, /tpr, /settpr commands, configuration, etc all appear and behave as expected and are intuitive to use, not buggy, etc. The basics have been tested so ideally try it out on a server and see if you find any issues using it.

There isn't an ETA For 2.20 currently but you can track progress in the milestone here on Github.

Okay thank you!
I will test these things when i got some spare time and get back to you with the results ;)

@Chris6ix
Copy link

Hey @pop4959 i found some free time and tested the multi world rtp feature :)
I loaded the 4 worlds from my Server to a completely fresh paper 1.18.2 #350 Test Server with only EssX 2.20.0-dev+6-2448e2a (your build) and Multiverse-Core 4.3.2-SNAPSHOT-b870
I also generated a completely new EssX folder and left everything to default.

I teleported myself to each of the world's spawns using mvtp <WorldName> and then just did /settpr <WorldName> center
This worked perfectly for all the worlds.

I then teleported myself to each world and made about 20 random teleports in each world, each time checking with Xaeros World Map that the teleports were really random and that it was not picking a location more than once or something.
Everything worked perfectly fine besides the rtps in the nether...there were 2 issues:
Out of the 20 times, I got teleported 2 times into a wall
Out of the 20 times, I got teleported 3 times on top of the nether roof

So I think the nether part needs to be adjusted a bit with a max height just under the nether roof for example and a fix for the teleporting into walls. The rest looks fine to me :)

Thanks again for working on this great feature!
If you need any more testing or something, just ping me here.

Cheers

@pop4959
Copy link
Member Author

pop4959 commented May 28, 2022

@Chris6ix Hey, thanks for doing such a thorough test! Glad to hear everything's working for you. 😄

Not sure about the teleporting into walls/roof, I don't believe any changes have been made with regards to that. It should be using Essentials safe teleport feature (as all other teleport commands do), so unless you've turned that off random teleports should behave correctly.

I sometimes forget to keep this branch up-to-date, but feel free to continue testing it. Just ping me if you need any changes merged in from the current mainstream dev builds.

@Chris6ix
Copy link

Hey @pop4959 thanks for the quick reply!
As I explained in my message from before, I generated a completely new EssX folder (so also a fresh config) and didn't even open it (the only file I checked was tpr.yml to check if all the worlds show up correctly).
So all settings were on default, which for the teleport safety seems to be this:
image
So the teleport safety was enabled...and it still teleported me into walls / on top of the nether roof...
Or is that because I was in creative? (Because of explanation of force-safe-teleport-location)
If that is so, shouldn't the default be true to also prevent creative mode players from getting teleported into walls?

@pop4959
Copy link
Member Author

pop4959 commented May 28, 2022

Yes it is probably because you were in creative. The teleport is "safe" in creative mode since you do not take damage. Teleportation safety primarily concerns whether or not the player takes damage teleporting to the location.

You can test in survival or try setting that option to true if that is your preference.

@Chris6ix
Copy link

Chris6ix commented May 28, 2022

Mhm okay I have force-safe-teleport-location now set to true and I'm not getting teleported into walls anymore in creative, but it still teleports me on top of the nether roof (Probably because its "safe" because you don't take damage...)
Is there something you can do to not make the nether roof count as "safe" / Or add a max tp height just for the nether dimension just under the nether roof, which seems to be Y:121 ?

Edit: This could be a config option if the nether roof should be treated as safe or not

@pop4959
Copy link
Member Author

pop4959 commented May 28, 2022

Okay, that's something we can look into then. The intent is definitely not to teleport on top of the roof. Probably either the location being selected too high, or teleportation safety choosing a spot above the roof (although I believe it's already supposed to do this).

@goweiwen
Copy link

Want to update that I've been using this PR on my server for more than a few months and it has been working great.

Copy link
Member

@JRoy JRoy left a comment

Choose a reason for hiding this comment

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

few things otherwise good!

@@ -153,6 +153,10 @@ public static void uuidFileConvert(final IEssentials ess, final Boolean ignoreUF
ess.getLogger().info("To rerun the conversion type /essentials uuidconvert");
}

public void updateRandomTeleport() {
ess.getRandomTeleport().updateConfig();
Copy link
Member

Choose a reason for hiding this comment

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

A couple problems with this upgrade;

  • This should only be ran once (by checking/setting the doneFile with a unique upgrade key)
  • The logic for this upgrade should be contained in the EssentialsUpgrade class and ideally not call any method in RandomTeleport as to not create an accidental regression down the road.

randomTeleport.getCachedLocations().clear();
if ("center".equalsIgnoreCase(args[0])) {
randomTeleport.setCenter(user.getLocation());
randomTeleport.reloadConfig();
Copy link
Member

Choose a reason for hiding this comment

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

This invokes an I/O operation. Is there a reason why it's ran let alone before any arguments are even validated?

Comment on lines +29 to 30
@Deprecated
public UserRandomTeleportEvent(final IUser user, final Location center, final double minRange, final double maxRange) {
Copy link
Member

Choose a reason for hiding this comment

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

Event constructors aren't API, you can remove this if you're not using it

@pop4959
Copy link
Member Author

pop4959 commented Aug 14, 2022

TODO

  • jroys comments above
  • pre-validate random locations in chunks
  • refactor / clean up some code

@JRoy JRoy modified the milestones: 2.20.0, 2.21.0 Apr 28, 2023
@mdcfe mdcfe modified the milestones: 2.21.0, 2.22.0 Sep 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module: main Issues or PRs for the main Essentials module module: spawn Issues or PRs for the EssentialsSpawn module type: bugfix PRs that fix bugs in EssentialsX. type: enhancement Features and feature requests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Run TPR from console/command block RTP Multi World Support Random Spawn
8 participants