feat: Added increment-block-statistics - #90
Open
awdrgyj8 wants to merge 19 commits into
Open
Conversation
MagicTeaMC
requested changes
Apr 4, 2026
MagicTeaMC
requested changes
Apr 4, 2026
MagicTeaMC
left a comment
Member
There was a problem hiding this comment.
Statistic might be double-counted if call-block-break-event is also true, any idea to prevent?
BTW, please allow me to edit this PR
| import org.milkteamc.autotreechop.Config; | ||
| import org.milkteamc.autotreechop.PlayerConfig; | ||
|
|
||
| import static org.bukkit.Statistic.MINE_BLOCK; |
Member
There was a problem hiding this comment.
import org.bukkit.Statistic, don't use static
| } | ||
|
|
||
| if (config.isIncrementBlockStatistics()) { | ||
| Material leafMaterial = leafBlock.getType(); |
Author
|
Of course. Thank you for reviewing my PR. |
Chopped blocks were always dropped on the ground with breakNaturally(), which leaves logs scattered around the top of a large tree where the player cannot reach them. Adds an opt-in auto pickup path: drops are read with block.getDrops(tool, player) before the block is cleared, so Fortune, Silk Touch and the tool type are respected exactly like a vanilla break. Both the log phase and the leaf phase (when leaf-removal-drop-items is on) are covered; the log the player originally broke is included since it is part of the BFS result and goes through the same path. Drops are accumulated during the batches and handed over once in the batch completion callback, next to the existing statistic flush and tool damage. That keeps inventory mutation out of the per-block loop and means at most one "inventory full" message per chop. Whatever does not fit is dropped at the player's feet. Gated behind enable-auto-pickup (default false, so existing servers are unaffected) and the new autotreechop.autopickup permission (default true), following the existing config-flag-and-permission pattern. Since setType(AIR) shows no break particles where breakNaturally() did, EffectUtils.showBlockBreakEffect() restores them under the existing visual-effect option. It emits particles only, so it does not double up on the playBreakSound option. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016MjYARRStYz4VsBfGJuAHi
…types Two related leaf-removal bugs reported for jungle trees: 1. VINE was never in the default leaf-types list, so isLeafBlock() always rejected it — vines on jungle logs/leaves were never even considered for removal. Added VINE to config.yml's leaf-types. 2. Leaf capture/discovery was centered on the single block the player broke, with a fixed radius (leaf-removal-radius). Trunk discovery has no such radius limit (BFS up to max-tree-size), so on very tall trees — giant/mega jungle trees are commonly 20-30 blocks tall — the canopy near the top can sit well outside that fixed sphere while the whole trunk still gets chopped, leaving the topmost leaves and vines untouched. executeTreeChop now derives the leaf capture center from the vertical midpoint of the whole discovered trunk (treeBlocks), and grows the radius by half the trunk's vertical span so the capture sphere always reaches from the lowest to the highest log plus the configured margin. Short trees are unaffected (span ~0, same behavior as before). The grown radius is capped at MAX_LEAF_CAPTURE_RADIUS (32) since captureLeafRegion runs synchronously on the main/region thread — protects against a pathologically tall block stack turning into an enormous scan. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VwwgSu7Yw29tb4XS8F3crn
…ollect-nup72g Claude/plugin tree auto collect nup72g
The 2x2 replant formation could be planted up to one block off on each axis from the trunk that was actually chopped. Two causes stacked: * The log recorded as the replant anchor was "the first log with the lowest Y", and a 2x2 trunk's four base logs all share that Y. The discovery set is a HashSet, so the winner was an arbitrary one of the four corners. * isLikely2x2Tree() already scanned the chopped-log set and computed the trunk's real minimum-corner anchor, but discarded it and returned only a boolean. find2x2PlantLocation() then re-guessed the anchor from that arbitrary corner, trying the origin-as-minimum-corner candidate first. With the tree gone the ground is flat, so the offset square passed the clear-and-soil check and was accepted. Dark Oak and Pale Oak skipped the footprint scan entirely, so their anchor was always a guess. Return the anchor from the footprint scan instead of a boolean and plant on it, falling back to the search only when that footprint is no longer plantable or was never detected (partial chop). Run the scan for Dark Oak and Pale Oak too, keeping their unconditional 2x2 behaviour via isAlways2x2(). Also order the anchor candidates by Y, then X, then Z, so the recorded corner is the minimum one and, above all, deterministic on the fallback path. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DLvC3xDtLN8xhL6fok7RKW
…-misalignment-eol4ae Fix 2x2 sapling replant landing offset from the chopped trunk
Auto pickup was an all-or-nothing server setting: once enable-auto-pickup was on, every player with the permission had chopped drops forced into their inventory. Players who want the drops on the ground had no way out. Add /atc autopickup (alias /atc pickup) as a self-only toggle, mirroring the existing /atc toggle. The choice is stored per player in the player_data table so it survives relogs and restarts, and is refused when auto pickup is off server-wide so nobody stores an "on" that does nothing. The new autoPickupEnabled column is added to tables created by older versions via a JDBC-metadata check plus ALTER TABLE, defaulting existing players to on so behaviour does not change under them. New players follow the new defaultAutoPickup config key.
…e-design-xxsvdy Add a per-player auto pickup toggle command
Guarding the subcommand with autotreechop.autopickup made Lamp drop it from tab completion and answer "unknown command" for anyone missing the node, so a player whose permission had been revoked could not tell the feature apart from one that does not exist. Guard on autotreechop.use like the other self-service subcommands and check the auto pickup node in the body, so the refusal is an explicit no-permission message.
When enable-auto-pickup is false the feature is off for everyone, so answering "you do not have permission" pointed the player at a permission node that would not have helped. Check the config flag first and report that the server has auto pickup disabled.
Auto pickup is a paid feature, so defaulting the node to true handed it to everyone as soon as a server turned enable-auto-pickup on. Default it to op, the same tier autotreechop.vip already uses, so it has to be granted to the ranks that paid for it.
en and zh were rewritten with hardcoded colours in 0602c28, which took them out of the styles.properties system while de/ja/ms/ru stayed in it, and the later locales copied the hardcoded form. Editing prefix in styles.properties therefore did nothing for most of the server's players. Wrap every chat message in all ten locales in <prefix> or <prefix_negative> so the prefix and the colour scheme are defined once in styles.properties. consoleName is a placeholder value rather than a message, and the four about lines are one block where a repeated prefix would be noise, so both keep raw MiniMessage. Default styles.properties values are unchanged, so the plugin still renders exactly as before until a server puts a prefix in front of {slot}; its comments now explain the two tags. Also drop the trailing full stop from every zh message, keeping the one that separates two sentences inside the three confirmation prompts.
…e-design-xxsvdy Refine the auto pickup toggle and restore the prefix style system
removeLeafBlock() and the log batch both take the player's tool, but only the auto pickup branch used it: the other branch called breakNaturally() with no argument, which rolls drops as if the block had been broken with nothing in hand. The result was that auto pickup, a setting about where drops end up, silently decided what they are. With leaf-removal-drop-items enabled, a player with auto pickup on got leaf blocks from a Silk Touch axe and extra saplings from Fortune, while a player with it off got neither from the exact same axe. Route both branches through DropCollectionUtils.breakNaturally(), which mirrors the null/AIR tool handling collectDrops() already does, so the two paths cannot drift apart again. The log branch has no visible change today (logs drop themselves regardless of enchantments) but had the same defect. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Xsw1ZoP2KD2x9oEBVXJuwu
…rop-items leaf-removal-drop-items is an all-or-nothing switch: leaving it off (the default) means leaves vanish even for a Silk Touch axe, and turning it on showers every player with saplings, sticks and apples. Servers that want the vanilla Silk Touch behaviour had to accept the litter as well. Add leaf-removal-silk-touch-drops (default true), checked alongside the existing flag when deciding whether a leaf yields anything. Once either says yes, the drops themselves are already correct: both the auto pickup and the ground-drop path read the tool, so Silk Touch produces the leaf block and an unenchanted axe the usual sapling roll. The enchantment is resolved once per chop next to the auto pickup lookup, not per leaf, since the tool cannot change while a removal is running. Shears are deliberately not recognised: chain chopping starts from a log break, so shears never reach this path in practice. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Xsw1ZoP2KD2x9oEBVXJuwu
removeLeafBlock() read leafBlock.getType() after removing the block, so every leaf resolved to AIR: with increment-block-statistics enabled the player's stats file accumulated minecraft:mined -> minecraft:air, the real per-leaf statistics stayed at zero, and because Material was the map key all leaf types collapsed into that one bogus entry. Capture the type before the break, matching how originalLogType is already handled on the log side. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Xsw1ZoP2KD2x9oEBVXJuwu
…f-drop-xwfxuu Claude/silk touch axe leaf drop xwfxuu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a new boolean config option
increment-block-statistics(default: false) that callsplayer.incrementStatistic(MINE_BLOCK)for every block broken by ATC, including all chain-chopped logs and leaves removed by leaf removal. Disabled by default to preserve existing behavior.