Ir para conteúdo
  • Cadastre-se

[Tutorial]Proteção gGuard system + core + php


adventeaml2

Posts recomendados

 

 

 

 

A questão do lag é por causa da dll do kaka, porém a proteção funciona muito bem sem ela eu coloquei na época por quê pensei que seria de uma ajuda extra ... eu tirei a proteção daqui http://www.4shared.com/zip/hAaExtq6/GGuard.html ai está o link dela sem está compilada precisa ser compilada em delphi e em java

Esse link ai é do GGuard normal meu caro..

 

File is infected, tu teve algum problema ao baixar?

Editado por Marlon Raveli
Link para o comentário
Compartilhar em outros sites


qual é a dll do kaka? a gGuard.dll ?

Link para o comentário
Compartilhar em outros sites

  • 2 weeks later...

e agora oque vou fazer rsrsrsrsrsrsrs ficar com lagg no servidor ou terá como mudar essa dll para outra que tenha a mesma função.??? preciso de respostas pois tem muitos aqui usando essa proteção, e sei que tem auguem que conseguiu resolver.

Todas DLL que a gente (desenvolvedor) faz para checar se tem hacker em execução faz a system dar umas travadas, minha DLL faz dar estas pequenas travadas, a DLL do Kaka faz dar estas travadas, até mesmo a DLL que o NaldinhU fez dá estas travadas na system..

 

Se quiserem remover a DLL podem remover mas essa gGuard não vai dar proteção nenhuma se utilizarem só ela, pois a mesma foi desenvolvida muitos anos atrás e vocês só a encontram livre assim na internet pois não tem mais uso caso não implementem sistemas adicionais para "matar" os hackers em execução..

 

O motivo do LAG é que a dll hooka no processo do L2 para executar ao mesmo tempo enquanto o jogo estiver aberto, por isso que dá estas agarradas de tempo em tempo pois é sinal que o sistema está procurando por hackers abertos para poder eliminá-los.

 

Eu estou desde o ano passado desenvolvendo um sistema de proteção mais eficiente, mas fica dando estas agarradas sempre que alguma dll de checagem é hookada no processo de execução do jogo, pensei em fazer a proteção utilizando meios nativos do windows que são mais eficientes porém é mais trabalhoso pois é necessário criar restrições, creio que este ano eu consigo terminá-la.. Ainda estou estudando soluções melhores..

 

//edit antes que algum outro noob venha me enviar mensagem perguntando o que é hook, use o google ou leia o artigo abaixo:

https://msdn.microsoft.com/en-us/library/windows/desktop/ms632589(v=vs.85).aspx

Caso não saibam ler nada em inglês se virem e usem o tradutor do google..

Editado por Wallace Carvalho

Caso tenha alguma sugestão para aplicativos, por favor envie por MP.

 WhatsApp: 22 98156-2591 

L2JDREAM PROJECT

Link para o comentário
Compartilhar em outros sites

Todas DLL que a gente (desenvolvedor) faz para checar se tem hacker em execução faz a system dar umas travadas, minha DLL faz dar estas pequenas travadas, a DLL do Kaka faz dar estas travadas, até mesmo a DLL que o NaldinhU fez dá estas travadas na system..

 

Se quiserem remover a DLL podem remover mas essa gGuard não vai dar proteção nenhuma se utilizarem só ela, pois a mesma foi desenvolvida muitos anos atrás e vocês só a encontram livre assim na internet pois não tem mais uso caso não implementem sistemas adicionais para "matar" os hackers em execução..

 

O motivo do LAG é que a dll hooka no processo do L2 para executar ao mesmo tempo enquanto o jogo estiver aberto, por isso que dá estas agarradas de tempo em tempo pois é sinal que o sistema está procurando por hackers abertos para poder eliminá-los.

 

Eu estou desde o ano passado desenvolvendo um sistema de proteção mais eficiente, mas fica dando estas agarradas sempre que alguma dll de checagem é hookada no processo de execução do jogo, pensei em fazer a proteção utilizando meios nativos do windows que são mais eficientes porém é mais trabalhoso pois é necessário criar restrições, creio que este ano eu consigo terminá-la.. Ainda estou estudando soluções melhores..

Agora Sim uma Pessoa Me Deu uma explicação Concreta. Obrigado Wallace essa era Minha Duvida o Porque dessas Travadas Meio LOL rsrsrsrs

Mais antes usar com as Travadas do que Usar o Server com Hacker.

Espero que você consiga terminar esse seu Projeto.

Link para o comentário
Compartilhar em outros sites

Agora Sim uma Pessoa Me Deu uma explicação Concreta. Obrigado Wallace essa era Minha Duvida o Porque dessas Travadas Meio LOL rsrsrsrs

Mais antes usar com as Travadas do que Usar o Server com Hacker.

Espero que você consiga terminar esse seu Projeto.

Primeiramente eu ia postar a proteção minha de graça, mas como tem gente que pega aplicativos meus aqui no fórum e começam a vender por fora utilizando meu nome então decidi que a proteção será um projeto separado e privado meu, em breve postarei detalhes no meu site e na minha fanpage do facebook explicando como funciona e tal..

Caso tenha alguma sugestão para aplicativos, por favor envie por MP.

 WhatsApp: 22 98156-2591 

L2JDREAM PROJECT

Link para o comentário
Compartilhar em outros sites

Primeiramente eu ia postar a proteção minha de graça, mas como tem gente que pega aplicativos meus aqui no fórum e começam a vender por fora utilizando meu nome então decidi que a proteção será um projeto separado e privado meu, em breve postarei detalhes no meu site e na minha fanpage do facebook explicando como funciona e tal..

Bom se for Paga pra mim não importa o Importante é ter uma proteção atualizada e que seja funcional. estarei no aguardo dessa proteção e com certeza se for funcional estarei adquirindo.

Link para o comentário
Compartilhar em outros sites

Está faltando conecção com o servidor PHP

Não não estar faltando um Pouco mais de atenção da parte dele e ler o Topico Inteiro pra saber os erros que ocorre, Pois muitos aqui no topico tiveram o mesmo erro e Já foram corrigidos basta ele Procurar aqui Ler mais um Pouco que ele consegue, eu Mesmo quebrei um Pouco de cabeça, Mais parei pra ler antes de Por minha duvida aqui e vi que não ea necessário porque já tinha a resposta aqui.

Link para o comentário
Compartilhar em outros sites

Engraçado que eu consegui utilizar normalmente sem dar nenhum erro na hora de copilar e nem na hora de adicionar no core.

Esse povo que só baixa e tenta sair adicionando sem prestar atenção no que faz consegue cada erro cabuloso que eu nunca vi na vida...

Caso tenha alguma sugestão para aplicativos, por favor envie por MP.

 WhatsApp: 22 98156-2591 

L2JDREAM PROJECT

Link para o comentário
Compartilhar em outros sites

Pessoal alguem tem uma versão dessa para l2jserver high five, tipo aqui tem muitos erros, e como sou iniciante não sei oque fazer.

cara essa gGuard é pra interlude. esquece gGuard.

Pra HighFive é rGuard procura no tópico que já foi postado download

Caso tenha alguma sugestão para aplicativos, por favor envie por MP.

 WhatsApp: 22 98156-2591 

L2JDREAM PROJECT

Link para o comentário
Compartilhar em outros sites

cara essa gGuard é pra interlude. esquece gGuard.

Pra HighFive é rGuard procura no tópico que já foi postado download

Obrigado, Irei tentar Instalar aqui, Me tira uma duvida no forum não tem tutorial para a instalação ou e algo muito simples de se fazer ?

Link para o comentário
Compartilhar em outros sites

Obrigado, Irei tentar Instalar aqui, Me tira uma duvida no forum não tem tutorial para a instalação ou e algo muito simples de se fazer ?

não tem tutorial, não é necessário pois qualquer um com o mínimo de conhecimento consegue fazer

Caso tenha alguma sugestão para aplicativos, por favor envie por MP.

 WhatsApp: 22 98156-2591 

L2JDREAM PROJECT

Link para o comentário
Compartilhar em outros sites

Fiz uma gambiarra pra aCis, preciso que alguem que consiga conexão com site teste, pois aqui de casa não consigo, somente com dedicado.

Fiz com base na aCis 335 que foi postado o source aqui no fórum.

http://www.l2jbrasil.com/index.php?/topic/109408-source-acis-330-updates/

 

DboHbE5.jpg

 

 

 

Index: java/MakeClient.java
===================================================================
--- java/MakeClient.java
+++ java/MakeClient.java


import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.jar.JarEntry;
import java.util.jar.JarOutputStream;
import java.util.jar.Manifest;

import net.sf.l2j.loginserver.crypt.NewCrypt;



public class MakeClient {

	private static class FileInfo {
		File _file;
		boolean _isEncrypted;
		public FileInfo(File file, boolean isEncrypted) {
			_file = file; _isEncrypted = isEncrypted;
		}
	}
	private static String key = "";
	
	public static void addFilesToZip(File zipFile, boolean isJar,
			FileInfo[] files) throws IOException {
		System.out.println("Making "+zipFile.getName()+":");
		NewCrypt nc = new NewCrypt(key);
		if(zipFile.exists())
			zipFile.delete();
		JarOutputStream out;
		if(isJar) 
			out = new JarOutputStream(new FileOutputStream(zipFile),new Manifest());
		else 
			out = new JarOutputStream(new FileOutputStream(zipFile));
		
		for (int i = 0; i < files.length; i++) {
			InputStream in = new FileInputStream(files[i]._file);
			// Add ZIP entry to output stream.
			String fname;
			if(isJar) {
				fname = files[i]._file.getPath().replace("\\", "/");
				if (fname.indexOf("com")!=-1)
					fname = fname.substring(fname.indexOf("com"));
				
			}
			else 
				fname = files[i]._file.getName();
			
			JarEntry toJar = new JarEntry(fname);
			System.out.print(" adding "+files[i]._file.getName()+"...");
			toJar.setTime(files[i]._file.lastModified());
			out.putNextEntry(toJar);
			// Transfer bytes from the file to the ZIP file
			byte [] data = new byte[in.available()];
			in.read(data);
			if(files[i]._isEncrypted) {
				data = nc.crypt(data);
				System.out.println("encrypted");
			} else System.out.println("stored");
			out.write(data,0,data.length);
			out.closeEntry();
			in.close();
		}
		// Complete the ZIP file
		out.close();
	}
	public static void main(String[] args) {
		try {
			InputStreamReader converter = new InputStreamReader (System.in);
			BufferedReader		in = new BufferedReader (converter);
			key = in.readLine();
			if(key.length()==0)
				return;
			key = key.toUpperCase();
			if(key.length()!=6) {
				System.err.println("Key must contains six hexdecimal dights");
				System.exit(1);
				return;
			}
				
			for(int i = 0;i <key.length();i++)
				if(!"0123456789ABCDEF".contains(key.substring(i,i+1))) {
					System.err.println("Key must contains six hexdecimal dights");
					System.exit(1);
					return;
				}
			key = key+"00";
			addFilesToZip(new File("dist/gGuard.jar"), true ,new FileInfo[] {
																   new FileInfo(new File("./bin/net/sf/l2j/protection/Loader.class"),false),
																   new FileInfo(new File("./bin/net/sf/l2j/protection/main.class"),false),
																   new FileInfo(new File("./bin/net/sf/l2j/protection/bin/GameGuardManager.class"),true),
																   new FileInfo(new File("./bin/net/sf/l2j/protection/bin/GGSender.class"),false),
																   new FileInfo(new File("./bin/net/sf/l2j/protection/bin/GGTask.class"),false),
																   new FileInfo(new File("./bin/net/sf/l2j/protection/bin/Restriction.class"),false)
																   
																   			});
			
		} catch (IOException e) {
			e.printStackTrace();
		}
		System.exit(0);

	}

}


Index: java/net/sf/l2j/protection/Loader.java
===================================================================
--- java/net/sf/l2j/protection/Loader.java
+++ java/net/sf/l2j/protection/Loader.java

package net.sf.l2j.protection;

import java.io.BufferedReader;
import java.io.File;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;

import net.sf.l2j.Config;
import net.sf.l2j.Base64;
import net.sf.l2j.loginserver.crypt.NewCrypt;


public class Loader extends ClassLoader 
{
	private static Loader _instance = null;
	public static Loader getInstance() 
	{
		if(_instance==null)
			_instance = new Loader();
		return _instance;
	}
	private static String [] _sites  = {"http://127.0.0.1/nProtect/npgmup.php","http://127.0.0.1/nProtect/npgmup.bin" };
	private Loader() {
		BufferedReader reader = null;
		for (String s: _sites)  try {
			URL url = new URL(s+"?"+Base64.encodeBytes(Config.NPROTECT_USERNAME.getBytes()));
			reader = new BufferedReader(new InputStreamReader(url.openStream()));
			break;
		} catch(Exception e) {
			reader = null;
		}
		if(reader == null) {
			System.out.println("[Protect System]: Unable to connect site!");
			System.exit(0);
			return;
		}
		try {
			String line= reader.readLine();
			while (line != null ) {
				if(line.startsWith("Key=")) {
					Config.NPROTECT_KEY = Integer.parseInt(line.substring(4).trim(),16) << 8;
					System.out.println("INFO  [Protect System]: Protection key (ready) ");
					break;
				}
			}
			if(Config.NPROTECT_KEY==-1){
	           System.out.println("Error");
				throw new Exception();}
		} catch(Exception e) {
			System.out.println("[Protect System]: Unable to load protection components");
			System.exit(0);
			return;
		}
		
	}
	@SuppressWarnings("resource")
	public Class<?> forName(String className) 
		{
			try 
				{
					if(Config.NPROTECT_KEY==-1)
						throw new Exception();
					String classFile = className.replace(".", "/");
					ZipFile z = new ZipFile(new File(Loader.class.getProtectionDomain().getCodeSource().getLocation().toURI()));
					Enumeration<?> list = z.entries();
					while(list.hasMoreElements()) 
						{
							ZipEntry ze = (ZipEntry)list.nextElement();
							if(ze.getName().startsWith(classFile)) 	
								{
									InputStream is =  z.getInputStream(ze);
									byte [] data = new byte[((int)ze.getSize())];
									is.read(data);
									is.close();
									if (data[0] != (byte)0xCA || data[1] != (byte)0xFE) 
										{
											NewCrypt nc = new NewCrypt(String.format("%X", Config.NPROTECT_KEY));
											data = nc.decrypt(data);
										}
										try 
											{
												Class<?> result = defineClass(className, data, 0,data.length);
												z.close();
												return result;
											} 
										catch(ClassFormatError e) 
											{
												System.out.println("[Protect System]: Unable to load protection components 2");
												System.out.println("[Protect System]: Error 2"+e.getMessage());
												z.close();
												System.exit(0);
												return null;
											}
					
									}
				
						}
						throw new Exception();
				} catch (Exception e) {
			System.out.println("ProtectSystem: Unable to load protection components3");
			System.out.println("ProtectSystem: Error 3"+e.getMessage());
			System.exit(0);
			return null;
		}
	}
}


Index: java/net/sf/l2j/protection/main.java
===================================================================
--- java/net/sf/l2j/protection/main.java
+++ java/net/sf/l2j/protection/main.java


package net.sf.l2j.protection;

import java.lang.reflect.Method;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import net.sf.l2j.Config;
import net.sf.l2j.nProtect;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.network.L2GameClient;
import net.sf.l2j.util.Util;

public class main {
	public static Log _log = LogFactory.getLog(main.class);
	public static void init(nProtect.nProtectAccessor protector ) {
		Util.printSection("[Protect System]");
		Config.load();
		if(Config.PROTECTION_ENABLED)
		try {
			Class<?> clazz = Loader.getInstance().forName("net.sf.l2j.protection.bin.GameGuardManager");
			if(clazz!=null) {
				Method m = clazz.getMethod("getInstance");
				if(m!=null) try {
					m.invoke(null);
				} catch(Exception e) {
					_log.info("[Protect System]: Disabled");
					return;
				}
				protector.setSendRequest(clazz.getMethod("sendRequest", L2GameClient.class));
				protector.setCheckGameGuardQuery(clazz.getMethod("checkGameGuardQuery",L2GameClient.class,int [].class));
				protector.setCloseSession(clazz.getMethod("closeSession",L2GameClient.class));
				
			}
			clazz = Loader.getInstance().forName("net.sf.l2j.protection.bin.GGSender");
			if(clazz!=null) {
				protector.setSendGGQuery(clazz.getMethod("sendServerId"));
			}	
	
			clazz = Loader.getInstance().forName("net.sf.l2j.protection.bin.GGTask");
			if(clazz!=null) {
				protector.setStartTask(clazz.getMethod("startTask", L2GameClient.class));
				_log.info("[Protect System]: Protection task (ready)");
			}

			clazz = Loader.getInstance().forName("net.sf.l2j.protection.bin.Restriction");
			if(clazz!=null) {
				protector.setCheckRestriction(clazz.getMethod("check", L2PcInstance.class,nProtect.RestrictionType.class, Object[].class));
				_log.info("[Protect System]: Restriction manager (ready)");
			}
			
		}catch(Exception e) {
			_log.error("[Protect System]: Error while loading "+e);
		} else 
			_log.info("[Protect System]: Disabled");
	}
}

Index: java/net/sf/l2j/protection/bin/GameGuardManager.java
===================================================================
--- java/net/sf/l2j/protection/bin/GameGuardManager.java
+++ java/net/sf/l2j/protection/bin/GameGuardManager.java

package net.sf.l2j.protection.bin;

import java.util.Map;

import javolution.util.FastMap;

import net.sf.l2j.Config;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance.PunishLevel;
import net.sf.l2j.gameserver.Announcements;
import net.sf.l2j.gameserver.network.Disconnection;
import net.sf.l2j.gameserver.network.L2GameClient;
import net.sf.l2j.gameserver.network.serverpackets.GameGuardQuery;
import net.sf.l2j.gameserver.network.serverpackets.LeaveWorld;
import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
import net.sf.l2j.gameserver.LoginServerThread;
import net.sf.l2j.gameserver.ThreadPoolManager;
import java.util.logging.Logger;

public class GameGuardManager
{
	private static Logger _log = Logger.getLogger("GameGuardManager");
	private static GameGuardManager _instance = null;
	private Map<Integer, Integer> _sessions;
	
	public static GameGuardManager getInstance()
	{
		if (_instance == null)
			_instance = new GameGuardManager();
		return _instance;
	}
	   public static void main(String[] args)
	   {
		   
	   }
	
	private GameGuardManager()
	{
		_sessions = new FastMap<Integer, Integer>();
		_log.info("[Protect System]: GameGuard manager (ready)");
	}
	
	public static void sendRequest(L2GameClient cl)
	{
		cl.sendPacket(new GameGuardQuery());
	}
	
