use of pl.themolka.arcade.game.GamePlayer in project Arcade2 by ShootGame.
the class Core method detectBreak.
//
// Listeners
//
@Handler(priority = Priority.NORMAL)
public void detectBreak(BlockTransformEvent event) {
if (event.isCanceled()) {
return;
}
Block block = event.getBlock();
if (!event.getNewState().getMaterial().equals(Material.AIR) || this.isCompleted() || !this.contains(block) || this.getLiquid().accepts(event.getNewState().getMaterial())) {
return;
}
GamePlayer player = event.getGamePlayer();
if (player == null) {
event.setCanceled(true);
return;
}
Participator winner = this.game.getMatch().findWinnerByPlayer(player);
if (this.getOwner().equals(winner)) {
event.setCanceled(true);
player.sendError("You may not damage your own " + ChatColor.GOLD + this.getColoredName() + Messageable.ERROR_COLOR + ".");
return;
}
if (!this.breakPiece(winner, player, block)) {
event.setCanceled(true);
}
}
use of pl.themolka.arcade.game.GamePlayer in project Arcade2 by ShootGame.
the class TeamsGame method onEnable.
@Override
public void onEnable() {
this.commands = new TeamCommands(this);
MatchGame module = (MatchGame) this.getGame().getModule(MatchModule.class);
this.match = module.getMatch();
for (Team team : this.teamsById.values()) {
team.setMatch(this.match);
this.match.registerWinner(team);
}
this.teamsById.put(this.match.getObservers().getId(), this.match.getObservers());
this.window = new TeamWindow(this);
this.window.create();
// register
this.getGame().getWindowRegistry().addWindow(this.getWindow());
this.match.setPlayWindow(this.getWindow());
this.match.setObserverHandler(this);
// cache
Observers observers = this.match.getObservers();
for (GamePlayer observer : observers.getOnlineMembers()) {
this.teamsByPlayer.put(observer, observers);
}
}
use of pl.themolka.arcade.game.GamePlayer in project Arcade2 by ShootGame.
the class Match method end.
public void end(MatchWinner winner, boolean force) {
if (!this.isRunning()) {
return;
}
MatchEndEvent endEvent = new MatchEndEvent(this.plugin, this, winner, force);
this.plugin.getEventBus().publish(endEvent);
if (endEvent.isCanceled()) {
return;
}
this.endTime = Time.now();
this.broadcastEndMessage(winner);
this.setForceEnd(force);
this.setState(MatchState.CYCLING);
for (ArcadePlayer online : this.plugin.getPlayers()) {
GamePlayer player = online.getGamePlayer();
if (player == null || !player.isParticipating()) {
continue;
}
player.setCurrentChannel(null);
player.setParticipating(false);
for (KitContent<?> content : new KitContent[] { ObserversKit.RESET, ObserversKit.GAME_MODE, ObserversKit.NAVIGATION_ITEM, ObserversKit.HELD_SLOT, ObserversKit.NIGHT_VISION_EFFECT, ObserversKit.CAN_FLY, ObserversKit.FLY, ObserversKit.FLY_SPEED, ObserversKit.WALK_SPEED }) {
content.applyIfApplicable(player);
}
}
this.plugin.getEventBus().publish(new MatchEndedEvent(this.plugin, this, winner, force));
}
use of pl.themolka.arcade.game.GamePlayer in project Arcade2 by ShootGame.
the class MatchStartCountdown method printCount.
private void printCount() {
long left = this.getLeftSeconds();
String text = null;
if (left == 0) {
text = "";
} else if (left == 1 || left == 2 || left == 3) {
text = ChatColor.YELLOW + Long.toString(left);
}
if (text != null) {
String start = ChatColor.GREEN + ChatColor.ITALIC.toString() + "The match has started.";
Observers observers = this.match.getObservers();
for (ArcadePlayer online : this.plugin.getPlayers()) {
GamePlayer player = online.getGamePlayer();
if (player == null) {
continue;
}
if (observers.contains(online)) {
if (left == 0) {
player.getBukkit().sendTitle(text, start, 3, 60, 10);
}
} else {
player.getBukkit().sendTitle(text, "", 3, 5, 20);
}
}
}
}
use of pl.themolka.arcade.game.GamePlayer 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);
}
Aggregations