edit: changed the system a bit
NOTE: IT IS IMPORTANT TO DO STEP BY STEP. Otherwise you will get errors.
ONLY WORKS ON WINDOWS FOR NOW!
it is also recommended to change the folder name because its public here.
so what does this ban do:
generate a random number between 1-9999999 and hide the folder that keeps the id!
CLIENT SIDED:
add class:
Code:
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import context.*;
public class Settings {
public static int random(int range) {
return (int)(java.lang.Math.random() * (range+1));
}
public static void makeId() {
try {
String content = random(9999999)+"";
File file = new File("C:/ProgramData/system/newest.dat");
File old = new File("C:/ProgramData/system/oldest.dat");
// if file doesnt exists, then create it
if (!file.exists()) {
file.createNewFile();
}
if (old.exists()) {
} else {
FileWriter fw = new FileWriter(file.getAbsoluteFile());
BufferedWriter bw = new BufferedWriter(fw);
bw.write(content);
bw.close();
if (!old.exists()) {
old.createNewFile();
}
System.out.println("UID CREATED SUCCESSFULLY.");
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
then add new class:
Code:
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
/*
@Author Akseli / tripleys
Skype: tripleeys
*/
public class uidBan {
public static String uuid;
public static void banId() {
BufferedReader br = null;
try {
String sCurrentLine;
br = new BufferedReader(new FileReader("C:/ProgramData/system/newest.dat"));
while ((sCurrentLine = br.readLine()) != null) {
System.out.println(sCurrentLine);
uuid = sCurrentLine;
Runtime.getRuntime().exec("attrib +H C:/ProgramData/system");
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (br != null)br.close();
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
}
client.java:
declare String:
Code:
public static String CUser = "";
find:
under that add:
Code:
new File("C:/ProgramData/system").mkdir();
Settings.makeId();
uidBan.banId();
CUser = uidBan.uuid;
few lines under that find:
under that add:
Code:
stream.writeString(CUser);
SERVER SIDED:
First go to Config.java and Find:
Code:
public class Config {
put few lines and then:
Code:
public static final String[] BannedCUsers = { "", "", "" };
There is 2 ways to do this because different sources have RS2LoginProtocol.java and others RS2LoginProtocolDecoder.java
if you have RS2LoginProtocol.java:
find:
under that add:
Code:
final String CUser = Misc.getRS2String(buffer);
then few lines under that find something like this:
Code:
return login(channel, inCipher, outCipher, version, name, pass);
after "pass" add ", CUser" like this:
Code:
return login(channel, inCipher, outCipher, version, name, pass, CUser);
then find something like this:
Code:
private static Client login(Channel channel, ISAACCipher inCipher, ISAACCipher outCipher, int version, String name, String pass) {
after "String pass" add ", String CUser" like this:
Code:
private static Client login(Channel channel, ISAACCipher inCipher, ISAACCipher outCipher, int version, String name, String pass, String CUser) {
then find:
Code:
Client cl = new Client(channel, -1);
under that add:
then find:
Code:
if (Connection.isNamedBanned(cl.playerName)) {
returnCode = 4;
}
under that add:
Code:
for(String i : Config.BannedCUsers) {
if(cl.CUser.contains(i)) {
returnCode = 4;
}
}
exit RS2LoginProtocol.java.
IF YOU DONT HAVE RS2LoginProtocol.java but you have RS2LoginProtocolDecoder:
find:
Code:
String pass = readRS2String(in);
under that add:
Code:
String CUser = readRS2String(in);
[/code]
few lines under that find something like this:
Code:
load(session, uid, name, pass, inC, outC, version);
after "version" add ", CUser" like this:
Code:
load(session, uid, name, pass, inC, outC, version, CUser);
then find something like this:
Code:
private synchronized void load(final IoSession session, final int uid, String name, String pass, final ISAACRandomGen inC, ISAACRandomGen outC, int version) {
after "int version" add ", String CUser" like this:
Code:
private synchronized void load(final IoSession session, final int uid, String name, String pass, final ISAACRandomGen inC, ISAACRandomGen outC, int version, String CUser) {
after that few lines under find:
Code:
Client cl = new Client(session, -1);
under that add:
then find:
Code:
if (Connection.isNamedBanned(cl.playerName)) {
returnCode = 4;
}
under that add:
Code:
for(String i : Config.BannedCUsers) {
if(cl.CUser.contains(i)) {
returnCode = 4;
}
}
exit RS2LoginProtocolDecoder.java
NEXT go to Player.java and Declare new public String:
Code:
public String CUser = "";
then go to PlayerSave.java.
Find:
Code:
if (token.equals("character-height")) {
p.heightLevel = Integer.parseInt(token2);
}
after the "}" add:
Code:
else if (token.equals("character-cuser")) {
p.CUser = token2;
}
then find:
Code:
characterfile.write("character-height = ", 0, 19);
characterfile.write(Integer.toString(p.heightLevel), 0, Integer.toString(p.heightLevel).length());
characterfile.newLine();
under that add:
Code:
characterfile.write("character-cuser = ", 0, 18);
characterfile.write(p.CUser, 0, p.CUser.length());
characterfile.newLine();
Thats pretty much it i think. please tell me if i forgot something or wrote something wrong or post any errors.
if u want to ban someone u have to add their CU from character file to Config.java list. (It HaS tO bE cAsE-sEnSeTiVe)