Search in sources :

Example 71 with ConfigurationManager

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

the class ActionBarUpdater method getBars.

private String getBars(Player player, long timeLeftMillis) {
    ConfigurationManager configurationManager = this.expansion.getConfigurationManager();
    YamlConfiguration configuration = configurationManager.get("config.yml");
    int scale = configuration.getInt("scale");
    String leftColorString = configuration.getString("left-color", "GREEN");
    String leftSymbol = configuration.getString("left-symbol", "|");
    String rightColorString = configuration.getString("right-color", "RED");
    String rightSymbol = configuration.getString("right-symbol", "|");
    ChatColor leftColor = getChatColor(leftColorString);
    ChatColor rightColor = getChatColor(rightColorString);
    ICombatLogX plugin = getCombatLogX();
    ICombatManager combatManager = plugin.getCombatManager();
    double timerMaxMillis = (combatManager.getMaxTimerSeconds(player) * 1_000L);
    double progressPercent = ((double) timeLeftMillis / timerMaxMillis);
    long leftBarsCount = Math.round(scale * progressPercent);
    long rightBarsCount = (scale - leftBarsCount);
    StringBuilder builder = new StringBuilder();
    builder.append(leftColor);
    for (long i = 0; i < leftBarsCount; i++) {
        builder.append(leftSymbol);
    }
    builder.append(rightColor);
    for (long i = 0; i < rightBarsCount; i++) {
        builder.append(rightSymbol);
    }
    String barsString = builder.toString();
    return MessageUtility.color(barsString);
}
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) ChatColor(net.md_5.bungee.api.ChatColor)

Example 72 with ConfigurationManager

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

the class RegionExpansion method reloadConfig.

@Override
public void reloadConfig() {
    ConfigurationManager configurationManager = getConfigurationManager();
    configurationManager.reload("config.yml");
}
Also used : ConfigurationManager(com.github.sirblobman.api.configuration.ConfigurationManager)

Example 73 with ConfigurationManager

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

the class ListenerConfiguration method isSelfCombatDisabled.

private boolean isSelfCombatDisabled(Player player, LivingEntity enemy) {
    if (enemy == null || doesNotEqual(player, enemy))
        return false;
    ConfigurationManager configurationManager = getPluginConfigurationManager();
    YamlConfiguration configuration = configurationManager.get("config.yml");
    return !configuration.getBoolean("self-combat");
}
Also used : YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration) ConfigurationManager(com.github.sirblobman.api.configuration.ConfigurationManager)

Example 74 with ConfigurationManager

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

the class ListenerConfiguration method runTagCommands.

private void runTagCommands(Player player, LivingEntity enemy) {
    ConfigurationManager configurationManager = getPluginConfigurationManager();
    YamlConfiguration configuration = configurationManager.get("commands.yml");
    ICombatLogX plugin = getCombatLogX();
    ICombatManager combatManager = getCombatManager();
    List<String> tagCommandList = configuration.getStringList("tag-command-list");
    if (tagCommandList.isEmpty())
        return;
    for (String tagCommand : tagCommandList) {
        String replacedCommand = combatManager.replaceVariables(player, enemy, tagCommand);
        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 75 with ConfigurationManager

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

the class ListenerDeath method onJoin.

@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onJoin(PlayerJoinEvent e) {
    ConfigurationManager configurationManager = getPluginConfigurationManager();
    YamlConfiguration configuration = configurationManager.get("punish.yml");
    String killTime = configuration.getString("kill-time");
    if (killTime == null || !killTime.equalsIgnoreCase("join")) {
        return;
    }
    Player player = e.getPlayer();
    PlayerDataManager playerDataManager = getPlayerDataManager();
    YamlConfiguration playerData = playerDataManager.get(player);
    if (!playerData.getBoolean("kill-on-join", false)) {
        return;
    }
    playerData.set("kill-on-join", false);
    playerDataManager.save(player);
    add(player);
    player.setHealth(0.0D);
}
Also used : Player(org.bukkit.entity.Player) YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration) ConfigurationManager(com.github.sirblobman.api.configuration.ConfigurationManager) PlayerDataManager(com.github.sirblobman.api.configuration.PlayerDataManager) EventHandler(org.bukkit.event.EventHandler)

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