Jump to content

Question

Posted

Hello guys,

I'm excusing for this topic but i need help with an antibot captcha to my Gracia final server.

 

This is the antibot http://www.maxcheaters.com/topic/105460-share-captcha-antibot-system-updated-1762011-version-2-please-lock-it/

 

The problem is when i start the server all npcs are removed from the world.

Also when spawn a mob and kill it few tims captcha appears, when close the html i write the command .captcha and notting appears.

I think that the problem is inside of L2Npc.java for the spawns and voicedcommandhandlers captcha.java and antibot.java.

This is the whole codes:

1.L2Npc
2.Antibot
3. Captcha
4.Masterhandler

package net.sf.l2j.gameserver.model.actor;

import static net.sf.l2j.gameserver.ai.CtrlIntention.AI_INTENTION_ACTIVE;

import java.text.DateFormat;
import java.text.DecimalFormat;
import java.util.Collection;
import java.util.List;
import java.util.logging.Level;

import javolution.util.FastList;
import net.sf.l2j.Config;
import net.sf.l2j.gameserver.GameTimeController;
import net.sf.l2j.gameserver.GmListTable;
import net.sf.l2j.gameserver.SevenSigns;
import net.sf.l2j.gameserver.SevenSignsFestival;
import net.sf.l2j.gameserver.ThreadPoolManager;
import net.sf.l2j.gameserver.ai.CtrlIntention;
import net.sf.l2j.gameserver.cache.HtmCache;
import net.sf.l2j.gameserver.datatables.ClanTable;
import net.sf.l2j.gameserver.datatables.FakePcsTable;
import net.sf.l2j.gameserver.datatables.ItemLists;
import net.sf.l2j.gameserver.datatables.ItemTable;
import net.sf.l2j.gameserver.datatables.SkillTable;
import net.sf.l2j.gameserver.datatables.SpawnTable;
import net.sf.l2j.gameserver.idfactory.IdFactory;
import net.sf.l2j.gameserver.instancemanager.CastleManager;
import net.sf.l2j.gameserver.instancemanager.DayNightSpawnManager;
import net.sf.l2j.gameserver.instancemanager.DimensionalRiftManager;
import net.sf.l2j.gameserver.instancemanager.FortManager;
import net.sf.l2j.gameserver.instancemanager.QuestManager;
import net.sf.l2j.gameserver.instancemanager.TownManager;
import net.sf.l2j.gameserver.instancemanager.games.Lottery;
import net.sf.l2j.gameserver.model.L2Clan;
import net.sf.l2j.gameserver.model.L2DropCategory;
import net.sf.l2j.gameserver.model.L2DropData;
import net.sf.l2j.gameserver.model.L2ItemInstance;
import net.sf.l2j.gameserver.model.L2Multisell;
import net.sf.l2j.gameserver.model.L2Object;
import net.sf.l2j.gameserver.model.L2Skill;
import net.sf.l2j.gameserver.model.L2Spawn;
import net.sf.l2j.gameserver.model.L2World;
import net.sf.l2j.gameserver.model.L2WorldRegion;
import net.sf.l2j.gameserver.model.MobGroupTable;
import net.sf.l2j.gameserver.model.actor.instance.L2BufferInstance;
import net.sf.l2j.gameserver.model.actor.instance.L2ClanHallManagerInstance;
import net.sf.l2j.gameserver.model.actor.instance.L2ControlTowerInstance;
import net.sf.l2j.gameserver.model.actor.instance.L2ControllableMobInstance;
import net.sf.l2j.gameserver.model.actor.instance.L2DoormenInstance;
import net.sf.l2j.gameserver.model.actor.instance.L2FestivalGuideInstance;
import net.sf.l2j.gameserver.model.actor.instance.L2FishermanInstance;
import net.sf.l2j.gameserver.model.actor.instance.L2MerchantInstance;
import net.sf.l2j.gameserver.model.actor.instance.L2MonsterInstance;
import net.sf.l2j.gameserver.model.actor.instance.L2NpcInstance;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.model.actor.instance.L2RaidBossInstance;
import net.sf.l2j.gameserver.model.actor.instance.L2TeleporterInstance;
import net.sf.l2j.gameserver.model.actor.instance.L2WarehouseInstance;
import net.sf.l2j.gameserver.model.actor.instance.L2SummonInstance;
import net.sf.l2j.gameserver.model.actor.instance.L2PetInstance;
import net.sf.l2j.gameserver.model.actor.knownlist.NpcKnownList;
import net.sf.l2j.gameserver.model.actor.stat.NpcStat;
import net.sf.l2j.gameserver.model.actor.status.NpcStatus;
import net.sf.l2j.gameserver.model.entity.Castle;
import net.sf.l2j.gameserver.model.entity.Fort;
import net.sf.l2j.gameserver.model.entity.L2Event;
import net.sf.l2j.gameserver.model.events.CTF;
import net.sf.l2j.gameserver.model.events.DM;
import net.sf.l2j.gameserver.model.events.FOS;
import net.sf.l2j.gameserver.model.events.TvT;
import net.sf.l2j.gameserver.model.events.VIP;
import net.sf.l2j.gameserver.model.itemcontainer.NpcInventory;
import net.sf.l2j.gameserver.model.olympiad.Olympiad;
import net.sf.l2j.gameserver.model.quest.Quest;
import net.sf.l2j.gameserver.model.quest.QuestState;
import net.sf.l2j.gameserver.model.quest.State;
import net.sf.l2j.gameserver.model.zone.type.L2TownZone;
import net.sf.l2j.gameserver.network.L2GameClient;
import net.sf.l2j.gameserver.network.SystemMessageId;
import net.sf.l2j.gameserver.network.serverpackets.AbstractNpcInfo;
import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
import net.sf.l2j.gameserver.network.serverpackets.EtcStatusUpdate;
import net.sf.l2j.gameserver.network.serverpackets.ExShowBaseAttributeCancelWindow;
import net.sf.l2j.gameserver.network.serverpackets.InventoryUpdate;
import net.sf.l2j.gameserver.network.serverpackets.MyTargetSelected;
import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
import net.sf.l2j.gameserver.network.serverpackets.PledgeCrest;
import net.sf.l2j.gameserver.network.serverpackets.RadarControl;
import net.sf.l2j.gameserver.network.serverpackets.ServerObjectInfo;
import net.sf.l2j.gameserver.network.serverpackets.SocialAction;
import net.sf.l2j.gameserver.network.serverpackets.StatusUpdate;
import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
import net.sf.l2j.gameserver.network.serverpackets.ValidateLocation;
import net.sf.l2j.gameserver.skills.Stats;
import net.sf.l2j.gameserver.taskmanager.DecayTaskManager;
import net.sf.l2j.gameserver.templates.chars.L2NpcTemplate;
import net.sf.l2j.gameserver.templates.chars.L2NpcTemplate.AIType;
import net.sf.l2j.gameserver.templates.item.L2Item;
import net.sf.l2j.gameserver.templates.item.L2Weapon;
import net.sf.l2j.gameserver.util.StringUtil;
import gov.nasa.worldwind.formats.dds.DDSConverter;
import java.awt.Color;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics2D;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
import java.io.File;
import javax.imageio.ImageIO;
import net.sf.l2j.gameserver.skills.AbnormalEffect;
import net.sf.l2j.util.Rnd;
import cz.nxs.events.engine.main.globalevent.GlobalEvent;
import cz.nxs.interf.NexusEvents;

HERE IS NOT WHOLE CODE BECOUSE OF THE LONG SIZE

/**
 * Return the Exp Reward of this L2NpcInstance contained in the L2NpcTemplate (modified by RATE_XP).<BR><BR>
 */
public long getExpReward()
{
	return (long)(getTemplate().rewardExp * Config.RATE_XP);
}

/**
 * Return the SP Reward of this L2NpcInstance contained in the L2NpcTemplate (modified by RATE_SP).<BR><BR>
 */
public int getSpReward()
{
	return (int) (getTemplate().rewardSp * Config.RATE_SP);
}

public static StringBuilder finalString = new StringBuilder();
	NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
	private static BufferedImage generateCaptcha()
	{    
		Color textColor = new Color(98, 213, 43);
		Color circleColor = new Color(98, 213, 43);
		Font textFont = new Font("comic sans ms", Font.BOLD, 24);
		int charsToPrint = 5;
		int width = 256;
		int height = 64;
		int circlesToDraw = 8;
		float horizMargin = 20.0f;
		double rotationRange = 0.7; // this is radians
		BufferedImage bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
	
		Graphics2D g = (Graphics2D) bufferedImage.getGraphics();
	
		//Draw an oval
		g.setColor(new Color(30,31,31));
		g.fillRect(0, 0, width, height);
	
		// lets make some noisey circles
		g.setColor(circleColor);
		for ( int i = 0; i < circlesToDraw; i++ ) 
		{
			int circleRadius = (int) (Math.random() * height / 2.0);
			int circleX = (int) (Math.random() * width - circleRadius);
			int circleY = (int) (Math.random() * height - circleRadius);
			g.drawOval(circleX, circleY, circleRadius * 2, circleRadius * 2);
		}
	
		g.setColor(textColor);
		g.setFont(textFont);
	
		FontMetrics fontMetrics = g.getFontMetrics();
		int maxAdvance = fontMetrics.getMaxAdvance();
		int fontHeight = fontMetrics.getHeight();
			   
		// Suggestions ----------------------------------------------------------------------
		// i removed 1 and l and i because there are confusing to users...
		// Z, z, and N also get confusing when rotated
		// 0, O, and o are also confusing...
		// lowercase G looks a lot like a 9 so i killed it
		// this should ideally be done for every language...
		// i like controlling the characters though because it helps prevent confusion
		// So recommended chars are:
		// String elegibleChars = "ABCDEFGHJKLMPQRSTUVWXYabcdefhjkmnpqrstuvwxy23456789";
		// Suggestions ----------------------------------------------------------------------
		String elegibleChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890";
		char[] chars = elegibleChars.toCharArray();
	
		float spaceForLetters = -horizMargin * 2 + width;
		float spacePerChar = spaceForLetters / (charsToPrint - 1.0f);
	
		for ( int i = 0; i < charsToPrint; i++ ) 
		{
			double randomValue = Math.random();
			int randomIndex = (int) Math.round(randomValue * (chars.length - 1));
			char characterToShow = chars[randomIndex];
			finalString.append(characterToShow);
	
			// this is a separate canvas used for the character so that
			// we can rotate it independently
			int charWidth = fontMetrics.charWidth(characterToShow);
			int charDim = Math.max(maxAdvance, fontHeight);
			int halfCharDim = (charDim / 2);
	
			BufferedImage charImage = new BufferedImage(charDim, charDim, BufferedImage.TYPE_INT_ARGB);
			Graphics2D charGraphics = charImage.createGraphics();
			charGraphics.translate(halfCharDim, halfCharDim);
			double angle = (Math.random() - 0.5) * rotationRange;
			charGraphics.transform(AffineTransform.getRotateInstance(angle));
			charGraphics.translate(-halfCharDim,-halfCharDim);
			charGraphics.setColor(textColor);
			charGraphics.setFont(textFont);
	
			int charX = (int) (0.5 * charDim - 0.5 * charWidth);
			charGraphics.drawString("" + characterToShow, charX, 
					((charDim - fontMetrics.getAscent()) 
							/ 2 + fontMetrics.getAscent()));
	
			float x = horizMargin + spacePerChar * (i) - charDim / 2.0f;
			int y = ((height - charDim) / 2);
			g.drawImage(charImage, (int) x, y, charDim, charDim, null, null);
	
			charGraphics.dispose();
		}
			   
		g.dispose();     
				
		return bufferedImage;
	}
		
		
/**
 * Kill the L2NpcInstance (the corpse disappeared after 7 seconds).<BR><BR>
 * 
 * <B><U> Actions</U> :</B><BR><BR>
 * <li>Create a DecayTask to remove the corpse of the L2NpcInstance after 7 seconds </li>
 * <li>Set target to null and cancel Attack or Cast </li>
 * <li>Stop movement </li>
 * <li>Stop HP/MP/CP Regeneration task </li>
 * <li>Stop all active skills effects in progress on the L2Character </li>
 * <li>Send the Server->Client packet StatusUpdate with current HP and MP to all other L2PcInstance to inform </li>
 * <li>Notify L2Character AI </li><BR><BR>
 * 
 * <B><U> Overridden in </U> :</B><BR><BR>
 * <li> L2Attackable </li><BR><BR>
 * 
 * @param killer The L2Character who killed it
 * 
 */
@Override
public boolean doDie(L2Character killer)
{
	//If killer instanceof L2PetInstance or instanceof L2SummonInstance, this is going to get the player that controls the killer.
	L2PcInstance player = null;
	player = killer.getActingPlayer();
				
	//ANTIBOT - Start
	if((killer instanceof L2PcInstance) || (killer instanceof L2PetInstance) || (killer instanceof L2SummonInstance))
	{
		//+1 to mobcounter
		player.setKills(player.getKills() + 1);
				
		//Checks the mobcounter
		if(player.getKills() == 50)
		{
			//Random image file name
			int imgId = IdFactory.getInstance().getNextId();
			//Convertion from .png to .dds, and crest packed send
			try
			{
				File captcha = new File("data/captcha/captcha.png");    
				ImageIO.write(generateCaptcha(), "png", captcha);
				PledgeCrest packet = new PledgeCrest(imgId, DDSConverter.convertToDDS(captcha).array()); //Convertion to DDS where is antybot
				player.sendPacket(packet);
			}
			catch (Exception e)
			{    
				_log.warning(e.getMessage());
			}
			//Paralyze, abnormal effect, invul, html with captcha output and start of the 1 min counter
			player.startAbnormalEffect(AbnormalEffect.REAL_TARGET);
			player.setIsParalyzed(true);
			player.setIsInvul(true);
			adminReply.setHtml("<html><title>Captcha Antibot System</title><body><center>Enter the 5-digits code below and click Confirm.<br><img src=\"Crest.crest_" + Config.SERVER_ID + "_" + imgId + "\" width=256 height=64><br><font color=\"888888\">(There are only english uppercase letters.)</font><br1><font color=\"FF0000\">Tries Left: " + player.getTries() +"</font><br><edit var=\"antibot\" width=110><br><button value=\"Confirm\" action=\"bypass -h voice .antibot $antibot\" width=80 height=26 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_ct1.button_df\"><br>If you close by mistake this window,<br1>you can re-open it by typing \".captcha\" on Chat.<br1>You have 3 minutes to answer or you<br1>will get jailed.<br1>You have 3 tries, if you will<br1>answer wrong to all of them you<br1>will get punished.</center></body></html>");
			player.sendPacket(adminReply);
			player.setCode(finalString);
			ThreadPoolManager.getInstance().scheduleGeneral(new CaptchaTimer(player), 180000);//180sec
			player.setCodeRight(false);
			finalString.replace(0, 5, "");
		}
	}
	//ANTIBOT - End

	if (!super.doDie(killer))
		return false;
	
	if(getGlobalEvent() != null)
		getGlobalEvent().monsterDies(this);
	
	// normally this wouldn't really be needed, but for those few exceptions,
	// we do need to reset the weapons back to the initial templated weapon.
	_currentLHandId = getTemplate().lhand;
	_currentRHandId = getTemplate().rhand;
	/*		_currentCollisionHeight = getCollisionHeight();
		_currentCollisionRadius = getCollisionRadius();*/
	DecayTaskManager.getInstance().addDecayTask(this);
	return true;
}

//3 Mins Counter and the event that happens
class CaptchaTimer implements Runnable
{
	L2PcInstance activeChar;
	public CaptchaTimer(L2PcInstance player)
	{
		activeChar = player;
	}
	public void run()
	{
		//here will be code that will run after 1 min
		if(!activeChar.isCodeRight())
		{
			activeChar.setTries(3);
			//here will run method with jailing player after 1 min
			activeChar.stopAbnormalEffect(AbnormalEffect.REAL_TARGET);
			NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(0);
			npcHtmlMessage.setHtml("<html><title>Captcha Antibot System</title><body><center><font color=\"FF0000\">3 minutes passed.<br><br></font><font color=\"66FF00\"><center></font><font color=\"FF0000\">You will be jailed.</font><br><button value=\"Exit\" action=\"bypass -h npc_%objectId%_Quest\" width=45 height=25 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_ct1.button_df\"></center></body></html>");
			if (activeChar.isFlyingMounted())
				activeChar.untransform();
			activeChar.setPunishLevel(L2PcInstance.PunishLevel.JAIL, 1);
			activeChar.setIsInvul(false);
			activeChar.setIsParalyzed(false);
			activeChar.sendPacket(npcHtmlMessage);
		}
	}
}

/**
 * Set the spawn of the L2NpcInstance.<BR><BR>
 * 
 * @param spawn The L2Spawn that manage the L2NpcInstance
 * 
 */
public void setSpawn(L2Spawn spawn)
{
	_spawn = spawn;
}

@Override
public void onSpawn()
{
	if (_inventory != null)
		_inventory.reset();
	
	super.onSpawn();
	
	if (getTemplate().getEventQuests(Quest.QuestEventType.ON_SPAWN) != null)
		for (Quest quest : getTemplate().getEventQuests(Quest.QuestEventType.ON_SPAWN))
			quest.notifySpawn(this);
}

/**
 * Remove the L2NpcInstance from the world and update its spawn object (for a complete removal use the deleteMe method).<BR><BR>
 * 
 * <B><U> Actions</U> :</B><BR><BR>
 * <li>Remove the L2NpcInstance from the world when the decay task is launched </li>
 * <li>Decrease its spawn counter </li>
 * <li>Manage Siege task (killFlag, killCT) </li><BR><BR>
 * 
 * <FONT COLOR=#FF0000><B> <U>Caution</U> : This method DOESN'T REMOVE the object from _allObjects of L2World </B></FONT><BR>
 * <FONT COLOR=#FF0000><B> <U>Caution</U> : This method DOESN'T SEND Server->Client packets to players</B></FONT><BR><BR>
 * 
 */
@Override
public void onDecay()
{
	if (isDecayed())
		return;
	setDecayed(true);
	
	// Manage Life Control Tower
	if (this instanceof L2ControlTowerInstance)
		((L2ControlTowerInstance) this).onDeath();
	
	// Remove the L2NpcInstance from the world when the decay task is launched
	super.onDecay();
	
	// Decrease its spawn counter
	if (_spawn != null)
		_spawn.decreaseCount(this);
}

/**
 * Remove PROPERLY the L2NpcInstance from the world.<BR><BR>
 * 
 * <B><U> Actions</U> :</B><BR><BR>
 * <li>Remove the L2NpcInstance from the world and update its spawn object </li>
 * <li>Remove all L2Object from _knownObjects and _knownPlayer of the L2NpcInstance then cancel Attack or Cast and notify AI </li>
 * <li>Remove L2Object object from _allObjects of L2World </li><BR><BR>
 * 
 * <FONT COLOR=#FF0000><B> <U>Caution</U> : This method DOESN'T SEND Server->Client packets to players</B></FONT><BR><BR>
 * 
 */
public void deleteMe()
{
	L2WorldRegion oldRegion = getWorldRegion();
	
	try
	{
		decayMe();
	}
	catch (Exception e)
	{
		_log.log(Level.SEVERE, "Failed decayMe().", e);
	}
	try
	{
		if (_fusionSkill != null)
			abortCast();
		
		for (L2Character character : getKnownList().getKnownCharacters())
			if (character.getFusionSkill() != null && character.getFusionSkill().getTarget() == this)
				character.abortCast();
	}
	catch (Exception e)
	{
		_log.log(Level.SEVERE, "deleteMe()", e);
	}
	if (oldRegion != null)
		oldRegion.removeFromZones(this);
	
	// Remove all L2Object from _knownObjects and _knownPlayer of the L2Character then cancel Attak or Cast and notify AI
	try
	{
		getKnownList().removeAllKnownObjects();
	}
	catch (Exception e)
	{
		_log.log(Level.SEVERE, "Failed removing cleaning knownlist.", e);
	}
	
	// Remove L2Object object from _allObjects of L2World
	L2World.getInstance().removeObject(this);
}

/**
 * Return the L2Spawn object that manage this L2NpcInstance.<BR><BR>
 */
public L2Spawn getSpawn()
{
	return _spawn;
}

@Override
public String toString()
{
	return getTemplate().name;
}

public boolean isDecayed()
{
	return _isDecayed;
}

public void setDecayed(boolean decayed)
{
	_isDecayed = decayed;
}

public void endDecayTask()
{
	if (!isDecayed())
	{
		DecayTaskManager.getInstance().cancelDecayTask(this);
		onDecay();
	}
}

public boolean isMob() // rather delete this check
{
	return false; // This means we use MAX_NPC_ANIMATION instead of MAX_MONSTER_ANIMATION
}

// Two functions to change the appearance of the equipped weapons on the NPC
// This is only useful for a few NPCs and is most likely going to be called from AI
public void setLHandId(int newWeaponId)
{
	_currentLHandId = newWeaponId;
	updateAbnormalEffect();
}

public void setRHandId(int newWeaponId)
{
	_currentRHandId = newWeaponId;
	updateAbnormalEffect();
}

public void setLRHandId(int newLWeaponId, int newRWeaponId)
{
	_currentRHandId = newRWeaponId;
	_currentLHandId = newLWeaponId;
	updateAbnormalEffect();
}

public void setCollisionHeight(float height)
{
	_currentCollisionHeight = height;
}

public void setCollisionRadius(float f)
{
	_currentCollisionRadius = f;
}

public float getCurrCollisionHeight()
{
	return _currentCollisionHeight;
}

public float getCurrCollisionRadius()
{
	return _currentCollisionRadius;
}

public boolean isUsingShot(boolean d)
{
	return isUsingShot();
}
public boolean isUsingShot()
{
	if (getTemplate().ssRate == 0)
		return false;
	
	if (getTemplate().ssRate >= Rnd.get(100))
		return true;
	
	return false;
}

@Override
public NpcInventory getInventory()
{
	return _inventory;
}

@Override
public void sendInfo(L2PcInstance activeChar)
{
	if (Config.CHECK_KNOWN) activeChar.sendMessage("Added NPC: "+getName());
	if (getRunSpeed() == 0)
		activeChar.sendPacket(new ServerObjectInfo(this, activeChar));
	else
		activeChar.sendPacket(new AbstractNpcInfo.NpcInfo(this, activeChar));
}

public int getElite()
{
	return getTemplate().elite;
}
public int getRare()
{
	return getTemplate().rare;
}

public void setIsTempSpawn()
{
	_tempSpawn = true;
}
}

package handlers.voicedcommandhandlers;

import gov.nasa.worldwind.formats.dds.DDSConverter;

import java.awt.Color;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics2D;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.StringTokenizer;
import java.util.logging.Level;

import javax.imageio.ImageIO;

import net.sf.l2j.Config;
import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
import net.sf.l2j.gameserver.idfactory.IdFactory;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
import net.sf.l2j.gameserver.network.serverpackets.PledgeCrest;
import net.sf.l2j.gameserver.skills.AbnormalEffect;
/**
 *
 * @author Pipiou211
 *
 */
public class AntiBot implements IVoicedCommandHandler
{
private static final String[] _voicedCommands = { "antibot" };


public static StringBuilder finalString = new StringBuilder();
NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
private static BufferedImage generateCaptcha()
{    
	   Color textColor = new Color(98, 213, 43);
	   Color circleColor = new Color(98, 213, 43);
	   Font textFont = new Font("comic sans ms", Font.BOLD, 24);
	   int charsToPrint = 5;
	   int width = 256;
	   int height = 64;
	   int circlesToDraw = 8;
	   float horizMargin = 20.0f;
	   double rotationRange = 0.7; // this is radians
	   BufferedImage bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);

	   Graphics2D g = (Graphics2D) bufferedImage.getGraphics();

	   //Draw an oval
	   g.setColor(new Color(30,31,31));
	   g.fillRect(0, 0, width, height);

	   // lets make some noisey circles
	   g.setColor(circleColor);
	   for ( int i = 0; i < circlesToDraw; i++ ) {
	     int circleRadius = (int) (Math.random() * height / 2.0);
	     int circleX = (int) (Math.random() * width - circleRadius);
	     int circleY = (int) (Math.random() * height - circleRadius);
	     g.drawOval(circleX, circleY, circleRadius * 2, circleRadius * 2);
	   }

	   g.setColor(textColor);
	   g.setFont(textFont);

	   FontMetrics fontMetrics = g.getFontMetrics();
	   int maxAdvance = fontMetrics.getMaxAdvance();
	   int fontHeight = fontMetrics.getHeight();
	   
	   // Suggestions ----------------------------------------------------------------------
	   // i removed 1 and l and i because there are confusing to users...
	   // Z, z, and N also get confusing when rotated
	   // 0, O, and o are also confusing...
	   // lowercase G looks a lot like a 9 so i killed it
	   // this should ideally be done for every language...
	   // i like controlling the characters though because it helps prevent confusion
	   // So recommended chars are:
	   // String elegibleChars = "ABCDEFGHJKLMPQRSTUVWXYabcdefhjkmnpqrstuvwxy23456789";
	   // Suggestions ----------------------------------------------------------------------
	   String elegibleChars = "ABCDEFGHJKLMPQRSTUVWXYZ";
	   char[] chars = elegibleChars.toCharArray();

	   float spaceForLetters = -horizMargin * 2 + width;
	   float spacePerChar = spaceForLetters / (charsToPrint - 1.0f);

	   for ( int i = 0; i < charsToPrint; i++ ) {
	     double randomValue = Math.random();
	     int randomIndex = (int) Math.round(randomValue * (chars.length - 1));
	     char characterToShow = chars[randomIndex];
	     finalString.append(characterToShow);

	     // this is a separate canvas used for the character so that
	     // we can rotate it independently
	     int charWidth = fontMetrics.charWidth(characterToShow);
	     int charDim = Math.max(maxAdvance, fontHeight);
	     int halfCharDim = (charDim / 2);

	     BufferedImage charImage = new BufferedImage(charDim, charDim, BufferedImage.TYPE_INT_ARGB);
	     Graphics2D charGraphics = charImage.createGraphics();
	     charGraphics.translate(halfCharDim, halfCharDim);
	     double angle = (Math.random() - 0.5) * rotationRange;
	     charGraphics.transform(AffineTransform.getRotateInstance(angle));
	     charGraphics.translate(-halfCharDim,-halfCharDim);
	     charGraphics.setColor(textColor);
	     charGraphics.setFont(textFont);

	     int charX = (int) (0.5 * charDim - 0.5 * charWidth);
	     charGraphics.drawString("" + characterToShow, charX, 
	                            ((charDim - fontMetrics.getAscent()) 
	                                   / 2 + fontMetrics.getAscent()));

	     float x = horizMargin + spacePerChar * (i) - charDim / 2.0f;
	     int y = ((height - charDim) / 2);
	     g.drawImage(charImage, (int) x, y, charDim, charDim, null, null);

	     charGraphics.dispose();
	   }
	   
		g.dispose();     
		
		return bufferedImage;
		}

public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target)
{
	NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(0);
	if (command.equalsIgnoreCase("antibot") && target != null)
	{
		StringTokenizer st = new StringTokenizer(target);
		try
		{
			String newpass = null, repeatnewpass = null;
			if (st.hasMoreTokens())
				newpass = st.nextToken();
				repeatnewpass = activeChar.getCode();
			
			if (!(newpass == null || repeatnewpass == null))
			{
				if (newpass.equals(repeatnewpass))//Right:)
				{
					npcHtmlMessage.setHtml("<html><title>Captcha Antibot System</title><body><center><font color=\"00FF00\">Correct Captcha.<br><br></font><center><br><button value=\"Exit\" action=\"bypass -h npc_%objectId%_Quest\" width=45 height=25 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_ct1.button_df\"></center></body></html>");
					activeChar.sendPacket(npcHtmlMessage);
					activeChar.stopAbnormalEffect(AbnormalEffect.REAL_TARGET);
					activeChar.setIsInvul(false);
					activeChar.setIsParalyzed(false);
					activeChar.setKills(0);
					activeChar.setCodeRight(true);
					return false;
				}
				
			}
			if (!newpass.equals(repeatnewpass))//Wrong
			{
				if (activeChar.getTries() > 1)
				{
				activeChar.setTries(activeChar.getTries() -1);
				//Random image file name
				int imgId = IdFactory.getInstance().getNextId();
				//Convertion from .png to .dds, and crest packed send
				try
				{
					File captcha = new File("data/captcha/captcha.png");    
					ImageIO.write(generateCaptcha(), "png", captcha);
					PledgeCrest packet = new PledgeCrest(imgId, DDSConverter.convertToDDS(captcha).array()); //Convertion to DDS where is antybot
					activeChar.sendPacket(packet);
				}
				catch (Exception e)
				{    
					_log.warning(e.getMessage());
				}
				//Paralyze, abnormal effect, invul, html with captcha output and start of the 1 min counter
				adminReply.setHtml("<html><title>Captcha Antibot System</title><body><center>Enter the 5-digits code below and click Confirm.<br><img src=\"Crest.crest_" + Config.SERVER_ID + "_" + imgId + "\" width=256 height=64><br><font color=\"888888\">(There are only english uppercase letters.)</font><br1><font color=\"FF0000\">Tries Left: " + activeChar.getTries() +"</font><br><edit var=\"antibot\" width=110><br><button value=\"Confirm\" action=\"bypass -h voice .antibot $antibot\" width=80 height=26 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_ct1.button_df\"><br>If you close by mistake this window,<br1>you can re-open it by typing \".captcha\" on Chat.<br1>You have 3 minutes to answer or you<br1>will get jailed.<br1>You have 3 tries, if you will<br1>answer wrong to all of them you<br1>will get punished.</center></body></html>");
				activeChar.sendPacket(adminReply);
				activeChar.setCode(finalString);
				finalString.replace(0, 5, "");
				return false;
				}
				activeChar.setPunishLevel(L2PcInstance.PunishLevel.JAIL, 1);
				return false;
			}
			else
			{
				if (activeChar.getTries() > 1)
				{
				activeChar.setTries(activeChar.getTries() -1);
				//Random image file name
				int imgId = IdFactory.getInstance().getNextId();
				//Convertion from .png to .dds, and crest packed send
				try
				{
					File captcha = new File("data/captcha/captcha.png");    
					ImageIO.write(generateCaptcha(), "png", captcha);
					PledgeCrest packet = new PledgeCrest(imgId, DDSConverter.convertToDDS(captcha).array()); //Convertion to DDS where is antybot
					activeChar.sendPacket(packet);
				}
				catch (Exception e)
				{    
					_log.warning(e.getMessage());
				}
				//Paralyze, abnormal effect, invul, html with captcha output and start of the 1 min counter
				adminReply.setHtml("<html><title>Captcha Antibot System</title><body><center>Enter the 5-digits code below and click Confirm.<br><img src=\"Crest.crest_" + Config.SERVER_ID + "_" + imgId + "\" width=256 height=64><br><font color=\"888888\">(There are only english uppercase letters.)</font><br1><font color=\"FF0000\">Tries Left: " + activeChar.getTries() +"</font><br><edit var=\"antibot\" width=110><br><button value=\"Confirm\" action=\"bypass -h voice .antibot $antibot\" width=80 height=26 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_ct1.button_df\"><br>If you close by mistake this window,<br1>you can re-open it by typing \".captcha\" on Chat.<br1>You have 3 minutes to answer or you<br1>will get jailed.<br1>You have 3 tries, if you will<br1>answer wrong to all of them you<br1>will get punished.</center></body></html>");
				activeChar.sendPacket(adminReply);
				activeChar.setCode(finalString);
				finalString.replace(0, 5, "");
				return false;
				}
				//here will run method with jailing player
				activeChar.stopAbnormalEffect(AbnormalEffect.REAL_TARGET);
				npcHtmlMessage.setHtml("<html><title>Captcha Antibot System</title><body><center><font color=\"FF0000\">You have wasted your Tries.<br><br></font><font color=\"66FF00\"><center></font><font color=\"FF0000\">You will be jailed.</font><br><button value=\"Exit\" action=\"bypass -h npc_%objectId%_Quest\" width=45 height=25 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_ct1.button_df\"></center></body></html>");
				if (activeChar.isFlyingMounted())
					activeChar.untransform();
				activeChar.setPunishLevel(L2PcInstance.PunishLevel.JAIL, 1);
				activeChar.setIsInvul(false);
				activeChar.setIsParalyzed(false);
				activeChar.sendPacket(npcHtmlMessage);
				return false;
			}
		}
		catch (Exception e)
		{
			activeChar.sendMessage("A problem occured while adding captcha!");
			_log.log(Level.WARNING, "", e);
		}
	}
	else
	{
		if (activeChar.getTries() > 1)
		{
		activeChar.setTries(activeChar.getTries() -1);
		//Random image file name
		int imgId = IdFactory.getInstance().getNextId();
		//Convertion from .png to .dds, and crest packed send
		try
		{
			File captcha = new File("data/captcha/captcha.png");    
			ImageIO.write(generateCaptcha(), "png", captcha);
			PledgeCrest packet = new PledgeCrest(imgId, DDSConverter.convertToDDS(captcha).array()); //Convertion to DDS where is antybot
			activeChar.sendPacket(packet);
		}
		catch (Exception e)
		{    
			_log.warning(e.getMessage());
		}
		//Paralyze, abnormal effect, invul, html with captcha output and start of the 1 min counter
		adminReply.setHtml("<html><title></title><body><center>Enter the 5-digits code below and click Confirm.<br><img src=\"Crest.crest_" + Config.SERVER_ID + "_" + imgId + "\" width=256 height=64><br><font color=\"888888\">(There are only english uppercase letters.)</font><br1><font color=\"FF0000\">Tries Left: " + activeChar.getTries() +"</font><br><edit var=\"antibot\" width=110><br><button value=\"Confirm\" action=\"bypass -h voice .antibot $antibot\" width=80 height=26 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_ct1.button_df\"><br>If you close by mistake this window,<br1>you can re-open it by typing \".captcha\" on Chat.<br1>You have 3 minutes to answer or you<br1>will get jailed.<br1>You have 3 tries, if you will<br1>answer wrong to all of them you<br1>will get punished.</center></body></html>");
		activeChar.sendPacket(adminReply);
		activeChar.setCode(finalString);
		finalString.replace(0, 5, "");
		return false;
	}
		//here will run method with jailing player
		activeChar.stopAbnormalEffect(AbnormalEffect.REAL_TARGET);
		npcHtmlMessage.setHtml("<html><title>Captcha Antibot System</title><body><center><font color=\"FF0000\">You have wasted your Tries.<br><br></font><font color=\"66FF00\"><center></font><font color=\"FF0000\">You will be jailed.</font><br><button value=\"Exit\" action=\"bypass -h npc_%objectId%_Quest\" width=45 height=25 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_ct1.button_df\"></center></body></html>");
		if (activeChar.isFlyingMounted())
			activeChar.untransform();
		activeChar.setPunishLevel(L2PcInstance.PunishLevel.JAIL, 1);
		activeChar.setIsInvul(false);
		activeChar.setIsParalyzed(false);
		activeChar.sendPacket(npcHtmlMessage);
	return false;
}
	return true;
}

public String[] getVoicedCommandList()
{
	return _voicedCommands;
}
}
package handlers.voicedcommandhandlers;

import gov.nasa.worldwind.formats.dds.DDSConverter;

import java.awt.Color;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics2D;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
import java.io.File;

import javax.imageio.ImageIO;

import net.sf.l2j.Config;
import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
import net.sf.l2j.gameserver.idfactory.IdFactory;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
import net.sf.l2j.gameserver.network.serverpackets.PledgeCrest;
import net.sf.l2j.gameserver.skills.AbnormalEffect;

/**
 *
 * @author Pipiou211
 *
 */
public class Captcha implements IVoicedCommandHandler //when you click on confirm, also this code is running or something else? this, only, and just //unpara the targetpl
{
	private static final String[] _voicedCommands =
	{
		"captcha"
	};
	
    public static StringBuilder finalString = new StringBuilder();
	NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
	private static BufferedImage generateCaptcha()
	{    
		   Color textColor = new Color(98, 213, 43);
		   Color circleColor = new Color(98, 213, 43);
		   Font textFont = new Font("comic sans ms", Font.BOLD, 24);
		   int charsToPrint = 5;
		   int width = 256;
		   int height = 64;
		   int circlesToDraw = 8;
		   float horizMargin = 20.0f;
		   double rotationRange = 0.7; // this is radians
		   BufferedImage bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);

		   Graphics2D g = (Graphics2D) bufferedImage.getGraphics();

		   //Draw an oval
		   g.setColor(new Color(30,31,31));
		   g.fillRect(0, 0, width, height);

		   // lets make some noisey circles
		   g.setColor(circleColor);
		   for ( int i = 0; i < circlesToDraw; i++ ) {
		     int circleRadius = (int) (Math.random() * height / 2.0);
		     int circleX = (int) (Math.random() * width - circleRadius);
		     int circleY = (int) (Math.random() * height - circleRadius);
		     g.drawOval(circleX, circleY, circleRadius * 2, circleRadius * 2);
		   }

		   g.setColor(textColor);
		   g.setFont(textFont);

		   FontMetrics fontMetrics = g.getFontMetrics();
		   int maxAdvance = fontMetrics.getMaxAdvance();
		   int fontHeight = fontMetrics.getHeight();
		   
		   // Suggestions ----------------------------------------------------------------------
		   // i removed 1 and l and i because there are confusing to users...
		   // Z, z, and N also get confusing when rotated
		   // 0, O, and o are also confusing...
		   // lowercase G looks a lot like a 9 so i killed it
		   // this should ideally be done for every language...
		   // i like controlling the characters though because it helps prevent confusion
		   // So recommended chars are:
		   // String elegibleChars = "ABCDEFGHJKLMPQRSTUVWXYabcdefhjkmnpqrstuvwxy23456789";
		   // Suggestions ----------------------------------------------------------------------
		   String elegibleChars = "ABCDEFGHJKLMPQRSTUVWXYZ";
		   char[] chars = elegibleChars.toCharArray();

		   float spaceForLetters = -horizMargin * 2 + width;
		   float spacePerChar = spaceForLetters / (charsToPrint - 1.0f);

		   for ( int i = 0; i < charsToPrint; i++ ) {
		     double randomValue = Math.random();
		     int randomIndex = (int) Math.round(randomValue * (chars.length - 1));
		     char characterToShow = chars[randomIndex];
		     finalString.append(characterToShow);

		     // this is a separate canvas used for the character so that
		     // we can rotate it independently
		     int charWidth = fontMetrics.charWidth(characterToShow);
		     int charDim = Math.max(maxAdvance, fontHeight);
		     int halfCharDim = (charDim / 2);

		     BufferedImage charImage = new BufferedImage(charDim, charDim, BufferedImage.TYPE_INT_ARGB);
		     Graphics2D charGraphics = charImage.createGraphics();
		     charGraphics.translate(halfCharDim, halfCharDim);
		     double angle = (Math.random() - 0.5) * rotationRange;
		     charGraphics.transform(AffineTransform.getRotateInstance(angle));
		     charGraphics.translate(-halfCharDim,-halfCharDim);
		     charGraphics.setColor(textColor);
		     charGraphics.setFont(textFont);

		     int charX = (int) (0.5 * charDim - 0.5 * charWidth);
		     charGraphics.drawString("" + characterToShow, charX, 
		                            ((charDim - fontMetrics.getAscent()) 
		                                   / 2 + fontMetrics.getAscent()));

		     float x = horizMargin + spacePerChar * (i) - charDim / 2.0f;
		     int y = ((height - charDim) / 2);
		     g.drawImage(charImage, (int) x, y, charDim, charDim, null, null);

		     charGraphics.dispose();
		   }
		   
			g.dispose();     
			
