Search in sources :

Example 31 with GamePlayer

use of pl.themolka.arcade.game.GamePlayer 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 32 with GamePlayer

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

the class TeamsGame method onEnable.

@Override
public void onEnable() {
    this.commands = new TeamCommands(this);
    MatchGame module = (MatchGame) this.getGame().getModule(MatchModule.class);
    this.match = module.getMatch();
    for (Team team : this.teamsById.values()) {
        team.setMatch(this.match);
        this.match.registerWinner(team);
    }
    this.teamsById.put(this.match.getObservers().getId(), this.match.getObservers());
    this.window = new TeamWindow(this);
    this.window.create();
    // register
    this.getGame().getWindowRegistry().addWindow(this.getWindow());
    this.match.setPlayWindow(this.getWindow());
    this.match.setObserverHandler(this);
    // cache
    Observers observers = this.match.getObservers();
    for (GamePlayer observer : observers.getOnlineMembers()) {
        this.teamsByPlayer.put(observer, observers);
    }
}
Also used : MatchGame(pl.themolka.arcade.match.MatchGame) GamePlayer(pl.themolka.arcade.game.GamePlayer) Observers(pl.themolka.arcade.match.Observers) MatchModule(pl.themolka.arcade.match.MatchModule)

Example 33 with GamePlayer

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

the class Match method end.

public void end(MatchWinner winner, boolean force) {
    if (!this.isRunning()) {
        return;
    }
    MatchEndEvent endEvent = new MatchEndEvent(this.plugin, this, winner, force);
    this.plugin.getEventBus().publish(endEvent);
    if (endEvent.isCanceled()) {
        return;
    }
    this.endTime = Time.now();
    this.broadcastEndMessage(winner);
    this.setForceEnd(force);
    this.setState(MatchState.CYCLING);
    for (ArcadePlayer online : this.plugin.getPlayers()) {
        GamePlayer player = online.getGamePlayer();
        if (player == null || !player.isParticipating()) {
            continue;
        }
        player.setCurrentChannel(null);
        player.setParticipating(false);
        for (KitContent<?> content : new KitContent[] { ObserversKit.RESET, ObserversKit.GAME_MODE, ObserversKit.NAVIGATION_ITEM, ObserversKit.HELD_SLOT, ObserversKit.NIGHT_VISION_EFFECT, ObserversKit.CAN_FLY, ObserversKit.FLY, ObserversKit.FLY_SPEED, ObserversKit.WALK_SPEED }) {
            content.applyIfApplicable(player);
        }
    }
    this.plugin.getEventBus().publish(new MatchEndedEvent(this.plugin, this, winner, force));
}
Also used : ArcadePlayer(pl.themolka.arcade.session.ArcadePlayer) GamePlayer(pl.themolka.arcade.game.GamePlayer) KitContent(pl.themolka.arcade.kit.content.KitContent)

Example 34 with GamePlayer

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

the class MatchStartCountdown method printCount.

private void printCount() {
    long left = this.getLeftSeconds();
    String text = null;
    if (left == 0) {
        text = "";
    } else if (left == 1 || left == 2 || left == 3) {
        text = ChatColor.YELLOW + Long.toString(left);
    }
    if (text != null) {
        String start = ChatColor.GREEN + ChatColor.ITALIC.toString() + "The match has started.";
        Observers observers = this.match.getObservers();
        for (ArcadePlayer online : this.plugin.getPlayers()) {
            GamePlayer player = online.getGamePlayer();
            if (player == null) {
                continue;
            }
            if (observers.contains(online)) {
                if (left == 0) {
                    player.getBukkit().sendTitle(text, start, 3, 60, 10);
                }
            } else {
                player.getBukkit().sendTitle(text, "", 3, 5, 20);
            }
        }
    }
}
Also used : ArcadePlayer(pl.themolka.arcade.session.ArcadePlayer) GamePlayer(pl.themolka.arcade.game.GamePlayer)

Example 35 with GamePlayer

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

the class Sessions method createSession.

// 
// Create Session
// 
public CreatedPlayerInfo createSession(Player bukkit) {
    ArcadePlayer player = new ArcadePlayer(this.plugin, bukkit);
    boolean restored = false;
    Game game = this.plugin.getGames().getCurrentGame();
    if (game != null) {
        // try to restore the GamePlayer first
        GamePlayer gamePlayer = game.getPlayer(bukkit);
        if (gamePlayer != null) {
            restored = true;
        } else {
            gamePlayer = new GamePlayer(game, player);
        }
        // link objects
        gamePlayer.setPlayer(player);
        player.setGamePlayer(gamePlayer);
        // register
        game.getPlayers().playerJoin(gamePlayer);
        // I don't know ;d
        gamePlayer.setParticipating(false);
        gamePlayer.reset();
        gamePlayer.refreshVisibilityArcadePlayer(this.plugin.getPlayers());
    }
    this.plugin.addPlayer(player);
    this.publish(new pl.themolka.arcade.session.PlayerJoinEvent(this.plugin, player, restored));
    return new CreatedPlayerInfo(player, restored);
}
Also used : Game(pl.themolka.arcade.game.Game) GamePlayer(pl.themolka.arcade.game.GamePlayer)

Aggregations

GamePlayer (pl.themolka.arcade.game.GamePlayer)41 EventHandler (org.bukkit.event.EventHandler)17 Handler (net.engio.mbassy.listener.Handler)13 Player (org.bukkit.entity.Player)6 ItemStack (org.bukkit.inventory.ItemStack)5 Participator (pl.themolka.arcade.game.Participator)5 ArcadePlayer (pl.themolka.arcade.session.ArcadePlayer)5 Block (org.bukkit.block.Block)4 Game (pl.themolka.arcade.game.Game)4 ArrayList (java.util.ArrayList)3 CommandException (pl.themolka.arcade.command.CommandException)3 Map (java.util.Map)2 TextComponent (net.md_5.bungee.api.chat.TextComponent)2 Location (org.bukkit.Location)2 HumanEntity (org.bukkit.entity.HumanEntity)2 BossBar (pl.themolka.arcade.bossbar.BossBar)2 Observers (pl.themolka.arcade.match.Observers)2 SpawnApply (pl.themolka.arcade.spawn.SpawnApply)2 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1