本文整理匯總了Java中org.bukkit.boss.BarStyle類的典型用法代碼示例。如果您正苦於以下問題:Java BarStyle類的具體用法?Java BarStyle怎麽用?Java BarStyle使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
BarStyle類屬於org.bukkit.boss包,在下文中一共展示了BarStyle類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getBar
import org.bukkit.boss.BarStyle; //導入依賴的package包/類
/**
* 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);
}
示例2: updateArena
import org.bukkit.boss.BarStyle; //導入依賴的package包/類
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());
}
示例3: doInit
import org.bukkit.boss.BarStyle; //導入依賴的package包/類
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);
}
示例4: doBar
import org.bukkit.boss.BarStyle; //導入依賴的package包/類
/**
* 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);
}
}
示例5: start
import org.bukkit.boss.BarStyle; //導入依賴的package包/類
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);
}
示例6: start
import org.bukkit.boss.BarStyle; //導入依賴的package包/類
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)));
}
示例7: PlayerState
import org.bukkit.boss.BarStyle; //導入依賴的package包/類
/**
* 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);
}
示例8: Arena
import org.bukkit.boss.BarStyle; //導入依賴的package包/類
/**
* 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.");
}
}
示例9: setupBossBar
import org.bukkit.boss.BarStyle; //導入依賴的package包/類
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();
}
示例10: start
import org.bukkit.boss.BarStyle; //導入依賴的package包/類
@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));
}
示例11: View
import org.bukkit.boss.BarStyle; //導入依賴的package包/類
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);
}
示例12: join
import org.bukkit.boss.BarStyle; //導入依賴的package包/類
@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));
}
示例13: update
import org.bukkit.boss.BarStyle; //導入依賴的package包/類
@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));
}
示例14: start
import org.bukkit.boss.BarStyle; //導入依賴的package包/類
@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;
}
示例15: setBossBarStyle
import org.bukkit.boss.BarStyle; //導入依賴的package包/類
@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;
}