Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: /trunk/Eclipse/java/config/Custom/FloodProtector.properties.properties
- ===================================================================
- --- /trunk/Eclipse/java/config/Custom/FloodProtector.properties.properties (revision 422)
- +++ /trunk/Eclipse/java/config/Custom/FloodProtector.properties.properties (revision 422)
- @@ -0,0 +1,114 @@
- +###########################################################
- +## Following settings can be applied to each feature: ##
- +###########################################################
- +# Interval - interval in gameserver ticks (10 = 1 second)
- +# LogFlooding - whether flooding should be logged
- +# PunishmentLimit - if number of requests within single interval exceeds (0 - disables punishment feature)
- +# PunishmentType - type of the punishment ('none', 'ban', 'jail'), used only, if PunishmentLimit is greater than zero
- +# PunishmentTime - for how many minutes should be the player/account punished, player is punished in case of 'jail', account is punishedin case of 'ban' (0 = forever)
- +
- +FloodProtectorUseItemInterval = 4
- +FloodProtectorUseItemLogFlooding = False
- +FloodProtectorUseItemPunishmentLimit = 0
- +FloodProtectorUseItemPunishmentType = none
- +FloodProtectorUseItemPunishmentTime = 0
- +
- +FloodProtectorRollDiceInterval = 42
- +FloodProtectorRollDiceLogFlooding = False
- +FloodProtectorRollDicePunishmentLimit = 0
- +FloodProtectorRollDicePunishmentType = none
- +FloodProtectorRollDicePunishmentTime = 0
- +
- +FloodProtectorFireworkInterval = 42
- +FloodProtectorFireworkLogFlooding = False
- +FloodProtectorFireworkPunishmentLimit = 0
- +FloodProtectorFireworkPunishmentType = none
- +FloodProtectorFireworkPunishmentTime = 0
- +
- +FloodProtectorItemPetSummonInterval = 16
- +FloodProtectorItemPetSummonLogFlooding = False
- +FloodProtectorItemPetSummonPunishmentLimit = 0
- +FloodProtectorItemPetSummonPunishmentType = none
- +FloodProtectorItemPetSummonPunishmentTime = 0
- +
- +FloodProtectorHeroVoiceInterval = 100
- +FloodProtectorHeroVoiceLogFlooding = False
- +FloodProtectorHeroVoicePunishmentLimit = 0
- +FloodProtectorHeroVoicePunishmentType = none
- +FloodProtectorHeroVoicePunishmentTime = 0
- +
- +FloodProtectorSubclassInterval = 200
- +FloodProtectorSubclassLogFlooding = False
- +FloodProtectorSubclassPunishmentLimit = 0
- +FloodProtectorSubclassPunishmentType = none
- +FloodProtectorSubclassPunishmentTime = 0
- +
- +FloodProtectorDropItemInterval = 10
- +FloodProtectorDropItemLogFlooding = False
- +FloodProtectorDropItemPunishmentLimit = 0
- +FloodProtectorDropItemPunishmentType = none
- +FloodProtectorDropItemPunishmentTime = 0
- +
- +FloodProtectorServerBypassInterval = 5
- +FloodProtectorServerBypassLogFlooding = False
- +FloodProtectorServerBypassPunishmentLimit = 0
- +FloodProtectorServerBypassPunishmentType = none
- +FloodProtectorServerBypassPunishmentTime = 0
- +
- +FloodProtectorUnkPacketsInterval = 5
- +FloodProtectorUnkPacketsLogFlooding = False
- +FloodProtectorUnkPacketsPunishmentLimit = 0
- +FloodProtectorUnkPacketsPunishmentType = none
- +FloodProtectorUnkPacketsPunishmentTime = 0
- +
- +FloodProtectorBufferInterval = 5
- +FloodProtectorBufferLogFlooding = False
- +FloodProtectorBufferPunishmentLimit = 0
- +FloodProtectorBufferPunishmentType = none
- +FloodProtectorBufferPunishmentTime = 0
- +
- +FloodProtectorCraftInterval = 5
- +FloodProtectorCraftLogFlooding = False
- +FloodProtectorCraftPunishmentLimit = 0
- +FloodProtectorCraftPunishmentType = none
- +FloodProtectorCraftPunishmentTime = 0
- +
- +FloodProtectorMultisellInterval = 30
- +FloodProtectorMultisellLogFlooding = False
- +FloodProtectorMultisellPunishmentLimit = 0
- +FloodProtectorMultisellPunishmentType = none
- +FloodProtectorMultisellPunishmentTime = 0
- +
- +FloodProtectorBankingSystemInterval = 30
- +FloodProtectorBankingSystemLogFlooding = False
- +FloodProtectorBankingSystemPunishmentLimit = 0
- +FloodProtectorBankingSystemPunishmentType = none
- +FloodProtectorBankingSystemPunishmentTime = 0
- +
- +FloodProtectorWerehouseInterval = 10
- +FloodProtectorWerehouseLogFlooding = False
- +FloodProtectorWerehousePunishmentLimit = 0
- +FloodProtectorWerehousePunishmentType = none
- +FloodProtectorWerehousePunishmentTime = 0
- +
- +FloodProtectorMiscInterval = 10
- +FloodProtectorMiscLogFlooding = False
- +FloodProtectorMiscPunishmentLimit = 0
- +FloodProtectorMiscPunishmentType = none
- +FloodProtectorMiscPunishmentTime = 0
- +
- +FloodProtectorChatInterval = 10
- +FloodProtectorChatLogFlooding = False
- +FloodProtectorChatPunishmentLimit = 0
- +FloodProtectorChatPunishmentType = none
- +FloodProtectorChatPunishmentTime = 0
- +
- +FloodProtectorGlobalInterval = 10
- +FloodProtectorGlobalLogFlooding = False
- +FloodProtectorGlobalPunishmentLimit = 0
- +FloodProtectorGlobalPunishmentType = none
- +FloodProtectorGlobalPunishmentTime = 0
- Index: /trunk/Eclipse/java/net/sf/l2j/Config.java
- ===================================================================
- --- /trunk/Eclipse/java/net/sf/l2j/Config.java (revision 421)
- +++ /trunk/Eclipse/java/net/sf/l2j/Config.java (revision 422)
- @@ -27,4 +27,7 @@
- import javolution.util.FastList;
- import javolution.util.FastMap;
- +
- +import net.sf.l2j.gameserver.util.FloodProtectorConfig;
- +import net.sf.l2j.gameserver.util.StringUtil;
- /**
- @@ -90,4 +93,23 @@
- public static String SERVER_BUILD_DATE;
- public static String DATAPACK_VERSION;
- +
- + public static final FloodProtectorConfig FLOOD_PROTECTOR_USE_ITEM = new FloodProtectorConfig("UseItemFloodProtector");
- + public static final FloodProtectorConfig FLOOD_PROTECTOR_ROLL_DICE = new FloodProtectorConfig("RollDiceFloodProtector");
- + public static final FloodProtectorConfig FLOOD_PROTECTOR_FIREWORK = new FloodProtectorConfig("FireworkFloodProtector");
- + public static final FloodProtectorConfig FLOOD_PROTECTOR_ITEM_PET_SUMMON = new FloodProtectorConfig("ItemPetSummonFloodProtector");
- + public static final FloodProtectorConfig FLOOD_PROTECTOR_HERO_VOICE = new FloodProtectorConfig("HeroVoiceFloodProtector");
- + public static final FloodProtectorConfig FLOOD_PROTECTOR_SUBCLASS = new FloodProtectorConfig("SubclassFloodProtector");
- + public static final FloodProtectorConfig FLOOD_PROTECTOR_DROP_ITEM = new FloodProtectorConfig("DropItemFloodProtector");
- + public static final FloodProtectorConfig FLOOD_PROTECTOR_SERVER_BYPASS = new FloodProtectorConfig("ServerBypassFloodProtector");
- + public static final FloodProtectorConfig FLOOD_PROTECTOR_UNK_PACKETS = new FloodProtectorConfig("UnkPacketsFloodProtector");
- + public static final FloodProtectorConfig FLOOD_PROTECTOR_BUFFER = new FloodProtectorConfig("BufferFloodProtector");
- + public static final FloodProtectorConfig FLOOD_PROTECTOR_CRAFT = new FloodProtectorConfig("CraftFloodProtector");
- + public static final FloodProtectorConfig FLOOD_PROTECTOR_MULTISELL = new FloodProtectorConfig("MultiSellFloodProtector");
- + public static final FloodProtectorConfig FLOOD_PROTECTOR_BANKING_SYSTEM = new FloodProtectorConfig("BankingSystemFloodProtector");
- + public static final FloodProtectorConfig FLOOD_PROTECTOR_WEREHOUSE = new FloodProtectorConfig("WerehouseFloodProtector");
- + public static final FloodProtectorConfig FLOOD_PROTECTOR_MISC = new FloodProtectorConfig("MiscFloodProtector");
- + public static final FloodProtectorConfig FLOOD_PROTECTOR_CHAT = new FloodProtectorConfig("ChatFloodProtector");
- + public static final FloodProtectorConfig FLOOD_PROTECTOR_GLOBAL = new FloodProtectorConfig("GlobalFloodProtector");
- /** Start AltSettings.properties */
- // Auto loots configs
- @@ -1682,7 +1704,6 @@
- FloodProtector.load(is);
- is.close();
- -
- - // Flood Tipos
- -
- + loadFloodProtectorConfigs(FloodProtector);
- + _log.info("# " + FLOODPROTECTOR_CONFIG_FILE + " Sucessfully LOADED #");
- }
- catch (Exception e)
- @@ -1691,5 +1712,4 @@
- throw new Error("Failed to Load " + FLOODPROTECTOR_CONFIG_FILE + " File.");
- }
- - // access levels
- try
- {
- @@ -4019,4 +4039,33 @@
- return true;
- }
- +
- + private static void loadFloodProtectorConfigs(final Properties properties)
- + {
- + loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_USE_ITEM, "UseItem", "4");
- + loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_ROLL_DICE, "RollDice", "42");
- + loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_FIREWORK, "Firework", "42");
- + loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_ITEM_PET_SUMMON, "ItemPetSummon", "16");
- + loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_HERO_VOICE, "HeroVoice", "100");
- + loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_SUBCLASS, "Subclass", "20");
- + loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_DROP_ITEM, "DropItem", "10");
- + loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_SERVER_BYPASS, "ServerBypass", "5");
- + loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_UNK_PACKETS, "UnkPackets", "5");
- + loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_BUFFER, "Buffer", "5");
- + loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_CRAFT, "Craft", "10");
- + loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_MULTISELL, "MultiSell", "30");
- + loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_WEREHOUSE, "Werehouse", "10");
- + loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_MISC, "Misc", "10");
- + loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_CHAT, "Chat", "10");
- + loadFloodProtectorConfig(properties, FLOOD_PROTECTOR_GLOBAL, "Global", "500");
- + }
- +
- + private static void loadFloodProtectorConfig(final Properties properties, final FloodProtectorConfig config, final String configString, final String defaultInterval)
- + {
- + config.FLOOD_PROTECTION_INTERVAL = Integer.parseInt(properties.getProperty(StringUtil.concat("FloodProtector", configString, "Interval"), defaultInterval));
- + config.LOG_FLOODING = Boolean.parseBoolean(properties.getProperty(StringUtil.concat("FloodProtector", configString, "LogFlooding"), "False"));
- + config.PUNISHMENT_LIMIT = Integer.parseInt(properties.getProperty(StringUtil.concat("FloodProtector", configString, "PunishmentLimit"), "0"));
- + config.PUNISHMENT_TYPE = properties.getProperty(StringUtil.concat("FloodProtector", configString, "PunishmentType"), "none");
- + config.PUNISHMENT_TIME = Integer.parseInt(properties.getProperty(StringUtil.concat("FloodProtector", configString, "PunishmentTime"), "0"));
- + }
- /*
- Index: /trunk/Eclipse/java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
- ===================================================================
- --- /trunk/Eclipse/java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (revision 421)
- +++ /trunk/Eclipse/java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (revision 422)
- @@ -201,4 +201,5 @@
- import net.sf.l2j.gameserver.templates.L2WeaponType;
- import net.sf.l2j.gameserver.util.Broadcast;
- +import net.sf.l2j.gameserver.util.FloodProtectors;
- import net.sf.l2j.util.Point3D;
- import net.sf.l2j.util.Rnd;
- @@ -382,4 +383,35 @@
- private long _jailTimer = 0;
- private ScheduledFuture<?> _jailTask;
- +
- + /** PunishLevel by Danielmwx **/
- + private PunishLevel _punishLevel = PunishLevel.NONE; // TODO Clean up, delete old methods and add this one...
- + private long _punishTimer = 0;
- + private ScheduledFuture<?> _punishTask;
- +
- + public enum PunishLevel
- + {
- + NONE(0, ""), CHAT(1, "chat banned"), JAIL(2, "jailed"), CHAR(3, "banned"), ACC(4, "banned");
- + private int punValue;
- + private String punString;
- +
- + PunishLevel(int value, String string)
- + {
- + punValue = value;
- + punString = string;
- + }
- +
- + public int value()
- + {
- + return punValue;
- + }
- +
- + public String string()
- + {
- + return punString;
- + }
- + }
- +
- + private final FloodProtectors _floodProtectors = new FloodProtectors(this);
- +
- /** character away mode **/
- private boolean _isAway = false;
- @@ -9174,4 +9206,16 @@
- }
- + public L2Object _saymode = null;
- +
- + public L2Object getSayMode()
- + {
- + return _saymode;
- + }
- +
- + public void setSayMode(L2Object say)
- + {
- + _saymode = say;
- + }
- +
- public boolean isChatBanned()
- {
- @@ -12200,3 +12244,234 @@
- _gatesRequest.setTarget(null);
- }
- + /**
- + * returns punishment level of player
- + *
- + * @return
- + */
- + public PunishLevel getPunishLevel()
- + {
- + return _punishLevel;
- + }
- +
- + /**
- + * @return True if player is jailed
- + */
- + @Deprecated
- + public boolean isInJail_()
- + {
- + return _punishLevel == PunishLevel.JAIL;
- + }
- +
- + // TODO clean up please...
- + /**
- + * @return True if player is chat banned
- + */
- + @Deprecated
- + public boolean isChatBanned_()
- + {
- + return _punishLevel == PunishLevel.CHAT;
- + }
- +
- + public void setPunishLevel(int state)
- + {
- + switch (state)
- + {
- + case 0:
- + {
- + _punishLevel = PunishLevel.NONE;
- + break;
- + }
- + case 1:
- + {
- + _punishLevel = PunishLevel.CHAT;
- + break;
- + }
- + case 2:
- + {
- + _punishLevel = PunishLevel.JAIL;
- + break;
- + }
- + case 3:
- + {
- + _punishLevel = PunishLevel.CHAR;
- + break;
- + }
- + case 4:
- + {
- + _punishLevel = PunishLevel.ACC;
- + break;
- + }
- + }
- + }
- +
- + /**
- + * Sets punish level for player based on delay
- + *
- + * @param state
- + * @param delayInMinutes
- + * 0 - Indefinite
- + */
- + public void setPunishLevel(PunishLevel state, int delayInMinutes)
- + {
- + long delayInMilliseconds = delayInMinutes * 60000L;
- + switch (state)
- + {
- + case NONE: // Remove Punishments
- + {
- + switch (_punishLevel)
- + {
- + case CHAT:
- + {
- + _punishLevel = state;
- + stopPunishTask(true);
- + sendPacket(new EtcStatusUpdate(this));
- + sendMessage("Your Chat ban has been lifted");
- + break;
- + }
- + case JAIL:
- + {
- + _punishLevel = state;
- + // Open a Html message to inform the player
- + NpcHtmlMessage htmlMsg = new NpcHtmlMessage(0);
- + String jailInfos = HtmCache.getInstance().getHtm("data/html/jail_out.htm");
- + if (jailInfos != null)
- + htmlMsg.setHtml(jailInfos);
- + else
- + htmlMsg.setHtml("<html><body>You are free for now, respect server rules!</body></html>");
- + sendPacket(htmlMsg);
- + stopPunishTask(true);
- + teleToLocation(17836, 170178, -3507, true); // Floran
- + break;
- + }
- + }
- + break;
- + }
- + case CHAT: // Chat Ban
- + {
- + _punishLevel = state;
- + _punishTimer = 0;
- + sendPacket(new EtcStatusUpdate(this));
- + // Remove the task if any
- + stopPunishTask(false);
- + if (delayInMinutes > 0)
- + {
- + _punishTimer = delayInMilliseconds;
- + // start the countdown
- + _punishTask = ThreadPoolManager.getInstance().scheduleGeneral(new PunishTask(this), _punishTimer);
- + sendMessage("You are chat banned for " + delayInMinutes + " minutes.");
- + }
- + else
- + sendMessage("You have been chat banned");
- + break;
- + }
- + case JAIL: // Jail Player
- + {
- + _punishLevel = state;
- + _punishTimer = 0;
- + // Remove the task if any
- + stopPunishTask(false);
- + if (delayInMinutes > 0)
- + {
- + _punishTimer = delayInMilliseconds;
- + // start the countdown
- + _punishTask = ThreadPoolManager.getInstance().scheduleGeneral(new PunishTask(this), _punishTimer);
- + sendMessage("You are in jail for " + delayInMinutes + " minutes.");
- + }
- + // Open a Html message to inform the player
- + NpcHtmlMessage htmlMsg = new NpcHtmlMessage(0);
- + String jailInfos = HtmCache.getInstance().getHtm("data/html/jail_in.htm");
- + if (jailInfos != null)
- + htmlMsg.setHtml(jailInfos);
- + else
- + htmlMsg.setHtml("<html><body>You have been put in jail by an admin.</body></html>");
- + sendPacket(htmlMsg);
- + setInstanceId(0);
- + teleToLocation(-114356, -249645, -2984, false); // Jail
- + break;
- + }
- + case CHAR: // Ban Character
- + case ACC: // Ban Account
- + default:
- + {
- + _punishLevel = state;
- + break;
- + }
- + }
- + // store in database
- + storeCharBase();
- + }
- +
- + public long getPunishTimer()
- + {
- + return _punishTimer;
- + }
- +
- + public void setPunishTimer(long time)
- + {
- + _punishTimer = time;
- + }
- +
- + @Deprecated
- + @SuppressWarnings("unused")
- + private void updatePunishState()// TODO Next clean up this shood be active
- + {
- + if (getPunishLevel() != PunishLevel.NONE)
- + {
- + // If punish timer exists, restart punishtask.
- + if (_punishTimer > 0)
- + {
- + _punishTask = ThreadPoolManager.getInstance().scheduleGeneral(new PunishTask(this), _punishTimer);
- + sendMessage("You are still " + getPunishLevel().string() + " for " + Math.round(_punishTimer / 60000) + " minutes.");
- + }
- + if (getPunishLevel() == PunishLevel.JAIL)
- + {
- + // If player escaped, put him back in jail
- + if (!isInsideZone(ZONE_JAIL))
- + teleToLocation(-114356, -249645, -2984, true);
- + }
- + }
- + }
- +
- + public void stopPunishTask(boolean save)
- + {
- + if (_punishTask != null)
- + {
- + if (save)
- + {
- + long delay = _punishTask.getDelay(TimeUnit.MILLISECONDS);
- + if (delay < 0)
- + delay = 0;
- + setPunishTimer(delay);
- + }
- + _punishTask.cancel(false);
- + _punishTask = null;
- + }
- + }
- +
- + private class PunishTask implements Runnable
- + {
- + L2PcInstance _player;
- + protected long _startedAt;
- +
- + protected PunishTask(L2PcInstance player)
- + {
- + _player = player;
- + _startedAt = System.currentTimeMillis();
- + }
- +
- + public void run()
- + {
- + _player.setPunishLevel(PunishLevel.NONE, 0);
- + }
- + }
- +
- + public FloodProtectors getFloodProtectors()
- + {
- + return _floodProtectors;
- + }
- +
- + public void systemSendMessage(SystemMessageId id)
- + {
- + sendPacket(new SystemMessage(id));
- + }
- }
- Index: /trunk/Eclipse/java/net/sf/l2j/gameserver/util/FloodProtectorAction.java
- ===================================================================
- --- /trunk/Eclipse/java/net/sf/l2j/gameserver/util/FloodProtectorAction.java (revision 422)
- +++ /trunk/Eclipse/java/net/sf/l2j/gameserver/util/FloodProtectorAction.java (revision 422)
- @@ -0,0 +1,145 @@
- +/*
- + * This program is free software: you can redistribute it and/or modify it under
- + * the terms of the GNU General Public License as published by the Free Software
- + * Foundation, either version 3 of the License, or (at your option) any later
- + * version.
- + *
- + * This program is distributed in the hope that it will be useful, but WITHOUT
- + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- + * details.
- + *
- + * You should have received a copy of the GNU General Public License along with
- + * this program. If not, see <http://www.gnu.org/licenses/>.
- + */
- +package net.sf.l2j.gameserver.util;
- +
- +import java.util.concurrent.atomic.AtomicInteger;
- +import java.util.logging.Level;
- +import java.util.logging.Logger;
- +
- +import net.sf.l2j.gameserver.GameTimeController;
- +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +
- +public final class FloodProtectorAction
- +{
- + /**
- + * Logger
- + */
- + private static final Logger _log = Logger.getLogger(FloodProtectorAction.class.getName());
- + /**
- + * Player for this instance of flood protector.
- + */
- + private final L2PcInstance _player;
- + /**
- + * Configuration of this instance of flood protector.
- + */
- + private final FloodProtectorConfig _config;
- + /**
- + * Next game tick when new request is allowed.
- + */
- + private volatile int _nextGameTick = GameTimeController.getGameTicks();
- + /**
- + * Request counter.
- + */
- + private AtomicInteger _count = new AtomicInteger(0);
- + /**
- + * Flag determining whether exceeding request has been logged.
- + */
- + private boolean _logged;
- + /**
- + * Flag determining whether punishment application is in progress so that we do not apply punisment multiple times (flooding).
- + */
- + private volatile boolean _punishmentInProgress;
- +
- + /**
- + * Creates new instance of FloodProtectorAction.
- + *
- + * @param player
- + * player for which flood protection is being created
- + * @param config
- + * flood protector configuration
- + */
- + public FloodProtectorAction(final L2PcInstance player, final FloodProtectorConfig config)
- + {
- + super();
- + _player = player;
- + _config = config;
- + }
- +
- + /**
- + * Checks whether the request is flood protected or not.
- + *
- + * @param command
- + * command issued or short command description
- + * @return true if action is allowed, otherwise false
- + */
- + public boolean tryPerformAction(final String command)
- + {
- + final int curTick = GameTimeController.getGameTicks();
- + if (curTick < _nextGameTick || _punishmentInProgress)
- + {
- + if (_config.LOG_FLOODING && !_logged && _log.isLoggable(Level.WARNING))
- + {
- + _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"));
- + _logged = true;
- + }
- + _count.incrementAndGet();
- + if (!_punishmentInProgress && _config.PUNISHMENT_LIMIT > 0 && _count.get() > _config.PUNISHMENT_LIMIT && _config.PUNISHMENT_TYPE != null)
- + {
- + _punishmentInProgress = true;
- + if ("ban".equals(_config.PUNISHMENT_TYPE))
- + {
- + banAccount();
- + }
- + else if ("jail".equals(_config.PUNISHMENT_TYPE))
- + {
- + jailChar();
- + }
- + _punishmentInProgress = false;
- + }
- + return false;
- + }
- + if (_count.get() > 0)
- + {
- + if (_config.LOG_FLOODING && _log.isLoggable(Level.WARNING))
- + {
- + _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]"));
- + }
- + }
- + _nextGameTick = curTick + _config.FLOOD_PROTECTION_INTERVAL;
- + _logged = false;
- + _count.set(0);
- + return true;
- + }
- +
- + /**
- + * Bans char account and logs out the char.
- + */
- + private void banAccount()
- + {
- + _player.setPunishLevel(L2PcInstance.PunishLevel.ACC, _config.PUNISHMENT_TIME);
- + if (_log.isLoggable(Level.WARNING))
- + {
- + _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"));
- + }
- + _player.logout();
- + }
- +
- + /**
- + * Jails char.
- + */
- + private void jailChar()
- + {
- + _player.setPunishLevel(L2PcInstance.PunishLevel.JAIL, _config.PUNISHMENT_TIME);
- + if (_log.isLoggable(Level.WARNING))
- + {
- + _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"));
- + }
- + }
- +}
- Index: /trunk/Eclipse/java/net/sf/l2j/gameserver/util/FloodProtectors.java
- ===================================================================
- --- /trunk/Eclipse/java/net/sf/l2j/gameserver/util/FloodProtectors.java
- +++ /trunk/Eclipse/java/net/sf/l2j/gameserver/util/FloodProtectors.java
- @@ -0,0 +1,293 @@
- +/*
- + * This program is free software: you can redistribute it and/or modify it under
- + * the terms of the GNU General Public License as published by the Free Software
- + * Foundation, either version 3 of the License, or (at your option) any later
- + * version.
- + *
- + * This program is distributed in the hope that it will be useful, but WITHOUT
- + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- + * details.
- + *
- + * You should have received a copy of the GNU General Public License along with
- + * this program. If not, see <http://www.gnu.org/licenses/>.
- + */
- +package net.sf.l2j.gameserver.util;
- +
- +import net.sf.l2j.Config;
- +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +
- +public final class FloodProtectors
- +{
- + /**
- + * Use-item flood protector.
- + */
- + private final FloodProtectorAction _useItem;
- + /**
- + * Roll-dice flood protector.
- + */
- + private final FloodProtectorAction _rollDice;
- + /**
- + * Firework flood protector.
- + */
- + private final FloodProtectorAction _firework;
- + /**
- + * Item-pet-summon flood protector.
- + */
- + private final FloodProtectorAction _itemPetSummon;
- + /**
- + * Hero-voice flood protector.
- + */
- + private final FloodProtectorAction _heroVoice;
- + /**
- + * Subclass flood protector.
- + */
- + private final FloodProtectorAction _subclass;
- + /**
- + * Drop-item flood protector.
- + */
- + private final FloodProtectorAction _dropItem;
- + /**
- + * Wnk flood protector.
- + */
- + private final FloodProtectorAction _wnk;
- + /**
- + * Server-bypass flood protector.
- + */
- + private final FloodProtectorAction _serverBypass;
- + /**
- + * Buffer flood protector.
- + */
- + private final FloodProtectorAction _buffer;
- + /**
- + * Craft flood protector.
- + */
- + private final FloodProtectorAction _craft;
- + /**
- + * Multisell flood protector.
- + */
- + private final FloodProtectorAction _multisell;
- + /**
- + * Banking System Flood Protector.
- + */
- + private final FloodProtectorAction _BankingSystem;
- + /**
- + * Werehouse Flood Protector.
- + */
- + private final FloodProtectorAction _werehouse;
- + /**
- + * Misc Flood Protector.
- + */
- + private final FloodProtectorAction _misc;
- + /**
- + * Chat Flood Protector.
- + */
- + private final FloodProtectorAction _chat;
- + /**
- + * Chat Global Flood Protector.
- + */
- + private final FloodProtectorAction _global;
- +
- + /**
- + * Creates new instance of FloodProtectors.
- + *
- + * @param player
- + * player for which the collection of flood protectors is being created.
- + */
- + public FloodProtectors(final L2PcInstance player)
- + {
- + super();
- + _useItem = new FloodProtectorAction(player, Config.FLOOD_PROTECTOR_USE_ITEM);
- + _rollDice = new FloodProtectorAction(player, Config.FLOOD_PROTECTOR_ROLL_DICE);
- + _firework = new FloodProtectorAction(player, Config.FLOOD_PROTECTOR_FIREWORK);
- + _itemPetSummon = new FloodProtectorAction(player, Config.FLOOD_PROTECTOR_ITEM_PET_SUMMON);
- + _heroVoice = new FloodProtectorAction(player, Config.FLOOD_PROTECTOR_HERO_VOICE);
- + _subclass = new FloodProtectorAction(player, Config.FLOOD_PROTECTOR_SUBCLASS);
- + _dropItem = new FloodProtectorAction(player, Config.FLOOD_PROTECTOR_DROP_ITEM);
- + _wnk = new FloodProtectorAction(player, Config.FLOOD_PROTECTOR_UNK_PACKETS);
- + _serverBypass = new FloodProtectorAction(player, Config.FLOOD_PROTECTOR_SERVER_BYPASS);
- + _buffer = new FloodProtectorAction(player, Config.FLOOD_PROTECTOR_BUFFER);
- + _craft = new FloodProtectorAction(player, Config.FLOOD_PROTECTOR_CRAFT);
- + _multisell = new FloodProtectorAction(player, Config.FLOOD_PROTECTOR_MULTISELL);
- + _BankingSystem = new FloodProtectorAction(player, Config.FLOOD_PROTECTOR_BANKING_SYSTEM);
- + _werehouse = new FloodProtectorAction(player, Config.FLOOD_PROTECTOR_WEREHOUSE);
- + _misc = new FloodProtectorAction(player, Config.FLOOD_PROTECTOR_MISC);
- + _chat = new FloodProtectorAction(player, Config.FLOOD_PROTECTOR_CHAT);
- + _global = new FloodProtectorAction(player, Config.FLOOD_PROTECTOR_GLOBAL);
- + }
- +
- + /**
- + * Returns {@link #_useItem}.
- + *
- + * @return {@link #_useItem}
- + */
- + public FloodProtectorAction getUseItem()
- + {
- + return _useItem;
- + }
- +
- + /**
- + * Returns {@link #_rollDice}.
- + *
- + * @return {@link #_rollDice}
- + */
- + public FloodProtectorAction getRollDice()
- + {
- + return _rollDice;
- + }
- +
- + /**
- + * Returns {@link #_firework}.
- + *
- + * @return {@link #_firework}
- + */
- + public FloodProtectorAction getFirework()
- + {
- + return _firework;
- + }
- +
- + /**
- + * Returns {@link #_itemPetSummon}.
- + *
- + * @return {@link #_itemPetSummon}
- + */
- + public FloodProtectorAction getItemPetSummon()
- + {
- + return _itemPetSummon;
- + }
- +
- + /**
- + * Returns {@link #_heroVoice}.
- + *
- + * @return {@link #_heroVoice}
- + */
- + public FloodProtectorAction getHeroVoice()
- + {
- + return _heroVoice;
- + }
- +
- + /**
- + * Returns {@link #_subclass}.
- + *
- + * @return {@link #_subclass}
- + */
- + public FloodProtectorAction getSubclass()
- + {
- + return _subclass;
- + }
- +
- + /**
- + * Returns {@link #_dropItem}.
- + *
- + * @return {@link #_dropItem}
- + */
- + public FloodProtectorAction getDropItem()
- + {
- + return _dropItem;
- + }
- +
- + /**
- + * Returns {@link #_wnk}.
- + *
- + * @return {@link #_wnk}
- + */
- + public FloodProtectorAction getWnk()
- + {
- + return _wnk;
- + }
- +
- + /**
- + * Returns {@link #_serverBypass}.
- + *
- + * @return {@link #_serverBypass}
- + */
- + public FloodProtectorAction getServerBypass()
- + {
- + return _serverBypass;
- + }
- +
- + /**
- + * Returns {@link #_buffer}.
- + *
- + * @return {@link #_buffer}
- + */
- + public FloodProtectorAction getBuffer()
- + {
- + return _buffer;
- + }
- +
- + /**
- + * Returns {@link #_craft}.
- + *
- + * @return {@link #_craft}
- + */
- + public FloodProtectorAction getCraft()
- + {
- + return _craft;
- + }
- +
- + /**
- + * Returns {@link #_multisell}.
- + *
- + * @return {@link #_multisell}
- + */
- + public FloodProtectorAction getMultisell()
- + {
- + return _multisell;
- + }
- +
- + /**
- + * Returns {@link #_BankingSystem}.
- + *
- + * @return {@link #_BankingSystem}
- + */
- + public FloodProtectorAction getBankingSystem()
- + {
- + return _BankingSystem;
- + }
- +
- + /**
- + * Returns {@link #_werehouse}.
- + *
- + * @return {@link #_werehouse}
- + */
- + public FloodProtectorAction getWerehouse()
- + {
- + return _werehouse;
- + }
- +
- + /**
- + * Returns {@link #_misc}.
- + *
- + * @return {@link #_misc}
- + */
- + public FloodProtectorAction getMisc()
- + {
- + return _misc;
- + }
- +
- + /**
- + * Returns {@link #_chat}.
- + *
- + * @return {@link #_chat}
- + */
- + public FloodProtectorAction getChat()
- + {
- + return _chat;
- + }
- +
- + /**
- + * Returns {@link #_global}.
- + *
- + * @return {@link #_global}
- + */
- + public FloodProtectorAction getGlobal()
- + {
- + return _global;
- + }
- +}
- Index: /trunk/Eclipse/java/net/sf/l2j/gameserver/util/FloodProtectorConfig.java
- ===================================================================
- --- /trunk/Eclipse/java/net/sf/l2j/gameserver/util/FloodProtectorConfig.java
- +++ /trunk/Eclipse/java/net/sf/l2j/gameserver/util/FloodProtectorConfig.java
- @@ -0,0 +1,60 @@
- +/*
- + * This program is free software: you can redistribute it and/or modify it under
- + * the terms of the GNU General Public License as published by the Free Software
- + * Foundation, either version 3 of the License, or (at your option) any later
- + * version.
- + *
- + * This program is distributed in the hope that it will be useful, but WITHOUT
- + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- + * details.
- + *
- + * You should have received a copy of the GNU General Public License along with
- + * this program. If not, see <http://www.gnu.org/licenses/>.
- + */
- +package net.sf.l2j.gameserver.util;
- +
- +public final class FloodProtectorConfig
- +{
- + /**
- + * Type used for identification of logging output.
- + */
- + public String FLOOD_PROTECTOR_TYPE;
- + /**
- + * Flood protection interval in game ticks.
- + */
- + public int FLOOD_PROTECTION_INTERVAL;
- + /**
- + * Whether flooding should be logged.
- + */
- + public boolean LOG_FLOODING;
- + /**
- + * If specified punishment limit is exceeded, punishment is applied.
- + */
- + public int PUNISHMENT_LIMIT;
- + /**
- + * Punishment type. Either 'none', 'ban' or 'jail'.
- + */
- + public String PUNISHMENT_TYPE;
- + /**
- + * For how long should the char/account be punished.
- + */
- + public int PUNISHMENT_TIME;
- +
- + /**
- + * Creates new instance of FloodProtectorConfig.
- + *
- + * @param floodProtectorType
- + * {@link #FLOOD_PROTECTOR_TYPE}
- + */
- + public FloodProtectorConfig(final String floodProtectorType)
- + {
- + super();
- + FLOOD_PROTECTOR_TYPE = floodProtectorType;
- + }
- +}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement