use of fr.mrmicky.fastboard.FastBoard in project GlitchFNaF by MichixYT.
the class ArenaTask method run.
@Override
public void run() {
for (Arena arena : Arena.getCurrentArenas()) {
if (arena.getTimeLeft() == 0) {
int exp = 0;
for (Animatronic a : arena.getAnimatronics()) {
exp += a.getAi() * 0.5;
}
PlayerDataManager.saveData(arena.getSecurityGuard().getPlayer(), "xp", (int) PlayerDataManager.getData(arena.getSecurityGuard().getPlayer(), "xp") + exp);
PlayerDataManager.saveData(arena.getSecurityGuard().getPlayer(), "wins", (int) PlayerDataManager.getData(arena.getSecurityGuard().getPlayer(), "wins") + 1);
if (arena.getNight() != Night.Night7) {
PlayerDataManager.saveData(arena.getSecurityGuard().getPlayer(), arena.getGameMode(), arena.getNight());
arena.getSecurityGuard().getPlayer().sendMessage(Main.getMessageInterpreter().translatePlain("&2&l! &fSuccessfully completed " + arena.getNight().getFormattedName() + " &7(" + exp + ")"));
} else {
boolean isAll20 = true;
for (Animatronic a : arena.getAnimatronics()) {
if (a.getAi() != 20) {
isAll20 = false;
break;
}
}
if (isAll20) {
PlayerDataManager.saveData(arena.getSecurityGuard().getPlayer(), arena.getGameMode(), arena.getNight());
arena.getSecurityGuard().getPlayer().sendMessage(Main.getMessageInterpreter().translatePlain("&2&l! &fSuccessfully completed " + arena.getNight().getFormattedName() + " &7(" + exp + ")"));
} else
arena.getSecurityGuard().getPlayer().sendMessage(Main.getMessageInterpreter().translatePlain("&c&l! &fTo complete Night 7 you need to play all 20 mode" + " &7(" + exp + ")"));
}
arena.endArena();
continue;
}
for (Animatronic a : arena.getAnimatronics()) {
if (a.getMoveInterval() * 100 == 0) {
if (a.getCurrentLocation().equals("attack")) {
if (arena.getSecurityGuard().getCamera().isActive()) {
arena.setAnimatronicInRoom(a);
for (Animatronic a2 : arena.getAnimatronics()) {
a2.getNpc().despawn();
}
break;
}
}
if (a.getNpc().getEntity() == null)
continue;
a.move(a.getNextLocation(arena.getGameMode()), arena);
a.resetMoveInterval();
} else {
a.removeFromMoveInterval(1);
}
}
if (arena.getTimeInterval() == 0) {
arena.removeFromTimeLeft(1);
if (arena.getPowerInterval() == 0) {
arena.removeFromPower(1);
arena.resetPowerInterval();
} else {
arena.removeFromPowerInterval(1);
}
for (FastBoard fastBoard : arena.getScoreBoards()) {
ScoreboardManager.updateArena(fastBoard, arena);
}
arena.resetTimeInterval();
} else {
arena.removeFromTimeInterval(1);
}
}
}
use of fr.mrmicky.fastboard.FastBoard in project PGM by PGMDev.
the class SidebarMatchModule method renderSidebar.
private void renderSidebar() {
final boolean hasScores = hasScores();
final boolean isBlitz = isBlitz();
final boolean isCompactWool = isCompactWool();
final GoalMatchModule gmm = match.needModule(GoalMatchModule.class);
Set<Competitor> competitorsWithGoals = new HashSet<>();
List<Goal<?>> sharedGoals = new ArrayList<>();
// Count the rows used for goals
for (Goal<?> goal : gmm.getGoals()) {
if (goal.isVisible()) {
if (goal.isShared()) {
sharedGoals.add(goal);
} else {
competitorsWithGoals.addAll(gmm.getCompetitors(goal));
}
}
}
final boolean isSuperCompact = isSuperCompact(competitorsWithGoals);
for (MatchPlayer player : this.match.getPlayers()) {
final FastBoard sidebar = this.sidebars.get(player.getId());
if (sidebar == null)
continue;
final Player viewer = player.getBukkit();
final Party party = player.getParty();
final List<String> rows = new ArrayList<>(MAX_ROWS);
// Scores/Blitz
if (hasScores || isBlitz) {
for (Competitor competitor : match.getSortedCompetitors()) {
String text;
if (hasScores) {
text = renderScore(competitor);
} else {
text = renderBlitz(competitor);
}
if (text.length() != 0)
text += " ";
rows.add(text + TextTranslations.translateLegacy(competitor.getName(), viewer));
// No point rendering more scores, usually seen in FFA
if (rows.size() >= MAX_ROWS)
break;
}
if (!competitorsWithGoals.isEmpty() || !sharedGoals.isEmpty()) {
// Blank row between scores and goals
rows.add("");
}
}
boolean firstTeam = true;
// Shared goals i.e. not grouped under a specific team
for (Goal goal : sharedGoals) {
firstTeam = false;
rows.add(this.renderGoal(goal, null, party, viewer));
}
// Team-specific goals
List<Competitor> sortedCompetitors = new ArrayList<>(match.getSortedCompetitors());
sortedCompetitors.retainAll(competitorsWithGoals);
if (party instanceof Competitor) {
// Bump viewing party to the top of the list
if (sortedCompetitors.remove(party)) {
sortedCompetitors.add(0, (Competitor) party);
}
}
for (Competitor competitor : sortedCompetitors) {
// Prevent team name from showing if there isn't space for at least 1 row of its objectives
if (!(rows.size() + 2 < MAX_ROWS))
break;
if (!(firstTeam || isSuperCompact)) {
// Add a blank row between teams
rows.add("");
}
firstTeam = false;
// Add a row for the team name
rows.add(TextTranslations.translateLegacy(competitor.getName(), viewer));
if (isCompactWool) {
boolean firstWool = true;
List<Goal> sortedWools = new ArrayList<>(gmm.getGoals(competitor));
Collections.sort(sortedWools, (a, b) -> a.getName().compareToIgnoreCase(b.getName()));
// Calculate whether having three spaces between each wool would fit on the scoreboard.
boolean horizontalCompact = MAX_LENGTH < (3 * sortedWools.size()) + (3 * (sortedWools.size() - 1)) + 1;
String woolText = "";
if (!horizontalCompact) {
// If there is extra room, add another space to the left of the wools to make them
// appear more centered.
woolText += " ";
}
for (Goal<?> goal : sortedWools) {
if (goal instanceof MonumentWool && goal.isVisible()) {
MonumentWool wool = (MonumentWool) goal;
woolText += " ";
if (!firstWool && !horizontalCompact)
woolText += " ";
firstWool = false;
woolText += wool.renderSidebarStatusColor(competitor, party);
woolText += wool.renderSidebarStatusText(competitor, party);
}
}
// Add a row for the compact wools
rows.add(woolText);
} else {
// Not compact; add a row for each of this team's goals
for (Goal goal : gmm.getGoals()) {
if (!goal.isShared() && goal.canComplete(competitor) && goal.isVisible()) {
rows.add(this.renderGoal(goal, competitor, party, viewer));
}
}
}
}
final Component footer = PGM.get().getConfiguration().getMatchFooter();
if (footer != null) {
// Only shows footer if there are one or two rows available
if (rows.size() < MAX_ROWS - 2) {
rows.add("");
}
rows.add(TextTranslations.translateLegacy(footer, viewer));
}
// Need at least one row for the sidebar to show
if (rows.isEmpty()) {
rows.add("");
}
// Avoids FastBoard throwing errors and stopping the rendering
for (int i = 0; i < rows.size(); i++) {
if (rows.get(i).length() > MAX_LENGTH)
rows.set(i, rows.get(i).substring(0, MAX_LENGTH));
}
String titleStr = TextTranslations.translateLegacy(title, viewer);
sidebar.updateTitle(titleStr.substring(0, Math.min(titleStr.length(), MAX_TITLE)));
sidebar.updateLines(rows.size() < MAX_ROWS ? rows : rows.subList(0, MAX_ROWS));
}
}
use of fr.mrmicky.fastboard.FastBoard in project BuildSystem by Trichtern.
the class SettingsManager method stopScoreboard.
private void stopScoreboard(Player player, Settings settings) {
BukkitTask scoreboardTask = settings.getScoreboardTask();
if (scoreboardTask != null) {
scoreboardTask.cancel();
settings.setScoreboardTask(null);
}
FastBoard board = this.boards.remove(player.getUniqueId());
if (board != null) {
board.delete();
}
}
use of fr.mrmicky.fastboard.FastBoard in project WereWolfPlugin by Ph1Lou.
the class PlayerListener method onJoin.
@EventHandler
private void onJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
UUID uuid = player.getUniqueId();
PlayerWW playerWW = (PlayerWW) game.getPlayerWW(uuid).orElse(null);
IModerationManager moderationManager = game.getModerationManager();
String playerName = player.getName();
FastBoard fastboard = new FastBoard(player);
fastboard.updateTitle(game.translate("werewolf.score_board.title"));
game.getBoards().put(uuid, fastboard);
event.setJoinMessage(null);
if (game.isState(StateGame.LOBBY)) {
if (moderationManager.getModerators().contains(uuid)) {
player.sendMessage(game.translate(Prefix.GREEN.getKey(), "werewolf.commands.admin.moderator.message"));
player.setGameMode(GameMode.SPECTATOR);
event.setJoinMessage(game.translate(Prefix.YELLOW.getKey(), "werewolf.announcement.join_moderator", Formatter.player(playerName)));
} else if (moderationManager.getQueue().contains(uuid)) {
moderationManager.checkQueue();
player.setGameMode(GameMode.ADVENTURE);
if (moderationManager.getQueue().contains(uuid)) {
event.setJoinMessage(game.translate(Prefix.YELLOW.getKey(), "werewolf.announcement.queue_rejoin", Formatter.player(playerName), Formatter.number(game.getModerationManager().getQueue().indexOf(uuid) + 1)));
}
} else {
game.join(player);
}
} else if (playerWW != null) {
if (!playerWW.getName().equals(player.getName())) {
playerWW.setName(player.getName());
}
player.setCompassTarget(playerWW.getSpawn());
playerWW.updateAfterReconnect(player);
if (playerWW.isState(StatePlayer.ALIVE)) {
event.setJoinMessage(game.translate(Prefix.YELLOW.getKey(), "werewolf.announcement.join_in_game", Formatter.player(playerName)));
} else if (playerWW.isState(StatePlayer.DEATH)) {
if (game.getConfig().getSpectatorMode() == 0 && !moderationManager.isStaff(player.getUniqueId()) && !player.isOp()) {
player.kickPlayer(game.translate(Prefix.RED.getKey(), "werewolf.check.spectator_disabled"));
} else {
player.setGameMode(GameMode.SPECTATOR);
event.setJoinMessage(game.translate("werewolf.announcement.join_in_spec", Formatter.player(playerName)));
}
}
} else {
player.setCompassTarget(game.getMapManager().getWorld().getSpawnLocation());
if (moderationManager.getModerators().contains(uuid)) {
event.setJoinMessage(game.translate(Prefix.YELLOW.getKey(), "werewolf.announcement.join_moderator", Formatter.player(playerName)));
player.sendMessage(game.translate(Prefix.GREEN.getKey(), "werewolf.commands.admin.moderator.message"));
player.setGameMode(GameMode.SPECTATOR);
} else {
player.setGameMode(GameMode.SPECTATOR);
event.setJoinMessage(game.translate(Prefix.YELLOW.getKey(), "werewolf.announcement.join_spec", Formatter.player(playerName)));
player.sendMessage(game.translate(Prefix.RED.getKey(), "werewolf.check.already_begin"));
}
BukkitUtils.scheduleSyncDelayedTask(() -> player.teleport(game.getMapManager().getWorld().getSpawnLocation()), 10);
}
}
use of fr.mrmicky.fastboard.FastBoard in project WereWolfPlugin by Ph1Lou.
the class GameManager method stopGame.
@Override
public void stopGame() {
if (!this.main.getWereWolfAPI().equals(this))
return;
Bukkit.getPluginManager().callEvent(new StopEvent(this));
this.listenersLoader.delete();
this.main.createGame();
GameManager newGame = (GameManager) this.main.getWereWolfAPI();
BukkitUtils.scheduleSyncDelayedTask(() -> {
for (Player player : Bukkit.getOnlinePlayers()) {
FastBoard fastboard = new FastBoard(player);
fastboard.updateTitle(newGame.translate("werewolf.score_board.title"));
newGame.boards.put(player.getUniqueId(), fastboard);
player.setGameMode(GameMode.ADVENTURE);
newGame.join(player);
}
if (this.getTimer() <= 60) {
newGame.getMapManager().generateMap(newGame.getConfig().getBorderMax());
}
}, 10);
Bukkit.getOnlinePlayers().stream().filter(player -> player.getWorld().equals(this.mapManager.getWorld())).forEach(player -> player.teleport(Bukkit.getWorlds().get(0).getSpawnLocation()));
if (this.getTimer() > 60) {
// Si la game a commencé depuis moins d'une minute on ne delete pas la map
this.mapManager.deleteMap();
}
}
Aggregations