Préparation des données de configuration

This commit is contained in:
Marc Baloup 2015-01-03 00:35:55 -05:00
parent 49246f233e
commit f9a49ff2ee
5 changed files with 118 additions and 21 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<jardesc> <jardesc>
<jar path="PandacraftUtils/jar_export/PandacraftUtils-2.7.jar"/> <jar path="PandacraftUtils/jar_export/PandacraftUtils-2.8.jar"/>
<options buildIfNeeded="true" compress="true" descriptionLocation="/PandacraftUtils/make_jar.jardesc" exportErrors="true" exportWarnings="true" includeDirectoryEntries="false" overwrite="false" saveDescription="true" storeRefactorings="false" useSourceFolders="false"/> <options buildIfNeeded="true" compress="true" descriptionLocation="/PandacraftUtils/make_jar.jardesc" exportErrors="true" exportWarnings="true" includeDirectoryEntries="false" overwrite="false" saveDescription="true" storeRefactorings="false" useSourceFolders="false"/>
<storedRefactorings deprecationInfo="true" structuralOnly="false"/> <storedRefactorings deprecationInfo="true" structuralOnly="false"/>
<selectedProjects/> <selectedProjects/>

28
resources/config.yml Normal file
View File

@ -0,0 +1,28 @@
database:
host: localhost
port: 3306
base: pandacraft
user: pandacraft
pass: HYtKq92pfx9ucwzq
afk:
# in seconds
timeoutAutoMessage: 300
timeoutAutoKick: 600
chatAnalysis:
# in miliseconds
timeBeforeResendSameMessage: 120000
timeBeforeResendSameCommand: 60000
timePerCaracterForNewMessage: 100
maxViolationLevel: 20
nbSecondForOneVLDown: 10

View File

@ -1,6 +1,6 @@
name: PandacraftUtils name: PandacraftUtils
main: net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils main: net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils
version: 2.7 version: 2.8

View File

@ -1,28 +1,82 @@
package net.mc_pandacraft.java.plugin.pandacraftutils; package net.mc_pandacraft.java.plugin.pandacraftutils;
import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.bukkit.configuration.file.FileConfiguration;
/* /*
* Configuration du plugin * Configuration du plugin
*/ */
public class ConfigManager { public class ConfigManager {
private static ConfigManager instance = null; private static ConfigManager instance = null;
public static ConfigManager getInstance() { public synchronized static ConfigManager getInstance() {
if (instance == null) if (instance == null)
try {
instance = new ConfigManager(); instance = new ConfigManager();
} catch (Exception e) {
PandacraftUtils.getInstance().getLogger().severe("Erreur de chargement de la configuration de PandacraftUtils");
e.printStackTrace();
}
return instance; return instance;
} }
@SuppressWarnings("unused") public synchronized static void reloadConfig() {
instance = null;
}
private PandacraftUtils plugin = PandacraftUtils.getInstance(); 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(); initChatAnalysisBadWord();
@ -35,11 +89,11 @@ public class ConfigManager {
* Connexion à la base de donnée * Connexion à la base de donnée
*/ */
public String Database_host = "localhost"; public String Database_host;
public int Database_port = 3306; public int Database_port;
public String Database_username = "pandacraft"; public String Database_username;
public String Database_database = "pandacraft"; public String Database_database;
public String Database_password = "HYtKq92pfx9ucwzq"; public String Database_password;
@ -51,9 +105,14 @@ public class ConfigManager {
/* /*
* Configuration AFK * Configuration AFK
*/ */
/**
public int AFK_timeoutAutoAfkMessage = 60*5; // 5 min * En secondes
public int AFK_timeoutAutoAfkKick = 60*10; // 10 min */
public int AFK_timeoutAutoAfkMessage;
/**
* En secondes
*/
public int AFK_timeoutAutoAfkKick; // 10 min
@ -63,11 +122,23 @@ public class ConfigManager {
* (antispam, insultes, publicité) * (antispam, insultes, publicité)
*/ */
public long ChatAnalysis_timeBeforeResendSameMessage = 120000;// 2 min /**
public long ChatAnalysis_timeBeforeResendSameCommand = 60000;// 60 sec * En milisecondes
public long ChatAnalysis_timePerCaracterForNewMessage = 100;// 0.1 sec */
public int ChatAnalysis_maxViolationLevel = 20; public long ChatAnalysis_timeBeforeResendSameMessage;// 2 min
public int ChatAnalysis_nbSecondForOneVLDown = 10; /**
* 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 List<String> ChatAnalysis_badWords; // les insultes public List<String> ChatAnalysis_badWords; // les insultes

View File

@ -4,8 +4,6 @@ import net.mc_pandacraft.java.plugin.pandacraftutils.plugin_interface.Essentials
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import com.earth2me.essentials.Essentials;
public class AfkPlayer { public class AfkPlayer {
private Player player; private Player player;
private long timeLastAction; private long timeLastAction;