Extend nonMembersCanInteractWithDoors to include fence gates#1956
Extend nonMembersCanInteractWithDoors to include fence gates#1956
Conversation
Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com> Agent-Logs-Url: https://github.com/Dans-Plugins/Medieval-Factions/sessions/aa00cee7-8c92-453d-8111-6d724c4dd2c9
There was a problem hiding this comment.
Pull request overview
Extends the existing “allow non-members to interact with doors” protection exception so it also applies to fence gates, preventing players from bypassing the intended accessibility policy by using gates instead of doors.
Changes:
- Add
org.bukkit.block.data.type.Gateto the door/trapdoor interaction bypass condition. - Add a unit test covering fence gate interaction when the config option is enabled.
- Update
CONFIG.mdto document that fence gates are included.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/main/kotlin/com/dansplugins/factionsystem/listener/PlayerInteractListener.kt |
Extends the interaction bypass condition to include Gate. |
src/test/kotlin/com/dansplugins/factionsystem/listener/PlayerInteractListenerTest.kt |
Adds a new test validating fence gate interaction is allowed when the config is enabled. |
CONFIG.md |
Updates config documentation to mention trapdoors and fence gates. |
| // Handle door/trapdoor/fence gate special case | ||
| if (plugin.config.getBoolean("factions.nonMembersCanInteractWithDoors")) { | ||
| if (clickedBlock.blockData is Door || clickedBlock.blockData is TrapDoor) { | ||
| if (clickedBlock.blockData is Door || clickedBlock.blockData is TrapDoor || clickedBlock.blockData is Gate) { | ||
| return | ||
| } | ||
| } |
There was a problem hiding this comment.
The nonMembersCanInteractWithDoors early-return happens before the claim/wilderness lookup, so enabling this option currently bypasses wilderness interaction protection as well (and now does so for fence gates too). If the intent is “in faction territory” (per CONFIG.md), consider moving this special-case to after the claim is resolved (only apply it when claim != null).
| // Handle door/trapdoor/fence gate special case | ||
| if (plugin.config.getBoolean("factions.nonMembersCanInteractWithDoors")) { | ||
| if (clickedBlock.blockData is Door || clickedBlock.blockData is TrapDoor) { | ||
| if (clickedBlock.blockData is Door || clickedBlock.blockData is TrapDoor || clickedBlock.blockData is Gate) { |
There was a problem hiding this comment.
Minor: blockData is already read into a local (val blockData = clickedBlock.blockData) earlier in this method. Reusing that variable here would avoid re-fetching clickedBlock.blockData three times and keeps the condition a bit cleaner.
| if (clickedBlock.blockData is Door || clickedBlock.blockData is TrapDoor || clickedBlock.blockData is Gate) { | |
| if (blockData is Door || blockData is TrapDoor || blockData is Gate) { |
|
@copilot address comments |
The
factions.nonMembersCanInteractWithDoorsconfig option only checked forDoorandTrapDoorblock data types, so fence gates in faction territory were fully protected. Players could cheaply gate off areas with fence gates to bypass the intended door accessibility policy.Adds
org.bukkit.block.data.type.Gateto the existing check:PlayerInteractListener.kt— IncludeGatein the door interaction bypassPlayerInteractListenerTest.kt— Add fence gate test mirroring existing door/trapdoor testsCONFIG.md— Update description to reflect fence gate coverageConfig key name unchanged for backward compatibility.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
hub.spigotmc.org/usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.lang.invoke=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.prefs/java.util.prefs=ALL-UNNAMED --add-opens java.prefs/java.util.prefs=ALL-UNNAMED --add-opens java.base/java.nio.charset=ALL-UNNAMED --add-opens java.base/java.net=ALL-UNNAMED --add-opens java.base/java.util.concurrent.atomic=ALL-UNNAMED -XX:MaxMetaspaceSize=256m(dns block)jitpack.io/usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.lang.invoke=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.prefs/java.util.prefs=ALL-UNNAMED --add-opens java.prefs/java.util.prefs=ALL-UNNAMED --add-opens java.base/java.nio.charset=ALL-UNNAMED --add-opens java.base/java.net=ALL-UNNAMED --add-opens java.base/java.util.concurrent.atomic=ALL-UNNAMED -XX:MaxMetaspaceSize=256m(dns block)repo.dansplugins.com/usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.lang.invoke=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.prefs/java.util.prefs=ALL-UNNAMED --add-opens java.prefs/java.util.prefs=ALL-UNNAMED --add-opens java.base/java.nio.charset=ALL-UNNAMED --add-opens java.base/java.net=ALL-UNNAMED --add-opens java.base/java.util.concurrent.atomic=ALL-UNNAMED -XX:MaxMetaspaceSize=256m(dns block)repo.extendedclip.com/usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.lang.invoke=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.prefs/java.util.prefs=ALL-UNNAMED --add-opens java.prefs/java.util.prefs=ALL-UNNAMED --add-opens java.base/java.nio.charset=ALL-UNNAMED --add-opens java.base/java.net=ALL-UNNAMED --add-opens java.base/java.util.concurrent.atomic=ALL-UNNAMED -XX:MaxMetaspaceSize=256m(dns block)repo.mikeprimm.com/usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.lang.invoke=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.prefs/java.util.prefs=ALL-UNNAMED --add-opens java.prefs/java.util.prefs=ALL-UNNAMED --add-opens java.base/java.nio.charset=ALL-UNNAMED --add-opens java.base/java.net=ALL-UNNAMED --add-opens java.base/java.util.concurrent.atomic=ALL-UNNAMED -XX:MaxMetaspaceSize=256m(dns block)repo.rpkit.com/usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.lang.invoke=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.prefs/java.util.prefs=ALL-UNNAMED --add-opens java.prefs/java.util.prefs=ALL-UNNAMED --add-opens java.base/java.nio.charset=ALL-UNNAMED --add-opens java.base/java.net=ALL-UNNAMED --add-opens java.base/java.util.concurrent.atomic=ALL-UNNAMED -XX:MaxMetaspaceSize=256m(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
⌨️ Start Copilot coding agent tasks without leaving your editor — available in VS Code, Visual Studio, JetBrains IDEs and Eclipse.