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);
}
}
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));
}
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);
}
}
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);
}
}
}
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());
}
Aggregations