use of com.github.sirblobman.combatlogx.api.ICombatLogX in project CombatLogX by SirBlobman.
the class CMIExpansion method onEnable.
@Override
public void onEnable() {
if (!checkDependency("CMI", true)) {
ICombatLogX plugin = getPlugin();
ExpansionManager expansionManager = plugin.getExpansionManager();
expansionManager.disableExpansion(this);
return;
}
new ListenerCMI(this).register();
}
use of com.github.sirblobman.combatlogx.api.ICombatLogX in project CombatLogX by SirBlobman.
the class ListenerGameMode method checkUntag.
private void checkUntag(Player player) {
if (!shouldUntagOnSwitch())
return;
ICombatLogX plugin = getCombatLogX();
ICombatManager combatManager = plugin.getCombatManager();
combatManager.untag(player, UntagReason.EXPIRE);
}
use of com.github.sirblobman.combatlogx.api.ICombatLogX in project CombatLogX by SirBlobman.
the class ExpansionLogger method log.
@Override
public void log(LogRecord record) {
Expansion expansion = getExpansion();
String expansionPrefix = expansion.getPrefix();
ICombatLogX combatLogX = expansion.getPlugin();
JavaPlugin plugin = combatLogX.getPlugin();
String pluginName = plugin.getName();
String originalMessage = record.getMessage();
String newMessage = ("[" + expansionPrefix + "] " + originalMessage);
record.setMessage(newMessage);
record.setLoggerName(pluginName);
Logger logger = plugin.getLogger();
logger.log(record);
}
use of com.github.sirblobman.combatlogx.api.ICombatLogX in project CombatLogX by SirBlobman.
the class ExpansionManager method enableExpansions.
public void enableExpansions() {
ICombatLogX plugin = getPlugin();
Logger logger = plugin.getLogger();
logger.info("Enabling expansions...");
List<Expansion> loadedExpansionList = getLoadedExpansions();
if (loadedExpansionList.isEmpty()) {
logger.info("There were no expansions to enable.");
return;
}
sortExpansions(loadedExpansionList);
List<Expansion> lateLoadExpansionList = new ArrayList<>();
for (Expansion expansion : loadedExpansionList) {
ExpansionDescription description = expansion.getDescription();
if (description.isLateLoad()) {
lateLoadExpansionList.add(expansion);
continue;
}
enableExpansion(expansion);
logger.info(" ");
}
List<Expansion> enabledExpansionList = getEnabledExpansions();
int expansionListSize = enabledExpansionList.size();
String message = ("Successfully enabled " + expansionListSize + " expansion" + (expansionListSize == 1 ? "" : "s") + ".");
logger.info(message);
Runnable task = () -> {
for (Expansion expansion : lateLoadExpansionList) {
enableExpansion(expansion);
logger.info(" ");
}
List<Expansion> newEnabledExpansionList = getEnabledExpansions();
int newExpansionListSize = newEnabledExpansionList.size();
int newExpansionCount = (newExpansionListSize - expansionListSize);
String newMessage = ("Successfully enabled " + newExpansionCount + " late-load expansion" + (expansionListSize == 1 ? "" : "s") + ".");
logger.info(newMessage);
};
JavaPlugin javaPlugin = getPlugin().getPlugin();
BukkitScheduler scheduler = Bukkit.getScheduler();
scheduler.scheduleSyncDelayedTask(javaPlugin, task, 1L);
}
use of com.github.sirblobman.combatlogx.api.ICombatLogX in project CombatLogX by SirBlobman.
the class ExpansionManager method loadExpansions.
public void loadExpansions() {
ICombatLogX plugin = getPlugin();
Logger logger = plugin.getLogger();
logger.info("Loading expansions...");
File dataFolder = plugin.getDataFolder();
if (!dataFolder.exists() && !dataFolder.mkdirs()) {
logger.warning("The CombatLogX folder does not exist and could not be created!");
return;
}
File expansionsFolder = new File(dataFolder, "expansions");
if (!expansionsFolder.exists() && !expansionsFolder.mkdirs()) {
logger.warning("The expansions folder does not exist and could not be created!");
return;
}
FilenameFilter filter = (folder, fileName) -> fileName.endsWith(".jar");
File[] fileArray = expansionsFolder.listFiles(filter);
if (fileArray == null || fileArray.length == 0) {
logger.info("There were no expansions to load.");
return;
}
for (File file : fileArray) {
if (file.isDirectory())
continue;
loadExpansion(file);
logger.info(" ");
}
List<Expansion> expansionList = sortExpansions(getLoadedExpansions());
int expansionListSize = expansionList.size();
String message = ("Successfully loaded " + expansionListSize + " expansion" + (expansionListSize == 1 ? "" : "s") + ".");
logger.info(message);
}
Aggregations