Search in sources :

Example 1 with LanternWorldBorder

use of org.lanternpowered.server.world.LanternWorldBorder in project LanternServer by LanternPowered.

the class LanternPlayer method setWorldBorder.

@Override
public void setWorldBorder(@Nullable WorldBorder border, Cause cause) {
    checkNotNull(cause, "cause");
    if (this.worldBorder == border) {
        return;
    }
    final ChangeWorldBorderEvent.TargetPlayer event = SpongeEventFactory.createChangeWorldBorderEventTargetPlayer(cause, Optional.ofNullable(border), Optional.ofNullable(this.worldBorder), this);
    Sponge.getEventManager().post(event);
    if (event.isCancelled()) {
        return;
    }
    if (this.worldBorder != null) {
        this.worldBorder.removePlayer(this);
    }
    final LanternWorldBorder worldBorder = (LanternWorldBorder) border;
    if (worldBorder != null) {
        if (this.worldBorder == null) {
            getWorld().getWorldBorder().removePlayer(this);
        }
        worldBorder.addPlayer(this);
    } else {
        getWorld().getWorldBorder().addPlayer(this);
    }
    this.worldBorder = worldBorder;
}
Also used : LanternWorldBorder(org.lanternpowered.server.world.LanternWorldBorder) ChangeWorldBorderEvent(org.spongepowered.api.event.world.ChangeWorldBorderEvent)

Aggregations

LanternWorldBorder (org.lanternpowered.server.world.LanternWorldBorder)1 ChangeWorldBorderEvent (org.spongepowered.api.event.world.ChangeWorldBorderEvent)1