use of com.ebicep.warlords.game.flags.SpawnFlagLocation in project Warlords by ebicep.
the class WarlordsEvents method onFlagChange.
@EventHandler
public void onFlagChange(WarlordsFlagUpdatedEvent event) {
// Bukkit.broadcastMessage(event.getTeam() + " " + event.getOld().getClass().getSimpleName() + " => " + event.getNew().getClass().getSimpleName());
if (event.getOld() instanceof PlayerFlagLocation) {
((PlayerFlagLocation) event.getOld()).getPlayer().setCarriedFlag(null);
}
if (event.getNew() instanceof PlayerFlagLocation) {
PlayerFlagLocation pfl = (PlayerFlagLocation) event.getNew();
WarlordsPlayer player = pfl.getPlayer();
player.setCarriedFlag(event.getInfo());
// removing invis for assassins
OrderOfEviscerate.removeCloak(player, false);
if (event.getOld() instanceof PlayerFlagLocation) {
// PLAYER -> PLAYER only happens if the multiplier gets to a new scale
if (pfl.getComputedHumanMultiplier() % 10 == 0) {
event.getGame().forEachOnlinePlayerWithoutSpectators((p, t) -> {
p.sendMessage("§eThe " + event.getTeam().coloredPrefix() + " §eflag carrier now takes §c" + pfl.getComputedHumanMultiplier() + "% §eincreased damage!");
});
event.getGame().spectators().forEach(uuid -> {
if (Bukkit.getPlayer(uuid) != null) {
Player p = Bukkit.getPlayer(uuid);
p.sendMessage("§eThe " + event.getTeam().coloredPrefix() + " §eflag carrier now takes §c" + pfl.getComputedHumanMultiplier() + "% §eincreased damage!");
}
});
}
} else {
// eg GROUND -> PLAYER
// or SPAWN -> PLAYER
ChatColor enemyColor = event.getTeam().enemy().teamColor();
event.getGame().forEachOnlinePlayerWithoutSpectators((p, t) -> {
p.sendMessage(enemyColor + player.getName() + " §epicked up the " + event.getTeam().coloredPrefix() + " §eflag!");
PacketUtils.sendTitle(p, "", enemyColor + player.getName() + " §epicked up the " + event.getTeam().coloredPrefix() + " §eflag!", 0, 60, 0);
if (t == event.getTeam()) {
p.playSound(player.getLocation(), "ctf.friendlyflagtaken", 500, 1);
} else {
p.playSound(player.getLocation(), "ctf.enemyflagtaken", 500, 1);
}
});
event.getGame().spectators().forEach(uuid -> {
if (Bukkit.getPlayer(uuid) != null) {
Player p = Bukkit.getPlayer(uuid);
p.sendMessage(enemyColor + player.getName() + " §epicked up the " + event.getTeam().coloredPrefix() + " §eflag!");
PacketUtils.sendTitle(p, "", enemyColor + player.getName() + " §epicked up the " + event.getTeam().coloredPrefix() + " §eflag!", 0, 60, 0);
}
});
}
} else if (event.getNew() instanceof SpawnFlagLocation) {
WarlordsPlayer toucher = ((SpawnFlagLocation) event.getNew()).getFlagReturner();
if (event.getOld() instanceof GroundFlagLocation) {
if (toucher != null) {
toucher.addFlagReturn();
event.getGame().forEachOnlinePlayer((p, t) -> {
ChatColor color = event.getTeam().teamColor();
p.sendMessage(color + toucher.getName() + " §ehas returned the " + event.getTeam().coloredPrefix() + " §eflag!");
PacketUtils.sendTitle(p, "", color + toucher.getName() + " §ehas returned the " + event.getTeam().coloredPrefix() + " §eflag!", 0, 60, 0);
if (t == event.getTeam()) {
p.playSound(p.getLocation(), "ctf.flagreturned", 500, 1);
}
});
} else {
event.getGame().forEachOnlinePlayer((p, t) -> {
p.sendMessage("§eThe " + event.getTeam().coloredPrefix() + " §eflag has returned to its base.");
});
}
}
} else if (event.getNew() instanceof GroundFlagLocation) {
if (event.getOld() instanceof PlayerFlagLocation) {
PlayerFlagLocation pfl = (PlayerFlagLocation) event.getOld();
pfl.getPlayer().updateArmor();
String flag = event.getTeam().coloredPrefix();
ChatColor playerColor = event.getTeam().enemy().teamColor();
event.getGame().forEachOnlinePlayer((p, t) -> {
PacketUtils.sendTitle(p, "", playerColor + pfl.getPlayer().getName() + " §ehas dropped the " + flag + " §eflag!", 0, 60, 0);
p.sendMessage(playerColor + pfl.getPlayer().getName() + " §ehas dropped the " + flag + " §eflag!");
});
}
} else if (event.getNew() instanceof WaitingFlagLocation && ((WaitingFlagLocation) event.getNew()).getScorer() != null) {
WarlordsPlayer player = ((WaitingFlagLocation) event.getNew()).getScorer();
player.addFlagCap();
event.getGame().forEachOnlinePlayer((p, t) -> {
String message = player.getColoredName() + " §ecaptured the " + event.getInfo().getTeam().coloredPrefix() + " §eflag!";
p.sendMessage(message);
PacketUtils.sendTitle(p, "", message, 0, 60, 0);
if (t != null) {
if (event.getTeam() == t) {
p.playSound(player.getLocation(), "ctf.enemycapturedtheflag", 500, 1);
} else {
p.playSound(player.getLocation(), "ctf.enemyflagcaptured", 500, 1);
}
}
});
}
}
use of com.ebicep.warlords.game.flags.SpawnFlagLocation in project Warlords by ebicep.
the class DebugMenuPlayerOptions method openFlagOptionMenu.
public static void openFlagOptionMenu(Player player, WarlordsPlayer target) {
Menu menu = new Menu("Flag Options: " + target.getName(), 9 * 4);
ItemStack[] flagOptions = { new ItemBuilder(Material.BANNER).name(ChatColor.GREEN + "Pick Up Flag").get(), new ItemBuilder(Material.BED).name(ChatColor.GREEN + "Return the Flag").get(), new ItemBuilder(Material.GRASS).name(ChatColor.GREEN + "Drop Flag").get(), new ItemBuilder(Material.REDSTONE_COMPARATOR).name(ChatColor.GREEN + "Set Multiplier").get() };
int row = 0;
for (FlagHolder holder : target.getGame().getMarkers(FlagHolder.class)) {
if (holder.getTeam() == target.getTeam()) {
continue;
}
row++;
for (int i = 0; i < flagOptions.length; i++) {
int finalI = i;
menu.setItem(i + 1, row, flagOptions[i], (m, e) -> {
switch(finalI) {
case 0:
if (target.getCarriedFlag() == holder.getInfo()) {
player.sendMessage(ChatColor.RED + "DEV: §aThat player already has the flag");
} else {
FlagHolder.update(target.getGame(), info -> info.getFlag() instanceof PlayerFlagLocation && ((PlayerFlagLocation) info.getFlag()).getPlayer() == target ? GroundFlagLocation.of(info.getFlag()) : info == holder.getInfo() ? PlayerFlagLocation.of(info.getFlag(), target) : null);
}
break;
case 1:
if (target.getCarriedFlag() == holder.getInfo()) {
holder.getInfo().setFlag(new SpawnFlagLocation(holder.getInfo().getSpawnLocation(), null));
} else {
player.sendMessage(ChatColor.RED + "DEV: §aThat player does not have the flag");
}
break;
case 2:
if (target.getCarriedFlag() == holder.getInfo()) {
holder.getInfo().setFlag(GroundFlagLocation.of(holder.getFlag()));
} else {
player.sendMessage(ChatColor.RED + "DEV: §aThat player does not have the flag");
}
break;
case 3:
if (target.getCarriedFlag() == holder.getInfo()) {
openFlagMultiplierMenu(player, target);
} else {
player.sendMessage(ChatColor.RED + "DEV: §aThat player does not have the flag");
}
break;
}
});
}
}
menu.setItem(3, 3, MENU_BACK, (m, e) -> openPlayerMenu(player, target));
menu.setItem(4, 3, MENU_CLOSE, ACTION_CLOSE_MENU);
menu.openForPlayer(player);
}
use of com.ebicep.warlords.game.flags.SpawnFlagLocation in project Warlords by ebicep.
the class SimulationTeleportOption method onFlagReturn.
@EventHandler
public void onFlagReturn(WarlordsFlagUpdatedEvent e) {
if (e.getNew() instanceof SpawnFlagLocation) {
preventPlayerMovement = true;
for (WarlordsPlayer wp : PlayerFilter.playingGame(game).isAlive()) {
wp.respawn();
}
new GameRunnable(game) {
@Override
public void run() {
preventPlayerMovement = false;
}
}.runTaskLater(40);
}
}
Aggregations