Search in sources :

Example 21 with GamePlayer

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

the class ObserverListeners method onMatchWindowOpen.

// 
// Miscellaneous
// 
@EventHandler(priority = EventPriority.MONITOR)
public void onMatchWindowOpen(PlayerInteractEvent event) {
    Action action = event.getAction();
    if (!(action.equals(Action.RIGHT_CLICK_AIR) || action.equals(Action.RIGHT_CLICK_BLOCK))) {
        // Deny all actions which are not right clicks.
        return;
    }
    ItemStack item = event.getItem();
    if (item != null && item.isSimilar(ObserversKit.PLAY_ITEM.getResult())) {
        GamePlayer player = this.game.getGame().getPlayer(event.getPlayer());
        if (player == null) {
            return;
        }
        PlayMatchWindow window = this.game.getMatch().getPlayWindow();
        if (window != null && window.open(player)) {
            return;
        }
        // The PlayerMatchWindow is not set. As we cannot handle the window
        // join the given player to match with the '/join' command instead.
        Commands commands = this.game.getPlugin().getCommands();
        Command command = commands.getCommand(PLAY_COMMAND);
        if (command != null) {
            commands.handleCommand(player, command, command.getCommand(), null);
            return;
        }
        player.sendError("Could not join the match right now. Did you defined format module?");
    }
}
Also used : Action(org.bukkit.event.block.Action) Command(pl.themolka.arcade.command.Command) GamePlayer(pl.themolka.arcade.game.GamePlayer) Commands(pl.themolka.arcade.command.Commands) ItemStack(org.bukkit.inventory.ItemStack) EventHandler(org.bukkit.event.EventHandler)

Example 22 with GamePlayer

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

the class ObserverListeners method onPlayerJoinedObservers.

// 
// Kit and Visibility Filtering
// 
@Handler(priority = Priority.NORMAL)
public void onPlayerJoinedObservers(ObserversJoinEvent event) {
    GamePlayer player = event.getGamePlayer();
    if (player.isOnline()) {
        this.game.getMatch().getObserversKit().apply(player);
        // ^ apply kits
        player.refreshVisibilityArcadePlayer(this.game.getPlugin().getPlayers());
    }
}
Also used : GamePlayer(pl.themolka.arcade.game.GamePlayer) Handler(net.engio.mbassy.listener.Handler) EventHandler(org.bukkit.event.EventHandler)

Example 23 with GamePlayer

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

the class ObserverListeners method onPlayerRespawn.

@Handler(priority = Priority.NORMAL)
public void onPlayerRespawn(PlayerRespawnEvent event) {
    GamePlayer player = event.getGamePlayer();
    if (player.isOnline() && !player.isParticipating()) {
        player.getPlayer().clearInventory(true);
        this.game.getMatch().getObserversKit().apply(player);
        player.getBukkit().updateInventory();
    // ^ apply kits
    }
}
Also used : GamePlayer(pl.themolka.arcade.game.GamePlayer) Handler(net.engio.mbassy.listener.Handler) EventHandler(org.bukkit.event.EventHandler)

Example 24 with GamePlayer

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

the class PortalParser method parseDestination.

protected SpawnApply parseDestination(Node node, String name, String value) throws ParserException {
    Spawn destination = (Spawn) this.destinationParser.parse(node.property("destination")).orFail().get();
    boolean smooth = this.smoothParser.parse(node.property("smooth")).orDefault(false);
    Direction yaw = this.yawDirectionParser.parse(node.property("yaw")).orDefault(Direction.ENTITY);
    Direction pitch = this.pitchDirectionParser.parse(node.property("pitch")).orDefault(Direction.ENTITY);
    return new SpawnApply(destination, new SpawnApply.AgentFactory() {

        @Override
        public SpawnAgent createAgent(Spawn spawn, GamePlayer player, Player bukkit) {
            if (smooth) {
                return SmoothSpawnAgent.create(spawn, player.getBukkit(), yaw, pitch);
            } else {
                return SpawnAgent.create(spawn, player.getBukkit(), yaw, pitch);
            }
        }
    });
}
Also used : GamePlayer(pl.themolka.arcade.game.GamePlayer) Player(org.bukkit.entity.Player) SpawnApply(pl.themolka.arcade.spawn.SpawnApply) GamePlayer(pl.themolka.arcade.game.GamePlayer) SmoothSpawnAgent(pl.themolka.arcade.spawn.SmoothSpawnAgent) SpawnAgent(pl.themolka.arcade.spawn.SpawnAgent) Spawn(pl.themolka.arcade.spawn.Spawn) Direction(pl.themolka.arcade.spawn.Direction)

Example 25 with GamePlayer

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

the class PortalsGame method detectPortal.

// See pl.themolka.arcade.capture.point.PointCapture#onPlayerInitialSpawn
@Handler(priority = Priority.LOW)
public void detectPortal(PlayerJoinEvent event) {
    GamePlayer player = event.getGamePlayer();
    this.detectPortal(player, player.getBukkit().getLocation().toVector());
}
Also used : GamePlayer(pl.themolka.arcade.game.GamePlayer) Handler(net.engio.mbassy.listener.Handler) 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