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