Search in sources :

Example 11 with GamePlayer

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

the class GeneralListeners method onPlayerMove.

// 
// Custom Events
// 
/**
 * Bukkit's {@link PlayerMoveEvent} is not what we need. We can simply
 * cancel the last player movement using the setCanceled(...) method in
 * {@link PlayerMoveEvent}.
 */
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerMove(org.bukkit.event.player.PlayerMoveEvent event) {
    Game game = this.plugin.getGames().getCurrentGame();
    if (game == null) {
        return;
    }
    World fromWorld = event.getFrom().getWorld();
    World toWorld = event.getTo().getWorld();
    if (fromWorld == null || !fromWorld.equals(toWorld) || !fromWorld.equals(game.getWorld())) {
        // We are not interested in such events.
        return;
    }
    GamePlayer player = game.getPlayer(event.getPlayer());
    if (player == null) {
        return;
    }
    PlayerMoveEvent wrapper = new PlayerMoveEvent(this.plugin, player, event);
    this.plugin.getEventBus().publish(wrapper);
    if (wrapper.isCanceled()) {
        Location to = event.getFrom().clone();
        to.setX(to.getBlockX() + 0.5);
        to.setZ(to.getBlockZ() + 0.5);
        event.setTo(to);
    }
}
Also used : Game(pl.themolka.arcade.game.Game) GamePlayer(pl.themolka.arcade.game.GamePlayer) PlayerMoveEvent(pl.themolka.arcade.session.PlayerMoveEvent) World(org.bukkit.World) Location(org.bukkit.Location) EventHandler(org.bukkit.event.EventHandler)

Example 12 with GamePlayer

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

the class Match method start.

public void start(boolean force) {
    if (!this.isStarting()) {
        return;
    }
    MatchStartEvent startEvent = new MatchStartEvent(this.plugin, this, force);
    this.plugin.getEventBus().publish(startEvent);
    if (startEvent.isCanceled()) {
        return;
    }
    this.startTime = Time.now();
    this.broadcastStartMessage();
    this.setForceStart(force);
    this.setState(MatchState.RUNNING);
    for (ArcadePlayer online : this.plugin.getPlayers()) {
        GamePlayer player = online.getGamePlayer();
        if (player == null || this.getObservers().hasPlayer(player)) {
            continue;
        }
        player.setParticipating(true);
        ObserversKit.RESET.applyIfApplicable(player);
    }
    this.plugin.getEventBus().publish(new MatchStartedEvent(this.plugin, this, force));
}
Also used : ArcadePlayer(pl.themolka.arcade.session.ArcadePlayer) GamePlayer(pl.themolka.arcade.game.GamePlayer)

Example 13 with GamePlayer

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

the class CanFlyContent method attach.

@Override
public void attach(GamePlayer player, Boolean value) {
    Player bukkit = player.getBukkit();
    bukkit.setAllowFlight(value);
    if (!this.force && !value) {
        bukkit.setFlying(false);
    }
}
Also used : GamePlayer(pl.themolka.arcade.game.GamePlayer) Player(org.bukkit.entity.Player)

Example 14 with GamePlayer

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

the class Sessions method onPlayerQuit.

@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerQuit(PlayerQuitEvent event) {
    DestroyedPlayerInfo info = this.destroySession(event.getPlayer());
    if (info != null && info.player != null) {
        // make GamePlayers offline
        GamePlayer game = info.player.getGamePlayer();
        if (game != null) {
            // remove the pointer
            game.setPlayer(null);
            game.setParticipating(false);
            game.onDisconnect(info.player);
        }
    }
}
Also used : GamePlayer(pl.themolka.arcade.game.GamePlayer) EventHandler(org.bukkit.event.EventHandler)

Example 15 with GamePlayer

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

the class TeamsGame method onNewTeamPut.

@Handler(priority = Priority.LAST)
public void onNewTeamPut(PlayerJoinTeamEvent event) {
    GamePlayer player = event.getGamePlayer();
    if (!event.isCanceled() && this.teamsByPlayer.containsKey(player)) {
        this.getTeam(player).leave(player);
        this.teamsByPlayer.remove(player);
    }
    this.teamsByPlayer.put(player, event.getTeam());
}
Also used : GamePlayer(pl.themolka.arcade.game.GamePlayer) Handler(net.engio.mbassy.listener.Handler)

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