Class<? extends CraftBookMechanic> mechClass = availableMechanics.get(enabled);
try {
if(mechClass != null) {
CraftBookMechanic mech = mechClass.newInstance();
mech.loadConfiguration(mechanismsConfig, "mechanics." + enabled + ".");
mechanics.add(mech);
}
} catch (Throwable t) {
getLogger().log(Level.WARNING, "Failed to load mechanic: " + enabled, t);
}
}
mechanismsConfig.save();
Iterator<CraftBookMechanic> iter = mechanics.iterator();
while(iter.hasNext()) {
CraftBookMechanic mech = iter.next();
try {
if(!mech.enable()) {
getLogger().warning("Failed to enable mechanic: " + mech.getClass().getSimpleName());
mech.disable();
iter.remove();
continue;
}
getServer().getPluginManager().registerEvents(mech, this);
} catch(Throwable t) {
getLogger().log(Level.WARNING, "Failed to enable mechanic: " + mech.getClass().getSimpleName(), t);
}
}
setupSelfTriggered();
}