2018-11-06 13:56:24 +01:00
|
|
|
package extensions.blockreplacepackets.rules;
|
|
|
|
|
|
|
|
import gearth.protocol.HMessage;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Created by Jonas on 6/11/2018.
|
|
|
|
*/
|
|
|
|
public class BlockPacketRule extends BlockReplaceRule{
|
|
|
|
|
|
|
|
private int headerId;
|
|
|
|
private Side side;
|
|
|
|
|
|
|
|
BlockPacketRule(Side side, int headerId) {
|
|
|
|
this.headerId = headerId;
|
|
|
|
this.side = side;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void appendRuleToMessage(HMessage message) {
|
|
|
|
if (side == Side.ALL
|
2020-04-24 23:16:02 +02:00
|
|
|
|| (message.getDestination() == HMessage.Direction.TOSERVER && side == Side.OUTGOING)
|
|
|
|
|| (message.getDestination() == HMessage.Direction.TOCLIENT && side ==Side.INCOMING)) {
|
2018-11-06 13:56:24 +01:00
|
|
|
if (message.getPacket().headerId() == headerId) {
|
|
|
|
message.setBlocked(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Option option() {
|
|
|
|
return Option.BLOCK;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Type type() {
|
|
|
|
return Type.PACKET;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Side side() {
|
|
|
|
return side;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String value() {
|
|
|
|
return headerId+"";
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String replacement() {
|
2018-11-06 20:32:36 +01:00
|
|
|
return "/";
|
2018-11-06 13:56:24 +01:00
|
|
|
}
|
|
|
|
}
|