|
|
|
@@ -1,28 +1,82 @@
|
|
|
|
|
package net.mc_pandacraft.java.plugin.pandacraftutils;
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
import org.bukkit.configuration.file.FileConfiguration;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Configuration du plugin
|
|
|
|
|
*/
|
|
|
|
|
public class ConfigManager {
|
|
|
|
|
private static ConfigManager instance = null;
|
|
|
|
|
|
|
|
|
|
public static ConfigManager getInstance() {
|
|
|
|
|
public synchronized static ConfigManager getInstance() {
|
|
|
|
|
|
|
|
|
|
if (instance == null)
|
|
|
|
|
instance = new ConfigManager();
|
|
|
|
|
try {
|
|
|
|
|
instance = new ConfigManager();
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
PandacraftUtils.getInstance().getLogger().severe("Erreur de chargement de la configuration de PandacraftUtils");
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return instance;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("unused")
|
|
|
|
|
public synchronized static void reloadConfig() {
|
|
|
|
|
instance = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private PandacraftUtils plugin = PandacraftUtils.getInstance();
|
|
|
|
|
|
|
|
|
|
private ConfigManager() {
|
|
|
|
|
private ConfigManager() throws Exception {
|
|
|
|
|
|
|
|
|
|
// dossier de configuration principale
|
|
|
|
|
File configDir = plugin.getDataFolder();
|
|
|
|
|
configDir.mkdir();
|
|
|
|
|
|
|
|
|
|
// dossier qui doit contenir les messages automatiques
|
|
|
|
|
File autoMessagesDir = new File(configDir, "automessages");
|
|
|
|
|
autoMessagesDir.mkdir();
|
|
|
|
|
|
|
|
|
|
// dossier qui doit contenir les alias de commandes
|
|
|
|
|
File commandAliasDir = new File(configDir, "commandalias");
|
|
|
|
|
commandAliasDir.mkdir();
|
|
|
|
|
|
|
|
|
|
// dossier qui doit contenir les séries de commandes
|
|
|
|
|
File multiCommandsDir = new File(configDir, "multicommands");
|
|
|
|
|
multiCommandsDir.mkdir();
|
|
|
|
|
|
|
|
|
|
// fichier qui doit contenir les insultes à censurer
|
|
|
|
|
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");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
initChatAnalysisBadWord();
|
|
|
|
@@ -35,11 +89,11 @@ public class ConfigManager {
|
|
|
|
|
* Connexion à la base de donnée
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
public String Database_host = "localhost";
|
|
|
|
|
public int Database_port = 3306;
|
|
|
|
|
public String Database_username = "pandacraft";
|
|
|
|
|
public String Database_database = "pandacraft";
|
|
|
|
|
public String Database_password = "HYtKq92pfx9ucwzq";
|
|
|
|
|
public String Database_host;
|
|
|
|
|
public int Database_port;
|
|
|
|
|
public String Database_username;
|
|
|
|
|
public String Database_database;
|
|
|
|
|
public String Database_password;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -51,9 +105,14 @@ public class ConfigManager {
|
|
|
|
|
/*
|
|
|
|
|
* Configuration AFK
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
public int AFK_timeoutAutoAfkMessage = 60*5; // 5 min
|
|
|
|
|
public int AFK_timeoutAutoAfkKick = 60*10; // 10 min
|
|
|
|
|
/**
|
|
|
|
|
* En secondes
|
|
|
|
|
*/
|
|
|
|
|
public int AFK_timeoutAutoAfkMessage;
|
|
|
|
|
/**
|
|
|
|
|
* En secondes
|
|
|
|
|
*/
|
|
|
|
|
public int AFK_timeoutAutoAfkKick; // 10 min
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -62,12 +121,24 @@ public class ConfigManager {
|
|
|
|
|
* 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;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public long ChatAnalysis_timeBeforeResendSameMessage = 120000;// 2 min
|
|
|
|
|
public long ChatAnalysis_timeBeforeResendSameCommand = 60000;// 60 sec
|
|
|
|
|
public long ChatAnalysis_timePerCaracterForNewMessage = 100;// 0.1 sec
|
|
|
|
|
public int ChatAnalysis_maxViolationLevel = 20;
|
|
|
|
|
public int ChatAnalysis_nbSecondForOneVLDown = 10;
|
|
|
|
|
|
|
|
|
|
public List<String> ChatAnalysis_badWords; // les insultes
|
|
|
|
|
|
|
|
|
|