Skip to content

Commit b5db1dc

Browse files
Update grid selector
1 parent 2085ecd commit b5db1dc

File tree

4 files changed

+75
-75
lines changed

4 files changed

+75
-75
lines changed

core/src/main/java/de/eldoria/gridselector/brush/MarkerResult.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ public List<Vector> getCorners() {
3939
List<Vector> result = new ArrayList<>();
4040
var max = schematicRegion.getMaximumPoint();
4141
var min = schematicRegion.getMinimumPoint();
42-
for (var x : new int[]{min.getX() - 1, max.getX() + 1}) {
43-
for (var y : new int[]{min.getY() - 1, max.getY() + 1}) {
44-
for (var z : new int[]{min.getZ() - 1, max.getZ() + 1}) {
42+
for (var x : new int[]{min.x() - 1, max.x() + 1}) {
43+
for (var y : new int[]{min.y() - 1, max.y() + 1}) {
44+
for (var z : new int[]{min.z() - 1, max.z() + 1}) {
4545
result.add(new Vector(x, y, z));
4646
}
4747
}
@@ -71,14 +71,14 @@ public Set<Vector> getBorderBlocks() {
7171

7272
Set<Vector> blocks = new HashSet<>();
7373

74-
for (int x = min.getBlockX(); x <= max.getBlockX(); x++) {
75-
blocks.add(new Vector(x, minHeight, min.getBlockZ()));
76-
blocks.add(new Vector(x, minHeight, max.getBlockZ()));
74+
for (int x = min.x(); x <= max.x(); x++) {
75+
blocks.add(new Vector(x, minHeight, min.z()));
76+
blocks.add(new Vector(x, minHeight, max.z()));
7777
}
7878

79-
for (int z = min.getBlockZ(); z <= max.getBlockZ(); z++) {
80-
blocks.add(new Vector(min.getBlockX(), minHeight, z));
81-
blocks.add(new Vector(max.getBlockX(), minHeight, z));
79+
for (int z = min.z(); z <= max.z(); z++) {
80+
blocks.add(new Vector(min.x(), minHeight, z));
81+
blocks.add(new Vector(max.x(), minHeight, z));
8282
}
8383
return blocks;
8484
}

core/src/main/java/de/eldoria/gridselector/brush/SelectionBrush.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public void build(EditSession editSession, BlockVector3 position, Pattern patter
8888
private int reduceFloor(EditSession session, CuboidRegion region, int minHeight) {
8989
var min = region.getMinimumPoint();
9090
var max = region.getMaximumPoint();
91-
for (var y = minHeight; y <= max.getY(); y++) {
91+
for (var y = minHeight; y <= max.y(); y++) {
9292
if (checkFlat(session, y, min, max, mat -> mat == Material.AIR)) {
9393
return y;
9494
}
@@ -100,7 +100,7 @@ private int reduceTop(EditSession session, CuboidRegion region) {
100100
var min = region.getMinimumPoint();
101101
var max = region.getMaximumPoint();
102102

103-
for (var y = max.getY(); y >= min.getY(); y--) {
103+
for (var y = max.y(); y >= min.y(); y--) {
104104
if (checkFlat(session, y, min, max, mat -> mat != Material.AIR)) {
105105
return y;
106106
}
@@ -109,8 +109,8 @@ private int reduceTop(EditSession session, CuboidRegion region) {
109109
}
110110

111111
private boolean checkFlat(EditSession session, int y, BlockVector3 min, BlockVector3 max, Predicate<Material> check) {
112-
for (var x = min.getX(); x < max.getX(); x++) {
113-
for (var z = min.getZ(); z < max.getZ(); z++) {
112+
for (var x = min.x(); x < max.x(); x++) {
113+
for (var z = min.z(); z < max.z(); z++) {
114114
var material = session.getBlock(BlockVector3.at(x, y, z)).getBlockType();
115115
if (check.test(BukkitAdapter.adapt(material)))
116116
return true;
@@ -122,33 +122,33 @@ private boolean checkFlat(EditSession session, int y, BlockVector3 min, BlockVec
122122
private int reduceEastWestSide(EditSession session, int yMin, int yMax, CuboidRegion region, boolean east) {
123123
var min = region.getMinimumPoint();
124124
var max = region.getMaximumPoint();
125-
for (var x = (east ? min : max).getX(); east ? x <= max.getX() : x >= min.getX(); x += east ? 1 : -1) {
125+
for (var x = (east ? min : max).x(); east ? x <= max.x() : x >= min.x(); x += east ? 1 : -1) {
126126
for (var y = yMin; y <= yMax; y++) {
127-
for (var z = min.getZ(); z < max.getZ(); z++) {
127+
for (var z = min.z(); z < max.z(); z++) {
128128
var material = session.getBlock(BlockVector3.at(x, y, z)).getBlockType();
129129
if (BukkitAdapter.adapt(material) != Material.AIR) {
130130
return x;
131131
}
132132
}
133133
}
134134
}
135-
return (east ? min : max).getX();
135+
return (east ? min : max).x();
136136
}
137137

138138
private int reduceSouthNorthSide(EditSession session, int yMin, int yMax, CuboidRegion region, boolean south) {
139139
var min = region.getMinimumPoint();
140140
var max = region.getMaximumPoint();
141-
for (var z = (south ? min : max).getZ(); south ? z <= max.getZ() : z >= min.getZ(); z += south ? 1 : -1) {
141+
for (var z = (south ? min : max).z(); south ? z <= max.z() : z >= min.z(); z += south ? 1 : -1) {
142142
for (var y = yMin; y <= yMax; y++) {
143-
for (var x = min.getX(); x < max.getX(); x++) {
143+
for (var x = min.x(); x < max.x(); x++) {
144144
var material = session.getBlock(BlockVector3.at(x, y, z)).getBlockType();
145145
if (BukkitAdapter.adapt(material) != Material.AIR) {
146146
return z;
147147
}
148148
}
149149
}
150150
}
151-
return (south ? min : max).getZ();
151+
return (south ? min : max).z();
152152
}
153153

154154
public List<CuboidRegion> getRegions() {

core/src/main/java/de/eldoria/gridselector/config/elements/cluster/GridCluster.java

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -80,17 +80,17 @@ public static Builder builder(Location center, Direction direction) {
8080
@NotNull
8181
public Map<String, Object> serialize() {
8282
return SerializationUtil.newBuilder()
83-
.add("id", id)
84-
.add("minHeight", minHeight)
85-
.add("plot", plot)
86-
.add("elementSize", elementSize)
87-
.add("offset", offset)
88-
.add("rows", rows)
89-
.add("columns", columns)
90-
.add("borderMaterial", borderMaterial)
91-
.add("offsetMaterial", offsetMaterial)
92-
.add("floorMaterial", floorMaterial)
93-
.build();
83+
.add("id", id)
84+
.add("minHeight", minHeight)
85+
.add("plot", plot)
86+
.add("elementSize", elementSize)
87+
.add("offset", offset)
88+
.add("rows", rows)
89+
.add("columns", columns)
90+
.add("borderMaterial", borderMaterial)
91+
.add("offsetMaterial", offsetMaterial)
92+
.add("floorMaterial", floorMaterial)
93+
.build();
9494
}
9595

9696
/**
@@ -168,8 +168,8 @@ public Optional<Plot> getRegion(BlockVector2 vector) {
168168
var totalElementSize = elementSize + 2 + offset;
169169
var min = plot.min();
170170

171-
var xOffset = EMath.diff(min.getX(), vector.getX());
172-
var zOffset = EMath.diff(min.getZ(), vector.getZ());
171+
var xOffset = EMath.diff(min.x(), vector.x());
172+
var zOffset = EMath.diff(min.z(), vector.z());
173173

174174
var xIndex = xOffset % totalElementSize;
175175
var zIndex = zOffset % totalElementSize;
@@ -182,8 +182,8 @@ public Optional<Plot> getRegion(BlockVector2 vector) {
182182
return Optional.empty();
183183
}
184184

185-
var gridX = Math.floor(xOffset / totalElementSize);
186-
var gridZ = Math.floor(zOffset / totalElementSize);
185+
var gridX = Math.floor(xOffset / (float) totalElementSize);
186+
var gridZ = Math.floor(zOffset / (float) totalElementSize);
187187

188188
return Optional.ofNullable(getRegion(min, (int) gridX, (int) gridZ));
189189
}
@@ -198,7 +198,7 @@ public Optional<Plot> getRegion(BlockVector2 vector) {
198198
*/
199199
public Plot getRegion(BlockVector2 base, int x, int z) {
200200
var totalElementSize = elementSize + 2 + offset;
201-
var min = BlockVector2.at(base.getX() + x * totalElementSize, base.getZ() + z * totalElementSize);
201+
var min = BlockVector2.at(base.x() + x * totalElementSize, base.z() + z * totalElementSize);
202202
return Plot.of(min, min.add(BlockVector2.at(elementSize + 1, elementSize + 1)));
203203
}
204204

@@ -262,8 +262,8 @@ public void id(int id) {
262262

263263
public List<Plot> getRegions() {
264264
List<Plot> plots = new ArrayList<>();
265-
for (var x = plot.min().getBlockX(); x < plot.max().getBlockX(); x += elementSize + 2 + offset) {
266-
for (var z = plot.min().getBlockZ(); z < plot.max().getBlockZ(); z += elementSize + 2 + offset) {
265+
for (var x = plot.min().x(); x < plot.max().x(); x += elementSize + 2 + offset) {
266+
for (var z = plot.min().z(); z < plot.max().z(); z += elementSize + 2 + offset) {
267267
getRegion(BlockVector2.at(x, z)).ifPresent(plots::add);
268268
}
269269
}
@@ -348,38 +348,38 @@ public BlockVector2 floorVector(Vector vector) {
348348

349349
public String asComponent() {
350350
var message = MessageComposer.create()
351-
.text("<%s>Cluster Settings", Colors.HEADING).newLine()
352-
.text("<%s>Location: <%s>%s|%s", Colors.NAME, Colors.VALUE, center.getBlockX(), center.getBlockZ())
353-
.space()
354-
.text("<%s><click:run_command:'/sbrg cluster modify center'>[change]</click>", Colors.CHANGE)
355-
.newLine()
356-
.text("<%s>Direction: <%s>%s", Colors.NAME, Colors.VALUE, direction.name()).space()
357-
.text("<%s><click:run_command:'/sbrg cluster modify direction'>[change]</click>", Colors.CHANGE)
358-
.newLine()
359-
.text("<%s>Expand: <%s>%s", Colors.NAME, Colors.VALUE, expandRight ? "right" : "left").space()
360-
.text("<%s><click:run_command:'/sbrg cluster modify expandRight'>[change]</click>", Colors.CHANGE)
361-
.newLine()
362-
.text("<%s>Size: <%s>%s", Colors.NAME, Colors.VALUE, elementSize).space()
363-
.text("<%s><click:suggest_command:'/sbrg cluster modify size '>[change]</click>", Colors.CHANGE)
364-
.newLine()
365-
.text("<%s>Rows: <%s>%s", Colors.NAME, Colors.VALUE, rows).space()
366-
.text("<%s><click:suggest_command:'/sbrg cluster modify rows '>[change]</click>", Colors.CHANGE)
367-
.newLine()
368-
.text("<%s>Columns: <%s>%s", Colors.NAME, Colors.VALUE, columns).space()
369-
.text("<%s><click:suggest_command:'/sbrg cluster modify columns '>[change]</click>", Colors.CHANGE)
370-
.newLine()
371-
.text("<%s>Offset: <%s>%s", Colors.NAME, Colors.VALUE, offset).space()
372-
.text("<%s><click:suggest_command:'/sbrg cluster modify offset '>[change]</click>", Colors.CHANGE)
373-
.newLine()
374-
.text("<%s>Floor Material: <%s>%s", Colors.NAME, Colors.VALUE, floorMaterial).space()
375-
.text("<%s><click:suggest_command:'/sbrg cluster modify floorMaterial '>[change]</click>", Colors.CHANGE)
376-
.newLine()
377-
.text("<%s>Border Material: <%s>%s", Colors.NAME, Colors.VALUE, borderMaterial).space()
378-
.text("<%s><click:suggest_command:'/sbrg cluster modify borderMaterial '>[change]</click>", Colors.CHANGE)
379-
.newLine()
380-
.text("<%s>Offset Material: <%s>%s", Colors.NAME, Colors.VALUE, offsetMaterial).space()
381-
.text("<%s><click:suggest_command:'/sbrg cluster modify offsetMaterial '>[change]</click>", Colors.CHANGE)
382-
.build();
351+
.text("<%s>Cluster Settings", Colors.HEADING).newLine()
352+
.text("<%s>Location: <%s>%s|%s", Colors.NAME, Colors.VALUE, center.getBlockX(), center.getBlockZ())
353+
.space()
354+
.text("<%s><click:run_command:'/sbrg cluster modify center'>[change]</click>", Colors.CHANGE)
355+
.newLine()
356+
.text("<%s>Direction: <%s>%s", Colors.NAME, Colors.VALUE, direction.name()).space()
357+
.text("<%s><click:run_command:'/sbrg cluster modify direction'>[change]</click>", Colors.CHANGE)
358+
.newLine()
359+
.text("<%s>Expand: <%s>%s", Colors.NAME, Colors.VALUE, expandRight ? "right" : "left").space()
360+
.text("<%s><click:run_command:'/sbrg cluster modify expandRight'>[change]</click>", Colors.CHANGE)
361+
.newLine()
362+
.text("<%s>Size: <%s>%s", Colors.NAME, Colors.VALUE, elementSize).space()
363+
.text("<%s><click:suggest_command:'/sbrg cluster modify size '>[change]</click>", Colors.CHANGE)
364+
.newLine()
365+
.text("<%s>Rows: <%s>%s", Colors.NAME, Colors.VALUE, rows).space()
366+
.text("<%s><click:suggest_command:'/sbrg cluster modify rows '>[change]</click>", Colors.CHANGE)
367+
.newLine()
368+
.text("<%s>Columns: <%s>%s", Colors.NAME, Colors.VALUE, columns).space()
369+
.text("<%s><click:suggest_command:'/sbrg cluster modify columns '>[change]</click>", Colors.CHANGE)
370+
.newLine()
371+
.text("<%s>Offset: <%s>%s", Colors.NAME, Colors.VALUE, offset).space()
372+
.text("<%s><click:suggest_command:'/sbrg cluster modify offset '>[change]</click>", Colors.CHANGE)
373+
.newLine()
374+
.text("<%s>Floor Material: <%s>%s", Colors.NAME, Colors.VALUE, floorMaterial).space()
375+
.text("<%s><click:suggest_command:'/sbrg cluster modify floorMaterial '>[change]</click>", Colors.CHANGE)
376+
.newLine()
377+
.text("<%s>Border Material: <%s>%s", Colors.NAME, Colors.VALUE, borderMaterial).space()
378+
.text("<%s><click:suggest_command:'/sbrg cluster modify borderMaterial '>[change]</click>", Colors.CHANGE)
379+
.newLine()
380+
.text("<%s>Offset Material: <%s>%s", Colors.NAME, Colors.VALUE, offsetMaterial).space()
381+
.text("<%s><click:suggest_command:'/sbrg cluster modify offsetMaterial '>[change]</click>", Colors.CHANGE)
382+
.build();
383383
return message;
384384
}
385385

core/src/main/java/de/eldoria/gridselector/config/elements/cluster/Plot.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ public Plot(Map<String, Object> objectMap) {
3333
}
3434

3535
private Plot(BlockVector2 min, BlockVector2 max) {
36-
this.min = BlockVector2.at(Math.min(min.getBlockX(), max.getBlockX()), Math.min(min.getBlockZ(), max.getBlockZ()));
37-
this.max = BlockVector2.at(Math.max(min.getBlockX(), max.getBlockX()), Math.max(min.getBlockZ(), max.getBlockZ()));
36+
this.min = BlockVector2.at(Math.min(min.x(), max.x()), Math.min(min.z(), max.z()));
37+
this.max = BlockVector2.at(Math.max(min.x(), max.x()), Math.max(min.z(), max.z()));
3838
}
3939

4040
public static Plot of(int minX, int minZ, int maxX, int maxZ) {
@@ -92,8 +92,8 @@ public Plot borderLessPlot() {
9292
* @return true if the vector is part of the plot.
9393
*/
9494
public boolean contains(BlockVector2 vector2) {
95-
return min.getBlockX() <= vector2.getBlockX() && vector2.getBlockX() <= max.getBlockX()
96-
&& min.getBlockZ() <= vector2.getBlockZ() && vector2.getBlockZ() <= max.getBlockZ();
95+
return min.x() <= vector2.x() && vector2.x() <= max.x()
96+
&& min.z() <= vector2.z() && vector2.z() <= max.z();
9797
}
9898

9999
public BlockVector2 min() {
@@ -111,8 +111,8 @@ public BlockVector2 max() {
111111
* @return true if they overlap
112112
*/
113113
public boolean overlaps(Plot plot) {
114-
return min.getBlockX() < plot.max().getBlockX() && max.getBlockX() > plot.min().getBlockX()
115-
&& min.getBlockZ() < plot.max().getBlockZ() && max.getBlockZ() > plot.min().getBlockZ();
114+
return min.x() < plot.max().x() && max.x() > plot.min().x()
115+
&& min.z() < plot.max().z() && max.z() > plot.min().z();
116116

117117
}
118118

0 commit comments

Comments
 (0)