Search in sources :

Example 46 with ICombatLogX

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

the class CombatListener method isWorldDisabled.

protected final boolean isWorldDisabled(World world) {
    ICombatLogX plugin = getCombatLogX();
    ConfigurationManager configurationManager = plugin.getConfigurationManager();
    YamlConfiguration configuration = configurationManager.get("config.yml");
    List<String> disabledWorldList = configuration.getStringList("disabled-world-list");
    boolean inverted = configuration.getBoolean("disabled-world-list-inverted");
    String worldName = world.getName();
    boolean contains = disabledWorldList.contains(worldName);
    return (inverted != contains);
}
Also used : ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX) YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration) ConfigurationManager(com.github.sirblobman.api.configuration.ConfigurationManager)

Example 47 with ICombatLogX

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

the class CombatLogCommand method isWorldDisabled.

protected final boolean isWorldDisabled(World world) {
    ICombatLogX plugin = getCombatLogX();
    ConfigurationManager configurationManager = plugin.getConfigurationManager();
    YamlConfiguration configuration = configurationManager.get("config.yml");
    List<String> disabledWorldList = configuration.getStringList("disabled-world-list");
    boolean inverted = configuration.getBoolean("disabled-world-list-inverted");
    String worldName = world.getName();
    boolean contains = disabledWorldList.contains(worldName);
    return (inverted != contains);
}
Also used : ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX) YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration) ConfigurationManager(com.github.sirblobman.api.configuration.ConfigurationManager)

Example 48 with ICombatLogX

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

the class CombatLogPlayerCommand method getMessageWithPrefix.

protected final String getMessageWithPrefix(@Nullable CommandSender sender, @NotNull String key, @Nullable Replacer replacer, boolean color) {
    ICombatLogX plugin = getCombatLogX();
    LanguageManager languageManager = plugin.getLanguageManager();
    String message = languageManager.getMessage(sender, key, replacer, color);
    if (message.isEmpty())
        return "";
    String prefix = languageManager.getMessage(sender, "prefix", null, true);
    return (prefix.isEmpty() ? message : String.format(Locale.US, "%s %s", prefix, message));
}
Also used : LanguageManager(com.github.sirblobman.api.language.LanguageManager) ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX)

Example 49 with ICombatLogX

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

the class ActionBarUpdater method getPlayerHandler.

private PlayerHandler getPlayerHandler() {
    ICombatLogX combatLogX = getCombatLogX();
    MultiVersionHandler multiVersionHandler = combatLogX.getMultiVersionHandler();
    return multiVersionHandler.getPlayerHandler();
}
Also used : MultiVersionHandler(com.github.sirblobman.api.nms.MultiVersionHandler) ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX)

Example 50 with ICombatLogX

use of com.github.sirblobman.combatlogx.api.ICombatLogX 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)

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