Guest User

Untitled

a guest
Apr 11th, 2010
459
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 41.83 KB | None | 0 0
  1. Index: java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
  2. ===================================================================
  3. --- java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java   (revision 4014)
  4. +++ java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java   (working copy)
  5. @@ -193,7 +193,7 @@
  6.  import net.sf.l2j.gameserver.templates.L2Weapon;
  7.  import net.sf.l2j.gameserver.templates.L2WeaponType;
  8.  import net.sf.l2j.gameserver.util.Broadcast;
  9. -import net.sf.l2j.gameserver.util.FloodProtector;
  10. +import net.sf.l2j.gameserver.util.FloodProtectors;
  11.  import net.sf.l2j.util.Point3D;
  12.  import net.sf.l2j.util.Rnd;
  13.  
  14. @@ -331,6 +331,9 @@
  15.     protected int _baseClass;
  16.     protected int _activeClass;
  17.     protected int _classIndex = 0;
  18. +  
  19. +   /** Flood Protector **/
  20. +   private final FloodProtectors _floodProtectors = new FloodProtectors(this);
  21.  
  22.     /** The list of sub-classes this character has. */
  23.      private Map<Integer, SubClass> _subClasses;
  24. @@ -9389,9 +9392,6 @@
  25.         // Close the connection with the client
  26.         closeNetConnection();
  27.  
  28. -       // remove from flood protector
  29. -       FloodProtector.getInstance().removePlayer(getObjectId());
  30. -
  31.         if (getClanId() > 0)
  32.             getClan().broadcastToOtherOnlineMembers(new PledgeShowMemberListUpdate(this), this);
  33.             //ClanTable.getInstance().getClan(getClanId()).broadcastToOnlineMembers(new PledgeShowMemberListAdd(this));
  34. @@ -10215,4 +10215,8 @@
  35.     {
  36.         _forceBuff = fb;
  37.     }
  38. +   public FloodProtectors getFloodProtectors()
  39. +   {
  40. +       return _floodProtectors;
  41. +   }
  42.  }
  43. Index: java/net/sf/l2j/gameserver/handler/itemhandlers/Firework.java
  44. ===================================================================
  45. --- java/net/sf/l2j/gameserver/handler/itemhandlers/Firework.java   (revision 4014)
  46. +++ java/net/sf/l2j/gameserver/handler/itemhandlers/Firework.java   (working copy)
  47. @@ -27,7 +27,6 @@
  48.  import net.sf.l2j.gameserver.network.SystemMessageId;
  49.  import net.sf.l2j.gameserver.serverpackets.MagicSkillUser;
  50.  import net.sf.l2j.gameserver.serverpackets.SystemMessage;
  51. -import net.sf.l2j.gameserver.util.FloodProtector;
  52.  
  53.  /**
  54.   * This class ...
  55. @@ -46,7 +45,7 @@
  56.          L2PcInstance activeChar = (L2PcInstance)playable;
  57.          int itemId = item.getItemId();
  58.  
  59. -        if (!FloodProtector.getInstance().tryPerformAction(activeChar.getObjectId(), FloodProtector.PROTECTED_FIREWORK))
  60. +        if (!activeChar.getFloodProtectors().getFirework().tryPerformAction("firework use"))
  61.          {
  62.             SystemMessage sm = new SystemMessage(SystemMessageId.S1_CANNOT_BE_USED);
  63.             sm.addItemName(itemId);
  64. Index: java/net/sf/l2j/gameserver/clientpackets/UseItem.java
  65. ===================================================================
  66. --- java/net/sf/l2j/gameserver/clientpackets/UseItem.java   (revision 4014)
  67. +++ java/net/sf/l2j/gameserver/clientpackets/UseItem.java   (working copy)
  68. @@ -36,7 +36,6 @@
  69.  import net.sf.l2j.gameserver.templates.L2Item;
  70.  import net.sf.l2j.gameserver.templates.L2Weapon;
  71.  import net.sf.l2j.gameserver.templates.L2WeaponType;
  72. -import net.sf.l2j.gameserver.util.FloodProtector;
  73.  
  74.  /**
  75.   * This class ...
  76. @@ -66,8 +65,11 @@
  77.              return;
  78.  
  79.         // Flood protect UseItem
  80. -       if (!FloodProtector.getInstance().tryPerformAction(activeChar.getObjectId(), FloodProtector.PROTECTED_USEITEM))
  81. +       if (!activeChar.getFloodProtectors().getUseItem().tryPerformAction("use item"))
  82. +       {
  83. +           activeChar.sendMessage("You cannot use items so fast. Try again latter !");
  84.             return;
  85. +       }
  86.  
  87.         if (activeChar.getPrivateStoreType() != 0)
  88.         {
  89. Index: java/net/sf/l2j/gameserver/handler/itemhandlers/RollingDice.java
  90. ===================================================================
  91. --- java/net/sf/l2j/gameserver/handler/itemhandlers/RollingDice.java    (revision 4014)
  92. +++ java/net/sf/l2j/gameserver/handler/itemhandlers/RollingDice.java    (working copy)
  93. @@ -27,7 +27,6 @@
  94.  import net.sf.l2j.gameserver.serverpackets.Dice;
  95.  import net.sf.l2j.gameserver.serverpackets.SystemMessage;
  96.  import net.sf.l2j.gameserver.util.Broadcast;
  97. -import net.sf.l2j.gameserver.util.FloodProtector;
  98.  import net.sf.l2j.util.Rnd;
  99.  
  100.  
  101. @@ -82,7 +81,11 @@
  102.     private int rollDice(L2PcInstance player)
  103.     {
  104.         // Check if the dice is ready
  105. -       if ( !FloodProtector.getInstance().tryPerformAction(player.getObjectId(), FloodProtector.PROTECTED_ROLLDICE) ) return 0;
  106. +       if (!player.getFloodProtectors().getRollDice().tryPerformAction("dice use"))
  107. +       {
  108. +          player.sendMessage("You can't roll dice so fast");
  109. +          return 0;
  110. +       }
  111.         return Rnd.get(1, 6);
  112.     }
  113.  
  114. Index: java/net/sf/l2j/gameserver/clientpackets/EnterWorld.java
  115. ===================================================================
  116. --- java/net/sf/l2j/gameserver/clientpackets/EnterWorld.java    (revision 4014)
  117. +++ java/net/sf/l2j/gameserver/clientpackets/EnterWorld.java    (working copy)
  118. @@ -71,7 +71,6 @@
  119.  import net.sf.l2j.gameserver.serverpackets.SignsSky;
  120.  import net.sf.l2j.gameserver.serverpackets.SystemMessage;
  121.  import net.sf.l2j.gameserver.serverpackets.UserInfo;
  122. -import net.sf.l2j.gameserver.util.FloodProtector;
  123.  /**
  124.   * Enter World Packet Handler<p>
  125.   * <p>
  126. @@ -106,9 +105,6 @@
  127.             return;
  128.         }
  129.  
  130. -       // Register in flood protector
  131. -       FloodProtector.getInstance().registerNewPlayer(activeChar.getObjectId());
  132. -
  133.         if (L2World.getInstance().findObject(activeChar.getObjectId()) != null)
  134.         {
  135.             if(Config.DEBUG)
  136. Index: java/net/sf/l2j/gameserver/clientpackets/Say2.java
  137. ===================================================================
  138. --- java/net/sf/l2j/gameserver/clientpackets/Say2.java  (revision 4014)
  139. +++ java/net/sf/l2j/gameserver/clientpackets/Say2.java  (working copy)
  140. @@ -35,7 +35,6 @@
  141.  import net.sf.l2j.gameserver.network.SystemMessageId;
  142.  import net.sf.l2j.gameserver.serverpackets.CreatureSay;
  143.  import net.sf.l2j.gameserver.serverpackets.SystemMessage;
  144. -import net.sf.l2j.gameserver.util.FloodProtector;
  145.  
  146.  /**
  147.   * This class ...
  148. @@ -313,7 +312,7 @@
  149.             case HERO_VOICE:
  150.                 if (activeChar.isHero())
  151.                 {
  152. -                   if (!FloodProtector.getInstance().tryPerformAction(activeChar.getObjectId(), FloodProtector.PROTECTED_HEROVOICE))
  153. +                   if (!activeChar.getFloodProtectors().getHeroVoice().tryPerformAction("hero chat"))
  154.                     {
  155.                         activeChar.sendMessage("Action failed. Heroes are only able to speak in the global channel once every 10 seconds.");
  156.                         return;
  157. Index: java/net/sf/l2j/gameserver/util/StringUtil.java
  158. ===================================================================
  159. --- java/net/sf/l2j/gameserver/util/StringUtil.java (revision 0)
  160. +++ java/net/sf/l2j/gameserver/util/StringUtil.java (revision 0)
  161. @@ -0,0 +1,297 @@
  162. +/*
  163. + * $Header$
  164. + *
  165. + * $Author: fordfrog $ $Date$ $Revision$ $Log$
  166. + *
  167. + *
  168. + * This program is free software: you can redistribute it and/or modify it under
  169. + * the terms of the GNU General Public License as published by the Free Software
  170. + * Foundation, either version 3 of the License, or (at your option) any later
  171. + * version.
  172. + *
  173. + * This program is distributed in the hope that it will be useful, but WITHOUT
  174. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  175. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  176. + * details.
  177. + *
  178. + * You should have received a copy of the GNU General Public License along with
  179. + * this program. If not, see <http://www.gnu.org/licenses/>.
  180. + */
  181. +package net.sf.l2j.gameserver.util;
  182. +
  183. +/**
  184. + * String utilities optimized for the best performance.
  185. + *
  186. + * <h1>How to Use It</h1> <h2>concat() or append()</h2> If concatenating strings
  187. + * in single call, use StringUtil.concat(), otherwise use StringUtil.append()
  188. + * and its variants. <h2>Minimum Calls</h2> Bad:
  189. + *
  190. + * <pre>
  191. + * final StringBuilder sbString = new StringBuilder();
  192. + * StringUtil.append(sbString, &quot;text 1&quot;, String.valueOf(npcId));
  193. + * StringUtil.append(&quot;text 2&quot;);
  194. + * </pre>
  195. + *
  196. + * Good:
  197. + *
  198. + * <pre>
  199. + * final StringBuilder sbString = new StringBuilder();
  200. + * StringUtil.append(sbString, &quot;text 1&quot;, String.valueOf(npcId), &quot;text 2&quot;);
  201. + * </pre>
  202. + *
  203. + * Why?<br/>
  204. + * Because the less calls you do, the less memory re-allocations have to be done
  205. + * so the whole text fits into the memory and less array copy tasks has to be
  206. + * performed. So if using less calls, less memory is used and string
  207. + * concatenation is faster. <h2>Size Hints for Loops</h2> Bad:
  208. + *
  209. + * <pre>
  210. + * final StringBuilder sbString = new StringBuilder();
  211. + * StringUtil.append(sbString, &quot;header start&quot;, someText, &quot;header end&quot;);
  212. + * for (int i = 0; i &lt; 50; i++)
  213. + * {
  214. + *     StringUtil.append(sbString, &quot;text 1&quot;, stringArray[i], &quot;text 2&quot;);
  215. + * }
  216. + * </pre>
  217. + *
  218. + * Good:
  219. + *
  220. + * <pre>
  221. + * final StringBuilder sbString = StringUtil.startAppend(1300, &quot;header start&quot;, someText, &quot;header end&quot;);
  222. + * for (int i = 0; i &lt; 50; i++)
  223. + * {
  224. + *     StringUtil.append(sbString, &quot;text 1&quot;, stringArray[i], &quot;text 2&quot;);
  225. + * }
  226. + * </pre>
  227. + *
  228. + * Why?<br/>
  229. + * When using StringUtil.append(), memory is only allocated to fit in the
  230. + * strings in method argument. So on each loop new memory for the string has to
  231. + * be allocated and old string has to be copied to the new string. With size
  232. + * hint, even if the size hint is above the needed memory, memory is saved
  233. + * because new memory has not to be allocated on each cycle. Also it is much
  234. + * faster if no string copy tasks has to be performed. So if concatenating
  235. + * strings in a loop, count approximately the size and set it as the hint for
  236. + * the string builder size. It's better to make the size hint little bit larger
  237. + * rather than smaller.<br/>
  238. + * In case there is no text appended before the cycle, just use <code>new
  239. + * StringBuilder(1300)</code>. <h2>Concatenation and Constants</h2> Bad:
  240. + *
  241. + * <pre>
  242. + * StringUtil.concat(&quot;text 1 &quot;, &quot;text 2&quot;, String.valueOf(npcId));
  243. + * </pre>
  244. + *
  245. + * Good:
  246. + *
  247. + * <pre>
  248. + * StringUtil.concat(&quot;text 1 &quot; + &quot;text 2&quot;, String.valueOf(npcId));
  249. + * </pre>
  250. + *
  251. + * or
  252. + *
  253. + * <pre>
  254. + * StringUtil.concat(&quot;text 1 text 2&quot;, String.valueOf(npcId));
  255. + * </pre>
  256. + *
  257. + * Why?<br/>
  258. + * It saves some cycles when determining size of memory that needs to be
  259. + * allocated because less strings are passed to concat() method. But do not use
  260. + * + for concatenation of non-constant strings, that degrades performance and
  261. + * makes extra memory allocations needed. <h2>Concatenation and Constant
  262. + * Variables</h2> Bad:
  263. + *
  264. + * <pre>
  265. + * String glue = &quot;some glue&quot;;
  266. + * StringUtil.concat(&quot;text 1&quot;, glue, &quot;text 2&quot;, glue, String.valueOf(npcId));
  267. + * </pre>
  268. + *
  269. + * Good:
  270. + *
  271. + * <pre>
  272. + * final String glue = &quot;some glue&quot;;
  273. + * StringUtil.concat(&quot;text 1&quot; + glue + &quot;text2&quot; + glue, String.valueOf(npcId));
  274. + * </pre>
  275. + *
  276. + * Why? Because when using <code>final</code> keyword, the <code>glue</code> is
  277. + * marked as constant string and compiler treats it as a constant string so it
  278. + * is able to create string "text1some gluetext2some glue" during the
  279. + * compilation. But this only works in case the value is known at compilation
  280. + * time, so this cannot be used for cases like
  281. + * <code>final String objectIdString =
  282. + * String.valueOf(getObjectId)</code>. <h2>StringBuilder Reuse</h2> Bad:
  283. + *
  284. + * <pre>
  285. + * final StringBuilder sbString1 = new StringBuilder();
  286. + * StringUtil.append(sbString1, &quot;text 1&quot;, String.valueOf(npcId), &quot;text 2&quot;);
  287. + * ... // output of sbString1, it is no more needed
  288. + * final StringBuilder sbString2 = new StringBuilder();
  289. + * StringUtil.append(sbString2, &quot;text 3&quot;, String.valueOf(npcId), &quot;text 4&quot;);
  290. + * </pre>
  291. + *
  292. + * Good:
  293. + *
  294. + * <pre>
  295. + * final StringBuilder sbString = new StringBuilder();
  296. + * StringUtil.append(sbString, &quot;text 1&quot;, String.valueOf(npcId), &quot;text 2&quot;);
  297. + * ... // output of sbString, it is no more needed
  298. + * sbString.setLength(0);
  299. + * StringUtil.append(sbString, &quot;text 3&quot;, String.valueOf(npcId), &quot;text 4&quot;);
  300. + * </pre>
  301. + *
  302. + * Why?</br> In first case, new memory has to be allocated for the second
  303. + * string. In second case already allocated memory is reused, but only in case
  304. + * the new string is not longer than the previously allocated string. Anyway,
  305. + * the second way is better because the string either fits in the memory and
  306. + * some memory is saved, or it does not fit in the memory, and in that case it
  307. + * works as in the first case. <h2>Primitives to Strings</h2> To convert
  308. + * primitives to string, use String.valueOf(). <h2>How much faster is it?</h2>
  309. + * Here are some results of my tests. Count is number of strings concatenated.
  310. + * Don't take the numbers as 100% true as the numbers are affected by other
  311. + * programs running on my computer at the same time. Anyway, from the results it
  312. + * is obvious that using StringBuilder with predefined size is the fastest (and
  313. + * also most memory efficient) solution. It is about 5 times faster when
  314. + * concatenating 7 strings, compared to TextBuilder. Also, with more strings
  315. + * concatenated, the difference between StringBuilder and TextBuilder gets
  316. + * larger. In code, there are many cases, where there are concatenated 50+
  317. + * strings so the time saving is even greater.
  318. + *
  319. + * <pre>
  320. + * Count: 2
  321. + * TextBuilder: 1893
  322. + * TextBuilder with size: 1703
  323. + * String: 1033
  324. + * StringBuilder: 993
  325. + * StringBuilder with size: 1024
  326. + * Count: 3
  327. + * TextBuilder: 1973
  328. + * TextBuilder with size: 1872
  329. + * String: 2583
  330. + * StringBuilder: 1633
  331. + * StringBuilder with size: 1156
  332. + * Count: 4
  333. + * TextBuilder: 2188
  334. + * TextBuilder with size: 2229
  335. + * String: 4207
  336. + * StringBuilder: 1816
  337. + * StringBuilder with size: 1444
  338. + * Count: 5
  339. + * TextBuilder: 9185
  340. + * TextBuilder with size: 9464
  341. + * String: 6937
  342. + * StringBuilder: 2745
  343. + * StringBuilder with size: 1882
  344. + * Count: 6
  345. + * TextBuilder: 9785
  346. + * TextBuilder with size: 10082
  347. + * String: 9471
  348. + * StringBuilder: 2889
  349. + * StringBuilder with size: 1857
  350. + * Count: 7
  351. + * TextBuilder: 10169
  352. + * TextBuilder with size: 10528
  353. + * String: 12746
  354. + * StringBuilder: 3081
  355. + * StringBuilder with size: 2139
  356. + * </pre>
  357. + *
  358. + * @author fordfrog
  359. + */
  360. +public final class StringUtil
  361. +{
  362. +  
  363. +   private StringUtil()
  364. +   {
  365. +   }
  366. +  
  367. +   /**
  368. +    * Concatenates strings.
  369. +    *
  370. +    * @param strings
  371. +    *            strings to be concatenated
  372. +    *
  373. +    * @return concatenated string
  374. +    *
  375. +    * @see StringUtil
  376. +    */
  377. +   public static String concat(final String... strings)
  378. +   {
  379. +       final StringBuilder sbString = new StringBuilder(getLength(strings));
  380. +      
  381. +       for (final String string : strings)
  382. +       {
  383. +           sbString.append(string);
  384. +       }
  385. +      
  386. +       return sbString.toString();
  387. +   }
  388. +  
  389. +   /**
  390. +    * Creates new string builder with size initializated to
  391. +    * <code>sizeHint</code>, unless total length of strings is greater than
  392. +    * <code>sizeHint</code>.
  393. +    *
  394. +    * @param sizeHint
  395. +    *            hint for string builder size allocation
  396. +    * @param strings
  397. +    *            strings to be appended
  398. +    *
  399. +    * @return created string builder
  400. +    *
  401. +    * @see StringUtil
  402. +    */
  403. +   public static StringBuilder startAppend(final int sizeHint, final String... strings)
  404. +   {
  405. +       final int length = getLength(strings);
  406. +       final StringBuilder sbString = new StringBuilder(sizeHint > length ? sizeHint : length);
  407. +      
  408. +       for (final String string : strings)
  409. +       {
  410. +           sbString.append(string);
  411. +       }
  412. +      
  413. +       return sbString;
  414. +   }
  415. +  
  416. +   /**
  417. +    * Appends strings to existing string builder.
  418. +    *
  419. +    * @param sbString
  420. +    *            string builder
  421. +    * @param strings
  422. +    *            strings to be appended
  423. +    *
  424. +    * @see StringUtil
  425. +    */
  426. +   public static void append(final StringBuilder sbString, final String... strings)
  427. +   {
  428. +       sbString.ensureCapacity(sbString.length() + getLength(strings));
  429. +      
  430. +       for (final String string : strings)
  431. +       {
  432. +           sbString.append(string);
  433. +       }
  434. +   }
  435. +  
  436. +   /**
  437. +    * Counts total length of all the strings.
  438. +    *
  439. +    * @param strings
  440. +    *            array of strings
  441. +    *
  442. +    * @return total length of all the strings
  443. +    */
  444. +   private static int getLength(final String[] strings)
  445. +   {
  446. +       int length = 0;
  447. +      
  448. +       for (final String string : strings)
  449. +       {
  450. +           if (string == null)
  451. +               length += 4;
  452. +           else
  453. +               length += string.length();
  454. +       }
  455. +      
  456. +       return length;
  457. +   }
  458. +}
  459. Index: java/net/sf/l2j/gameserver/GameServer.java
  460. ===================================================================
  461. --- java/net/sf/l2j/gameserver/GameServer.java  (revision 4014)
  462. +++ java/net/sf/l2j/gameserver/GameServer.java  (working copy)
  463. @@ -227,7 +227,6 @@
  464.  import net.sf.l2j.gameserver.script.faenor.FaenorScriptEngine;
  465.  import net.sf.l2j.gameserver.taskmanager.TaskManager;
  466.  import net.sf.l2j.gameserver.util.DynamicExtension;
  467. -import net.sf.l2j.gameserver.util.FloodProtector;
  468.  import net.sf.l2j.status.Status;
  469.  
  470.  import com.l2jserver.mmocore.network.SelectorServerConfig;
  471. @@ -646,7 +645,6 @@
  472.              _log.log(Level.WARNING, "DynamicExtension could not be loaded and initialized", ex);
  473.          }
  474.  
  475. -        FloodProtector.getInstance();
  476.          TvTManager.getInstance();
  477.         System.gc();
  478.         // maxMemory is the upper limit the jvm can use, totalMemory the size of the current allocation pool, freeMemory the unused memory in the allocation pool
  479. Index: java/net/sf/l2j/gameserver/handler/itemhandlers/SummonItems.java
  480. ===================================================================
  481. --- java/net/sf/l2j/gameserver/handler/itemhandlers/SummonItems.java    (revision 4014)
  482. +++ java/net/sf/l2j/gameserver/handler/itemhandlers/SummonItems.java    (working copy)
  483. @@ -45,7 +45,6 @@
  484.  import net.sf.l2j.gameserver.serverpackets.Ride;
  485.  import net.sf.l2j.gameserver.serverpackets.SystemMessage;
  486.  import net.sf.l2j.gameserver.templates.L2NpcTemplate;
  487. -import net.sf.l2j.gameserver.util.FloodProtector;
  488.  
  489.  public class SummonItems implements IItemHandler
  490.  {
  491. @@ -59,7 +58,11 @@
  492.  
  493.         L2PcInstance activeChar = (L2PcInstance)playable;
  494.  
  495. -       if ( !FloodProtector.getInstance().tryPerformAction(activeChar.getObjectId(), FloodProtector.PROTECTED_ITEMPETSUMMON) ) return;
  496. +       if (!activeChar.getFloodProtectors().getItemPetSummon().tryPerformAction("summon item"))
  497. +       {
  498. +       activeChar.sendMessage("You can't summon items so fast");
  499. +       return;
  500. +       }
  501.  
  502.         if(activeChar.isSitting())
  503.         {
  504. Index: java/net/sf/l2j/gameserver/util/FloodProtectorConfig.java
  505. ===================================================================
  506. --- java/net/sf/l2j/gameserver/util/FloodProtectorConfig.java   (revision 0)
  507. +++ java/net/sf/l2j/gameserver/util/FloodProtectorConfig.java   (revision 0)
  508. @@ -0,0 +1,59 @@
  509. +/*
  510. + * This program is free software: you can redistribute it and/or modify it under the terms of the
  511. + * GNU General Public License as published by the Free Software Foundation, either version 3 of the
  512. + * License, or (at your option) any later version.
  513. + *
  514. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
  515. + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  516. + * General Public License for more details.
  517. + *
  518. + * You should have received a copy of the GNU General Public License along with this program. If
  519. + * not, see <http://www.gnu.org/licenses/>.
  520. + */
  521. +package net.sf.l2j.gameserver.util;
  522. +
  523. +/**
  524. + * Flood protector configuration
  525. + *
  526. + * @author fordfrog
  527. + */
  528. +public final class FloodProtectorConfig
  529. +{
  530. +  
  531. +   /**
  532. +    * Type used for identification of logging output.
  533. +    */
  534. +   public String FLOOD_PROTECTOR_TYPE;
  535. +   /**
  536. +    * Flood protection interval in game ticks.
  537. +    */
  538. +   public int FLOOD_PROTECTION_INTERVAL;
  539. +   /**
  540. +    * Whether flooding should be logged.
  541. +    */
  542. +   public boolean LOG_FLOODING;
  543. +   /**
  544. +    * If specified punishment limit is exceeded, punishment is applied.
  545. +    */
  546. +   public int PUNISHMENT_LIMIT;
  547. +   /**
  548. +    * Punishment type. Either 'none', 'kick', 'ban' or 'jail'.
  549. +    */
  550. +   public String PUNISHMENT_TYPE;
  551. +   /**
  552. +    * For how long should the char/account be punished.
  553. +    */
  554. +   public int PUNISHMENT_TIME;
  555. +  
  556. +   /**
  557. +    * Creates new instance of FloodProtectorConfig.
  558. +    *
  559. +    * @param floodProtectorType
  560. +    *            {@link #FLOOD_PROTECTOR_TYPE}
  561. +    */
  562. +   public FloodProtectorConfig(final String floodProtectorType)
  563. +   {
  564. +       super();
  565. +       FLOOD_PROTECTOR_TYPE = floodProtectorType;
  566. +   }
  567. +}
  568. \ No newline at end of file
  569. Index: java/net/sf/l2j/gameserver/util/FloodProtectorAction.java
  570. ===================================================================
  571. --- java/net/sf/l2j/gameserver/util/FloodProtectorAction.java   (revision 0)
  572. +++ java/net/sf/l2j/gameserver/util/FloodProtectorAction.java   (revision 0)
  573. @@ -0,0 +1,172 @@
  574. +/*
  575. + * This program is free software: you can redistribute it and/or modify it under the terms of the
  576. + * GNU General Public License as published by the Free Software Foundation, either version 3 of the
  577. + * License, or (at your option) any later version.
  578. + *
  579. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
  580. + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  581. + * General Public License for more details.
  582. + *
  583. + * You should have received a copy of the GNU General Public License along with this program. If
  584. + * not, see <http://www.gnu.org/licenses/>.
  585. + */
  586. +package net.sf.l2j.gameserver.util;
  587. +
  588. +import java.util.concurrent.atomic.AtomicInteger;
  589. +import java.util.logging.Level;
  590. +import java.util.logging.Logger;
  591. +import net.sf.l2j.gameserver.GameTimeController;
  592. +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  593. +
  594. +/**
  595. + * Flood protector implementation.
  596. + *
  597. + * @author fordfrog
  598. + */
  599. +public final class FloodProtectorAction
  600. +{
  601. +  
  602. +   /**
  603. +    * Logger
  604. +    */
  605. +   private static final Logger _log = Logger.getLogger(FloodProtectorAction.class.getName());
  606. +   /**
  607. +    * Player for this instance of flood protector.
  608. +    */
  609. +   private final L2PcInstance _player;
  610. +   /**
  611. +    * Configuration of this instance of flood protector.
  612. +    */
  613. +   private final FloodProtectorConfig _config;
  614. +   /**
  615. +    * Next game tick when new request is allowed.
  616. +    */
  617. +   private volatile int _nextGameTick = GameTimeController.getGameTicks();
  618. +   /**
  619. +    * Request counter.
  620. +    */
  621. +   private AtomicInteger _count = new AtomicInteger(0);
  622. +   /**
  623. +    * Flag determining whether exceeding request has been logged.
  624. +    */
  625. +   private boolean _logged;
  626. +   /**
  627. +    * Flag determining whether punishment application is in progress so that we do not apply
  628. +    * punisment multiple times (flooding).
  629. +    */
  630. +   private volatile boolean _punishmentInProgress;
  631. +  
  632. +   /**
  633. +    * Creates new instance of FloodProtectorAction.
  634. +    *
  635. +    * @param player
  636. +    *            player for which flood protection is being created
  637. +    * @param config
  638. +    *            flood protector configuration
  639. +    */
  640. +   public FloodProtectorAction(final L2PcInstance player, final FloodProtectorConfig config)
  641. +   {
  642. +       super();
  643. +       _player = player;
  644. +       _config = config;
  645. +   }
  646. +  
  647. +   /**
  648. +    * Checks whether the request is flood protected or not.
  649. +    *
  650. +    * @param command
  651. +    *            command issued or short command description
  652. +    *
  653. +    * @return true if action is allowed, otherwise false
  654. +    */
  655. +   public boolean tryPerformAction(final String command)
  656. +   {
  657. +       final int curTick = GameTimeController.getGameTicks();
  658. +      
  659. +       if (curTick < _nextGameTick || _punishmentInProgress)
  660. +       {
  661. +           if (_config.LOG_FLOODING && !_logged && _log.isLoggable(Level.WARNING))
  662. +           {
  663. +               _log.warning(StringUtil.concat(_config.FLOOD_PROTECTOR_TYPE, ": Player [", _player.getName(), "] called command [", command, "] [~", String.valueOf((_config.FLOOD_PROTECTION_INTERVAL - (_nextGameTick - curTick)) * GameTimeController.MILLIS_IN_TICK), " ms] after previous command"));
  664. +               _logged = true;
  665. +           }
  666. +          
  667. +           _count.incrementAndGet();
  668. +          
  669. +           if (!_punishmentInProgress && _config.PUNISHMENT_LIMIT > 0 && _count.get() > _config.PUNISHMENT_LIMIT && _config.PUNISHMENT_TYPE != null)
  670. +           {
  671. +               _punishmentInProgress = true;
  672. +              
  673. +               if ("kick".equals(_config.PUNISHMENT_TYPE))
  674. +               {
  675. +                   kickPlayer();
  676. +               }
  677. +               else if ("ban".equals(_config.PUNISHMENT_TYPE))
  678. +               {
  679. +                   banAccount();
  680. +               }
  681. +               else if ("jail".equals(_config.PUNISHMENT_TYPE))
  682. +               {
  683. +                   jailChar();
  684. +               }
  685. +              
  686. +               _punishmentInProgress = false;
  687. +           }
  688. +          
  689. +           return false;
  690. +       }
  691. +      
  692. +       if (_count.get() > 0)
  693. +       {
  694. +           if (_config.LOG_FLOODING && _log.isLoggable(Level.WARNING))
  695. +           {
  696. +               _log.warning(StringUtil.concat(_config.FLOOD_PROTECTOR_TYPE, ": Player [", _player.getName(), "] issued [", String.valueOf(_count), "] extra requests within [~", String.valueOf(_config.FLOOD_PROTECTION_INTERVAL * GameTimeController.MILLIS_IN_TICK), " ms]"));
  697. +           }
  698. +       }
  699. +      
  700. +       _nextGameTick = curTick + _config.FLOOD_PROTECTION_INTERVAL;
  701. +       _logged = false;
  702. +       _count.set(0);
  703. +      
  704. +       return true;
  705. +   }
  706. +
  707. +   /**
  708. +    * Kick player from game (close network connection).
  709. +    */
  710. +   private void kickPlayer()
  711. +   {
  712. +       _player.closeNetConnection();
  713. +
  714. +       if (_log.isLoggable(Level.WARNING))
  715. +       {
  716. +           _log.warning(StringUtil.concat(_config.FLOOD_PROTECTOR_TYPE, ": Account [", _player.getAccountName(), "] kicked for flooding [char ", _player.getName(), "]"));
  717. +       }
  718. +   }
  719. +
  720. +   /**
  721. +    * Bans char account and logs out the char.
  722. +    */
  723. +   private void banAccount()
  724. +   {
  725. +       _player.setAccountAccesslevel(-100);
  726. +              
  727. +       if (_log.isLoggable(Level.WARNING))
  728. +           _log.warning(StringUtil.concat(_config.FLOOD_PROTECTOR_TYPE, ": Account [", _player.getAccountName(), "] banned for flooding [char ", _player.getName(), "] ", _config.PUNISHMENT_TIME <= 0 ? "forever" : "for " + _config.PUNISHMENT_TIME + " mins"));
  729. +              
  730. +       _player.logout();
  731. +       }
  732. +  
  733. +   /**
  734. +    * Jails char.
  735. +    */
  736. +   private void jailChar()
  737. +   {
  738. +       _player.setInJail(true, _config.PUNISHMENT_TIME);
  739. +      
  740. +       if (_log.isLoggable(Level.WARNING))
  741. +       {
  742. +           _log.warning(StringUtil.concat(_config.FLOOD_PROTECTOR_TYPE, ": Player [", _player.getName(), "] jailed for flooding [char ", _player.getName(), "] ", _config.PUNISHMENT_TIME <= 0 ? "forever" : "for " + _config.PUNISHMENT_TIME + " mins"));
  743. +       }
  744. +   }
  745. +}
  746. \ No newline at end of file
  747. Index: java/net/sf/l2j/Config.java
  748. ===================================================================
  749. --- java/net/sf/l2j/Config.java (revision 4014)
  750. +++ java/net/sf/l2j/Config.java (working copy)
  751. @@ -30,6 +30,8 @@
  752.  
  753.  import javolution.util.FastList;
  754.  import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  755. +import net.sf.l2j.gameserver.util.FloodProtectorConfig;
  756. +import net.sf.l2j.gameserver.util.StringUtil;
  757.  
  758.  /**
  759.   * This class contains global server configuration.<br>
  760. @@ -711,6 +713,7 @@
  761.      public static final String  SEVENSIGNS_FILE             = "./config/sevensigns.properties";
  762.      public static final String  CLANHALL_CONFIG_FILE        = "./config/clanhall.properties";
  763.      public static final String  L2JMOD_CONFIG_FILE            = "./config/l2jmods.properties";
  764. +    public static final String  FLOODPROTECTOR_CONFIG_FILE  = "./config/FloodProtector.properties";
  765.      public static int MAX_ITEM_IN_PACKET;
  766.  
  767.      public static boolean CHECK_KNOWN;
  768. @@ -881,6 +884,32 @@
  769.      public static boolean L2JMOD_WEDDING_SAMESEX;
  770.      public static boolean L2JMOD_WEDDING_FORMALWEAR;
  771.      public static int L2JMOD_WEDDING_DIVORCE_COSTS;
  772. +    
  773. +     //--------------------------------------------------
  774. +    // FloodProtector Settings
  775. +    //--------------------------------------------------
  776. +    public static final FloodProtectorConfig FLOOD_PROTECTOR_USE_ITEM =
  777. +       new FloodProtectorConfig("UseItemFloodProtector");
  778. +    public static final FloodProtectorConfig FLOOD_PROTECTOR_ROLL_DICE =
  779. +       new FloodProtectorConfig("RollDiceFloodProtector");
  780. +    public static final FloodProtectorConfig FLOOD_PROTECTOR_FIREWORK =
  781. +       new FloodProtectorConfig("FireworkFloodProtector");
  782. +    public static final FloodProtectorConfig FLOOD_PROTECTOR_ITEM_PET_SUMMON =
  783. +       new FloodProtectorConfig("ItemPetSummonFloodProtector");
  784. +    public static final FloodProtectorConfig FLOOD_PROTECTOR_HERO_VOICE =
  785. +       new FloodProtectorConfig("HeroVoiceFloodProtector");
  786. +    public static final FloodProtectorConfig FLOOD_PROTECTOR_GLOBAL_CHAT =
  787. +       new FloodProtectorConfig("GlobalChatFloodProtector");
  788. +    public static final FloodProtectorConfig FLOOD_PROTECTOR_SUBCLASS =
  789. +       new FloodProtectorConfig("SubclassFloodProtector");
  790. +    public static final FloodProtectorConfig FLOOD_PROTECTOR_DROP_ITEM =
  791. +       new FloodProtectorConfig("DropItemFloodProtector");
  792. +    public static final FloodProtectorConfig FLOOD_PROTECTOR_SERVER_BYPASS =
  793. +       new FloodProtectorConfig("ServerBypassFloodProtector");
  794. +    public static final FloodProtectorConfig FLOOD_PROTECTOR_MULTISELL =
  795. +       new FloodProtectorConfig("MultiSellFloodProtector");
  796. +    public static final FloodProtectorConfig FLOOD_PROTECTOR_TRANSACTION =
  797. +       new FloodProtectorConfig("TransactionFloodProtector");
  798.  
  799.      // Packet information
  800.      /** Count the amount of packets per minute ? */
  801. @@ -1963,6 +1992,24 @@
  802.                  e.printStackTrace();
  803.                  throw new Error("Failed to Load "+L2JMOD_CONFIG_FILE+" File.");
  804.              }
  805. +            
  806. +            // Actions FloodProtector
  807. +            try
  808. +            {
  809. +            Properties FloodProtector   = new Properties();
  810. +            InputStream is        = new FileInputStream(new File(FLOODPROTECTOR_CONFIG_FILE));
  811. +            FloodProtector.load(is);
  812. +            is.close();
  813. +                  
  814. +            loadFloodProtectorConfigs(FloodProtector);
  815. +                        
  816. +            }  
  817. +            catch (Exception e)  
  818. +            {  
  819. +            e.printStackTrace();  
  820. +            throw new Error("Failed to Load "+FLOODPROTECTOR_CONFIG_FILE+" File.");  
  821. +            }
  822. +            
  823.              // pvp config
  824.              try
  825.              {
  826. @@ -2164,6 +2211,44 @@
  827.          }
  828.  
  829.      }
  830. +    
  831. +    /**
  832. +    * Loads single flood protector configuration.
  833. +    *  
  834. +    * @param properties
  835. +    * properties file reader
  836. +    * @param config
  837. +    * flood protector configuration instance
  838. +    * @param configString
  839. +    * flood protector configuration string that determines for which flood protector
  840. +    * configuration should be read
  841. +    * @param defaultInterval
  842. +    *  default flood protector interval
  843. +    */
  844. +    private static void loadFloodProtectorConfig(final Properties properties, final FloodProtectorConfig config, final String configString, final String defaultInterval)
  845. +    {
  846. +    config.FLOOD_PROTECTION_INTERVAL = Integer.parseInt(properties.getProperty(StringUtil.concat("FloodProtector", configString, "Interval"), defaultInterval));
  847. +    config.LOG_FLOODING = Boolean.parseBoolean(properties.getProperty(StringUtil.concat("FloodProtector", configString, "LogFlooding"), "False"));
  848. +    config.PUNISHMENT_LIMIT = Integer.parseInt(properties.getProperty(StringUtil.concat("FloodProtector", configString, "PunishmentLimit"), "0"));
  849. +    config.PUNISHMENT_TYPE = properties.getProperty(StringUtil.concat("FloodProtector", configString, "PunishmentType"), "none");
  850. +    config.PUNISHMENT_TIME = Integer.parseInt(properties.getProperty(StringUtil.concat("FloodProtector", configString, "PunishmentTime"), "0"));
  851. +    }
  852. +            
  853. +                
  854. +    private static void loadFloodProtectorConfigs(final Properties properties)
  855. +    {
  856. +           loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_USE_ITEM, "UseItem", "4");
  857. +           loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_ROLL_DICE, "RollDice", "42");
  858. +           loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_FIREWORK, "Firework", "42");
  859. +           loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_ITEM_PET_SUMMON, "ItemPetSummon", "16");
  860. +           loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_HERO_VOICE, "HeroVoice", "100");
  861. +           loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_GLOBAL_CHAT, "GlobalChat", "5");
  862. +           loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_SUBCLASS, "Subclass", "20");
  863. +           loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_DROP_ITEM, "DropItem", "10");
  864. +           loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_SERVER_BYPASS, "ServerBypass", "5");
  865. +           loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_MULTISELL, "MultiSell", "1");
  866. +           loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_TRANSACTION, "Transaction", "10");
  867. +       }
  868.  
  869.      /**
  870.       * Set a new value to a game parameter from the admin console.
  871. Index: java/net/sf/l2j/gameserver/util/FloodProtectors.java
  872. ===================================================================
  873. --- java/net/sf/l2j/gameserver/util/FloodProtectors.java    (revision 0)
  874. +++ java/net/sf/l2j/gameserver/util/FloodProtectors.java    (revision 0)
  875. @@ -0,0 +1,204 @@
  876. +/*
  877. +/*
  878. + * This program is free software: you can redistribute it and/or modify it under the terms of the
  879. + * GNU General Public License as published by the Free Software Foundation, either version 3 of the
  880. + * License, or (at your option) any later version.
  881. + *
  882. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
  883. + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  884. + * General Public License for more details.
  885. + *
  886. + * You should have received a copy of the GNU General Public License along with this program. If
  887. + * not, see <http://www.gnu.org/licenses/>.
  888. + */
  889. +package net.sf.l2j.gameserver.util;
  890. +
  891. +import net.sf.l2j.Config;
  892. +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  893. +
  894. +/**
  895. + * Collection of flood protectors for single player.
  896. + *
  897. + * @author fordfrog
  898. + */
  899. +public final class FloodProtectors
  900. +{
  901. +  
  902. +   /**
  903. +    * Use-item flood protector.
  904. +    */
  905. +   private final FloodProtectorAction _useItem;
  906. +   /**
  907. +    * Roll-dice flood protector.
  908. +    */
  909. +   private final FloodProtectorAction _rollDice;
  910. +   /**
  911. +    * Firework flood protector.
  912. +    */
  913. +   private final FloodProtectorAction _firework;
  914. +   /**
  915. +    * Item-pet-summon flood protector.
  916. +    */
  917. +   private final FloodProtectorAction _itemPetSummon;
  918. +   /**
  919. +    * Hero-voice flood protector.
  920. +    */
  921. +   private final FloodProtectorAction _heroVoice;
  922. +   /**
  923. +    * Global-chat flood protector.
  924. +    */
  925. +   private final FloodProtectorAction _globalChat;
  926. +   /**
  927. +    * Subclass flood protector.
  928. +    */
  929. +   private final FloodProtectorAction _subclass;
  930. +   /**
  931. +    * Drop-item flood protector.
  932. +    */
  933. +   private final FloodProtectorAction _dropItem;
  934. +   /**
  935. +    * Server-bypass flood protector.
  936. +    */
  937. +   private final FloodProtectorAction _serverBypass;
  938. +   /**
  939. +    * Multisell flood protector.
  940. +    */
  941. +   private final FloodProtectorAction _multiSell;
  942. +   /**
  943. +    * Transaction flood protector.
  944. +    */
  945. +   private final FloodProtectorAction _transaction;
  946. +  
  947. +   /**
  948. +    * Creates new instance of FloodProtectors.
  949. +    *
  950. +    * @param player
  951. +    *            player for which the collection of flood protectors is being created.
  952. +    */
  953. +   public FloodProtectors(final L2PcInstance player)
  954. +   {
  955. +       super();
  956. +       _useItem = new FloodProtectorAction(player, Config.FLOOD_PROTECTOR_USE_ITEM);
  957. +       _rollDice = new FloodProtectorAction(player, Config.FLOOD_PROTECTOR_ROLL_DICE);
  958. +       _firework = new FloodProtectorAction(player, Config.FLOOD_PROTECTOR_FIREWORK);
  959. +       _itemPetSummon = new FloodProtectorAction(player, Config.FLOOD_PROTECTOR_ITEM_PET_SUMMON);
  960. +       _heroVoice = new FloodProtectorAction(player, Config.FLOOD_PROTECTOR_HERO_VOICE);
  961. +       _globalChat = new FloodProtectorAction(player, Config.FLOOD_PROTECTOR_GLOBAL_CHAT);
  962. +       _subclass = new FloodProtectorAction(player, Config.FLOOD_PROTECTOR_SUBCLASS);
  963. +       _dropItem = new FloodProtectorAction(player, Config.FLOOD_PROTECTOR_DROP_ITEM);
  964. +       _serverBypass = new FloodProtectorAction(player, Config.FLOOD_PROTECTOR_SERVER_BYPASS);
  965. +       _multiSell = new FloodProtectorAction(player, Config.FLOOD_PROTECTOR_MULTISELL);
  966. +       _transaction = new FloodProtectorAction(player, Config.FLOOD_PROTECTOR_TRANSACTION);
  967. +   }
  968. +  
  969. +   /**
  970. +    * Returns {@link #_useItem}.
  971. +    *
  972. +    * @return {@link #_useItem}
  973. +    */
  974. +   public FloodProtectorAction getUseItem()
  975. +   {
  976. +       return _useItem;
  977. +   }
  978. +  
  979. +   /**
  980. +    * Returns {@link #_rollDice}.
  981. +    *
  982. +    * @return {@link #_rollDice}
  983. +    */
  984. +   public FloodProtectorAction getRollDice()
  985. +   {
  986. +       return _rollDice;
  987. +   }
  988. +  
  989. +   /**
  990. +    * Returns {@link #_firework}.
  991. +    *
  992. +    * @return {@link #_firework}
  993. +    */
  994. +   public FloodProtectorAction getFirework()
  995. +   {
  996. +       return _firework;
  997. +   }
  998. +  
  999. +   /**
  1000. +    * Returns {@link #_itemPetSummon}.
  1001. +    *
  1002. +    * @return {@link #_itemPetSummon}
  1003. +    */
  1004. +   public FloodProtectorAction getItemPetSummon()
  1005. +   {
  1006. +       return _itemPetSummon;
  1007. +   }
  1008. +  
  1009. +   /**
  1010. +    * Returns {@link #_heroVoice}.
  1011. +    *
  1012. +    * @return {@link #_heroVoice}
  1013. +    */
  1014. +   public FloodProtectorAction getHeroVoice()
  1015. +   {
  1016. +       return _heroVoice;
  1017. +   }
  1018. +  
  1019. +   /**
  1020. +    * Returns {@link #_globalChat}.
  1021. +    *
  1022. +    * @return {@link #_globalChat}
  1023. +    */
  1024. +   public FloodProtectorAction getGlobalChat()
  1025. +   {
  1026. +       return _globalChat;
  1027. +   }
  1028. +  
  1029. +   /**
  1030. +    * Returns {@link #_subclass}.
  1031. +    *
  1032. +    * @return {@link #_subclass}
  1033. +    */
  1034. +   public FloodProtectorAction getSubclass()
  1035. +   {
  1036. +       return _subclass;
  1037. +   }
  1038. +  
  1039. +   /**
  1040. +    * Returns {@link #_dropItem}.
  1041. +    *
  1042. +    * @return {@link #_dropItem}
  1043. +    */
  1044. +   public FloodProtectorAction getDropItem()
  1045. +   {
  1046. +       return _dropItem;
  1047. +   }
  1048. +  
  1049. +   /**
  1050. +    * Returns {@link #_serverBypass}.
  1051. +    *
  1052. +    * @return {@link #_serverBypass}
  1053. +    */
  1054. +   public FloodProtectorAction getServerBypass()
  1055. +   {
  1056. +       return _serverBypass;
  1057. +   }
  1058. +
  1059. +   /**
  1060. +    * Returns {@link #_multisell}.
  1061. +    *
  1062. +    * @return {@link #_multisell}
  1063. +    */
  1064. +   public FloodProtectorAction getMultiSell()
  1065. +   {
  1066. +       return _multiSell;
  1067. +   }
  1068. +
  1069. +   /**
  1070. +    * Returns {@link #_transaction}.
  1071. +    *
  1072. +    * @return {@link #_transaction}
  1073. +    */
  1074. +   public FloodProtectorAction getTransaction()
  1075. +   {
  1076. +       return _transaction;
  1077. +   }
  1078. +
  1079. +}
  1080. \ No newline at end of file
  1081. Index: java/config/FloodProtector.properties
  1082. ===================================================================
  1083. --- java/config/FloodProtector.properties   (revision 0)
  1084. +++ java/config/FloodProtector.properties   (revision 0)
  1085. @@ -0,0 +1,86 @@
  1086. +# ---------------------------------------------------------------------------
  1087. +# Floodprotector Options
  1088. +# ---------------------------------------------------------------------------
  1089. +# The following settings can be applied to each feature:
  1090. +# Interval - interval in gameserver ticks (1 tick = 100ms) in which only one request is allowed
  1091. +# LogFlooding - whether flooding should be logged (only first ocurrance of flooding and total count of flood requests is logged)
  1092. +# PunishmentLimit - if number of requests within single interval exceeds specified number then the specified punishment is applied (0 = disables punishment feature)
  1093. +# PunishmentType - type of the punishment ('none', 'kick', 'ban', 'jail'), valid only if PunishmentLimit is greater than 0
  1094. +# PunishmentTime - for how many minutes should the player(jail)/account(ban) be punished (0 = forever), valid only for PunishmentType 'jail' or 'ban'
  1095. +
  1096. +# UseItem - item usage flooding
  1097. +FloodProtectorUseItemInterval = 4
  1098. +FloodProtectorUseItemLogFlooding = False
  1099. +FloodProtectorUseItemPunishmentLimit = 0
  1100. +FloodProtectorUseItemPunishmentType = none
  1101. +FloodProtectorUseItemPunishmentTime = 0
  1102. +
  1103. +# RollDice - rolling dice flooding
  1104. +FloodProtectorRollDiceInterval = 42
  1105. +FloodProtectorRollDiceLogFlooding = False
  1106. +FloodProtectorRollDicePunishmentLimit = 0
  1107. +FloodProtectorRollDicePunishmentType = none
  1108. +FloodProtectorRollDicePunishmentTime = 0
  1109. +
  1110. +# Firework - firework flooding
  1111. +FloodProtectorFireworkInterval = 42
  1112. +FloodProtectorFireworkLogFlooding = False
  1113. +FloodProtectorFireworkPunishmentLimit = 0
  1114. +FloodProtectorFireworkPunishmentType = none
  1115. +FloodProtectorFireworkPunishmentTime = 0
  1116. +
  1117. +# ItemPetSummon - item summonning and pet mounting flooding
  1118. +FloodProtectorItemPetSummonInterval = 16
  1119. +FloodProtectorItemPetSummonLogFlooding = False
  1120. +FloodProtectorItemPetSummonPunishmentLimit = 0
  1121. +FloodProtectorItemPetSummonPunishmentType = none
  1122. +FloodProtectorItemPetSummonPunishmentTime = 0
  1123. +
  1124. +# HeroVoice - hero voice flooding
  1125. +FloodProtectorHeroVoiceInterval = 100
  1126. +FloodProtectorHeroVoiceLogFlooding = False
  1127. +FloodProtectorHeroVoicePunishmentLimit = 0
  1128. +FloodProtectorHeroVoicePunishmentType = none
  1129. +FloodProtectorHeroVoicePunishmentTime = 0
  1130. +
  1131. +# GlobalChat - global chat flooding
  1132. +FloodProtectorGlobalChatInterval = 5
  1133. +FloodProtectorGlobalChatLogFlooding = False
  1134. +FloodProtectorGlobalChatPunishmentLimit = 0
  1135. +FloodProtectorGlobalChatPunishmentType = none
  1136. +FloodProtectorGlobalChatPunishmentTime = 0
  1137. +
  1138. +# Subclass - subclass flooding
  1139. +FloodProtectorSubclassInterval = 20
  1140. +FloodProtectorSubclassLogFlooding = False
  1141. +FloodProtectorSubclassPunishmentLimit = 0
  1142. +FloodProtectorSubclassPunishmentType = none
  1143. +FloodProtectorSubclassPunishmentTime = 0
  1144. +
  1145. +# DropItem - drop item flooding
  1146. +FloodProtectorDropItemInterval = 10
  1147. +FloodProtectorDropItemLogFlooding = False
  1148. +FloodProtectorDropItemPunishmentLimit = 0
  1149. +FloodProtectorDropItemPunishmentType = none
  1150. +FloodProtectorDropItemPunishmentTime = 0
  1151. +
  1152. +# ServerBypass - server bypass flooding
  1153. +FloodProtectorServerBypassInterval = 5
  1154. +FloodProtectorServerBypassLogFlooding = False
  1155. +FloodProtectorServerBypassPunishmentLimit = 0
  1156. +FloodProtectorServerBypassPunishmentType = none
  1157. +FloodProtectorServerBypassPunishmentTime = 0
  1158. +
  1159. +# ServerBypass - multisell list request flooding
  1160. +FloodProtectorMultiSellInterval = 1
  1161. +FloodProtectorMultiSellLogFlooding = False
  1162. +FloodProtectorMultiSellPunishmentLimit = 0
  1163. +FloodProtectorMultiSellPunishmentType = none
  1164. +FloodProtectorMultiSellPunishmentTime = 0
  1165. +
  1166. +# All kind of other transactions - to/from pet, private store, warehouse, destroy
  1167. +FloodProtectorTransactionInterval = 10
  1168. +FloodProtectorTransactionLogFlooding = False
  1169. +FloodProtectorTransactionPunishmentLimit = 0
  1170. +FloodProtectorTransactionPunishmentType = none
  1171. +FloodProtectorTransactionPunishmentTime = 0
  1172. \ No newline at end of file
Advertisement
Add Comment
Please, Sign In to add comment