Java 类org.bukkit.boss.BarColor 实例源码

项目:SamaGamesAPI    文件:BossBarAPI.java   
/**
 * Set a boss bar with a given color, style, percentage to a given
 * player. Also you can enable the darken sky, the boss music ambiance
 * and enable fog to a given player
 *
 * @param message Message on the top of the bar
 * @param color Color of the bar
 * @param style Style of the bar
 * @param progress Filling percentage
 * @param darkenSky Enable darken sky
 * @param playMusic Enable boss music
 * @param createFog Enable the fog
 */
public static Pair<UUID, BossBar> getBar(String message, BarColor color, BarStyle style, double progress, boolean darkenSky, boolean playMusic, boolean createFog)
{
    BossBar bossBar = Bukkit.createBossBar(message, color, style);
    bossBar.setProgress(progress < 0 ? 0D : progress / 100.0D);

    if (darkenSky)
        bossBar.addFlag(BarFlag.DARKEN_SKY);

    if (playMusic)
        bossBar.addFlag(BarFlag.PLAY_BOSS_MUSIC);

    if (createFog)
        bossBar.addFlag(BarFlag.CREATE_FOG);

    UUID random = UUID.randomUUID();
    bossBars.put(random, bossBar);

    return Pair.of(random, bossBar);
}
项目:ProjectAres    文件:TicketDisplay.java   
private void updateArena(Arena arena) {
    final Game game = games.byId(arena.game_id());
    int minPlayers = 0;
    if(arena.next_server_id() != null) {
        minPlayers = servers.byId(arena.next_server_id()).min_players();
    }
    final BaseComponent text;
    final double progress;
    if(minPlayers > 0 && arena.num_queued() < minPlayers) {
        text = gameFormatter.queued(game, minPlayers - arena.num_queued());
        progress = (double) arena.num_queued() / (double) minPlayers;
    } else {
        text = gameFormatter.joining(game);
        progress = 1;
    }
    bars.getUnchecked(arena).update(text, progress, BarColor.YELLOW, BarStyle.SOLID, Collections.emptySet());
}
项目:SkipNight    文件:Vote.java   
private void doInit() {
    voters = new ArrayList();
    plugin.getServer().getPluginManager().registerEvents(this, plugin);

    messageArray[0] = Messages.voteStarted();
    messageArray[1] = Messages.voteButtons();

    yes = 1;
    no = 0;
    countDown = 30;

    bar = Bukkit.createBossBar("Current Vote: "
            + ChatColor.GREEN + ChatColor.BOLD + "Yes "
            + ChatColor.RESET + "- " + yes
            + ChatColor.DARK_RED + ChatColor.BOLD +  " No "
            + ChatColor.RESET + "- " + no, BarColor.PURPLE, BarStyle.SOLID);

    voters = updateAll(voters, messageArray, player);

    timer = Timer.OPERATION;
    plugin.getServer().getScheduler().runTaskLater(plugin, this, 20);
}
项目:SkipNight    文件:Vote.java   
private void doFinal() {
    countDown--;
    bar.setProgress((double) countDown / 30.0);
    bar.setTitle("Current Vote: "
            + ChatColor.GREEN + ChatColor.BOLD + "Yes "
            + ChatColor.RESET + "- " + yes
            + ChatColor.DARK_RED + ChatColor.BOLD +  " No "
            + ChatColor.RESET + "- " + no);
    if (countDown == 9) voters = updateAll(voters, Messages.tenSecondsLeft());
    else voters = updateAll(voters);

    if (countDown % 2 == 1) bar.setColor(BarColor.WHITE);
    else bar.setColor(BarColor.PURPLE);

    if (countDown == 0) timer = Timer.COMPLETE;
    plugin.getServer().getScheduler().runTaskLater(plugin, this, 20);
}
项目:AthenaGM    文件:Vote.java   
/**
 * Manage the creation, updating and removal of a BossBar to show remaining vote time.
 */
private void doBar() {
    long elapsed = (System.currentTimeMillis() - timeCreated) / 1000;
    int seconds = 60 - (int) elapsed;
    String title = String.format("%d seconds left to vote", seconds);
    if (bar == null) {
        // create bar
        bar = arena.getPlugin().getServer().createBossBar(title, BarColor.WHITE, BarStyle.SEGMENTED_10);
        arena.getMatch().getAllPlayers().forEach(bar::addPlayer);
    } else if (seconds < 1) {
        // remove bar
        removeBar();
    } else {
        // update bar
        bar.setProgress(calculatePercentage(seconds, 60));
        bar.setTitle(title);
    }
}
项目:QuestManager    文件:ForgeSequence.java   
public void start() {
    if (!player.getPlayer().isOnline())
        return;

    state = State.STARTING;
    Alarm.getScheduler().schedule(this, 0, 1);
    player.getPlayer().getPlayer().sendMessage(ChatColor.GREEN + "Get Ready...");

    this.displayBar = Bukkit.createBossBar(displayName, BarColor.BLUE, BarStyle.SEGMENTED_20, new BarFlag[0]);
    displayBar.setProgress(1f);
    displayBar.addPlayer(player.getPlayer().getPlayer());

    this.timeLeft = coolTime;
    isCooling = true;

    Bukkit.getPluginManager().registerEvents(this, QuestManagerPlugin.questManagerPlugin);
}
项目:QuestManager    文件:ForgeSequence.java   
private void update() {
    if (this.state != State.RUNNING) {
        return;
    }

    if (isCooling) {
        displayBar.setColor(BarColor.BLUE);
        displayBar.setProgress(1.0 - (timeLeft / coolTime));

        if (timeLeft <= 0) {
            finishGame();
            return;
        }
    } else {
        displayBar.setColor(BarColor.RED);
        displayBar.setProgress(timeLeft / heatTime);
    }
}
项目:QuestManager    文件:FishingGui.java   
public void start() {

        //Set up top bar
        inv.setItem(0, this.reelOffIcon);
//      for (int i = 1; i < 4; i++) {
//          inv.setItem(i, this.meterOnIcon);
//      }
//      for (int i = 4; i < 8; i++) {
//          inv.setItem(i, this.meterOffIcon);
//      }
        inv.setItem(8, this.reelOnIcon);

        displayBar = Bukkit.createBossBar("Fishing Progress", BarColor.BLUE, BarStyle.SEGMENTED_20, new BarFlag[0]);
        displayBar.setProgress(1f);
        displayBar.addPlayer(player);

        stressBar = Bukkit.createBossBar("Line Stress", BarColor.GREEN, BarStyle.SEGMENTED_10, new BarFlag[0]);
        stressBar.setProgress(lineStress);
        stressBar.addPlayer(player);

        //start filling the 'sea'
        //time is time to fill all in 5 seconds, or .2 if less than that (it would be too fast!)
        Alarm.getScheduler().schedule(this, 0, Math.max(.2, 5 / (9 * this.waterRows)));
    }
项目:QuestManager    文件:CookingGui.java   
private void update() {
    displayBar.setProgress(Math.max(0, cookTime / maxCookTime));
    failBar.setProgress(Math.min(1, missIndex));

    if (missIndex < .20)
        failBar.setColor(BarColor.RED);

    if (furnace.getBurnTime() > 200) {
        loseGame();
        player.getWorld().playSound(player.getLocation(), BURN_SOUND, 1, 1);
    }
    if (furnace.getBurnTime() < 0)
        loseGame();

    if (missIndex > 1.0) 
        loseGame();

    if (cookTime <= 0)
        winGame();

}
项目:WingCommander    文件:PlayerState.java   
/**
 * Constructor.
 *
 * @param player the player.
 * @param config the configuration from which player preferences are loaded.
 */
public PlayerState(Player player, YamlConfiguration config) {
    _player = player;
    _altitudeBossBar = Bukkit.getServer().createBossBar("Altitude", BarColor.BLUE, BarStyle.SEGMENTED_20);
    _altitudeBossBar.addPlayer(_player);
    _altitudeBossBar.setProgress(0);
    _altitudeBossBar.setVisible(false);
    _speedBossBar = Bukkit.getServer().createBossBar("Speed", WingCommander.CONFIG.SPEEDOMETER_COLOUR, BarStyle.SEGMENTED_20);
    _speedBossBar.addPlayer(_player);
    _speedBossBar.setProgress(0);
    _speedBossBar.setVisible(false);
    _wingsBossBar = Bukkit.getServer().createBossBar("Wings", BarColor.GREEN, BarStyle.SEGMENTED_20);
    _wingsBossBar.addPlayer(_player);
    _wingsBossBar.setProgress(1.0);
    _wingsBossBar.setVisible(false);
    _pitchBossBar = Bukkit.getServer().createBossBar("Pitch", BarColor.GREEN, BarStyle.SEGMENTED_20);
    _pitchBossBar.addPlayer(_player);
    _pitchBossBar.setProgress(0.5);
    _pitchBossBar.setVisible(false);
    load(config);
}
项目:buildinggame    文件:Arena.java   
/**
    * Constructs a new arena with the given name as identifier
    *
    * @param name the name of the arena
    */
