Doing this, along with obfuscation makes it REALLY hard, if not impossible (Unless for beasts like graham, Galkon) for people to get on with cheat clients.
Client-sided
Code:
/**
*
* Cheat client packets, defined in client.java.
* @author Arno
*
*
*/
public final class CheatPackets
{
public static int packet1;
public static int packet2;
public static int packet3;
public static int packet4;
public static int packet5;
public static int packet6;
public static int packet7;
public static int packet8;
}
In public client():
Code:
CheatPackets.packet1 = ****;
CheatPackets.packet2 = ****;
CheatPackets.packet3 = ****;
CheatPackets.packet4 = ****;
CheatPackets.packet5 = ****;
CheatPackets.packet6 = ****;
CheatPackets.packet7 = ****;
CheatPackets.packet8 = ****;
Assign numbers.
Private void login:
Code:
stream.writeDWord(CheatPackets.packet1);
stream.writeDWord(CheatPackets.packet2);
stream.writeDWord(CheatPackets.packet3);
stream.writeDWord(CheatPackets.packet4);
stream.writeDWord(CheatPackets.packet5);
stream.writeDWord(CheatPackets.packet6);
stream.writeDWord(CheatPackets.packet7);
stream.writeDWord(CheatPackets.packet8);
Makes client send out data to server.
Code:
if (k == 22) //Good fight fucking cheaters. TTYL.
{
loginMessage1 = "Cheatclient detected!";
loginMessage2 = "Please use the official Webclient/Client!";
return;
}
Making opcode, in case packets are NOT met.
Server-sided:
Code:
int packet1 = in.getInt();
int packet2 = in.getInt();
int packet3 = in.getInt();
int packet4 = in.getInt();
int packet5 = in.getInt();
int packet6 = in.getInt();
int packet7 = in.getInt();
int packet8 = in.getInt();
And:
Code:
final int[] cheatPackets = {packet1, packet2, packet3, packet4, packet5, packet6, packet7, packet8};
for (int i = 0; i < Config.CHEATPACKETS.length; i++)
if (Config.CHEATPACKETS[i] != cheatPackets[i]) {
returnCode = 22;
}
Don't forget making packets load into load method. (twice).
Config reference:
Code:
public static final int[] CHEATPACKETS =
/**P1****P2***P3***P4****P5***P6**P7**P8***/
{****,****,****,****,****,****,****,****} ;
NOTE: This is written in a very unclear way, so people will have to spend time before actually implementing this.
Don't say thanks, there's a button for that