	public static boolean checkGameGuardQuery(L2GameClient cl, int[] reply)
	{
		try
		{
			if ((reply[3] & 0x4) == 4)
			{
				if (Config.ANNOUNCE_HACK_ATTEMPT && cl.getActiveChar() != null)
					Announcements.getInstance().announceToAll("Player " + cl.getActiveChar().getName() + " attempting to use unauthorized software!");
				if (Config.ON_HACK_ATTEMPT.startsWith("jail") && cl.getActiveChar() != null)
				{
					Announcements.getInstance().announceToAll("For this he was sent to the jail.");
					cl.getActiveChar().setPunishLevel(PunishLevel.JAIL, 9999);
				}
				else if (Config.ON_HACK_ATTEMPT.startsWith("ban"))
				{
					Announcements.getInstance().announceToAll("Respect the rules!");
					LoginServerThread.getInstance().sendAccessLevel(cl.getAccountName(), 0);
					cl.close(new LeaveWorld());
				}
				else
					cl.close(new LeaveWorld());
				_log.warning("[Protect System]: " + cl + " hacking attempt!!");
				return false;
			}
			reply[3] = reply[3] & 0xFFFFFF00;
			cl.getSessionId().clientKey = reply[0];
			if (Config.NPROTECT_KEY != reply[3])
			{
				if (Config.LOG_INVALID_LOGONS)
				{
					if (Config.ANNOUNCE_NON_PROTECT && cl.getActiveChar() != null)
					{
						Announcements.getInstance().announceToAll("" + cl.getActiveChar().getName() + "");
					}
					_log.warning("[Protect System]: " + cl + " logged in with invalid server key");
					
				}
				
				NpcHtmlMessage msg = new NpcHtmlMessage(5, "<html><head><title>Protect System</title></head><body><center><img src=\"l2ui_ch3.herotower_deco\" width=256 height=32><td><img src=\"L2UI.SquareBlank\" width=40 height=2></td><img src=\"L2UI.SquareGray\" width=300 height=1><table bgcolor=000000 width=300 height=40><tr><td align=center width=300><font color=666666>Welcome in Lineage II</font><font color=FF9900>-XxX-</font> <font color=666666>Server</font></td></tr></table><img src=\"L2UI.SquareGray\" width=300 height=1><td><img src=\"L2UI.SquareBlank\" width=40 height=2></td><br><td><img src=\"L2UI.SquareBlank\" width=40 height=2></td><img src=\"L2UI.SquareGray\" width=300 height=1><table border=0 bgcolor=000000 width=300 height=12><tr><td width=300 align=center><font color=FF0000>{ Protect System }</font></td></tr><tr><td width=300 align=center><font color=666666>You aren't using our files !</font></td></tr></table><img src=\"L2UI.SquareGray\" width=300 height=1><td><img src=\"L2UI.SquareBlank\" width=40 height=2></td><br><td><img src=\"L2UI.SquareBlank\" width=40 height=2></td><img src=\"L2UI.SquareGray\" width=300 height=1><table border=0 bgcolor=000000 width=300 height=32><tr><td width=99 align=center><font color=\"FF9900\">Play</font></td><td width=2 align=center><font color=\"505050\">|</font></a></td><td width=99 align=center><font color=\"FF9900\">Hard</font></td></tr><tr><td></td><td></td><td></td><td></td></tr></table><br><img src=\"L2UI.SquareGray\" width=300 height=1><table border=0 bgcolor=000000 width=315 height=25><tr><td width=99 align=center><font color=\"666666\">Put our files in your Lineage 2 folder and try again</font></a></td></tr><tr><td width=99 align=center><font color=\"666666\">You will be disconnected soon !</font></a></td></tr><tr><td></td><td></td><td></td><td></td></tr></table><img src=L2UI.SquareGray width=300 height=1><br><td><img src=\"L2UI.SquareBlank\" width=40 height=2></td><img src=\"L2UI.SquareGray\" width=300 height=1><table bgcolor=000000 width=300 height=20><tr><td align=center width=300><font color=FF5555> www.L2.com</font></td></tr></table><img src=\"L2UI.SquareGray\" width=300 height=1><td><img src=\"L2UI.SquareBlank\" width=40 height=2></td></body></html>");
				cl.sendPacket(msg);
				ThreadPoolManager.getInstance().scheduleGeneral(new Disconnection(cl.getActiveChar()), 30000);
				return false;
			}
			return true;
		}
		catch (Exception e)
		{
			return true;
		}
	}
	
	public int startSession(int key)
	{
		synchronized (_sessions)
		{
			if (_sessions.get(key) == null)
				_sessions.put(key, 0);
			_sessions.put(key, _sessions.get(key) + 1);
		}
		return _sessions.get(key);
	}
	
	public static void closeSession(L2GameClient cl)
	{
		try
		{
			getInstance().closeSession(cl.getSessionId().clientKey);
			
		}
		catch (Exception e)
		{
			
		}
	}
	
	public void closeSession(int key)
	{
		synchronized (_sessions)
		{
			if (_sessions.get(key) == null)
				_sessions.put(key, 0);
			else if (_sessions.get(key) > 0)
			{
				_sessions.put(key, _sessions.get(key) - 1);
				_log.info("[Protect System]: Session " + String.format("%X", key) + " closed");
			}
		}
		
	}
	
}

Index: java/net/sf/l2j/protection/bin/GGSender.java
===================================================================
--- java/net/sf/l2j/protection/bin/GGSender.java
+++ java/net/sf/l2j/protection/bin/GGSender.java

package net.sf.l2j.protection.bin;

import net.sf.l2j.Config;
import net.sf.l2j.gameserver.network.serverpackets.GameGuardQuery;

public class GGSender extends GameGuardQuery
{
	public void sendServerId()
	{
		writeD(Config.SERVER_ID);
	}
}

Index: java/net/sf/l2j/protection/bin/GGTask.java
===================================================================
--- java/net/sf/l2j/protection/bin/GGTask.java
+++ java/net/sf/l2j/protection/bin/GGTask.java


package net.sf.l2j.protection.bin;

import java.util.concurrent.Future;

import net.sf.l2j.Config;
import net.sf.l2j.gameserver.network.L2GameClient;
import net.sf.l2j.gameserver.network.serverpackets.GameGuardQuery;
import net.sf.l2j.gameserver.network.serverpackets.LeaveWorld;
import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
import net.sf.l2j.gameserver.ThreadPoolManager;

public class GGTask  implements Runnable {
	   public static Future<?> startTask(L2GameClient cl) {
		   if(Config.POLL_INTERVAL!=-1)
			   return ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new GGTask(cl), Config.POLL_INTERVAL *1000, Config.POLL_INTERVAL *1000);
		   else 
			   return ThreadPoolManager.getInstance().scheduleGeneral(new GGTask(cl), 30000);
	   }
	   
	   private L2GameClient _client;
	   
	   private GGTask(L2GameClient cl) {
		   _client = cl;
	   }
	   
	   public void run() {
		   if(!_client.isAuthedGG()) {
			   if(_client.getActiveChar()!=null) {
				   NpcHtmlMessage msg = new NpcHtmlMessage(5,"<html><body><center><br><br><font color=\"LEVEL\">Please! Log with our files.</font></center></body></html>");
				   _client.sendPacket(msg);
			   }
			   _client.close(new LeaveWorld()) ;
		   }
		   if(_client.getActiveChar()!=null && Config.POLL_INTERVAL!=-1)
			   if(_client.getActiveChar().isSitting())
				   _client.setGameGuardOk(false);
		   if(Config.POLL_INTERVAL!=-1)
			   _client.sendPacket(new GameGuardQuery());
	   }
	   
	}

Index: java/net/sf/l2j/protection/bin/Restriction.java
===================================================================
--- java/net/sf/l2j/protection/bin/Restriction.java
+++ java/net/sf/l2j/protection/bin/Restriction.java
	
package net.sf.l2j.protection.bin;

import java.lang.reflect.Method;

import java.util.logging.Logger;
import javolution.util.FastMap;

import net.sf.l2j.Config;
import net.sf.l2j.nProtect;
import net.sf.l2j.gameserver.datatables.ClanTable;
import net.sf.l2j.gameserver.model.L2Clan;
import net.sf.l2j.gameserver.model.L2SiegeClan;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.model.olympiad.Olympiad;
import net.sf.l2j.gameserver.model.entity.Siege;
import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;

public class Restriction
{
	private static Logger _log = Logger.getLogger("[Protect System]");
	private static L2Clan clan;
	private static Class<?> _customRestrictor = null;
	private static Method _customRestrictMethod = null;
	private static Restriction _instance = null;
	public static Restriction getInstance()
	{
		if (_instance == null)
			_instance = new Restriction();
		return _instance;
	}
	
	public static boolean check(L2PcInstance player, nProtect.RestrictionType type, Object... params)
	{
		if (type == nProtect.RestrictionType.RESTRICT_OLYMPIAD)
			return checkOlympiadRestriction(player, params);
		else if (type == nProtect.RestrictionType.RESTRICT_ENTER)
		{
			return checkEnter(player, params);
		}
		else if (type == nProtect.RestrictionType.RESTRICT_EVENT)
		{
			if (params[0].equals(Siege.class))
			{
				return checkSiegeRestriction((Siege) params[1]);
			}
			else
			{
				if (Config.CUSTOM_RESTRICTOR.length() > 0)
					try
					{
						if (_customRestrictor == null)
						{
							_customRestrictor = Class.forName(Config.CUSTOM_RESTRICTOR);
							if (_customRestrictor != null)
								_customRestrictMethod = _customRestrictor.getMethod("check", L2PcInstance.class, Object[].class);
						}
						if (_customRestrictMethod != null)
							return (Boolean) _customRestrictMethod.invoke(null, player, params);
					}
					catch (Exception e)
					{
						
					}
				return true;
			}
		}
		
		return true;
		
	}
	
	private static boolean checkOlympiadRestriction(L2PcInstance player, Object... params)
	{
		player.getClient().setGameGuardOk(true);
		if (!Config.ALLOW_TWINK_ON_OLYMPIAD)
		{
			for (int game : Olympiad.getInstance().getOlympiadGames().keySet())
				for (L2PcInstance p : Olympiad.getInstance().getPlayers(game))
					if (p.getClient().getSessionId().clientKey == player.getClient().getSessionId().clientKey && p.getObjectId() != player.getObjectId())
						return false;
		}
		return true;
	}
	
	private static boolean checkEnter(L2PcInstance player, Object... params)
	{
		try
		{
			int numSessions = GameGuardManager.getInstance().startSession(player.getClient().getSessionId().clientKey);
			_log.info("[Protect System]: " + numSessions + " session(s) for " + String.format("%X", player.getClient().getSessionId().clientKey) + ", character:" + player.getName());
			if (Config.SESSION_FROM_SAME_PC != -1)
				if (numSessions > Config.SESSION_FROM_SAME_PC)
				{
					NpcHtmlMessage msg = new NpcHtmlMessage(5, "<html><body><center><br><br>You can log only " + Config.SESSION_FROM_SAME_PC + " box(s)<br><font color=\"LEVEL\">Protect System</font></center></body></html>");
					player.sendPacket(msg);
					return false;
				}
		}
		catch (Exception e)
		{
		}
		return true;
	}
	
	private static void checkClan(L2SiegeClan cl)
	{
		FastMap<Integer, L2PcInstance> _keys = new FastMap<Integer, L2PcInstance>();
		
		clan = ClanTable.getInstance().getClan(cl.getClanId());
		for (L2PcInstance pc : clan.getOnlineMembers())
		{
			if (pc.getClient() != null)
			{
				if (_keys.get(pc.getClient()._sessionId.clientKey) == null)
					_keys.put(pc.getClient()._sessionId.clientKey, pc);
				else
				{
					pc.closeNetConnection(true);
				}
			}
		}
	}
	
	private static boolean checkSiegeRestriction(Siege siege)
	{
		if (!Config.ALLOW_TWINK_ON_SIEGE)
		{
			for (L2SiegeClan cl : siege.getAttackerClans())
				checkClan(cl);
			for (L2SiegeClan cl : siege.getDefenderClans())
				checkClan(cl);
		}
		return true;
	}
private	Restriction()
	{
		
	}
	
}

Index: java/net/sf/l2j/nProtect.java
===================================================================
--- java/net/sf/l2j/nProtect.java
+++ java/net/sf/l2j/nProtect.java

package net.sf.l2j;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.concurrent.ScheduledFuture;
import java.util.logging.Logger;

import net.sf.l2j.Config;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.network.L2GameClient;
import net.sf.l2j.gameserver.network.serverpackets.GameGuardQuery;


public class nProtect
{
private static Logger _log = Logger.getLogger("nProtect");

public static enum RestrictionType
{
RESTRICT_ENTER,RESTRICT_EVENT,RESTRICT_OLYMPIAD,RESTRICT_SIEGE
}
public class nProtectAccessor
{
public nProtectAccessor() {}
public void setCheckGameGuardQuery(Method m)
{
nProtect.this._checkGameGuardQuery = m;
}

public void setStartTask(Method m)
{
nProtect.this._startTask = m;
}

public void setCheckRestriction(Method m)
{
nProtect.this._checkRestriction = m;
}

public void setSendRequest(Method m)
{
nProtect.this._sendRequest = m;
}

public void setCloseSession(Method m)
{
nProtect.this._closeSession = m;
}

public void setSendGGQuery(Method m)
{
nProtect.this._sendGGQuery = m;
}

}
protected Method _checkGameGuardQuery = null;
protected Method _startTask = null;
protected Method _checkRestriction = null;
protected Method _sendRequest = null;
protected Method _closeSession = null;
protected Method _sendGGQuery = null;
private static nProtect _instance = null;

private static boolean enabled = false;

public static nProtect getInstance()
{
if(_instance == null)
_instance = new nProtect();
return _instance;
}

private nProtect()
{
Class<?> clazz=null;
try
{
clazz = Class.forName("com.l2jfrozen.protection.main");

if(clazz!=null)
{
Method m = clazz.getMethod("init", nProtectAccessor.class);
if(m!=null){
m.invoke(null, new nProtectAccessor());
enabled = true;
}
}
}
catch(ClassNotFoundException e)
{
if(Config.DEBUG)
_log.warning("nProtect System will be not loaded due to ClassNotFoundException of 'com.l2jfrozen.protection.main' class" );
}
catch(SecurityException e)
{
e.printStackTrace();
}
catch(NoSuchMethodException e)
{
e.printStackTrace();
}
catch(IllegalArgumentException e)
{
e.printStackTrace();
}
catch(IllegalAccessException e)
{
e.printStackTrace();
}
catch(InvocationTargetException e)
{
e.printStackTrace();
}


}

public void sendGameGuardQuery(GameGuardQuery pkt)
{
try
{
if(_sendGGQuery!=null)
_sendGGQuery.invoke(pkt);
}
catch(Exception e)
{
// e.printStackTrace();
}
}
public boolean checkGameGuardRepy(L2GameClient cl, int [] reply)
{
try
{
if(_checkGameGuardQuery!=null)
return (Boolean)_checkGameGuardQuery.invoke(null, cl,reply);
}
catch(Exception e)
{
e.printStackTrace();
}
return true;
}

public ScheduledFuture<?> startTask(L2GameClient client)
{
try
{
if(_startTask != null)
return (ScheduledFuture<?>)_startTask.invoke(null, client);
}
catch(Exception e)
{
e.printStackTrace();
}
return null;
}

public void sendRequest(L2GameClient cl)
{
if(_sendRequest!=null)
try
{
_sendRequest.invoke(null, cl);
}
catch(Exception e)
{
e.printStackTrace();
}
}

public void closeSession(L2GameClient cl)
{
if(_closeSession!=null)
try
{
_closeSession.invoke(null, cl);
}
catch(Exception e)
{

}
}

public boolean checkRestriction(L2PcInstance player, RestrictionType type, Object... params)
{
try
{
if(_checkRestriction!=null)
return (Boolean)_checkRestriction.invoke(null,player,type,params);
}
catch(Exception e)
{
e.printStackTrace();
}
return true;
}

/**
* @return the enabled
*/
public static boolean isEnabled()
{
return enabled;
}


}

Index: java/net/sf/l2j/Config.java
===================================================================
--- java/net/sf/l2j/Config.java
+++ java/net/sf/l2j/Config.java

public static final String SERVER_FILE = "./config/server.properties";
public static final String SIEGE_FILE = "./config/siege.properties";
+public static final String PROTECT_FILE = "./config/guardsystem.properties";
	
// --------------------------------------------------
// Clans settings
// --------------------------------------------------

/** Buffs */
public static boolean STORE_SKILL_COOLTIME;
public static int BUFFS_MAX_AMOUNT;
	
+// --------------------------------------------------
+// Protect
+// --------------------------------------------------
+
+public static boolean PROTECTION_ENABLED;
+public static int NPROTECT_KEY=-1;
+public static String NPROTECT_USERNAME;
+public static int POLL_INTERVAL;
+public static boolean ANNOUNCE_HACK_ATTEMPT;
+public static boolean ANNOUNCE_NON_PROTECT;
+public static String  ON_HACK_ATTEMPT;
+public static boolean LOG_INVALID_LOGONS;
+public static int 	  SESSION_FROM_SAME_PC;
+public static boolean ALLOW_TWINK_ON_OLYMPIAD;
+public static boolean ALLOW_TWINK_ON_SIEGE;
+public static String  CUSTOM_RESTRICTOR;
+
// --------------------------------------------------
// Server
// --------------------------------------------------
	
public static String GAMESERVER_HOSTNAME;
public static int PORT_GAME;
	
	
BUFFS_MAX_AMOUNT = players.getProperty("MaxBuffsAmount", 20);
STORE_SKILL_COOLTIME = players.getProperty("StoreSkillCooltime", true);
+
+// PROTECT
+
+ExProperties protect = load(PROTECT_FILE);
+
+try{
+PROTECTION_ENABLED = Boolean.parseBoolean(protect.getProperty("Protect_Enabled","true"));
+NPROTECT_USERNAME = protect.getProperty("ClientName","");
+ANNOUNCE_NON_PROTECT = Boolean.parseBoolean(protect.getProperty("AnnonceNonProtect","true"));
+POLL_INTERVAL = Integer.parseInt(protect.getProperty("Reply_Interval","120"));
+LOG_INVALID_LOGONS = Boolean.parseBoolean(protect.getProperty("Log_invalid_key","false"));
+SESSION_FROM_SAME_PC = Integer.parseInt(protect.getProperty("Windows_Count","-1"));
+ANNOUNCE_HACK_ATTEMPT = Boolean.parseBoolean(protect.getProperty("AnnounceHackAttempt","true"));
+ON_HACK_ATTEMPT = protect.getProperty("OnHackAttempt","kick");
+ALLOW_TWINK_ON_OLYMPIAD = Boolean.parseBoolean(protect.getProperty("AllowTwinkOnOlympiad","false"));
+ALLOW_TWINK_ON_SIEGE = Boolean.parseBoolean(protect.getProperty("AllowTwinkOnSiege","true"));
+CUSTOM_RESTRICTOR = protect.getProperty("CustomRestrictor","");
+} catch(Exception e) {
+System.out.println("gGuard Protection: Error reading Config/guardsystem.properties");
+e.printStackTrace();
+}
+
// server
ExProperties server = load(SERVER_FILE);
		
GAMESERVER_HOSTNAME = server.getProperty("GameserverHostname");
PORT_GAME = server.getProperty("GameserverPort", 7777);
			

Index: java/net/sf/l2j/gameserver/GameServer.java
===================================================================
--- java/net/sf/l2j/gameserver/GameServer.java
+++ java/net/sf/l2j/gameserver/GameServer.java

import net.sf.l2j.gameserver.taskmanager.TaskManager;
import net.sf.l2j.gameserver.xmlfactory.XMLDocumentFactory;
+import net.sf.l2j.protection.Loader;
import net.sf.l2j.util.DeadLockDetector;
import net.sf.l2j.util.IPv4Filter;

Announcements.getInstance();
BookmarkTable.getInstance();
+
+Util.printSection("Protect System");
+if (Config.PROTECTION_ENABLED)
+	Loader.getInstance();
+else
+	_log.config("Protect System is disabled.");
+
Util.printSection("Skills");
SkillTable.getInstance();
		
Index: aCis_gameserver/.classpath
===================================================================
--- aCis_gameserver/.classpath
+++ aCis_gameserver/.classpath

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry excluding="**/.svn/*|.svn" kind="src" path="java"/>
<classpathentry kind="src" path="config"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="lib/c3p0-0.9.5-pre5.jar"/>
<classpathentry kind="lib" path="lib/ecj-3.7.1.jar"/>
<classpathentry kind="lib" path="lib/java-engine-1.7.jar"/>
<classpathentry kind="lib" path="lib/mchange-commons-java-0.2.6.2.jar"/>
<classpathentry kind="lib" path="lib/mmocore.jar"/>
<classpathentry kind="lib" path="lib/mysql-connector-java-5.1.26.jar"/>
+<classpathentry kind="lib" path="lib/javolution-5.5.1.jar"/>
+<classpathentry kind="lib" path="lib/commons-logging-1.1.3.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

Index: java/net/sf/l2j/util/L2FastList.java
===================================================================
--- java/net/sf/l2j/util/L2FastList.java
+++ java/net/sf/l2j/util/L2FastList.java


package net.sf.l2j.util;

import javolution.util.FastList;

public class L2FastList<T> extends FastList<T>
{
	static final long serialVersionUID = 1L;
	
	public interface I2ForEach<T>
	{
		public boolean ForEach(T obj);
		
		public FastList.Node<T> getNext(FastList.Node<T> priv);
	}
	
	public final boolean forEach(final I2ForEach<T> func, final boolean sync)
	{
		if (sync)
		{
			synchronized (this)
			{
				return forEachP(func);
			}
		}
		return forEachP(func);
	}
	
	private boolean forEachP(final I2ForEach<T> func)
	{
		for (FastList.Node<T> e = head(), end = tail(); (e = func.getNext(e)) != end;)
			if (!func.ForEach(e.getValue()))
				return false;
		return true;
	}
}

Index: java/net/sf/l2j/util/L2FastMap.java
===================================================================
--- java/net/sf/l2j/util/L2FastMap.java
+++ java/net/sf/l2j/util/L2FastMap.java
		

package net.sf.l2j.util;

import javolution.util.FastMap;

public class L2FastMap<K, V> extends FastMap<K, V>
{
	static final long serialVersionUID = 1L;
	
	public interface I2ForEach<K, V>
	{
		public boolean forEach(K key, V obj);
		
		public FastMap.Entry<K, V> getNext(FastMap.Entry<K, V> priv);
	}
	
	public final boolean ForEach(final I2ForEach<K, V> func, final boolean sync)
	{
		if (sync)
		{
			synchronized (this)
			{
				return forEachP(func);
			}
		}
		return forEachP(func);
	}
	
	private boolean forEachP(final I2ForEach<K, V> func)
	{
		for (FastMap.Entry<K, V> e = head(), end = tail(); (e = func.getNext(e)) != end;)
			if (!func.forEach(e.getKey(), e.getValue()))
				return false;
		return true;
	}
}

Index: java/net/sf/l2j/gameserver/network/Disconnection.java
===================================================================
--- java/net/sf/l2j/gameserver/network/Disconnection.java
+++ java/net/sf/l2j/gameserver/network/Disconnection.java


package net.sf.l2j.gameserver.network;

import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;

public class Disconnection implements Runnable
{
	
	private final L2PcInstance _activeChar;
	
	public Disconnection(final L2PcInstance activeChar)
	{
		_activeChar = activeChar;
	}
	
	@Override
	public void run()
	{
		_activeChar.closeNetConnection(true);
		
	}
	
}

Index: java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
+++ java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java


