Search in sources :

Example 36 with ICombatLogX

use of com.github.sirblobman.combatlogx.api.ICombatLogX in project CombatLogX by SirBlobman.

the class CMIExpansion method onEnable.

@Override
public void onEnable() {
    if (!checkDependency("CMI", true)) {
        ICombatLogX plugin = getPlugin();
        ExpansionManager expansionManager = plugin.getExpansionManager();
        expansionManager.disableExpansion(this);
        return;
    }
    new ListenerCMI(this).register();
}
Also used : ListenerCMI(combatlogx.expansion.compatibility.cmi.listener.ListenerCMI) ExpansionManager(com.github.sirblobman.combatlogx.api.expansion.ExpansionManager) ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX)

Example 37 with ICombatLogX

use of com.github.sirblobman.combatlogx.api.ICombatLogX in project CombatLogX by SirBlobman.

the class ListenerGameMode method checkUntag.

private void checkUntag(Player player) {
    if (!shouldUntagOnSwitch())
        return;
    ICombatLogX plugin = getCombatLogX();
    ICombatManager combatManager = plugin.getCombatManager();
    combatManager.untag(player, UntagReason.EXPIRE);
}
Also used : ICombatManager(com.github.sirblobman.combatlogx.api.manager.ICombatManager) ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX)

Example 38 with ICombatLogX

use of com.github.sirblobman.combatlogx.api.ICombatLogX in project CombatLogX by SirBlobman.

the class ExpansionLogger method log.

@Override
public void log(LogRecord record) {
    Expansion expansion = getExpansion();
    String expansionPrefix = expansion.getPrefix();
    ICombatLogX combatLogX = expansion.getPlugin();
    JavaPlugin plugin = combatLogX.getPlugin();
    String pluginName = plugin.getName();
    String originalMessage = record.getMessage();
    String newMessage = ("[" + expansionPrefix + "] " + originalMessage);
    record.setMessage(newMessage);
    record.setLoggerName(pluginName);
    Logger logger = plugin.getLogger();
    logger.log(record);
}
Also used : JavaPlugin(org.bukkit.plugin.java.JavaPlugin) ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX) Logger(java.util.logging.Logger)

Example 39 with ICombatLogX

use of com.github.sirblobman.combatlogx.api.ICombatLogX in project CombatLogX by SirBlobman.

the class ExpansionManager method enableExpansions.

public void enableExpansions() {
    ICombatLogX plugin = getPlugin();
    Logger logger = plugin.getLogger();
    logger.info("Enabling expansions...");
    List<Expansion> loadedExpansionList = getLoadedExpansions();
    if (loadedExpansionList.isEmpty()) {
        logger.info("There were no expansions to enable.");
        return;
    }
    sortExpansions(loadedExpansionList);
    List<Expansion> lateLoadExpansionList = new ArrayList<>();
    for (Expansion expansion : loadedExpansionList) {
        ExpansionDescription description = expansion.getDescription();
        if (description.isLateLoad()) {
            lateLoadExpansionList.add(expansion);
            continue;
        }
        enableExpansion(expansion);
        logger.info(" ");
    }
    List<Expansion> enabledExpansionList = getEnabledExpansions();
    int expansionListSize = enabledExpansionList.size();
    String message = ("Successfully enabled " + expansionListSize + " expansion" + (expansionListSize == 1 ? "" : "s") + ".");
    logger.info(message);
    Runnable task = () -> {
        for (Expansion expansion : lateLoadExpansionList) {
            enableExpansion(expansion);
            logger.info(" ");
        }
        List<Expansion> newEnabledExpansionList = getEnabledExpansions();
        int newExpansionListSize = newEnabledExpansionList.size();
        int newExpansionCount = (newExpansionListSize - expansionListSize);
        String newMessage = ("Successfully enabled " + newExpansionCount + " late-load expansion" + (expansionListSize == 1 ? "" : "s") + ".");
        logger.info(newMessage);
    };
    JavaPlugin javaPlugin = getPlugin().getPlugin();
    BukkitScheduler scheduler = Bukkit.getScheduler();
    scheduler.scheduleSyncDelayedTask(javaPlugin, task, 1L);
}
Also used : ArrayList(java.util.ArrayList) JavaPlugin(org.bukkit.plugin.java.JavaPlugin) BukkitScheduler(org.bukkit.scheduler.BukkitScheduler) ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX) HandlerList(org.bukkit.event.HandlerList) ArrayList(java.util.ArrayList) List(java.util.List) Logger(java.util.logging.Logger)

