Java Code Examples for com.sk89q.worldedit.LocalSession#getSelectionWorld()

The following examples show how to use com.sk89q.worldedit.LocalSession#getSelectionWorld() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WorldEditHelper.java    From WorldEditSelectionVisualizer with MIT License 5 votes vote down vote up
@Nullable
private Region getSelectedRegion(@Nullable LocalSession session) {
    if (session != null && session.getSelectionWorld() != null) {
        RegionSelector selector = session.getRegionSelector(session.getSelectionWorld());

        if (selector.isDefined()) {
            try {
                return selector.getRegion();
            } catch (IncompleteRegionException e) {
                plugin.getLogger().warning("Region still incomplete");
            }
        }
    }
    return null;
}
 
Example 2
Source File: WorldEditApiProvider.java    From GriefPrevention with MIT License 5 votes vote down vote up
public World getWorld(String playerName) {
    final LocalSession session = getLocalSession(playerName);
    if (session == null) {
        return null;
    }

    return session.getSelectionWorld();
}
 
Example 3
Source File: WorldEditApiProvider.java    From GriefPrevention with MIT License 5 votes vote down vote up
public RegionSelector getRegionSelector(Player player) {
    final LocalSession session = getLocalSession(player.getName());
    if (session == null) {
        return null;
    }

    World world = session.getSelectionWorld();
    if (world == null) {
        world = this.getWorld(player.getWorld());
    }
    return session.getRegionSelector(world);
}
 
Example 4
Source File: WorldEditApiProvider.java    From GriefPrevention with MIT License 5 votes vote down vote up
public void visualizeClaim(Claim claim, Vector3i pos1, Vector3i pos2, Player player, GPPlayerData playerData, boolean investigating) {
    // revert any current visuals if investigating
    if (investigating) {
        this.revertVisuals(player, playerData, null);
    }
    final LocalSession session = this.getLocalSession(player.getName());
    if (session == null || !session.hasCUISupport()) {
        return;
    }
    final Vector point1 = this.createVector(pos1);
    final Vector point2 = this.createVector(pos2);
    final CuboidRegionSelector regionSelector = new CuboidRegionSelector(session.getSelectionWorld(), point1, point2);
    final GPActor actor = this.getOrCreateActor(player);
    session.setRegionSelector(this.getWorld(player.getWorld()), regionSelector);
    actor.dispatchCUIEvent(new MultiSelectionCuboidEvent(claim.getUniqueId()));
    actor.dispatchCUIEvent(new MultiSelectionPointEvent(0, point1, regionSelector.getArea()));
    if (playerData.claimResizing != null) {
        actor.dispatchCUIEvent(new MultiSelectionPointEvent(1));
    } else {
        actor.dispatchCUIEvent(new MultiSelectionPointEvent(1, point2, regionSelector.getArea()));
    }

    if (investigating || playerData.lastShovelLocation == null) {
        actor.dispatchCUIEvent(new MultiSelectionColorEvent(MultiSelectionColors.RED, MultiSelectionColors.getClaimColor(claim), "", ""));
    }
    actor.dispatchCUIEvent(new MultiSelectionGridEvent(10));
}
 
Example 5
Source File: WorldEditApiProvider.java    From GriefPrevention with MIT License 5 votes vote down vote up
public void visualizeClaims(Set<Claim> claims, Player player, GPPlayerData playerData, boolean investigating) {
    for (Claim claim : claims) {
        if (((GPClaim) claim).children.size() > 0) {
            visualizeClaims(((GPClaim) claim).getInternalChildren(true), player, playerData, investigating);
        }
        final LocalSession session = this.getLocalSession(player.getName());
        if (session == null || !session.hasCUISupport()) {
            return;
        }
        final Vector point1 = this.createVector(claim.getLesserBoundaryCorner().getBlockPosition());
        final Vector point2 = this.createVector(claim.getGreaterBoundaryCorner().getBlockPosition());
        final CuboidRegionSelector regionSelector = new CuboidRegionSelector(session.getSelectionWorld(), point1, point2);
        final GPActor actor = this.getOrCreateActor(player);
        session.setRegionSelector(this.getWorld(player.getWorld()), regionSelector);
        actor.dispatchCUIEvent(new MultiSelectionCuboidEvent(claim.getUniqueId()));
        actor.dispatchCUIEvent(new MultiSelectionPointEvent(0, point1, regionSelector.getArea()));
        if (playerData.claimResizing != null) {
            actor.dispatchCUIEvent(new MultiSelectionPointEvent(1));
        } else {
            actor.dispatchCUIEvent(new MultiSelectionPointEvent(1, point2, regionSelector.getArea()));
        }
        if (investigating) {
            actor.dispatchCUIEvent(new MultiSelectionColorEvent(MultiSelectionColors.RED, MultiSelectionColors.getClaimColor(claim), "", ""));
        }
        actor.dispatchCUIEvent(new MultiSelectionGridEvent(10));
    }
}