org.bukkit.boss.BarFlag Java Examples

The following examples show how to use org.bukkit.boss.BarFlag. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LocalizedBossBar.java    From CardinalPGM with MIT License 5 votes vote down vote up
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);
}
 
Example #2
Source File: RenderedBossBar.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void addPlayer(Player player) {
    if(!views.containsKey(player)) {
        final BossBar view = bossBarFactory.createBossBar(renderer.render(title, player), color, style, flags.toArray(new BarFlag[flags.size()]));
        view.setVisible(visibile);
        view.addPlayer(player);
        views.put(player, view);
    }
}
 
Example #3
Source File: RenderedBossBar.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
@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));
}
 
Example #4
Source File: BossBarManager.java    From skRayFall with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Add a flag to a bossbar in the BossBarManager through the stored ID.
 *
 * @param id   The ID text for the bossbar.
 * @param flag The BarFlag to be added.
 */
void addFlag(String id, BarFlag flag) {
    BossBar bar = barMap.get(id);
    if (bar != null) {
        bar.addFlag(flag);
        barMap.put(id, bar);
    }
}
 
Example #5
Source File: BossBarManager.java    From skRayFall with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Remove a flag from a bossbar in the BossBarManager through the stored ID.
 *
 * @param id   The ID text for the bossbar.
 * @param flag The BarFlag to be added.
 */
void removeFlag(String id, BarFlag flag) {
    BossBar bar = barMap.get(id);
    if (bar != null) {
        bar.removeFlag(flag);
        barMap.put(id, bar);
    }
}
 
Example #6
Source File: BossBarOptions.java    From FunnyGuilds with Apache License 2.0 5 votes vote down vote up
public Builder flags(Collection<? extends String> barFlags) {
    for (String flag : barFlags) {
        for (BarFlag barFlag : BarFlag.values()) {
            if (barFlag.name().equalsIgnoreCase(flag)) {
                this.barFlags.add(barFlag);
            }
        }
    }

    return this;
}
 
Example #7
Source File: CraftBossBar.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
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();
}
 
Example #8
Source File: LocalizedBossBar.java    From CardinalPGM with MIT License 5 votes vote down vote up
public void removeFlag(BarFlag flag) {
    if (this.flags.contains(flag)) {
        this.flags.remove(flag);
        for (BossBar bossbar : playerBossBars.values()) {
            bossbar.setFlags(this.flags);
        }
    }
}
 
Example #9
Source File: LocalizedBossBar.java    From CardinalPGM with MIT License 5 votes vote down vote up
public void addFlag(BarFlag flag) {
    if (!this.flags.contains(flag)) {
        this.flags.remove(flag);
        for (BossBar bossbar : playerBossBars.values()) {
            bossbar.setFlags(this.flags);
        }
    }
}
 
Example #10
Source File: LocalizedBossBar.java    From CardinalPGM with MIT License 5 votes vote down vote up
public void addPlayer(Player player) {
    if (!playerBossBars.containsKey(player)) {
        BossBar bossBar = Bukkit.createBossBar(getTitle(player.getLocale()), this.color, this.style, this.flags.toArray(new BarFlag[flags.size()]));
        bossBar.setVisible(this.shown);
        bossBar.addPlayer(player);
        playerBossBars.put(player, bossBar);
    }
}
 
Example #11
Source File: BossBars.java    From CardinalPGM with MIT License 5 votes vote down vote up
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;
}
 
Example #12
Source File: LocalizedBossBar.java    From CardinalPGM with MIT License 4 votes vote down vote up
public void setFlags(Set<BarFlag> flags) {
    this.flags = flags;
    for (BossBar bossbar : playerBossBars.values()) {
        bossbar.setFlags(this.flags);
    }
}
 
Example #13
Source File: RenderedBossBar.java    From ProjectAres with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void addFlag(BarFlag flag) {
    this.flags.add(flag);
    views.values().forEach(view -> view.addFlag(flag));
}
 
Example #14
Source File: BossBarOptions.java    From FunnyGuilds with Apache License 2.0 4 votes vote down vote up
Set<BarFlag> getFlags() {
    return this.barFlags;
}
 
