use of com.andrei1058.bedwars.api.arena.team.TeamColor in project BedWars1058 by andrei1058.
the class Arena method removePlayer.
/**
* Remove a player from the arena
*
* @param p Player to be removed
* @param disconnect True if the player was disconnected
*/
public void removePlayer(@NotNull Player p, boolean disconnect) {
if (leaving.contains(p)) {
return;
} else {
leaving.add(p);
}
debug("Player removed: " + p.getName() + " arena: " + getArenaName());
respawnSessions.remove(p);
ITeam team = null;
Arena.afkCheck.remove(p.getUniqueId());
BedWars.getAPI().getAFKUtil().setPlayerAFK(p, false);
if (getStatus() == GameState.playing) {
for (ITeam t : getTeams()) {
if (t.isMember(p)) {
team = t;
t.getMembers().remove(p);
// noinspection deprecation
t.destroyBedHolo(p);
}
}
}
List<ShopCache.CachedItem> cacheList = new ArrayList<>();
if (ShopCache.getShopCache(p.getUniqueId()) != null) {
// noinspection ConstantConditions
cacheList = ShopCache.getShopCache(p.getUniqueId()).getCachedPermanents();
}
LastHit lastHit = LastHit.getLastHit(p);
Player lastDamager = (lastHit == null) ? null : (lastHit.getDamager() instanceof Player) ? (Player) lastHit.getDamager() : null;
if (lastHit != null) {
// accept damager in last 13 seconds only.
if (lastHit.getTime() < System.currentTimeMillis() - 13_000) {
lastDamager = null;
}
}
Bukkit.getPluginManager().callEvent(new PlayerLeaveArenaEvent(p, this, lastDamager));
// players.remove must be under call event in order to check if the player is a spectator or not
players.remove(p);
removeArenaByPlayer(p, this);
for (PotionEffect pf : p.getActivePotionEffects()) {
p.removePotionEffect(pf.getType());
}
if (p.getPassenger() != null && p.getPassenger().getType() == EntityType.ARMOR_STAND)
p.getPassenger().remove();
boolean teamuri = false;
for (Player on : getPlayers()) {
if (getParty().hasParty(on)) {
teamuri = true;
}
}
if (status == GameState.starting && (maxInTeam > players.size() && teamuri || players.size() < minPlayers && !teamuri)) {
changeStatus(GameState.waiting);
for (Player on : players) {
on.sendMessage(getMsg(on, Messages.ARENA_START_COUNTDOWN_STOPPED_INSUFF_PLAYERS_CHAT));
}
} else if (status == GameState.playing) {
BedWars.debug("removePlayer debug1");
int alive_teams = 0;
for (ITeam t : getTeams()) {
if (t == null)
continue;
if (!t.getMembers().isEmpty()) {
alive_teams++;
}
}
if (alive_teams == 1 && !BedWars.isShuttingDown()) {
checkWinner();
Bukkit.getScheduler().runTaskLater(BedWars.plugin, () -> changeStatus(GameState.restarting), 10L);
if (team != null) {
if (!team.isBedDestroyed()) {
for (Player p2 : this.getPlayers()) {
p2.sendMessage(getMsg(p2, Messages.TEAM_ELIMINATED_CHAT).replace("{TeamColor}", team.getColor().chat().toString()).replace("{TeamName}", team.getDisplayName(Language.getPlayerLanguage(p2))));
}
for (Player p2 : this.getSpectators()) {
p2.sendMessage(getMsg(p2, Messages.TEAM_ELIMINATED_CHAT).replace("{TeamColor}", team.getColor().chat().toString()).replace("{TeamName}", team.getDisplayName(Language.getPlayerLanguage(p2))));
}
}
}
} else if (alive_teams == 0 && !BedWars.isShuttingDown()) {
Bukkit.getScheduler().runTaskLater(BedWars.plugin, () -> changeStatus(GameState.restarting), 10L);
} else if (!BedWars.isShuttingDown()) {
// ReJoin feature
new ReJoin(p, this, team, cacheList);
}
// pvp log out
if (team != null) {
ITeam killerTeam = getTeam(lastDamager);
if (lastDamager != null && isPlayer(lastDamager) && killerTeam != null) {
String message;
PlayerKillEvent.PlayerKillCause cause;
if (team.isBedDestroyed()) {
cause = PlayerKillEvent.PlayerKillCause.PLAYER_DISCONNECT_FINAL;
message = Messages.PLAYER_DIE_PVP_LOG_OUT_FINAL;
} else {
message = Messages.PLAYER_DIE_PVP_LOG_OUT_REGULAR;
cause = PlayerKillEvent.PlayerKillCause.PLAYER_DISCONNECT;
}
PlayerKillEvent event = new PlayerKillEvent(this, p, lastDamager, player -> Language.getMsg(player, message), cause);
for (Player inGame : getPlayers()) {
Language lang = Language.getPlayerLanguage(inGame);
inGame.sendMessage(event.getMessage().apply(inGame).replace("{PlayerTeamName}", team.getDisplayName(lang)).replace("{PlayerColor}", team.getColor().chat().toString()).replace("{PlayerName}", p.getDisplayName()).replace("{KillerColor}", killerTeam.getColor().chat().toString()).replace("{KillerName}", lastDamager.getDisplayName()).replace("{KillerTeamName}", killerTeam.getDisplayName(lang)));
}
for (Player inGame : getSpectators()) {
Language lang = Language.getPlayerLanguage(inGame);
inGame.sendMessage(event.getMessage().apply(inGame).replace("{PlayerTeamName}", team.getDisplayName(lang)).replace("{PlayerColor}", team.getColor().chat().toString()).replace("{PlayerName}", p.getDisplayName()).replace("{KillerColor}", killerTeam.getColor().chat().toString()).replace("{KillerName}", lastDamager.getDisplayName()).replace("{KillerTeamName}", killerTeam.getDisplayName(lang)));
}
PlayerDrops.handlePlayerDrops(this, p, lastDamager, team, killerTeam, cause, new ArrayList<>(Arrays.asList(p.getInventory().getContents())));
}
}
}
for (Player on : getPlayers()) {
on.sendMessage(getMsg(on, Messages.COMMAND_LEAVE_MSG).replace("{vPrefix}", getChatSupport().getPrefix(p)).replace("{vSuffix}", getChatSupport().getSuffix(p)).replace("{playername}", p.getName()).replace("{player}", p.getDisplayName()));
}
for (Player on : getSpectators()) {
on.sendMessage(getMsg(on, Messages.COMMAND_LEAVE_MSG).replace("{vPrefix}", getChatSupport().getPrefix(p)).replace("{playername}", p.getName()).replace("{player}", p.getDisplayName()));
}
if (getServerType() == ServerType.SHARED) {
BedWarsScoreboard sb = BedWarsScoreboard.getSBoard(p.getUniqueId());
if (sb != null) {
sb.remove();
}
this.sendToMainLobby(p);
} else if (getServerType() == ServerType.BUNGEE) {
Misc.moveToLobbyOrKick(p, this, true);
return;
} else {
this.sendToMainLobby(p);
}
/* restore player inventory */
PlayerGoods pg = PlayerGoods.getPlayerGoods(p);
if (pg == null) {
// if there is no previous backup of the inventory send lobby items if multi arena
if (BedWars.getServerType() == ServerType.MULTIARENA) {
// Send items
Arena.sendLobbyCommandItems(p);
}
} else {
pg.restore();
}
playerLocation.remove(p);
for (PotionEffect pf : p.getActivePotionEffects()) {
p.removePotionEffect(pf.getType());
}
if (!BedWars.isShuttingDown()) {
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> {
for (Player on : Bukkit.getOnlinePlayers()) {
if (on.equals(p))
continue;
if (getArenaByPlayer(on) == null) {
BedWars.nms.spigotShowPlayer(p, on);
BedWars.nms.spigotShowPlayer(on, p);
} else {
BedWars.nms.spigotHidePlayer(p, on);
BedWars.nms.spigotHidePlayer(on, p);
}
}
if (!disconnect)
BedWarsScoreboard.giveScoreboard(p, null, false);
}, 5L);
}
/* Remove also the party */
if (getParty().hasParty(p)) {
if (getParty().isOwner(p)) {
if (status != GameState.restarting) {
if (getParty().isInternal()) {
for (Player mem : new ArrayList<>(getParty().getMembers(p))) {
mem.sendMessage(getMsg(mem, Messages.ARENA_LEAVE_PARTY_DISBANDED));
}
}
getParty().disband(p);
// prevent arena from staring with a single player
teamuri = false;
for (Player on : getPlayers()) {
if (getParty().hasParty(on)) {
teamuri = true;
}
}
if (status == GameState.starting && (maxInTeam > players.size() && teamuri || players.size() < minPlayers && !teamuri)) {
changeStatus(GameState.waiting);
for (Player on : players) {
on.sendMessage(getMsg(on, Messages.ARENA_START_COUNTDOWN_STOPPED_INSUFF_PLAYERS_CHAT));
}
}
}
}
}
p.setFlying(false);
p.setAllowFlight(false);
// Remove from ReJoin if game ended
if (status == GameState.restarting) {
if (ReJoin.exists(p)) {
// noinspection ConstantConditions
if (ReJoin.getPlayer(p).getArena() == this) {
// noinspection ConstantConditions
ReJoin.getPlayer(p).destroy(false);
}
}
}
// Remove from magic milk
if (magicMilk.containsKey(p.getUniqueId())) {
int taskId = magicMilk.remove(p.getUniqueId());
if (taskId > 0) {
Bukkit.getScheduler().cancelTask(taskId);
}
}
showTime.remove(p);
refreshSigns();
JoinNPC.updateNPCs(getGroup());
// remove player from party if leaves and the owner is still in the arena while waiting or starting
if (getStatus() == GameState.waiting || getStatus() == GameState.starting) {
if (BedWars.getParty().hasParty(p) && !BedWars.getParty().isOwner(p)) {
for (Player pl : BedWars.getParty().getMembers(p)) {
if (BedWars.getParty().isOwner(pl) && pl.getWorld().getName().equalsIgnoreCase(getArenaName())) {
BedWars.getParty().removeFromParty(p);
break;
}
}
}
}
if (lastHit != null) {
lastHit.remove();
}
}
use of com.andrei1058.bedwars.api.arena.team.TeamColor in project BedWars1058 by andrei1058.
the class Arena method checkWinner.
/**
* Check winner. You can always do that.
* It will manage the arena restart and the needed stuff.
*/
public void checkWinner() {
if (getStatus() != GameState.restarting) {
int max = getTeams().size(), eliminated = 0;
ITeam winner = null;
for (ITeam t : getTeams()) {
if (t.getMembers().isEmpty()) {
eliminated++;
} else {
winner = t;
}
}
if (max - eliminated == 1) {
if (winner != null) {
if (!winner.getMembers().isEmpty()) {
for (Player p : winner.getMembers()) {
if (!p.isOnline())
continue;
p.getInventory().clear();
}
}
String firstName = "";
String secondName = "";
String thirdName = "";
StringBuilder winners = new StringBuilder();
// noinspection deprecation
for (Player p : winner.getMembersCache()) {
if (p.getWorld().equals(getWorld())) {
nms.sendTitle(p, getMsg(p, Messages.GAME_END_VICTORY_PLAYER_TITLE), null, 0, 70, 0);
}
if (!winners.toString().contains(p.getDisplayName())) {
winners.append(p.getDisplayName()).append(" ");
}
}
if (winners.toString().endsWith(" ")) {
winners = new StringBuilder(winners.substring(0, winners.length() - 1));
}
int first = 0, second = 0, third = 0;
if (!playerKills.isEmpty()) {
LinkedHashMap<String, Integer> reverseSortedMap = new LinkedHashMap<>();
// Use Comparator.reverseOrder() for reverse ordering
playerKills.entrySet().stream().sorted(Map.Entry.comparingByValue(Comparator.reverseOrder())).forEachOrdered(x -> reverseSortedMap.put(x.getKey(), x.getValue()));
int entry = 0;
for (Map.Entry<String, Integer> e : reverseSortedMap.entrySet()) {
if (entry == 0) {
firstName = e.getKey();
Player onlinePlayer = Bukkit.getPlayerExact(e.getKey());
if (onlinePlayer != null) {
firstName = onlinePlayer.getDisplayName();
}
first = e.getValue();
} else if (entry == 1) {
secondName = e.getKey();
Player onlinePlayer = Bukkit.getPlayerExact(e.getKey());
if (onlinePlayer != null) {
secondName = onlinePlayer.getDisplayName();
}
second = e.getValue();
} else if (entry == 2) {
thirdName = e.getKey();
Player onlinePlayer = Bukkit.getPlayerExact(e.getKey());
if (onlinePlayer != null) {
thirdName = onlinePlayer.getDisplayName();
}
third = e.getValue();
break;
}
entry++;
}
}
for (Player p : world.getPlayers()) {
p.sendMessage(getMsg(p, Messages.GAME_END_TEAM_WON_CHAT).replace("{TeamColor}", winner.getColor().chat().toString()).replace("{TeamName}", winner.getDisplayName(Language.getPlayerLanguage(p))));
if (!winner.getMembers().contains(p)) {
nms.sendTitle(p, getMsg(p, Messages.GAME_END_GAME_OVER_PLAYER_TITLE), null, 0, 70, 0);
}
for (String s : getList(p, Messages.GAME_END_TOP_PLAYER_CHAT)) {
String message = s.replace("{firstName}", firstName.isEmpty() ? getMsg(p, Messages.MEANING_NOBODY) : firstName).replace("{firstKills}", String.valueOf(first)).replace("{secondName}", secondName.isEmpty() ? getMsg(p, Messages.MEANING_NOBODY) : secondName).replace("{secondKills}", String.valueOf(second)).replace("{thirdName}", thirdName.isEmpty() ? getMsg(p, Messages.MEANING_NOBODY) : thirdName).replace("{thirdKills}", String.valueOf(third)).replace("{winnerFormat}", getMaxInTeam() > 1 ? getMsg(p, Messages.FORMATTING_TEAM_WINNER_FORMAT).replace("{members}", winners.toString()) : getMsg(p, Messages.FORMATTING_SOLO_WINNER_FORMAT).replace("{members}", winners.toString())).replace("{TeamColor}", winner.getColor().chat().toString()).replace("{TeamName}", winner.getDisplayName(Language.getPlayerLanguage(p)));
p.sendMessage(SupportPAPI.getSupportPAPI().replace(p, message));
}
}
}
changeStatus(GameState.restarting);
// Game end event
List<UUID> winners = new ArrayList<>(), losers = new ArrayList<>(), aliveWinners = new ArrayList<>();
for (Player p : getPlayers()) {
aliveWinners.add(p.getUniqueId());
}
if (winner != null) {
// noinspection deprecation
for (Player p : winner.getMembersCache()) {
winners.add(p.getUniqueId());
}
}
for (ITeam bwt : getTeams()) {
if (winner != null) {
if (bwt == winner)
continue;
}
// noinspection deprecation
for (Player p : bwt.getMembersCache()) {
losers.add(p.getUniqueId());
}
}
Bukkit.getPluginManager().callEvent(new GameEndEvent(this, winners, losers, winner, aliveWinners));
//
}
if (players.size() == 0 && getStatus() != GameState.restarting) {
changeStatus(GameState.restarting);
}
}
}
use of com.andrei1058.bedwars.api.arena.team.TeamColor in project BedWars1058 by andrei1058.
the class GamePlayingTask method run.
@Override
public void run() {
switch(getArena().getNextEvent()) {
case EMERALD_GENERATOR_TIER_II:
case EMERALD_GENERATOR_TIER_III:
case DIAMOND_GENERATOR_TIER_II:
case DIAMOND_GENERATOR_TIER_III:
if (getArena().upgradeDiamondsCount > 0) {
getArena().upgradeDiamondsCount--;
if (getArena().upgradeDiamondsCount == 0) {
getArena().updateNextEvent();
}
}
if (getArena().upgradeEmeraldsCount > 0) {
getArena().upgradeEmeraldsCount--;
if (getArena().upgradeEmeraldsCount == 0) {
getArena().updateNextEvent();
}
}
break;
case BEDS_DESTROY:
beds_destroy_countdown--;
if (getBedsDestroyCountdown() == 0) {
for (Player p : getArena().getPlayers()) {
nms.sendTitle(p, getMsg(p, Messages.NEXT_EVENT_TITLE_ANNOUNCE_BEDS_DESTROYED), getMsg(p, Messages.NEXT_EVENT_SUBTITLE_ANNOUNCE_BEDS_DESTROYED), 0, 30, 0);
p.sendMessage(getMsg(p, Messages.NEXT_EVENT_CHAT_ANNOUNCE_BEDS_DESTROYED));
}
for (Player p : getArena().getSpectators()) {
nms.sendTitle(p, getMsg(p, Messages.NEXT_EVENT_TITLE_ANNOUNCE_BEDS_DESTROYED), getMsg(p, Messages.NEXT_EVENT_SUBTITLE_ANNOUNCE_BEDS_DESTROYED), 0, 30, 0);
p.sendMessage(getMsg(p, Messages.NEXT_EVENT_CHAT_ANNOUNCE_BEDS_DESTROYED));
}
for (ITeam t : getArena().getTeams()) {
t.setBedDestroyed(true);
}
getArena().updateNextEvent();
}
break;
case ENDER_DRAGON:
dragon_spawn_countdown--;
if (getDragonSpawnCountdown() == 0) {
for (Player p : getArena().getPlayers()) {
nms.sendTitle(p, getMsg(p, Messages.NEXT_EVENT_TITLE_ANNOUNCE_SUDDEN_DEATH), getMsg(p, Messages.NEXT_EVENT_SUBTITLE_ANNOUNCE_SUDDEN_DEATH), 0, 30, 0);
for (ITeam t : getArena().getTeams()) {
if (t.getMembers().isEmpty())
continue;
p.sendMessage(getMsg(p, Messages.NEXT_EVENT_CHAT_ANNOUNCE_SUDDEN_DEATH).replace("{TeamDragons}", String.valueOf(t.getDragons())).replace("{TeamColor}", t.getColor().chat().toString()).replace("{TeamName}", t.getDisplayName(Language.getPlayerLanguage(p))));
}
}
for (Player p : getArena().getSpectators()) {
nms.sendTitle(p, getMsg(p, Messages.NEXT_EVENT_TITLE_ANNOUNCE_SUDDEN_DEATH), getMsg(p, Messages.NEXT_EVENT_SUBTITLE_ANNOUNCE_SUDDEN_DEATH), 0, 30, 0);
for (ITeam t : getArena().getTeams()) {
if (t.getMembers().isEmpty())
continue;
p.sendMessage(getMsg(p, Messages.NEXT_EVENT_CHAT_ANNOUNCE_SUDDEN_DEATH).replace("{TeamDragons}", String.valueOf(t.getDragons())).replace("{TeamColor}", t.getColor().chat().toString()).replace("{TeamName}", t.getDisplayName(Language.getPlayerLanguage(p))));
}
}
getArena().updateNextEvent();
for (IGenerator o : arena.getOreGenerators()) {
Location l = o.getLocation();
for (int y = 0; y < 20; y++) {
l.clone().subtract(0, y, 0).getBlock().setType(Material.AIR);
}
}
for (ITeam team : arena.getTeams()) {
for (IGenerator o : team.getGenerators()) {
Location l = o.getLocation();
for (int y = 0; y < 20; y++) {
l.clone().subtract(0, y, 0).getBlock().setType(Material.AIR);
}
}
}
for (ITeam t : getArena().getTeams()) {
if (t.getMembers().isEmpty())
continue;
for (int x = 0; x < t.getDragons(); x++) {
nms.spawnDragon(getArena().getConfig().getArenaLoc("waiting.Loc").add(0, 10, 0), t);
}
}
}
break;
case GAME_END:
game_end_countdown--;
if (getGameEndCountdown() == 0) {
getArena().checkWinner();
getArena().changeStatus(GameState.restarting);
}
break;
}
int distance = 0;
for (ITeam t : getArena().getTeams()) {
if (t.getSize() > 1) {
for (Player p : t.getMembers()) {
for (Player p2 : t.getMembers()) {
if (p2 == p)
continue;
if (distance == 0) {
distance = (int) p.getLocation().distance(p2.getLocation());
} else if ((int) p.getLocation().distance(p2.getLocation()) < distance) {
distance = (int) p.getLocation().distance(p2.getLocation());
}
}
nms.playAction(p, getMsg(p, Messages.FORMATTING_ACTION_BAR_TRACKING).replace("{team}", t.getColor().chat() + t.getDisplayName(Language.getPlayerLanguage(p))).replace("{distance}", t.getColor().chat().toString() + distance).replace("&", "§"));
}
}
// spawn items
for (IGenerator o : t.getGenerators()) {
o.spawn();
}
}
/* AFK SYSTEM FOR PLAYERS */
int current = 0;
for (Player p : getArena().getPlayers()) {
if (Arena.afkCheck.get(p.getUniqueId()) == null) {
Arena.afkCheck.put(p.getUniqueId(), current);
} else {
current = Arena.afkCheck.get(p.getUniqueId());
current++;
Arena.afkCheck.replace(p.getUniqueId(), current);
if (current == 45) {
BedWars.getAPI().getAFKUtil().setPlayerAFK(p, true);
}
}
}
/* RESPAWN SESSION */
if (!getArena().getRespawnSessions().isEmpty()) {
for (Map.Entry<Player, Integer> e : getArena().getRespawnSessions().entrySet()) {
if (e.getValue() <= 0) {
IArena a = Arena.getArenaByPlayer(e.getKey());
if (a == null) {
getArena().getRespawnSessions().remove(e.getKey());
continue;
}
ITeam t = a.getTeam(e.getKey());
if (t == null) {
a.addSpectator(e.getKey(), true, null);
} else {
t.respawnMember(e.getKey());
e.getKey().setAllowFlight(false);
e.getKey().setFlying(false);
}
} else {
nms.sendTitle(e.getKey(), getMsg(e.getKey(), Messages.PLAYER_DIE_RESPAWN_TITLE).replace("{time}", String.valueOf(e.getValue())), getMsg(e.getKey(), Messages.PLAYER_DIE_RESPAWN_SUBTITLE).replace("{time}", String.valueOf(e.getValue())), 0, 30, 0);
e.getKey().sendMessage(getMsg(e.getKey(), Messages.PLAYER_DIE_RESPAWN_CHAT).replace("{time}", String.valueOf(e.getValue())));
getArena().getRespawnSessions().replace(e.getKey(), e.getValue() - 1);
}
}
}
/* INVISIBILITY FOR ARMOR */
if (!getArena().getShowTime().isEmpty()) {
for (Map.Entry<Player, Integer> e : getArena().getShowTime().entrySet()) {
if (e.getValue() <= 0) {
getArena().getShowTime().remove(e.getKey());
Bukkit.getPluginManager().callEvent(new PlayerInvisibilityPotionEvent(PlayerInvisibilityPotionEvent.Type.REMOVED, getArena().getTeam(e.getKey()), e.getKey(), getArena()));
for (Player p : e.getKey().getWorld().getPlayers()) {
nms.showArmor(e.getKey(), p);
// nms.showPlayer(e.getKey(), p);
}
} else {
getArena().getShowTime().replace(e.getKey(), e.getValue() - 1);
}
}
}
/* SPAWN ITEMS */
for (IGenerator o : getArena().getOreGenerators()) {
o.spawn();
}
}
use of com.andrei1058.bedwars.api.arena.team.TeamColor in project BedWars1058 by andrei1058.
the class CreateTeam method execute.
@Override
public boolean execute(String[] args, CommandSender s) {
if (s instanceof ConsoleCommandSender)
return false;
Player p = (Player) s;
SetupSession ss = SetupSession.getSession(p.getUniqueId());
if (ss == null) {
s.sendMessage("§c ▪ §7You're not in a setup session!");
return true;
}
if (args.length < 2) {
p.sendMessage("§c▪ §7Usage: /" + mainCmd + " createTeam §o<name> §o<color>");
StringBuilder colors = new StringBuilder("§7");
for (TeamColor t : TeamColor.values()) {
colors.append(t.chat()).append(t.toString()).append(ChatColor.GRAY).append(", ");
}
colors = new StringBuilder(colors.toString().substring(0, colors.toString().length() - 2) + ChatColor.GRAY + ".");
p.sendMessage("§6 ▪ §7Available colors: " + colors);
} else {
boolean y = true;
for (TeamColor t : TeamColor.values()) {
if (t.toString().equalsIgnoreCase(args[1])) {
y = false;
}
}
if (y) {
p.sendMessage("§c▪ §7Invalid color!");
StringBuilder colors = new StringBuilder("§7");
for (TeamColor t : TeamColor.values()) {
colors.append(t.chat()).append(t.toString()).append(ChatColor.GRAY).append(", ");
}
colors = new StringBuilder(colors.toString().substring(0, colors.toString().length() - 2) + ChatColor.GRAY + ".");
p.sendMessage("§6 ▪ §7Available colors: " + colors);
} else {
if (ss.getConfig().getYml().get("Team." + args[0] + ".Color") != null) {
p.sendMessage("§c▪ §7" + args[0] + " team already exists!");
return true;
}
ss.getConfig().set("Team." + args[0] + ".Color", args[1].toUpperCase());
p.sendMessage("§6 ▪ §7" + TeamColor.getChatColor(args[1]) + args[0] + " §7created!");
if (ss.getSetupType() == SetupType.ASSISTED) {
ss.getConfig().reload();
int teams = ss.getConfig().getYml().getConfigurationSection("Team").getKeys(false).size();
int max = 1;
if (teams == 4) {
max = 2;
}
ss.getConfig().set("maxInTeam", max);
}
}
}
return true;
}
use of com.andrei1058.bedwars.api.arena.team.TeamColor in project BedWars1058 by andrei1058.
the class BuyCommand method give.
@Override
public void give(Player player, IArena arena) {
BedWars.debug("Giving BuyCMD: " + getUpgradeIdentifier() + " to: " + player.getName());
String playerName = player.getName();
String playerUUID = player.getUniqueId().toString();
ITeam team = arena.getTeam(player);
String teamName = team == null ? "null" : team.getName();
String teamDisplay = team == null ? "null" : team.getDisplayName(Language.getPlayerLanguage(player));
String teamColor = team == null ? ChatColor.WHITE.toString() : team.getColor().chat().toString();
String arenaIdentifier = arena.getArenaName();
String arenaWorld = arena.getWorldName();
String arenaDisplay = arena.getDisplayName();
String arenaGroup = arena.getGroup();
for (String playerCmd : asPlayer) {
player.chat(playerCmd.replace("{player}", playerName).replace("{player_uuid}", playerUUID).replace("{team}", teamName).replace("{team_display}", teamDisplay).replace("{team_color}", teamColor).replace("{arena}", arenaIdentifier).replace("{arena_world}", arenaWorld).replace("{arena_display}", arenaDisplay).replace("{arena_group}", arenaGroup));
}
for (String consoleCmd : asConsole) {
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), consoleCmd.replace("{player}", playerName).replace("{player_uuid}", playerUUID).replace("{team}", teamName).replace("{team_display}", teamDisplay).replace("{team_color}", teamColor).replace("{arena}", arenaIdentifier).replace("{arena_world}", arenaWorld).replace("{arena_display}", arenaDisplay).replace("{arena_group}", arenaGroup));
}
}
Aggregations