Search in sources :

Example 1 with Expansion

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

the class ListenerDamage method isDisabled.

private boolean isDisabled(DamageCause damageCause) {
    Expansion expansion = getExpansion();
    ConfigurationManager configurationManager = expansion.getConfigurationManager();
    YamlConfiguration configuration = configurationManager.get("config.yml");
    if (configuration.getBoolean("all-damage"))
        return false;
    String damageCauseName = damageCause.name().toLowerCase();
    return !configuration.getBoolean("damage-type." + damageCauseName);
}
Also used : YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration) Expansion(com.github.sirblobman.combatlogx.api.expansion.Expansion) DamageTaggerExpansion(combatlogx.expansion.damage.tagger.DamageTaggerExpansion) ConfigurationManager(com.github.sirblobman.api.configuration.ConfigurationManager)

Example 2 with Expansion

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

the class ListenerLogger method appendLog.

private void appendLog(String... messageArray) {
    Expansion expansion = getExpansion();
    Logger logger = expansion.getLogger();
    try {
        File dataFolder = expansion.getDataFolder();
        if (!dataFolder.exists() && !dataFolder.mkdirs()) {
            logger.warning("Could not create expansion folder!");
            return;
        }
        String logFileName = getLogFileName();
        File logFile = new File(dataFolder, logFileName);
        if (!logFile.exists() && !logFile.createNewFile()) {
            logger.warning("Could not create log file!");
            return;
        }
        Path logPath = logFile.toPath();
        List<String> messageList = Arrays.asList(messageArray);
        Files.write(logPath, messageList, StandardCharsets.UTF_8, StandardOpenOption.APPEND);
    } catch (IOException ex) {
        logger.log(Level.WARNING, "An error occurred while appending a message to a log file:", ex);
    }
}
Also used : Path(java.nio.file.Path) IOException(java.io.IOException) Logger(java.util.logging.Logger) Expansion(com.github.sirblobman.combatlogx.api.expansion.Expansion) LoggerExpansion(combatlogx.expansion.logger.LoggerExpansion) File(java.io.File)

Example 3 with Expansion

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

the class ListenerLogger method getLoggerFormat.

private String getLoggerFormat(String path) {
    Expansion expansion = getExpansion();
    ConfigurationManager configurationManager = expansion.getConfigurationManager();
    YamlConfiguration configuration = configurationManager.get("config.yml");
    String prefixFormat = configuration.getString("log-entry-options.prefix-format");
    if (prefixFormat == null)
        prefixFormat = "[MMMM dd, YYYY HH:mm:ss.SSSa zzz] ";
    SimpleDateFormat format = new SimpleDateFormat(prefixFormat);
    String prefix = format.format(new Date(System.currentTimeMillis()));
    String messageFormat = configuration.getString("log-entry-options." + path);
    if (messageFormat == null)
        messageFormat = "";
    return (prefix + messageFormat);
}
Also used : YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration) Expansion(com.github.sirblobman.combatlogx.api.expansion.Expansion) LoggerExpansion(combatlogx.expansion.logger.LoggerExpansion) ConfigurationManager(com.github.sirblobman.api.configuration.ConfigurationManager) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Example 4 with Expansion

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

the class ListenerDamage method isDisabled.

private boolean isDisabled(SpawnReason spawnReason) {
    if (spawnReason == null) {
        return true;
    }
    Expansion expansion = getExpansion();
    ConfigurationManager configurationManager = expansion.getConfigurationManager();
    YamlConfiguration configuration = configurationManager.get("config.yml");
    List<String> spawnReasonList = configuration.getStringList("spawn-reason-list");
    String spawnReasonName = spawnReason.name();
    return spawnReasonList.contains(spawnReasonName);
}
Also used : YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration) MobTaggerExpansion(combatlogx.expansion.mob.tagger.MobTaggerExpansion) Expansion(com.github.sirblobman.combatlogx.api.expansion.Expansion) ConfigurationManager(com.github.sirblobman.api.configuration.ConfigurationManager)

Example 5 with Expansion

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

the class ListenerDamage method isDisabled.

private boolean isDisabled(EntityType entityType) {
    if (entityType == null || entityType == EntityType.PLAYER || !entityType.isAlive()) {
        return true;
    }
    Expansion expansion = getExpansion();
    ConfigurationManager configurationManager = expansion.getConfigurationManager();
    YamlConfiguration configuration = configurationManager.get("config.yml");
    List<String> mobList = configuration.getStringList("mob-list");
    if (mobList.contains("*")) {
        return false;
    }
    String entityTypeName = entityType.name();
    return !mobList.contains(entityTypeName);
}
Also used : YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration) MobTaggerExpansion(combatlogx.expansion.mob.tagger.MobTaggerExpansion) Expansion(com.github.sirblobman.combatlogx.api.expansion.Expansion) ConfigurationManager(com.github.sirblobman.api.configuration.ConfigurationManager)

Aggregations

Expansion (com.github.sirblobman.combatlogx.api.expansion.Expansion)31 ConfigurationManager (com.github.sirblobman.api.configuration.ConfigurationManager)20 YamlConfiguration (org.bukkit.configuration.file.YamlConfiguration)10 ICombatLogX (com.github.sirblobman.combatlogx.api.ICombatLogX)6 ExpansionManager (com.github.sirblobman.combatlogx.api.expansion.ExpansionManager)6 NewbieHelperExpansion (combatlogx.expansion.newbie.helper.NewbieHelperExpansion)6 LoggerExpansion (combatlogx.expansion.logger.LoggerExpansion)4 State (com.github.sirblobman.combatlogx.api.expansion.Expansion.State)3 MobTaggerExpansion (combatlogx.expansion.mob.tagger.MobTaggerExpansion)3 PlaceholderExpansion (me.clip.placeholderapi.expansion.PlaceholderExpansion)3 LanguageManager (com.github.sirblobman.api.language.LanguageManager)2 PVPManager (combatlogx.expansion.newbie.helper.manager.PVPManager)2 ProtectionManager (combatlogx.expansion.newbie.helper.manager.ProtectionManager)2 SimpleDateFormat (java.text.SimpleDateFormat)2 Date (java.util.Date)2 HashSet (java.util.HashSet)2 Replacer (com.github.sirblobman.api.language.Replacer)1 MessageUtility (com.github.sirblobman.api.utility.MessageUtility)1 CombatLogCommand (com.github.sirblobman.combatlogx.api.command.CombatLogCommand)1 ExpansionDescription (com.github.sirblobman.combatlogx.api.expansion.ExpansionDescription)1