Lecture de config.yml dans une classe à part (DefaultConfigManager)

This commit is contained in:
Marc Baloup 2015-02-17 00:45:41 -05:00
parent 0b6b288c8d
commit f7f093bc52
20 changed files with 270 additions and 230 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-3.11.jar"/> <jar path="PandacraftUtils/jar_export/PandacraftUtils-3.12.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/>

View File

@ -1,8 +1,8 @@
database: database:
host: localhost host: localhost
port: 3306 port: 3306
base: pandacraft
user: pandacraft user: pandacraft
base: pandacraft
pass: HYtKq92pfx9ucwzq pass: HYtKq92pfx9ucwzq
@ -37,4 +37,36 @@ cubos:
cleaner: 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

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: 3.11 version: 3.12

View File

@ -1,6 +1,7 @@
package net.mc_pandacraft.java.plugin.pandacraftutils; package net.mc_pandacraft.java.plugin.pandacraftutils;
import net.mc_pandacraft.java.plugin.pandacraftutils.commands.PandacraftUtilsCommandsManager; 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.AutoMessagesManager;
import net.mc_pandacraft.java.plugin.pandacraftutils.modules.CalculatorManager; import net.mc_pandacraft.java.plugin.pandacraftutils.modules.CalculatorManager;
import net.mc_pandacraft.java.plugin.pandacraftutils.modules.CommandAliasManager; 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.network_api.NetworkAPI;
import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayer; 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.OnlinePlayerManager;
import net.mc_pandacraft.java.plugin.pandacraftutils.players.PlayerDataCleaner;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
@ -171,7 +173,7 @@ public class PandacraftUtils extends JavaPlugin {
throw new IllegalArgumentException("Un message doit être défini"); throw new IllegalArgumentException("Un message doit être défini");
if (prefix) if (prefix)
message = ConfigManager.getInstance().ServerMessages_prefix + message; message = ConfigManager.getInstance().defaultConfig.serverMessages_prefix + message;
for (OnlinePlayer op : OnlinePlayerManager.getAll()) for (OnlinePlayer op : OnlinePlayerManager.getAll())

View File

@ -1,6 +1,6 @@
package net.mc_pandacraft.java.plugin.pandacraftutils.commands; 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.NetworkAPI;
import net.mc_pandacraft.java.plugin.pandacraftutils.network_api.NetworkAPIListener; import net.mc_pandacraft.java.plugin.pandacraftutils.network_api.NetworkAPIListener;

View File

@ -6,7 +6,7 @@ import java.util.List;
import java.util.Random; import java.util.Random;
import java.util.Set; 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.EssentialsInterface;
import net.mc_pandacraft.java.plugin.pandacraftutils.plugin_interface.WorldEditInterface; import net.mc_pandacraft.java.plugin.pandacraftutils.plugin_interface.WorldEditInterface;
import net.mc_pandacraft.java.plugin.pandacraftutils.plugin_interface.WorldGuardInterface; import net.mc_pandacraft.java.plugin.pandacraftutils.plugin_interface.WorldGuardInterface;
@ -53,7 +53,7 @@ public class CommandCubo extends AbstractCommandExecutor {
Player player = (Player) sender; Player player = (Player) sender;
// on vérifie que le joueur se trouve bien dans un monde dans lequel on peut cubo // 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"); player.sendMessage(ChatColor.RED+"Les cubos ne se font pas sur cette map");
return true; return true;

View File

@ -2,7 +2,7 @@ package net.mc_pandacraft.java.plugin.pandacraftutils.commands;
import java.util.ArrayList; 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.OnlinePlayer;
import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayerManager; import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayerManager;
import net.mc_pandacraft.java.plugin.pandacraftutils.plugin_interface.EssentialsInterface; import net.mc_pandacraft.java.plugin.pandacraftutils.plugin_interface.EssentialsInterface;
@ -159,7 +159,7 @@ public class CommandList extends AbstractCommandExecutor {
try try
{ {
int vl = OnlinePlayerManager.get(p).getVL(); 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); aff_list.add("§f"+name+"§r - §7"+vl+"/"+max_vl);
} }

View File

@ -5,7 +5,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; 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.OnlinePlayer;
import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayerManager; import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayerManager;

View File

@ -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.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
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 net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.configuration.file.FileConfiguration;
/* /*
* Configuration du plugin * Configuration du plugin
@ -25,7 +25,6 @@ public class ConfigManager {
} }
public synchronized static void loadNewInstance() { public synchronized static void loadNewInstance() {
PandacraftUtils.getInstance().reloadConfig();
try { try {
instance = new ConfigManager(); instance = new ConfigManager();
} catch (Exception e) { } catch (Exception e) {
@ -52,12 +51,23 @@ public class ConfigManager {
private PandacraftUtils plugin = PandacraftUtils.getInstance(); private PandacraftUtils plugin = PandacraftUtils.getInstance();
public final DefaultConfigManager defaultConfig;
private ConfigManager() throws Exception { private ConfigManager() throws Exception {
// dossier de configuration principale // dossier de configuration principale
File configDir = plugin.getDataFolder(); File configDir = plugin.getDataFolder();
configDir.mkdir(); configDir.mkdir();
defaultConfig = new DefaultConfigManager();
// dossier qui doit contenir les messages automatiques // dossier qui doit contenir les messages automatiques
File autoMessagesDir = new File(configDir, "automessages"); File autoMessagesDir = new File(configDir, "automessages");
autoMessagesDir.mkdir(); autoMessagesDir.mkdir();
@ -74,57 +84,7 @@ public class ConfigManager {
File badWordsFile = new File(configDir, "badwords.txt"); File badWordsFile = new File(configDir, "badwords.txt");
badWordsFile.createNewFile(); 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(); initChatAnalysisBadWord();
initCommandAlias(); 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 * Automessages
*/ */
public List<Map<String, String>> Automessages_messages; public List<Map<String, String>> 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() { private void initAutomessages() {
Automessages_messages = new ArrayList<Map<String,String>>(); Automessages_messages = new ArrayList<Map<String,String>>();
String defColor = defaultConfig.serverMessages_defaultColor;
Map<String, String> message; Map<String, String> message;
@ -207,12 +116,12 @@ public class ConfigManager {
Automessages_messages.add(message); Automessages_messages.add(message);
message = new HashMap<String, String>(); message = new HashMap<String, String>();
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", "*"); message.put("permissions", "*");
Automessages_messages.add(message); Automessages_messages.add(message);
message = new HashMap<String, String>(); message = new HashMap<String, String>();
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", "*"); message.put("permissions", "*");
Automessages_messages.add(message); 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); MultiCommand_config.put("new_nether", list);
} }
public List<String> CuboCommand_worlds = new ArrayList<String>();
public String ServerMessages_prefix;
public String ServerMessages_defaultColor;
public String ServerMOTD;
} }

