diff --git a/make_jar.jardesc b/make_jar.jardesc index 169440d..0bb0d0b 100644 --- a/make_jar.jardesc +++ b/make_jar.jardesc @@ -1,6 +1,6 @@ - + diff --git a/resources/config.yml b/resources/config.yml index 60275ed..d97b7ac 100644 --- a/resources/config.yml +++ b/resources/config.yml @@ -1,8 +1,8 @@ database: host: localhost port: 3306 - base: pandacraft user: pandacraft + base: pandacraft pass: HYtKq92pfx9ucwzq @@ -37,4 +37,36 @@ cubos: cleaner: - users_cleaner_group: default + usersCleanerGroup: default + + + +autoMessages: + playerInterval: 600 + defaultInterval: 150 + + +serverMessages: + defaultColor: '&e' + prefix: '&e[&fPandacraft&e]' + + + + +pingMOTD: '&7Serveur &fPandacraft&7, &eVenez nous rejoindre :D\n&bCreatif&7, &6Survie&7 et &4Faction/PVP&7 !' + + + +entitySpam: +# séparé par des point-virgules + worlds: creative + limitPerChunk: 50 + + +networkAPI: + pass: rgrgaethejtrvvzh47 + + + + + diff --git a/resources/plugin.yml b/resources/plugin.yml index 18dd80f..ef277a3 100644 --- a/resources/plugin.yml +++ b/resources/plugin.yml @@ -1,6 +1,6 @@ name: PandacraftUtils main: net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils -version: 3.11 +version: 3.12 diff --git a/src/net/mc_pandacraft/java/plugin/pandacraftutils/PandacraftUtils.java b/src/net/mc_pandacraft/java/plugin/pandacraftutils/PandacraftUtils.java index d135192..580657b 100644 --- a/src/net/mc_pandacraft/java/plugin/pandacraftutils/PandacraftUtils.java +++ b/src/net/mc_pandacraft/java/plugin/pandacraftutils/PandacraftUtils.java @@ -1,6 +1,7 @@ package net.mc_pandacraft.java.plugin.pandacraftutils; import net.mc_pandacraft.java.plugin.pandacraftutils.commands.PandacraftUtilsCommandsManager; +import net.mc_pandacraft.java.plugin.pandacraftutils.config.ConfigManager; import net.mc_pandacraft.java.plugin.pandacraftutils.modules.AutoMessagesManager; import net.mc_pandacraft.java.plugin.pandacraftutils.modules.CalculatorManager; import net.mc_pandacraft.java.plugin.pandacraftutils.modules.CommandAliasManager; @@ -22,6 +23,7 @@ import net.mc_pandacraft.java.plugin.pandacraftutils.modules.staff.StaffQueueMan import net.mc_pandacraft.java.plugin.pandacraftutils.network_api.NetworkAPI; import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayer; import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayerManager; +import net.mc_pandacraft.java.plugin.pandacraftutils.players.PlayerDataCleaner; import org.bukkit.plugin.java.JavaPlugin; @@ -171,7 +173,7 @@ public class PandacraftUtils extends JavaPlugin { throw new IllegalArgumentException("Un message doit être défini"); if (prefix) - message = ConfigManager.getInstance().ServerMessages_prefix + message; + message = ConfigManager.getInstance().defaultConfig.serverMessages_prefix + message; for (OnlinePlayer op : OnlinePlayerManager.getAll()) diff --git a/src/net/mc_pandacraft/java/plugin/pandacraftutils/commands/CommandAdmin.java b/src/net/mc_pandacraft/java/plugin/pandacraftutils/commands/CommandAdmin.java index 028f4dd..6cd5d78 100644 --- a/src/net/mc_pandacraft/java/plugin/pandacraftutils/commands/CommandAdmin.java +++ b/src/net/mc_pandacraft/java/plugin/pandacraftutils/commands/CommandAdmin.java @@ -1,6 +1,6 @@ package net.mc_pandacraft.java.plugin.pandacraftutils.commands; -import net.mc_pandacraft.java.plugin.pandacraftutils.ConfigManager; +import net.mc_pandacraft.java.plugin.pandacraftutils.config.ConfigManager; import net.mc_pandacraft.java.plugin.pandacraftutils.network_api.NetworkAPI; import net.mc_pandacraft.java.plugin.pandacraftutils.network_api.NetworkAPIListener; diff --git a/src/net/mc_pandacraft/java/plugin/pandacraftutils/commands/CommandCubo.java b/src/net/mc_pandacraft/java/plugin/pandacraftutils/commands/CommandCubo.java index efbbb34..8d77e39 100644 --- a/src/net/mc_pandacraft/java/plugin/pandacraftutils/commands/CommandCubo.java +++ b/src/net/mc_pandacraft/java/plugin/pandacraftutils/commands/CommandCubo.java @@ -6,7 +6,7 @@ import java.util.List; import java.util.Random; import java.util.Set; -import net.mc_pandacraft.java.plugin.pandacraftutils.ConfigManager; +import net.mc_pandacraft.java.plugin.pandacraftutils.config.ConfigManager; import net.mc_pandacraft.java.plugin.pandacraftutils.plugin_interface.EssentialsInterface; import net.mc_pandacraft.java.plugin.pandacraftutils.plugin_interface.WorldEditInterface; import net.mc_pandacraft.java.plugin.pandacraftutils.plugin_interface.WorldGuardInterface; @@ -53,7 +53,7 @@ public class CommandCubo extends AbstractCommandExecutor { Player player = (Player) sender; // on vérifie que le joueur se trouve bien dans un monde dans lequel on peut cubo - if (!ConfigManager.getInstance().CuboCommand_worlds.contains(player.getWorld().getName())) + if (!ConfigManager.getInstance().defaultConfig.cubos_worlds.contains(player.getWorld().getName())) { player.sendMessage(ChatColor.RED+"Les cubos ne se font pas sur cette map"); return true; diff --git a/src/net/mc_pandacraft/java/plugin/pandacraftutils/commands/CommandList.java b/src/net/mc_pandacraft/java/plugin/pandacraftutils/commands/CommandList.java index c27154c..4be1034 100644 --- a/src/net/mc_pandacraft/java/plugin/pandacraftutils/commands/CommandList.java +++ b/src/net/mc_pandacraft/java/plugin/pandacraftutils/commands/CommandList.java @@ -2,7 +2,7 @@ package net.mc_pandacraft.java.plugin.pandacraftutils.commands; import java.util.ArrayList; -import net.mc_pandacraft.java.plugin.pandacraftutils.ConfigManager; +import net.mc_pandacraft.java.plugin.pandacraftutils.config.ConfigManager; import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayer; import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayerManager; import net.mc_pandacraft.java.plugin.pandacraftutils.plugin_interface.EssentialsInterface; @@ -159,7 +159,7 @@ public class CommandList extends AbstractCommandExecutor { try { int vl = OnlinePlayerManager.get(p).getVL(); - int max_vl = ConfigManager.getInstance().ChatAnalysis_maxViolationLevel; + int max_vl = ConfigManager.getInstance().defaultConfig.chatAnalysis_maxViolationLevel; aff_list.add("§f"+name+"§r - §7"+vl+"/"+max_vl); } diff --git a/src/net/mc_pandacraft/java/plugin/pandacraftutils/commands/CommandMuco.java b/src/net/mc_pandacraft/java/plugin/pandacraftutils/commands/CommandMuco.java index a4de716..0b0bcf7 100644 --- a/src/net/mc_pandacraft/java/plugin/pandacraftutils/commands/CommandMuco.java +++ b/src/net/mc_pandacraft/java/plugin/pandacraftutils/commands/CommandMuco.java @@ -5,7 +5,7 @@ import java.util.List; import java.util.Map; import java.util.Set; -import net.mc_pandacraft.java.plugin.pandacraftutils.ConfigManager; +import net.mc_pandacraft.java.plugin.pandacraftutils.config.ConfigManager; import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayer; import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayerManager; diff --git a/src/net/mc_pandacraft/java/plugin/pandacraftutils/ConfigManager.java b/src/net/mc_pandacraft/java/plugin/pandacraftutils/config/ConfigManager.java similarity index 73% rename from src/net/mc_pandacraft/java/plugin/pandacraftutils/ConfigManager.java rename to src/net/mc_pandacraft/java/plugin/pandacraftutils/config/ConfigManager.java index 36faa65..6912586 100644 --- a/src/net/mc_pandacraft/java/plugin/pandacraftutils/ConfigManager.java +++ b/src/net/mc_pandacraft/java/plugin/pandacraftutils/config/ConfigManager.java @@ -1,14 +1,14 @@ -package net.mc_pandacraft.java.plugin.pandacraftutils; +package net.mc_pandacraft.java.plugin.pandacraftutils.config; import java.io.File; import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; +import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils; + import org.bukkit.ChatColor; -import org.bukkit.configuration.file.FileConfiguration; /* * Configuration du plugin @@ -25,7 +25,6 @@ public class ConfigManager { } public synchronized static void loadNewInstance() { - PandacraftUtils.getInstance().reloadConfig(); try { instance = new ConfigManager(); } catch (Exception e) { @@ -52,12 +51,23 @@ public class ConfigManager { private PandacraftUtils plugin = PandacraftUtils.getInstance(); + public final DefaultConfigManager defaultConfig; + + + + + private ConfigManager() throws Exception { // dossier de configuration principale File configDir = plugin.getDataFolder(); configDir.mkdir(); + + defaultConfig = new DefaultConfigManager(); + + + // dossier qui doit contenir les messages automatiques File autoMessagesDir = new File(configDir, "automessages"); autoMessagesDir.mkdir(); @@ -74,57 +84,7 @@ public class ConfigManager { File badWordsFile = new File(configDir, "badwords.txt"); badWordsFile.createNewFile(); - plugin.saveDefaultConfig(); - FileConfiguration configFile = plugin.getConfig(); - - - Database_host = configFile.getString("database.host"); - Database_port = configFile.getInt("database.port"); - Database_database = configFile.getString("database.base"); - Database_username = configFile.getString("database.user"); - Database_password = configFile.getString("database.pass"); - - AFK_timeoutAutoAfkMessage = configFile.getInt("afk.timeoutAutoMessage"); - AFK_timeoutAutoAfkKick = configFile.getInt("afk.timeoutAutoKick"); - - - ChatAnalysis_timeBeforeResendSameMessage = configFile.getLong("chatAnalysis.timeBeforeResendSameMessage"); - ChatAnalysis_timeBeforeResendSameCommand = configFile.getLong("chatAnalysis.timeBeforeResendSameCommand"); - ChatAnalysis_timePerCaracterForNewMessage = configFile.getLong("chatAnalysis.timePerCaracterForNewMessage"); - ChatAnalysis_maxViolationLevel = configFile.getInt("chatAnalysis.maxViolationLevel"); - ChatAnalysis_nbSecondForOneVLDown = configFile.getInt("chatAnalysis.nbSecondForOneVLDown"); - - CuboCommand_worlds = Arrays.asList(configFile.getString("cubos.worlds").split(";")); - - UsersCleaner_users_cleaner_group = configFile.getString("cleaner.users_cleaner_group"); - - // TODO ajouter les valeurs par défaut dans config.yml - Automessage_interval_players = configFile.getInt("autoMessage.interval_player", 10*60); - Automessage_interval_default = configFile.getInt("autoMessage.interval_default", 2*60+30); - - - // TODO ajouter les valeurs par défaut dans config.yml - // TODO gérer les codes de coloration; - ServerMessages_defaultColor = ChatColor.YELLOW.toString(); - ServerMessages_prefix = ChatColor.YELLOW+"["+ChatColor.WHITE+"Pandacraft"+ChatColor.YELLOW+"] "; //configFile.getString("server_messages_prefix"); - - - // TODO ajouter les valeurs par défaut dans config.yml - // TODO gérer les codes de coloration; - ServerMOTD = "§7Serveur §fPandacraft§7, §eVenez nous rejoindre :D\n§bCreatif§7, §6Survie§7 et §4Faction/PVP§7 !"; - - - - // TODO ajouter les valeurs par défaut dans config.yml - EntitySpam_worlds = "creative"; // séparé avec des point-virgules - EntitySpam_limitPerChunks = 50; - - - // TODO ajouter les valeurs par défaut dans config.yml - NetworkAPI_passwd = "rgrgaethejtrvvzh47"; - - initChatAnalysisBadWord(); initCommandAlias(); @@ -135,50 +95,6 @@ public class ConfigManager { - /* - * Connexion à la base de donnée - */ - - public String Database_host; - public int Database_port; - public String Database_username; - public String Database_database; - public String Database_password; - - - - - - - - - /* - * Users cleaner - */ - public String UsersCleaner_users_cleaner_group; - - - - /* - * Entity Spam - */ - public String EntitySpam_worlds; - public int EntitySpam_limitPerChunks; - - - - - - /* - * NetworkAPI - */ - public String NetworkAPI_passwd; - - - - - - @@ -186,18 +102,11 @@ public class ConfigManager { * Automessages */ public List> Automessages_messages; - /** - * En seconde : pour les joueurs != visiteur - */ - public int Automessage_interval_players; - /** - * En seconde : pour les visiteurs - */ - public int Automessage_interval_default; private void initAutomessages() { Automessages_messages = new ArrayList>(); + String defColor = defaultConfig.serverMessages_defaultColor; Map message; @@ -207,12 +116,12 @@ public class ConfigManager { Automessages_messages.add(message); message = new HashMap(); - message.put("message", "Utilisez la commande &7/cubo"+ServerMessages_defaultColor+" en Survie pour protéger vos construction ! :)%n&a https://www.mc-pandacraft.net/?p=antigrief#tuto_cubo"); + message.put("message", "Utilisez la commande &7/cubo"+defColor+" en Survie pour protéger vos construction ! :)%n&a https://www.mc-pandacraft.net/?p=antigrief#tuto_cubo"); message.put("permissions", "*"); Automessages_messages.add(message); message = new HashMap(); - message.put("message", "WorldEdit disponible en &bCréatif"+ServerMessages_defaultColor+" avec le grade %n&f[&eUltimate&f]"+ServerMessages_defaultColor+". Profitez en vite :D%n &a https://www.mc-pandacraft.net/?p=ultimate"); + message.put("message", "WorldEdit disponible en &bCréatif"+defColor+" avec le grade %n&f[&eUltimate&f]"+defColor+". Profitez en vite :D%n &a https://www.mc-pandacraft.net/?p=ultimate"); message.put("permissions", "*"); Automessages_messages.add(message); @@ -236,40 +145,10 @@ public class ConfigManager { - /* - * Configuration AFK - */ - /** - * En secondes - */ - public int AFK_timeoutAutoAfkMessage; - /** - * En secondes - */ - public int AFK_timeoutAutoAfkKick; // 10 min - /* - * Configuration analyse du chat et des messages privés - * (antispam, insultes, publicité) - */ - - /** - * En milisecondes - */ - public long ChatAnalysis_timeBeforeResendSameMessage;// 2 min - /** - * En milisecondes - */ - public long ChatAnalysis_timeBeforeResendSameCommand;// 60 sec - /** - * En milisecondes - */ - public long ChatAnalysis_timePerCaracterForNewMessage;// 0.1 sec - public int ChatAnalysis_maxViolationLevel; - public int ChatAnalysis_nbSecondForOneVLDown; @@ -557,56 +436,6 @@ public class ConfigManager { MultiCommand_config.put("new_nether", list); } - - - - - - - - - - - - - - - - - - - public List CuboCommand_worlds = new ArrayList(); - - public String ServerMessages_prefix; - public String ServerMessages_defaultColor; - - - - public String ServerMOTD; - - - - - - - - - - - - - - - - - - - - - - - - } diff --git a/src/net/mc_pandacraft/java/plugin/pandacraftutils/config/DefaultConfigManager.java b/src/net/mc_pandacraft/java/plugin/pandacraftutils/config/DefaultConfigManager.java new file mode 100644 index 0000000..1814aad --- /dev/null +++ b/src/net/mc_pandacraft/java/plugin/pandacraftutils/config/DefaultConfigManager.java @@ -0,0 +1,174 @@ +package net.mc_pandacraft.java.plugin.pandacraftutils.config; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import org.bukkit.ChatColor; +import org.bukkit.configuration.file.FileConfiguration; + +import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils; + +public class DefaultConfigManager { + private PandacraftUtils plugin = PandacraftUtils.getInstance(); + + + private FileConfiguration configFile; + + + + + + + + + + + /* + * Connexion à la base de donnée + */ + + public final String database_host; + public final int database_port; + public final String database_user; + public final String database_base; + public final String database_pass; + + /* + * Configuration AFK + */ + /** En secondes */ + public final int afk_timeoutAutoMessage; + /** En secondes */ + public final int afk_timeoutAutoKick; + + /* + * Configuration analyse du chat et des messages privés + * (antispam, insultes, publicité) + */ + /** En milisecondes */ + public final long chatAnalysis_timeBeforeResendSameMessage; + /** En milisecondes */ + public final long chatAnalysis_timeBeforeResendSameCommand; + /** En milisecondes */ + public final long chatAnalysis_timePerCaracterForNewMessage; + public final int chatAnalysis_maxViolationLevel; + public final int chatAnalysis_nbSecondForOneVLDown; + + /* + * Cubos + */ + public final List cubos_worlds; + + /* + * Users cleaner + */ + public final String cleaner_usersCleanerGroup; + + /* + * Automessages + */ + /** En seconde : pour les joueurs != visiteur */ + public final int autoMessages_playerInterval; + /** En seconde : pour les visiteurs */ + public final int autoMessages_defaultInterval; + + /* + * Server Messages + */ + public final String serverMessages_defaultColor; + public final String serverMessages_prefix; + + /* + * Ping MOTD + */ + public final String pingMOTD; + + /* + * Entity Spam + */ + public final List entitySpam_worlds; + public final int entitySpam_limitPerChunk; + + /* + * Network API + */ + public final String networkAPI_pass; + + + + + + + + + + DefaultConfigManager() { + plugin.reloadConfig(); + + plugin.saveDefaultConfig(); + + configFile = plugin.getConfig(); + + + database_host = configFile.getString("database.host"); + database_port = configFile.getInt("database.port"); + database_base = configFile.getString("database.base"); + database_user = configFile.getString("database.user"); + database_pass = configFile.getString("database.pass"); + + + afk_timeoutAutoMessage = configFile.getInt("afk.timeoutAutoMessage"); + afk_timeoutAutoKick = configFile.getInt("afk.timeoutAutoKick"); + + + chatAnalysis_timeBeforeResendSameMessage = configFile.getLong("chatAnalysis.timeBeforeResendSameMessage"); + chatAnalysis_timeBeforeResendSameCommand = configFile.getLong("chatAnalysis.timeBeforeResendSameCommand"); + chatAnalysis_timePerCaracterForNewMessage = configFile.getLong("chatAnalysis.timePerCaracterForNewMessage"); + chatAnalysis_maxViolationLevel = configFile.getInt("chatAnalysis.maxViolationLevel"); + chatAnalysis_nbSecondForOneVLDown = configFile.getInt("chatAnalysis.nbSecondForOneVLDown"); + + + cubos_worlds = getSplittedString("cubos.worlds", ";"); + + + cleaner_usersCleanerGroup = configFile.getString("cleaner.usersCleanerGroup"); + + + autoMessages_playerInterval = configFile.getInt("autoMessages.playerInterval"); + autoMessages_defaultInterval = configFile.getInt("autoMessages.defaultInterval"); + + + serverMessages_defaultColor = getTransletedColorCode("serverMessages.defaultColor"); + serverMessages_prefix = getTransletedColorCode("serverMessages.prefix"); + + + pingMOTD = getTransletedColorCode("pingMOTD").replace("\\n", "\n"); + + + entitySpam_worlds = getSplittedString("entitySpam.worlds", ";"); + entitySpam_limitPerChunk = configFile.getInt("entitySpam.limitPerChunk"); + + + networkAPI_pass = configFile.getString("networkAPI.pass"); + + + } + + + + + + + + + private List getSplittedString(String path, String split) { + String value = configFile.getString(path, ""); + + return Collections.unmodifiableList(Arrays.asList(value.split(split))); + } + + private String getTransletedColorCode(String path) { + return ChatColor.translateAlternateColorCodes('&', configFile.getString(path, "")); + } +} diff --git a/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/AutoMessagesManager.java b/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/AutoMessagesManager.java index 276f897..29901da 100644 --- a/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/AutoMessagesManager.java +++ b/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/AutoMessagesManager.java @@ -6,8 +6,8 @@ import java.util.Collection; import java.util.List; import java.util.Map; -import net.mc_pandacraft.java.plugin.pandacraftutils.ConfigManager; import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils; +import net.mc_pandacraft.java.plugin.pandacraftutils.config.ConfigManager; import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayer; import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayerManager; @@ -31,8 +31,8 @@ public class AutoMessagesManager extends BukkitRunnable { @Override public void run() { List messages = getMessagesFromConfig(); - int interval_default = ConfigManager.getInstance().Automessage_interval_default, - interval_players = ConfigManager.getInstance().Automessage_interval_players; + int interval_default = ConfigManager.getInstance().defaultConfig.autoMessages_defaultInterval, + interval_players = ConfigManager.getInstance().defaultConfig.autoMessages_playerInterval; // message // permissions diff --git a/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/CommandAliasManager.java b/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/CommandAliasManager.java index 87f8e62..6b984ad 100644 --- a/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/CommandAliasManager.java +++ b/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/CommandAliasManager.java @@ -3,8 +3,8 @@ package net.mc_pandacraft.java.plugin.pandacraftutils.modules; import java.util.List; import java.util.Map; -import net.mc_pandacraft.java.plugin.pandacraftutils.ConfigManager; import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils; +import net.mc_pandacraft.java.plugin.pandacraftutils.config.ConfigManager; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; diff --git a/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/PacketOutServerInfoListener.java b/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/PacketOutServerInfoListener.java index 7192bcb..bcc6813 100644 --- a/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/PacketOutServerInfoListener.java +++ b/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/PacketOutServerInfoListener.java @@ -15,8 +15,8 @@ import com.comphenix.protocol.events.PacketAdapter; import com.comphenix.protocol.events.PacketEvent; import com.comphenix.protocol.wrappers.WrappedGameProfile; -import net.mc_pandacraft.java.plugin.pandacraftutils.ConfigManager; import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils; +import net.mc_pandacraft.java.plugin.pandacraftutils.config.ConfigManager; import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayer; import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayerManager; @@ -106,7 +106,7 @@ public class PacketOutServerInfoListener { - event.getPacket().getServerPings().read(0).setMotD(ConfigManager.getInstance().ServerMOTD); + event.getPacket().getServerPings().read(0).setMotD(ConfigManager.getInstance().defaultConfig.pingMOTD); } } ); diff --git a/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/player_control/AfkManager.java b/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/player_control/AfkManager.java index f00bc48..bb5a200 100644 --- a/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/player_control/AfkManager.java +++ b/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/player_control/AfkManager.java @@ -3,8 +3,8 @@ package net.mc_pandacraft.java.plugin.pandacraftutils.modules.player_control; import java.util.Collection; -import net.mc_pandacraft.java.plugin.pandacraftutils.ConfigManager; import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils; +import net.mc_pandacraft.java.plugin.pandacraftutils.config.ConfigManager; import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayer; import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayerManager; @@ -28,8 +28,6 @@ import org.bukkit.scheduler.BukkitRunnable; public class AfkManager extends BukkitRunnable implements Listener { private PandacraftUtils plugin = PandacraftUtils.getInstance(); - private int timeoutAutoAfkMessage = ConfigManager.getInstance().AFK_timeoutAutoAfkMessage; - private int timeoutAutoAfkKick = ConfigManager.getInstance().AFK_timeoutAutoAfkKick; public AfkManager() @@ -53,6 +51,8 @@ public class AfkManager extends BukkitRunnable implements Listener { @Override public void run() { // methode exécutée toute les secondes + int timeoutAutoAfkMessage = ConfigManager.getInstance().defaultConfig.afk_timeoutAutoMessage; + int timeoutAutoAfkKick = ConfigManager.getInstance().defaultConfig.afk_timeoutAutoKick; Collection oPlayers = OnlinePlayerManager.getAll(); for (OnlinePlayer ap : oPlayers.toArray(new OnlinePlayer[oPlayers.size()])) { // parcours de tout les joueurs diff --git a/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/player_control/ChatAnalysisManager.java b/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/player_control/ChatAnalysisManager.java index fcb5581..471fb63 100644 --- a/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/player_control/ChatAnalysisManager.java +++ b/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/player_control/ChatAnalysisManager.java @@ -1,7 +1,7 @@ package net.mc_pandacraft.java.plugin.pandacraftutils.modules.player_control; -import net.mc_pandacraft.java.plugin.pandacraftutils.ConfigManager; import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils; +import net.mc_pandacraft.java.plugin.pandacraftutils.config.ConfigManager; import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayer; import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayerManager; @@ -34,10 +34,10 @@ public class ChatAnalysisManager implements Listener { long time = System.currentTimeMillis(); if (op.getLast_message() != null) { - if (op.getLast_message().equals(message) && time - op.getLast_message_time() < ConfigManager.getInstance().ChatAnalysis_timeBeforeResendSameMessage) + if (op.getLast_message().equals(message) && time - op.getLast_message_time() < ConfigManager.getInstance().defaultConfig.chatAnalysis_timeBeforeResendSameMessage) { event.getPlayer().sendMessage(ChatColor.RED+"Evitez de renvoyer le même message !"); - if (op.getVL() >= ConfigManager.getInstance().ChatAnalysis_maxViolationLevel/2) + if (op.getVL() >= ConfigManager.getInstance().defaultConfig.chatAnalysis_maxViolationLevel/2) event.setCancelled(true); else event.setMessage(analyseString(message, op)); @@ -47,7 +47,7 @@ public class ChatAnalysisManager implements Listener { else { long time_since_last_message = time - op.getLast_message_time(); - long timeout_needed = message.length() * ConfigManager.getInstance().ChatAnalysis_timePerCaracterForNewMessage; + long timeout_needed = message.length() * ConfigManager.getInstance().defaultConfig.chatAnalysis_timePerCaracterForNewMessage; if (time_since_last_message < timeout_needed) { @@ -63,7 +63,7 @@ public class ChatAnalysisManager implements Listener { event.setMessage(message); - op.removeVL(NumberConversions.floor(((time - op.getLast_message_time())/1000)/ConfigManager.getInstance().ChatAnalysis_nbSecondForOneVLDown)); + op.removeVL(NumberConversions.floor(((time - op.getLast_message_time())/1000)/ConfigManager.getInstance().defaultConfig.chatAnalysis_nbSecondForOneVLDown)); op.setLast_message(message); @@ -168,17 +168,17 @@ public class ChatAnalysisManager implements Listener { { if (op.getLast_command() != null) { - if (op.getLast_command().equals(command_line) && time - op.getLast_command_time() < ConfigManager.getInstance().ChatAnalysis_timeBeforeResendSameCommand) + if (op.getLast_command().equals(command_line) && time - op.getLast_command_time() < ConfigManager.getInstance().defaultConfig.chatAnalysis_timeBeforeResendSameCommand) { event.getPlayer().sendMessage(ChatColor.RED+"Patientez avant de renvoyer cette commande !"); - if (op.getVL() >= ConfigManager.getInstance().ChatAnalysis_maxViolationLevel/2) + if (op.getVL() >= ConfigManager.getInstance().defaultConfig.chatAnalysis_maxViolationLevel/2) event.setCancelled(true); op.addVL(5); event.setMessage(command_line); return; } } - op.removeVL(NumberConversions.floor(((time - op.getLast_command_time())/1000)/ConfigManager.getInstance().ChatAnalysis_nbSecondForOneVLDown)); + op.removeVL(NumberConversions.floor(((time - op.getLast_command_time())/1000)/ConfigManager.getInstance().defaultConfig.chatAnalysis_nbSecondForOneVLDown)); op.setLast_command(command_line); op.setLast_command_time(time); diff --git a/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/protection/EntitySpamManager.java b/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/protection/EntitySpamManager.java index c4b538b..073af30 100644 --- a/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/protection/EntitySpamManager.java +++ b/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/protection/EntitySpamManager.java @@ -1,5 +1,7 @@ package net.mc_pandacraft.java.plugin.pandacraftutils.modules.protection; +import java.util.List; + import org.bukkit.Chunk; import org.bukkit.Location; import org.bukkit.World; @@ -11,8 +13,8 @@ import org.bukkit.event.Listener; import org.bukkit.event.entity.ExpBottleEvent; import org.bukkit.event.vehicle.VehicleCreateEvent; -import net.mc_pandacraft.java.plugin.pandacraftutils.ConfigManager; import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils; +import net.mc_pandacraft.java.plugin.pandacraftutils.config.ConfigManager; public class EntitySpamManager implements Listener { @@ -79,9 +81,8 @@ public class EntitySpamManager implements Listener { private boolean isInWorld(Location l) { World w = l.getWorld(); - String config = ConfigManager.getInstance().EntitySpam_worlds; - String[] worlds = config.split(";"); - for (String ws : worlds) + List config = ConfigManager.getInstance().defaultConfig.entitySpam_worlds; + for (String ws : config) if (w.getName().equalsIgnoreCase(ws)) return true; return false; @@ -91,7 +92,7 @@ public class EntitySpamManager implements Listener { private boolean containsTooManyEntity(Chunk c) { if (!c.isLoaded()) c.load(); Entity[] ents = c.getEntities(); - return (ents.length > ConfigManager.getInstance().EntitySpam_limitPerChunks); + return (ents.length > ConfigManager.getInstance().defaultConfig.entitySpam_limitPerChunk); } } diff --git a/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/protection/WorldBorderManager.java b/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/protection/WorldBorderManager.java index 0b9902c..799a70b 100644 --- a/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/protection/WorldBorderManager.java +++ b/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/protection/WorldBorderManager.java @@ -6,8 +6,8 @@ import java.util.List; import java.util.Map; import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils; -import net.mc_pandacraft.java.plugin.pandacraftutils.ConfigManager; -import net.mc_pandacraft.java.plugin.pandacraftutils.ConfigManager.WorldBorderConfig; +import net.mc_pandacraft.java.plugin.pandacraftutils.config.ConfigManager; +import net.mc_pandacraft.java.plugin.pandacraftutils.config.ConfigManager.WorldBorderConfig; import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayer; import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayerManager; import net.mc_pandacraft.java.util.bukkit.protocol.ParticleEffect; diff --git a/src/net/mc_pandacraft/java/plugin/pandacraftutils/network_api/RequestAnalyser.java b/src/net/mc_pandacraft/java/plugin/pandacraftutils/network_api/RequestAnalyser.java index 4acff94..29e67df 100644 --- a/src/net/mc_pandacraft/java/plugin/pandacraftutils/network_api/RequestAnalyser.java +++ b/src/net/mc_pandacraft/java/plugin/pandacraftutils/network_api/RequestAnalyser.java @@ -5,13 +5,13 @@ import java.io.IOException; import java.io.InputStreamReader; import java.net.Socket; -import net.mc_pandacraft.java.plugin.pandacraftutils.ConfigManager; +import net.mc_pandacraft.java.plugin.pandacraftutils.config.ConfigManager; public class RequestAnalyser { private NetworkAPIListener networkAPIListener = NetworkAPIListener.getInstance(); - private final String pass = ConfigManager.getInstance().NetworkAPI_passwd; + private final String pass = ConfigManager.getInstance().defaultConfig.networkAPI_pass; public final String command; public final String data; diff --git a/src/net/mc_pandacraft/java/plugin/pandacraftutils/players/OnlinePlayer.java b/src/net/mc_pandacraft/java/plugin/pandacraftutils/players/OnlinePlayer.java index 713c27f..89df419 100644 --- a/src/net/mc_pandacraft/java/plugin/pandacraftutils/players/OnlinePlayer.java +++ b/src/net/mc_pandacraft/java/plugin/pandacraftutils/players/OnlinePlayer.java @@ -7,8 +7,8 @@ import java.util.List; import java.util.Random; import java.util.Set; -import net.mc_pandacraft.java.plugin.pandacraftutils.ConfigManager; import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils; +import net.mc_pandacraft.java.plugin.pandacraftutils.config.ConfigManager; import net.mc_pandacraft.java.plugin.pandacraftutils.modules.CalculatorManager; import net.mc_pandacraft.java.plugin.pandacraftutils.plugin_interface.EssentialsInterface; @@ -113,7 +113,7 @@ public class OnlinePlayer { { violation_level += nb; plugin.getLogger().info("ViolationLevel for player "+player.getDisplayName()+"§r : +"+nb+" -> "+violation_level); - if (violation_level >= ConfigManager.getInstance().ChatAnalysis_maxViolationLevel) + if (violation_level >= ConfigManager.getInstance().defaultConfig.chatAnalysis_maxViolationLevel) Bukkit.getScheduler().runTask(plugin, new Runnable() { @Override public void run() { @@ -298,7 +298,7 @@ public class OnlinePlayer { * @param message le message à envoyer au joueur */ public void sendMessageFromServer(String message) { - player.sendMessage(ConfigManager.getInstance().ServerMessages_prefix + message); + player.sendMessage(ConfigManager.getInstance().defaultConfig.serverMessages_prefix + message); } diff --git a/src/net/mc_pandacraft/java/plugin/pandacraftutils/PlayerDataCleaner.java b/src/net/mc_pandacraft/java/plugin/pandacraftutils/players/PlayerDataCleaner.java similarity index 86% rename from src/net/mc_pandacraft/java/plugin/pandacraftutils/PlayerDataCleaner.java rename to src/net/mc_pandacraft/java/plugin/pandacraftutils/players/PlayerDataCleaner.java index 18f73a9..c2d404b 100644 --- a/src/net/mc_pandacraft/java/plugin/pandacraftutils/PlayerDataCleaner.java +++ b/src/net/mc_pandacraft/java/plugin/pandacraftutils/players/PlayerDataCleaner.java @@ -1,7 +1,9 @@ -package net.mc_pandacraft.java.plugin.pandacraftutils; +package net.mc_pandacraft.java.plugin.pandacraftutils.players; import java.util.Set; +import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils; +import net.mc_pandacraft.java.plugin.pandacraftutils.config.ConfigManager; import net.mc_pandacraft.java.plugin.pandacraftutils.plugin_interface.EssentialsInterface; import ru.tehkode.permissions.PermissionUser; import ru.tehkode.permissions.bukkit.PermissionsEx; @@ -31,7 +33,7 @@ public class PlayerDataCleaner { private void clean() { - String group_to_remove = ConfigManager.getInstance().UsersCleaner_users_cleaner_group; + String group_to_remove = ConfigManager.getInstance().defaultConfig.cleaner_usersCleanerGroup; // essentials players