Repository navigation
fix(war): pass the war accept event its guilds in the right order - #830
Merged
Merged
Conversation
GuildWarAcceptEvent declares its guild parameters challenger then defender and hands the defender to GuildEvent as event.guild. The call site in CommandWar passed them the other way round, so event.challenger held the defending guild, event.defender held the challenging guild, and event.guild reported the challenger as the guild that accepted. accept() only runs for the defender, since it refuses unless challenge.defender is the sender's guild, so the command's guild is always the defender and swapping the two arguments is always wrong. The decline and challenge call sites already pass challenger first. The event's own callers were the only ones affected. Nothing in this plugin reads these properties back.
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.
Summary
GuildWarAcceptEventtakes its two guilds challenger-then-defender and passes the defender toGuildEventasevent.guild.CommandWar.accept()passed them the other way round.fun accept(player: Player, guild: Guild) { val challenge = challengeHandler.getChallenge(guild) ?: ... val challenger = challenge.challenger + // challenge.defender == guild, so guild is the defender - val event = GuildWarAcceptEvent(player, guild, challenger) + val event = GuildWarAcceptEvent(player, challenger, guild)What a listener saw before and after:
event.challengerevent.defenderevent.guildEvidence
accept()refuses unlesschallenge.defender == guild, so the command'sguildis always the defender. Position 2 ischallengerand position 3 isdefender, so the old call handed each guild the other's slot.The two sibling call sites already pass challenger first and are untouched:
./gradlew test testJava11passes.Testing
No test was added. Nothing under
src/testreferencedGuildWarAcceptEventand there were no war command tests to extend. Covering this would need a new pattern for driving aBaseCommandsubclass: the handler reaches forBukkit.getPluginManager(), and the code after the event fires needs ACF'scurrentCommandManager, which does not exist without a server. The existing suite tests handlers and domain objects directly rather than commands, so this would be new scaffolding, which is out of scope here.Merge Danger
Door: two-way
Reverts with a single commit.
Blast Radius: plugin API consumers
GuildWarAcceptEvent's constructor signature is unchanged, so nothing breaks at compile time. Listeners readingchallenger,defenderorguildget the correct guild going forward. Listeners that worked around the swap will need updating.