Search in sources :

Example 26 with ConfigurationManager

use of com.github.sirblobman.api.configuration.ConfigurationManager in project CombatLogX by SirBlobman.

the class ListenerDeath method getRandomDeathMessage.

private String getRandomDeathMessage(Player player) {
    ConfigurationManager configurationManager = getPluginConfigurationManager();
    YamlConfiguration configuration = configurationManager.get("punish.yml");
    List<String> customDeathMessageList = configuration.getStringList("custom-death-message-list");
    if (customDeathMessageList.isEmpty()) {
        return null;
    }
    ThreadLocalRandom random = ThreadLocalRandom.current();
    int customDeathMessageListSize = customDeathMessageList.size();
    int customDeathMessageIndex = random.nextInt(customDeathMessageListSize);
    String customDeathMessage = customDeathMessageList.get(customDeathMessageIndex);
    String playerName = player.getName();
    return customDeathMessage.replace("{player}", playerName);
}
Also used : ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration) ConfigurationManager(com.github.sirblobman.api.configuration.ConfigurationManager)

Example 27 with ConfigurationManager

use of com.github.sirblobman.api.configuration.ConfigurationManager in project CombatLogX by SirBlobman.

the class ListenerPunish method shouldPunishForReason.

private boolean shouldPunishForReason(UntagReason reason) {
    ConfigurationManager configurationManager = getPluginConfigurationManager();
    YamlConfiguration configuration = configurationManager.get("punish.yml");
    if (reason.isExpire()) {
        return configuration.getBoolean("on-expire");
    }
    if (reason == UntagReason.KICK) {
        return configuration.getBoolean("on-kick");
    }
    if (reason == UntagReason.QUIT) {
        return configuration.getBoolean("on-disconnect");
    }
    return false;
}
Also used : YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration) ConfigurationManager(com.github.sirblobman.api.configuration.ConfigurationManager)

Example 28 with ConfigurationManager

use of com.github.sirblobman.api.configuration.ConfigurationManager in project CombatLogX by SirBlobman.

the class ListenerUntag method runUntagCommands.

private void runUntagCommands(Player player, LivingEntity previousEnemy) {
    ConfigurationManager configurationManager = getPluginConfigurationManager();
    YamlConfiguration configuration = configurationManager.get("commands.yml");
    List<String> untagCommandList = configuration.getStringList("untag-command-list");
    if (untagCommandList.isEmpty()) {
        return;
    }
    ICombatLogX plugin = getCombatLogX();
    ICombatManager combatManager = getCombatManager();
    for (String untagCommand : untagCommandList) {
        String replacedCommand = combatManager.replaceVariables(player, previousEnemy, untagCommand);
        if (replacedCommand.startsWith("[PLAYER]")) {
            String command = replacedCommand.substring("[PLAYER]".length());
            CommandHelper.runAsPlayer(plugin, player, command);
            continue;
        }
        if (replacedCommand.startsWith("[OP]")) {
            String command = replacedCommand.substring("[OP]".length());
            CommandHelper.runAsOperator(plugin, player, command);
            continue;
        }
        CommandHelper.runAsConsole(plugin, replacedCommand);
    }
}
Also used : ICombatManager(com.github.sirblobman.combatlogx.api.manager.ICombatManager) ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX) YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration) ConfigurationManager(com.github.sirblobman.api.configuration.ConfigurationManager)

Example 29 with ConfigurationManager

use of com.github.sirblobman.api.configuration.ConfigurationManager in project CombatLogX by SirBlobman.

the class ListenerUntag method isKickReasonIgnored.

private boolean isKickReasonIgnored(String kickReason) {
    ICombatLogX plugin = getCombatLogX();
    ConfigurationManager configurationManager = plugin.getConfigurationManager();
    YamlConfiguration configuration = configurationManager.get("punish.yml");
    List<String> kickIgnoreList = configuration.getStringList("kick-ignore-list");
    if (kickIgnoreList.isEmpty()) {
        return false;
    }
    for (String kickIgnoreMessage : kickIgnoreList) {
        if (kickReason.contains(kickIgnoreMessage)) {
            return true;
        }
    }
    return false;
}
Also used : ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX) YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration) ConfigurationManager(com.github.sirblobman.api.configuration.ConfigurationManager)

Example 30 with ConfigurationManager

use of com.github.sirblobman.api.configuration.ConfigurationManager in project CombatLogX by SirBlobman.

the class CombatManager method getGlobalTimerSeconds.

private int getGlobalTimerSeconds() {
    ConfigurationManager configurationManager = this.plugin.getConfigurationManager();
    YamlConfiguration configuration = configurationManager.get("config.yml");
    return configuration.getInt("timer.default-timer", 10);
}
Also used : YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration) ConfigurationManager(com.github.sirblobman.api.configuration.ConfigurationManager)

Aggregations

ConfigurationManager (com.github.sirblobman.api.configuration.ConfigurationManager)117 YamlConfiguration (org.bukkit.configuration.file.YamlConfiguration)62 Expansion (com.github.sirblobman.combatlogx.api.expansion.Expansion)20 ICombatLogX (com.github.sirblobman.combatlogx.api.ICombatLogX)10 PlayerDataManager (com.github.sirblobman.api.configuration.PlayerDataManager)6 LanguageManager (com.github.sirblobman.api.language.LanguageManager)6 Player (org.bukkit.entity.Player)6 EventHandler (org.bukkit.event.EventHandler)6 ICombatManager (com.github.sirblobman.combatlogx.api.manager.ICombatManager)5 Entity (org.bukkit.entity.Entity)4 LoggerExpansion (combatlogx.expansion.logger.LoggerExpansion)3 LivingEntity (org.bukkit.entity.LivingEntity)3 PluginManager (org.bukkit.plugin.PluginManager)3 ExpansionManager (com.github.sirblobman.combatlogx.api.expansion.ExpansionManager)2 IDeathListener (com.github.sirblobman.combatlogx.api.listener.IDeathListener)2 MobTaggerExpansion (combatlogx.expansion.mob.tagger.MobTaggerExpansion)2 ScoreboardExpansion (combatlogx.expansion.scoreboard.ScoreboardExpansion)2 SimpleDateFormat (java.text.SimpleDateFormat)2 Date (java.util.Date)2 UUID (java.util.UUID)2