Example #15
Source File: BossBarOptions.java    From FunnyGuilds with Apache License 2.0 4 votes vote down vote up
private BossBarOptions(BarColor barColor, BarStyle barStyle, Set<BarFlag> barFlags) {
    this.barColor = barColor;
    this.barStyle = barStyle;
    this.barFlags = barFlags;
}
 
Example #16
Source File: LocalizedBossBar.java    From CardinalPGM with MIT License 4 votes vote down vote up
public boolean hasFlag(BarFlag flag) {
    return this.flags.contains(flag);
}
 
Example #17
Source File: BossBarNotifyIO.java    From BetonQuest with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void sendNotify(String message, Collection<? extends Player> players) {
    BossBar bossBar = Bukkit.createBossBar(Utils.format(message), barColor, style);
    if (barFlags != null) {
        for (BarFlag flag : barFlags) {
            bossBar.addFlag(flag);
        }
    }
    bossBar.setProgress(progress);

    // Show bar
    for (Player player : players) {
        bossBar.addPlayer(player);
    }

    bossBar.setVisible(true);

    // Remove after stay ticks
    new BukkitRunnable() {

        @Override
        public void run() {
            bossBar.removeAll();
        }
    }.runTaskLater(BetonQuest.getInstance(), stay);

    // If Countdown, then divide stay by countdown and reduce progress to 0 by those intevals
    if (countdown > 0) {
        int interval = stay / countdown;
        double amount = progress / ((double) countdown);
        new BukkitRunnable() {

            @Override
            public void run() {
                if (countdown == 0) {
                    cancel();
                    return;
                }
                countdown -= 1;
                progress -= amount;
                bossBar.setProgress(Math.max(0.0, progress));
            }
        }.runTaskTimer(BetonQuest.getInstance(), interval, interval);
    }

    super.sendNotify(message, players);
}
 
Example #18
Source File: BarConfig.java    From CraftserveRadiation with Apache License 2.0 4 votes vote down vote up
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");
}
 
Example #19
Source File: RenderedBossBar.java    From ProjectAres with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void removeFlag(BarFlag flag) {
    this.flags.remove(flag);
    views.values().forEach(view -> view.removeFlag(flag));
}
 
Example #20
Source File: RenderedBossBar.java    From ProjectAres with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void setFlags(Set<BarFlag> flags) {
    this.flags.clear();
    this.flags.addAll(flags);
    views.values().forEach(view -> view.setFlags(flags));
}
 
Example #21
Source File: RenderedBossBar.java    From ProjectAres with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public boolean hasFlag(BarFlag flag) {
    return this.flags.contains(flag);
}
 
Example #22
Source File: BossBarFactoryImpl.java    From ProjectAres with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public BossBar createBossBar(BaseComponent title, BarColor color, BarStyle style, BarFlag... flags) {
    return server.createBossBar(title, color, style, flags);
}
 
Example #23
Source File: BossBarSource.java    From ProjectAres with GNU Affero General Public License v3.0 4 votes vote down vote up
default Set<BarFlag> barFlags(Player viewer) {
    return Collections.emptySet();
}
 
Example #24
Source File: CraftBossBar.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean hasFlag(BarFlag flag) {
    return flags.contains(flag);
}
 
Example #25
Source File: CraftBossBar.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void removeFlag(BarFlag flag) {
    flags.remove(flag);
    updateFlags();
}
 
Example #26
Source File: CraftBossBar.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void addFlag(BarFlag flag) {
    flags.add(flag);
    updateFlags();
}
 
Example #27
Source File: CraftBossBar.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
private void updateFlags() {
    handle.setDarkenSky(hasFlag(BarFlag.DARKEN_SKY));
    handle.setPlayEndBossMusic(hasFlag(BarFlag.PLAY_BOSS_MUSIC));
    handle.setCreateFog(hasFlag(BarFlag.CREATE_FOG));
}
 
Example #28
Source File: CraftServer.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
@Override
public BossBar createBossBar(String title, BarColor color, BarStyle style, BarFlag... flags) {
    return new CraftBossBar(title, color, style, flags);
}
 
Example #29
Source File: RadiationPlugin.java    From CraftserveRadiation with Apache License 2.0 4 votes vote down vote up
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;
}
 
Example #30
Source File: BarConfig.java    From CraftserveRadiation with Apache License 2.0 4 votes vote down vote up
public BarFlag[] flags() {
    return this.flags;
}