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

Feat: adding "last" argument for Visit cmd to choose the highest number #4219

Merged

Conversation

RedstoneFuture
Copy link
Member

@RedstoneFuture RedstoneFuture commented Oct 28, 2023

Overview

With this PR it is allowed to use the last or n argument to choose the highest possible (last) plot number of the target. For this purpose, parts of the algorithm were also outsourced to a private method and extended.

If this is accepted so far, I can build the same for the Home command: /p h last.

EDIT (21.12.2023): Support for inverted plot numbers has also been added.

Description

Examples:

  • /p v <username> last
  • /p v <username> <area> last
    --> Teleports the player to the x plot of <username> if he has a total of x.

EDIT (21.12.2023):

  • /p v <username> -#
  • /p v <username> <area> -#

grafik

Submitter Checklist

Preview Give feedback

@RedstoneFuture RedstoneFuture requested a review from a team as a code owner October 28, 2023 20:00
@github-actions github-actions bot added the Feature This PR proposes a new feature label Oct 28, 2023
@RedstoneFuture RedstoneFuture changed the title Feat: Adding "last" argument for Visit cmd to choose the highest number Feat: adding "last" argument for Visit cmd to choose the highest number Oct 28, 2023
@dordsor21
Copy link
Member

What if as well as adding last we allowed adding a - to the number to indicate the number-from-last to visit?

@RedstoneFuture
Copy link
Member Author

RedstoneFuture commented Nov 19, 2023

What if as well as adding last we allowed adding a - to the number to indicate the number-from-last to visit?

Do you mean the argument last or n is the same as -1. And -2 is the second plot from behind?

Example:
Total plots: 4x

  • /p v last = /p v -1 --> /p v 4
  • /p v -2 --> /p v 3

@dordsor21
Copy link
Member

I'd say last is still the very last plot, and then -1 is the plot before last. So -0 is basically last

@RedstoneFuture
Copy link
Member Author

I'd say last is still the very last plot, and then -1 is the plot before last. So -0 is basically last

Ah ok. Yea, both versions make sense.

grafik

grafik

@SirYwell
Copy link
Member

I'm not sure about the negative values. It might make sense for us, but I don't know if it is user-friendly. Python has a similar feature for lists, but there -1 is tne last element. Having -0 looks very confusing.

Maybe it would be better to have a flag (e.g. -r for reverse?), so /p v -r brings you to the last plot, /p v -r 2 or /p v 2 -r brings you to the second last, etc. WDYT?

@dordsor21
Copy link
Member

I'd still think having the -# shorthand would be good, though a flag is probably more user-friendly for most to be fair

@RedstoneFuture
Copy link
Member Author

RedstoneFuture commented Nov 23, 2023

I'll add the -# spelling.

But I don't think that a "reverse flag" is much more very user-friendly, as the command already has a very complex syntax. Especially because the order of the arguments also plays a role here, so that we can classify the individual command inputs. In the end, the -# spelling is the same in short, with the difference that not even the syntax "changes" for the user.

/plot visit <player> | <alias> | <plot> [area]|[#] [#]

@RedstoneFuture
Copy link
Member Author

RedstoneFuture commented Dec 21, 2023

I'll add the -# spelling.

But I don't think that a "reverse flag" is much more very user-friendly, as the command already has a very complex syntax. Especially because the order of the arguments also plays a role here, so that we can classify the individual command inputs. In the end, the -# spelling is the same in short, with the difference that not even the syntax "changes" for the user.

/plot visit <player> | <alias> | <plot> [area]|[#] [#]

-# spelling has been added.

@@ -326,6 +317,29 @@ public CompletableFuture<Boolean> execute(
return CompletableFuture.completedFuture(true);
}

private boolean isInvalidPageNr(String arg) {
if (MathMan.isInteger(arg)) return false;
Copy link
Member

Choose a reason for hiding this comment

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

I think the code style requires all ifs etc. these have the braces applied

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok. I have changed it.

@RedstoneFuture
Copy link
Member Author

I'm looking forward to the merge. I can make good use of the command. When this has been merged, I'll add a "last" to the "/p home" command too.

@dordsor21 dordsor21 merged commit 1b40cea into IntellectualSites:main Mar 20, 2024
9 checks passed
pull bot pushed a commit to Craftstuebchen/PlotSquared that referenced this pull request Mar 21, 2024
…er (IntellectualSites#4219)

* Refactoring, Adding "last" argument to visit cmd

* Adding reversed plot format

* fixing tab-completion of "last" argument

* reformatting the code-style
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature This PR proposes a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants