Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package quests.AntiBotPW;
- import java.awt.Color;
- import java.awt.Font;
- import java.awt.FontMetrics;
- import java.awt.Graphics2D;
- import java.awt.RenderingHints;
- import java.awt.geom.Rectangle2D.Float;
- import java.awt.image.BufferedImage;
- import java.awt.image.ColorModel;
- import java.io.File;
- import java.io.FileInputStream;
- import java.io.FileWriter;
- import java.io.IOException;
- import java.io.InputStream;
- import java.io.PrintStream;
- import java.nio.ByteBuffer;
- import java.nio.ByteOrder;
- import java.sql.PreparedStatement;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import java.util.HashMap;
- import java.util.Iterator;
- import java.util.Properties;
- import java.util.Random;
- import java.util.concurrent.ScheduledFuture;
- import java.util.logging.Logger;
- import javolution.util.FastList;
- import net.sf.l2j.Config;
- import net.sf.l2j.L2DatabaseFactory;
- import net.sf.l2j.gameserver.ThreadPoolManager;
- import net.sf.l2j.gameserver.model.L2Character;
- import net.sf.l2j.gameserver.model.L2Object;
- import net.sf.l2j.gameserver.model.L2Skill;
- import net.sf.l2j.gameserver.model.L2Skill.SkillType;
- import net.sf.l2j.gameserver.model.L2Summon;
- import net.sf.l2j.gameserver.model.actor.instance.L2GrandBossInstance;
- 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.quest.Quest;
- import net.sf.l2j.gameserver.network.SystemMessageId;
- import net.sf.l2j.gameserver.network.serverpackets.MagicSkillUser;
- import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
- import net.sf.l2j.gameserver.network.serverpackets.PledgeCrest;
- import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
- import net.sf.l2j.gameserver.util.Util;
- import net.sf.l2j.mysql.Close;
- import net.sf.l2j.mysql.Connect;
- import net.sf.l2j.util.Rnd;
- import scripts.commands.IVoicedCommandHandler;
- import scripts.commands.VoicedCommandHandler;
- import scripts.skills.ISkillHandler;
- import scripts.skills.SkillHandler;
- public class AntiBotPW
- extends Quest
- {
- public static boolean AntiBotPWCaptchaEnable;
- public static int AntiBotPWCaptchaMode;
- public static boolean AntiBotPWCaptchaEnableNpc;
- public static boolean AntiBotPWCaptchaEnableCmd;
- public static boolean AntiBotPWCaptchaEnableSkill;
- public static String MONSTERSs;
- public static FastList<Integer> MONSTERS = new FastList();
- public static int AntiBotPWTriggerChance;
- public static int AntiBotPWLVL;
- public static int CaptchaAntiBotPWKick;
- public static int[] CaptchaAntiBotPWLoc = { 82543, 149221, 62068 };
- public static int AntiBotPWReCheckInterval;
- public static int AntiBotPWReCheckEndingInterval;
- public static boolean AntiBotPWReCheckEndingGM;
- public static int CaptchaCountError;
- public static boolean AntiBotPWCaptchaNoble;
- public static boolean AntiBotPWCaptchaHero;
- public static boolean AntiBotPWCaptchaPremium;
- public static boolean AntiBotPWNewCore;
- public static int AntiBotPWCMDPlayerLVL;
- public static int AntiBotPWCMDTargetLVL;
- public static int AntiBotPWCMDSkill;
- public static boolean AntiBotPWLog;
- private static final Logger _log = Logger.getLogger(AntiBotPW.class.getName());
- private HashMap<L2PcInstance, BotResults> _players;
- private HashMap<L2PcInstance, String> _codes;
- private HashMap<L2PcInstance, Integer> _errors;
- private HashMap<L2PcInstance, Integer> _recheckending;
- protected HashMap<L2PcInstance, BotEye> _activeEyes;
- private static final String qn = "AntiBotPW";
- public AntiBotPW()
- {
- super(-1, "AntiBotPW", "custom");
- loadAntiBotPWCfg();
- if (AntiBotPWCaptchaEnable)
- {
- for (Iterator localIterator = MONSTERS.iterator(); localIterator.hasNext();)
- {
- int mobs = ((Integer)localIterator.next()).intValue();
- addKillId(mobs);
- }
- _log.info("-------------------------------------------");
- _log.info("########## AntiBot: PWsoft ##########");
- _log.info("########## Developer: ncs.SpawN ##########");
- _log.info("########## Share: gvb ICQ: 685308391 #####");
- _log.info("########## Site: L2CODE.RU #########");
- _log.info("-------------------------------------------");
- this._players = new HashMap();
- this._codes = new HashMap();
- this._errors = new HashMap();
- this._recheckending = new HashMap();
- this._activeEyes = new HashMap();
- new SecurityCode();
- new AntiBotPWSkillTP1();
- }
- }
- public static void loadAntiBotPWCfg()
- {
- try
- {
- Properties AntiBotPWSettings = new Properties();
- InputStream is = new FileInputStream(new File("./config/AntiBotPW.cfg"));
- AntiBotPWSettings.load(is);
- is.close();
- AntiBotPWCaptchaEnable = Boolean.valueOf(AntiBotPWSettings.getProperty("CaptchaEnable", "true")).booleanValue();
- AntiBotPWCaptchaMode = Integer.parseInt(AntiBotPWSettings.getProperty("CaptchaMode", "2"));
- AntiBotPWCaptchaEnableNpc = Boolean.valueOf(AntiBotPWSettings.getProperty("CaptchaEnableNpc", "true")).booleanValue();
- AntiBotPWCaptchaEnableCmd = Boolean.valueOf(AntiBotPWSettings.getProperty("CaptchaEnableCmd", "true")).booleanValue();
- AntiBotPWCaptchaEnableSkill = Boolean.valueOf(AntiBotPWSettings.getProperty("CaptchaEnableSkill", "true")).booleanValue();
- String[] propertySplit = AntiBotPWSettings.getProperty("Loc", "82543,149221,-3468").split(",");
- CaptchaAntiBotPWLoc[0] = Integer.parseInt(propertySplit[0]);
- CaptchaAntiBotPWLoc[1] = Integer.parseInt(propertySplit[1]);
- CaptchaAntiBotPWLoc[2] = Integer.parseInt(propertySplit[2]);
- MONSTERSs = AntiBotPWSettings.getProperty("MONSTERS", "2375,3500,3501,3502,4422,4423,4424,4425,6648,6649,6650,9882");
- MONSTERS = new FastList();
- for (String id : MONSTERSs.trim().split(",")) {
- MONSTERS.add(Integer.valueOf(Integer.parseInt(id.trim())));
- }
- AntiBotPWTriggerChance = Integer.parseInt(AntiBotPWSettings.getProperty("TriggerChance", "10"));
- AntiBotPWLVL = Integer.parseInt(AntiBotPWSettings.getProperty("LVL", "76"));
- CaptchaAntiBotPWKick = Integer.parseInt(AntiBotPWSettings.getProperty("Kick", "3"));
- AntiBotPWReCheckInterval = Integer.parseInt(AntiBotPWSettings.getProperty("ReCheckInterval", "300"));
- AntiBotPWReCheckEndingInterval = Integer.parseInt(AntiBotPWSettings.getProperty("ReCheckEndingInterval", "5"));
- AntiBotPWReCheckEndingGM = Boolean.valueOf(AntiBotPWSettings.getProperty("ReCheckEndingGM", "true")).booleanValue();
- CaptchaCountError = Integer.parseInt(AntiBotPWSettings.getProperty("CountError", "3"));
- AntiBotPWCaptchaNoble = Boolean.valueOf(AntiBotPWSettings.getProperty("CaptchaNoble", "true")).booleanValue();
- AntiBotPWCaptchaHero = Boolean.valueOf(AntiBotPWSettings.getProperty("CaptchaHero", "true")).booleanValue();
- AntiBotPWCaptchaPremium = Boolean.valueOf(AntiBotPWSettings.getProperty("CaptchaPremium ", "true")).booleanValue();
- AntiBotPWNewCore = Boolean.valueOf(AntiBotPWSettings.getProperty("NewCore", "true")).booleanValue();
- AntiBotPWCMDPlayerLVL = Integer.parseInt(AntiBotPWSettings.getProperty("CMDPlayerLVL", "76"));
- AntiBotPWCMDTargetLVL = Integer.parseInt(AntiBotPWSettings.getProperty("CMDTargetLVL", "76"));
- AntiBotPWCMDSkill = Integer.parseInt(AntiBotPWSettings.getProperty("CMDSkill", "7100"));
- AntiBotPWLog = Boolean.valueOf(AntiBotPWSettings.getProperty("Log", "true")).booleanValue();
- }
- catch (Exception e)
- {
- e.printStackTrace();
- throw new Error("Failed to Load ./config/AntiBotPW.cfg File.");
- }
- }
- public String onKill(L2NpcInstance npc, L2PcInstance player, boolean isPet)
- {
- L2Character character = player;
- L2Object target = character != null ? character.getTarget() : null;
- if ((character instanceof L2PcInstance)) {
- player = character.getPlayer();
- } else if ((character instanceof L2Summon)) {
- player = character.getPlayer();
- }
- if (player == null)
- {
- _log.info("AntiBotPW: #onKill for null.");
- return null;
- }
- if (((target instanceof L2RaidBossInstance)) || ((target instanceof L2GrandBossInstance))) {
- return null;
- }
- if (((target instanceof L2PcInstance)) || ((target instanceof L2Summon))) {
- return null;
- }
- if ((!AntiBotPWCaptchaEnableNpc) || (player.getLevel() < AntiBotPWLVL)) {
- return null;
- }
- if ((!AntiBotPWCaptchaPremium) && (player.isPremium())) {
- return null;
- }
- if ((!AntiBotPWCaptchaHero) && (player.isHero())) {
- return null;
- }
- if ((!AntiBotPWCaptchaNoble) && (player.isNoble())) {
- return null;
- }
- if ((Rnd.get(100) < AntiBotPWTriggerChance) && (!this._activeEyes.containsKey(player)))
- {
- int current_time = (int)(System.currentTimeMillis() / 1000L);
- int player_time = 0;
- if (this._recheckending.containsKey(player)) {
- player_time = ((Integer)this._recheckending.get(player)).intValue();
- }
- if (player_time > current_time)
- {
- int last_sec = ((Integer)this._recheckending.get(player)).intValue() - current_time;
- player.sendPacket(SystemMessage.id(SystemMessageId.GM_S1).addString("???? ???: ? ??????? " + last_sec + " ?????? ???????? ??? ??? ?????????."));
- return null;
- }
- player.broadcastPacket(new MagicSkillUser(player, player, 1427, 1, 10, 0));
- int counterrors = CaptchaCountError;
- this._errors.put(player, Integer.valueOf(counterrors));
- timer(player);
- triggerCaptcha(player, true);
- }
- return null;
- }
- private void writeLog(L2PcInstance activeChar)
- {
- String name = activeChar.getName();
- String ip = activeChar.getIP();
- String account = activeChar.getAccountName();
- new File("log/AntiBotPW").mkdirs();
- try
- {
- File file = new File("log/AntiBotPW/AntiBotPW.txt");
- FileWriter save = new FileWriter(file, true);
- String out = "Player: " + name + " Account: " + account + " IP: " + ip + " Not check the captcha!\n";
- save.write(out);
- save.flush();
- save.close();
- save = null;
- file = null;
- }
- catch (IOException e)
- {
- _log.warning("AntiBotPW: Error create log ./log/AntiBotPW/AntiBotPW.txt");
- e.printStackTrace();
- }
- }
- private void triggerCaptcha(L2PcInstance player, boolean setEffect)
- {
- int id = 0;
- if (AntiBotPWCaptchaMode == 1)
- {
- id = (int)(Math.random() * 1000.0D + 1.0D);
- if (id < 10) {
- id += 10;
- }
- }
- else
- {
- Random rndoms = new Random();
- id = rndoms.nextInt(12);
- }
- String code = String.valueOf(id);
- this._codes.put(player, code);
- id = (int)(Math.random() * 100000.0D + 1.0D);
- if (id < 1000) {
- id += 1000;
- }
- sendImage(player, id, generateImage(code));
- NpcHtmlMessage htmll = NpcHtmlMessage.id(0);
- int seconds = AntiBotPWReCheckInterval;
- String html;
- String html;
- if (AntiBotPWCaptchaMode == 1) {
- html = "<html><title>???? ???</title><body><center><br><img src=\"Crest.crest_" + Config.SERVER_ID + "_" + id + "\" width=128 height=64><br><edit width=100 var=\"code\"><br><button action=\"bypass -h " + CheckCore() + "ag_code $code\" value=\"??????????\" width=75 height=21 back=\"L2UI_ch3.Btn1_normalOn\" fore=\"L2UI_ch3.Btn1_normal\"><br><br>???? ?? ???????? ??? ????, ??????????? ???????<br1> <font color=\"EEEEEE\">.code</font><br1>? ??? ???? <font color=\"EEEEEE\">" + seconds + " ??????</font> ???? ?????? ????????? ?????!<br><a action=\"bypass -h " + CheckCore() + "ag_refresh\"><font color=\"EEEEEE\">???????? ?????</font></a></center></body></html>";
- } else {
- html = "<html><title>???? ???</title><body><center><br><img src=\"Crest.crest_" + Config.SERVER_ID + "_" + id + "\" width=128 height=64><br><table border=\"0\" width=\"290\" cellpadding=\"3\" cellspacing=\"0\"><tr><td align=\"center\" width=\"75\"><a action=\"bypass -h " + CheckCore() + "ag_code 0\"><font color=\"3030DD\">???????</font></a></td><td align=\"center\" width=\"75\"><a action=\"bypass -h " + CheckCore() + "ag_code 1\"><font color=\"00DD00\">???????</font></a></td><td align=\"center\" width=\"75\"><a action=\"bypass -h " + CheckCore() + "ag_code 2\"><font color=\"DD0000\">???????</font></a></td><td align=\"center\" width=\"75\"><a action=\"bypass -h " + CheckCore() + "ag_code 3\"><font color=\"DDDD00\">???????</font></a></td></tr><tr><td align=\"center\" width=\"75\"><a action=\"bypass -h " + CheckCore() + "ag_code 4\"><font color=\"3030DD\">????</font></a></td><td align=\"center\" width=\"75\"><a action=\"bypass -h " + CheckCore() + "ag_code 5\"><font color=\"00DD00\">????</font></a></td><td align=\"center\" width=\"75\"><a action=\"bypass -h " + CheckCore() + "ag_code 6\"><font color=\"DD0000\">????</font></a></td><td align=\"center\" width=\"75\"><a action=\"bypass -h " + CheckCore() + "ag_code 7\"><font color=\"DDDD00\">????</font></a></td></tr><tr><td align=\"center\" width=\"75\"><a action=\"bypass -h " + CheckCore() + "ag_code 8\"><font color=\"3030DD\">???????????</font></a></td><td align=\"center\" width=\"75\"><a action=\"bypass -h " + CheckCore() + "ag_code 9\"><font color=\"00DD00\">???????????</font></a></td><td align=\"center\" width=\"75\"><a action=\"bypass -h " + CheckCore() + "ag_code 10\"><font color=\"DD0000\">???????????</font></a></td><td align=\"center\" width=\"75\"><a action=\"bypass -h " + CheckCore() + "ag_code 11\"><font color=\"DDDD00\">???????????</font></a></td></tr></table><br><br>???? ?? ???????? ??? ????, ??????????? ???????<br1> <font color=\"EEEEEE\">.code</font><br1>? ??? ???? <font color=\"EEEEEE\">" + seconds + " ??????</font> ???? ?????? ????????? ?????!<br><a action=\"bypass -h " + CheckCore() + "ag_refresh\"><font color=\"EEEEEE\">???????? ?????</font></a></center></body></html>";
- }
- htmll.setHtml(html);
- player.sendPacket(htmll);
- if (setEffect)
- {
- player.sendPacket(SystemMessage.id(SystemMessageId.GM_S1).addString("???? ???: .code"));
- player.startAbnormalEffect(524288);
- player.startAbnormalEffect(1024);
- player.setIsParalyzed(true);
- player.setIsInvul(true);
- this._activeEyes.put(player, new BotEye(player, seconds));
- }
- }
- public static AntiBotPW getInstance()
- {
- return SingletonHolder._instance;
- }
- public String CheckCore()
- {
- String result = "";
- if (AntiBotPWNewCore) {
- result = "vch_";
- }
- return result;
- }
- public void validate(L2PcInstance player, String code)
- {
- code = code.trim();
- if ((code == null) || (code.equalsIgnoreCase("ag_refresh")))
- {
- triggerCaptcha(player, false);
- return;
- }
- String valid = (String)this._codes.get(player);
- if ((valid != null) && (valid.equalsIgnoreCase(code)))
- {
- player.sendPacket(SystemMessage.id(SystemMessageId.GM_S1).addString("???? ???: ???????????! ?? ?????? ???????????."));
- player.stopAbnormalEffect(524288);
- player.stopAbnormalEffect(1024);
- player.setIsParalyzed(false);
- player.setIsInvul(false);
- timer(player);
- player.setCurrentHp(player.getMaxHp());
- if (this._activeEyes.containsKey(player)) {
- ((BotEye)this._activeEyes.remove(player)).cancel();
- }
- }
- else
- {
- int validerrors = ((Integer)this._errors.get(player)).intValue();
- if (validerrors >= 1)
- {
- validerrors--;
- this._errors.put(player, Integer.valueOf(validerrors));
- player.sendPacket(SystemMessage.id(SystemMessageId.GM_S1).addString("???? ???: ???????????! ???????? (" + validerrors + ") ???????. ?????????? ??? ???."));
- triggerCaptcha(player, false);
- }
- else if (CaptchaAntiBotPWKick == 1)
- {
- Util.handleIllegalPlayerAction(player, "Player " + player.getName() + " did not enter the AntiBotPW captcha intime.", 2);
- if (AntiBotPWLog) {
- writeLog(player);
- }
- }
- else
- {
- player.sendPacket(SystemMessage.id(SystemMessageId.GM_S1).addString("???? ???: ???????????! ?? ?????? ???????????."));
- player.stopAbnormalEffect(524288);
- player.stopAbnormalEffect(1024);
- player.setIsParalyzed(false);
- player.setIsInvul(false);
- timer(player);
- player.setCurrentHp(player.getMaxHp());
- if (this._activeEyes.containsKey(player)) {
- ((BotEye)this._activeEyes.remove(player)).cancel();
- }
- if (CaptchaAntiBotPWKick == 2) {
- player.teleToClosestTown();
- } else {
- player.teleToLocation(CaptchaAntiBotPWLoc[0], CaptchaAntiBotPWLoc[1], CaptchaAntiBotPWLoc[2]);
- }
- if (AntiBotPWLog) {
- writeLog(player);
- }
- }
- }
- }
- private void teleportOfflinePlayer(String name, int xxx, int yyy, int zzz)
- {
- Connect con = null;
- PreparedStatement st = null;
- ResultSet rs = null;
- try
- {
- con = L2DatabaseFactory.get();
- con.setTransactionIsolation(1);
- settp(con, name, xxx, yyy, zzz);
- }
- catch (SQLException e)
- {
- System.out.println("[ERROR] AntiBotPW 1, settp() error: " + e);
- }
- finally
- {
- Close.CSR(con, st, rs);
- }
- }
- private void settp(Connect con, String name, int xxx, int yyy, int zzz)
- {
- PreparedStatement st = null;
- ResultSet rs = null;
- try
- {
- st = con.prepareStatement("UPDATE characters SET x=?, y=?, z=? WHERE char_name=?");
- st.setInt(1, xxx);
- st.setInt(2, yyy);
- st.setInt(3, zzz);
- st.setString(4, name);
- st.execute();
- }
- catch (SQLException e)
- {
- System.out.println("[ERROR] AntiBotPW 2, settp() error: " + e);
- }
- finally
- {
- Close.SR(st, rs);
- }
- }
- private boolean checkmob(int int_mobs)
- {
- boolean result = false;
- for (Iterator localIterator = MONSTERS.iterator(); localIterator.hasNext();)
- {
- int mobs = ((Integer)localIterator.next()).intValue();
- if (mobs == int_mobs) {
- result = true;
- }
- }
- return result;
- }
- private void timer(L2PcInstance player)
- {
- if (this._recheckending.containsKey(player)) {
- this._recheckending.remove(player);
- }
- int current_time = (int)(System.currentTimeMillis() / 1000L);
- int last_time = current_time + AntiBotPWReCheckEndingInterval;
- this._recheckending.put(player, Integer.valueOf(last_time));
- }
- public static ByteBuffer convertToDDS(BufferedImage bufferedimage)
- {
- if (bufferedimage == null) {
- return null;
- }
- if (bufferedimage.getColorModel().hasAlpha()) {
- return convertToDxt3(bufferedimage);
- }
- return convertToDxt1NoTransparency(bufferedimage);
- }
- public static ByteBuffer convertToDxt1NoTransparency(BufferedImage bufferedimage)
- {
- if (bufferedimage == null) {
- return null;
- }
- int[] ai = new int[16];
- int i = 128 + bufferedimage.getWidth() * bufferedimage.getHeight() / 2;
- ByteBuffer bytebuffer = ByteBuffer.allocate(i);
- bytebuffer.order(ByteOrder.LITTLE_ENDIAN);
- buildHeaderDxt1(bytebuffer, bufferedimage.getWidth(), bufferedimage.getHeight());
- int j = bufferedimage.getWidth() / 4;
- int k = bufferedimage.getHeight() / 4;
- for (int l = 0; l < k; l++) {
- for (int i2 = 0; i2 < j; i2++)
- {
- BufferedImage bufferedimage2 = bufferedimage.getSubimage(i2 * 4, l * 4, 4, 4);
- bufferedimage2.getRGB(0, 0, 4, 4, ai, 0, 4);
- Color[] acolor = getColors888(ai);
- for (int j2 = 0; j2 < ai.length; j2++)
- {
- ai[j2] = getPixel565(acolor[j2]);
- acolor[j2] = getColor565(ai[j2]);
- }
- int[] ai2 = determineExtremeColors(acolor);
- if (ai[ai2[0]] < ai[ai2[1]])
- {
- int k2 = ai2[0];
- ai2[0] = ai2[1];
- ai2[1] = k2;
- }
- bytebuffer.putShort((short)ai[ai2[0]]);
- bytebuffer.putShort((short)ai[ai2[1]]);
- long l2 = computeBitMask(acolor, ai2);
- bytebuffer.putInt((int)l2);
- }
- }
- return bytebuffer;
- }
- public static ByteBuffer convertToDxt3(BufferedImage bufferedimage)
- {
- if (bufferedimage == null) {
- return null;
- }
- if (!bufferedimage.getColorModel().hasAlpha()) {
- return convertToDxt1NoTransparency(bufferedimage);
- }
- int[] ai = new int[16];
- int i = 128 + bufferedimage.getWidth() * bufferedimage.getHeight();
- ByteBuffer bytebuffer = ByteBuffer.allocate(i);
- bytebuffer.order(ByteOrder.LITTLE_ENDIAN);
- buildHeaderDxt3(bytebuffer, bufferedimage.getWidth(), bufferedimage.getHeight());
- int j = bufferedimage.getWidth() / 4;
- int k = bufferedimage.getHeight() / 4;
- for (int l = 0; l < k; l++) {
- for (int i2 = 0; i2 < j; i2++)
- {
- BufferedImage bufferedimage2 = bufferedimage.getSubimage(i2 * 4, l * 4, 4, 4);
- bufferedimage2.getRGB(0, 0, 4, 4, ai, 0, 4);
- Color[] acolor = getColors888(ai);
- for (int j2 = 0; j2 < ai.length; j2 += 2) {
- bytebuffer.put((byte)(ai[j2] >>> 28 | ai[(j2 + 1)] >>> 24));
- }
- for (int k2 = 0; k2 < ai.length; k2++)
- {
- ai[k2] = getPixel565(acolor[k2]);
- acolor[k2] = getColor565(ai[k2]);
- }
- int[] ai2 = determineExtremeColors(acolor);
- if (ai[ai2[0]] < ai[ai2[1]])
- {
- int l2 = ai2[0];
- ai2[0] = ai2[1];
- ai2[1] = l2;
- }
- bytebuffer.putShort((short)ai[ai2[0]]);
- bytebuffer.putShort((short)ai[ai2[1]]);
- long l3 = computeBitMask(acolor, ai2);
- bytebuffer.putInt((int)l3);
- }
- }
- return bytebuffer;
- }
- protected static void buildHeaderDxt1(ByteBuffer bytebuffer, int i, int j)
- {
- bytebuffer.rewind();
- bytebuffer.put((byte)68);
- bytebuffer.put((byte)68);
- bytebuffer.put((byte)83);
- bytebuffer.put((byte)32);
- bytebuffer.putInt(124);
- int k = 659463;
- bytebuffer.putInt(659463);
- bytebuffer.putInt(j);
- bytebuffer.putInt(i);
- bytebuffer.putInt(i * j / 2);
- bytebuffer.putInt(0);
- bytebuffer.putInt(0);
- bytebuffer.position(bytebuffer.position() + 44);
- bytebuffer.putInt(32);
- bytebuffer.putInt(4);
- bytebuffer.put((byte)68);
- bytebuffer.put((byte)88);
- bytebuffer.put((byte)84);
- bytebuffer.put((byte)49);
- bytebuffer.putInt(0);
- bytebuffer.putInt(0);
- bytebuffer.putInt(0);
- bytebuffer.putInt(0);
- bytebuffer.putInt(0);
- bytebuffer.putInt(4096);
- bytebuffer.putInt(0);
- bytebuffer.position(bytebuffer.position() + 12);
- }
- protected static void buildHeaderDxt3(ByteBuffer bytebuffer, int i, int j)
- {
- bytebuffer.rewind();
- bytebuffer.put((byte)68);
- bytebuffer.put((byte)68);
- bytebuffer.put((byte)83);
- bytebuffer.put((byte)32);
- bytebuffer.putInt(124);
- int k = 659463;
- bytebuffer.putInt(659463);
- bytebuffer.putInt(j);
- bytebuffer.putInt(i);
- bytebuffer.putInt(i * j);
- bytebuffer.putInt(0);
- bytebuffer.putInt(0);
- bytebuffer.position(bytebuffer.position() + 44);
- bytebuffer.putInt(32);
- bytebuffer.putInt(4);
- bytebuffer.put((byte)68);
- bytebuffer.put((byte)88);
- bytebuffer.put((byte)84);
- bytebuffer.put((byte)51);
- bytebuffer.putInt(0);
- bytebuffer.putInt(0);
- bytebuffer.putInt(0);
- bytebuffer.putInt(0);
- bytebuffer.putInt(0);
- bytebuffer.putInt(4096);
- bytebuffer.putInt(0);
- bytebuffer.position(bytebuffer.position() + 12);
- }
- protected static int[] determineExtremeColors(Color[] acolor)
- {
- int i = Integer.MIN_VALUE;
- int[] ai = new int[2];
- for (int j = 0; j < acolor.length - 1; j++) {
- for (int k = j + 1; k < acolor.length; k++)
- {
- int l = distance(acolor[j], acolor[k]);
- if (l > i)
- {
- i = l;
- ai[0] = j;
- ai[1] = k;
- }
- }
- }
- return ai;
- }
- protected static long computeBitMask(Color[] acolor, int[] ai)
- {
- Color[] acolor2 = { null, null, new Color(), new Color() };
- acolor2[0] = acolor[ai[0]];
- acolor2[1] = acolor[ai[1]];
- if (acolor2[0].equals(acolor2[1])) {
- return 0L;
- }
- acolor2[2].r = ((2 * acolor2[0].r + acolor2[1].r + 1) / 3);
- acolor2[2].g = ((2 * acolor2[0].g + acolor2[1].g + 1) / 3);
- acolor2[2].b = ((2 * acolor2[0].b + acolor2[1].b + 1) / 3);
- acolor2[3].r = ((acolor2[0].r + 2 * acolor2[1].r + 1) / 3);
- acolor2[3].g = ((acolor2[0].g + 2 * acolor2[1].g + 1) / 3);
- acolor2[3].b = ((acolor2[0].b + 2 * acolor2[1].b + 1) / 3);
- long l = 0L;
- for (int i = 0; i < acolor.length; i++)
- {
- int j = Integer.MAX_VALUE;
- int k = 0;
- for (int i2 = 0; i2 < acolor2.length; i2++)
- {
- int j2 = distance(acolor[i], acolor2[i2]);
- if (j2 < j)
- {
- j = j2;
- k = i2;
- }
- }
- l |= k << i * 2;
- }
- return l;
- }
- protected static int getPixel565(Color color)
- {
- int i = color.r >> 3;
- int j = color.g >> 2;
- int k = color.b >> 3;
- return i << 11 | j << 5 | k;
- }
- protected static Color getColor565(int i)
- {
- Color color = new Color();
- color.r = ((int)(i & 0xF800) >> 11);
- color.g = ((int)(i & 0x7E0) >> 5);
- color.b = ((int)(i & 0x1F));
- return color;
- }
- protected static Color[] getColors888(int[] ai)
- {
- Color[] acolor = new Color[ai.length];
- for (int i = 0; i < ai.length; i++)
- {
- acolor[i] = new Color();
- acolor[i].r = ((int)(ai[i] & 0xFF0000) >> 16);
- acolor[i].g = ((int)(ai[i] & 0xFF00) >> 8);
- acolor[i].b = ((int)(ai[i] & 0xFF));
- }
- return acolor;
- }
- protected static int distance(Color color, Color color1)
- {
- return (color1.r - color.r) * (color1.r - color.r) + (color1.g - color.g) * (color1.g - color.g) + (color1.b - color.b) * (color1.b - color.b);
- }
- public static BufferedImage scaleImage(BufferedImage img, int width, int height, Color background)
- {
- int imgWidth = img.getWidth();
- int imgHeight = img.getHeight();
- if (imgWidth * height < imgHeight * width) {
- width = imgWidth * height / imgHeight;
- } else {
- height = imgHeight * width / imgWidth;
- }
- BufferedImage newImage = new BufferedImage(width, height, 1);
- Graphics2D g = newImage.createGraphics();
- try
- {
- g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
- g.setBackground(background);
- g.clearRect(0, 0, width, height);
- g.drawImage(img, 0, 0, width, height, null);
- }
- finally
- {
- g.dispose();
- }
- return newImage;
- }
- public static BufferedImage generateImage(String text)
- {
- BufferedImage img = new BufferedImage(128, 64, 1);
- Color bgColor = new Color(100, 100, 100);
- Color textColor = new Color(160, 160, 160);
- Color noiseColor = new Color(130, 130, 130);
- Random rnd = new Random();
- if (AntiBotPWCaptchaMode == 1) {
- switch (rnd.nextInt(10))
- {
- case 0:
- case 1:
- bgColor = new Color(0, 100, 0);
- textColor = new Color(0, 150, 0);
- noiseColor = new Color(0, 125, 0);
- break;
- case 2:
- case 3:
- bgColor = new Color(0, 0, 100);
- textColor = new Color(0, 0, 170);
- noiseColor = new Color(0, 0, 125);
- break;
- case 4:
- case 5:
- bgColor = new Color(100, 0, 100);
- textColor = new Color(150, 0, 150);
- noiseColor = new Color(125, 0, 125);
- }
- } else {
- bgColor = new Color(0, 0, 0);
- }
- Graphics2D backColor = img.createGraphics();
- backColor.setPaint(bgColor);
- backColor.fillRect(0, 0, img.getWidth(), img.getHeight());
- backColor.dispose();
- if (AntiBotPWCaptchaMode == 1)
- {
- for (int i = 0; i < 20; i++)
- {
- Graphics2D g = img.createGraphics();
- g.setColor(noiseColor);
- int radius = rnd.nextInt(10) + 4;
- int x = rnd.nextInt(128) + 1;
- int y = rnd.nextInt(64) + 1;
- g.fillOval(x, y, radius, radius);
- }
- }
- else
- {
- Graphics2D g2 = img.createGraphics();
- g2.setColor(new Color(0, 100, 0));
- int sw = Integer.parseInt(text);
- switch (sw)
- {
- case 0:
- textColor = new Color(0, 0, 170);
- g2.setColor(textColor);
- g2.fill(new Rectangle2D.Float(42.0F, 10.0F, 45.0F, 45.0F));
- break;
- case 1:
- textColor = new Color(0, 150, 0);
- g2.setColor(textColor);
- g2.fill(new Rectangle2D.Float(42.0F, 10.0F, 45.0F, 45.0F));
- break;
- case 2:
- textColor = new Color(170, 0, 0);
- g2.setColor(textColor);
- g2.fill(new Rectangle2D.Float(42.0F, 10.0F, 45.0F, 45.0F));
- break;
- case 3:
- textColor = new Color(170, 170, 0);
- g2.setColor(textColor);
- g2.fill(new Rectangle2D.Float(42.0F, 10.0F, 45.0F, 45.0F));
- break;
- case 4:
- textColor = new Color(0, 0, 170);
- g2.setColor(textColor);
- g2.fillOval(42, 10, 45, 45);
- break;
- case 5:
- textColor = new Color(0, 150, 0);
- g2.setColor(textColor);
- g2.fillOval(42, 10, 45, 45);
- break;
- case 6:
- textColor = new Color(170, 0, 0);
- g2.setColor(textColor);
- g2.fillOval(42, 10, 45, 45);
- break;
- case 7:
- textColor = new Color(170, 170, 0);
- g2.setColor(textColor);
- g2.fillOval(42, 10, 45, 45);
- break;
- case 8:
- textColor = new Color(0, 0, 170);
- g2.setColor(textColor);
- g2.fillPolygon(new int[] { 42, 67, 90 }, new int[] { 50, 10, 50 }, 3);
- break;
- case 9:
- textColor = new Color(0, 150, 0);
- g2.setColor(textColor);
- g2.fillPolygon(new int[] { 42, 67, 90 }, new int[] { 50, 10, 50 }, 3);
- break;
- case 10:
- textColor = new Color(170, 0, 0);
- g2.setColor(textColor);
- g2.fillPolygon(new int[] { 42, 67, 90 }, new int[] { 50, 10, 50 }, 3);
- break;
- case 11:
- textColor = new Color(170, 170, 0);
- g2.setColor(textColor);
- g2.fillPolygon(new int[] { 42, 67, 90 }, new int[] { 50, 10, 50 }, 3);
- }
- }
- Graphics2D g2d = img.createGraphics();
- g2d.drawImage(img, 0, 0, null);
- g2d.setPaint(textColor);
- int fontSize = 0;
- if (AntiBotPWCaptchaMode == 1) {
- fontSize = rnd.nextInt(10) + 35;
- } else {
- fontSize = 36;
- }
- g2d.setFont(new Font("Serif", 1, fontSize));
- FontMetrics fm = g2d.getFontMetrics();
- int y2;
- if (AntiBotPWCaptchaMode == 1)
- {
- int x2 = img.getWidth() - fm.stringWidth(text) - rnd.nextInt(100 - fontSize);
- if (fontSize < 35) {
- fontSize = 35;
- }
- int y2 = fm.getHeight() - fontSize / 8;
- g2d.drawString(text, x2, y2);
- }
- else
- {
- int x2 = img.getWidth() - fm.stringWidth(text) - (70 - fontSize);
- y2 = fm.getHeight() - fontSize / 8;
- }
- g2d.dispose();
- return img;
- }
- public static void sendImage(L2PcInstance player, int id, BufferedImage image)
- {
- try
- {
- PledgeCrest packet = new PledgeCrest(id, convertToDDS(image).array());
- player.sendPacket(packet);
- }
- catch (Exception localException) {}
- }
- public static void main(String[] args)
- {
- new AntiBotPW();
- }
- private static class SingletonHolder
- {
- protected static final AntiBotPW _instance = new AntiBotPW();
- }
- public class AntiBotPWSkillTP1
- implements ISkillHandler
- {
- private final L2Skill.SkillType[] SKILL_IDS;
- public AntiBotPWSkillTP1()
- {
- this.SKILL_IDS = new L2Skill.SkillType[] { L2Skill.SkillType.NOTDONE };
- SkillHandler.getInstance().registerSkillHandler(this);
- }
- public void useSkill(L2Character activeChar, L2Skill skill, FastList<L2Object> targets)
- {
- L2PcInstance player = null;
- L2PcInstance target = null;
- L2Character Character_target = null;
- if (activeChar.isPlayer()) {
- player = (L2PcInstance)activeChar;
- }
- L2Object targetz = player != null ? player.getTarget() : null;
- int leveltarget = 0;
- if ((targetz instanceof L2PcInstance))
- {
- Character_target = (L2Character)targetz;
- target = (L2PcInstance)Character_target;
- leveltarget = target.getLevel();
- }
- if (player != null)
- {
- int levelchar = player.getLevel();
- if (!AntiBotPW.AntiBotPWCaptchaEnableSkill)
- {
- if (skill.getId() == AntiBotPW.AntiBotPWCMDSkill) {
- player.sendPacket(SystemMessage.id(SystemMessageId.GM_S1).addString("??????? ??????? ???????? ????? ????? ????????? ??????????????!"));
- }
- }
- else if (levelchar < AntiBotPW.AntiBotPWCMDPlayerLVL)
- {
- if (skill.getId() == AntiBotPW.AntiBotPWCMDSkill) {
- player.sendPacket(SystemMessage.id(SystemMessageId.GM_S1).addString("?? ?? ?????? ???????????? ??????? ???????? ???? ?? ?????????? " + AntiBotPW.AntiBotPWCMDPlayerLVL + " ??????"));
- }
- }
- else if (target == null)
- {
- if (skill.getId() == AntiBotPW.AntiBotPWCMDSkill) {
- player.sendPacket(SystemMessage.id(SystemMessageId.GM_S1).addString("?? ?? ?????? ???????????? ??????? ???????? ???? ? ??? ???????????? ??????"));
- }
- }
- else if (leveltarget < AntiBotPW.AntiBotPWCMDTargetLVL)
- {
- if (skill.getId() == AntiBotPW.AntiBotPWCMDSkill) {
- player.sendPacket(SystemMessage.id(SystemMessageId.GM_S1).addString("?? ?? ?????? ???????????? ??????? ???????? ?? " + target.getName() + " ???? ?? ?? ????????? " + AntiBotPW.AntiBotPWCMDTargetLVL + " ??????"));
- }
- }
- else if (skill.getId() == AntiBotPW.AntiBotPWCMDSkill)
- {
- if ((!AntiBotPW.AntiBotPWReCheckEndingGM) || (!player.isGM()))
- {
- if ((!AntiBotPW.AntiBotPWCaptchaPremium) && (target.isPremium()))
- {
- player.sendPacket(SystemMessage.id(SystemMessageId.GM_S1).addString("?????? ??????? ???????? ? " + target.getName() + " ????????!"));
- return;
- }
- if ((!AntiBotPW.AntiBotPWCaptchaHero) && (target.isHero()))
- {
- player.sendPacket(SystemMessage.id(SystemMessageId.GM_S1).addString("?????? ??????? ???????? ? " + target.getName() + " ????????!"));
- return;
- }
- if ((!AntiBotPW.AntiBotPWCaptchaNoble) && (target.isNoble()))
- {
- player.sendPacket(SystemMessage.id(SystemMessageId.GM_S1).addString("?????? ??????? ???????? ? " + target.getName() + " ????????!"));
- return;
- }
- L2Object targetx = target != null ? target.getTarget() : null;
- int int_targetx = 0;
- if ((targetx instanceof L2NpcInstance))
- {
- L2NpcInstance npc_targetx = (L2NpcInstance)targetx;
- int_targetx = npc_targetx.getNpcId();
- }
- if (!AntiBotPW.this.checkmob(int_targetx))
- {
- player.sendPacket(SystemMessage.id(SystemMessageId.GM_S1).addString("?????????! ? ?????? " + target.getName() + " ?????? ???? ? ??????? ?????? ?? ???????? ???????????????? ????????! ?????????? ??? ???..."));
- return;
- }
- int current_time = (int)(System.currentTimeMillis() / 1000L);
- int player_time = 0;
- if (AntiBotPW.this._recheckending.containsKey(target)) {
- player_time = ((Integer)AntiBotPW.this._recheckending.get(target)).intValue();
- }
- if (player_time > current_time)
- {
- int last_sec = ((Integer)AntiBotPW.this._recheckending.get(target)).intValue() - current_time;
- player.sendPacket(SystemMessage.id(SystemMessageId.GM_S1).addString("??????? ???????? ? " + target.getName() + " ??? ????????!"));
- target.sendPacket(SystemMessage.id(SystemMessageId.GM_S1).addString("???? ???: ? ??????? " + last_sec + " ?????? ???????? ??? ??? ?????????."));
- return;
- }
- }
- if (!AntiBotPW.this._activeEyes.containsKey(target))
- {
- player.sendPacket(SystemMessage.id(SystemMessageId.GM_S1).addString("?????? ??????? ???????? ? " + target.getName() + "!"));
- if ((!AntiBotPW.AntiBotPWReCheckEndingGM) || (!player.isGM())) {
- target.sendPacket(SystemMessage.id(SystemMessageId.GM_S1).addString("????? " + player.getName() + " ???????? ? ??? ??????? ????????!"));
- } else {
- target.sendPacket(SystemMessage.id(SystemMessageId.GM_S1).addString("??? ????????? ??????? ????????!"));
- }
- target.broadcastPacket(new MagicSkillUser(target, target, 1427, 1, 10, 0));
- player.broadcastPacket(new MagicSkillUser(player, player, 1427, 1, 10, 0));
- int counterrors = AntiBotPW.CaptchaCountError;
- AntiBotPW.this._errors.put(target, Integer.valueOf(counterrors));
- AntiBotPW.this.triggerCaptcha(target, true);
- }
- else
- {
- player.sendPacket(SystemMessage.id(SystemMessageId.GM_S1).addString("??????? ???????? ? " + target.getName() + " ??? ????????!"));
- }
- }
- }
- }
- public L2Skill.SkillType[] getSkillIds()
- {
- return this.SKILL_IDS;
- }
- }
- public static final class BotResults
- {
- public final int _success;
- public final int _fails;
- public BotResults(int success, int fails)
- {
- this._success = success;
- this._fails = fails;
- }
- }
- public void useVoicedCommand2(String command, L2PcInstance player, String target)
- {
- if ((command.startsWith("ag_code")) && (this._activeEyes.containsKey(player)))
- {
- String flag = command.substring(7).trim();
- validate(player, flag);
- }
- if ((command.equalsIgnoreCase("ag_refresh")) && (this._activeEyes.containsKey(player))) {
- validate(player, command);
- }
- }
- public class SecurityCode
- implements IVoicedCommandHandler
- {
- private final String[] VOICED_COMMANDS;
- public SecurityCode()
- {
- this.VOICED_COMMANDS = new String[] { "code", "check" };
- VoicedCommandHandler.getInstance().registerVoicedCommandHandler(this);
- }
- public boolean useVoicedCommand(String command, L2PcInstance player, String target)
- {
- if ((command.equalsIgnoreCase("code")) && (AntiBotPW.this._activeEyes.containsKey(player))) {
- AntiBotPW.this.validate(player, "ag_refresh");
- }
- if (command.equalsIgnoreCase("check"))
- {
- L2PcInstance target_cp = null;
- L2Character Character_target = null;
- L2Object targetz = player != null ? player.getTarget() : null;
- int leveltarget = 0;
- if ((targetz instanceof L2PcInstance))
- {
- Character_target = (L2Character)targetz;
- target_cp = (L2PcInstance)Character_target;
- leveltarget = target_cp.getLevel();
- }
- if (player != null)
- {
- int levelchar = player.getLevel();
- if (!AntiBotPW.AntiBotPWCaptchaEnableCmd)
- {
- player.sendPacket(SystemMessage.id(SystemMessageId.GM_S1).addString("??????? ??????? ???????? ????? .check ????????? ??????????????!"));
- }
- else if (levelchar < AntiBotPW.AntiBotPWCMDPlayerLVL)
- {
- player.sendPacket(SystemMessage.id(SystemMessageId.GM_S1).addString("?? ?? ?????? ???????????? ??????? ???????? ???? ?? ?????????? " + AntiBotPW.AntiBotPWCMDPlayerLVL + " ??????"));
- }
- else if (target_cp == null)
- {
- player.sendPacket(SystemMessage.id(SystemMessageId.GM_S1).addString("?? ?? ?????? ???????????? ??????? ???????? ???? ? ??? ???????????? ??????"));
- }
- else if (leveltarget < AntiBotPW.AntiBotPWCMDTargetLVL)
- {
- player.sendPacket(SystemMessage.id(SystemMessageId.GM_S1).addString("?? ?? ?????? ???????????? ??????? ???????? ?? " + target_cp.getName() + " ???? ?? ?? ????????? " + AntiBotPW.AntiBotPWCMDTargetLVL + " ??????"));
- }
- else
- {
- if ((!AntiBotPW.AntiBotPWReCheckEndingGM) || (!player.isGM()))
- {
- if ((!AntiBotPW.AntiBotPWCaptchaPremium) && (target_cp.isPremium()))
- {
- player.sendPacket(SystemMessage.id(SystemMessageId.GM_S1).addString("?????? ??????? ???????? ? " + target_cp.getName() + " ????????!"));
- return true;
- }
- if ((!AntiBotPW.AntiBotPWCaptchaHero) && (target_cp.isHero()))
- {
- player.sendPacket(SystemMessage.id(SystemMessageId.GM_S1).addString("?????? ??????? ???????? ? " + target_cp.getName() + " ????????!"));
- return true;
- }
- if ((!AntiBotPW.AntiBotPWCaptchaNoble) && (target_cp.isNoble()))
- {
- player.sendPacket(SystemMessage.id(SystemMessageId.GM_S1).addString("?????? ??????? ???????? ? " + target_cp.getName() + " ????????!"));
- return true;
- }
- L2Object targetx = target_cp != null ? target_cp.getTarget() : null;
- int int_targetx = 0;
- if ((targetx instanceof L2NpcInstance))
- {
- L2NpcInstance npc_targetx = (L2NpcInstance)targetx;
- int_targetx = npc_targetx.getNpcId();
- }
- if (!AntiBotPW.this.checkmob(int_targetx))
- {
- player.sendPacket(SystemMessage.id(SystemMessageId.GM_S1).addString("?????????! ? ?????? " + target_cp.getName() + " ?????? ???? ? ??????? ?????? ?? ???????? ???????????????? ????????! ?????????? ??? ???..."));
- return true;
- }
- int current_time = (int)(System.currentTimeMillis() / 1000L);
- int player_time = 0;
- if (AntiBotPW.this._recheckending.containsKey(target_cp)) {
- player_time = ((Integer)AntiBotPW.this._recheckending.get(target_cp)).intValue();
- }
- if (player_time > current_time)
- {
- int last_sec = ((Integer)AntiBotPW.this._recheckending.get(target_cp)).intValue() - current_time;
- player.sendPacket(SystemMessage.id(SystemMessageId.GM_S1).addString("??????? ???????? ? " + target_cp.getName() + " ??? ????????!"));
- target_cp.sendPacket(SystemMessage.id(SystemMessageId.GM_S1).addString("???? ???: ? ??????? " + last_sec + " ?????? ???????? ??? ??? ?????????."));
- return true;
- }
- }
- if (!AntiBotPW.this._activeEyes.containsKey(target_cp))
- {
- player.sendPacket(SystemMessage.id(SystemMessageId.GM_S1).addString("?????? ??????? ???????? ? " + target_cp.getName() + "!"));
- if ((!AntiBotPW.AntiBotPWReCheckEndingGM) || (!player.isGM())) {
- target_cp.sendPacket(SystemMessage.id(SystemMessageId.GM_S1).addString("????? " + player.getName() + " ???????? ? ??? ??????? ????????!"));
- } else {
- target_cp.sendPacket(SystemMessage.id(SystemMessageId.GM_S1).addString("??? ????????? ??????? ????????!"));
- }
- target_cp.broadcastPacket(new MagicSkillUser(target_cp, target_cp, 1427, 1, 10, 0));
- player.broadcastPacket(new MagicSkillUser(player, player, 1427, 1, 10, 0));
- int counterrors = AntiBotPW.CaptchaCountError;
- AntiBotPW.this._errors.put(target_cp, Integer.valueOf(counterrors));
- AntiBotPW.this.triggerCaptcha(target_cp, true);
- }
- else
- {
- player.sendPacket(SystemMessage.id(SystemMessageId.GM_S1).addString("??????? ???????? ? " + target_cp.getName() + " ??? ????????!"));
- }
- }
- }
- }
- return true;
- }
- public String[] getVoicedCommandList()
- {
- return this.VOICED_COMMANDS;
- }
- }
- private final class BotEye
- implements Runnable
- {
- private ScheduledFuture<?> _task;
- private int _delay;
- private L2PcInstance _player;
- public BotEye(L2PcInstance player, int delay)
- {
- this._task = null;
- this._player = player;
- this._delay = delay;
- run();
- }
- public void run()
- {
- if ((this._delay < 1) || (this._player.isOnline() == 0))
- {
- if (AntiBotPW.CaptchaAntiBotPWKick == 1)
- {
- String valid = (String)AntiBotPW.this._codes.get(this._player);
- AntiBotPW.this.validate(this._player, valid);
- Util.handleIllegalPlayerAction(this._player, "Player " + this._player.getName() + " did not enter the AntiBotPW captcha intime.", 2);
- if (this._player.isOnline() == 0) {
- AntiBotPW.this.teleportOfflinePlayer(this._player.getName(), 82737, 148571, 62066);
- }
- if (AntiBotPW.AntiBotPWLog) {
- AntiBotPW.this.writeLog(this._player);
- }
- }
- else
- {
- String valid = (String)AntiBotPW.this._codes.get(this._player);
- AntiBotPW.this.validate(this._player, valid);
- if (this._player.isOnline() == 0) {
- AntiBotPW.this.teleportOfflinePlayer(this._player.getName(), 82737, 148571, 62066);
- } else if (AntiBotPW.CaptchaAntiBotPWKick == 2) {
- this._player.teleToClosestTown();
- } else {
- this._player.teleToLocation(AntiBotPW.CaptchaAntiBotPWLoc[0], AntiBotPW.CaptchaAntiBotPWLoc[1], AntiBotPW.CaptchaAntiBotPWLoc[2]);
- }
- if (AntiBotPW.AntiBotPWLog) {
- AntiBotPW.this.writeLog(this._player);
- }
- }
- return;
- }
- handleTick();
- this._task = ThreadPoolManager.getInstance().scheduleGeneral(this, 1000L);
- this._delay -= 1;
- }
- public void cancel()
- {
- if (this._task != null) {
- this._task.cancel(true);
- }
- }
- private void handleTick()
- {
- switch (this._delay)
- {
- case 1:
- case 2:
- case 3:
- case 4:
- case 5:
- case 10:
- case 15:
- case 30:
- case 45:
- case 60:
- case 120:
- case 180:
- case 240:
- case 300:
- this._player.sendPacket(SystemMessage.id(SystemMessageId.GM_S1).addString("???? ???: ? ??? ???????? " + this._delay + " ?????? ?? ??????????? ????? ?????."));
- }
- }
- }
- protected static class Color
- {
- protected int r;
- protected int g;
- protected int b;
- public boolean equals(Object obj)
- {
- if (this == obj) {
- return true;
- }
- if ((obj == null) || (getClass() != obj.getClass())) {
- return false;
- }
- Color color = (Color)obj;
- return (this.b == color.b) && (this.g == color.g) && (this.r == color.r);
- }
- public int hashCode()
- {
- int i = this.r;
- i = 29 * i + this.g;
- i = 29 * i + this.b;
- return i;
- }
- public Color()
- {
- boolean z = false;
- this.b = 0;
- this.g = 0;
- this.r = 0;
- }
- public Color(int i, int j, int k)
- {
- this.r = i;
- this.g = j;
- this.b = k;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment