Advertisement
Sarada-L2

Bot Captar Acis 394+ diferenciado

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