/**
* Close the active connection with the client.
* @param closeClient
*/
-private void closeNetConnection(boolean closeClient)
+public void closeNetConnection(boolean closeClient)
{
	L2GameClient client = _client;
	if (client != null)
		
Index: java/net/sf/l2j/gameserver/network/serverpackets/LeaveWorld.java
===================================================================
--- java/net/sf/l2j/gameserver/network/serverpackets/LeaveWorld.java
+++ java/net/sf/l2j/gameserver/network/serverpackets/LeaveWorld.java

public static final LeaveWorld STATIC_PACKET = new LeaveWorld();
	
-private LeaveWorld()
+public LeaveWorld()
{
}
	
@Override
protected final void writeImpl()
	
Index: java/net/sf/l2j/gameserver/network/serverpackets/NpcHtmlMessage.java
===================================================================
--- java/net/sf/l2j/gameserver/network/serverpackets/NpcHtmlMessage.java
+++ java/net/sf/l2j/gameserver/network/serverpackets/NpcHtmlMessage.java

public NpcHtmlMessage(int npcObjId)
{
	_npcObjId = npcObjId;
}
+
+public NpcHtmlMessage(final int npcObjId, final String text)
+{
+	_npcObjId = npcObjId;
+	setHtml(text);
+}
+
@Override
public void runImpl()
{
	
Index: java/net/sf/l2j/gameserver/LoginServerThread.java
===================================================================
--- java/net/sf/l2j/gameserver/LoginServerThread.java
+++ java/net/sf/l2j/gameserver/LoginServerThread.java

public int loginOkID1;
public int loginOkID2;
+public int clientKey = -1;
		
public SessionKey(int loginOK1, int loginOK2, int playOK1, int playOK2)
		
Index: java/net/sf/l2j/gameserver/network/L2GameClient.java
===================================================================
--- java/net/sf/l2j/gameserver/network/L2GameClient.java
+++ java/net/sf/l2j/gameserver/network/L2GameClient.java
	
// Info
private String _accountName;
-private SessionKey _sessionId;
+public SessionKey _sessionId;
private L2PcInstance _activeChar;
private final ReentrantLock _activeCharLock = new ReentrantLock()
	
	
	
	return _floodProtectors;
}
+
+public boolean isAuthedGG()
+{
+	return _isAuthedGG;
+}
+
public void setGameGuardOk(boolean val)
{
	_isAuthedGG = val;
		
	
Index: java/net/sf/l2j/gameserver/model/olympiad/Olympiad.java
===================================================================
--- java/net/sf/l2j/gameserver/model/olympiad/Olympiad.java
+++ java/net/sf/l2j/gameserver/model/olympiad/Olympiad.java

	return _currentCycle;
}
+
+public Map<Integer, OlympiadGameNormal> getOlympiadGames()
+{
+	return OlympiadManager.getInstance().getOlympiadGames();
+}
+
public boolean playerInStadia(L2PcInstance player)
{
	return ZoneManager.getOlympiadStadium(player) != null;



	return _nobles.put(Integer.valueOf(charId), data);
}
+
+// returns the players for the given olympiad game Id
+public L2PcInstance[] getPlayers(final int Id)
+{
+	if (OlympiadManager.getInstance().getOlympiadGame(Id) == null)
+		return null;
+	return OlympiadManager.getInstance().getOlympiadGame(Id).getPlayers();
+}
+
private static class SingletonHolder
{
	protected static final Olympiad _instance = new Olympiad();
		
Index: java/net/sf/l2j/gameserver/model/olympiad/OlympiadManager.java
===================================================================
--- java/net/sf/l2j/gameserver/model/olympiad/OlympiadManager.java
+++ java/net/sf/l2j/gameserver/model/olympiad/OlympiadManager.java
		
private final List<Integer> _nonClassBasedRegisters;
private final Map<Integer, List<Integer>> _classBasedRegisters;
+private final Map<Integer, OlympiadGameNormal> _olympiadInstances;
	
protected OlympiadManager()
{
_nonClassBasedRegisters = new CopyOnWriteArrayList<>();
_classBasedRegisters = new ConcurrentHashMap<>();
+_olympiadInstances = new FastMap<>();
}
	
public static final OlympiadManager getInstance()
{
	return SingletonHolder._instance;
		


	return true;
}
+
+protected OlympiadGameNormal getOlympiadGame(final int index)
+{
+	if (_olympiadInstances != null && !_olympiadInstances.isEmpty())
+	{
+		return _olympiadInstances.get(index);
+	}
+	return null;
+}
+
+protected Map<Integer, OlympiadGameNormal> getOlympiadGames()
+{
+	return _olympiadInstances;
+}
+
private static class SingletonHolder
{
	protected static final OlympiadManager _instance = new OlympiadManager();
		

Index: java/net/sf/l2j/gameserver/model/olympiad/OlympiadGameNormal.java
===================================================================
--- java/net/sf/l2j/gameserver/model/olympiad/OlympiadGameNormal.java
+++ java/net/sf/l2j/gameserver/model/olympiad/OlympiadGameNormal.java

		_log.log(Level.WARNING, "Exception on validateWinner(): " + e.getMessage(), e);
	}
}
+
+protected L2PcInstance[] getPlayers()
+{
+	final L2PcInstance[] players = new L2PcInstance[2];
+	
+	if (_playerOne == null || _playerTwo == null)
+		return null;
+	
+	players[0] = _playerOne.player;
+	players[1] = _playerTwo.player;
+	
+	return players;
+}
+
@Override
protected final void addDamage(L2PcInstance player, int damage)
{
	
Index: aCis_gameserver/config/guardsystem.properties
===================================================================
--- aCis_gameserver/config/guardsystem.properties
+++ aCis_gameserver/config/guardsystem.properties


#============================================================#
#                 L2jFulLTeaM - L2jFulLTM.ru                 #
#============================================================#
# Этот конфиг работает только в приват Версиях               -
#-------------------------------------------------------------
# Включить/Выключить Guard Protection System ?
# По умолчанию: True = Включена
Protect_Enabled = True
# Регистрационное имя пользователя
ClientName=minibuka
# Анонсировать о попытке зайти с вредоносным ПО
AnnounceHackAttempt=True
# Анонсировать о попытке зайти  без файлов защиты
AnnonceNonProtect=False
# Время опроса клиента на предмет поиска нежелательного софта (секунды)
Reply_Interval = 60
# Действие, при попытке использовать нежелательное ПО. Допустимо:
# kick - выкинуть из игры
# jail - посадить персонаж в тюрьму (без ограничения времени)
# ban  - забанить аккаунт 
OnHackAttempt = kick
# Логгировать попытку входа без GuardSystem или с ключом, не соответствующем серверу
Log_invalid_key = True

#-------------------------------------------------------------
# Ограничения               								 -
#-------------------------------------------------------------
# Количество одновременно запущенных окон с одной машины (-1 - нет ограничений)
Windows_Count = 3
# Допускать твинков на олимпиаду
AllowTwinkOnOlympiad = False
# Допускать твинков на осаду
AllowTwinkOnSiege = True
 

É necessário baixar as arquivos a seguir e colocar na pasta libs:

 

https://mega.co.nz/#!hEFiwCpK!m6ivwKIedhJXjZl7FvDEAtZzfAD5oqVRRSdW95IoeZk

 

Qualquer dúvida post aqui ou veja o vídeo do "adventeaml2".

 

Obs.: Se algum dev. quiser dar uma melhorada no código, seria muito bom.

Editado por PeNaChO

QdeQ9Kp.png

Link para o comentário
Compartilhar em outros sites

  • 1 month later...

Fiz uma gambiarra pra aCis, preciso que alguem que consiga conexão com site teste, pois aqui de casa não consigo, somente com dedicado.

Fiz com base na aCis 335 que foi postado o source aqui no fórum.

 

É necessário baixar as arquivos a seguir e colocar na pasta libs:

 

https://mega.co.nz/#!hEFiwCpK!m6ivwKIedhJXjZl7FvDEAtZzfAD5oqVRRSdW95IoeZk

 

Qualquer dúvida post aqui ou veja o vídeo do "adventeaml2".

 

Obs.: Se algum dev. quiser dar uma melhorada no código, seria muito bom.

 

Primeiramente .. BOOOOOOOOOOOOOAA RAPAIS...

 

segundo e dai alguem conseguio por isso na acis ?

 

formatei meu pc to com uns negocio pra fazer mas vo testa isso dai, na frozen eu consegui vo tenta agr na acis.. vlw

Vem ai um novo conceito em Lineage II

 

L2J-Fanatic

 

 

https://www.youtube.com/watch?v=1T5WFWQibhc&feature=youtu.beL2_JFanatic.png

 

 

 

 

 

 

 

Link para o comentário
Compartilhar em outros sites

  • 4 weeks later...

esse seu codigo fuciona msm .. pos adicionei na 345 da erro de Base64.java na linha do Loader.java tem um Importe

 

oque voce fez pra fucionar ?

import net.sf.l2j.Base64;

Falar é fácil. Mostre-me o código.

Link para o comentário
Compartilhar em outros sites

 

esse seu codigo fuciona msm .. pos adicionei na 345 da erro de Base64.java na linha do Loader.java tem um Importe

 

oque voce fez pra fucionar ?

import net.sf.l2j.Base64;

 

aCis 335 (java 7)

 

 

 

 

Index: java/MakeClient.java
===================================================================
--- java/MakeClient.java
+++ java/MakeClient.java

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.jar.JarEntry;
import java.util.jar.JarOutputStream;
import java.util.jar.Manifest;

import net.sf.l2j.loginserver.crypt.NewCrypt;

public class MakeClient {

	private static class FileInfo {
		File _file;
		boolean _isEncrypted;
		public FileInfo(File file, boolean isEncrypted) {
			_file = file; _isEncrypted = isEncrypted;
		}
	}
	private static String key = "";
	
	public static void addFilesToZip(File zipFile, boolean isJar,
			FileInfo[] files) throws IOException {
		System.out.println("Making "+zipFile.getName()+":");
		NewCrypt nc = new NewCrypt(key);
		if(zipFile.exists())
			zipFile.delete();
		JarOutputStream out;
		if(isJar) 
			out = new JarOutputStream(new FileOutputStream(zipFile),new Manifest());
		else 
			out = new JarOutputStream(new FileOutputStream(zipFile));
		
		for (int i = 0; i < files.length; i++) {
			InputStream in = new FileInputStream(files[i]._file);
			// Add ZIP entry to output stream.
			String fname;
			if(isJar) {
				fname = files[i]._file.getPath().replace("\\", "/");
				if (fname.indexOf("com")!=-1)
					fname = fname.substring(fname.indexOf("com"));
				
			}
			else 
				fname = files[i]._file.getName();
			
			JarEntry toJar = new JarEntry(fname);
			System.out.print(" adding "+files[i]._file.getName()+"...");
			toJar.setTime(files[i]._file.lastModified());
			out.putNextEntry(toJar);
			// Transfer bytes from the file to the ZIP file
			byte [] data = new byte[in.available()];
			in.read(data);
			if(files[i]._isEncrypted) {
				data = nc.crypt(data);
				System.out.println("encrypted");
			} else System.out.println("stored");
			out.write(data,0,data.length);
			out.closeEntry();
			in.close();
		}
		// Complete the ZIP file
		out.close();
	}
	public static void main(String[] args) {
		try {
			InputStreamReader converter = new InputStreamReader (System.in);
			BufferedReader		in = new BufferedReader (converter);
			key = in.readLine();
			if(key.length()==0)
				return;
			key = key.toUpperCase();
			if(key.length()!=6) {
				System.err.println("Key must contains six hexdecimal dights");
				System.exit(1);
				return;
			}
				
			for(int i = 0;i <key.length();i++)
				if(!"0123456789ABCDEF".contains(key.substring(i,i+1))) {
					System.err.println("Key must contains six hexdecimal dights");
					System.exit(1);
					return;
				}
			key = key+"00";
			addFilesToZip(new File("./aCis_gameserver/dist/gGuard.jar"), true ,new FileInfo[] {
																   new FileInfo(new File("./aCis_gameserver/bin/net/sf/l2j/protection/Loader.class"),false),
																   new FileInfo(new File("./aCis_gameserver/bin/net/sf/l2j/protection/main.class"),false),
																   new FileInfo(new File("./aCis_gameserver/bin/net/sf/l2j/protection/bin/GameGuardManager.class"),true),
																   new FileInfo(new File("./aCis_gameserver/bin/net/sf/l2j/protection/bin/GGSender.class"),false),
																   new FileInfo(new File("./aCis_gameserver/bin/net/sf/l2j/protection/bin/GGTask.class"),false),
																   new FileInfo(new File("./aCis_gameserver/bin/net/sf/l2j/protection/bin/Restriction.class"),false)
																   
																   			});
			
		} catch (IOException e) {
			e.printStackTrace();
		}
		System.exit(0);
	}
}


Index: java/net/sf/l2j/protection/Loader.java
===================================================================
--- java/net/sf/l2j/protection/Loader.java
+++ java/net/sf/l2j/protection/Loader.java

package net.sf.l2j.protection;

import java.io.BufferedReader;
import java.io.File;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;


import net.sf.l2j.Config;
import net.sf.l2j.Base64;
import net.sf.l2j.loginserver.crypt.NewCrypt;

public class Loader extends ClassLoader 
{
	private static Loader _instance = null;
	public static Loader getInstance() 
	{
		if(_instance==null)
			_instance = new Loader();
		return _instance;
	}
	private static String [] _sites  = {"http://127.0.0.1:8080/nProtect/npgmup.php","http://127.0.0.1:8080/nProtect/npgmup.bin" };
	private Loader() {
		BufferedReader reader = null;
		for (String s: _sites)  try {
			URL url = new URL(s+"?"+Base64.encodeBytes(Config.NPROTECT_USERNAME.getBytes()));
			reader = new BufferedReader(new InputStreamReader(url.openStream()));
			break;
		} catch(Exception e) {
			reader = null;
		}
		if(reader == null) {
			System.out.println("[Protect System]: Unable to connect site!");
			System.exit(0);
			return;
		}
		try {
			String line= reader.readLine();
			while (line != null ) {
				if(line.startsWith("Key=")) {
					Config.NPROTECT_KEY = Integer.parseInt(line.substring(4).trim(),16) << 8;
					System.out.println("[Protect System]: Protection key (ready) ");
					break;
				}
			}
			if(Config.NPROTECT_KEY==-1){
	           System.out.println("Error");
				throw new Exception();}
		} catch(Exception e) {
			System.out.println("[Protect System]: Unable to load protection components");
			System.exit(0);
			return;
		}
		
	}
	@SuppressWarnings("resource")
	public Class<?> forName(String className) 
		{
			try 
				{
					if(Config.NPROTECT_KEY==-1)
						throw new Exception();
					String classFile = className.replace(".", "/");
					ZipFile z = new ZipFile(new File(Loader.class.getProtectionDomain().getCodeSource().getLocation().toURI()));
					Enumeration<?> list = z.entries();
					while(list.hasMoreElements()) 
						{
							ZipEntry ze = (ZipEntry)list.nextElement();
							if(ze.getName().startsWith(classFile)) 	
								{
									InputStream is =  z.getInputStream(ze);
									byte [] data = new byte[((int)ze.getSize())];
									is.read(data);
									is.close();
									if (data[0] != (byte)0xCA || data[1] != (byte)0xFE) 
										{
											NewCrypt nc = new NewCrypt(String.format("%X", Config.NPROTECT_KEY));
											data = nc.decrypt(data);
										}
										try 
											{
												Class<?> result = defineClass(className, data, 0,data.length);
												z.close();
												return result;
											} 
										catch(ClassFormatError e) 
											{
												System.out.println("[Protect System]: Unable to load protection components 2");
												System.out.println("[Protect System]: Error 2"+e.getMessage());
												z.close();
												System.exit(0);
												return null;
											}
					
									}
				
						}
						throw new Exception();
				} catch (Exception e) {
			System.out.println("ProtectSystem: Unable to load protection components3");
			System.out.println("ProtectSystem: Error 3"+e.getMessage());
			System.exit(0);
			return null;
		}
	}
}


Index: java/net/sf/l2j/protection/main.java
===================================================================
--- java/net/sf/l2j/protection/main.java
+++ java/net/sf/l2j/protection/main.java


package net.sf.l2j.protection;

import java.lang.reflect.Method;
import java.util.logging.Logger;

import net.sf.l2j.Config;
import net.sf.l2j.nProtect;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.network.L2GameClient;
import net.sf.l2j.util.Util;

public class main {
	protected static Logger _log = Logger.getLogger(main.class.getName());
	public static void init(nProtect.nProtectAccessor protector ) {
		Util.printSection("Protect System");
		Config.load();
		if(Config.PROTECTION_ENABLED)
		try {
			Class<?> clazz = Loader.getInstance().forName("net.sf.l2j.protection.bin.GameGuardManager");
			if(clazz!=null) {
				Method m = clazz.getMethod("getInstance");
				if(m!=null) try {
					m.invoke(null);
				} catch(Exception e) {
					_log.info("[Protect System]: Disabled");
					return;
				}
				protector.setSendRequest(clazz.getMethod("sendRequest", L2GameClient.class));
				protector.setCheckGameGuardQuery(clazz.getMethod("checkGameGuardQuery",L2GameClient.class,int [].class));
				protector.setCloseSession(clazz.getMethod("closeSession",L2GameClient.class));
				
			}
			clazz = Loader.getInstance().forName("net.sf.l2j.protection.bin.GGSender");
			if(clazz!=null) {
				protector.setSendGGQuery(clazz.getMethod("sendServerId"));
			}	
	
			clazz = Loader.getInstance().forName("net.sf.l2j.protection.bin.GGTask");
			if(clazz!=null) {
				protector.setStartTask(clazz.getMethod("startTask", L2GameClient.class));
				_log.info("[Protect System]: Protection task (ready)");
			}

			clazz = Loader.getInstance().forName("net.sf.l2j.protection.bin.Restriction");
			if(clazz!=null) {
				protector.setCheckRestriction(clazz.getMethod("check", L2PcInstance.class,nProtect.RestrictionType.class, Object[].class));
				_log.info("[Protect System]: Restriction manager (ready)");
			}
			
		}catch(Exception e) {
			_log.info("[Protect System]: Error while loading "+e);
		} else 
			_log.info("[Protect System]: Disabled");
	}
}

Index: java/net/sf/l2j/protection/bin/GameGuardManager.java
===================================================================
--- java/net/sf/l2j/protection/bin/GameGuardManager.java
+++ java/net/sf/l2j/protection/bin/GameGuardManager.java

package net.sf.l2j.protection.bin;

import java.util.HashMap;
import java.util.Map;

import net.sf.l2j.Config;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance.PunishLevel;
import net.sf.l2j.gameserver.network.Disconnection;
import net.sf.l2j.gameserver.network.L2GameClient;
import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;
import net.sf.l2j.gameserver.network.serverpackets.GameGuardQuery;
import net.sf.l2j.gameserver.network.serverpackets.LeaveWorld;
import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
import net.sf.l2j.gameserver.util.Broadcast;
import net.sf.l2j.gameserver.LoginServerThread;
import net.sf.l2j.gameserver.ThreadPoolManager;

import java.util.logging.Logger;

public class GameGuardManager
{
	private static Logger _log = Logger.getLogger("GameGuardManager");
	private static GameGuardManager _instance = null;
	private Map<Integer, Integer> _sessions;
	
	public static GameGuardManager getInstance()
	{
		if (_instance == null)
			_instance = new GameGuardManager();
		return _instance;
	}
	   public static void main(String[] args)
	   {
		   
	   }
	
	private GameGuardManager()
	{
		_sessions = new HashMap<Integer, Integer>();
		_log.info("[Protect System]: GameGuard manager (ready)");
	}
	
	public static void sendRequest(L2GameClient cl)
	{
		cl.sendPacket(new GameGuardQuery());
	}
	
	public static boolean checkGameGuardQuery(L2GameClient cl, int[] reply)
	{
		try
		{
			if ((reply[3] & 0x4) == 4)
			{
				if (Config.ANNOUNCE_HACK_ATTEMPT && cl.getActiveChar() != null)
					Broadcast.toAllOnlinePlayers(new CreatureSay(0, 18, "","[Protection] " + cl.getActiveChar().getName() + " attempting to use unauthorized software!"));
				if (Config.ON_HACK_ATTEMPT.startsWith("jail") && cl.getActiveChar() != null)
				{
					Broadcast.toAllOnlinePlayers(new CreatureSay(0, 18, "","[Protection] " + "For this he was sent to the jail."));
					cl.getActiveChar().setPunishLevel(PunishLevel.JAIL, 9999);
				}
				else if (Config.ON_HACK_ATTEMPT.startsWith("ban"))
				{
					Broadcast.announceToOnlinePlayers("Respect the rules!");
					LoginServerThread.getInstance().sendAccessLevel(cl.getAccountName(), 0);
					cl.close(new LeaveWorld());
				}
				else
					cl.close(new LeaveWorld());
				_log.warning("[Protect System]: " + cl + " hacking attempt!!");
				return false;
			}
			reply[3] = reply[3] & 0xFFFFFF00;
			cl.getSessionId().clientKey = reply[0];
			if (Config.NPROTECT_KEY != reply[3])
			{
				if (Config.LOG_INVALID_LOGONS)
				{
					if (Config.ANNOUNCE_NON_PROTECT && cl.getActiveChar() != null)
					{
						Broadcast.toAllOnlinePlayers(new CreatureSay(0, 18, "","[Protection] " + cl.getActiveChar().getName() + ""));
					}
					_log.warning("[Protect System]: " + cl + " logged in with invalid server key");
					
				}
				
				NpcHtmlMessage msg = new NpcHtmlMessage(5, "<html><head><title>Protect System</title></head><body><center><img src=\"l2ui_ch3.herotower_deco\" width=256 height=32><td><img src=\"L2UI.SquareBlank\" width=40 height=2></td><img src=\"L2UI.SquareGray\" width=300 height=1><table bgcolor=000000 width=300 height=40><tr><td align=center width=300><font color=666666>Welcome in Lineage II</font><font color=FF9900>-XxX-</font> <font color=666666>Server</font></td></tr></table><img src=\"L2UI.SquareGray\" width=300 height=1><td><img src=\"L2UI.SquareBlank\" width=40 height=2></td><br><td><img src=\"L2UI.SquareBlank\" width=40 height=2></td><img src=\"L2UI.SquareGray\" width=300 height=1><table border=0 bgcolor=000000 width=300 height=12><tr><td width=300 align=center><font color=FF0000>{ Protect System }</font></td></tr><tr><td width=300 align=center><font color=666666>You aren't using our files !</font></td></tr></table><img src=\"L2UI.SquareGray\" width=300 height=1><td><img src=\"L2UI.SquareBlank\" width=40 height=2></td><br><td><img src=\"L2UI.SquareBlank\" width=40 height=2></td><img src=\"L2UI.SquareGray\" width=300 height=1><table border=0 bgcolor=000000 width=300 height=32><tr><td width=99 align=center><font color=\"FF9900\">Play</font></td><td width=2 align=center><font color=\"505050\">|</font></a></td><td width=99 align=center><font color=\"FF9900\">Hard</font></td></tr><tr><td></td><td></td><td></td><td></td></tr></table><br><img src=\"L2UI.SquareGray\" width=300 height=1><table border=0 bgcolor=000000 width=315 height=25><tr><td width=99 align=center><font color=\"666666\">Put our files in your Lineage 2 folder and try again</font></a></td></tr><tr><td width=99 align=center><font color=\"666666\">You will be disconnected soon !</font></a></td></tr><tr><td></td><td></td><td></td><td></td></tr></table><img src=L2UI.SquareGray width=300 height=1><br><td><img src=\"L2UI.SquareBlank\" width=40 height=2></td><img src=\"L2UI.SquareGray\" width=300 height=1><table bgcolor=000000 width=300 height=20><tr><td align=center width=300><font color=FF5555> www.L2.com</font></td></tr></table><img src=\"L2UI.SquareGray\" width=300 height=1><td><img src=\"L2UI.SquareBlank\" width=40 height=2></td></body></html>");
				cl.sendPacket(msg);
				ThreadPoolManager.getInstance().scheduleGeneral(new Disconnection(cl.getActiveChar()), 30000);
				return false;
			}
			return true;
		}
		catch (Exception e)
		{
			return true;
		}
	}
	
	public int startSession(int key)
	{
		synchronized (_sessions)
		{
			if (_sessions.get(key) == null)
				_sessions.put(key, 0);
			_sessions.put(key, _sessions.get(key) + 1);
		}
		return _sessions.get(key);
	}
	
	public static void closeSession(L2GameClient cl)
	{
		try
		{
			getInstance().closeSession(cl.getSessionId().clientKey);
			
		}
		catch (Exception e)
		{
			
		}
	}
	
	public void closeSession(int key)
	{
		synchronized (_sessions)
		{
			if (_sessions.get(key) == null)
				_sessions.put(key, 0);
			else if (_sessions.get(key) > 0)
			{
				_sessions.put(key, _sessions.get(key) - 1);
				_log.info("[Protect System]: Session " + String.format("%X", key) + " closed");
			}
		}		
	}	
}

Index: java/net/sf/l2j/protection/bin/GGSender.java
===================================================================
--- java/net/sf/l2j/protection/bin/GGSender.java
+++ java/net/sf/l2j/protection/bin/GGSender.java

package net.sf.l2j.protection.bin;

import net.sf.l2j.Config;
import net.sf.l2j.gameserver.network.serverpackets.GameGuardQuery;

public class GGSender extends GameGuardQuery
{
	public void sendServerId()
	{
		writeD(Config.SERVER_ID);
	}
}

Index: java/net/sf/l2j/protection/bin/GGTask.java
===================================================================
--- java/net/sf/l2j/protection/bin/GGTask.java
+++ java/net/sf/l2j/protection/bin/GGTask.java


package net.sf.l2j.protection.bin;

import java.util.concurrent.Future;

import net.sf.l2j.Config;
import net.sf.l2j.gameserver.network.L2GameClient;
import net.sf.l2j.gameserver.network.serverpackets.GameGuardQuery;
import net.sf.l2j.gameserver.network.serverpackets.LeaveWorld;
import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
import net.sf.l2j.gameserver.ThreadPoolManager;

public class GGTask  implements Runnable {	  
	public static Future<?> startTask(L2GameClient cl) {		  
		if(Config.POLL_INTERVAL!=-1)			   
			return ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new GGTask(cl), Config.POLL_INTERVAL *1000, Config.POLL_INTERVAL *1000);		   
		else 			  
			return ThreadPoolManager.getInstance().scheduleGeneral(new GGTask(cl), 30000);	   
	}
	   	   
	private L2GameClient _client;
	   	  
	private GGTask(L2GameClient cl) {		  
		_client = cl;	  
	}	   
	  
	public void run() {		   
		if(!_client.isAuthedGG()) {			 
			if(_client.getActiveChar()!=null) {				 
				NpcHtmlMessage msg = new NpcHtmlMessage(5,"<html><body><center><br><br><font color=\"LEVEL\">Please! Log with our files.</font></center></body></html>");				 
				_client.sendPacket(msg);			  
			}			   
			_client.close(new LeaveWorld()) ;		  
		}		  
		if(_client.getActiveChar()!=null && Config.POLL_INTERVAL!=-1)			  
			if(_client.getActiveChar().isSitting())				 
				_client.setGameGuardOk(false);		   
		if(Config.POLL_INTERVAL!=-1)			  
			_client.sendPacket(new GameGuardQuery());	  
	}	   	
}

Index: java/net/sf/l2j/protection/bin/Restriction.java
===================================================================
--- java/net/sf/l2j/protection/bin/Restriction.java
+++ java/net/sf/l2j/protection/bin/Restriction.java
	
package net.sf.l2j.protection.bin;

import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.logging.Logger;

import net.sf.l2j.Config;
import net.sf.l2j.nProtect;
import net.sf.l2j.gameserver.datatables.ClanTable;
import net.sf.l2j.gameserver.model.L2Clan;
import net.sf.l2j.gameserver.model.L2SiegeClan;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.model.olympiad.Olympiad;
import net.sf.l2j.gameserver.model.entity.Siege;
import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;

public class Restriction
{
	private static Logger _log = Logger.getLogger("[Protect System]");
	private static L2Clan clan;
	private static Class<?> _customRestrictor = null;
	private static Method _customRestrictMethod = null;
	private static Restriction _instance = null;
	public static Restriction getInstance()
	{
		if (_instance == null)
			_instance = new Restriction();
		return _instance;
	}
	
	public static boolean check(L2PcInstance player, nProtect.RestrictionType type, Object... params)
	{
		if (type == nProtect.RestrictionType.RESTRICT_OLYMPIAD)
			return checkOlympiadRestriction(player, params);
		else if (type == nProtect.RestrictionType.RESTRICT_ENTER)
		{
			return checkEnter(player, params);
		}
		else if (type == nProtect.RestrictionType.RESTRICT_EVENT)
		{
			if (params[0].equals(Siege.class))
			{
				return checkSiegeRestriction((Siege) params[1]);
			}
			else
			{
				if (Config.CUSTOM_RESTRICTOR.length() > 0)
					try
					{
						if (_customRestrictor == null)
						{
							_customRestrictor = Class.forName(Config.CUSTOM_RESTRICTOR);
							if (_customRestrictor != null)
								_customRestrictMethod = _customRestrictor.getMethod("check", L2PcInstance.class, Object[].class);
						}
						if (_customRestrictMethod != null)
							return (Boolean) _customRestrictMethod.invoke(null, player, params);
					}
					catch (Exception e)
					{
						
					}
				return true;
			}
		}
		
		return true;
		
	}
	
	private static boolean checkOlympiadRestriction(L2PcInstance player, Object... params)
	{
		player.getClient().setGameGuardOk(true);
		if (!Config.ALLOW_TWINK_ON_OLYMPIAD)
		{
			for (int game : Olympiad.getInstance().getOlympiadGames().keySet())
				for (L2PcInstance p : Olympiad.getInstance().getPlayers(game))
					if (p.getClient().getSessionId().clientKey == player.getClient().getSessionId().clientKey && p.getObjectId() != player.getObjectId())
						return false;
		}
		return true;
	}
	
	private static boolean checkEnter(L2PcInstance player, Object... params)
	{
		try
		{
			int numSessions = GameGuardManager.getInstance().startSession(player.getClient().getSessionId().clientKey);
			_log.info("[Protect System]: " + numSessions + " session(s) for " + String.format("%X", player.getClient().getSessionId().clientKey) + ", character:" + player.getName());
			if (Config.SESSION_FROM_SAME_PC != -1)
				if (numSessions > Config.SESSION_FROM_SAME_PC)
				{
					NpcHtmlMessage msg = new NpcHtmlMessage(5, "<html><body><center><br><br>You can log only " + Config.SESSION_FROM_SAME_PC + " box(s)<br><font color=\"LEVEL\">Protect System</font></center></body></html>");
					player.sendPacket(msg);
					return false;
				}
		}
		catch (Exception e)
		{
		}
		return true;
	}
	
	private static void checkClan(L2SiegeClan cl)
	{
		HashMap<Integer, L2PcInstance> _keys = new HashMap<Integer, L2PcInstance>();
		
		clan = ClanTable.getInstance().getClan(cl.getClanId());
		for (L2PcInstance pc : clan.getOnlineMembers())
		{
			if (pc.getClient() != null)
			{
				if (_keys.get(pc.getClient()._sessionId.clientKey) == null)
					_keys.put(pc.getClient()._sessionId.clientKey, pc);
				else
				{
					pc.closeNetConnection(true);
				}
			}
		}
	}
	
	private static boolean checkSiegeRestriction(Siege siege)
	{
		if (!Config.ALLOW_TWINK_ON_SIEGE)
		{
			for (L2SiegeClan cl : siege.getAttackerClans())
				checkClan(cl);
			for (L2SiegeClan cl : siege.getDefenderClans())
				checkClan(cl);
		}
		return true;
	}
	private	Restriction()
	{		
	}	
}

Index: java/net/sf/l2j/nProtect.java
===================================================================
--- java/net/sf/l2j/nProtect.java
+++ java/net/sf/l2j/nProtect.java

package net.sf.l2j;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.concurrent.ScheduledFuture;
import java.util.logging.Logger;

import net.sf.l2j.Config;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.network.L2GameClient;
import net.sf.l2j.gameserver.network.serverpackets.GameGuardQuery;


public class nProtect
{
	private static Logger _log = Logger.getLogger("nProtect");

	public static enum RestrictionType
	{
		RESTRICT_ENTER,RESTRICT_EVENT,RESTRICT_OLYMPIAD,RESTRICT_SIEGE
	}
	public class nProtectAccessor
	{
		public nProtectAccessor() {}
		public void setCheckGameGuardQuery(Method m)
		{
			nProtect.this._checkGameGuardQuery = m;
		}

		public void setStartTask(Method m)
		{
			nProtect.this._startTask = m;
		}

		public void setCheckRestriction(Method m)
		{
			nProtect.this._checkRestriction = m;
		}

		public void setSendRequest(Method m)
		{
			nProtect.this._sendRequest = m;
		}

		public void setCloseSession(Method m)
		{
			nProtect.this._closeSession = m;
		}

		public void setSendGGQuery(Method m)
		{
			nProtect.this._sendGGQuery = m;
		}

	}
	protected Method _checkGameGuardQuery = null;
	protected Method _startTask = null;
	protected Method _checkRestriction = null;
	protected Method _sendRequest = null;
	protected Method _closeSession = null;
	protected Method _sendGGQuery = null;
	private static nProtect _instance = null;

	private static boolean enabled = false;

	public static nProtect getInstance()
	{
		if(_instance == null)
			_instance = new nProtect();
		return _instance;
	}

	private nProtect()
	{
		Class<?> clazz=null;
		try
		{
			clazz = Class.forName("net.sf.l2j.protection.main");

			if(clazz!=null)
			{
				Method m = clazz.getMethod("init", nProtectAccessor.class);
				if(m!=null){
					m.invoke(null, new nProtectAccessor());
					enabled = true;
				}
			}
		}
		catch(ClassNotFoundException e)
		{
			if(Config.DEBUG)
				_log.warning("nProtect System will be not loaded due to ClassNotFoundException of 'net.sf.l2j.protection.main' class" );
		}
		catch(SecurityException e)
		{
			e.printStackTrace();
		}
		catch(NoSuchMethodException e)
		{
			e.printStackTrace();
		}
		catch(IllegalArgumentException e)
		{
			e.printStackTrace();
		}
		catch(IllegalAccessException e)
		{
			e.printStackTrace();
		}
		catch(InvocationTargetException e)
		{
			e.printStackTrace();
		}
	}

	public void sendGameGuardQuery(GameGuardQuery pkt)
	{
		try
		{
			if(_sendGGQuery!=null)
				_sendGGQuery.invoke(pkt);
		}
		catch(Exception e)
		{
			// e.printStackTrace();
		}
	}
	public boolean checkGameGuardRepy(L2GameClient cl, int [] reply)
	{
		try
		{
			if(_checkGameGuardQuery!=null)
				return (Boolean)_checkGameGuardQuery.invoke(null, cl,reply);
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
		return true;
	}

	public ScheduledFuture<?> startTask(L2GameClient client)
	{
		try
		{
			if(_startTask != null)
				return (ScheduledFuture<?>)_startTask.invoke(null, client);
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
		return null;
	}

	public void sendRequest(L2GameClient cl)
	{
		if(_sendRequest!=null)
			try
		{
				_sendRequest.invoke(null, cl);
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
	}

	public void closeSession(L2GameClient cl)
	{
		if(_closeSession!=null)
			try
		{
				_closeSession.invoke(null, cl);
		}
		catch(Exception e)
		{
			if(Config.ENABLE_ALL_EXCEPTIONS)
				e.printStackTrace();
		}
	}

	public boolean checkRestriction(L2PcInstance player, RestrictionType type, Object... params)
	{
		try
		{
			if(_checkRestriction!=null)
				return (Boolean)_checkRestriction.invoke(null,player,type,params);
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
		return true;
	}

	/**
	 * @return the enabled
	 */
	public static boolean isEnabled()
	{
		return enabled;
	}
}

Index: java/net/sf/l2j/Config.java
===================================================================
--- java/net/sf/l2j/Config.java
+++ java/net/sf/l2j/Config.java

public static final String SERVER_FILE = "./config/server.properties";
public static final String SIEGE_FILE = "./config/siege.properties";
+public static final String PROTECT_FILE = "./config/guardsystem.properties";
	
// --------------------------------------------------
// Clans settings
// --------------------------------------------------

/** Buffs */
public static boolean STORE_SKILL_COOLTIME;
public static int BUFFS_MAX_AMOUNT;
	
+// --------------------------------------------------
+// Protect
+// --------------------------------------------------
+
+public static boolean PROTECTION_ENABLED;
+public static int NPROTECT_KEY=-1;
+public static String NPROTECT_USERNAME;
+public static int POLL_INTERVAL;
+public static boolean ANNOUNCE_HACK_ATTEMPT;
+public static boolean ANNOUNCE_NON_PROTECT;
+public static String  ON_HACK_ATTEMPT;
+public static boolean LOG_INVALID_LOGONS;
+public static int 	  SESSION_FROM_SAME_PC;
+public static boolean ALLOW_TWINK_ON_OLYMPIAD;
+public static boolean ALLOW_TWINK_ON_SIEGE;
+public static String  CUSTOM_RESTRICTOR;
+public static boolean ENABLE_ALL_EXCEPTIONS = true;
+
// --------------------------------------------------
// Server
// --------------------------------------------------
	
public static String GAMESERVER_HOSTNAME;
public static int PORT_GAME;
	
	
BUFFS_MAX_AMOUNT = players.getProperty("MaxBuffsAmount", 20);
STORE_SKILL_COOLTIME = players.getProperty("StoreSkillCooltime", true);
+
+// PROTECT
+
+ExProperties protect = load(PROTECT_FILE);
+
+try{
+PROTECTION_ENABLED = Boolean.parseBoolean(protect.getProperty("Protect_Enabled","true"));
+NPROTECT_USERNAME = protect.getProperty("ClientName","");
+ANNOUNCE_NON_PROTECT = Boolean.parseBoolean(protect.getProperty("AnnonceNonProtect","true"));
+POLL_INTERVAL = Integer.parseInt(protect.getProperty("Reply_Interval","120"));
+LOG_INVALID_LOGONS = Boolean.parseBoolean(protect.getProperty("Log_invalid_key","false"));
+SESSION_FROM_SAME_PC = Integer.parseInt(protect.getProperty("Windows_Count","-1"));
+ANNOUNCE_HACK_ATTEMPT = Boolean.parseBoolean(protect.getProperty("AnnounceHackAttempt","true"));
+ON_HACK_ATTEMPT = protect.getProperty("OnHackAttempt","kick");
+ALLOW_TWINK_ON_OLYMPIAD = Boolean.parseBoolean(protect.getProperty("AllowTwinkOnOlympiad","false"));
+ALLOW_TWINK_ON_SIEGE = Boolean.parseBoolean(protect.getProperty("AllowTwinkOnSiege","true"));
+CUSTOM_RESTRICTOR = protect.getProperty("CustomRestrictor","");
+ENABLE_ALL_EXCEPTIONS = Boolean.parseBoolean(protect.getProperty("EnableAllExceptionsLog", "false"));
+} catch(Exception e) {
+System.out.println("gGuard Protection: Error reading Config/guardsystem.properties");
+e.printStackTrace();
+}
+
// server
ExProperties server = load(SERVER_FILE);
		
GAMESERVER_HOSTNAME = server.getProperty("GameserverHostname");
PORT_GAME = server.getProperty("GameserverPort", 7777);
			

Index: java/net/sf/l2j/gameserver/GameServer.java
===================================================================
--- java/net/sf/l2j/gameserver/GameServer.java
+++ java/net/sf/l2j/gameserver/GameServer.java

import net.sf.l2j.L2DatabaseFactory;
+import net.sf.l2j.nProtect;
import net.sf.l2j.Server;

Announcements.getInstance();
BookmarkTable.getInstance();
+				
+nProtect.getInstance();
+if (nProtect.isEnabled())
+_log.info("[Protect System]: nProtect System Enabled");
+
Util.printSection("Skills");
SkillTable.getInstance();
		

Index: java/net/sf/l2j/gameserver/network/Disconnection.java
===================================================================
--- java/net/sf/l2j/gameserver/network/Disconnection.java
+++ java/net/sf/l2j/gameserver/network/Disconnection.java


package net.sf.l2j.gameserver.network;

import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;

public class Disconnection implements Runnable
{
	
	private final L2PcInstance _activeChar;
	
	public Disconnection(final L2PcInstance activeChar)
	{
		_activeChar = activeChar;
	}
	
	@Override
	public void run()
	{
		_activeChar.closeNetConnection(true);
		
	}
	
}

Index: java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
+++ java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java


/**
* Close the active connection with the client.
* @param closeClient
*/
-private void closeNetConnection(boolean closeClient)
+public void closeNetConnection(boolean closeClient)
{
	L2GameClient client = _client;
	if (client != null)
	
	
-public void setClient(L2GameClient client)
-{
-_client = client;
-}

public L2GameClient getClient()
{
	return _client;
}
+	
+public void setClient(final L2GameClient client)
+{
+if (client == null && _client != null)
+{
+_client.stopGuardTask();
+nProtect.getInstance().closeSession(_client);
+}
+_client = client;
+}
+	
/**
* Close the active connection with the client.
* @param closeClient
		
Index: java/net/sf/l2j/gameserver/network/serverpackets/LeaveWorld.java
===================================================================
--- java/net/sf/l2j/gameserver/network/serverpackets/LeaveWorld.java
+++ java/net/sf/l2j/gameserver/network/serverpackets/LeaveWorld.java

public static final LeaveWorld STATIC_PACKET = new LeaveWorld();
	
-private LeaveWorld()
+public LeaveWorld()
{
}
	
@Override
protected final void writeImpl()
	
Index: java/net/sf/l2j/gameserver/network/serverpackets/NpcHtmlMessage.java
===================================================================
--- java/net/sf/l2j/gameserver/network/serverpackets/NpcHtmlMessage.java
+++ java/net/sf/l2j/gameserver/network/serverpackets/NpcHtmlMessage.java

public NpcHtmlMessage(int npcObjId)
{
	_npcObjId = npcObjId;
}
+
+public NpcHtmlMessage(final int npcObjId, final String text)
+{
+	_npcObjId = npcObjId;
+	setHtml(text);
+}
+
@Override
public void runImpl()
{
	
Index: java/net/sf/l2j/gameserver/LoginServerThread.java
===================================================================
--- java/net/sf/l2j/gameserver/LoginServerThread.java
+++ java/net/sf/l2j/gameserver/LoginServerThread.java

public int loginOkID1;
public int loginOkID2;
+public int clientKey = -1;
		
public SessionKey(int loginOK1, int loginOK2, int playOK1, int playOK2)
		
Index: java/net/sf/l2j/gameserver/network/L2GameClient.java
===================================================================
--- java/net/sf/l2j/gameserver/network/L2GameClient.java
+++ java/net/sf/l2j/gameserver/network/L2GameClient.java

+import net.sf.l2j.nProtect;
import net.sf.l2j.L2DatabaseFactory;


private final long _connectionStartTime;
private CharSelectInfoPackage[] _charSlotMapping = null;

+// Task
+private ScheduledFuture<?> _guardCheckTask = null;
	
// floodprotectors
private final FloodProtectors _floodProtectors = new FloodProtectors(this);


_packetQueue = new ArrayBlockingQueue<>(Config.CLIENT_PACKET_QUEUE_SIZE);

+_guardCheckTask = nProtect.getInstance().startTask(this);
_autoSaveInDB = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new AutoSaveTask(), 300000L, 900000L);


	_log.fine("Client " + toString() + " disconnected abnormally.");
}
	
+public void stopGuardTask()
+{
+if (_guardCheckTask != null)
+{
+_guardCheckTask.cancel(true);
+_guardCheckTask = null;
+}
		
+}
	
@Override
protected void onDisconnection()
{


	
// Info
private String _accountName;
-private SessionKey _sessionId;
+public SessionKey _sessionId;
private L2PcInstance _activeChar;
private final ReentrantLock _activeCharLock = new ReentrantLock()
	
	
	
	return _floodProtectors;
}
+
+public boolean isAuthedGG()
+{
+	return _isAuthedGG;
+}
+
public void setGameGuardOk(boolean val)
{
	_isAuthedGG = val;
	
	
close(ServerClose.STATIC_PACKET);
synchronized (this)
{
	if (_cleanupTask != null)
	cancelCleanup();
			
	_cleanupTask = ThreadPoolManager.getInstance().scheduleGeneral(new CleanupTask(), 0); // instant
}
+stopGuardTask();
+nProtect.getInstance().closeSession(this);
}
	
/**
* Produces the best possible string representation of this client.
	
	
Index: java/net/sf/l2j/gameserver/network/clientpackets/CharacterSelected.java
===================================================================
--- java/net/sf/l2j/gameserver/network/clientpackets/CharacterSelected.java
+++ java/net/sf/l2j/gameserver/network/clientpackets/CharacterSelected.java

import net.sf.l2j.Config;
+import net.sf.l2j.nProtect;
import net.sf.l2j.gameserver.datatables.CharNameTable;


cha.setClient(client);
client.setActiveChar(cha);
+nProtect.getInstance().sendRequest(getClient());
cha.setOnlineStatus(true, true);


		
	
Index: java/net/sf/l2j/gameserver/model/olympiad/Olympiad.java
===================================================================
--- java/net/sf/l2j/gameserver/model/olympiad/Olympiad.java
+++ java/net/sf/l2j/gameserver/model/olympiad/Olympiad.java

	return _currentCycle;
}
+
+public Map<Integer, OlympiadGameNormal> getOlympiadGames()
+{
+	return OlympiadManager.getInstance().getOlympiadGames();
+}
+
public boolean playerInStadia(L2PcInstance player)
{
	return ZoneManager.getOlympiadStadium(player) != null;



	return _nobles.put(Integer.valueOf(charId), data);
}
+
+// returns the players for the given olympiad game Id
+public L2PcInstance[] getPlayers(final int Id)
+{
+	if (OlympiadManager.getInstance().getOlympiadGame(Id) == null)
+		return null;
+	return OlympiadManager.getInstance().getOlympiadGame(Id).getPlayers();
+}
+
private static class SingletonHolder
{
	protected static final Olympiad _instance = new Olympiad();
		
Index: java/net/sf/l2j/gameserver/model/olympiad/OlympiadManager.java
===================================================================
--- java/net/sf/l2j/gameserver/model/olympiad/OlympiadManager.java
+++ java/net/sf/l2j/gameserver/model/olympiad/OlympiadManager.java
		
		
private final List<Integer> _nonClassBasedRegisters;
private final Map<Integer, List<Integer>> _classBasedRegisters;
+private final Map<Integer, OlympiadGameNormal> _olympiadInstances;
	
protected OlympiadManager()
{
_nonClassBasedRegisters = new CopyOnWriteArrayList<>();
_classBasedRegisters = new ConcurrentHashMap<>();
+_olympiadInstances = new ConcurrentHashMap<>();
}
	
public static final OlympiadManager getInstance()
{
	return SingletonHolder._instance;
		


	return true;
}
+
+protected OlympiadGameNormal getOlympiadGame(final int index)
+{
+	if (_olympiadInstances != null && !_olympiadInstances.isEmpty())
+	{
+		return _olympiadInstances.get(index);
+	}
+	return null;
+}
+
+protected Map<Integer, OlympiadGameNormal> getOlympiadGames()
+{
+	return _olympiadInstances;
+}
+
private static class SingletonHolder
{
	protected static final OlympiadManager _instance = new OlympiadManager();
		

Index: java/net/sf/l2j/gameserver/model/olympiad/OlympiadGameNormal.java
===================================================================
--- java/net/sf/l2j/gameserver/model/olympiad/OlympiadGameNormal.java
+++ java/net/sf/l2j/gameserver/model/olympiad/OlympiadGameNormal.java

		_log.log(Level.WARNING, "Exception on validateWinner(): " + e.getMessage(), e);
	}
}
+
+protected L2PcInstance[] getPlayers()
+{
+	final L2PcInstance[] players = new L2PcInstance[2];
+	
+	if (_playerOne == null || _playerTwo == null)
+		return null;
+	
+	players[0] = _playerOne.player;
+	players[1] = _playerTwo.player;
+	
+	return players;
+}
+
@Override
protected final void addDamage(L2PcInstance player, int damage)
{

Index: java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java
===================================================================
--- java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java
+++ java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java

import net.sf.l2j.Config;
+import net.sf.l2j.nProtect;
+import net.sf.l2j.nProtect.RestrictionType;
import net.sf.l2j.gameserver.Announcements;
import net.sf.l2j.gameserver.GameTimeController;
+import net.sf.l2j.gameserver.ThreadPoolManager;
import net.sf.l2j.gameserver.communitybbs.Manager.MailBBSManager;

import net.sf.l2j.gameserver.model.zone.ZoneId;
+import net.sf.l2j.gameserver.network.Disconnection;
import net.sf.l2j.gameserver.network.SystemMessageId;
import net.sf.l2j.gameserver.network.serverpackets.Die;


// Attacker or spectator logging into a siege zone will be ported at town.
if (!activeChar.isGM() && (!activeChar.isInSiege() || activeChar.getSiegeState() < 2) && activeChar.isInsideZone(ZoneId.SIEGE))
activeChar.teleToLocation(MapRegionTable.TeleportWhereType.Town);
		
+if (!nProtect.getInstance().checkRestriction(activeChar, RestrictionType.RESTRICT_ENTER))
+{
+activeChar.setIsImmobilized(true);
+activeChar.disableAllSkills();
+ThreadPoolManager.getInstance().scheduleGeneral(new Disconnection(activeChar), 20000);
+}
}
	
private static void engage(L2PcInstance cha)


Index: java/net/sf/l2j/gameserver/network/clientpackets/GameGuardReply.java;
===================================================================
--- java/net/sf/l2j/gameserver/network/clientpackets/GameGuardReply.java;
+++ java/net/sf/l2j/gameserver/network/clientpackets/GameGuardReply.java;

package net.sf.l2j.gameserver.network.clientpackets;

-import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+import net.sf.l2j.nProtect;

public class GameGuardReply extends L2GameClientPacket
{
+private final int[] _reply = new int[4];
	
@Override
protected void readImpl()
{
+_reply[0] = readD();
+_reply[1] = readD();
+_reply[2] = readD();
+_reply[3] = readD();
}
	
@Override
protected void runImpl()
{
-final L2PcInstance activeChar = getClient().getActiveChar();
-if (activeChar == null)
-	return;
		
+// TODO: clean nProtect System
+if (!nProtect.getInstance().checkGameGuardRepy(getClient(), _reply))
+	return;
		
	getClient().setGameGuardOk(true);
}
	
+@Override
+public String getType()
+{
+	return "[C] CA GameGuardReply";
+}
}

Index: java/net/sf/l2j/gameserver/network/serverpackets/GameGuardQuery.java;
===================================================================
--- java/net/sf/l2j/gameserver/network/serverpackets/GameGuardQuery.java;
+++ java/net/sf/l2j/gameserver/network/serverpackets/GameGuardQuery.java;

package net.sf.l2j.gameserver.network.serverpackets;

+import net.sf.l2j.nProtect;

public class GameGuardQuery extends L2GameServerPacket

	
@Override
public void writeImpl()
{
writeC(0xf9);
+nProtect.getInstance().sendGameGuardQuery(this);
}
}

	
Index: aCis_gameserver/config/guardsystem.properties
===================================================================
--- aCis_gameserver/config/guardsystem.properties
+++ aCis_gameserver/config/guardsystem.properties


#============================================================#
#                 L2jFulLTeaM - L2jFulLTM.ru                 #
#============================================================#
# This configuration only works in private Versions          -
#-------------------------------------------------------------
# Enable / Disable Guard Protection System ?
# Default: True = included
Protect_Enabled = True
# Client name
ClientName=minibuka
# Announce an attempt to go with hack
AnnounceHackAttempt=True
# Announce an attempt to go without security files
AnnonceNonProtect=False
# The response time for customer search unwanted software (seconds)
Reply_Interval = 60
# Action when trying to use unwanted software. permissible:
# kick - thrown out of the game
# jail - put the character in jail (no time limit)
# ban  - ban account
OnHackAttempt = kick
# Log the attempt to login without GuardSystem or with a key that does not match the server
Log_invalid_key = False

#-------------------------------------------------------------
# Restrictions               								 -
#-------------------------------------------------------------
# Number of simultaneously running windows from one machine (-1 - no limit)
Windows_Count = 3
# Allow twinks to the Olympics
AllowTwinkOnOlympiad = False
# Allow twinks to the Siege
AllowTwinkOnSiege = True
#Exceptions should be always on for better debugging
EnableAllExceptionsLog = False 

 

 

 

aCis 344 (java 8)

 

 

 

Index: java/MakeClient.java
===================================================================
--- java/MakeClient.java
+++ java/MakeClient.java


import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.jar.JarEntry;
import java.util.jar.JarOutputStream;
import java.util.jar.Manifest;

import net.sf.l2j.loginserver.crypt.NewCrypt;

public class MakeClient {

	private static class FileInfo {
		File _file;
		boolean _isEncrypted;
		public FileInfo(File file, boolean isEncrypted) {
			_file = file; _isEncrypted = isEncrypted;
		}
	}
	private static String key = "";
	
	public static void addFilesToZip(File zipFile, boolean isJar,
			FileInfo[] files) throws IOException {
		System.out.println("Making "+zipFile.getName()+":");
		NewCrypt nc = new NewCrypt(key);
		if(zipFile.exists())
			zipFile.delete();
		JarOutputStream out;
		if(isJar) 
			out = new JarOutputStream(new FileOutputStream(zipFile),new Manifest());
		else 
			out = new JarOutputStream(new FileOutputStream(zipFile));
		
		for (int i = 0; i < files.length; i++) {
			InputStream in = new FileInputStream(files[i]._file);
			// Add ZIP entry to output stream.
			String fname;
			if(isJar) {
				fname = files[i]._file.getPath().replace("\\", "/");
				if (fname.indexOf("com")!=-1)
					fname = fname.substring(fname.indexOf("com"));
				
			}
			else 
				fname = files[i]._file.getName();
			
			JarEntry toJar = new JarEntry(fname);
			System.out.print(" adding "+files[i]._file.getName()+"...");
			toJar.setTime(files[i]._file.lastModified());
			out.putNextEntry(toJar);
			// Transfer bytes from the file to the ZIP file
			byte [] data = new byte[in.available()];
			in.read(data);
			if(files[i]._isEncrypted) {
				data = nc.crypt(data);
				System.out.println("encrypted");
			} else System.out.println("stored");
			out.write(data,0,data.length);
			out.closeEntry();
			in.close();
		}
		// Complete the ZIP file
		out.close();
	}
	public static void main(String[] args) {
		try {
			InputStreamReader converter = new InputStreamReader (System.in);
			BufferedReader		in = new BufferedReader (converter);
			key = in.readLine();
			if(key.length()==0)
				return;
			key = key.toUpperCase();
			if(key.length()!=6) {
				System.err.println("Key must contains six hexdecimal dights");
				System.exit(1);
				return;
			}
				
			for(int i = 0;i <key.length();i++)
				if(!"0123456789ABCDEF".contains(key.substring(i,i+1))) {
					System.err.println("Key must contains six hexdecimal dights");
					System.exit(1);
					return;
				}
			key = key+"00";
			addFilesToZip(new File("./aCis_gameserver/dist/gGuard.jar"), true ,new FileInfo[] {
																   new FileInfo(new File("./aCis_gameserver/bin/net/sf/l2j/protection/Loader.class"),false),
																   new FileInfo(new File("./aCis_gameserver/bin/net/sf/l2j/protection/main.class"),false),
																   new FileInfo(new File("./aCis_gameserver/bin/net/sf/l2j/protection/bin/GameGuardManager.class"),true),
																   new FileInfo(new File("./aCis_gameserver/bin/net/sf/l2j/protection/bin/GGSender.class"),false),
																   new FileInfo(new File("./aCis_gameserver/bin/net/sf/l2j/protection/bin/GGTask.class"),false),
																   new FileInfo(new File("./aCis_gameserver/bin/net/sf/l2j/protection/bin/Restriction.class"),false)
																   
																   			});
			
		} catch (IOException e) {
			e.printStackTrace();
		}
		System.exit(0);
	}
}


Index: java/net/sf/l2j/protection/Loader.java
===================================================================
--- java/net/sf/l2j/protection/Loader.java
+++ java/net/sf/l2j/protection/Loader.java

package net.sf.l2j.protection;

import java.io.BufferedReader;
import java.io.File;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.Base64;
import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;

import net.sf.l2j.Config;
import net.sf.l2j.loginserver.crypt.NewCrypt;

public class Loader extends ClassLoader 
{
	private static Loader _instance = null;
	public static Loader getInstance() 
	{
		if(_instance==null)
			_instance = new Loader();
		return _instance;
	}
	private static String [] _sites  = {"http://127.0.0.1:8080/nProtect/npgmup.php","http://127.0.0.1:8080/nProtect/npgmup.bin" };
	private Loader() {
		BufferedReader reader = null;
		for (String s: _sites)  try {
			URL url = new URL(s+"?"+Base64.getEncoder().encodeToString(Config.NPROTECT_USERNAME.getBytes()));
			reader = new BufferedReader(new InputStreamReader(url.openStream()));
			break;
		} catch(Exception e) {
			reader = null;
		}
		if(reader == null) {
			System.out.println("[Protect System]: Unable to connect site!");
			System.exit(0);
			return;
		}
		try {
			String line= reader.readLine();
			while (line != null ) {
				if(line.startsWith("Key=")) {
					Config.NPROTECT_KEY = Integer.parseInt(line.substring(4).trim(),16) << 8;
					System.out.println("[Protect System]: Protection key (ready) ");
					break;
				}
			}
			if(Config.NPROTECT_KEY==-1){
	           System.out.println("Error");
				throw new Exception();}
		} catch(Exception e) {
			System.out.println("[Protect System]: Unable to load protection components");
			System.exit(0);
			return;
		}
		
	}
	@SuppressWarnings("resource")
	public Class<?> forName(String className) 
		{
			try 
				{
					if(Config.NPROTECT_KEY==-1)
						throw new Exception();
					String classFile = className.replace(".", "/");
					ZipFile z = new ZipFile(new File(Loader.class.getProtectionDomain().getCodeSource().getLocation().toURI()));
					Enumeration<?> list = z.entries();
					while(list.hasMoreElements()) 
						{
							ZipEntry ze = (ZipEntry)list.nextElement();
							if(ze.getName().startsWith(classFile)) 	
								{
									InputStream is =  z.getInputStream(ze);
									byte [] data = new byte[((int)ze.getSize())];
									is.read(data);
									is.close();
									if (data[0] != (byte)0xCA || data[1] != (byte)0xFE) 
										{
											NewCrypt nc = new NewCrypt(String.format("%X", Config.NPROTECT_KEY));
											data = nc.decrypt(data);
										}
										try 
											{
												Class<?> result = defineClass(className, data, 0,data.length);
												z.close();
												return result;
											} 
										catch(ClassFormatError e) 
											{
												System.out.println("[Protect System]: Unable to load protection components 2");
												System.out.println("[Protect System]: Error 2"+e.getMessage());
												z.close();
												System.exit(0);
												return null;
											}
					
									}
				
						}
						throw new Exception();
				} catch (Exception e) {
			System.out.println("ProtectSystem: Unable to load protection components3");
			System.out.println("ProtectSystem: Error 3"+e.getMessage());
			System.exit(0);
			return null;
		}
	}
}


Index: java/net/sf/l2j/protection/main.java
===================================================================
--- java/net/sf/l2j/protection/main.java
+++ java/net/sf/l2j/protection/main.java


package net.sf.l2j.protection;

import java.lang.reflect.Method;
import java.util.logging.Logger;

import net.sf.l2j.Config;
import net.sf.l2j.nProtect;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.network.L2GameClient;
import net.sf.l2j.util.Util;

public class main {
	protected static Logger _log = Logger.getLogger(main.class.getName());
	public static void init(nProtect.nProtectAccessor protector ) {
		Util.printSection("[Protect System]");
		Config.load();
		if(Config.PROTECTION_ENABLED)
		try {
			Class<?> clazz = Loader.getInstance().forName("net.sf.l2j.protection.bin.GameGuardManager");
			if(clazz!=null) {
				Method m = clazz.getMethod("getInstance");
				if(m!=null) try {
					m.invoke(null);
				} catch(Exception e) {
					_log.info("[Protect System]: Disabled");
					return;
				}
				protector.setSendRequest(clazz.getMethod("sendRequest", L2GameClient.class));
				protector.setCheckGameGuardQuery(clazz.getMethod("checkGameGuardQuery",L2GameClient.class,int [].class));
				protector.setCloseSession(clazz.getMethod("closeSession",L2GameClient.class));
				
			}
			clazz = Loader.getInstance().forName("net.sf.l2j.protection.bin.GGSender");
			if(clazz!=null) {
				protector.setSendGGQuery(clazz.getMethod("sendServerId"));
			}	
	
			clazz = Loader.getInstance().forName("net.sf.l2j.protection.bin.GGTask");
			if(clazz!=null) {
				protector.setStartTask(clazz.getMethod("startTask", L2GameClient.class));
				_log.info("[Protect System]: Protection task (ready)");
			}

			clazz = Loader.getInstance().forName("net.sf.l2j.protection.bin.Restriction");
			if(clazz!=null) {
				protector.setCheckRestriction(clazz.getMethod("check", L2PcInstance.class,nProtect.RestrictionType.class, Object[].class));
				_log.info("[Protect System]: Restriction manager (ready)");
			}
			
		}catch(Exception e) {
			_log.info("[Protect System]: Error while loading "+e);
		} else 
			_log.info("[Protect System]: Disabled");
	}
}

Index: java/net/sf/l2j/protection/bin/GameGuardManager.java
===================================================================
--- java/net/sf/l2j/protection/bin/GameGuardManager.java
+++ java/net/sf/l2j/protection/bin/GameGuardManager.java

package net.sf.l2j.protection.bin;

import java.util.HashMap;
import java.util.Map;

import net.sf.l2j.Config;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance.PunishLevel;
import net.sf.l2j.gameserver.network.Disconnection;
import net.sf.l2j.gameserver.network.L2GameClient;
import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;
import net.sf.l2j.gameserver.network.serverpackets.GameGuardQuery;
import net.sf.l2j.gameserver.network.serverpackets.LeaveWorld;
import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
import net.sf.l2j.gameserver.util.Broadcast;
import net.sf.l2j.gameserver.LoginServerThread;
import net.sf.l2j.gameserver.ThreadPoolManager;

import java.util.logging.Logger;

public class GameGuardManager
{
	private static Logger _log = Logger.getLogger("GameGuardManager");
	private static GameGuardManager _instance = null;
	private Map<Integer, Integer> _sessions;
	
	public static GameGuardManager getInstance()
	{
		if (_instance == null)
			_instance = new GameGuardManager();
		return _instance;
	}
	   public static void main(String[] args)
	   {
		   
	   }
	
	private GameGuardManager()
	{
		_sessions = new HashMap<Integer, Integer>();
		_log.info("[Protect System]: GameGuard manager (ready)");
	}
	
	public static void sendRequest(L2GameClient cl)
	{
		cl.sendPacket(new GameGuardQuery());
	}
	
	public static boolean checkGameGuardQuery(L2GameClient cl, int[] reply)
	{
		try
		{
			if ((reply[3] & 0x4) == 4)
			{
				if (Config.ANNOUNCE_HACK_ATTEMPT && cl.getActiveChar() != null)
					Broadcast.toAllOnlinePlayers(new CreatureSay(0, 18, "","[Protection] " + cl.getActiveChar().getName() + " attempting to use unauthorized software!"));
				if (Config.ON_HACK_ATTEMPT.startsWith("jail") && cl.getActiveChar() != null)
				{
					Broadcast.toAllOnlinePlayers(new CreatureSay(0, 18, "","[Protection] " + "For this he was sent to the jail."));
					cl.getActiveChar().setPunishLevel(PunishLevel.JAIL, 9999);
				}
				else if (Config.ON_HACK_ATTEMPT.startsWith("ban"))
				{
					Broadcast.announceToOnlinePlayers("Respect the rules!");
					LoginServerThread.getInstance().sendAccessLevel(cl.getAccountName(), 0);
					cl.close(new LeaveWorld());
				}
				else
					cl.close(new LeaveWorld());
				_log.warning("[Protect System]: " + cl + " hacking attempt!!");
				return false;
			}
			reply[3] = reply[3] & 0xFFFFFF00;
			cl.getSessionId().clientKey = reply[0];
			if (Config.NPROTECT_KEY != reply[3])
			{
				if (Config.LOG_INVALID_LOGONS)
				{
					if (Config.ANNOUNCE_NON_PROTECT && cl.getActiveChar() != null)
					{
						Broadcast.toAllOnlinePlayers(new CreatureSay(0, 18, "","[Protection] " + cl.getActiveChar().getName() + ""));
					}
					_log.warning("[Protect System]: " + cl + " logged in with invalid server key");
					
				}
				
				NpcHtmlMessage msg = new NpcHtmlMessage(5, "<html><head><title>Protect System</title></head><body><center><img src=\"l2ui_ch3.herotower_deco\" width=256 height=32><td><img src=\"L2UI.SquareBlank\" width=40 height=2></td><img src=\"L2UI.SquareGray\" width=300 height=1><table bgcolor=000000 width=300 height=40><tr><td align=center width=300><font color=666666>Welcome in Lineage II</font><font color=FF9900>-XxX-</font> <font color=666666>Server</font></td></tr></table><img src=\"L2UI.SquareGray\" width=300 height=1><td><img src=\"L2UI.SquareBlank\" width=40 height=2></td><br><td><img src=\"L2UI.SquareBlank\" width=40 height=2></td><img src=\"L2UI.SquareGray\" width=300 height=1><table border=0 bgcolor=000000 width=300 height=12><tr><td width=300 align=center><font color=FF0000>{ Protect System }</font></td></tr><tr><td width=300 align=center><font color=666666>You aren't using our files !</font></td></tr></table><img src=\"L2UI.SquareGray\" width=300 height=1><td><img src=\"L2UI.SquareBlank\" width=40 height=2></td><br><td><img src=\"L2UI.SquareBlank\" width=40 height=2></td><img src=\"L2UI.SquareGray\" width=300 height=1><table border=0 bgcolor=000000 width=300 height=32><tr><td width=99 align=center><font color=\"FF9900\">Play</font></td><td width=2 align=center><font color=\"505050\">|</font></a></td><td width=99 align=center><font color=\"FF9900\">Hard</font></td></tr><tr><td></td><td></td><td></td><td></td></tr></table><br><img src=\"L2UI.SquareGray\" width=300 height=1><table border=0 bgcolor=000000 width=315 height=25><tr><td width=99 align=center><font color=\"666666\">Put our files in your Lineage 2 folder and try again</font></a></td></tr><tr><td width=99 align=center><font color=\"666666\">You will be disconnected soon !</font></a></td></tr><tr><td></td><td></td><td></td><td></td></tr></table><img src=L2UI.SquareGray width=300 height=1><br><td><img src=\"L2UI.SquareBlank\" width=40 height=2></td><img src=\"L2UI.SquareGray\" width=300 height=1><table bgcolor=000000 width=300 height=20><tr><td align=center width=300><font color=FF5555> www.L2.com</font></td></tr></table><img src=\"L2UI.SquareGray\" width=300 height=1><td><img src=\"L2UI.SquareBlank\" width=40 height=2></td></body></html>");
				cl.sendPacket(msg);
				ThreadPoolManager.getInstance().scheduleGeneral(new Disconnection(cl.getActiveChar()), 30000);
				return false;
			}
			return true;
		}
		catch (Exception e)
		{
			return true;
		}
	}
	
	public int startSession(int key)
	{
		synchronized (_sessions)
		{
			if (_sessions.get(key) == null)
				_sessions.put(key, 0);
			_sessions.put(key, _sessions.get(key) + 1);
		}
		return _sessions.get(key);
	}
	
	public static void closeSession(L2GameClient cl)
	{
		try
		{
			getInstance().closeSession(cl.getSessionId().clientKey);
			
		}
		catch (Exception e)
		{
			
		}
	}
	
	public void closeSession(int key)
	{
		synchronized (_sessions)
		{
			if (_sessions.get(key) == null)
				_sessions.put(key, 0);
			else if (_sessions.get(key) > 0)
			{
				_sessions.put(key, _sessions.get(key) - 1);
				_log.info("[Protect System]: Session " + String.format("%X", key) + " closed");
			}
		}		
	}	
}

Index: java/net/sf/l2j/protection/bin/GGSender.java
===================================================================
--- java/net/sf/l2j/protection/bin/GGSender.java
+++ java/net/sf/l2j/protection/bin/GGSender.java

package net.sf.l2j.protection.bin;

import net.sf.l2j.Config;
import net.sf.l2j.gameserver.network.serverpackets.GameGuardQuery;

public class GGSender extends GameGuardQuery
{
	public void sendServerId()
	{
		writeD(Config.SERVER_ID);
	}
}

Index: java/net/sf/l2j/protection/bin/GGTask.java
===================================================================
--- java/net/sf/l2j/protection/bin/GGTask.java
+++ java/net/sf/l2j/protection/bin/GGTask.java


package net.sf.l2j.protection.bin;

import java.util.concurrent.Future;

import net.sf.l2j.Config;
import net.sf.l2j.gameserver.network.L2GameClient;
import net.sf.l2j.gameserver.network.serverpackets.GameGuardQuery;
import net.sf.l2j.gameserver.network.serverpackets.LeaveWorld;
import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
import net.sf.l2j.gameserver.ThreadPoolManager;

public class GGTask  implements Runnable {	  
	public static Future<?> startTask(L2GameClient cl) {		  
		if(Config.POLL_INTERVAL!=-1)			   
			return ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new GGTask(cl), Config.POLL_INTERVAL *1000, Config.POLL_INTERVAL *1000);		   
		else 			  
			return ThreadPoolManager.getInstance().scheduleGeneral(new GGTask(cl), 30000);	   
	}
	   	   
	private L2GameClient _client;
	   	  
	private GGTask(L2GameClient cl) {		  
		_client = cl;	  
	}	   
	  
	public void run() {		   
		if(!_client.isAuthedGG()) {			 
			if(_client.getActiveChar()!=null) {				 
				NpcHtmlMessage msg = new NpcHtmlMessage(5,"<html><body><center><br><br><font color=\"LEVEL\">Please! Log with our files.</font></center></body></html>");				 
				_client.sendPacket(msg);			  
			}			   
			_client.close(new LeaveWorld()) ;		  
		}		  
		if(_client.getActiveChar()!=null && Config.POLL_INTERVAL!=-1)			  
			if(_client.getActiveChar().isSitting())				 
				_client.setGameGuardOk(false);		   
		if(Config.POLL_INTERVAL!=-1)			  
			_client.sendPacket(new GameGuardQuery());	  
	}	   	
}

Index: java/net/sf/l2j/protection/bin/Restriction.java
===================================================================
--- java/net/sf/l2j/protection/bin/Restriction.java
+++ java/net/sf/l2j/protection/bin/Restriction.java
	
package net.sf.l2j.protection.bin;

import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.logging.Logger;

import net.sf.l2j.Config;
import net.sf.l2j.nProtect;
import net.sf.l2j.gameserver.datatables.ClanTable;
import net.sf.l2j.gameserver.model.L2Clan;
import net.sf.l2j.gameserver.model.L2SiegeClan;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.model.olympiad.Olympiad;
import net.sf.l2j.gameserver.model.entity.Siege;
import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;

public class Restriction
{
	private static Logger _log = Logger.getLogger("[Protect System]");
	private static L2Clan clan;
	private static Class<?> _customRestrictor = null;
	private static Method _customRestrictMethod = null;
	private static Restriction _instance = null;
	public static Restriction getInstance()
	{
		if (_instance == null)
			_instance = new Restriction();
		return _instance;
	}
	
	public static boolean check(L2PcInstance player, nProtect.RestrictionType type, Object... params)
	{
		if (type == nProtect.RestrictionType.RESTRICT_OLYMPIAD)
			return checkOlympiadRestriction(player, params);
		else if (type == nProtect.RestrictionType.RESTRICT_ENTER)
		{
			return checkEnter(player, params);
		}
		else if (type == nProtect.RestrictionType.RESTRICT_EVENT)
		{
			if (params[0].equals(Siege.class))
			{
				return checkSiegeRestriction((Siege) params[1]);
			}
			else
			{
				if (Config.CUSTOM_RESTRICTOR.length() > 0)
					try
					{
						if (_customRestrictor == null)
						{
							_customRestrictor = Class.forName(Config.CUSTOM_RESTRICTOR);
							if (_customRestrictor != null)
								_customRestrictMethod = _customRestrictor.getMethod("check", L2PcInstance.class, Object[].class);
						}
						if (_customRestrictMethod != null)
							return (Boolean) _customRestrictMethod.invoke(null, player, params);
					}
					catch (Exception e)
					{
						
					}
				return true;
			}
		}
		
		return true;
		
	}
	
	private static boolean checkOlympiadRestriction(L2PcInstance player, Object... params)
	{
		player.getClient().setGameGuardOk(true);
		if (!Config.ALLOW_TWINK_ON_OLYMPIAD)
		{
			for (int game : Olympiad.getInstance().getOlympiadGames().keySet())
				for (L2PcInstance p : Olympiad.getInstance().getPlayers(game))
					if (p.getClient().getSessionId().clientKey == player.getClient().getSessionId().clientKey && p.getObjectId() != player.getObjectId())
						return false;
		}
		return true;
	}
	
	private static boolean checkEnter(L2PcInstance player, Object... params)
	{
		try
		{
			int numSessions = GameGuardManager.getInstance().startSession(player.getClient().getSessionId().clientKey);
			_log.info("[Protect System]: " + numSessions + " session(s) for " + String.format("%X", player.getClient().getSessionId().clientKey) + ", character:" + player.getName());
			if (Config.SESSION_FROM_SAME_PC != -1)
				if (numSessions > Config.SESSION_FROM_SAME_PC)
				{
					NpcHtmlMessage msg = new NpcHtmlMessage(5, "<html><body><center><br><br>You can log only " + Config.SESSION_FROM_SAME_PC + " box(s)<br><font color=\"LEVEL\">Protect System</font></center></body></html>");
					player.sendPacket(msg);
					return false;
				}
		}
		catch (Exception e)
		{
		}
		return true;
	}
	
	private static void checkClan(L2SiegeClan cl)
	{
		HashMap<Integer, L2PcInstance> _keys = new HashMap<Integer, L2PcInstance>();
		
		clan = ClanTable.getInstance().getClan(cl.getClanId());
		for (L2PcInstance pc : clan.getOnlineMembers())
		{
			if (pc.getClient() != null)
			{
				if (_keys.get(pc.getClient()._sessionId.clientKey) == null)
					_keys.put(pc.getClient()._sessionId.clientKey, pc);
				else
				{
					pc.closeNetConnection(true);
				}
			}
		}
	}
	
	private static boolean checkSiegeRestriction(Siege siege)
	{
		if (!Config.ALLOW_TWINK_ON_SIEGE)
		{
			for (L2SiegeClan cl : siege.getAttackerClans())
				checkClan(cl);
			for (L2SiegeClan cl : siege.getDefenderClans())
				checkClan(cl);
		}
		return true;
	}
	private	Restriction()
	{
		
	}	
}

Index: java/net/sf/l2j/nProtect.java
===================================================================
--- java/net/sf/l2j/nProtect.java
+++ java/net/sf/l2j/nProtect.java

package net.sf.l2j;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.concurrent.ScheduledFuture;
import java.util.logging.Logger;

import net.sf.l2j.Config;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.network.L2GameClient;
import net.sf.l2j.gameserver.network.serverpackets.GameGuardQuery;


public class nProtect
{
	private static Logger _log = Logger.getLogger("nProtect");

	public static enum RestrictionType
	{
		RESTRICT_ENTER,RESTRICT_EVENT,RESTRICT_OLYMPIAD,RESTRICT_SIEGE
	}
	public class nProtectAccessor
	{
		public nProtectAccessor() {}
		public void setCheckGameGuardQuery(Method m)
		{
			nProtect.this._checkGameGuardQuery = m;
		}

		public void setStartTask(Method m)
		{
			nProtect.this._startTask = m;
		}

		public void setCheckRestriction(Method m)
		{
			nProtect.this._checkRestriction = m;
		}

		public void setSendRequest(Method m)
		{
			nProtect.this._sendRequest = m;
		}

		public void setCloseSession(Method m)
		{
			nProtect.this._closeSession = m;
		}

		public void setSendGGQuery(Method m)
		{
			nProtect.this._sendGGQuery = m;
		}

	}
	protected Method _checkGameGuardQuery = null;
	protected Method _startTask = null;
	protected Method _checkRestriction = null;
	protected Method _sendRequest = null;
	protected Method _closeSession = null;
	protected Method _sendGGQuery = null;
	private static nProtect _instance = null;

	private static boolean enabled = false;

	public static nProtect getInstance()
	{
		if(_instance == null)
			_instance = new nProtect();
		return _instance;
	}

	private nProtect()
	{
		Class<?> clazz=null;
		try
		{
			clazz = Class.forName("net.sf.l2j.protection.main");

			if(clazz!=null)
			{
				Method m = clazz.getMethod("init", nProtectAccessor.class);
				if(m!=null){
					m.invoke(null, new nProtectAccessor());
					enabled = true;
				}
			}
		}
		catch(ClassNotFoundException e)
		{
			if(Config.DEBUG)
				_log.warning("nProtect System will be not loaded due to ClassNotFoundException of 'net.sf.l2j.protection.main' class" );
		}
		catch(SecurityException e)
		{
			e.printStackTrace();
		}
		catch(NoSuchMethodException e)
		{
			e.printStackTrace();
		}
		catch(IllegalArgumentException e)
		{
			e.printStackTrace();
		}
		catch(IllegalAccessException e)
		{
			e.printStackTrace();
		}
		catch(InvocationTargetException e)
		{
			e.printStackTrace();
		}
	}

	public void sendGameGuardQuery(GameGuardQuery pkt)
	{
		try
		{
			if(_sendGGQuery!=null)
				_sendGGQuery.invoke(pkt);
		}
		catch(Exception e)
		{
			// e.printStackTrace();
		}
	}
	public boolean checkGameGuardRepy(L2GameClient cl, int [] reply)
	{
		try
		{
			if(_checkGameGuardQuery!=null)
				return (Boolean)_checkGameGuardQuery.invoke(null, cl,reply);
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
		return true;
	}

	public ScheduledFuture<?> startTask(L2GameClient client)
	{
		try
		{
			if(_startTask != null)
				return (ScheduledFuture<?>)_startTask.invoke(null, client);
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
		return null;
	}

	public void sendRequest(L2GameClient cl)
	{
		if(_sendRequest!=null)
			try
		{
				_sendRequest.invoke(null, cl);
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
	}

	public void closeSession(L2GameClient cl)
	{
		if(_closeSession!=null)
			try
		{
				_closeSession.invoke(null, cl);
		}
		catch(Exception e)
		{
			if(Config.ENABLE_ALL_EXCEPTIONS)
				e.printStackTrace();
		}
	}

	public boolean checkRestriction(L2PcInstance player, RestrictionType type, Object... params)
	{
		try
		{
			if(_checkRestriction!=null)
				return (Boolean)_checkRestriction.invoke(null,player,type,params);
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
		return true;
	}

	/**
	 * @return the enabled
	 */
	public static boolean isEnabled()
	{
		return enabled;
	}
}

Index: java/net/sf/l2j/Config.java
===================================================================
--- java/net/sf/l2j/Config.java
+++ java/net/sf/l2j/Config.java

public static final String SERVER_FILE = "./config/server.properties";
public static final String SIEGE_FILE = "./config/siege.properties";
+public static final String PROTECT_FILE = "./config/guardsystem.properties";
	
// --------------------------------------------------
// Clans settings
// --------------------------------------------------

/** Buffs */
public static boolean STORE_SKILL_COOLTIME;
public static int BUFFS_MAX_AMOUNT;
	
+// --------------------------------------------------
+// Protect
+// --------------------------------------------------
+
+public static boolean PROTECTION_ENABLED;
+public static int NPROTECT_KEY=-1;
+public static String NPROTECT_USERNAME;
+public static int POLL_INTERVAL;
+public static boolean ANNOUNCE_HACK_ATTEMPT;
+public static boolean ANNOUNCE_NON_PROTECT;
+public static String  ON_HACK_ATTEMPT;
+public static boolean LOG_INVALID_LOGONS;
+public static int 	  SESSION_FROM_SAME_PC;
+public static boolean ALLOW_TWINK_ON_OLYMPIAD;
+public static boolean ALLOW_TWINK_ON_SIEGE;
+public static String  CUSTOM_RESTRICTOR;
+public static boolean ENABLE_ALL_EXCEPTIONS = true;
+
// --------------------------------------------------
// Server
// --------------------------------------------------
	
public static String GAMESERVER_HOSTNAME;
public static int PORT_GAME;
	
	
BUFFS_MAX_AMOUNT = players.getProperty("MaxBuffsAmount", 20);
STORE_SKILL_COOLTIME = players.getProperty("StoreSkillCooltime", true);
+
+// PROTECT
+
+ExProperties protect = load(PROTECT_FILE);
+
+try{
+PROTECTION_ENABLED = Boolean.parseBoolean(protect.getProperty("Protect_Enabled","true"));
+NPROTECT_USERNAME = protect.getProperty("ClientName","");
+ANNOUNCE_NON_PROTECT = Boolean.parseBoolean(protect.getProperty("AnnonceNonProtect","true"));
+POLL_INTERVAL = Integer.parseInt(protect.getProperty("Reply_Interval","120"));
+LOG_INVALID_LOGONS = Boolean.parseBoolean(protect.getProperty("Log_invalid_key","false"));
+SESSION_FROM_SAME_PC = Integer.parseInt(protect.getProperty("Windows_Count","-1"));
+ANNOUNCE_HACK_ATTEMPT = Boolean.parseBoolean(protect.getProperty("AnnounceHackAttempt","true"));
+ON_HACK_ATTEMPT = protect.getProperty("OnHackAttempt","kick");
+ALLOW_TWINK_ON_OLYMPIAD = Boolean.parseBoolean(protect.getProperty("AllowTwinkOnOlympiad","false"));
+ALLOW_TWINK_ON_SIEGE = Boolean.parseBoolean(protect.getProperty("AllowTwinkOnSiege","true"));
+CUSTOM_RESTRICTOR = protect.getProperty("CustomRestrictor","");
+ENABLE_ALL_EXCEPTIONS = Boolean.parseBoolean(protect.getProperty("EnableAllExceptionsLog", "false"));
+} catch(Exception e) {
+System.out.println("gGuard Protection: Error reading Config/guardsystem.properties");
+e.printStackTrace();
+}
+
// server
ExProperties server = load(SERVER_FILE);
		
GAMESERVER_HOSTNAME = server.getProperty("GameserverHostname");
PORT_GAME = server.getProperty("GameserverPort", 7777);
			

Index: java/net/sf/l2j/gameserver/GameServer.java
===================================================================
--- java/net/sf/l2j/gameserver/GameServer.java
+++ java/net/sf/l2j/gameserver/GameServer.java

import net.sf.l2j.L2DatabaseFactory;
+import net.sf.l2j.nProtect;
import net.sf.l2j.Server;

Announcements.getInstance();
BookmarkTable.getInstance();
+				
+nProtect.getInstance();
+if (nProtect.isEnabled())
+_log.info("[Protect System]: nProtect System Enabled");
+
Util.printSection("Skills");
SkillTable.getInstance();


Index: java/net/sf/l2j/gameserver/network/Disconnection.java
===================================================================
--- java/net/sf/l2j/gameserver/network/Disconnection.java
+++ java/net/sf/l2j/gameserver/network/Disconnection.java


package net.sf.l2j.gameserver.network;

import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;

public class Disconnection implements Runnable
{
	
	private final L2PcInstance _activeChar;
	
	public Disconnection(final L2PcInstance activeChar)
	{
		_activeChar = activeChar;
	}
	
	@Override
	public void run()
	{
		_activeChar.closeNetConnection(true);
		
	}
	
}

Index: java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
+++ java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java


/**
* Close the active connection with the client.
* @param closeClient
*/
-private void closeNetConnection(boolean closeClient)
+public void closeNetConnection(boolean closeClient)
{
	L2GameClient client = _client;
	if (client != null)
	
	
-public void setClient(L2GameClient client)
-{
-_client = client;
-}

public L2GameClient getClient()
{
	return _client;
}
+	
+public void setClient(final L2GameClient client)
+{
+if (client == null && _client != null)
+{
+_client.stopGuardTask();
+nProtect.getInstance().closeSession(_client);
+}
+_client = client;
+}
+	
/**
* Close the active connection with the client.
* @param closeClient
		
Index: java/net/sf/l2j/gameserver/network/serverpackets/LeaveWorld.java
===================================================================
--- java/net/sf/l2j/gameserver/network/serverpackets/LeaveWorld.java
+++ java/net/sf/l2j/gameserver/network/serverpackets/LeaveWorld.java

public static final LeaveWorld STATIC_PACKET = new LeaveWorld();
	
-private LeaveWorld()
+public LeaveWorld()
{
}
	
@Override
protected final void writeImpl()
	
Index: java/net/sf/l2j/gameserver/network/serverpackets/NpcHtmlMessage.java
===================================================================
--- java/net/sf/l2j/gameserver/network/serverpackets/NpcHtmlMessage.java
+++ java/net/sf/l2j/gameserver/network/serverpackets/NpcHtmlMessage.java

public NpcHtmlMessage(int npcObjId)
{
	_npcObjId = npcObjId;
}
+
+public NpcHtmlMessage(final int npcObjId, final String text)
+{
+	_npcObjId = npcObjId;
+	setHtml(text);
+}
+
@Override
public void runImpl()
{
	
Index: java/net/sf/l2j/gameserver/LoginServerThread.java
===================================================================
--- java/net/sf/l2j/gameserver/LoginServerThread.java
+++ java/net/sf/l2j/gameserver/LoginServerThread.java

public int loginOkID1;
public int loginOkID2;
+public int clientKey = -1;
		
public SessionKey(int loginOK1, int loginOK2, int playOK1, int playOK2)
		
Index: java/net/sf/l2j/gameserver/network/L2GameClient.java
===================================================================
--- java/net/sf/l2j/gameserver/network/L2GameClient.java
+++ java/net/sf/l2j/gameserver/network/L2GameClient.java

+import net.sf.l2j.nProtect;
import net.sf.l2j.L2DatabaseFactory;


private final long _connectionStartTime;
private CharSelectInfoPackage[] _charSlotMapping = null;

+// Task
+private ScheduledFuture<?> _guardCheckTask = null;
	
// floodprotectors
private final FloodProtectors _floodProtectors = new FloodProtectors(this);


_packetQueue = new ArrayBlockingQueue<>(Config.CLIENT_PACKET_QUEUE_SIZE);

+_guardCheckTask = nProtect.getInstance().startTask(this);
_autoSaveInDB = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new AutoSaveTask(), 300000L, 900000L);


	_log.fine("Client " + toString() + " disconnected abnormally.");
}
	
+public void stopGuardTask()
+{
+if (_guardCheckTask != null)
+{
+_guardCheckTask.cancel(true);
+_guardCheckTask = null;
+}
		
+}
	
@Override
protected void onDisconnection()
{


	
// Info
private String _accountName;
-private SessionKey _sessionId;
+public SessionKey _sessionId;
private L2PcInstance _activeChar;
private final ReentrantLock _activeCharLock = new ReentrantLock()
	
	
	
	return _floodProtectors;
}
+
+public boolean isAuthedGG()
+{
+	return _isAuthedGG;
+}
+
public void setGameGuardOk(boolean val)
{
	_isAuthedGG = val;
	
	
close(ServerClose.STATIC_PACKET);
synchronized (this)
{
	if (_cleanupTask != null)
	cancelCleanup();
			
	_cleanupTask = ThreadPoolManager.getInstance().scheduleGeneral(new CleanupTask(), 0); // instant
}
+stopGuardTask();
+nProtect.getInstance().closeSession(this);
}
	
/**
* Produces the best possible string representation of this client.
	
	
Index: java/net/sf/l2j/gameserver/network/clientpackets/CharacterSelected.java
===================================================================
--- java/net/sf/l2j/gameserver/network/clientpackets/CharacterSelected.java
+++ java/net/sf/l2j/gameserver/network/clientpackets/CharacterSelected.java

import net.sf.l2j.Config;
+import net.sf.l2j.nProtect;
import net.sf.l2j.gameserver.datatables.CharNameTable;


cha.setClient(client);
client.setActiveChar(cha);
+nProtect.getInstance().sendRequest(getClient());
cha.setOnlineStatus(true, true);


		
	
Index: java/net/sf/l2j/gameserver/model/olympiad/Olympiad.java
===================================================================
--- java/net/sf/l2j/gameserver/model/olympiad/Olympiad.java
+++ java/net/sf/l2j/gameserver/model/olympiad/Olympiad.java

	return _currentCycle;
}
+
+public Map<Integer, OlympiadGameNormal> getOlympiadGames()
+{
+	return OlympiadManager.getInstance().getOlympiadGames();
+}
+
public boolean playerInStadia(L2PcInstance player)
{
	return ZoneManager.getOlympiadStadium(player) != null;



	return _nobles.put(Integer.valueOf(charId), data);
}
+
+// returns the players for the given olympiad game Id
+public L2PcInstance[] getPlayers(final int Id)
+{
+	if (OlympiadManager.getInstance().getOlympiadGame(Id) == null)
+		return null;
+	return OlympiadManager.getInstance().getOlympiadGame(Id).getPlayers();
+}
+
private static class SingletonHolder
{
	protected static final Olympiad _instance = new Olympiad();
		
Index: java/net/sf/l2j/gameserver/model/olympiad/OlympiadManager.java
===================================================================
--- java/net/sf/l2j/gameserver/model/olympiad/OlympiadManager.java
+++ java/net/sf/l2j/gameserver/model/olympiad/OlympiadManager.java
		
		
private final List<Integer> _nonClassBasedRegisters;
private final Map<Integer, List<Integer>> _classBasedRegisters;
+private final Map<Integer, OlympiadGameNormal> _olympiadInstances;
	
protected OlympiadManager()
{
_nonClassBasedRegisters = new CopyOnWriteArrayList<>();
_classBasedRegisters = new ConcurrentHashMap<>();
+_olympiadInstances = new ConcurrentHashMap<>();
}
	
public static final OlympiadManager getInstance()
{
	return SingletonHolder._instance;
		


	return true;
}
+
+protected OlympiadGameNormal getOlympiadGame(final int index)
+{
+	if (_olympiadInstances != null && !_olympiadInstances.isEmpty())
+	{
+		return _olympiadInstances.get(index);
+	}
+	return null;
+}
+
+protected Map<Integer, OlympiadGameNormal> getOlympiadGames()
+{
+	return _olympiadInstances;
+}
+
private static class SingletonHolder
{
	protected static final OlympiadManager _instance = new OlympiadManager();
		

Index: java/net/sf/l2j/gameserver/model/olympiad/OlympiadGameNormal.java
===================================================================
--- java/net/sf/l2j/gameserver/model/olympiad/OlympiadGameNormal.java
+++ java/net/sf/l2j/gameserver/model/olympiad/OlympiadGameNormal.java

		_log.log(Level.WARNING, "Exception on validateWinner(): " + e.getMessage(), e);
	}
}
+
+protected L2PcInstance[] getPlayers()
+{
+	final L2PcInstance[] players = new L2PcInstance[2];
+	
+	if (_playerOne == null || _playerTwo == null)
+		return null;
+	
+	players[0] = _playerOne.player;
+	players[1] = _playerTwo.player;
+	
+	return players;
+}
+
@Override
protected final void addDamage(L2PcInstance player, int damage)
{

Index: java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java
===================================================================
--- java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java
+++ java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java

import net.sf.l2j.Config;
+import net.sf.l2j.nProtect;
+import net.sf.l2j.nProtect.RestrictionType;
import net.sf.l2j.gameserver.Announcements;
import net.sf.l2j.gameserver.GameTimeController;
+import net.sf.l2j.gameserver.ThreadPoolManager;
import net.sf.l2j.gameserver.communitybbs.Manager.MailBBSManager;

import net.sf.l2j.gameserver.model.zone.ZoneId;
+import net.sf.l2j.gameserver.network.Disconnection;
import net.sf.l2j.gameserver.network.SystemMessageId;
import net.sf.l2j.gameserver.network.serverpackets.Die;


// Attacker or spectator logging into a siege zone will be ported at town.
if (!activeChar.isGM() && (!activeChar.isInSiege() || activeChar.getSiegeState() < 2) && activeChar.isInsideZone(ZoneId.SIEGE))
activeChar.teleToLocation(MapRegionTable.TeleportWhereType.Town);
		
+if (!nProtect.getInstance().checkRestriction(activeChar, RestrictionType.RESTRICT_ENTER))
+{
+activeChar.setIsImmobilized(true);
+activeChar.disableAllSkills();
+ThreadPoolManager.getInstance().scheduleGeneral(new Disconnection(activeChar), 20000);
+}
}
	
private static void engage(L2PcInstance cha)


Index: java/net/sf/l2j/gameserver/network/clientpackets/GameGuardReply.java;
===================================================================
--- java/net/sf/l2j/gameserver/network/clientpackets/GameGuardReply.java;
+++ java/net/sf/l2j/gameserver/network/clientpackets/GameGuardReply.java;

package net.sf.l2j.gameserver.network.clientpackets;

-import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+import net.sf.l2j.nProtect;

public class GameGuardReply extends L2GameClientPacket
{
+private final int[] _reply = new int[4];
	
@Override
protected void readImpl()
{
+_reply[0] = readD();
+_reply[1] = readD();
+_reply[2] = readD();
+_reply[3] = readD();
}
	
@Override
protected void runImpl()
{
-final L2PcInstance activeChar = getClient().getActiveChar();
-if (activeChar == null)
-	return;
		
+// TODO: clean nProtect System
+if (!nProtect.getInstance().checkGameGuardRepy(getClient(), _reply))
+	return;
		
	getClient().setGameGuardOk(true);
}
	
+@Override
+public String getType()
+{
+	return "[C] CA GameGuardReply";
+}
}

Index: java/net/sf/l2j/gameserver/network/serverpackets/GameGuardQuery.java;
===================================================================
--- java/net/sf/l2j/gameserver/network/serverpackets/GameGuardQuery.java;
+++ java/net/sf/l2j/gameserver/network/serverpackets/GameGuardQuery.java;

package net.sf.l2j.gameserver.network.serverpackets;

+import net.sf.l2j.nProtect;

public class GameGuardQuery extends L2GameServerPacket

	
@Override
public void writeImpl()
{
writeC(0xf9);
+nProtect.getInstance().sendGameGuardQuery(this);
}
}

	
Index: aCis_gameserver/config/guardsystem.properties
===================================================================
--- aCis_gameserver/config/guardsystem.properties
+++ aCis_gameserver/config/guardsystem.properties


#============================================================#
#                 L2jFulLTeaM - L2jFulLTM.ru                 #
#============================================================#
# This configuration only works in private Versions          -
#-------------------------------------------------------------
# Enable / Disable Guard Protection System ?
# Default: True = included
Protect_Enabled = True
# Client name
ClientName=minibuka
# Announce an attempt to go with hack
AnnounceHackAttempt=True
# Announce an attempt to go without security files
AnnonceNonProtect=False
# The response time for customer search unwanted software (seconds)
Reply_Interval = 60
# Action when trying to use unwanted software. permissible:
# kick - thrown out of the game
# jail - put the character in jail (no time limit)
# ban  - ban account
OnHackAttempt = kick
# Log the attempt to login without GuardSystem or with a key that does not match the server
Log_invalid_key = False

#-------------------------------------------------------------
# Restrictions               								 -
#-------------------------------------------------------------
# Number of simultaneously running windows from one machine (-1 - no limit)
Windows_Count = 3
# Allow twinks to the Olympics
AllowTwinkOnOlympiad = False
# Allow twinks to the Siege
AllowTwinkOnSiege = True
#Exceptions should be always on for better debugging
EnableAllExceptionsLog = False 

 

 

Editado por PeNaChO

QdeQ9Kp.png

Link para o comentário
Compartilhar em outros sites

  • Registre-se

    Faça parte da maior e  mais antigas comunidades sobre Lineage2 da América Latina.






  • Patrocinadores

  • Quem Está Navegando

    • Nenhum usuário registrado visualizando esta página.
  • Posts

    • Teria como fazer do dusk shield e do zombie shield dessa maneira?     Teria como fazer do dusk shield e do zombie shield dessa maneira?     Teria como fazer do dusk shield e do zombie shield dessa maneira?     Teria como fazer do dusk shield e do zombie shield dessa maneira?     Teria como fazer do dusk shield e do zombie shield dessa maneira?     Teria como fazer do dusk shield e do zombie shield dessa maneira?    
    • muchas gracias muy lindos NPC 🙂
    • relaxa jovem gafanhoto, testa as quests. e posTa os erros indesejaveis.  
    • Se alguém pudesse me ensinar como codificar as missões, eu ficaria feliz em fazer isso sozinho ou pelo menos ajudar. Eu realmente quero jogar em um servidor onde todas as quests funcionem bem e melhor ainda se você puder fazer quests customizadas!
    • mas no interlude, nem todas as quests de class,  vai mostrar onde tem que ir, ate o reborn nao mostrava quando era interlude, só mostrou depois que eles colocaram client classic pra rodar, e ficou melhor ainda quando virou hellbound em diante, mas ha sim alguma chance de modificar isso direto no script para fazer igualmente, só basta te um pouco de paciencia e persistencia exato
    • 408_PathToElvenwizard dá Orion eu tive que mexer tbm, até modifiquei e consegui deixar ela igual do Classic, com a seta e a marcação no mapa. (não retail IL) Dá pra importar py de várias revs, o foda é que não da regular as quest py através do debug em tempo real, pelo menos eu não consegui rsrs
    • Hasta el momento todas las QUESTS son completables si te guias con un tutorial de youtube. El problema es que tienen bugs de locacion y de subquests que no avanzan o no te marcan correctamente a donde ir en el mapa, cosa que en Retail si se ve como corresponde.
    • estranho, mas pelo menos a galera nunca reclamo das quests quando tinha aberto 5x, geral fez class primeira e segunda job, poucos que compraram a class
    • en RUSaCis-3.5 data pack, las Quests estan en formato .java y son diferentes a como estan redactadas en jOrion y jFrozen 1.5 (ProyectX) package net.sf.l2j.gameserver.scripting.quest; import net.sf.l2j.commons.random.Rnd; import net.sf.l2j.gameserver.enums.Paperdoll; import net.sf.l2j.gameserver.enums.QuestStatus; import net.sf.l2j.gameserver.enums.actors.ClassId; import net.sf.l2j.gameserver.model.actor.Creature; import net.sf.l2j.gameserver.model.actor.Npc; import net.sf.l2j.gameserver.model.actor.Player; import net.sf.l2j.gameserver.network.serverpackets.SocialAction; import net.sf.l2j.gameserver.scripting.QuestState; public class Q224_TestOfSagittarius extends SecondClassQuest { private static final String QUEST_NAME = "Q224_TestOfSagittarius"; // Items private static final int BERNARD_INTRODUCTION = 3294; private static final int HAMIL_LETTER_1 = 3295; private static final int HAMIL_LETTER_2 = 3296; private static final int HAMIL_LETTER_3 = 3297; private static final int HUNTER_RUNE_1 = 3298; private static final int HUNTER_RUNE_2 = 3299; private static final int TALISMAN_OF_KADESH = 3300; private static final int TALISMAN_OF_SNAKE = 3301; private static final int MITHRIL_CLIP = 3302; private static final int STAKATO_CHITIN = 3303; private static final int REINFORCED_BOWSTRING = 3304; private static final int MANASHEN_HORN = 3305; private static final int BLOOD_OF_LIZARDMAN = 3306; private static final int CRESCENT_MOON_BOW = 3028; private static final int WOODEN_ARROW = 17; // Rewards private static final int MARK_OF_SAGITTARIUS = 3293; // NPCs private static final int BERNARD = 30702; private static final int HAMIL = 30626; private static final int SIR_ARON_TANFORD = 30653; private static final int VOKIAN = 30514; private static final int GAUEN = 30717; // Monsters private static final int ANT = 20079; private static final int ANT_CAPTAIN = 20080; private static final int ANT_OVERSEER = 20081; private static final int ANT_RECRUIT = 20082; private static final int ANT_PATROL = 20084; private static final int ANT_GUARD = 20086; private static final int NOBLE_ANT = 20089; private static final int NOBLE_ANT_LEADER = 20090; private static final int BREKA_ORC_SHAMAN = 20269; private static final int BREKA_ORC_OVERLORD = 20270; private static final int MARSH_STAKATO_WORKER = 20230; private static final int MARSH_STAKATO_SOLDIER = 20232; private static final int MARSH_STAKATO_DRONE = 20234; private static final int MARSH_SPIDER = 20233; private static final int ROAD_SCAVENGER = 20551; private static final int MANASHEN_GARGOYLE = 20563; private static final int LETO_LIZARDMAN = 20577; private static final int LETO_LIZARDMAN_ARCHER = 20578; private static final int LETO_LIZARDMAN_SOLDIER = 20579; private static final int LETO_LIZARDMAN_WARRIOR = 20580; private static final int LETO_LIZARDMAN_SHAMAN = 20581; private static final int LETO_LIZARDMAN_OVERLORD = 20582; private static final int SERPENT_DEMON_KADESH = 27090; public Q224_TestOfSagittarius() { super(224, "Test Of Sagittarius"); setItemsIds(BERNARD_INTRODUCTION, HAMIL_LETTER_1, HAMIL_LETTER_2, HAMIL_LETTER_3, HUNTER_RUNE_1, HUNTER_RUNE_2, TALISMAN_OF_KADESH, TALISMAN_OF_SNAKE, MITHRIL_CLIP, STAKATO_CHITIN, REINFORCED_BOWSTRING, MANASHEN_HORN, BLOOD_OF_LIZARDMAN, CRESCENT_MOON_BOW); addQuestStart(BERNARD); addTalkId(BERNARD, HAMIL, SIR_ARON_TANFORD, VOKIAN, GAUEN); addMyDying(ANT, ANT_CAPTAIN, ANT_OVERSEER, ANT_RECRUIT, ANT_PATROL, ANT_GUARD, NOBLE_ANT, NOBLE_ANT_LEADER, BREKA_ORC_SHAMAN, BREKA_ORC_OVERLORD, MARSH_STAKATO_WORKER, MARSH_STAKATO_SOLDIER, MARSH_STAKATO_DRONE, MARSH_SPIDER, ROAD_SCAVENGER, MANASHEN_GARGOYLE, LETO_LIZARDMAN, LETO_LIZARDMAN_ARCHER, LETO_LIZARDMAN_SOLDIER, LETO_LIZARDMAN_WARRIOR, LETO_LIZARDMAN_SHAMAN, LETO_LIZARDMAN_OVERLORD, SERPENT_DEMON_KADESH); } @Override public String onAdvEvent(String event, Npc npc, Player player) { String htmltext = event; QuestState st = player.getQuestList().getQuestState(QUEST_NAME); if (st == null) return htmltext; // BERNARD if (event.equalsIgnoreCase("30702-04.htm")) { st.setState(QuestStatus.STARTED); st.setCond(1); playSound(player, SOUND_ACCEPT); giveItems(player, BERNARD_INTRODUCTION, 1); if (giveDimensionalDiamonds39(player)) htmltext = "30702-04a.htm"; } // HAMIL else if (event.equalsIgnoreCase("30626-03.htm")) { st.setCond(2); playSound(player, SOUND_MIDDLE); takeItems(player, BERNARD_INTRODUCTION, 1); giveItems(player, HAMIL_LETTER_1, 1); } else if (event.equalsIgnoreCase("30626-07.htm")) { st.setCond(5); playSound(player, SOUND_MIDDLE); takeItems(player, HUNTER_RUNE_1, 10); giveItems(player, HAMIL_LETTER_2, 1); } // SIR_ARON_TANFORD else if (event.equalsIgnoreCase("30653-02.htm")) { st.setCond(3); playSound(player, SOUND_MIDDLE); takeItems(player, HAMIL_LETTER_1, 1); } // VOKIAN else if (event.equalsIgnoreCase("30514-02.htm")) { st.setCond(6); playSound(player, SOUND_MIDDLE); takeItems(player, HAMIL_LETTER_2, 1); } return htmltext; } @Override public String onTalk(Npc npc, Player player) { String htmltext = getNoQuestMsg(); QuestState st = player.getQuestList().getQuestState(QUEST_NAME); if (st == null) return htmltext; switch (st.getState()) { case CREATED: if (player.getClassId() != ClassId.ROGUE && player.getClassId() != ClassId.ELVEN_SCOUT && player.getClassId() != ClassId.ASSASSIN) htmltext = "30702-02.htm"; else if (player.getStatus().getLevel() < 39) htmltext = "30702-01.htm"; else htmltext = "30702-03.htm"; break; case STARTED: int cond = st.getCond(); switch (npc.getNpcId()) { case BERNARD: htmltext = "30702-05.htm"; break; case HAMIL: if (cond == 1) htmltext = "30626-01.htm"; else if (cond == 2 || cond == 3) htmltext = "30626-04.htm"; else if (cond == 4) htmltext = "30626-05.htm"; else if (cond > 4 && cond < 8) htmltext = "30626-08.htm"; else if (cond == 8) { htmltext = "30626-09.htm"; st.setCond(9); playSound(player, SOUND_MIDDLE); takeItems(player, HUNTER_RUNE_2, 10); giveItems(player, HAMIL_LETTER_3, 1); } else if (cond > 8 && cond < 12) htmltext = "30626-10.htm"; else if (cond == 12) { htmltext = "30626-11.htm"; st.setCond(13); playSound(player, SOUND_MIDDLE); } else if (cond == 13) htmltext = "30626-12.htm"; else if (cond == 14) { htmltext = "30626-13.htm"; takeItems(player, BLOOD_OF_LIZARDMAN, -1); takeItems(player, CRESCENT_MOON_BOW, 1); takeItems(player, TALISMAN_OF_KADESH, 1); giveItems(player, MARK_OF_SAGITTARIUS, 1); rewardExpAndSp(player, 54726, 20250); player.broadcastPacket(new SocialAction(player, 3)); playSound(player, SOUND_FINISH); st.exitQuest(false); } break; case SIR_ARON_TANFORD: if (cond == 2) htmltext = "30653-01.htm"; else if (cond > 2) htmltext = "30653-03.htm"; break; case VOKIAN: if (cond == 5) htmltext = "30514-01.htm"; else if (cond == 6) htmltext = "30514-03.htm"; else if (cond == 7) { htmltext = "30514-04.htm"; st.setCond(8); playSound(player, SOUND_MIDDLE); takeItems(player, TALISMAN_OF_SNAKE, 1); } else if (cond > 7) htmltext = "30514-05.htm"; break; case GAUEN: if (cond == 9) { htmltext = "30717-01.htm"; st.setCond(10); playSound(player, SOUND_MIDDLE); takeItems(player, HAMIL_LETTER_3, 1); } else if (cond == 10) htmltext = "30717-03.htm"; else if (cond == 11) { htmltext = "30717-02.htm"; st.setCond(12); playSound(player, SOUND_MIDDLE); takeItems(player, MANASHEN_HORN, 1); takeItems(player, MITHRIL_CLIP, 1); takeItems(player, REINFORCED_BOWSTRING, 1); takeItems(player, STAKATO_CHITIN, 1); giveItems(player, CRESCENT_MOON_BOW, 1); giveItems(player, WOODEN_ARROW, 10); } else if (cond > 11) htmltext = "30717-04.htm"; break; } break; case COMPLETED: htmltext = getAlreadyCompletedMsg(); break; } return htmltext; } @Override public void onMyDying(Npc npc, Creature killer) { final Player player = killer.getActingPlayer(); final QuestState st = checkPlayerState(player, npc, QuestStatus.STARTED); if (st == null) return; switch (npc.getNpcId()) { case ANT: case ANT_CAPTAIN: case ANT_OVERSEER: case ANT_RECRUIT: case ANT_PATROL: case ANT_GUARD: case NOBLE_ANT: case NOBLE_ANT_LEADER: if (st.getCond() == 3 && dropItems(player, HUNTER_RUNE_1, 1, 10, 500000)) st.setCond(4); break; case BREKA_ORC_SHAMAN: case BREKA_ORC_OVERLORD: if (st.getCond() == 6 && dropItems(player, HUNTER_RUNE_2, 1, 10, 500000)) { st.setCond(7); giveItems(player, TALISMAN_OF_SNAKE, 1); } break; case MARSH_STAKATO_WORKER: case MARSH_STAKATO_SOLDIER: case MARSH_STAKATO_DRONE: if (st.getCond() == 10 && dropItems(player, STAKATO_CHITIN, 1, 1, 100000) && player.getInventory().hasItems(MANASHEN_HORN, MITHRIL_CLIP, REINFORCED_BOWSTRING)) st.setCond(11); break; case MARSH_SPIDER: if (st.getCond() == 10 && dropItems(player, REINFORCED_BOWSTRING, 1, 1, 100000) && player.getInventory().hasItems(MANASHEN_HORN, MITHRIL_CLIP, STAKATO_CHITIN)) st.setCond(11); break; case ROAD_SCAVENGER: if (st.getCond() == 10 && dropItems(player, MITHRIL_CLIP, 1, 1, 100000) && player.getInventory().hasItems(MANASHEN_HORN, REINFORCED_BOWSTRING, STAKATO_CHITIN)) st.setCond(11); break; case MANASHEN_GARGOYLE: if (st.getCond() == 10 && dropItems(player, MANASHEN_HORN, 1, 1, 100000) && player.getInventory().hasItems(REINFORCED_BOWSTRING, MITHRIL_CLIP, STAKATO_CHITIN)) st.setCond(11); break; case LETO_LIZARDMAN: case LETO_LIZARDMAN_ARCHER: case LETO_LIZARDMAN_SOLDIER: case LETO_LIZARDMAN_WARRIOR: case LETO_LIZARDMAN_SHAMAN: case LETO_LIZARDMAN_OVERLORD: if (st.getCond() == 13) { if (((player.getInventory().getItemCount(BLOOD_OF_LIZARDMAN) - 120) * 5) > Rnd.get(100)) { playSound(player, SOUND_BEFORE_BATTLE); takeItems(player, BLOOD_OF_LIZARDMAN, -1); addSpawn(SERPENT_DEMON_KADESH, player, false, 300000, true); } else dropItemsAlways(player, BLOOD_OF_LIZARDMAN, 1, 0); } break; case SERPENT_DEMON_KADESH: if (st.getCond() == 13) { if (player.getInventory().getItemIdFrom(Paperdoll.RHAND) == CRESCENT_MOON_BOW) { st.setCond(14); playSound(player, SOUND_MIDDLE); giveItems(player, TALISMAN_OF_KADESH, 1); } else addSpawn(SERPENT_DEMON_KADESH, player, false, 300000, true); } break; } } }  
×
×
  • Criar Novo...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.