Search in sources :

Example 1 with DuelFeature

use of com.voxelgameslib.voxelgameslib.api.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.api.feature.features.DuelFeature) GameEvent(com.voxelgameslib.voxelgameslib.api.event.GameEvent)

Example 2 with DuelFeature

use of com.voxelgameslib.voxelgameslib.api.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.api.feature.features.TeamFeature) NoSuchFeatureException(com.voxelgameslib.voxelgameslib.api.exception.NoSuchFeatureException) DuelFeature(com.voxelgameslib.voxelgameslib.api.feature.features.DuelFeature)

Aggregations

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