/* * 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 silentium.gameserver.configs; import java.io.File; import java.io.FileInputStream; import java.io.InputStream; import java.util.Properties; import silentium.commons.utils.StringUtil; import silentium.gameserver.utils.FloodProtectorConfig; public final class FProtectorConfig extends ConfigEngine { public static FloodProtectorConfig FLOOD_PROTECTOR_ROLL_DICE; public static FloodProtectorConfig FLOOD_PROTECTOR_HERO_VOICE; public static FloodProtectorConfig FLOOD_PROTECTOR_SUBCLASS; public static FloodProtectorConfig FLOOD_PROTECTOR_DROP_ITEM; public static FloodProtectorConfig FLOOD_PROTECTOR_SERVER_BYPASS; public static FloodProtectorConfig FLOOD_PROTECTOR_MULTISELL; public static FloodProtectorConfig FLOOD_PROTECTOR_MANUFACTURE; public static FloodProtectorConfig FLOOD_PROTECTOR_MANOR; public static FloodProtectorConfig FLOOD_PROTECTOR_SENDMAIL; public static FloodProtectorConfig FLOOD_PROTECTOR_CHARACTER_SELECT; public static void load() { FLOOD_PROTECTOR_ROLL_DICE = new FloodProtectorConfig("RollDiceFloodProtector"); FLOOD_PROTECTOR_HERO_VOICE = new FloodProtectorConfig("HeroVoiceFloodProtector"); FLOOD_PROTECTOR_SUBCLASS = new FloodProtectorConfig("SubclassFloodProtector"); FLOOD_PROTECTOR_DROP_ITEM = new FloodProtectorConfig("DropItemFloodProtector"); FLOOD_PROTECTOR_SERVER_BYPASS = new FloodProtectorConfig("ServerBypassFloodProtector"); FLOOD_PROTECTOR_MULTISELL = new FloodProtectorConfig("MultiSellFloodProtector"); FLOOD_PROTECTOR_MANUFACTURE = new FloodProtectorConfig("ManufactureFloodProtector"); FLOOD_PROTECTOR_MANOR = new FloodProtectorConfig("ManorFloodProtector"); FLOOD_PROTECTOR_SENDMAIL = new FloodProtectorConfig("SendMailFloodProtector"); FLOOD_PROTECTOR_CHARACTER_SELECT = new FloodProtectorConfig("CharacterSelectFloodProtector"); try (InputStream is = new FileInputStream(new File(FLOOD_PROTECTOR_FILE))) { Properties security = new Properties(); security.load(is); loadFloodProtectorConfig(security, FLOOD_PROTECTOR_ROLL_DICE, "RollDice", "42"); loadFloodProtectorConfig(security, FLOOD_PROTECTOR_HERO_VOICE, "HeroVoice", "100"); loadFloodProtectorConfig(security, FLOOD_PROTECTOR_SUBCLASS, "Subclass", "20"); loadFloodProtectorConfig(security, FLOOD_PROTECTOR_DROP_ITEM, "DropItem", "10"); loadFloodProtectorConfig(security, FLOOD_PROTECTOR_SERVER_BYPASS, "ServerBypass", "5"); loadFloodProtectorConfig(security, FLOOD_PROTECTOR_MULTISELL, "MultiSell", "1"); loadFloodProtectorConfig(security, FLOOD_PROTECTOR_MANUFACTURE, "Manufacture", "3"); loadFloodProtectorConfig(security, FLOOD_PROTECTOR_MANOR, "Manor", "30"); loadFloodProtectorConfig(security, FLOOD_PROTECTOR_SENDMAIL, "SendMail", "100"); loadFloodProtectorConfig(security, FLOOD_PROTECTOR_CHARACTER_SELECT, "CharacterSelect", "30"); } catch (Exception e) { log.warn("Server failed to load " + FLOOD_PROTECTOR_FILE + " file."); } } 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")); } }