Bobcat00 / PlotMarkers

Adds PlotSquared markers to BlueMap maps
0 stars 1 forks source link

Implementation suggestion #1

Open alekso56 opened 5 months ago

alekso56 commented 5 months ago

Hey there, I'm interested in this. However, could you please: 1) Utilize a shapemarker instead of a poi marker?

2) Access the PlotSquared API via PlotSquared.get().getPlotAreaManager().forEachPlotArea(plotarea ->{ plotarea.getPlots() });?

I'm aiming for something similar to this code. using this library

Using a shapemarker would help reduce the number of markers and enhance the visualization of grouped plots.

thanks for reading.

Bobcat00 commented 5 months ago

What shapes does PlotSquared support? Do they have to be rectangular, or can they be, for example, L or U shaped? I thought they supported arbitrary shapes, like circles or triangles.

Bobcat00 commented 5 months ago

Looking at this further, apparently you can have a group of base plots connected like this:

              XXX
              XXX
               X             XXXXXX
               X             X    X
               XXXXXXXXXXXXXXX    X
  XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  X                      X
  X
  X
  X

And this would have to be created as a single BlueMap shape. But it gets worse. Two adjacent base plots are not necessarily connected. They could be connected, or there could be a road between them. And the shape would have to account for it. For that matter, the road could be a hole inside the shape.

I really have no idea how to do this. I could look at the PlotSquared code, but they're approaching it from a different direction - If a person is in a plot, not how to recreate the shape of the plot.

alekso56 commented 5 months ago

Looking at this further, apparently you can have a group of base plots connected like this:

              XXX
              XXX
               X             XXXXXX
               X             X    X
               XXXXXXXXXXXXXXX    X
  XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  X                      X
  X
  X
  X

And this would have to be created as a single BlueMap shape. But it gets worse. Two adjacent base plots are not necessarily connected. They could be connected, or there could be a road between them. And the shape would have to account for it. For that matter, the road could be a hole inside the shape.

I really have no idea how to do this. I could look at the PlotSquared code, but they're approaching it from a different direction - If a person is in a plot, not how to recreate the shape of the plot.

I would assume it would turn out something like this, (just a rough sketch will probably not work) hybrid is the newest generator, classic is the older one, square is the base for both. so it goes hybrid inherits classic, classic inherits square. some people more intelligent than me have made a library for making cheese from cells of any size, if offsets are not used, this should work fine. https://github.com/TechnicJelle/BMUtils

PlotSquared.get().getPlotAreaManager().forEachPlotArea(plotarea ->{

                if(plotarea instanceof HybridPlotWorld) {
                HybridPlotWorld newest = (HybridPlotWorld) plotarea;

                }else if(plotarea instanceof ClassicPlotWorld ) {
                ClassicPlotWorld classic = (ClassicPlotWorld) plotarea;

                }else if(plotarea instanceof SquarePlotWorld) {
                SquarePlotWorld base = (SquarePlotWorld) plotarea;

                base.forEachBasePlot(coreOfMergedPlots -> {
                    Set<Plot> everythingInMergedPlots = coreOfMergedPlots.getConnectedPlots();
                    everythingInMergedPlots.add(coreOfMergedPlots);

                    Vector2i[] chunks = everythingInMergedPlots.stream().map((plot) -> new Vector2i(plot.getId().getX(), plot.getId().getY())).toArray(Vector2i[]::new);

                        Cheese cheese = Cheese.createSingleFromCells(new Vector2d(base.PLOT_WIDTH+base.ROAD_WIDTH,base.PLOT_WIDTH+base.ROAD_WIDTH), chunks);

                        ShapeMarker plotMarker = new ShapeMarker.Builder()
                                        .label(coreOfMergedPlots.getId().toCommaSeparatedString())
                                        .detail(coreOfMergedPlots.getAlias())
                                        .lineColor(new Color("#" + hex + opacity))
                                        .lineWidth(3)
                                        .fillColor(new Color("#" + hex + opacity))
                                        .depthTestEnabled(false)
                                        .shape(cheese.getShape(), (float) base.getMinBuildHeight())
                                        .holes(cheese.getHoles().toArray(Shape[]::new))
                                        .centerPosition()
                                        .build();
                        markerSet.put("plots." + coreOfMergedPlots.getId() + ".area", plotMarker);
                        createMarker(coreOfMergedPlots,markerSet);
                });
                }
            });
Bobcat00 commented 5 months ago

(base.PLOT_WIDTH+base.ROAD_WIDTH, base.PLOT_WIDTH+base.ROAD_WIDTH)

This looks like the shape area will cover half the roads on all sides of the plot, which is less than ideal.