236 lines
6.5 KiB
Java
236 lines
6.5 KiB
Java
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;
|
|
|
|
/*
|
|
* 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();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
* Découpe une chaine de caractère contenant une série de noeuds
|
|
* de permissions séparés par des point-virgules et la retourne sous forme d'une liste.
|
|
* @param perms la chaine de permissions à traiter
|
|
* @return <code>null</code> si le paramètre est nulle ou si <code>perms.equals("*")</code>, ou alors la chaine splittée.
|
|
*/
|
|
public static List<String> splitPermissionsString(String perms) {
|
|
if (perms == null || perms.equals("*"))
|
|
return null;
|
|
else
|
|
return Arrays.asList(perms.split(";"));
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private PandacraftUtils plugin = PandacraftUtils.getInstance();
|
|
|
|
public final DefaultConfig defaultConfig;
|
|
public final WorldBorderConfig worldBorderConfig;
|
|
public final ChatBadWordsConfig chatBadWordsConfig;
|
|
public final AutoMessagesConfig autoMessagesConfig;
|
|
public final CommandAliasConfig commandAliasConfig;
|
|
|
|
|
|
|
|
|
|
|
|
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();
|
|
commandAliasConfig = new CommandAliasConfig();
|
|
|
|
|
|
|
|
// dossier qui doit contenir les séries de commandes
|
|
File multiCommandsDir = new File(configDir, "multicommands");
|
|
multiCommandsDir.mkdir();
|
|
|
|
|
|
|
|
initMultiCommand();
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
* 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);
|
|
|
|
}
|
|
|
|
|
|
}
|