use of pl.themolka.arcade.capture.Capturable in project Arcade2 by ShootGame.
the class Wool method onWoolPlace.
@Handler(priority = Priority.HIGHER)
public void onWoolPlace(BlockTransformEvent event) {
Block block = event.getBlock();
if (!WoolUtils.isWool(block) || !this.getMonument().contains(block)) {
return;
}
GamePlayer player = event.getGamePlayer();
if (player == null) {
// Endermans, TNTs and other entities are not permitted to place wools.
event.setCanceled(true);
return;
}
if (!WoolUtils.isWool(block, this.getColor())) {
for (Capturable otherCapturable : this.game.getCapturables()) {
if (otherCapturable instanceof Wool) {
Wool otherWool = (Wool) otherCapturable;
if (WoolUtils.isWool(block, otherWool.getColor()) && otherWool.getMonument().contains(block)) {
// This will be handled in its correct listener, return.
return;
}
}
}
event.setCanceled(true);
player.sendError("Only " + this.getColoredName() + Messageable.ERROR_COLOR + " may be placed here!");
return;
}
event.setCanceled(true);
if (this.isCompleted()) {
player.sendError(ChatColor.GOLD + this.getColoredName() + Messageable.ERROR_COLOR + " has already been captured!");
} else if (this.hasOwner() && this.getOwner().contains(player)) {
player.sendError("You may not capture your own " + ChatColor.GOLD + this.getColoredName() + Messageable.ERROR_COLOR + "!");
} else {
Participator competitor = this.game.getMatch().findWinnerByPlayer(player);
if (competitor == null) {
return;
}
WoolPlaceEvent placeEvent = new WoolPlaceEvent(this.game.getPlugin(), this, competitor, player);
this.game.getPlugin().getEventBus().publish(placeEvent);
if (placeEvent.isCanceled()) {
return;
}
event.setCanceled(false);
this.capture(placeEvent.getCompleter(), player);
}
}
use of pl.themolka.arcade.capture.Capturable in project Arcade2 by ShootGame.
the class FlagPayloadRender method onInventoryClick.
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onInventoryClick(InventoryClickEvent event) {
ItemStack item = event.getCurrentItem();
for (Capturable capturable : this.game.getCapturables()) {
if (capturable instanceof Flag && ((Flag) capturable).getItem().isSimilar(item)) {
event.setCancelled(true);
event.setResult(Event.Result.DENY);
break;
}
}
}
Aggregations