Search in sources :

Example 16 with GamePlayer

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

the class TeamsGame method onChannelsUpdate.

// 
// Listeners
// 
@Handler(priority = Priority.HIGHEST)
public void onChannelsUpdate(MatchStartedEvent event) {
    for (Team team : this.getTeams()) {
        for (GamePlayer player : team.getOnlineMembers()) {
            player.setCurrentChannel(team.getChannel());
            player.setParticipating(team.isParticipating());
        }
    }
}
Also used : GamePlayer(pl.themolka.arcade.game.GamePlayer) Handler(net.engio.mbassy.listener.Handler)

Example 17 with GamePlayer

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

the class TeamApplyListeners method playerRespawn.

// This is a special listener where we manually set player's
// respawn location by looping all apply contents.
@Handler(priority = Priority.LOWEST)
public void playerRespawn(PlayerRespawnEvent event) {
    GamePlayer player = event.getGamePlayer();
    Team team = this.game.getTeam(player);
    if (this.shouldApplyTo(team)) {
        player.getPlayer().clearInventory(true);
        Location spawn = this.fetchSpawn(team, MatchApplyContext.EventType.PLAYER_RESPAWN, player);
        if (spawn != null) {
            event.setRespawnPosition(spawn);
        }
        // The player must be spawned to be able to be meta attachable.
        this.game.getServer().getScheduler().runTaskLater(this.game.getPlugin(), new Runnable() {

            @Override
            public void run() {
                if (!player.isOnline()) {
                    return;
                }
                for (PlayerApplicable content : team.getApplyContext().getAllContent(MatchApplyContext.EventType.PLAYER_RESPAWN)) {
                    if (!(content instanceof SpawnApply)) {
                        content.apply(player);
                    }
                }
            }
        }, Time.ZERO.toTicks());
    }
}
Also used : PlayerApplicable(pl.themolka.arcade.game.PlayerApplicable) GamePlayer(pl.themolka.arcade.game.GamePlayer) SpawnApply(pl.themolka.arcade.spawn.SpawnApply) Location(org.bukkit.Location) Handler(net.engio.mbassy.listener.Handler)

Example 18 with GamePlayer

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

the class TeamCommands method kickCommand.

public void kickCommand(Sender sender, String username) {
    GamePlayer player = this.fetchPlayer(username);
    Team team = this.game.getTeam(player);
    if (team.isObservers()) {
        throw new CommandException("Cannot kick from observers.");
    }
    team.leaveForce(player);
    team.getMatch().getObservers().joinForce(player);
    sender.sendSuccess(player.getUsername() + " has been kicked from " + team.getName() + ".");
}
Also used : GamePlayer(pl.themolka.arcade.game.GamePlayer) CommandException(pl.themolka.arcade.command.CommandException)

Example 19 with GamePlayer

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

the class WindowListeners method onInventoryClick.

@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onInventoryClick(InventoryClickEvent event) {
    Window window = this.fetchWindow(event.getInventory());
    if (window == null) {
        return;
    }
    GamePlayer player = this.fetchPlayer(event.getWhoClicked());
    if (player == null) {
        return;
    }
    boolean click = window.click(player, event.getClick(), event.getSlot());
    if (!click) {
        event.setCancelled(true);
        event.setResult(Event.Result.DENY);
    }
}
Also used : GamePlayer(pl.themolka.arcade.game.GamePlayer) EventHandler(org.bukkit.event.EventHandler)

Example 20 with GamePlayer

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

the class WindowListeners method onInventoryClose.

@EventHandler(priority = EventPriority.LOWEST)
public void onInventoryClose(InventoryCloseEvent event) {
    Window window = this.fetchWindow(event.getInventory());
    if (window == null) {
        return;
    }
    GamePlayer player = this.fetchPlayer(event.getPlayer());
    if (player == null) {
        return;
    }
    boolean close = window.close(player, false);
    if (!close) {
        // don't use the open(...) method in Window, because
        // it will handle the onOpen(...) event.
        event.getPlayer().openInventory(window.getContainer());
    }
}
Also used : GamePlayer(pl.themolka.arcade.game.GamePlayer) EventHandler(org.bukkit.event.EventHandler)

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