IntellectualSites / IntellectualSites/PlotSquared

plot merge count only contains the number of connected plots for the plot the players is located in

Open
#3,044 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Approved Bug
Dominant language
Java
Stars
653
Forks
975
Avg merge
2m
Merged PRs (30d)
6

Description

Server Implementation

Paper

Server Version

1.15.2

Describe the bug

Copy of https://issues.intellectualsites.com/issue/PS-30 by ofunny

#Usability problem

Plot merge count argument in world.yml (economy.prices.merge) only contains the number of connected plots for the plot the players is located at the moment.

You can either define a double or custom JavaScript In the worlds.yml (economy.prices.merge).
The JavaScript will be executed via eval and gets one argument on call. The return of the JavaScript will be the merge price.
This will allow detailed price calculation.

In the Merge.java you will find the eval on line 144 "final double price = priceExr == null ? 0d : priceExr.evaluate((double) size);"
The size argument will be assigned on line 126 "final int size = plot.getConnectedPlots().size();"

The problem: ConnectedPlots().size(); will just retrieve the count of connected plots for the plot in which the player is located at the moment.
This will allow the player to bypass higher merge price by simply merging to a bigger (merged) plot from a smaller plot since the smaller one will have less or no connected plots.

Instead of passing the size of actually connected plots passing the total size of the merge process would fix this issue.
Since the total amount will be retrieved earlier to check the permission "plots.merge.x" this value should already exist.

Optional: pass a second double containing the total amount of merges a player already owns in/on the world/server.

To Reproduce

Create dynamic merge prices, example "merge: "(function(count) { if(count >= 1) count--; var base = 10000.0 * count; return base; }).call(new Object(), {arg});" in the world.yml.
Now perform multiple merges on the same plot.

  • always merge from the already merged plots in the direction of single (unmerged) plots (one by one).
  • check the merge prices, it will always increase.
  • delete the merges.
  • Now do the same thing, but always merge from the single (unmerged) plots in the direction of the already merged plots.
  • you will see, it is always the start price.
Expected behaviour
Screenshots / Videos

No response

Error log (if applicable)

No response

Plot Debugpaste
PlotSquared Version

5.12.0

Checklist
Anything else?

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in Merge.java around lines 126 and 144, then inspect the economy.prices.merge setting in world.yml and the described reproduction steps. Trace how the total merge size is determined before permission checks; done means dynamic pricing uses the full merge operation size consistently regardless of which plot starts the merge, verified in both merge directions.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, javascript
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.