public Arena(String name) {
    YamlConfiguration config = SettingsManager.getInstance().getConfig();

    this.name = name;

       try {
        this.bossbar = Bukkit.createBossBar(MessageManager.translate(SettingsManager.getInstance().getMessages()
                           .getString("global.bossbar-header").replace("%subject%", "?")),
                   BarColor.valueOf(config.getString("bossbar.color").toUpperCase(Locale.getDefault())),
                   BarStyle.valueOf(config.getString("bossbar.style").toUpperCase(Locale.getDefault())));

        getBossBar().setVisible(false);
    } catch (IllegalArgumentException e) {
        Main.getInstance().getLogger().warning("Bossbar couldn't be loaded, check the data and try again.");
    }
}
项目:TimeVote    文件:TimeVote.java   
protected void setupBossBar() {
    String timeString = Options.msg.get("bossBarMessage");

    if (getTime() == Time.DAY) {
        timeString = timeString.replace("[TIME]", Options.msg.get("text.1"));
    } else {
        timeString = timeString.replace("[TIME]", Options.msg.get("text.2"));
    }

    this.bossbar = Bukkit.createBossBar(timeString, BarColor.YELLOW, BarStyle.SEGMENTED_20);

    for (Player p : getAllPlayersAtWorld()) {
        setupBossBar(p);
    }

    bossBarTimer();
}
项目:CardinalPGM    文件:TimeNotifications.java   
@Override
public void run() {
    if (GameHandler.getGameHandler().getMatch().isRunning()) {
        int timeLimit = TimeLimit.getMatchTimeLimit();
        double time = MatchTimer.getTimeInSeconds();
        if (timeLimit > 0) {
            double timeRemaining = timeLimit - time;
            BossBars.setProgress(bossBar, timeRemaining / timeLimit);
            if (lastSecond != (int) time) {
                lastSecond = (int) time;
                BossBars.setTitle(bossBar, new UnlocalizedChatMessage(ChatColor.AQUA + "{0} " + ChatUtil.getTimerColor(timeRemaining) + "{1}", new LocalizedChatMessage(ChatConstant.UI_TIMER), new UnlocalizedChatMessage(Strings.formatTime(timeRemaining + 1))));
                if (timeRemaining < 30) {
                    BossBars.broadcastedBossBars.get(bossBar).setColor(BarColor.RED);
                } else if (timeRemaining < 60) {
                    BossBars.broadcastedBossBars.get(bossBar).setColor(BarColor.YELLOW);
                } else {
                    BossBars.broadcastedBossBars.get(bossBar).setColor(BarColor.GREEN);
                }
            }
        } else if (lastSecond != (int) time) {
            lastSecond = (int) time;
            if ((int)time % 300 == 0) sendTimeElapsedMessage(time);
        }
    }
}
项目:Warzone    文件:StartCountdown.java   
@Override
protected void onTick() {
    if(isCancelled()) return;

    int amountParticipating = teamManagerModule.getAmountParticipating();
    if (amountParticipating < REQUIRED_PLAYERS) {
        int needed = REQUIRED_PLAYERS - amountParticipating;
        getBossBar().setProgress(1);
        getBossBar().setTitle(ChatColor.RED + "Waiting for " + ChatColor.AQUA + needed +
                ChatColor.RED + " more player" + (needed == 1 ? "" : "s") + " to join");
        getBossBar().setColor(BarColor.RED);

        setTimeLeft(getTimeMax());
        return;
    }

    getBossBar().setProgress((getTimeMax() - getTimeLeft()) / getTimeMax());

    if (getTimeLeft() % 20 == 0) {
        getBossBar().setColor(BarColor.GREEN);
        getBossBar().setTitle(ChatColor.GREEN + "Match starting in " + ChatColor.DARK_RED + getTimeLeftSeconds() +
                ChatColor.GREEN + " second" + (getTimeLeftSeconds() > 1 ? "s" : ""));

        if (getTimeLeftSeconds() <= 3) {
            for (Player player : Bukkit.getOnlinePlayers()) {
                player.playSound(player.getLocation(), Sound.BLOCK_NOTE_PLING, 1, 1);
                if (!TGM.get().getModule(TeamManagerModule.class).getSpectators().containsPlayer(player)) {
                    player.sendTitle(ChatColor.YELLOW.toString() + getTimeLeftSeconds(), "", 0, 5, 15);
                }
            }
        }
    }
}
项目:Arcadia-Spigot    文件:GameVotingRunnable.java   
public GameVotingRunnable() {
    this.api = Arcadia.getPlugin(Arcadia.class).getAPI();
    api.getGameManager().getMainBossBar().setColor(BarColor.YELLOW);
    List<Class<? extends BaseGame>> temp = api.getGameRegistry().getRegisteredGames();
    List<String> allowedGames = api.getPlugin().mainConfiguration.fetch().getStringList("games-in-voting");
    Iterator<Class<? extends BaseGame>> iterator = temp.iterator();
    while(iterator.hasNext()) {
        Class<? extends BaseGame> next = iterator.next();
        if(!allowedGames.contains(next.getName())) iterator.remove();
    }
    Collections.shuffle(temp);
    int slot = 2;
    for(int i=0; i<5; i++) {
        if(i < temp.size()) {
            slots.put(slot, temp.get(i));
            slot++;
        }
    }
    Bukkit.getOnlinePlayers().forEach(player -> {
        for(int i=0; i<9; i++) {
            Utils.setSpacer(player, i);
        }
        int s = 2;
        for(Class<? extends BaseGame> key : slots.values()) {
            final VotingData votingData = api.getGameRegistry().getVotingData(key);
            ItemStack itemStack = new ItemStack(votingData.getMaterialData().getItemType(), 1,
                votingData.getMaterialData().getData());
            ItemMeta itemMeta = itemStack.getItemMeta();
            itemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', "&b&l" + votingData.getGameName()));
            itemStack.setItemMeta(itemMeta);
            player.getInventory().setItem(s, itemStack);
            s++;
        }
    });
    api.getPlugin().getServer().getPluginManager().registerEvents(this, api.getPlugin());
    this.runTaskTimer(Arcadia.getPlugin(Arcadia.class), 0, 20L);
}
项目:Arcadia-Spigot    文件:GameStartRunnable.java   
public GameStartRunnable() {
    this.api = Arcadia.getPlugin(Arcadia.class).getAPI();
    api.getTranslationManager().sendTranslation("ui.game-title", api.getGameManager().getCurrentGame().getName());
    api.getTranslationManager().sendTranslation("ui.game-description", api.getGameManager().getCurrentGame().getDescription());
    for(Player player : Bukkit.getOnlinePlayers()) {
        if(api.getGameManager().isSpectating(player)) {
            api.getTranslationManager().sendTranslation("ui.game-spectating", player);
        } else {
            api.getTranslationManager().sendTranslation("ui.game-quit-playing", player);
        }
    }
    api.getGameManager().getMainBossBar().setColor(BarColor.BLUE);
    this.runTaskTimer(Arcadia.getPlugin(Arcadia.class), 0, 20L);
}
项目:Arcadia-Spigot    文件:GameRunnable.java   
public GameRunnable() {
    this.api = Arcadia.getPlugin(Arcadia.class).getAPI();
    this.minutes = api.getGameManager().getCurrentGame().getSidebarSettings().getGameMinutes();
    this.seconds = api.getGameManager().getCurrentGame().getSidebarSettings().getGameSeconds();
    this.totalSeconds = seconds+(minutes*60);
    new GameTickRunnable();
    api.getGameManager().getMainBossBar().setColor(BarColor.GREEN);
    this.runTaskTimer(Arcadia.getPlugin(Arcadia.class), 0, 20L);
}
项目:PlayerStevesBattleGrounds    文件:BattlesTimerTask.java   
@Override
public void start() {
    seconds = plugin.getConfig().getInt("battles.time");
    bar1 = plugin.getServer().createBossBar("", BarColor.WHITE, BarStyle.SOLID);
    bar2 = plugin.getServer().createBossBar("", BarColor.GREEN, BarStyle.SOLID);
    bar1.setVisible(true);
    bar2.setVisible(true);
    plugin.getServer().getOnlinePlayers().forEach(p -> {
        bar1.addPlayer(p);
        bar2.addPlayer(p);
    });
    setTask(plugin.getServer().getScheduler().runTaskTimer(plugin, this, 0L, 20L));
}
项目:ProjectAres    文件:TimeLimitCountdown.java   
@Override
public BarColor barColor(Player viewer) {
    long seconds = remaining.getSeconds();
    if(seconds > 60) {
        return BarColor.GREEN;
    } else if(seconds > 30) {
        return BarColor.YELLOW;
    } else {
        return BarColor.RED;
    }
}
项目:ProjectAres    文件:BossBarMatchModule.java   
View(BossBarSource source, Player viewer) {
    this.source = source;
    this.viewer = viewer;
    this.bar = bossBarFactory.createBossBar(Components.blank(), BarColor.WHITE, BarStyle.SOLID);
    render();
    bar.addPlayer(viewer);
}
项目:ProjectAres    文件:PlayerListener.java   
@EventHandler(priority = EventPriority.HIGHEST)
public void join(final PlayerJoinEvent event) {
    Player player = event.getPlayer();

    resetPlayer(player);

    event.getPlayer().addAttachment(lobby, Permissions.OBSERVER, true);

    if (player.hasPermission("lobby.overhead-news")) {
        final String datacenter = minecraftService.getLocalServer().datacenter();
        final Component news = new Component(ChatColor.GREEN)
            .extra(new TranslatableComponent(
                "lobby.news",
                new Component(ChatColor.GOLD, ChatColor.BOLD).extra(generalFormatter.publicHostname())
            ));

        final BossBar bar = bossBarFactory.createBossBar(renderer.render(news, player), BarColor.BLUE, BarStyle.SOLID);
        bar.setProgress(1);
        bar.addPlayer(player);
        bar.show();
    }

    if(!player.hasPermission("lobby.disabled-permissions-exempt")) {
        for(PermissionAttachmentInfo attachment : player.getEffectivePermissions()) {
            if(config.getDisabledPermissions().contains(attachment.getPermission())) {
                attachment.getAttachment().setPermission(attachment.getPermission(), false);
            }
        }
    }

    int count = lobby.getServer().getOnlinePlayers().size();
    if(!lobby.getServer().getOnlinePlayers().contains(event.getPlayer())) count++;
    minecraftService.updateLocalServer(new SignUpdate(count));
}
项目:ProjectAres    文件:RenderedBossBar.java   
@Override
public void update(BaseComponent title, double progress, BarColor color, BarStyle style, Set<BarFlag> flags) {
    this.title = title;
    this.progress = progress;
    this.color = color;
    this.style = style;
    this.flags.clear();
    this.flags.addAll(flags);

    views.entrySet().forEach(entry -> entry.getValue().update(renderer.render(title, entry.getKey()), progress, color, style, flags));
}
项目:VoxelGamesLibv2    文件:TimedPhase.java   
@Override
public void start() {
    super.start();

    originalTicks = ticks;

    log.finer("start timed phase with name " + getName());
    bossBar = Bukkit.createBossBar(getName(), BarColor.BLUE, BarStyle.SEGMENTED_20);

    getGame().getPlayers().forEach(u -> bossBar.addPlayer(u.getPlayer()));
    getGame().getSpectators().forEach(u -> bossBar.addPlayer(u.getPlayer()));

    started = true;
}
项目:SkipNight    文件:Vote.java   
public void doInterrupt() {
    countDown = 0;
    bar.setProgress(1.0);
    bar.setTitle(ChatColor.YELLOW + "All players have voted!");
    bar.setColor(BarColor.YELLOW);

    timer = Timer.COMPLETE;
    plugin.getServer().getScheduler().runTaskLater(plugin, this, 20);
}
项目:SkipNight    文件:Vote.java   
private void doComplete() {
    countDown--;
    if (countDown == -1) {
        bar.setProgress(1.0);
        if (yes > no) {
            bar.setTitle(ChatColor.GREEN + "Vote passed!");
            bar.setColor(BarColor.GREEN);
            updateAll(voters, Messages.votePassed());
            world.setTime(0);
            if (world.hasStorm()) world.setStorm(false);
        }
        else {
            bar.setTitle(ChatColor.DARK_RED + "Vote failed!");
            bar.setColor(BarColor.RED);
            updateAll(voters, Messages.voteFailed());
        }
        plugin.getServer().getScheduler().runTaskLater(plugin, this, 20);
    }

    if (countDown == -2) plugin.getServer().getScheduler().runTaskLater(plugin, this, 20);

    if (countDown == -3) {
        HandlerList.unregisterAll(this);
        bar.removeAll();
        bar = null;
        voters = null;
    }
}
项目:DragonEggDrop    文件:DragonBattle1_10_R1.java   
@Override
public boolean setBossBarStyle(BarStyle style, BarColor colour) {
    try {
        Field fieldBossBattleServer = EnderDragonBattle.class.getDeclaredField("c");
        fieldBossBattleServer.setAccessible(true);

        BossBattleServer battleServer = (BossBattleServer) fieldBossBattleServer.get(battle);
        if (battleServer == null) return false;

        if (style != null) {
            String nmsStyle = style.name().contains("SEGMENTED") ? style.name().replace("SEGMENTED", "NOTCHED") : "PROGRESS";
            if (EnumUtils.isValidEnum(BossBattle.BarStyle.class, nmsStyle)) {
                battleServer.style = BossBattle.BarStyle.valueOf(nmsStyle);
            }
        }
        if (colour != null) {
            battleServer.color = BossBattle.BarColor.valueOf(colour.name());
        }

        battleServer.sendUpdate(PacketPlayOutBoss.Action.UPDATE_STYLE);
        fieldBossBattleServer.setAccessible(false);
    } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
        e.printStackTrace();
        return false;
    }

    return true;
}
项目:DragonEggDrop    文件:DragonBattle1_12_R1.java   
@Override
public boolean setBossBarStyle(BarStyle style, BarColor colour) {
    try {
        Field fieldBossBattleServer = EnderDragonBattle.class.getDeclaredField("c");
        fieldBossBattleServer.setAccessible(true);

        BossBattleServer battleServer = (BossBattleServer) fieldBossBattleServer.get(battle);
        if (battleServer == null) return false;

        if (style != null) {
            String nmsStyle = style.name().contains("SEGMENTED") ? style.name().replace("SEGMENTED", "NOTCHED") : "PROGRESS";
            if (EnumUtils.isValidEnum(BossBattle.BarStyle.class, nmsStyle)) {
                battleServer.style = BossBattle.BarStyle.valueOf(nmsStyle);
            }
        }
        if (colour != null) {
            battleServer.color = BossBattle.BarColor.valueOf(colour.name());
        }

        battleServer.sendUpdate(PacketPlayOutBoss.Action.UPDATE_STYLE);
        fieldBossBattleServer.setAccessible(false);
    } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
        e.printStackTrace();
        return false;
    }

    return true;
}
项目:DragonEggDrop    文件:DragonBattle1_9_R1.java   
@Override
public boolean setBossBarStyle(BarStyle style, BarColor colour) {
    try {
        Field fieldBossBattleServer = EnderDragonBattle.class.getDeclaredField("c");
        fieldBossBattleServer.setAccessible(true);

        BossBattleServer battleServer = (BossBattleServer) fieldBossBattleServer.get(battle);
        if (battleServer == null) return false;

        if (style != null) {
            String nmsStyle = style.name().contains("SEGMENTED") ? style.name().replace("SEGMENTED", "NOTCHED") : "PROGRESS";
            if (EnumUtils.isValidEnum(BossBattle.BarStyle.class, nmsStyle)) {
                battleServer.style = BossBattle.BarStyle.valueOf(nmsStyle);
            }
        }
        if (colour != null) {
            battleServer.color = BossBattle.BarColor.valueOf(colour.name());
        }

        battleServer.sendUpdate(PacketPlayOutBoss.Action.UPDATE_STYLE);
        fieldBossBattleServer.setAccessible(false);
    } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
        e.printStackTrace();
        return false;
    }

    return true;
}
项目:DragonEggDrop    文件:DragonBattle1_9_R2.java   
@Override
public boolean setBossBarStyle(BarStyle style, BarColor colour) {
    try {
        Field fieldBossBattleServer = EnderDragonBattle.class.getDeclaredField("c");
        fieldBossBattleServer.setAccessible(true);

        BossBattleServer battleServer = (BossBattleServer) fieldBossBattleServer.get(battle);
        if (battleServer == null) return false;

        if (style != null) {
            String nmsStyle = style.name().contains("SEGMENTED") ? style.name().replace("SEGMENTED", "NOTCHED") : "PROGRESS";
            if (EnumUtils.isValidEnum(BossBattle.BarStyle.class, nmsStyle)) {
                battleServer.style = BossBattle.BarStyle.valueOf(nmsStyle);
            }
        }
        if (colour != null) {
            battleServer.color = BossBattle.BarColor.valueOf(colour.name());
        }

        battleServer.sendUpdate(PacketPlayOutBoss.Action.UPDATE_STYLE);
        fieldBossBattleServer.setAccessible(false);
    } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
        e.printStackTrace();
        return false;
    }

    return true;
}
项目:DragonEggDrop    文件:DragonBattle1_11_R1.java   
@Override
public boolean setBossBarStyle(BarStyle style, BarColor colour) {
    try {
        Field fieldBossBattleServer = EnderDragonBattle.class.getDeclaredField("c");
        fieldBossBattleServer.setAccessible(true);

        BossBattleServer battleServer = (BossBattleServer) fieldBossBattleServer.get(battle);
        if (battleServer == null) return false;

        if (style != null) {
            String nmsStyle = style.name().contains("SEGMENTED") ? style.name().replace("SEGMENTED", "NOTCHED") : "PROGRESS";
            if (EnumUtils.isValidEnum(BossBattle.BarStyle.class, nmsStyle)) {
                battleServer.style = BossBattle.BarStyle.valueOf(nmsStyle);
            }
        }
        if (colour != null) {
            battleServer.color = BossBattle.BarColor.valueOf(colour.name());
        }

        battleServer.sendUpdate(PacketPlayOutBoss.Action.UPDATE_STYLE);
        fieldBossBattleServer.setAccessible(false);
    } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
        e.printStackTrace();
        return false;
    }

    return true;
}
项目:DragonEggDrop    文件:DragonTemplate.java   
/**
 * Construct a new DragonTemplate object
 * 
 * @param file the file holding this template data
 * @param name the name of the dragon. Can be null
 * @param barStyle the style of the bar. Can be null
 * @param barColour the colour of the bar. Can be null
 */
public DragonTemplate(File file, String name, BarStyle barStyle, BarColor barColour) {
    Validate.notNull(file, "File cannot be null. See DragonTemplate(String, String, BarStyle, BarColor) for null files");

    this.file = file;
    this.configFile = YamlConfiguration.loadConfiguration(file);
    this.identifier = file.getName().substring(0, file.getName().lastIndexOf('.'));

    this.name = (name != null ? ChatColor.translateAlternateColorCodes('&', name) : null);
    this.barStyle = (barStyle != null ? barStyle : BarStyle.SOLID);
    this.barColour = (barColour != null ? barColour : BarColor.PINK);
    this.loot = new DragonLoot(this);
}
项目:DragonEggDrop    文件:DragonTemplate.java   
/**
 * Construct a new DragonTemplate object
 * 
 * @param identifier the name to identify this template
 * @param name the name of the dragon. Can be null
 * @param barStyle the style of the bar. Can be null
 * @param barColour the colour of the bar. Can be null
 */
public DragonTemplate(String identifier, String name, BarStyle barStyle, BarColor barColour) {
    Validate.notEmpty(identifier, "Idenfitier must not be empty or null");

    this.file = null;
    this.configFile = null;
    this.identifier = identifier;

    this.name = (name != null ? ChatColor.translateAlternateColorCodes('&', name) : null);
    this.barStyle = (barStyle != null ? barStyle : BarStyle.SOLID);
    this.barColour = (barColour != null ? barColour : BarColor.PINK);
    this.loot = new DragonLoot(this);
}
项目:DragonEggDrop    文件:DragonTemplate.java   
/**
 * Set the colour of the boss bar
 * 
 * @param barColour the new boss bar colour
 * @param updateFile whether to update the dragon file or not
 */
