Search in sources :

Example 21 with Game

use of pl.themolka.arcade.game.Game 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)

Example 22 with Game

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

the class Sessions method onPlayerRespawn.

// 
// Respawn Event
// 
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerRespawn(PlayerRespawnEvent event) {
    ArcadePlayer player = this.plugin.getPlayer(event.getPlayer().getUniqueId());
    Game game = this.plugin.getGames().getCurrentGame();
    if (game != null) {
        pl.themolka.arcade.respawn.PlayerRespawnEvent respawnEvent = new pl.themolka.arcade.respawn.PlayerRespawnEvent(this.plugin, player);
        respawnEvent.setRespawnPosition(game.getMap().getManifest().getWorld().getSpawn());
        this.publish(respawnEvent);
        Location respawnPosition = respawnEvent.getRespawnPosition();
        if (respawnPosition != null) {
            event.setRespawnLocation(respawnPosition);
        }
    }
}
Also used : Game(pl.themolka.arcade.game.Game) PlayerRespawnEvent(org.bukkit.event.player.PlayerRespawnEvent) Location(org.bukkit.Location) EventHandler(org.bukkit.event.EventHandler)

Aggregations

Game (pl.themolka.arcade.game.Game)22 OfflineMap (pl.themolka.arcade.map.OfflineMap)7 Countdown (pl.themolka.arcade.task.Countdown)6 GamePlayer (pl.themolka.arcade.game.GamePlayer)5 ArrayList (java.util.ArrayList)4 EventHandler (org.bukkit.event.EventHandler)4 CycleCountdown (pl.themolka.arcade.cycle.CycleCountdown)4 RestartCountdown (pl.themolka.arcade.game.RestartCountdown)4 CycleStartEvent (pl.themolka.arcade.cycle.CycleStartEvent)3 ArcadePlayer (pl.themolka.arcade.session.ArcadePlayer)3 TextComponent (net.md_5.bungee.api.chat.TextComponent)2 Location (org.bukkit.Location)2 BossBar (pl.themolka.arcade.bossbar.BossBar)2 CommandException (pl.themolka.arcade.command.CommandException)2 CommandInfo (pl.themolka.arcade.command.CommandInfo)2 GeneralCommands (pl.themolka.arcade.command.GeneralCommands)2 Handler (net.engio.mbassy.listener.Handler)1 World (org.bukkit.World)1 Player (org.bukkit.entity.Player)1 PlayerDeathEvent (org.bukkit.event.entity.PlayerDeathEvent)1