			return bufferedImage;
			}
	
	public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target)
	{
		NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(0);
		if (command.equalsIgnoreCase("captcha") && !activeChar.isCodeRight())
		{
							if (activeChar.getTries() > 1)
				{
				activeChar.setTries(activeChar.getTries() -1);
				//Random image file name
				int imgId = IdFactory.getInstance().getNextId();
				//Convertion from .png to .dds, and crest packed send
				try
				{
					File captcha = new File("data/captcha/captcha.png");    
					ImageIO.write(generateCaptcha(), "png", captcha);
					PledgeCrest packet = new PledgeCrest(imgId, DDSConverter.convertToDDS(captcha).array()); //Convertion to DDS where is antybot
					activeChar.sendPacket(packet);
				}
				catch (Exception e)
				{    
					_log.warning(e.getMessage());
				}
				//Paralyze, abnormal effect, invul, html with captcha output and start of the 1 min counter
				adminReply.setHtml("<html><title>Captcha Antibot System</title><body><center>Enter the 5-digits code below and click Confirm.<br><img src=\"Crest.crest_" + Config.SERVER_ID + "_" + imgId + "\" width=256 height=64><br><font color=\"888888\">(There are only english uppercase letters.)</font><br1><font color=\"FF0000\">Tries Left: " + activeChar.getTries() +"</font><br><edit var=\"antibot\" width=110><br><button value=\"Confirm\" action=\"bypass -h voice .antibot $antibot\" width=80 height=26 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_ct1.button_df\"><br>If you close by mistake this window,<br1>you can re-open it by typing \".captcha\" on Chat.<br1>You have 3 minutes to answer or you<br1>will get jailed.<br1>You have 3 tries, if you will<br1>answer wrong to all of them you<br1>will get punished.</center></body></html>");
				activeChar.sendPacket(adminReply);
				activeChar.setCode(finalString);
				finalString.replace(0, 5, "");
				return false;
				}
				activeChar.setTries(3);
				//here will run method with jailing player
				activeChar.stopAbnormalEffect(AbnormalEffect.REAL_TARGET);
				npcHtmlMessage.setHtml("<html><title>Captcha Antibot System</title><body><center><font color=\"FF0000\">You have wasted your Tries.<br><br></font><font color=\"66FF00\"><center></font><font color=\"FF0000\">You will be jailed.</font><br><button value=\"Exit\" action=\"bypass -h npc_%objectId%_Quest\" width=45 height=25 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_ct1.button_df\"></center></body></html>");
				if (activeChar.isFlyingMounted())
					activeChar.untransform();
				activeChar.setPunishLevel(L2PcInstance.PunishLevel.JAIL, 1);
				activeChar.setIsInvul(false);
				activeChar.setIsParalyzed(false);
				activeChar.sendPacket(npcHtmlMessage);
			return false;
		}
		else
		{
			return false;
		}
		//return false;
	}
	
	public String[] getVoicedCommandList()
	{
		return _voicedCommands;
	}
}
/*
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU General Public License along with
 * this program. If not, see <http://www.gnu.org/licenses/>.
 */
package handlers;

import handlers.admincommandhandlers.*;
import handlers.chathandlers.*;
import handlers.itemhandlers.*;
import handlers.skillhandlers.*;
import handlers.usercommandhandlers.*;
import handlers.voicedcommandhandlers.*;
import handlers.voicedcommandhandlers.stats;
import handlers.voicedcommandhandlers.AntiBot;
import handlers.voicedcommandhandlers.Captcha;

import java.util.logging.Logger;

import net.sf.l2j.Config;
import net.sf.l2j.gameserver.handler.AdminCommandHandler;
import net.sf.l2j.gameserver.handler.ChatHandler;
import net.sf.l2j.gameserver.handler.ItemHandler;
import net.sf.l2j.gameserver.handler.SkillHandler;
import net.sf.l2j.gameserver.handler.UserCommandHandler;
import net.sf.l2j.gameserver.handler.VoicedCommandHandler;

/**
 *
 * @author  nBd
 */
public class MasterHandler
{
	private static Logger _log = Logger.getLogger(MasterHandler.class.getName());
	
