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

下面列出了怎么用org.bukkit.boss.BarColor的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: BedWars   文件: GameCreator.java
private String setGameBossBarColor(String color) {
    color = color.toUpperCase();
    BarColor c = null;
    if (!color.equalsIgnoreCase("default")) {
        try {
            c = BarColor.valueOf(color);
        } catch (Exception e) {
            return i18n("admin_command_invalid_bar_color");
        }
    }

    game.setGameBossBarColor(c);

    return i18n("admin_command_bar_color_set").replace("%color%", c == null ? "default" : c.name())
            .replace("%type%", "GAME");
}
 
源代码2 项目: BedWars   文件: GameCreator.java
private String setLobbyBossBarColor(String color) {
    color = color.toUpperCase();
    BarColor c = null;
    if (!color.equalsIgnoreCase("default")) {
        try {
            c = BarColor.valueOf(color);
        } catch (Exception e) {
            return i18n("admin_command_invalid_bar_color");
        }
    }

    game.setLobbyBossBarColor(c);

    return i18n("admin_command_bar_color_set").replace("%color%", c == null ? "default" : c.name())
            .replace("%type%", "LOBBY");
}
 
源代码3 项目: BedWars   文件: GameCreator.java
private String setGameBossBarColor(String color) {
    color = color.toUpperCase();
    BarColor c = null;
    if (!color.equalsIgnoreCase("default")) {
        try {
            c = BarColor.valueOf(color);
        } catch (Exception e) {
            return i18n("admin_command_invalid_bar_color");
        }
    }

    game.setGameBossBarColor(c);

    return i18n("admin_command_bar_color_set").replace("%color%", c == null ? "default" : c.name())
            .replace("%type%", "GAME");
}
 
源代码4 项目: BedWars   文件: GameCreator.java
private String setLobbyBossBarColor(String color) {
    color = color.toUpperCase();
    BarColor c = null;
    if (!color.equalsIgnoreCase("default")) {
        try {
            c = BarColor.valueOf(color);
        } catch (Exception e) {
            return i18n("admin_command_invalid_bar_color");
        }
    }

    game.setLobbyBossBarColor(c);

    return i18n("admin_command_bar_color_set").replace("%color%", c == null ? "default" : c.name())
            .replace("%type%", "LOBBY");
}
 
源代码5 项目: helper   文件: BukkitBossBarFactory.java
private static BarColor convertColor(BossBarColor color) {
    switch (color) {
        case PINK:
            return BarColor.PINK;
        case BLUE:
            return BarColor.BLUE;
        case RED:
            return BarColor.RED;
        case GREEN:
            return BarColor.GREEN;
        case YELLOW:
            return BarColor.YELLOW;
        case PURPLE:
            return BarColor.PURPLE;
        case WHITE:
            return BarColor.WHITE;
        default:
            return convertColor(BossBarColor.defaultColor());
    }
}
 
源代码6 项目: 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());
}
 
源代码7 项目: AdditionsAPI   文件: DurabilityBar.java
public static void hideDurabilityBossBar(Player player, EquipmentSlot slot) {
	UUID uuid = player.getUniqueId();
	BossBar bar;
	HashMap<UUID, BossBar> playersBars;
	if (slot.equals(EquipmentSlot.HAND)) {
		playersBars = playersBarsMain;
	} else if (slot.equals(EquipmentSlot.OFF_HAND)) {
		playersBars = playersBarsOff;
	} else {
		return;
	}
	if (!playersBars.containsKey(uuid)) {
		return;
	} else {
		bar = playersBars.get(uuid);
	}

	bar.setVisible(false);
	bar.setProgress(1.0D);
	bar.setColor(BarColor.GREEN);
}
 
源代码8 项目: 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);
        }
    }
}
 
源代码9 项目: BedWars   文件: Game.java
public static BarColor loadBossBarColor(String color) {
    try {
        return BarColor.valueOf(color);
    } catch (Exception e) {
        return null;
    }
}
 
源代码10 项目: BedWars   文件: Game.java
public static BarColor loadBossBarColor(String color) {
    try {
        return BarColor.valueOf(color);
    } catch (Exception e) {
        return null;
    }
}
 
源代码11 项目: Kettle   文件: CraftBossBar.java
public CraftBossBar(String title, BarColor color, BarStyle style, BarFlag... flags) {
    this.flags = flags.length > 0 ? EnumSet.of(flags[0], flags) : EnumSet.noneOf(BarFlag.class);
    this.color = color;
    this.style = style;

    handle = new BossInfoServer(
            CraftChatMessage.fromString(title, true)[0],
            convertColor(color),
            convertStyle(style)
    );

    updateFlags();
}
 
源代码12 项目: Harbor   文件: Messages.java
private static BarColor getBarColor(final String enumString) {
    BarColor barColor;
    try {
        barColor = BarColor.valueOf(enumString.toUpperCase().trim());
    } catch (IllegalArgumentException e) {
        barColor = BarColor.BLUE;
    }
    return barColor;
}
 
源代码13 项目: 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;
    }
}
 
源代码14 项目: 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);
}
 
源代码15 项目: HeavySpleef   文件: FlagBossbar.java
@Override
public void onFlagAdd(Game game) {
    baseTitle = getI18N().getVarString(Messages.Broadcast.BOSSBAR_PLAYING_ON)
            .setVariable("game", game.getName())
            .toString();
    baseColor = new SafeContainer<>(BarColor.GREEN);

    bossBar = new SafeContainer<>(Bukkit.getServer().createBossBar(baseTitle, baseColor.value, BarStyle.SOLID));
    bossBar.value.setProgress(DEFAULT_PROGRESS);
}
 
源代码16 项目: 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));
}
 
源代码17 项目: 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));
}
 
源代码18 项目: VoxelGamesLibv2   文件: TimedPhase.java
@Override
public void enable() {
    super.enable();

    originalTicks = ticks;

    log.finer("enable 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;
}
 
源代码19 项目: NovaGuilds   文件: BossBarUtilsBukkitImpl.java
/**
 * Creates a boss bar if doesn't exist
 *
 * @param player the player
 * @return the boss bar
 */
private BossBar createIfNotExists(Player player) {
	if(bossBars.containsKey(player.getUniqueId())) {
		return getBossBar(player);
	}

	BossBar bossBar = Bukkit.getServer().createBossBar("", Config.BOSSBAR_RAIDBAR_COLOR.toEnum(BarColor.class), Config.BOSSBAR_RAIDBAR_STYLE.toEnum(BarStyle.class));
	bossBar.addPlayer(player);
	bossBars.put(player.getUniqueId(), bossBar);
	return bossBar;
}
 
源代码20 项目: skRayFall   文件: BossBarManager.java
/**
 * Changed the color of a bossbar from the BossBarManager through the stored ID.
 *
 * @param id    The ID text for the bossbar.
 * @param color The BarColor to be used.
 */
void changeColor(String id, BarColor color) {
    BossBar bar = barMap.get(id);
    if (bar != null) {
        bar.setColor(color);
        barMap.put(id, bar);
    }
}
 
源代码21 项目: skRayFall   文件: EffCreateModernBossBar.java
@Override
protected void execute(Event evt) {
    BarStyle barStyle = BarStyle.SOLID;
    BarColor barColor = BarColor.PURPLE;
    if (style != null) {
        barStyle = style.getSingle(evt).getKey();
    }
    if (color != null) {
        barColor = color.getSingle(evt).getKey();
    }
    BossBar bar;
    if (flag != null) {
        bar = Bukkit.createBossBar(title.getSingle(evt).replace("\"", ""), barColor, barStyle,
                flag.getSingle(evt).getKey());
    } else {
        bar = Bukkit.createBossBar(title.getSingle(evt).replace("\"", ""), barColor, barStyle);
    }
    if (value != null) {
        double vol = value.getSingle(evt).doubleValue();
        if (vol > 100) {
            vol = 100;
        } else if (vol < 0) {
            vol = 0;
        }
        bar.setProgress(vol / 100);
    }
    for (Player p : players.getAll(evt)) {
        bar.addPlayer(p);
    }
    Core.bossbarManager.createBossBar(id.getSingle(evt).replace("\"", ""), bar);
}
 
源代码22 项目: FunnyGuilds   文件: BossBarOptions.java
public Builder color(String barColor) {
    for (BarColor loopColor : BarColor.values()) {
        if (loopColor.name().equalsIgnoreCase(barColor)) {
            this.barColor = loopColor;
            break;
        }
    }

    return this;
}
 
源代码23 项目: CardinalPGM   文件: MonumentModes.java
public MonumentModes(int after, final Pair<Material, Integer> material, final String name, int showBefore) {
    this.after = after;
    this.material = material;
    this.name = name;
    this.showBefore = showBefore;

    this.ran = false;

    this.bossBar = BossBars.addBroadcastedBossBar(new UnlocalizedChatMessage(""), BarColor.BLUE, BarStyle.SOLID, false);
}
 
源代码24 项目: CardinalPGM   文件: LocalizedBossBar.java
public LocalizedBossBar(ChatMessage bossBarTitle, BarColor color, BarStyle style, BarFlag... flags) {
    this.bossBarTitle = bossBarTitle;
    this.color = color;
    this.style = style;
    this.shown = true;
    this.flags = flags.length > 0 ? EnumSet.of(flags[0], flags):EnumSet.noneOf(BarFlag.class);
}
 
源代码25 项目: CardinalPGM   文件: LocalizedBossBar.java
public void setColor(BarColor color) {
    if (color != this.color) {
        this.color = color;
        for (BossBar bossbar : playerBossBars.values()) {
            bossbar.setColor(color);
        }
    }
}
 
源代码26 项目: CardinalPGM   文件: BossBars.java
public static UUID addBroadcastedBossBar(ChatMessage bossBarTitle, BarColor color, BarStyle style, Boolean shown, BarFlag... flags) {
    UUID id = UUID.randomUUID();
    LocalizedBossBar bossBar = new LocalizedBossBar(bossBarTitle, color, style, flags);
    bossBar.setVisible(shown);
    for (Player player : Bukkit.getOnlinePlayers()) {
        bossBar.addPlayer(player);
    }
    broadcastedBossBars.put(id, bossBar);
    return id;
}
 
源代码27 项目: CardinalPGM   文件: Poll.java
protected Poll(int id, CommandSender sender, String command, int time, boolean any) {
    this.id = id;
    this.sender = sender;
    this.command = command;
    this.any = any;
    this.time = time * 20;
    this.originalTime = this.time;
    this.bossBar = BossBars.addBroadcastedBossBar(new UnlocalizedChatMessage(""), BarColor.YELLOW, BarStyle.SOLID, true);
    taskId = Bukkit.getScheduler().scheduleSyncRepeatingTask(Cardinal.getInstance(), new Runnable() {
        @Override
        public void run() {
            Poll.this.update();
        }
    }, 0L, 1L);
}
 
源代码28 项目: CraftserveRadiation   文件: BarConfig.java
public BarConfig(String title, BarColor color, BarStyle style, BarFlag[] flags) {
    this.title = Objects.requireNonNull(title, "title");
    this.color = Objects.requireNonNull(color, "color");
    this.style = Objects.requireNonNull(style, "style");
    this.flags = Objects.requireNonNull(flags, "flags");
}
 
源代码29 项目: CraftserveRadiation   文件: BarConfig.java
public BarColor color() {
    return this.color;
}
 
源代码30 项目: CraftserveRadiation   文件: RadiationPlugin.java
private boolean migrate(ConfigurationSection section, int protocol) {
    Objects.requireNonNull(section, "section");
    Logger logger = this.getLogger();

    if (protocol > CURRENT_PROTOCOL_VERSION) {
        logger.severe("Your configuration file's protocol version \"" + protocol +
                "\" is invalid. Are you trying to load it using a newer version of the plugin?");
        return false;
    }

    if (protocol < 0) {
        section.set("lugols-iodine-bar.title", "Działanie Płynu Lugola");
        section.set("lugols-iodine-bar.color", BarColor.GREEN.name());
        section.set("lugols-iodine-bar.style", BarStyle.SEGMENTED_20.name());
        section.set("lugols-iodine-bar.flags", Collections.emptyList());

        section.set("lugols-iodine-potion.name", "Płyn Lugola");
        section.set("lugols-iodine-potion.description", "Odporność na promieniowanie ({0})");
        section.set("lugols-iodine-potion.duration", TimeUnit.MINUTES.toSeconds(section.getInt("potion-duration", 10)));
        section.set("lugols-iodine-potion.drink-message", "{0}" + ChatColor.RED + " wypił/a {1}.");

        section.set("radiation.bar.title", "Strefa radiacji");
        section.set("radiation.bar.color", BarColor.RED.name());
        section.set("radiation.bar.style", BarStyle.SOLID.name());
        section.set("radiation.bar.flags", Collections.singletonList(BarFlag.DARKEN_SKY.name()));

        section.set("radiation.effects.wither.level", 5);
        section.set("radiation.effects.wither.ambient", false);
        section.set("radiation.effects.wither.has-particles", false);
        section.set("radiation.effects.wither.has-icon", false);

        section.set("radiation.effects.hunger.level", 1);
        section.set("radiation.effects.hunger.ambient", false);
        section.set("radiation.effects.hunger.has-particles", false);
        section.set("radiation.effects.hunger.has-icon", false);

        section.set("radiation.escape-message", "{0}" + ChatColor.RED + " uciekł/a do strefy radiacji.");

        // Migrate from the old region-ID based system.
        String legacyRegionId = section.getString("region-name", "km_safe_from_radiation");
        AtomicBoolean logged = new AtomicBoolean();
        section.getStringList("world-names").forEach(worldName -> {
            if (logged.compareAndSet(false, true)) {
                logger.warning(
                        "Enabling in legacy region-name mode! The plugin will try to automatically migrate to the new flag-based system.\n" +
                        "If everything went fine please completely remove your config.yml file.");
            }

            this.migrateFromRegionId(worldName, legacyRegionId);
        });
    }

    if (protocol < 1) {
        section.set("lugols-iodine-potion.recipe.enabled", true);
        section.set("lugols-iodine-potion.recipe.base-potion", LugolsIodinePotion.Config.Recipe.DEFAULT_BASE_POTION.name());
        section.set("lugols-iodine-potion.recipe.ingredient", LugolsIodinePotion.Config.Recipe.DEFAULT_INGREDIENT.getKey().getKey());

        section.set("lugols-iodine-potion.color", null);
    }

    return true;
}
 
 类所在包
 类方法
 同包方法