Skip to content

fix: prevent food crops being planted indoors or underground - #62

Merged
XxFran10xX merged 2 commits into
mainfrom
fix/outdoor-crop-planting
Oct 1, 2026
Merged

XxFran10xX merged 2 commits into
mainfrom
fix/outdoor-crop-planting

Conversation

@XxFran10xX

@XxFran10xX XxFran10xX commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Food crops could be planted under cave ceilings and house roofs. Require an open column above vanilla and CustomCrops planting, including Cooking's automatic replanting. Glass greenhouses are allowed by default; nether wart, mushrooms, and CustomCrops yeast remain exempt. Existing planted crops and growth rules are unchanged.

Add reloadable crops.yml options for requiring open sky, allowing glass roofs, additional allowed roof materials, and vanilla/custom crop exemptions. Existing configs use these defaults without migration.

Validation: Maven verify passed all 290 tests, including 14 planting cases for stone/wood roofs, glass greenhouses, world height, custom crops, configuration and fungal exceptions. TFMCDev01 enabled the final DEV-20261001-greenhouses build and reached Paper Done. In-game tests passed: open-sky wheat allowed, stone roof denied without seed consumption and with feedback, glass greenhouse wheat allowed, nether wart allowed indoors. Test blocks were restored. GitHub CI passed and CodeRabbit approved.

@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: d046e413-0454-4250-b3f7-d810a7ab3604

📥 Commits

Reviewing files that changed from the base of the PR and between 44d3e9c and 777be74.

📒 Files selected for processing (5)
  • README.md
  • src/main/java/net/tfminecraft/cooking/crops/CropPlantingRule.java
  • src/main/java/net/tfminecraft/cooking/crops/CropsLoader.java
  • src/main/resources/crops.yml
  • src/test/java/net/tfminecraft/cooking/crops/CropPlantingTest.java

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.


📝 Summary

Summary by CodeRabbit

  • New Features
    • Most vanilla and CustomCrops crops now require open sky when planted. Glass roofs are allowed by default; other overhead blocks prevent planting.
    • Nether wart, red and brown mushrooms, and yeast are exempt by default.
    • Planting requirements, allowed roof materials and crop exemptions can be configured. Existing crop settings are handled when the configuration is reloaded.

Walkthrough

Vanilla and CustomCrops planting now checks whether crops require open sky and whether the planting location has it. The change adds configurable exemptions and allowed covers, registers planting listeners, and documents the rules.

Changes

Crop planting rules

Layer / File(s) Summary
Define and configure open-sky rules
src/main/java/net/tfminecraft/cooking/crops/CropPlantingRule.java, src/main/java/net/tfminecraft/cooking/crops/CropsLoader.java, src/main/resources/crops.yml, src/test/java/net/tfminecraft/cooking/crops/CropPlantingTest.java
The rule checks for obstructions above the planting location and applies configured crop exemptions and allowed covers. The loader applies or resets the configuration. Tests cover sky checks, exemptions, covers and planting outcomes.
Enforce rules on planting events
src/main/java/net/tfminecraft/cooking/crops/CropPlantingListener.java, src/main/java/net/tfminecraft/cooking/crops/CropCustomCropsListener.java, src/main/java/net/tfminecraft/cooking/Cooking.java, README.md
Listeners cancel vanilla or CustomCrops planting when open sky is required but absent. The plugin registers the block-placement listener. The README describes the rules and configuration.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant Bukkit as Bukkit block placement event
  participant Planting as CropPlantingListener
  participant CustomEvent as CustomCrops planting event
  participant CustomListener as CropCustomCropsListener
  participant Rule as CropPlantingRule
  participant Player
  Bukkit->>Planting: Check block placement
  Planting->>Rule: Check crop requirement and open sky
  Rule-->>Planting: Return check results
  Planting->>Player: Cancel placement and send denial if required
  CustomEvent->>CustomListener: Check crop planting
  CustomListener->>Rule: Check crop requirement and open sky
  Rule-->>CustomListener: Return check results
  CustomListener->>Player: Cancel planting and send denial if required
Loading

Suggested reviewers: ryanbarlow97

Merge Risk: ⚪ Minimal · up to 777be

The planting restrictions and configurable exceptions have no identified merge-blocking defect. Complete the planned build and in-game smoke test before release.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 777be

The planting restriction uses existing event and administrative configuration paths. Cooking’s automatic replanting honors cancellation and returns the reserved seed. No new player configuration authority was established, but external crop-plugin behavior and runtime integration remain incompletely verified.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The shared static policy affects participating planting paths across the Cooking server instance, rather than being scoped per player or world. Ordinary players influence crop identity and placement location; policy changes come from the server configuration lifecycle.

Trust Boundaries and Controls

  • observed — The loader reads crops.yml from Cooking’s data folder. The normal reload command requires cooking.admin, declared with an operator default, and invokes the existing reload lifecycle. Public Java lifecycle methods are not internally permission-guarded; the inspected boundary is the command declaration, not protection against an already privileged in-process plugin.

Resilience and Maintainability Implications

  • observed — The delayed automatic replant retains crop identity and a seed copy, then checks player presence and block emptiness before placement. Cancellation or a failed build check attempts to restore the previous block state and drops the seed; successful placement proceeds to effects without scheduling another replant. This establishes repository-local recovery branches, not durable recovery across server interruption.
  • inferred — Observed startup and command calls apply configuration directly, and automatic replant uses the synchronous task scheduler. These paths support serialized policy consumption under the normal Bukkit lifecycle. Configuration nevertheless updates several static fields sequentially; coherence for external asynchronous API callers is not established.
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


Comment @coderabbitai help to get the list of available commands.

coderabbitai[bot]
coderabbitai Bot previously approved these changes Oct 1, 2026
@XxFran10xX
XxFran10xX merged commit 01298b4 into main Oct 1, 2026
2 checks passed
@XxFran10xX
XxFran10xX deleted the fix/outdoor-crop-planting branch October 1, 2026 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant