As you may (or may not) know, you can use FileFilters from java.io.File to only list files that fit certain specs. I thought it would be good to have a similar functionality in the API, but for packets that are sent to the clients. This would make it easier to intercept chat-, entity-, etc. packets, maybe modify their data, before they’re sent to the the client.
For example (this is just an idea):
Server.addPacketFilter(typeOfPacket, new PacketFilter() {
@Override public boolean filter(Packet pck) {
if (((Player)pck.target).getName().equals("Player"))
return false;
else
return true;
}
});
Would cancel all packets of type “typeOfpacket” that are sent to the player named “Player”.
What do you think? Would sth like this be helpful (or possible)?
I also would love to see that. I only see 1 problem. All these packets . Will give a class explosion in the API. I don’t know if it is possible to generalize every packet in 1 packet class.
Well thats just the problem. If we have to make an interface for every packet … . I guess @gratimax is right. We will need a sponge addon mod for this. I say mod because a plugin can’t solve the problem. On the positive sight. That addon won’t need to do reflection or other hacky stuff in order to get things done.