View File

@ -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<String> 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<String> 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<String> 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, ""));
}
}

View File

@ -6,8 +6,8 @@ import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Map; 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.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.OnlinePlayer;
import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayerManager; import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayerManager;
@ -31,8 +31,8 @@ public class AutoMessagesManager extends BukkitRunnable {
@Override @Override
public void run() { public void run() {
List<AutoMessage> messages = getMessagesFromConfig(); List<AutoMessage> messages = getMessagesFromConfig();
int interval_default = ConfigManager.getInstance().Automessage_interval_default, int interval_default = ConfigManager.getInstance().defaultConfig.autoMessages_defaultInterval,
interval_players = ConfigManager.getInstance().Automessage_interval_players; interval_players = ConfigManager.getInstance().defaultConfig.autoMessages_playerInterval;
// message // message
// permissions // permissions

View File

@ -3,8 +3,8 @@ package net.mc_pandacraft.java.plugin.pandacraftutils.modules;
import java.util.List; import java.util.List;
import java.util.Map; 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.PandacraftUtils;
import net.mc_pandacraft.java.plugin.pandacraftutils.config.ConfigManager;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;

View File

@ -15,8 +15,8 @@ import com.comphenix.protocol.events.PacketAdapter;
import com.comphenix.protocol.events.PacketEvent; import com.comphenix.protocol.events.PacketEvent;
import com.comphenix.protocol.wrappers.WrappedGameProfile; 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.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.OnlinePlayer;
import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayerManager; 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);
} }
} }
); );

