Types of visualizations

Every visual implements svVisualInterface and extends main svVisual classes.

svVisualCuboid – most common visual to show cuboid of defined area in 2 particles for sides and edges

svVisualCylinder – basic cylinder shape utilizing 3 different effects for sides, edges and top/bottom parts

svVisualPolygon – mainly recognizable from WorldEdit poly selection type. Used 2 different particle types for sides and edges.

svVisualSphere – basic spheroid visualization. Used only one particle effect type.

svVisualConvex – complex visualization between points. Recognizable from WorldEdit selection type. uses 2 different effect types.

svVisualAutoGrid – complex visualization to show a grid that will merge areas that have the same effect type defined. Only bounds will be shown. Effects are limited to 10 different types. Recognizable from plugins as Factions or Towny. height is limited to only one line and is offset by a defined amount to its center to avoid overlapping.

Cuboid

First of all, we need a cuboid object which will define bounds of that area. This can be done with simple code as

 CuboidArea cuboid = new CuboidArea(cornerLocation1, cornerLocation2);

Where corner locations as basic bukkit Location objects. Which 2 corners you will provide, doesn’t matter.

Next, lets create actual visualization of this cuboid.

svVisualCuboid cuboid = new svVisualCuboid(player, cuboid , AreaType.BEACON);

Player object will be needed to get some of the options for that visualization, like update rates and so on.

AreaType is optional, but in general, it will define from which visualization we want to take particle effects.

And in genral you are done, you can run

cuboid.startRender();

Which will start drawing particles in a defined area for the defined player. But lets do some extra things about it.

Lets hide the bottom and top parts.

cuboid.addHiddenSide(CuboidSide.Bottom);
cuboid.addHiddenSide(CuboidSide.Top);

So in this case you will only see walls of that visualization.

For performance reassons particle locations are caculated only once, to avoid constant calculations when we dont need. So at this point if bounds are bigger then your view range, you will not see the entirety of it. So lets fix it

cuboid.addUpdateType(svUpdateType.move2blocks);

This will recalculate visible points after you move 2 blocks. Full list of posible update triggers can be found belowe.

Now, what we should do if we would want to stop visualization if something happens? Not a problem.

svVisualCuboid cuboid = new svVisualCuboid(player, new CuboidArea(start, end), AreaType.BEACON) {
@Override
public boolean isValid() {
if (center.getBlock().getType() != Material.BEACON)
return false;
return true;
}
};

This code will force a check before each update cycle, and if it fails, visualization stops. In this example it will stop if target block is no longer a beacon.

So what if you would want to change something when update event triggers? Like in example if you would want to change cuboid bounds.

svVisualCuboid cuboid = new svVisualCuboid(player, cuboidArea, AreaType.WEPASTE) {
@Override
public void onUpdateEvent() {
cuboidAreas.clear();
CuboidArea clone = cArea.clone();
clone.getLowLoc().add(player.getLocation().getBlockX(), player.getLocation().getBlockY(), player.getLocation().getBlockZ());
clone.getHighLoc().add(player.getLocation().getBlockX(), player.getLocation().getBlockY(), player.getLocation().getBlockZ());
cuboidAreas.add(clone);
calculateLocations();
}
};

This is the code used to show WorldEdit paste visualization which updates its location when player moves. So actions are quite simple, clear old cuboids, have a original one which can be cloned to avoid messing it up. Then update its locations, add to cuboid list and recalculate locations. Simple? Kind of.

Multiple players

In case you want to show particle effects to more then one player you will need to add them into watcher list. Keep in mind that particle locations will be calculated by source player and not by watchers, so watcher sees what source player sees.

svPlayer watcher = plugin.getSvPlayer(player);
cuboid.addWatcher(watcher)

svUpdateType

move1blocks – move 1 or more blocks for update to be triggered

move2blocks – move 2 or more blocks for update to be triggered

move4blocks – move 4 or more blocks for update to be triggered

move8blocks – move 8 or more blocks for update to be triggered

look – turn camera for update to be triggered.

chunkChange – move to another chunk for update to be triggered

levelChange – move up or down for update to be triggered