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;
}
Aggregations