Disconnect client by throwing exception in handler

This makes it easier to add checks in handlers, which should improve security over time.
I think this approach is more readable and testable than calling Client#disconnect straight up,
while it also decentralizes the handling.
This commit is contained in:
P0nk
2023-08-06 15:48:49 +02:00
parent e9819fac87
commit 2686b2b02d
36 changed files with 180 additions and 106 deletions

View File

@@ -34,6 +34,7 @@ import constants.id.MapId;
import constants.inventory.ItemConstants;
import constants.skills.*;
import database.drop.DropProvider;
import net.netty.GameViolationException;
import net.packet.InPacket;
import net.packet.Packet;
import org.slf4j.Logger;
@@ -67,9 +68,7 @@ public final class RangedAttackHandler extends AbstractDealDamageHandler {
if (chr.getBuffEffect(BuffStat.MORPH) != null) {
if (chr.getBuffEffect(BuffStat.MORPH).isMorphWithoutAttack()) {
// How are they attacking when the client won't let them?
chr.getClient().disconnect(false, false);
return;
throw new GameViolationException("Attempt to attack with morph skill that disallows attacking");
}
}