Search in sources :

Example 11 with Participator

use of pl.themolka.arcade.game.Participator in project Arcade2 by ShootGame.

the class KillEnemiesGame method onEnable.

@Override
public void onEnable() {
    MatchGame module = (MatchGame) this.getGame().getModule(MatchModule.class);
    this.match = module.getMatch();
    this.match.registerDynamicWinnable(this);
    for (Map.Entry<Participator, KillEnemies> entry : this.byOwner.entrySet()) {
        MatchWinner winner = this.match.findWinnerById(entry.getKey().getId());
        if (winner == null) {
            continue;
        }
        winner.addGoal(entry.getValue());
    }
}
Also used : Participator(pl.themolka.arcade.game.Participator) MatchGame(pl.themolka.arcade.match.MatchGame) MatchWinner(pl.themolka.arcade.match.MatchWinner) MatchModule(pl.themolka.arcade.match.MatchModule) HashMap(java.util.HashMap) Map(java.util.Map)

Example 12 with Participator

use of pl.themolka.arcade.game.Participator in project Arcade2 by ShootGame.

the class Core method detectBreak.

// 
// Listeners
// 
@Handler(priority = Priority.NORMAL)
public void detectBreak(BlockTransformEvent event) {
    if (event.isCanceled()) {
        return;
    }
    Block block = event.getBlock();
    if (!event.getNewState().getMaterial().equals(Material.AIR) || this.isCompleted() || !this.contains(block) || this.getLiquid().accepts(event.getNewState().getMaterial())) {
        return;
    }
    GamePlayer player = event.getGamePlayer();
    if (player == null) {
        event.setCanceled(true);
        return;
    }
    Participator winner = this.game.getMatch().findWinnerByPlayer(player);
    if (this.getOwner().equals(winner)) {
        event.setCanceled(true);
        player.sendError("You may not damage your own " + ChatColor.GOLD + this.getColoredName() + Messageable.ERROR_COLOR + ".");
        return;
    }
    if (!this.breakPiece(winner, player, block)) {
        event.setCanceled(true);
    }
}
Also used : Participator(pl.themolka.arcade.game.Participator) GamePlayer(pl.themolka.arcade.game.GamePlayer) Block(org.bukkit.block.Block) Handler(net.engio.mbassy.listener.Handler) EventHandler(org.bukkit.event.EventHandler)

Example 13 with Participator

use of pl.themolka.arcade.game.Participator in project Arcade2 by ShootGame.

the class ScoreBoxListeners method onPlayerEnterScoreBox.

@Handler(priority = Priority.LOWEST)
public void onPlayerEnterScoreBox(PlayerMoveEvent event) {
    if (event.isCanceled() || !this.game.hasAnyScoreBoxes()) {
        return;
    }
    GamePlayer player = event.getGamePlayer();
    ScoreBox scoreBox = this.game.getScoreBox(event.getTo().toVector());
    if (scoreBox == null || !scoreBox.canScore(player)) {
        return;
    }
    Participator participator = this.game.getMatch().findWinnerByPlayer(player);
    if (participator != null) {
        Score score = this.game.getScore(participator);
        if (score != null) {
            scoreBox.score(score, player);
        }
    }
}
Also used : Participator(pl.themolka.arcade.game.Participator) GamePlayer(pl.themolka.arcade.game.GamePlayer) Handler(net.engio.mbassy.listener.Handler)

Example 14 with Participator

use of pl.themolka.arcade.game.Participator in project Arcade2 by ShootGame.

the class ScoreGame method onEnable.

@Override
public void onEnable() {
    MatchGame module = (MatchGame) this.getGame().getModule(MatchModule.class);
    this.match = module.getMatch();
    this.match.registerDynamicWinnable(this);
    for (Map.Entry<Participator, Score> entry : this.byOwner.entrySet()) {
        MatchWinner winner = this.match.findWinnerById(entry.getKey().getId());
        if (winner == null) {
            continue;
        }
        Score score = entry.getValue();
        score.setMatch(this.match);
        winner.addGoal(score);
    }
}
Also used : Participator(pl.themolka.arcade.game.Participator) MatchGame(pl.themolka.arcade.match.MatchGame) MatchWinner(pl.themolka.arcade.match.MatchWinner) MatchModule(pl.themolka.arcade.match.MatchModule) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

Participator (pl.themolka.arcade.game.Participator)14 GamePlayer (pl.themolka.arcade.game.GamePlayer)5 MatchWinner (pl.themolka.arcade.match.MatchWinner)4 Map (java.util.Map)3 Handler (net.engio.mbassy.listener.Handler)3 Element (org.jdom2.Element)3 JDOMException (org.jdom2.JDOMException)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Block (org.bukkit.block.Block)2 EventHandler (org.bukkit.event.EventHandler)2 MatchGame (pl.themolka.arcade.match.MatchGame)2 MatchModule (pl.themolka.arcade.match.MatchModule)2 Collection (java.util.Collection)1 Capturable (pl.themolka.arcade.capture.Capturable)1 PointCapturedEvent (pl.themolka.arcade.capture.point.PointCapturedEvent)1 Match (pl.themolka.arcade.match.Match)1