	private static void loadAdminHandlers()
	{
		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminAdmin());
		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminAnnouncements());
		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminBan());
		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminBBS());
		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminBuffs());
		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminCache());
		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminChangeAccessLevel());
		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminCreateItem());
		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminCursedWeapons());
		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminDelete());
		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminDisconnect());
		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminDoorControl());
		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminEditChar());
		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminEditNpc());
		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminEffects());
		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminElement());
		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminEnchant());
		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminEventEngine());
		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminExpSp());
		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminFightCalculator());
		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminFortSiege());
		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminGeodata());
		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminGeoEditor());
		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminGm());
		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminGmChat());
		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminHeal());
		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminHelpPage());
		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminInstance());
		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminInvul());
		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminKick());
		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminKill());
		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminLevel());
		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminLogin());
		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminMammon());
		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminManor());
		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminMenu());
		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminMobGroup());
		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminMonsterRace());
		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminPathNode());
		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminPetition());
		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminPForge());
		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminPledge());
		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminPolymorph());
		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminQuest());
		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminRepairChar());
		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminRes());
		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminRide());
		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminShop());
		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminShutdown());
		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminSiege());
		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminSkill());
		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminSpawn());
		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminSummon());
		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminTarget());
		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminTeleport());
		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminTest());
		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminTvTEvent());
		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminUnblockIp());
		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminZone());
		_log.config("Loaded " + AdminCommandHandler.getInstance().size() + "  AdminCommandHandlers");
	}
	
	private static void loadChatHandlers()
	{
		ChatHandler.getInstance().registerChatHandler(new ChatAll());
		ChatHandler.getInstance().registerChatHandler(new ChatAlliance());
		ChatHandler.getInstance().registerChatHandler(new ChatClan());
		ChatHandler.getInstance().registerChatHandler(new ChatHeroVoice());
		ChatHandler.getInstance().registerChatHandler(new ChatParty());
		ChatHandler.getInstance().registerChatHandler(new ChatPartyRoomAll());
		ChatHandler.getInstance().registerChatHandler(new ChatPartyRoomCommander());
		ChatHandler.getInstance().registerChatHandler(new ChatPetition());
		ChatHandler.getInstance().registerChatHandler(new ChatShout());
		ChatHandler.getInstance().registerChatHandler(new ChatTell());
		ChatHandler.getInstance().registerChatHandler(new ChatTrade());
		_log.config("Loaded " + ChatHandler.getInstance().size() + "  ChatHandlers");
	}
	
	private static void loadItemHandlers()
	{
		ItemHandler.getInstance().registerItemHandler(new ScrollOfResurrection());
		ItemHandler.getInstance().registerItemHandler(new SoulShots());
		ItemHandler.getInstance().registerItemHandler(new SpiritShot());
		ItemHandler.getInstance().registerItemHandler(new BlessedSpiritShot());
		ItemHandler.getInstance().registerItemHandler(new BeastSoulShot());
		ItemHandler.getInstance().registerItemHandler(new BeastSpiritShot());
		ItemHandler.getInstance().registerItemHandler(new PaganKeys());
		ItemHandler.getInstance().registerItemHandler(new Maps());
		ItemHandler.getInstance().registerItemHandler(new Potions());
		ItemHandler.getInstance().registerItemHandler(new Recipes());
		ItemHandler.getInstance().registerItemHandler(new RollingDice());
		ItemHandler.getInstance().registerItemHandler(new EnchantAttribute());
		ItemHandler.getInstance().registerItemHandler(new EnchantScrolls());
		ItemHandler.getInstance().registerItemHandler(new ExtractableItems());
		ItemHandler.getInstance().registerItemHandler(new Book());
		ItemHandler.getInstance().registerItemHandler(new SoulCrystals());
		ItemHandler.getInstance().registerItemHandler(new SevenSignsRecord());
		ItemHandler.getInstance().registerItemHandler(new ItemSkills());
		ItemHandler.getInstance().registerItemHandler(new Seed());
		ItemHandler.getInstance().registerItemHandler(new Harvester());
		ItemHandler.getInstance().registerItemHandler(new MercTicket());
		ItemHandler.getInstance().registerItemHandler(new FishShots());
		ItemHandler.getInstance().registerItemHandler(new PetFood());
		ItemHandler.getInstance().registerItemHandler(new SpecialXMas());
		ItemHandler.getInstance().registerItemHandler(new SummonItems());
		ItemHandler.getInstance().registerItemHandler(new BeastSpice());
		ItemHandler.getInstance().registerItemHandler(new TeleportBookmark());
		ItemHandler.getInstance().registerItemHandler(new Elixir());
		_log.config("Loaded " + ItemHandler.getInstance().size() + " ItemHandlers");
	}
	
	private static void loadSkillHandlers()
	{
		SkillHandler.getInstance().registerSkillHandler(new Blow());
		SkillHandler.getInstance().registerSkillHandler(new Pdam());
		SkillHandler.getInstance().registerSkillHandler(new Mdam());
		SkillHandler.getInstance().registerSkillHandler(new CpDam());
		SkillHandler.getInstance().registerSkillHandler(new Manadam());
		SkillHandler.getInstance().registerSkillHandler(new Heal());
		SkillHandler.getInstance().registerSkillHandler(new CombatPointHeal());
		SkillHandler.getInstance().registerSkillHandler(new ManaHeal());
		SkillHandler.getInstance().registerSkillHandler(new BalanceLife());
		SkillHandler.getInstance().registerSkillHandler(new Charge());
		SkillHandler.getInstance().registerSkillHandler(new Continuous());
		SkillHandler.getInstance().registerSkillHandler(new ChangeFace());
		SkillHandler.getInstance().registerSkillHandler(new Resurrect());
		SkillHandler.getInstance().registerSkillHandler(new ShiftTarget());
		SkillHandler.getInstance().registerSkillHandler(new Spoil());
		SkillHandler.getInstance().registerSkillHandler(new Sweep());
		SkillHandler.getInstance().registerSkillHandler(new StrSiegeAssault());
		SkillHandler.getInstance().registerSkillHandler(new SummonFriend());
		SkillHandler.getInstance().registerSkillHandler(new SummonTreasureKey());
		SkillHandler.getInstance().registerSkillHandler(new Disablers());
		SkillHandler.getInstance().registerSkillHandler(new Recall());
		SkillHandler.getInstance().registerSkillHandler(new BallistaBomb());
		SkillHandler.getInstance().registerSkillHandler(new TakeCastle());
		SkillHandler.getInstance().registerSkillHandler(new TakeFort());
		SkillHandler.getInstance().registerSkillHandler(new Unlock());
		SkillHandler.getInstance().registerSkillHandler(new DrainSoul());
		SkillHandler.getInstance().registerSkillHandler(new Craft());
		SkillHandler.getInstance().registerSkillHandler(new Fishing());
		SkillHandler.getInstance().registerSkillHandler(new FishingSkill());
		SkillHandler.getInstance().registerSkillHandler(new LearnSkill());
		SkillHandler.getInstance().registerSkillHandler(new BeastFeed());
		SkillHandler.getInstance().registerSkillHandler(new DeluxeKey());
		SkillHandler.getInstance().registerSkillHandler(new Sow());
		SkillHandler.getInstance().registerSkillHandler(new Soul());
		SkillHandler.getInstance().registerSkillHandler(new Harvest());
		SkillHandler.getInstance().registerSkillHandler(new GetPlayer());
		SkillHandler.getInstance().registerSkillHandler(new TransformDispel());
		SkillHandler.getInstance().registerSkillHandler(new Trap());
		SkillHandler.getInstance().registerSkillHandler(new GiveSp());
		SkillHandler.getInstance().registerSkillHandler(new InstantJump());
		SkillHandler.getInstance().registerSkillHandler(new Dummy());
		SkillHandler.getInstance().registerSkillHandler(new Extractable());
		_log.config("Loaded " + SkillHandler.getInstance().size() + " SkillHandlers");
	}
	
	private static void loadUserHandlers()
	{
		UserCommandHandler.getInstance().registerUserCommandHandler(new ClanPenalty());
		UserCommandHandler.getInstance().registerUserCommandHandler(new ClanWarsList());
		UserCommandHandler.getInstance().registerUserCommandHandler(new DisMount());
		UserCommandHandler.getInstance().registerUserCommandHandler(new Escape());
		UserCommandHandler.getInstance().registerUserCommandHandler(new InstanceZone());
		UserCommandHandler.getInstance().registerUserCommandHandler(new Loc());
		UserCommandHandler.getInstance().registerUserCommandHandler(new Mount());
		UserCommandHandler.getInstance().registerUserCommandHandler(new PartyInfo());
		UserCommandHandler.getInstance().registerUserCommandHandler(new Time());
		UserCommandHandler.getInstance().registerUserCommandHandler(new OlympiadStat());
		UserCommandHandler.getInstance().registerUserCommandHandler(new ChannelLeave());
		UserCommandHandler.getInstance().registerUserCommandHandler(new ChannelDelete());
		UserCommandHandler.getInstance().registerUserCommandHandler(new ChannelListUpdate());
		_log.config("Loaded " + UserCommandHandler.getInstance().size() + " UserHandlers");
	}
	
	private static void loadVoicedHandlers()
	{
		VoicedCommandHandler.getInstance().registerVoicedCommandHandler(new AntiBot());
		VoicedCommandHandler.getInstance().registerVoicedCommandHandler(new Captcha());
		VoicedCommandHandler.getInstance().registerVoicedCommandHandler(new stats());
		if (Config.L2JMOD_ALLOW_WEDDING)
			VoicedCommandHandler.getInstance().registerVoicedCommandHandler(new Wedding());
		if (Config.BANKING_SYSTEM_ENABLED)
			VoicedCommandHandler.getInstance().registerVoicedCommandHandler(new Banking());
		_log.config("Loaded " + VoicedCommandHandler.getInstance().size() + " VoicedHandlers");
	}
	
	/**
	 * @param args
	 */
	public static void main(String[] args)
	{
		_log.config("Loading Handlers...");
		loadAdminHandlers();
		loadChatHandlers();
		loadItemHandlers();
		loadSkillHandlers();
		loadUserHandlers();
		loadVoicedHandlers();
		_log.config("Handlers Loaded...");
	}
}

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...