Search in sources :

Example 1 with DuelFeature

use of com.voxelgameslib.voxelgameslib.feature.features.DuelFeature in project VoxelGamesLibv2 by VoxelGamesLib.

the class AbstractGame method handleElo.

private void handleElo(@Nullable Team winnerTeam, @Nullable User winnerUser) {
    boolean handled = false;
    if (winnerTeam != null) {
        try {
            TeamFeature teamFeature = getActivePhase().getFeature(TeamFeature.class);
            eloHandler.handleGameEnd(this, teamFeature);
            handled = true;
        } catch (NoSuchFeatureException ignored) {
        }
    }
    if (!handled && winnerUser != null) {
        try {
            DuelFeature duelFeature = getActivePhase().getFeature(DuelFeature.class);
            eloHandler.handleGameEnd(this, duelFeature, winnerUser);
            handled = true;
        } catch (NoSuchFeatureException ignored) {
        }
    }
    if (!handled) {
        if (winnerUser != null) {
            eloHandler.handleGameEnd(this, winnerUser);
        } else {
            log.warning("Could not distribute any elo!");
        }
    }
}
Also used : TeamFeature(com.voxelgameslib.voxelgameslib.feature.features.TeamFeature) NoSuchFeatureException(com.voxelgameslib.voxelgameslib.exception.NoSuchFeatureException) DuelFeature(com.voxelgameslib.voxelgameslib.feature.features.DuelFeature)

Example 2 with DuelFeature

use of com.voxelgameslib.voxelgameslib.feature.features.DuelFeature in project VoxelGamesLibv2 by VoxelGamesLib.

the class DuelVictoryCondition method onDeath.

@GameEvent
public void onDeath(@Nonnull PlayerDeathEvent e) {
    if (completed())
        return;
    DuelFeature duelFeature = getPhase().getFeature(DuelFeature.class);
    winner = duelFeature.getOther(e.getEntity().getUniqueId());
}
Also used : DuelFeature(com.voxelgameslib.voxelgameslib.feature.features.DuelFeature) GameEvent(com.voxelgameslib.voxelgameslib.event.GameEvent)

Aggregations

DuelFeature (com.voxelgameslib.voxelgameslib.feature.features.DuelFeature)2 GameEvent (com.voxelgameslib.voxelgameslib.event.GameEvent)1 NoSuchFeatureException (com.voxelgameslib.voxelgameslib.exception.NoSuchFeatureException)1 TeamFeature (com.voxelgameslib.voxelgameslib.feature.features.TeamFeature)1