Search in sources :

Example 1 with BossBar

use of net.kyori.adventure.bossbar.BossBar in project SpongeCommon by SpongePowered.

the class HackyBossBarPlatformBridgeMixin method bridge$asVanillaServerBar.

@Override
public ServerBossEvent bridge$asVanillaServerBar() {
    if (this.bridge$vanillaServerBar == null) {
        final BossBar $this = (BossBar) this;
        this.bridge$vanillaServerBar = new ServerBossEvent(SpongeAdventure.asVanilla($this.name()), SpongeAdventure.asVanilla($this.color()), SpongeAdventure.asVanilla($this.overlay()));
        final BossEventBridge bridge = (BossEventBridge) this.bridge$vanillaServerBar;
        bridge.bridge$copyAndAssign($this);
        $this.addListener(new VanillaBossBarListener(this.bridge$vanillaServerBar));
    }
    return this.bridge$vanillaServerBar;
}
Also used : ServerBossEvent(net.minecraft.server.level.ServerBossEvent) BossEventBridge(org.spongepowered.common.bridge.world.BossEventBridge) VanillaBossBarListener(org.spongepowered.common.adventure.VanillaBossBarListener) BossBar(net.kyori.adventure.bossbar.BossBar)

Example 2 with BossBar

use of net.kyori.adventure.bossbar.BossBar in project SpongeCommon by SpongePowered.

the class ServerBossEventMixin method bridge$setAdventure.

@Override
public void bridge$setAdventure(final BossBar adventure) {
    final BossBar oldAdventure = this.impl$adventure;
    super.bridge$setAdventure(adventure);
    if (oldAdventure != adventure) {
        if (oldAdventure != null) {
            // TODO(adventure): how to update viewers?
            oldAdventure.removeListener(this);
        }
        adventure.addListener(this);
        // Apply invalid data where possible, avoid sameness checks
        this.name = null;
        this.percent = Float.MIN_VALUE;
        this.color = null;
        this.overlay = null;
    // flags have to be done separately
    }
}
Also used : BossBar(net.kyori.adventure.bossbar.BossBar)

Aggregations

BossBar (net.kyori.adventure.bossbar.BossBar)2 ServerBossEvent (net.minecraft.server.level.ServerBossEvent)1 VanillaBossBarListener (org.spongepowered.common.adventure.VanillaBossBarListener)1 BossEventBridge (org.spongepowered.common.bridge.world.BossEventBridge)1