geforkt von Mirrors/Velocity
Rename some bossbar-related fields and methods
Dieser Commit ist enthalten in:
Ursprung
20b34447f8
Commit
0a53343547
@ -66,19 +66,19 @@ public interface BossBar {
|
||||
void setTitle(@NonNull Component title);
|
||||
|
||||
/**
|
||||
* Gets the boss bar's progress. In Minecraft, this is called 'health' of the boss bar.
|
||||
* Gets the boss bar's percent.
|
||||
*
|
||||
* @return progress
|
||||
* @return percent
|
||||
*/
|
||||
float getProgress();
|
||||
float getPercent();
|
||||
|
||||
/**
|
||||
* Sets a new progress of the boss bar. In Minecraft, this is called 'health' of the boss bar.
|
||||
* Sets a new percent of the boss bar.
|
||||
*
|
||||
* @param progress a float between 0 and 1, representing boss bar's progress
|
||||
* @throws IllegalArgumentException if the new progress is not between 0 and 1
|
||||
* @param percent a float between 0 and 1, representing boss bar's percent
|
||||
* @throws IllegalArgumentException if the new percent is not between 0 and 1
|
||||
*/
|
||||
void setProgress(float progress);
|
||||
void setPercent(float percent);
|
||||
|
||||
/**
|
||||
* Returns a copy of the {@link Collection} of all {@link Player} added to the boss bar.
|
||||
|
@ -4,7 +4,7 @@ package com.velocitypowered.api.util.bossbar;
|
||||
* Represents any {@link BossBar}'s flags.
|
||||
*/
|
||||
public enum BossBarFlag {
|
||||
DARKEN_SKY,
|
||||
DRAGON_BAR,
|
||||
CREATE_FOG
|
||||
DARKEN_SCREEN,
|
||||
PLAY_BOSS_MUSIC,
|
||||
CREATE_WORLD_FOG
|
||||
}
|
||||
|
@ -4,9 +4,9 @@ package com.velocitypowered.api.util.bossbar;
|
||||
* Represents a overlay of a {@link BossBar}.
|
||||
*/
|
||||
public enum BossBarOverlay {
|
||||
SOLID,
|
||||
SEGMENTED_6,
|
||||
SEGMENTED_10,
|
||||
SEGMENTED_12,
|
||||
SEGMENTED_20
|
||||
PROGRESS,
|
||||
NOTCHED_6,
|
||||
NOTCHED_10,
|
||||
NOTCHED_12,
|
||||
NOTCHED_20
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ public class VelocityBossBar implements com.velocitypowered.api.util.bossbar.Bos
|
||||
private final UUID uuid;
|
||||
private boolean visible;
|
||||
private Component title;
|
||||
private float progress;
|
||||
private float percent;
|
||||
private BossBarColor color;
|
||||
private BossBarOverlay overlay;
|
||||
|
||||
@ -39,17 +39,15 @@ public class VelocityBossBar implements com.velocitypowered.api.util.bossbar.Bos
|
||||
* @param title the title for the bar
|
||||
* @param color the color of the bar
|
||||
* @param overlay the overlay to use
|
||||
* @param progress the progress of the bar
|
||||
* @param percent the percent of the bar
|
||||
*/
|
||||
public VelocityBossBar(
|
||||
Component title, BossBarColor color, BossBarOverlay overlay, float progress) {
|
||||
Component title, BossBarColor color, BossBarOverlay overlay, float percent) {
|
||||
this.title = checkNotNull(title, "title");
|
||||
this.color = checkNotNull(color, "color");
|
||||
this.overlay = checkNotNull(overlay, "overlay");
|
||||
this.progress = progress;
|
||||
if (progress > 1 || progress < 0) {
|
||||
throw new IllegalArgumentException("Progress not between 0 and 1");
|
||||
}
|
||||
this.percent = percent;
|
||||
checkPercent(percent);
|
||||
this.uuid = UUID.randomUUID();
|
||||
visible = true;
|
||||
players = new ArrayList<>();
|
||||
@ -115,25 +113,29 @@ public class VelocityBossBar implements com.velocitypowered.api.util.bossbar.Bos
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getProgress() {
|
||||
return progress;
|
||||
public float getPercent() {
|
||||
return percent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProgress(float progress) {
|
||||
if (progress > 1 || progress < 0) {
|
||||
throw new IllegalArgumentException("Progress should be between 0 and 1");
|
||||
}
|
||||
this.progress = progress;
|
||||
public void setPercent(float percent) {
|
||||
checkPercent(percent);
|
||||
this.percent = percent;
|
||||
if (visible) {
|
||||
BossBar bar = new BossBar();
|
||||
bar.setUuid(uuid);
|
||||
bar.setAction(BossBar.UPDATE_PERCENT);
|
||||
bar.setPercent(progress);
|
||||
bar.setPercent(percent);
|
||||
sendToAffected(bar);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkPercent(final float percent) {
|
||||
if (percent < 0f || percent > 1f) {
|
||||
throw new IllegalArgumentException("Percent must be between 0 and 1");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Collection<Player> getPlayers() {
|
||||
return ImmutableList.copyOf(players);
|
||||
@ -221,13 +223,13 @@ public class VelocityBossBar implements com.velocitypowered.api.util.bossbar.Bos
|
||||
|
||||
private short serializeFlags() {
|
||||
short flagMask = 0x0;
|
||||
if (flags.contains(BossBarFlag.DARKEN_SKY)) {
|
||||
if (flags.contains(BossBarFlag.DARKEN_SCREEN)) {
|
||||
flagMask |= 0x1;
|
||||
}
|
||||
if (flags.contains(BossBarFlag.DRAGON_BAR)) {
|
||||
if (flags.contains(BossBarFlag.PLAY_BOSS_MUSIC)) {
|
||||
flagMask |= 0x2;
|
||||
}
|
||||
if (flags.contains(BossBarFlag.CREATE_FOG)) {
|
||||
if (flags.contains(BossBarFlag.CREATE_WORLD_FOG)) {
|
||||
flagMask |= 0x4;
|
||||
}
|
||||
return flagMask;
|
||||
@ -240,7 +242,7 @@ public class VelocityBossBar implements com.velocitypowered.api.util.bossbar.Bos
|
||||
bossBar.setName(GsonComponentSerializer.INSTANCE.serialize(title));
|
||||
bossBar.setColor(color.ordinal());
|
||||
bossBar.setOverlay(overlay.ordinal());
|
||||
bossBar.setPercent(progress);
|
||||
bossBar.setPercent(percent);
|
||||
bossBar.setFlags(serializeFlags());
|
||||
return bossBar;
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren