Trophonix / TradePlus

Easy-to-use, highly configurable trading plugin for Spigot- and Bukkit-based Minecraft servers.
https://www.spigotmc.org/resources/23138/
GNU General Public License v3.0
54 stars 42 forks source link

Fix GriefPrevention max claimblocks calculation. #83

Closed RezzedUp closed 2 years ago

RezzedUp commented 2 years ago

This patch allows players to trade their accrued claimblocks once again, instead of just their bonus claimblocks. It also fixes several issues with building the plugin (by updating/removing improperly-defined and unused dependencies).

Trophonix commented 2 years ago

Have you tested with this? When I used accrued claimblocks before, I believe someone reported the issue that GriefPrevention plugin would automatically grant players the default claim block amount when they traded down to 0 claim blocks, effectively making duplication of claim blocks possible.

RezzedUp commented 2 years ago

Yes, I did test it. That shouldn't be an issue because it's modifying bonus claimblocks, not accrued claimblocks.

Trophonix commented 2 years ago

What happens if a user has 1000 bonus claim blocks, 1200 total, and they trade away all 1200? Their bonus claim blocks would be set to negative 200? Looking at the GriefPrevention code, it looks like this would still trigger the plugin to give them new claim blocks.

RezzedUp commented 2 years ago

Looking at the GriefPrevention code, it looks like this would still trigger the plugin to give them new claim blocks.

Not quite sure where you're seeing that because it only adjusts accrued claimblocks if they're less than the config's default value. Bonus claimblocks are a separate value and aren't affected by that.

GriefPrevention calculates remaining claimblocks by adding accrued claimblocks with bonus claimblocks, and since bonus claimblocks can be negative (and aren't reset to a minimum amount), subtracting traded claimblocks from the bonus amount works as intended. Here are a few screenshots of a trade in action:

Trophonix commented 2 years ago

I was mistaken when looking at the GriefPrevention code, I was seeing a section which restored claim blocks to a player when their total claimed land exceeded their total claim blocks.