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