public void setBarColor(BarColor barColour, boolean updateFile) {
    this.barColour = barColour;

    if (updateFile) {
        this.updateConfig("bar-color", barColour);
    }
}
项目:RealisticSwimming    文件:StaminaBar_Native.java   
StaminaBar_Native(Player player){
    super(player);
    //****************************** Changes by DrkMatr1984 START ******************************
    if(ChatColor.translateAlternateColorCodes('&', Language.stamina).length()>64)
        staminaBar = Bukkit.createBossBar(ChatColor.translateAlternateColorCodes('&', Language.stamina).substring(0, 63), BarColor.GREEN, BarStyle.SOLID);
    else
        staminaBar = Bukkit.createBossBar(ChatColor.translateAlternateColorCodes('&', Language.stamina), BarColor.GREEN, BarStyle.SOLID);
    //****************************** Changes by DrkMatr1984 END ******************************
    staminaBar.addPlayer(p);

}
项目:RealisticSwimming    文件:StaminaBar_Native.java   
@Override
protected void setColor(float staminaValue) {
    //noinspection StatementWithEmptyBody
    if(staminaValue > 700){
        //Do nothing because the bar is already green
    }else if(staminaValue > 400){
        staminaBar.setColor(BarColor.YELLOW);
    }else if(staminaValue > 300){
        staminaBar.setColor(BarColor.RED);
    }else if(Config.blinkStaminaBarWhenStaminaIsLow){
        alert();
    }
}
项目:RealisticSwimming    文件:StaminaBar_Native.java   
@Override
protected void alert() {
    if(staminaBar.getColor() == BarColor.RED){
        staminaBar.setColor(BarColor.YELLOW);
    }else if(staminaBar.getColor() == BarColor.YELLOW){
        staminaBar.setColor(BarColor.RED);
    }
}
项目:Thirst    文件:ThirstManager.java   
private BarColor validateColor(String name)
{
    try
    {
        return Enum.valueOf(BarColor.class, name.toUpperCase());
    }
    catch (IllegalArgumentException iae)
    {
        return null;
    }
}
项目:NationZ    文件:NZPlayer.java   
public void updateBossBar() {
    BossBar b = Bukkit.createBossBar("error", BarColor.GREEN, BarStyle.SOLID);
    b.addPlayer(getPlayer());
    int begin = getJobExp().getXPLVL().begin;
    int current = getJobExp().getEXP();
    int end = getJobExp().getXPLVL().end;
    b.setTitle(getJob().getDisplayname() + ChatColor.DARK_GRAY + " - " + Job.getColor() + current + ChatColor.DARK_GRAY + "/" + Job.getColor() + end);
    b.setProgress(100 / (end - begin) * (current - begin));

}
项目:GameBoxx    文件:BarColors.java   
@Override
public void onLoad() {
    add(BarColor.PINK, "Pink", "PI", "P", "Default", "Def", "D");
    add(BarColor.BLUE, "Blue", "BL", "B");
    add(BarColor.RED, "Red", "RE", "R");
    add(BarColor.GREEN, "Green", "GR", "G");
    add(BarColor.YELLOW, "Yellow", "YE", "Y");
    add(BarColor.PURPLE, "Purple", "PU", "P");
    add(BarColor.WHITE, "White", "WH", "W");
}
项目:Arcade2    文件:MatchStartCountdown.java   
public MatchStartCountdown(ArcadePlugin plugin, Match match) {
    super(plugin.getTasks(), null);
    this.plugin = plugin;

    this.match = match;
    this.setBossBar(plugin.getServer().createBossBar(new TextComponent(), BarColor.GREEN, BarStyle.SOLID));
}