use of com.voxelgameslib.voxelgameslib.components.ability.Ability in project VoxelGamesLibv2 by VoxelGamesLib.
the class KitFeature method enable.
/**
* @see AbstractFeature#enable()
*/
@Override
public void enable() {
if (registerCommands) {
commandManager.registerCommand(injector.getInstance(KitCommands.class));
}
if (allowedKits.size() == 0) {
allowedKits.add("DefaultKit");
}
// try to load kits
allowedKits.forEach(kit -> {
Optional<Kit> k = kitHandler.loadKit(kit);
if (k.isPresent()) {
kits.add(k.get());
} else {
log.warning("Could not find kit " + kit);
}
});
kits.forEach(kit -> {
if (kit.getAbilities() != null) {
for (Ability ability : kit.getAbilities().values()) {
Bukkit.getPluginManager().registerEvents(ability, voxelGamesLib);
}
}
});
}
use of com.voxelgameslib.voxelgameslib.components.ability.Ability in project VoxelGamesLibv2 by VoxelGamesLib.
the class AbstractPhase method disable.
@Override
public void disable() {
// disable timer
duration = Duration.between(startTime, LocalDateTime.now());
log.finer("disable phase " + getName());
// only disable features that have been started to avoid errors
for (Feature feature : startedFeatures) {
log.finer("disable " + feature.getName());
try {
feature.disable();
} catch (Exception ex) {
log.severe("error while stopping " + feature.getName());
ex.printStackTrace();
return;
}
if (feature instanceof Listener) {
eventHandler.unregister((Listener) feature, getGame());
}
if (feature instanceof FeatureCommandImplementor) {
AbstractFeatureCommand cmd = injector.getInstance(((FeatureCommandImplementor) feature).getCommandClass());
commandHandler.unregister(cmd, this);
}
}
for (VictoryCondition victoryCondition : victoryConditions) {
if (victoryCondition instanceof Listener) {
eventHandler.registerEvents((Listener) victoryCondition, getGame());
}
}
phaseTickables.values().forEach(tickable -> {
tickable.disable();
if (tickable instanceof Ability) {
((Ability) tickable).unregister();
}
});
startedFeatures.clear();
}
Aggregations