Search in sources :

Example 1 with ViewStack

use of com.bergerkiller.bukkit.common.internal.CommonMapController.ViewStack in project BKCommonLib by bergerhealer.

the class MapSession method onOwnerAdded.

private void onOwnerAdded(Owner owner) {
    // Add to map display by-player mapping
    MapDisplayInfo info = this.display.getMapInfo();
    if (info != null) {
        ViewStack views = info.getStack(owner.player);
        if (views.stack.isEmpty()) {
            views.stack.addLast(this.display);
        } else {
            MapDisplay previousDisplay = views.stack.getLast();
            if (previousDisplay != this.display) {
                previousDisplay.removeOwner(owner.player);
                views.stack.addLast(previousDisplay);
                views.stack.addLast(this.display);
            }
        }
    }
}
Also used : MapDisplayInfo(com.bergerkiller.bukkit.common.internal.CommonMapController.MapDisplayInfo) ViewStack(com.bergerkiller.bukkit.common.internal.CommonMapController.ViewStack)

Example 2 with ViewStack

use of com.bergerkiller.bukkit.common.internal.CommonMapController.ViewStack in project BKCommonLib by bergerhealer.

the class MapSession method onOwnerRemoved.

private void onOwnerRemoved(Owner owner) {
    // Remove map display from by-player mapping
    MapDisplayInfo info = this.display.getMapInfo();
    if (info != null) {
        ViewStack views = info.getStack(owner.player);
        if (!views.stack.isEmpty() && views.stack.getLast() == this.display) {
            // Stop intercepting input
            owner.interceptInput = false;
            owner.input.doTick(this.display, false);
            // Remove self
            views.stack.removeLast();
            // If an older display is in the stack, switch to it
            if (!views.stack.isEmpty()) {
                views.stack.getLast().addOwner(owner.player);
            }
        } else {
            // Simply remove the player from anywhere in the view stack
            views.stack.remove(this.display);
        }
    }
}
Also used : MapDisplayInfo(com.bergerkiller.bukkit.common.internal.CommonMapController.MapDisplayInfo) ViewStack(com.bergerkiller.bukkit.common.internal.CommonMapController.ViewStack)

Aggregations

MapDisplayInfo (com.bergerkiller.bukkit.common.internal.CommonMapController.MapDisplayInfo)2 ViewStack (com.bergerkiller.bukkit.common.internal.CommonMapController.ViewStack)2