Advertisement
ChristianMacedo

Bot Captar l2JLisvus

Jul 6th, 2022
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 26.01 KB | None | 0 0
  1. diff --git a/config/CustomMods/SpecialMods.ini b/config/CustomMods/SpecialMods.ini
  2. index 7f85fbc..1c88b2d 100644
  3. --- a/config/CustomMods/SpecialMods.ini
  4. +++ b/config/CustomMods/SpecialMods.ini
  5. @@ -52,3 +52,28 @@
  6. # Announce TOPS PVP E PK. default = false
  7. AnnounceTops = False
  8.  
  9. +# ===============================================================
  10. +# Ant Bot
  11. +# ===============================================================
  12. +# Bots prevention system.
  13. +EnableBotsPrevention = True
  14. +# How many monsters have to be killed to run validation task?
  15. +KillsCounter = 35
  16. +# Specify range of randomly taken values summed with main counter.
  17. +KillsCounterRandomization = 35
  18. +# How long validation window awaits an answer? (in seconds)
  19. +ValidationTime = 90
  20. +# Punishments:
  21. +# 0 = move character to the closest village.
  22. +# 1 = kick characters from the server.
  23. +# 2 = put character to jail.
  24. +# 3 = ban character from the server.
  25. +Punishment = 2
  26. +# How long character were suppose to stay in jail? (in minutes)
  27. +PunishmentTime = 60
  28. +# Location for City Character X,Y,Z
  29. +# Retail Giran -> 83365, 148144, -3431
  30. +CoordenadX = 83365
  31. +CoordenadY = 148144
  32. +CoordenadZ = -3431
  33. +
  34. diff --git a/java/net/sf/l2j/Config.java b/java/net/sf/l2j/Config.java
  35. index 8aedc48..2b854ea 100644
  36. --- a/java/net/sf/l2j/Config.java
  37. +++ b/java/net/sf/l2j/Config.java
  38. @@ -49,6 +49,7 @@
  39. /**Custom Properties */
  40. public static final String VIP_DONATE= "./config/CustomMods/Donate.ini";
  41. public static final String SPECIAL_MODS= "./config/CustomMods/SpecialMods.ini";
  42. + public static final String PROTECTION_MODS= "./config/CustomMods/ProtectionMods.ini";
  43. /** Properties file for access level configurations */
  44. public static final String ACCESS_LEVELS_FILE = "./config/AccessLevels.properties";
  45. /** Properties file for alternative configurations */
  46. @@ -992,7 +993,15 @@
  47. public static int PVP_NORMAL_TIME;
  48. /** Duration (in ms) while a player stay in PVP mode after hitting a purple player */
  49. public static int PVP_PVP_TIME;
  50. -
  51. + public static boolean BOTS_PREVENTION;
  52. + public static int KILLS_COUNTER;
  53. + public static int KILLS_COUNTER_RANDOMIZATION;
  54. + public static int VALIDATION_TIME;
  55. + public static int PUNISHMENT;
  56. + public static int PUNISHMENT_TIME;
  57. + public static int BOT_X;
  58. + public static int BOT_Y;
  59. + public static int BOT_Z;
  60. // Karma Punishment
  61. /** Allow player with karma to be killed in peace zone ? */
  62. public static boolean ALT_GAME_KARMA_PLAYER_CAN_BE_KILLED_IN_PEACEZONE;
  63. @@ -2227,6 +2236,29 @@
  64. PVP_PVP_TIME = Integer.parseInt(pvpSettings.getProperty("PvPVsPvPTime", "30000"));
  65.  
  66.  
  67. +
  68. + // ProtectionMods Properties
  69. + Properties ProtectionMods = new Properties();
  70. + try (InputStream is = new FileInputStream(new File(PROTECTION_MODS)))
  71. + {
  72. + ProtectionMods.load(is);
  73. + }
  74. + catch (Exception e)
  75. + {
  76. + e.printStackTrace();
  77. + throw new Error("Failed to Load " + PROTECTION_MODS + " File.");
  78. + }
  79. + BOTS_PREVENTION = Boolean.parseBoolean(ProtectionMods.getProperty("EnableBotsPrevention", "false"));
  80. + KILLS_COUNTER = Integer.parseInt(ProtectionMods.getProperty("KillsCounter", "60"));
  81. + KILLS_COUNTER_RANDOMIZATION = Integer.parseInt(ProtectionMods.getProperty("KillsCounterRandomization", "50"));
  82. + VALIDATION_TIME = Integer.parseInt(ProtectionMods.getProperty("ValidationTime", "60"));
  83. + PUNISHMENT = Integer.parseInt(ProtectionMods.getProperty("Punishment", "0"));
  84. + PUNISHMENT_TIME = Integer.parseInt(ProtectionMods.getProperty("PunishmentTime", "60"));
  85. + BOT_X = Integer.parseInt(ProtectionMods.getProperty("CoordenadX", "0"));
  86. + BOT_Y = Integer.parseInt(ProtectionMods.getProperty("CoordenadY", "0"));
  87. + BOT_Z = Integer.parseInt(ProtectionMods.getProperty("CoordenadZ", "0"));
  88. +
  89. +
  90. // SpecialMods Properties
  91. Properties Special = new Properties();
  92. try (InputStream is = new FileInputStream(new File(SPECIAL_MODS)))
  93. diff --git a/java/net/sf/l2j/gameserver/instancemanager/BotsPreventionManager.java b/java/net/sf/l2j/gameserver/instancemanager/BotsPreventionManager.java
  94. new file mode 100644
  95. index 0000000..b7a7185
  96. --- /dev/null
  97. +++ b/java/net/sf/l2j/gameserver/instancemanager/BotsPreventionManager.java
  98. @@ -0,0 +1,594 @@
  99. +package net.sf.l2j.gameserver.instancemanager;
  100. +
  101. +import java.io.File;
  102. +import java.io.RandomAccessFile;
  103. +import java.sql.Connection;
  104. +import java.sql.PreparedStatement;
  105. +import java.sql.SQLException;
  106. +import java.util.ArrayList;
  107. +import java.util.Calendar;
  108. +import java.util.HashMap;
  109. +import java.util.List;
  110. +import java.util.Map;
  111. +import java.util.Random;
  112. +import java.util.concurrent.Future;
  113. +
  114. +import net.sf.l2j.Config;
  115. +import net.sf.l2j.L2DatabaseFactory;
  116. +import net.sf.l2j.gameserver.ThreadPoolManager;
  117. +import net.sf.l2j.gameserver.model.L2Character;
  118. +import net.sf.l2j.gameserver.model.actor.instance.L2MonsterInstance;
  119. +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  120. +import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
  121. +import net.sf.l2j.gameserver.network.serverpackets.PledgeCrest;
  122. +import net.sf.l2j.util.StringUtil;
  123. +
  124. +public class BotsPreventionManager
  125. +{
  126. + private class PlayerData
  127. + {
  128. + public PlayerData()
  129. + {
  130. + firstWindow = true;
  131. + }
  132. +
  133. + public int mainpattern;
  134. + public List<Integer> options = new ArrayList<>();
  135. + public boolean firstWindow;
  136. + public int patternid;
  137. + }
  138. +
  139. + protected Random _randomize;
  140. + protected static Map<Integer, Integer> _monsterscounter;
  141. + protected static Map<Integer, Future<?>> _beginvalidation;
  142. + protected static Map<Integer, PlayerData> _validation;
  143. + protected static Map<Integer, byte[]> _images;
  144. + protected int WINDOW_DELAY = 3; //delay used to generate new window if previous have been closed.
  145. + protected int VALIDATION_TIME = Config.VALIDATION_TIME * 1000;
  146. +
  147. + public static final BotsPreventionManager getInstance()
  148. + {
  149. + return SingletonHolder._instance;
  150. + }
  151. +
  152. + BotsPreventionManager()
  153. + {
  154. + _randomize = new Random();
  155. + _monsterscounter = new HashMap<>();
  156. + _beginvalidation = new HashMap<>();
  157. + _validation = new HashMap<>();
  158. + _images = new HashMap<>();
  159. + _beginvalidation = new HashMap<>();
  160. +
  161. + getimages();
  162. + }
  163. +
  164. + public void updatecounter(L2Character player, L2Character monster)
  165. + {
  166. + if ((player instanceof L2PcInstance) && (monster instanceof L2MonsterInstance))
  167. + {
  168. + L2PcInstance killer = (L2PcInstance) player;
  169. +
  170. + if (_validation.get(killer.getObjectId()) != null)
  171. + {
  172. + return;
  173. + }
  174. +
  175. + int count = 1;
  176. + if (_monsterscounter.get(killer.getObjectId()) != null)
  177. + {
  178. + count = _monsterscounter.get(killer.getObjectId()) + 1;
  179. + }
  180. +
  181. + int next = _randomize.nextInt(Config.KILLS_COUNTER_RANDOMIZATION);
  182. + if (Config.KILLS_COUNTER + next < count)
  183. + {
  184. + validationtasks(killer);
  185. + _monsterscounter.remove(killer.getObjectId());
  186. + }
  187. + else
  188. + {
  189. + _monsterscounter.put(killer.getObjectId(), count);
  190. + }
  191. + }
  192. + }
  193. +
  194. + private static void getimages()
  195. + {
  196. + String CRESTS_DIR = "data/html/mods/prevention";
  197. +
  198. + final File directory = new File(CRESTS_DIR);
  199. + directory.mkdirs();
  200. +
  201. + int i = 0;
  202. + for (File file : directory.listFiles())
  203. + {
  204. + if (!file.getName().endsWith(".dds"))
  205. + continue;
  206. +
  207. + byte[] data;
  208. +
  209. + try (RandomAccessFile f = new RandomAccessFile(file, "r"))
  210. + {
  211. + data = new byte[(int) f.length()];
  212. + f.readFully(data);
  213. + }
  214. + catch (Exception e)
  215. + {
  216. + continue;
  217. + }
  218. + _images.put(i, data);
  219. + i++;
  220. + }
  221. + }
  222. +
  223. + public void prevalidationwindow(L2PcInstance player)
  224. + {
  225. + NpcHtmlMessage html = new NpcHtmlMessage(1);
  226. + StringBuilder tb = new StringBuilder();
  227. + StringUtil.append(tb, "<html>");
  228. + StringUtil.append(tb, "<title>Bots prevention</title>");
  229. + StringUtil.append(tb, "<body><center><br><br><img src=\"L2UI_CH3.herotower_deco\" width=\"256\" height=\"32\">");
  230. + StringUtil.append(tb, "<br><br><font color=\"a2a0a2\">if such window appears it means server suspect,<br1>that you may using cheating software.</font>");
  231. + StringUtil.append(tb, "<br><br><font color=\"b09979\">if given answer results are incorrect or no action is made<br1>server is going to punish character instantly.</font>");
  232. + StringUtil.append(tb, "<br><br><button value=\"CONTINUE\" action=\"bypass report_continue\" width=\"75\" height=\"21\" back=\"L2UI_CH3.Btn1_normal\" fore=\"L2UI_CH3.Btn1_normal\">");
  233. + StringUtil.append(tb, "</center></body>");
  234. + StringUtil.append(tb, "</html>");
  235. + html.setHtml(tb.toString());
  236. + player.sendPacket(html);
  237. + }
  238. +
  239. + private static void validationwindow(L2PcInstance player)
  240. + {
  241. + PlayerData container = _validation.get(player.getObjectId());
  242. + NpcHtmlMessage html = new NpcHtmlMessage(1);
  243. +
  244. + StringBuilder tb = new StringBuilder();
  245. + StringUtil.append(tb, "<html>");
  246. + StringUtil.append(tb, "<title>Bots prevention</title>");
  247. + StringUtil.append(tb, "<body><center><br><br><img src=\"L2UI_CH3.herotower_deco\" width=\"256\" height=\"32\">");
  248. + StringUtil.append(tb, "<br><br><font color=\"a2a0a2\">in order to prove you are a human being<br1>you've to</font> <font color=\"b09979\">match colours within generated pattern:</font>");
  249. +
  250. + // generated main pattern.
  251. + StringUtil.append(tb, "<br><br><img src=\"Crest.crest_" + Config.SERVER_ID + "_" + (_validation.get(player.getObjectId()).patternid) + "\" width=\"32\" height=\"32\"></td></tr>");
  252. + StringUtil.append(tb, "<br><br><font color=b09979>click-on pattern of your choice beneath:</font>");
  253. +
  254. + // generate random colours.
  255. + StringUtil.append(tb, "<table><tr>");
  256. + for (int i = 0; i < container.options.size(); i++)
  257. + {
  258. + StringUtil.append(tb, "<td><button action=\"bypass -h report_" + i + "\" width=32 height=32 back=\"Crest.crest_" + Config.SERVER_ID + "_" + (container.options.get(i) + 1500) + "\" fore=\"Crest.crest_" + Config.SERVER_ID + "_" + (container.options.get(i) + 1500) + "\"></td>");
  259. + }
  260. + StringUtil.append(tb, "</tr></table>");
  261. + StringUtil.append(tb, "</center></body>");
  262. + StringUtil.append(tb, "</html>");
  263. +
  264. + html.setHtml(tb.toString());
  265. + player.sendPacket(html);
  266. + }
  267. +
  268. + private static void validationOnewindow(L2PcInstance player)
  269. + {
  270. + PlayerData container = _validation.get(player.getObjectId());
  271. + NpcHtmlMessage html = new NpcHtmlMessage(1);
  272. +
  273. + StringBuilder tb = new StringBuilder();
  274. + StringUtil.append(tb, "<html>");
  275. + StringUtil.append(tb, "<title>Bots prevention Second Chance</title>");
  276. + StringUtil.append(tb, "<body><center><br><br><img src=\"L2UI_CH3.herotower_deco\" width=\"256\" height=\"32\">");
  277. + StringUtil.append(tb, "<br><br><font color=\"a2a0a2\">in order to prove you are a human being<br1>you've to</font> <font color=\"b09979\">match colours within generated pattern:</font>");
  278. +
  279. + // generated main pattern.
  280. + StringUtil.append(tb, "<br><br><img src=\"Crest.crest_" + Config.SERVER_ID + "_" + (_validation.get(player.getObjectId()).patternid) + "\" width=\"32\" height=\"32\"></td></tr>");
  281. + StringUtil.append(tb, "<br><br><font color=b09979>click-on pattern of your choice beneath:</font>");
  282. +
  283. + // generate random colours.
  284. + StringUtil.append(tb, "<table><tr>");
  285. + for (int i = 0; i < container.options.size(); i++)
  286. + {
  287. + StringUtil.append(tb, "<td><button action=\"bypass -h one_" + i + "\" width=32 height=32 back=\"Crest.crest_" + Config.SERVER_ID + "_" + (container.options.get(i) + 1500) + "\" fore=\"Crest.crest_" + Config.SERVER_ID + "_" + (container.options.get(i) + 1500) + "\"></td>");
  288. + }
  289. + StringUtil.append(tb, "</tr></table>");
  290. + StringUtil.append(tb, "</center></body>");
  291. + StringUtil.append(tb, "</html>");
  292. +
  293. + html.setHtml(tb.toString());
  294. + player.sendPacket(html);
  295. + }
  296. +
  297. + private static void validationFinalwindow(L2PcInstance player)
  298. + {
  299. + PlayerData container = _validation.get(player.getObjectId());
  300. + NpcHtmlMessage html = new NpcHtmlMessage(1);
  301. +
  302. + StringBuilder tb = new StringBuilder();
  303. + StringUtil.append(tb, "<html>");
  304. + StringUtil.append(tb, "<title>Bots prevention Final Chance</title>");
  305. + StringUtil.append(tb, "<body><center><br><br><img src=\"L2UI_CH3.herotower_deco\" width=\"256\" height=\"32\">");
  306. + StringUtil.append(tb, "<br><br><font color=\"a2a0a2\">in order to prove you are a human being<br1>you've to</font> <font color=\"b09979\">match colours within generated pattern:</font>");
  307. +
  308. + // generated main pattern.
  309. + StringUtil.append(tb, "<br><br><img src=\"Crest.crest_" + Config.SERVER_ID + "_" + (_validation.get(player.getObjectId()).patternid) + "\" width=\"32\" height=\"32\"></td></tr>");
  310. + StringUtil.append(tb, "<br><br><font color=b09979>click-on pattern of your choice beneath:</font>");
  311. +
  312. + // generate random colours.
  313. + StringUtil.append(tb, "<table><tr>");
  314. + for (int i = 0; i < container.options.size(); i++)
  315. + {
  316. + StringUtil.append(tb, "<td><button action=\"bypass -h final_" + i + "\" width=32 height=32 back=\"Crest.crest_" + Config.SERVER_ID + "_" + (container.options.get(i) + 1500) + "\" fore=\"Crest.crest_" + Config.SERVER_ID + "_" + (container.options.get(i) + 1500) + "\"></td>");
  317. + }
  318. + StringUtil.append(tb, "</tr></table>");
  319. + StringUtil.append(tb, "</center></body>");
  320. + StringUtil.append(tb, "</html>");
  321. +
  322. + html.setHtml(tb.toString());
  323. + player.sendPacket(html);
  324. + }
  325. +
  326. +
  327. + public void punishmentnwindow(L2PcInstance player)
  328. + {
  329. + NpcHtmlMessage html = new NpcHtmlMessage(1);
  330. + StringBuilder tb = new StringBuilder();
  331. + StringUtil.append(tb, "<html>");
  332. + StringUtil.append(tb, "<title>Bots prevention</title>");
  333. + StringUtil.append(tb, "<body><center><br><br><img src=\"L2UI_CH3.herotower_deco\" width=\"256\" height=\"32\">");
  334. + StringUtil.append(tb, "<br><br><font color=\"a2a0a2\">if such window appears, it means character haven't<br1>passed through prevention system.");
  335. + StringUtil.append(tb, "<br><br><font color=\"b09979\">in such case character get moved to nearest town.</font>");
  336. + StringUtil.append(tb, "</center></body>");
  337. + StringUtil.append(tb, "</html>");
  338. + html.setHtml(tb.toString());
  339. + player.sendPacket(html);
  340. + }
  341. +
  342. + public void validationtasks(L2PcInstance player)
  343. + {
  344. + PlayerData container = new PlayerData();
  345. + randomizeimages(container, player);
  346. +
  347. + for (int i = 0; i < container.options.size(); i++)
  348. + {
  349. + PledgeCrest packet = new PledgeCrest((container.options.get(i) + 1500), _images.get(container.options.get(i)));
  350. + player.sendPacket(packet);
  351. +
  352. + }
  353. +
  354. + PledgeCrest packet = new PledgeCrest(container.patternid, _images.get(container.options.get(container.mainpattern)));
  355. + player.sendPacket(packet);
  356. +
  357. + _validation.put(player.getObjectId(), container);
  358. +
  359. + Future<?> newTask = ThreadPoolManager.getInstance().scheduleGeneral(new ReportCheckTask(player), VALIDATION_TIME);
  360. + ThreadPoolManager.getInstance().scheduleGeneral(new countdown(player, VALIDATION_TIME / 1000), 0);
  361. + _beginvalidation.put(player.getObjectId(), newTask);
  362. + }
  363. +
  364. + protected void randomizeimages(PlayerData container,L2PcInstance player)
  365. + {
  366. + int buttonscount = 4;
  367. + int imagescount = _images.size();
  368. +
  369. + for (int i = 0; i < buttonscount; i++)
  370. + {
  371. + int next = _randomize.nextInt(imagescount);
  372. + while (container.options.indexOf(next) > -1)
  373. + {
  374. + next = _randomize.nextInt(imagescount);
  375. + }
  376. + container.options.add(next);
  377. + }
  378. +
  379. + int mainIndex = _randomize.nextInt(buttonscount);
  380. + container.mainpattern = mainIndex;
  381. +
  382. + Calendar token = Calendar.getInstance();
  383. + String uniquetoken = Integer.toString(token.get(Calendar.DAY_OF_MONTH))+Integer.toString(token.get(Calendar.HOUR_OF_DAY))+Integer.toString(token.get(Calendar.MINUTE))+Integer.toString(token.get(Calendar.SECOND))+Integer.toString(token.get(Calendar.MILLISECOND)/100);
  384. + container.patternid = Integer.parseInt(uniquetoken);
  385. + }
  386. +
  387. + protected void banpunishment(L2PcInstance player)
  388. + {
  389. + _validation.remove(player.getObjectId());
  390. + _beginvalidation.get(player.getObjectId()).cancel(true);
  391. + _beginvalidation.remove(player.getObjectId());
  392. +
  393. + switch (Config.PUNISHMENT)
  394. + {
  395. + // 0 = move character to the closest village.
  396. + // 1 = kick characters from the server.
  397. + // 2 = put character to jail.
  398. + // 3 = ban character from the server.
  399. + case 0:
  400. + player.stopMove(null);
  401. + // player.teleToLocation(MapRegionTable.TeleportType.TOWN);
  402. + player.teleToLocation(Config.BOT_X, Config.BOT_Y, Config.BOT_Z);
  403. + punishmentnwindow(player);
  404. + break;
  405. + case 1:
  406. + if (player.isOnline())
  407. + {
  408. + player.logout(true);
  409. + }
  410. + break;
  411. + case 2:
  412. + jailpunishment(player, Config.PUNISHMENT_TIME * 60);
  413. + break;
  414. + case 3:
  415. + //player.setAccessLevel(-100);
  416. + changeaccesslevel(player, -100);
  417. + break;
  418. + }
  419. +
  420. + player.sendMessage("Unfortunately, colours doesn't match.");
  421. + }
  422. +
  423. + private static void changeaccesslevel(L2PcInstance targetPlayer, int lvl)
  424. + {
  425. + if (targetPlayer.isOnline())
  426. + {
  427. + targetPlayer.setAccountAccesslevel(-100);
  428. + targetPlayer.logout();
  429. + }
  430. + else
  431. + {
  432. + try (Connection con = L2DatabaseFactory.getInstance().getConnection())
  433. + {
  434. + PreparedStatement statement = con.prepareStatement("UPDATE characters SET accesslevel=? WHERE obj_id=?");
  435. + statement.setInt(1, lvl);
  436. + statement.setInt(2, targetPlayer.getObjectId());
  437. + statement.execute();
  438. + statement.close();
  439. + }
  440. + catch (SQLException se)
  441. + {
  442. + if (Config.DEBUG)
  443. + se.printStackTrace();
  444. + }
  445. + }
  446. + }
  447. +
  448. + private static void jailpunishment(L2PcInstance activeChar, int delay)
  449. + {
  450. + if (activeChar.isOnline())
  451. + {
  452. + activeChar.setInJail(true, Config.PUNISHMENT_TIME);
  453. + }
  454. + else
  455. + {
  456. + try (Connection con = L2DatabaseFactory.getInstance().getConnection())
  457. + {
  458. + PreparedStatement statement = con.prepareStatement("UPDATE characters SET x=?, y=?, z=?, punish_level=?, punish_timer=? WHERE obj_id=?");
  459. + statement.setInt(1, -114356);
  460. + statement.setInt(2, -249645);
  461. + statement.setInt(3, -2984);
  462. + //statement.setInt(4, L2PcInstance.setInJail(true));
  463. + statement.setLong(5, (delay > 0 ? delay * Config.PUNISHMENT_TIME * 100 : 0));
  464. + statement.setInt(6, activeChar.getObjectId());
  465. +
  466. + statement.execute();
  467. + statement.close();
  468. + }
  469. + catch (SQLException se)
  470. + {
  471. + activeChar.sendMessage("SQLException while jailing player");
  472. + if (Config.DEBUG)
  473. + se.printStackTrace();
  474. + }
  475. + }
  476. + }
  477. +
  478. + public void AnalyseBypass(String command, L2PcInstance player)
  479. + {
  480. + if (!_validation.containsKey(player.getObjectId()))
  481. + return;
  482. +
  483. + String params = command.substring(command.indexOf("_") + 1);
  484. +
  485. + if (params.startsWith("continue"))
  486. + {
  487. + validationwindow(player);
  488. + _validation.get(player.getObjectId()).firstWindow = false;
  489. + return;
  490. + }
  491. +
  492. + int choosenoption = -1;
  493. + if (tryParseInt(params))
  494. + {
  495. + choosenoption = Integer.parseInt(params);
  496. + }
  497. +
  498. + if (choosenoption > -1)
  499. + {
  500. + PlayerData playerData = _validation.get(player.getObjectId());
  501. + if (choosenoption != playerData.mainpattern)
  502. + {
  503. + validationOnewindow(player);
  504. + _validation.get(player.getObjectId()).firstWindow = false;
  505. + return;
  506. + }
  507. +
  508. + player.sendMessage("Congratulations, colours match!");
  509. + _validation.remove(player.getObjectId());
  510. + _beginvalidation.get(player.getObjectId()).cancel(true);
  511. + _beginvalidation.remove(player.getObjectId());
  512. + }
  513. + }
  514. +
  515. + public void AnalyseOneBypass(String command, L2PcInstance player)
  516. + {
  517. + if (!_validation.containsKey(player.getObjectId()))
  518. + return;
  519. +
  520. + String params = command.substring(command.indexOf("_") + 1);
  521. +
  522. + if (params.startsWith("continue"))
  523. + {
  524. + validationwindow(player);
  525. + _validation.get(player.getObjectId()).firstWindow = false;
  526. + return;
  527. + }
  528. +
  529. + int choosenoption = -1;
  530. + if (tryParseInt(params))
  531. + {
  532. + choosenoption = Integer.parseInt(params);
  533. + }
  534. +
  535. + if (choosenoption > -1)
  536. + {
  537. + PlayerData playerData = _validation.get(player.getObjectId());
  538. + if (choosenoption != playerData.mainpattern)
  539. + {
  540. + validationFinalwindow(player);
  541. + _validation.get(player.getObjectId()).firstWindow = false;
  542. + return;
  543. + }
  544. +
  545. + player.sendMessage("Congratulations, colours match!");
  546. + _validation.remove(player.getObjectId());
  547. + _beginvalidation.get(player.getObjectId()).cancel(true);
  548. + _beginvalidation.remove(player.getObjectId());
  549. + }
  550. + }
  551. +
  552. + public void AnalyseFinalBypass(String command, L2PcInstance player)
  553. + {
  554. + if (!_validation.containsKey(player.getObjectId()))
  555. + return;
  556. +
  557. + String params = command.substring(command.indexOf("_") + 1);
  558. +
  559. + if (params.startsWith("continue"))
  560. + {
  561. + validationwindow(player);
  562. + _validation.get(player.getObjectId()).firstWindow = false;
  563. + return;
  564. + }
  565. +
  566. + int choosenoption = -1;
  567. + if (tryParseInt(params))
  568. + {
  569. + choosenoption = Integer.parseInt(params);
  570. + }
  571. +
  572. + if (choosenoption > -1)
  573. + {
  574. + PlayerData playerData = _validation.get(player.getObjectId());
  575. + if (choosenoption != playerData.mainpattern)
  576. + banpunishment(player);
  577. + else
  578. + {
  579. + player.sendMessage("Congratulations, colours match!");
  580. + _validation.remove(player.getObjectId());
  581. + _beginvalidation.get(player.getObjectId()).cancel(true);
  582. + _beginvalidation.remove(player.getObjectId());
  583. + }
  584. + }
  585. + }
  586. +
  587. + protected class countdown implements Runnable
  588. + {
  589. + private final L2PcInstance _player;
  590. + private int _time;
  591. +
  592. + public countdown(L2PcInstance player, int time)
  593. + {
  594. + _time = time;
  595. + _player = player;
  596. + }
  597. +
  598. + @Override
  599. + public void run()
  600. + {
  601. + if (_player.isOnline())
  602. + {
  603. + if (_validation.containsKey(_player.getObjectId()) && _validation.get(_player.getObjectId()).firstWindow)
  604. + {
  605. + if (_time % WINDOW_DELAY == 0)
  606. + {
  607. + prevalidationwindow(_player);
  608. + }
  609. + }
  610. +
  611. + switch (_time)
  612. + {
  613. + case 300:
  614. + case 240:
  615. + case 180:
  616. + case 120:
  617. + case 60:
  618. + _player.sendMessage(_time / 60 + " minute(s) to match colors.");
  619. + break;
  620. + case 30:
  621. + case 10:
  622. + case 5:
  623. + case 4:
  624. + case 3:
  625. + case 2:
  626. + case 1:
  627. + _player.sendMessage(_time + " second(s) to match colors!");
  628. + break;
  629. + }
  630. + if (_time > 1 && _validation.containsKey(_player.getObjectId()))
  631. + {
  632. + ThreadPoolManager.getInstance().scheduleGeneral(new countdown(_player, _time - 1), 1000);
  633. + }
  634. + }
  635. + }
  636. + }
  637. +
  638. + protected boolean tryParseInt(String value)
  639. + {
  640. + try
  641. + {
  642. + Integer.parseInt(value);
  643. + return true;
  644. + }
  645. +
  646. + catch (NumberFormatException e)
  647. + {
  648. + return false;
  649. + }
  650. + }
  651. +
  652. + public void CaptchaSuccessfull(L2PcInstance player)
  653. + {
  654. + if (_validation.get(player.getObjectId()) != null)
  655. + {
  656. + _validation.remove(player.getObjectId());
  657. + }
  658. + }
  659. +
  660. + public Boolean IsAlredyInReportMode(L2PcInstance player)
  661. + {
  662. + if (_validation.get(player.getObjectId()) != null)
  663. + {
  664. + return true;
  665. + }
  666. + return false;
  667. + }
  668. +
  669. + private class ReportCheckTask implements Runnable
  670. + {
  671. + private final L2PcInstance _player;
  672. +
  673. + public ReportCheckTask(L2PcInstance player)
  674. + {
  675. + _player = player;
  676. + }
  677. +
  678. + @Override
  679. + public void run()
  680. + {
  681. + if (_validation.get(_player.getObjectId()) != null)
  682. + {
  683. + banpunishment(_player);
  684. + }
  685. + }
  686. + }
  687. +
  688. + private static class SingletonHolder
  689. + {
  690. + protected static final BotsPreventionManager _instance = new BotsPreventionManager();
  691. + }
  692. +}
  693. \ No newline at end of file
  694. diff --git a/java/net/sf/l2j/gameserver/model/L2Character.java b/java/net/sf/l2j/gameserver/model/L2Character.java
  695. index 9ea33fd..37520dd 100644
  696. --- a/java/net/sf/l2j/gameserver/model/L2Character.java
  697. +++ b/java/net/sf/l2j/gameserver/model/L2Character.java
  698. @@ -38,6 +38,7 @@
  699. import net.sf.l2j.gameserver.geoengine.GeoData;
  700. import net.sf.l2j.gameserver.handler.ISkillHandler;
  701. import net.sf.l2j.gameserver.handler.SkillHandler;
  702. +import net.sf.l2j.gameserver.instancemanager.BotsPreventionManager;
  703. import net.sf.l2j.gameserver.instancemanager.TownManager;
  704. import net.sf.l2j.gameserver.model.L2Skill.SkillType;
  705. import net.sf.l2j.gameserver.model.actor.instance.L2BoatInstance;
  706. @@ -1652,7 +1653,10 @@
  707. }
  708.  
  709. calculateRewards(killer);
  710. -
  711. + if (Config.BOTS_PREVENTION)
  712. + {
  713. + BotsPreventionManager.getInstance().updatecounter(killer,this);
  714. + }
  715. // Send the Server->Client packet StatusUpdate with current HP and MP to all other L2PcInstance to inform
  716. broadcastStatusUpdate();
  717.  
  718. @@ -6886,7 +6890,6 @@
  719.  
  720. return true;
  721. }
  722. -
  723. public boolean canInteract(L2PcInstance player)
  724. {
  725. if (player.isCastingNow() || player.isSitting())
  726. diff --git a/java/net/sf/l2j/gameserver/network/clientpackets/RequestBypassToServer.java b/java/net/sf/l2j/gameserver/network/clientpackets/RequestBypassToServer.java
  727. index 1226d04..3ddd484 100644
  728. --- a/java/net/sf/l2j/gameserver/network/clientpackets/RequestBypassToServer.java
  729. +++ b/java/net/sf/l2j/gameserver/network/clientpackets/RequestBypassToServer.java
  730. @@ -25,6 +25,7 @@
  731. import net.sf.l2j.gameserver.handler.IAdminCommandHandler;
  732. import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
  733. import net.sf.l2j.gameserver.handler.VoicedCommandHandler;
  734. +import net.sf.l2j.gameserver.instancemanager.BotsPreventionManager;
  735. import net.sf.l2j.gameserver.model.L2Object;
  736. import net.sf.l2j.gameserver.model.L2World;
  737. import net.sf.l2j.gameserver.model.Location;
  738. @@ -140,6 +141,18 @@
  739. {
  740. playerHelp(activeChar, _command.substring(12));
  741. }
  742. + else if (_command.startsWith("report"))
  743. + {
  744. + BotsPreventionManager.getInstance().AnalyseBypass(_command,activeChar);
  745. + }
  746. + else if (_command.startsWith("one"))
  747. + {
  748. + BotsPreventionManager.getInstance().AnalyseOneBypass(_command,activeChar);
  749. + }
  750. + else if (_command.startsWith("final"))
  751. + {
  752. + BotsPreventionManager.getInstance().AnalyseFinalBypass(_command,activeChar);
  753. + }
  754. else if (_command.startsWith("npc_"))
  755. {
  756. if (!activeChar.validateBypass(_command))
  757.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement