Skip to content

ConcurrentModificationException in serverTick, unvalidated SoulKillPayload, and other issues #6

@printerts

Description

@printerts

Bug Report: Several issues found in spell/soul systems

Hey! I was reading through the source and noticed a few bugs worth flagging. Happy to submit a PR for any of these if that'd be helpful.


🔴 SpellDataComponent.serverTick() will crash with ConcurrentModificationException

File: src/main/java/org/aussiebox/wingcrafter/cca/SpellDataComponent.java

The serverTick() method iterates over spellCooldowns and spellDurations while removing entries from them mid-loop. This will throw a ConcurrentModificationException at runtime as soon as any spell with a duration is active.

Fix: Collect keys to remove in a separate list, then remove after the loop:

List<String> toRemove = new ArrayList<>();
for (String spell : spellCooldowns.keySet()) {
    int cooldown = spellCooldowns.getInt(spell);
    if (cooldown - 1 <= 0) { toRemove.add(spell); continue; }
    spellCooldowns.put(spell, cooldown - 1);
}
toRemove.forEach(spellCooldowns::removeInt);

🔴 SoulKillPayload should be server-validated

File: src/main/java/org/aussiebox/wingcrafter/Wingcrafter.java

The server kills the player whenever it receives a SoulKillPayload from the client, with no check that the player's soul is actually at 0. A client could send this packet at any time to trigger an instant death.

Fix: Add a soul check before applying damage:

if (SoulComponent.KEY.get(player).getSoul() <= 0) {
    player.damage((ServerWorld) world, damageSource, 524);
}

🟡 FrostbeamSpell applies soul penalty twice

File: src/main/java/org/aussiebox/wingcrafter/spells/FrostbeamSpell.java

afflictSoulPenalty() is called via super.cast() (costing 3 soul), but then data.changeSoul(-5) and data.changeSoul(-10) are also called manually in the same method. The soul cost is inconsistent and stacks unexpectedly.


🟠 SpellRegistry has leftover test entries

File: src/main/java/org/aussiebox/wingcrafter/spells/util/SpellRegistry.java

test1 through test4 are registered and will appear in the spell selection UI for players.


Let me know if a PR would be welcome!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions