Search in sources :

Example 1 with FastBoard

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);
        }
    }
}
Also used : FastBoard(fr.mrmicky.fastboard.FastBoard) Animatronic(me.Glicz.GlitchFNaF.Types.Animatronic) Arena(me.Glicz.GlitchFNaF.Types.Arena)

Example 2 with FastBoard

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));
    }
}
Also used : Competitor(tc.oc.pgm.api.party.Competitor) Player(org.bukkit.entity.Player) MatchPlayer(tc.oc.pgm.api.player.MatchPlayer) ArrayList(java.util.ArrayList) Goal(tc.oc.pgm.goals.Goal) ProximityGoal(tc.oc.pgm.goals.ProximityGoal) Party(tc.oc.pgm.api.party.Party) GoalMatchModule(tc.oc.pgm.goals.GoalMatchModule) FastBoard(fr.mrmicky.fastboard.FastBoard) MonumentWool(tc.oc.pgm.wool.MonumentWool) MatchPlayer(tc.oc.pgm.api.player.MatchPlayer) Component(net.kyori.adventure.text.Component) HashSet(java.util.HashSet)

Example 3 with FastBoard

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();
    }
}
Also used : BukkitTask(org.bukkit.scheduler.BukkitTask) FastBoard(fr.mrmicky.fastboard.FastBoard)

Example 4 with FastBoard

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);
    }
}
Also used : IModerationManager(fr.ph1lou.werewolfapi.game.IModerationManager) Player(org.bukkit.entity.Player) StatePlayer(fr.ph1lou.werewolfapi.enums.StatePlayer) FastBoard(fr.mrmicky.fastboard.FastBoard) UUID(java.util.UUID) IPlayerWW(fr.ph1lou.werewolfapi.player.interfaces.IPlayerWW) PlayerWW(fr.ph1lou.werewolfplugin.game.PlayerWW) EventHandler(org.bukkit.event.EventHandler)

Example 5 with FastBoard

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();
    }
}
Also used : Day(fr.ph1lou.werewolfapi.enums.Day) Stuff(fr.ph1lou.werewolfplugin.save.Stuff) DefaultArtifactVersion(org.apache.maven.artifact.versioning.DefaultArtifactVersion) ResurrectionEvent(fr.ph1lou.werewolfapi.events.game.life_cycle.ResurrectionEvent) IVoteManager(fr.ph1lou.werewolfapi.vote.IVoteManager) Random(java.util.Random) IWerewolfChatHandler(fr.ph1lou.werewolfapi.game.IWerewolfChatHandler) Player(org.bukkit.entity.Player) Inventory(org.bukkit.inventory.Inventory) StatePlayer(fr.ph1lou.werewolfapi.enums.StatePlayer) Location(org.bukkit.Location) Map(java.util.Map) PlayerInventory(org.bukkit.inventory.PlayerInventory) Configuration(fr.ph1lou.werewolfplugin.save.Configuration) UpdateNameTagEvent(fr.ph1lou.werewolfapi.events.UpdateNameTagEvent) Bukkit(org.bukkit.Bukkit) StateGame(fr.ph1lou.werewolfapi.enums.StateGame) Collection(java.util.Collection) Main(fr.ph1lou.werewolfplugin.Main) ScoreBoard(fr.ph1lou.werewolfplugin.scoreboards.ScoreBoard) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) RandomConfig(fr.ph1lou.werewolfplugin.utils.random_config.RandomConfig) LoadEvent(fr.ph1lou.werewolfapi.events.game.game_cycle.LoadEvent) List(java.util.List) Prefix(fr.ph1lou.werewolfapi.enums.Prefix) Optional(java.util.Optional) IMapManager(fr.ph1lou.werewolfapi.game.IMapManager) PotionEffectType(org.bukkit.potion.PotionEffectType) IModerationManager(fr.ph1lou.werewolfapi.game.IModerationManager) UpdateChecker(fr.ph1lou.werewolfplugin.utils.UpdateChecker) HashMap(java.util.HashMap) IStuffManager(fr.ph1lou.werewolfapi.game.IStuffManager) VersionUtils(fr.ph1lou.werewolfapi.versions.VersionUtils) BukkitUtils(fr.ph1lou.werewolfapi.utils.BukkitUtils) LanguageManager(fr.ph1lou.werewolfplugin.save.LanguageManager) HashSet(java.util.HashSet) GameMode(org.bukkit.GameMode) IPlayerWW(fr.ph1lou.werewolfapi.player.interfaces.IPlayerWW) LobbyTask(fr.ph1lou.werewolfplugin.tasks.LobbyTask) ILoverManager(fr.ph1lou.werewolfapi.lovers.ILoverManager) IConfiguration(fr.ph1lou.werewolfapi.game.IConfiguration) Formatter(fr.ph1lou.werewolfapi.player.utils.Formatter) FileUtils_(fr.ph1lou.werewolfplugin.save.FileUtils_) FinalDeathEvent(fr.ph1lou.werewolfapi.events.game.life_cycle.FinalDeathEvent) StopEvent(fr.ph1lou.werewolfapi.events.game.game_cycle.StopEvent) FastBoard(fr.mrmicky.fastboard.FastBoard) FinalJoinEvent(fr.ph1lou.werewolfapi.events.game.life_cycle.FinalJoinEvent) WereWolfAPI(fr.ph1lou.werewolfapi.game.WereWolfAPI) File(java.io.File) PotionEffect(org.bukkit.potion.PotionEffect) UpdateLanguageEvent(fr.ph1lou.werewolfapi.events.UpdateLanguageEvent) Player(org.bukkit.entity.Player) StatePlayer(fr.ph1lou.werewolfapi.enums.StatePlayer) StopEvent(fr.ph1lou.werewolfapi.events.game.game_cycle.StopEvent) FastBoard(fr.mrmicky.fastboard.FastBoard)

Aggregations

FastBoard (fr.mrmicky.fastboard.FastBoard)18 Player (org.bukkit.entity.Player)8 StatePlayer (fr.ph1lou.werewolfapi.enums.StatePlayer)3 IPlayerWW (fr.ph1lou.werewolfapi.player.interfaces.IPlayerWW)3 UUID (java.util.UUID)3 BukkitTask (org.bukkit.scheduler.BukkitTask)3 Settings (com.eintosti.buildsystem.object.settings.Settings)2 IModerationManager (fr.ph1lou.werewolfapi.game.IModerationManager)2 PlayerWW (fr.ph1lou.werewolfplugin.game.PlayerWW)2 HashSet (java.util.HashSet)2 PlayerData (me.Glicz.GlitchFNaF.Types.PlayerData)2 EventHandler (org.bukkit.event.EventHandler)2 Menu (dev.efnilite.fycore.inventory.Menu)1 MenuClickEvent (dev.efnilite.fycore.inventory.MenuClickEvent)1 PagedMenu (dev.efnilite.fycore.inventory.PagedMenu)1 RandomAnimation (dev.efnilite.fycore.inventory.animation.RandomAnimation)1 SnakeSingleAnimation (dev.efnilite.fycore.inventory.animation.SnakeSingleAnimation)1 WaveEastAnimation (dev.efnilite.fycore.inventory.animation.WaveEastAnimation)1 WaveWestAnimation (dev.efnilite.fycore.inventory.animation.WaveWestAnimation)1 Item (dev.efnilite.fycore.inventory.item.Item)1