Example 40 with ICombatLogX

use of com.github.sirblobman.combatlogx.api.ICombatLogX in project CombatLogX by SirBlobman.

the class ExpansionManager method loadExpansions.

public void loadExpansions() {
    ICombatLogX plugin = getPlugin();
    Logger logger = plugin.getLogger();
    logger.info("Loading expansions...");
    File dataFolder = plugin.getDataFolder();
    if (!dataFolder.exists() && !dataFolder.mkdirs()) {
        logger.warning("The CombatLogX folder does not exist and could not be created!");
        return;
    }
    File expansionsFolder = new File(dataFolder, "expansions");
    if (!expansionsFolder.exists() && !expansionsFolder.mkdirs()) {
        logger.warning("The expansions folder does not exist and could not be created!");
        return;
    }
    FilenameFilter filter = (folder, fileName) -> fileName.endsWith(".jar");
    File[] fileArray = expansionsFolder.listFiles(filter);
    if (fileArray == null || fileArray.length == 0) {
        logger.info("There were no expansions to load.");
        return;
    }
    for (File file : fileArray) {
        if (file.isDirectory())
            continue;
        loadExpansion(file);
        logger.info(" ");
    }
    List<Expansion> expansionList = sortExpansions(getLoadedExpansions());
    int expansionListSize = expansionList.size();
    String message = ("Successfully loaded " + expansionListSize + " expansion" + (expansionListSize == 1 ? "" : "s") + ".");
    logger.info(message);
}
Also used : HandlerList(org.bukkit.event.HandlerList) Plugin(org.bukkit.plugin.Plugin) FilenameFilter(java.io.FilenameFilter) HashMap(java.util.HashMap) JarFile(java.util.jar.JarFile) ArrayList(java.util.ArrayList) Level(java.util.logging.Level) JarEntry(java.util.jar.JarEntry) Validate(com.github.sirblobman.api.utility.Validate) Map(java.util.Map) Bukkit(org.bukkit.Bukkit) Listener(org.bukkit.event.Listener) BukkitScheduler(org.bukkit.scheduler.BukkitScheduler) Collection(java.util.Collection) IOException(java.io.IOException) Logger(java.util.logging.Logger) InputStreamReader(java.io.InputStreamReader) Collectors(java.util.stream.Collectors) ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX) File(java.io.File) Objects(java.util.Objects) JavaPlugin(org.bukkit.plugin.java.JavaPlugin) List(java.util.List) State(com.github.sirblobman.combatlogx.api.expansion.Expansion.State) YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration) Optional(java.util.Optional) BufferedReader(java.io.BufferedReader) Comparator(java.util.Comparator) InvalidConfigurationException(org.bukkit.configuration.InvalidConfigurationException) InputStream(java.io.InputStream) PluginManager(org.bukkit.plugin.PluginManager) FilenameFilter(java.io.FilenameFilter) ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX) Logger(java.util.logging.Logger) JarFile(java.util.jar.JarFile) File(java.io.File)

Aggregations

ICombatLogX (com.github.sirblobman.combatlogx.api.ICombatLogX)96 ExpansionManager (com.github.sirblobman.combatlogx.api.expansion.ExpansionManager)24 ICombatManager (com.github.sirblobman.combatlogx.api.manager.ICombatManager)19 YamlConfiguration (org.bukkit.configuration.file.YamlConfiguration)19 Player (org.bukkit.entity.Player)18 JavaPlugin (org.bukkit.plugin.java.JavaPlugin)14 LivingEntity (org.bukkit.entity.LivingEntity)13 LanguageManager (com.github.sirblobman.api.language.LanguageManager)12 Logger (java.util.logging.Logger)11 ConfigurationManager (com.github.sirblobman.api.configuration.ConfigurationManager)10 MultiVersionHandler (com.github.sirblobman.api.nms.MultiVersionHandler)9 PlayerDataManager (com.github.sirblobman.api.configuration.PlayerDataManager)8 Expansion (com.github.sirblobman.combatlogx.api.expansion.Expansion)8 List (java.util.List)8 Replacer (com.github.sirblobman.api.language.Replacer)6 EntityHandler (com.github.sirblobman.api.nms.EntityHandler)5 State (com.github.sirblobman.combatlogx.api.expansion.Expansion.State)5 Collections (java.util.Collections)5 EventHandler (org.bukkit.event.EventHandler)5 NewbieHelperExpansion (combatlogx.expansion.newbie.helper.NewbieHelperExpansion)4