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);
}
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");
}
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");
}
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);
}
}
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);
}
Aggregations