290 lines
8.3 KiB
Java
290 lines
8.3 KiB
Java
package net.mc_pandacraft.java.plugin.pandacraftutils.config;
|
|
|
|
import java.io.File;
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils;
|
|
|
|
/*
|
|
* Configuration du plugin
|
|
*/
|
|
public class ConfigManager {
|
|
private static ConfigManager instance = null;
|
|
|
|
|
|
|
|
public synchronized static ConfigManager getInstance() {
|
|
if (instance == null)
|
|
loadNewInstance();
|
|
return instance;
|
|
}
|
|
|
|
public synchronized static void loadNewInstance() {
|
|
try {
|
|
instance = new ConfigManager();
|
|
} catch (Exception e) {
|
|
PandacraftUtils.getInstance().getLogger().severe("Erreur de chargement de la configuration de PandacraftUtils");
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private PandacraftUtils plugin = PandacraftUtils.getInstance();
|
|
|
|
public final DefaultConfig defaultConfig;
|
|
public final WorldBorderConfig worldBorderConfig;
|
|
public final ChatBadWordsConfig chatBadWordsConfig;
|
|
public final AutoMessagesConfig autoMessagesConfig;
|
|
|
|
|
|
|
|
|
|
|
|
private ConfigManager() throws Exception {
|
|
|
|
// dossier de configuration principale
|
|
File configDir = plugin.getDataFolder();
|
|
configDir.mkdir();
|
|
|
|
|
|
defaultConfig = new DefaultConfig();
|
|
worldBorderConfig = new WorldBorderConfig();
|
|
chatBadWordsConfig = new ChatBadWordsConfig();
|
|
autoMessagesConfig = new AutoMessagesConfig();
|
|
|
|
|
|
|
|
// 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();
|
|
|
|
|
|
|
|
initCommandAlias();
|
|
initMultiCommand();
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
* Alias pour les commandes
|
|
*/
|
|
|
|
public List<Map<String, String>> CommandAlias_alias;
|
|
|
|
private void initCommandAlias() {
|
|
CommandAlias_alias = new ArrayList<Map<String, String>>();
|
|
Map<String, String> alias;
|
|
|
|
|
|
alias = new HashMap<String, String>();
|
|
alias.put("initialCommand", "/day");
|
|
alias.put("replaceWith", "/ptime day");
|
|
alias.put("permissions", "pandacraft.grade.users"); // multiple permission separated with semicolumn
|
|
CommandAlias_alias.add(alias);
|
|
|
|
alias = new HashMap<String, String>();
|
|
alias.put("initialCommand", "/night");
|
|
alias.put("replaceWith", "/ptime night");
|
|
alias.put("permissions", "pandacraft.grade.users");
|
|
CommandAlias_alias.add(alias);
|
|
|
|
alias = new HashMap<String, String>();
|
|
alias.put("initialCommand", "/time");
|
|
alias.put("replaceWith", "/ptime");
|
|
alias.put("permissions", "pandacraft.grade.users");
|
|
CommandAlias_alias.add(alias);
|
|
|
|
alias = new HashMap<String, String>();
|
|
alias.put("initialCommand", "/shop");
|
|
alias.put("replaceWith", "/warp shop");
|
|
alias.put("permissions", "*"); // tout le monde
|
|
CommandAlias_alias.add(alias);
|
|
|
|
alias = new HashMap<String, String>();
|
|
alias.put("initialCommand", "/lobby");
|
|
alias.put("replaceWith", "/spawn");
|
|
alias.put("permissions", "*"); // tout le monde
|
|
CommandAlias_alias.add(alias);
|
|
|
|
alias = new HashMap<String, String>();
|
|
alias.put("initialCommand", "/hub");
|
|
alias.put("replaceWith", "/spawn");
|
|
alias.put("permissions", "*"); // tout le monde
|
|
CommandAlias_alias.add(alias);
|
|
|
|
alias = new HashMap<String, String>();
|
|
alias.put("initialCommand", "/tete");
|
|
alias.put("replaceWith", "/heads nick");
|
|
alias.put("permissions", "*");
|
|
CommandAlias_alias.add(alias);
|
|
|
|
alias = new HashMap<String, String>();
|
|
alias.put("initialCommand", "/inscription");
|
|
alias.put("replaceWith", "/mail send marcbal Inscription");
|
|
alias.put("permissions", "pandacraft.grade.users");
|
|
CommandAlias_alias.add(alias);
|
|
/*
|
|
Map<String, String> alias = new HashMap<String, String>();
|
|
alias.put("initialCommand", "");
|
|
alias.put("replaceWith", "");
|
|
alias.put("permissions", "");
|
|
CommandAlias_alias.add(alias);
|
|
*/
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
* Multicommand
|
|
*/
|
|
|
|
public Map<String, List<String>> MultiCommand_config;
|
|
|
|
|
|
private void initMultiCommand() {
|
|
/*
|
|
* Format d'un String dans l'ArrayList :
|
|
* T C A /CMD ...
|
|
* - T : temps en tick, depuis l'exécution de la commande /muco
|
|
* - C : "C" si doit être exécuté en tant que la console, autre chose sinon
|
|
* - A : "A" si la commande peut être exécuté en mode asynchrone, autre chose, sinon
|
|
* (T, C et A ne peuvent pas contenir d'espace)
|
|
* /CMD ... correspond à la commande, avec le / devant. Peut contenir $1, $2, ... comme des paramètres
|
|
*/
|
|
|
|
MultiCommand_config = new HashMap<String, List<String>>();
|
|
|
|
List<String> list = new ArrayList<String>();
|
|
list.add("0 - - /pex user $1 remove $2");
|
|
list.add("1 - - /pex user $1 add $3");
|
|
list.add("1 - - /m $1 La mise à jour de votre grade est terminé :) !");
|
|
MultiCommand_config.put("gradejoueur", list);
|
|
|
|
list = new ArrayList<String>();
|
|
list.add("0 - - /region select arenespleef_niv1");
|
|
list.add("1 - - //replace 0 87");
|
|
list.add("2 - - /region select arenespleef_niv2");
|
|
list.add("3 - - //replace 0 87");
|
|
list.add("4 - - /region select arenespleef_niv3");
|
|
list.add("5 - - //replace 0 87");
|
|
list.add("6 - - /region select arenespleef_niv4");
|
|
list.add("7 - - //replace 0 87");
|
|
list.add("8 - - /region select arenespleef_niv5");
|
|
list.add("9 - - //replace 0 87");
|
|
list.add("10 - - /region select arenespleef_niv6");
|
|
list.add("11 - - //replace 0 87");
|
|
list.add("12 - - /region select arenespleef_niv7");
|
|
list.add("13 - - //replace 0 87");
|
|
list.add("14 - - /region select arenespleef_niv8");
|
|
list.add("15 - - //replace 0 87");
|
|
MultiCommand_config.put("arenespleef_reparer", list);
|
|
|
|
list = new ArrayList<String>();
|
|
list.add("0 - - /pex user $1 group add premium");
|
|
list.add("0 - - /m $1 Vous venez de passer Premium :)");
|
|
MultiCommand_config.put("addpremium", list);
|
|
|
|
list = new ArrayList<String>();
|
|
list.add("0 - - /pex user $1 group remove premium");
|
|
MultiCommand_config.put("delpremium", list);
|
|
|
|
list = new ArrayList<String>();
|
|
list.add("0 - - /pex user $1 group add ultimate");
|
|
list.add("0 - - /m $1 Vous venez de recevoir le grade Ultimate, félicitation :)");
|
|
MultiCommand_config.put("addultimate", list);
|
|
|
|
list = new ArrayList<String>();
|
|
list.add("0 - - /pex user $1 group remove ultimate");
|
|
list.add("0 - - /mail send $1 Vous venez de perdre votre grade Ultimate et tous ses avantages car la durée est écoulée.");
|
|
list.add("1 - - /mail send $1 Si vous voulez encore en profiter, rendez vous sur http://mc-pandacraft.net/?p=ultimate");
|
|
MultiCommand_config.put("delultimate", list);
|
|
|
|
list = new ArrayList<String>();
|
|
list.add("0 - - /region select arenepvp_solarene");
|
|
list.add("1 - - //replace 11 20");
|
|
MultiCommand_config.put("arenepvp_proteger_lave", list);
|
|
|
|
list = new ArrayList<String>();
|
|
list.add("0 - - /region select arenepvp_solarene");
|
|
list.add("1 - - //replace 20 11");
|
|
MultiCommand_config.put("arenepvp_remettre_lave", list);
|
|
|
|
list = new ArrayList<String>();
|
|
list.add("0 - - /region select arenepvp_toit");
|
|
list.add("1 - - //replace 20 98");
|
|
MultiCommand_config.put("arenepvp_fermer_fenetre", list);
|
|
|
|
list = new ArrayList<String>();
|
|
list.add("0 - - /region select arenepvp_toit");
|
|
list.add("1 - - //replace 98 20");
|
|
MultiCommand_config.put("arenepvp_ouvrir_fenetre", list);
|
|
|
|
list = new ArrayList<String>();
|
|
list.add("0 C - /broadcast &7Site Web :&a https://www.mc-pandacraft.net/");
|
|
MultiCommand_config.put("site", list);
|
|
|
|
list = new ArrayList<String>();
|
|
list.add("0 C - /broadcast &7Devenir &f[&bMembre&f]&7 :&a http://mc-pandacraft.net/?id=12");
|
|
MultiCommand_config.put("sitemembre", list);
|
|
|
|
list = new ArrayList<String>();
|
|
list.add("0 C - /broadcast Grade &f[&eUltimate&f]&7 :&a http://mc-pandacraft.net/?p=ultimate");
|
|
MultiCommand_config.put("siteultimate", list);
|
|
|
|
list = new ArrayList<String>();
|
|
list.add("0 - - /mv regen Survival_the_end");
|
|
list.add("1 - - /mvconfirm");
|
|
MultiCommand_config.put("new_ender", list);
|
|
|
|
list = new ArrayList<String>();
|
|
list.add("0 - - /mv regen Survival_nether");
|
|
list.add("1 - - /mvconfirm");
|
|
list.add("600 - - /mv regen Faction_nether");
|
|
list.add("601 - - /mvconfirm");
|
|
MultiCommand_config.put("new_nether", list);
|
|
|
|
}
|
|
|
|
|
|
}
|