use of com.elmakers.mine.bukkit.spell.SpellCategory in project MagicPlugin by elBukkit.
the class MagicController method loadSpell.
@Nullable
public static Spell loadSpell(String name, ConfigurationSection node, MageController controller) {
String className = node.getString("class");
if (className == null || className.equalsIgnoreCase("action") || className.equalsIgnoreCase("actionspell")) {
className = "com.elmakers.mine.bukkit.spell.ActionSpell";
} else if (className.indexOf('.') <= 0) {
className = BUILTIN_SPELL_CLASSPATH + "." + className;
}
Class<?> spellClass = null;
try {
spellClass = Class.forName(className);
} catch (Throwable ex) {
controller.getLogger().log(Level.WARNING, "Error loading spell: " + className, ex);
return null;
}
if (spellClass.getAnnotation(Deprecated.class) != null) {
controller.getLogger().warning("Spell " + name + " is using a deprecated spell class " + className + ". This will be removed in the future, please see the default configs for alternatives.");
}
Object newObject;
try {
newObject = spellClass.getDeclaredConstructor().newInstance();
} catch (Throwable ex) {
controller.getLogger().log(Level.WARNING, "Error loading spell: " + className, ex);
return null;
}
if (newObject == null || !(newObject instanceof MageSpell)) {
controller.getLogger().warning("Error loading spell: " + className + ", does it implement MageSpell?");
return null;
}
MageSpell newSpell = (MageSpell) newObject;
newSpell.initialize(controller);
newSpell.loadTemplate(name, node);
com.elmakers.mine.bukkit.api.spell.SpellCategory category = newSpell.getCategory();
if (category instanceof SpellCategory) {
((SpellCategory) category).addSpellTemplate(newSpell);
}
return newSpell;
}
use of com.elmakers.mine.bukkit.spell.SpellCategory in project MagicPlugin by elBukkit.
the class MagicController method activateMetrics.
protected void activateMetrics() {
// Activate Metrics
final MagicController controller = this;
metrics = null;
if (metricsLevel > 0) {
try {
metrics = new Metrics(plugin);
if (metricsLevel > 1) {
metrics.addCustomChart(new Metrics.MultiLineChart("Plugin Integration") {
@Override
public HashMap<String, Integer> getValues(HashMap<String, Integer> valueMap) {
valueMap.put("Essentials", controller.hasEssentials ? 1 : 0);
valueMap.put("Dynmap", controller.hasDynmap ? 1 : 0);
valueMap.put("Factions", controller.factionsManager.isEnabled() ? 1 : 0);
valueMap.put("WorldGuard", controller.worldGuardManager.isEnabled() ? 1 : 0);
valueMap.put("Elementals", controller.elementalsEnabled() ? 1 : 0);
valueMap.put("Citizens", controller.citizens != null ? 1 : 0);
valueMap.put("CommandBook", controller.hasCommandBook ? 1 : 0);
valueMap.put("PvpManager", controller.pvpManager.isEnabled() ? 1 : 0);
valueMap.put("Multiverse-Core", controller.multiverseManager.isEnabled() ? 1 : 0);
valueMap.put("Towny", controller.townyManager.isEnabled() ? 1 : 0);
valueMap.put("GriefPrevention", controller.griefPreventionManager.isEnabled() ? 1 : 0);
valueMap.put("PreciousStones", controller.preciousStonesManager.isEnabled() ? 1 : 0);
valueMap.put("Lockette", controller.locketteManager.isEnabled() ? 1 : 0);
valueMap.put("NoCheatPlus", controller.ncpManager.isEnabled() ? 1 : 0);
return valueMap;
}
});
metrics.addCustomChart(new Metrics.MultiLineChart("Features Enabled") {
@Override
public HashMap<String, Integer> getValues(HashMap<String, Integer> valueMap) {
valueMap.put("Crafting", controller.crafting.isEnabled() ? 1 : 0);
valueMap.put("Enchanting", controller.enchanting.isEnabled() ? 1 : 0);
valueMap.put("SP", controller.isSPEnabled() ? 1 : 0);
return valueMap;
}
});
}
if (metricsLevel > 2) {
metrics.addCustomChart(new Metrics.MultiLineChart("Total Casts by Category") {
@Override
public HashMap<String, Integer> getValues(HashMap<String, Integer> valueMap) {
for (final SpellCategory category : categories.values()) {
valueMap.put(category.getName(), (int) category.getCastCount());
}
return valueMap;
}
});
}
if (metricsLevel > 3) {
metrics.addCustomChart(new Metrics.MultiLineChart("Total Casts") {
@Override
public HashMap<String, Integer> getValues(HashMap<String, Integer> valueMap) {
for (final SpellTemplate spell : spells.values()) {
if (!(spell instanceof Spell))
continue;
valueMap.put(spell.getName(), (int) ((Spell) spell).getCastCount());
}
return valueMap;
}
});
}
plugin.getLogger().info("Activated BStats");
} catch (Exception ex) {
plugin.getLogger().warning("Failed to load BStats: " + ex.getMessage());
}
}
}
use of com.elmakers.mine.bukkit.spell.SpellCategory in project MagicPlugin by elBukkit.
the class MagicController method getCategory.
@Nullable
@Override
public com.elmakers.mine.bukkit.api.spell.SpellCategory getCategory(String key) {
if (key == null || key.isEmpty()) {
return null;
}
SpellCategory category = categories.get(key);
if (category == null) {
category = new com.elmakers.mine.bukkit.spell.SpellCategory(key, this);
categories.put(key, category);
}
return category;
}
Aggregations