View File

@ -3,8 +3,8 @@ package net.mc_pandacraft.java.plugin.pandacraftutils.modules.player_control;
import java.util.Collection; 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.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.OnlinePlayer;
import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayerManager; 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 { public class AfkManager extends BukkitRunnable implements Listener {
private PandacraftUtils plugin = PandacraftUtils.getInstance(); private PandacraftUtils plugin = PandacraftUtils.getInstance();
private int timeoutAutoAfkMessage = ConfigManager.getInstance().AFK_timeoutAutoAfkMessage;
private int timeoutAutoAfkKick = ConfigManager.getInstance().AFK_timeoutAutoAfkKick;
public AfkManager() public AfkManager()
@ -53,6 +51,8 @@ public class AfkManager extends BukkitRunnable implements Listener {
@Override @Override
public void run() { public void run() {
// methode exécutée toute les secondes // methode exécutée toute les secondes
int timeoutAutoAfkMessage = ConfigManager.getInstance().defaultConfig.afk_timeoutAutoMessage;
int timeoutAutoAfkKick = ConfigManager.getInstance().defaultConfig.afk_timeoutAutoKick;
Collection<OnlinePlayer> oPlayers = OnlinePlayerManager.getAll(); Collection<OnlinePlayer> oPlayers = OnlinePlayerManager.getAll();
for (OnlinePlayer ap : oPlayers.toArray(new OnlinePlayer[oPlayers.size()])) for (OnlinePlayer ap : oPlayers.toArray(new OnlinePlayer[oPlayers.size()]))
{ // parcours de tout les joueurs { // parcours de tout les joueurs

View File

@ -1,7 +1,7 @@
package net.mc_pandacraft.java.plugin.pandacraftutils.modules.player_control; 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.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.OnlinePlayer;
import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayerManager; import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayerManager;
@ -34,10 +34,10 @@ public class ChatAnalysisManager implements Listener {
long time = System.currentTimeMillis(); long time = System.currentTimeMillis();
if (op.getLast_message() != null) 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 !"); 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); event.setCancelled(true);
else else
event.setMessage(analyseString(message, op)); event.setMessage(analyseString(message, op));
@ -47,7 +47,7 @@ public class ChatAnalysisManager implements Listener {
else else
{ {
long time_since_last_message = time - op.getLast_message_time(); 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) if (time_since_last_message < timeout_needed)
{ {
@ -63,7 +63,7 @@ public class ChatAnalysisManager implements Listener {
event.setMessage(message); 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); op.setLast_message(message);
@ -168,17 +168,17 @@ public class ChatAnalysisManager implements Listener {
{ {
if (op.getLast_command() != null) 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 !"); 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); event.setCancelled(true);
op.addVL(5); op.addVL(5);
event.setMessage(command_line); event.setMessage(command_line);
return; 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(command_line);
op.setLast_command_time(time); op.setLast_command_time(time);

View File

@ -1,5 +1,7 @@
package net.mc_pandacraft.java.plugin.pandacraftutils.modules.protection; package net.mc_pandacraft.java.plugin.pandacraftutils.modules.protection;
import java.util.List;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
@ -11,8 +13,8 @@ import org.bukkit.event.Listener;
import org.bukkit.event.entity.ExpBottleEvent; import org.bukkit.event.entity.ExpBottleEvent;
import org.bukkit.event.vehicle.VehicleCreateEvent; 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.PandacraftUtils;
import net.mc_pandacraft.java.plugin.pandacraftutils.config.ConfigManager;
public class EntitySpamManager implements Listener { public class EntitySpamManager implements Listener {
@ -79,9 +81,8 @@ public class EntitySpamManager implements Listener {
private boolean isInWorld(Location l) { private boolean isInWorld(Location l) {
World w = l.getWorld(); World w = l.getWorld();
String config = ConfigManager.getInstance().EntitySpam_worlds; List<String> config = ConfigManager.getInstance().defaultConfig.entitySpam_worlds;
String[] worlds = config.split(";"); for (String ws : config)
for (String ws : worlds)
if (w.getName().equalsIgnoreCase(ws)) if (w.getName().equalsIgnoreCase(ws))
return true; return true;
return false; return false;
@ -91,7 +92,7 @@ public class EntitySpamManager implements Listener {
private boolean containsTooManyEntity(Chunk c) { private boolean containsTooManyEntity(Chunk c) {
if (!c.isLoaded()) c.load(); if (!c.isLoaded()) c.load();
Entity[] ents = c.getEntities(); Entity[] ents = c.getEntities();
return (ents.length > ConfigManager.getInstance().EntitySpam_limitPerChunks); return (ents.length > ConfigManager.getInstance().defaultConfig.entitySpam_limitPerChunk);
} }
} }

View File

@ -6,8 +6,8 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils; import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils;
import net.mc_pandacraft.java.plugin.pandacraftutils.ConfigManager; import net.mc_pandacraft.java.plugin.pandacraftutils.config.ConfigManager;
import net.mc_pandacraft.java.plugin.pandacraftutils.ConfigManager.WorldBorderConfig; 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.OnlinePlayer;
import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayerManager; import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayerManager;
import net.mc_pandacraft.java.util.bukkit.protocol.ParticleEffect; import net.mc_pandacraft.java.util.bukkit.protocol.ParticleEffect;

View File

@ -5,13 +5,13 @@ import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.net.Socket; import java.net.Socket;
import net.mc_pandacraft.java.plugin.pandacraftutils.ConfigManager; import net.mc_pandacraft.java.plugin.pandacraftutils.config.ConfigManager;
public class RequestAnalyser { public class RequestAnalyser {
private NetworkAPIListener networkAPIListener = NetworkAPIListener.getInstance(); 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 command;
public final String data; public final String data;

View File

@ -7,8 +7,8 @@ import java.util.List;
import java.util.Random; import java.util.Random;
import java.util.Set; 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.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.modules.CalculatorManager;
import net.mc_pandacraft.java.plugin.pandacraftutils.plugin_interface.EssentialsInterface; import net.mc_pandacraft.java.plugin.pandacraftutils.plugin_interface.EssentialsInterface;
@ -113,7 +113,7 @@ public class OnlinePlayer {
{ {
violation_level += nb; violation_level += nb;
plugin.getLogger().info("ViolationLevel for player "+player.getDisplayName()+"§r : +"+nb+" -> "+violation_level); 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() { Bukkit.getScheduler().runTask(plugin, new Runnable() {
@Override @Override
public void run() { public void run() {
@ -298,7 +298,7 @@ public class OnlinePlayer {
* @param message le message à envoyer au joueur * @param message le message à envoyer au joueur
*/ */
public void sendMessageFromServer(String message) { public void sendMessageFromServer(String message) {
player.sendMessage(ConfigManager.getInstance().ServerMessages_prefix + message); player.sendMessage(ConfigManager.getInstance().defaultConfig.serverMessages_prefix + message);
} }

View File

@ -1,7 +1,9 @@
package net.mc_pandacraft.java.plugin.pandacraftutils; package net.mc_pandacraft.java.plugin.pandacraftutils.players;
import java.util.Set; 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 net.mc_pandacraft.java.plugin.pandacraftutils.plugin_interface.EssentialsInterface;
import ru.tehkode.permissions.PermissionUser; import ru.tehkode.permissions.PermissionUser;
import ru.tehkode.permissions.bukkit.PermissionsEx; import ru.tehkode.permissions.bukkit.PermissionsEx;
@ -31,7 +33,7 @@ public class PlayerDataCleaner {
private void clean() { private void clean() {
String group_to_remove = ConfigManager.getInstance().UsersCleaner_users_cleaner_group; String group_to_remove = ConfigManager.getInstance().defaultConfig.cleaner_usersCleanerGroup;
// essentials players // essentials players