Search in sources :

Example 36 with GamePlayer

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

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

the class SpawnApply method spawn.

public Location spawn(GamePlayer player) {
    Player bukkit = player.getBukkit();
    if (bukkit != null && bukkit.isOnline()) {
        AgentFactory factory = this.getAgentFactory();
        SpawnAgent agent = factory.createAgent(this.getSpawn(), player, bukkit);
        if (agent != null) {
            return agent.spawn();
        }
    }
    return null;
}
Also used : GamePlayer(pl.themolka.arcade.game.GamePlayer) Player(org.bukkit.entity.Player)

Example 38 with GamePlayer

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

the class TeamApplyListeners method playerPlay.

@Handler(priority = Priority.LOWEST)
public void playerPlay(PlayerJoinedTeamEvent event) {
    GamePlayer player = event.getGamePlayer();
    Team team = event.getTeam();
    if (this.shouldApplyTo(team)) {
        player.getPlayer().clearInventory(true);
        team.getApplyContext().applyAll(player, MatchApplyContext.EventType.PLAYER_PLAY);
    }
}
Also used : GamePlayer(pl.themolka.arcade.game.GamePlayer) Handler(net.engio.mbassy.listener.Handler)

Example 39 with GamePlayer

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

the class TeamCommands method forceCommand.

public void forceCommand(Sender sender, String username, String teamId) {
    GamePlayer player = this.fetchPlayer(username);
    Team team = this.fetchTeam(teamId);
    if (team.contains(player)) {
        throw new CommandException(player.getUsername() + " is already member of " + team.getName() + ".");
    }
    team.joinForce(player);
    sender.sendSuccess(player.getUsername() + " has been moved to " + team.getName() + ".");
}
Also used : GamePlayer(pl.themolka.arcade.game.GamePlayer) CommandException(pl.themolka.arcade.command.CommandException)

Example 40 with GamePlayer

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

the class TeamCommands method clearCommand.

// 
// Commands
// 
public void clearCommand(Sender sender, String teamId) {
    Team team = this.fetchTeam(teamId);
    if (team.isObservers()) {
        throw new CommandException("Cannot clear observers.");
    }
    Observers observers = this.game.getMatch().getObservers();
    int result = 0;
    for (GamePlayer player : new ArrayList<>(team.getOnlineMembers())) {
        observers.joinForce(player);
        result++;
    }
    if (result > 0) {
        sender.sendSuccess(team.getName() + " has been cleared (" + result + " players) and moved to " + observers.getName() + ".");
    } else {
        sender.sendError("No players to clear.");
    }
}
Also used : GamePlayer(pl.themolka.arcade.game.GamePlayer) Observers(pl.themolka.arcade.match.Observers) ArrayList(java.util.ArrayList) CommandException(pl.themolka.arcade.command.CommandException)

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