Make block positions copy on click for //size

6925d3715a6c6992d01ab1d4b5564bb9535b6711

Co-Authored-By: Lewis B <17665267+lewisjb@users.noreply.github.com>
This commit is contained in:
N0tMyFaultOG 2020-11-13 21:54:46 +01:00
parent 679b9d203d
commit 0d2c4c0825
7 changed files with 51 additions and 4 deletions

View File

@ -610,4 +610,12 @@ public class BlockVector2 {
public String toString() { public String toString() {
return "(" + x + ", " + z + ")"; return "(" + x + ", " + z + ")";
} }
/**
* Returns a string representation that is supported by the parser.
* @return string
*/
public String toParserString() {
return x + "," + z;
}
} }

View File

@ -787,6 +787,14 @@ public abstract class BlockVector3 {
return "(" + getX() + ", " + getY() + ", " + getZ() + ")"; return "(" + getX() + ", " + getY() + ", " + getZ() + ")";
} }
/**
* Returns a string representation that is supported by the parser.
* @return string
*/
public String toParserString() {
return getX() + "," + getY() + "," + getZ();
}
//Used by VS fork //Used by VS fork
public BlockVector3 plus(BlockVector3 other) { public BlockVector3 plus(BlockVector3 other) {
return add(other); return add(other);

View File

@ -478,4 +478,12 @@ public final class Vector2 {
return "(" + x + ", " + z + ")"; return "(" + x + ", " + z + ")";
} }
/**
* Returns a string representation that is supported by the parser.
* @return string
*/
public String toParserString() {
return x + "," + z;
}
} }

View File

@ -639,4 +639,12 @@ public abstract class Vector3 {
return "(" + x + ", " + y + ", " + z + ")"; return "(" + x + ", " + y + ", " + z + ")";
} }
/**
* Returns a string representation that is supported by the parser.
* @return string
*/
public String toParserString() {
return getX() + "," + getY() + "," + getZ();
}
} }

View File

@ -33,6 +33,8 @@ import com.sk89q.worldedit.regions.selector.limit.SelectorLimits;
import com.sk89q.worldedit.util.formatting.text.Component; import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.sk89q.worldedit.util.formatting.text.event.ClickEvent;
import com.sk89q.worldedit.util.formatting.text.event.HoverEvent;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import java.util.ArrayList; import java.util.ArrayList;
@ -256,11 +258,15 @@ public class CuboidRegionSelector implements RegionSelector, CUIRegion {
final List<Component> lines = new ArrayList<>(); final List<Component> lines = new ArrayList<>();
if (position1 != null) { if (position1 != null) {
lines.add(TranslatableComponent.of("worldedit.selection.cuboid.info.pos1", TextComponent.of(position1.toString()))); lines.add(TranslatableComponent.of("worldedit.selection.cuboid.info.pos1", TextComponent.of(position1.toString())
.clickEvent(ClickEvent.of(ClickEvent.Action.COPY_TO_CLIPBOARD, position1.toParserString()))
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to copy")))));
} }
if (position2 != null) { if (position2 != null) {
lines.add(TranslatableComponent.of("worldedit.selection.cuboid.info.pos2", TextComponent.of(position2.toString()))); lines.add(TranslatableComponent.of("worldedit.selection.cuboid.info.pos2", TextComponent.of(position2.toString())
.clickEvent(ClickEvent.of(ClickEvent.Action.COPY_TO_CLIPBOARD, position2.toParserString()))
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to copy")))));
} }
return lines; return lines;

View File

@ -37,6 +37,8 @@ import com.sk89q.worldedit.regions.selector.limit.SelectorLimits;
import com.sk89q.worldedit.util.formatting.text.Component; import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.sk89q.worldedit.util.formatting.text.event.ClickEvent;
import com.sk89q.worldedit.util.formatting.text.event.HoverEvent;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import java.text.NumberFormat; import java.text.NumberFormat;
@ -249,7 +251,10 @@ public class CylinderRegionSelector implements RegionSelector, CUIRegion {
final List<Component> lines = new ArrayList<>(); final List<Component> lines = new ArrayList<>();
if (!region.getCenter().equals(Vector3.ZERO)) { if (!region.getCenter().equals(Vector3.ZERO)) {
lines.add(TranslatableComponent.of("worldedit.selection.cylinder.info.center", TextComponent.of(region.getCenter().toString()))); Vector3 center = region.getCenter();
lines.add(TranslatableComponent.of("worldedit.selection.cylinder.info.center", TextComponent.of(center.toString())
.clickEvent(ClickEvent.of(ClickEvent.Action.COPY_TO_CLIPBOARD, center.toParserString()))
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to copy")))));
} }
if (!region.getRadius().equals(Vector2.ZERO)) { if (!region.getRadius().equals(Vector2.ZERO)) {
lines.add(TranslatableComponent.of("worldedit.selection.cylinder.info.radius", TextComponent.of(region.getRadius().toString()))); lines.add(TranslatableComponent.of("worldedit.selection.cylinder.info.radius", TextComponent.of(region.getRadius().toString())));

View File

@ -34,6 +34,8 @@ import com.sk89q.worldedit.regions.selector.limit.SelectorLimits;
import com.sk89q.worldedit.util.formatting.text.Component; import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.sk89q.worldedit.util.formatting.text.event.ClickEvent;
import com.sk89q.worldedit.util.formatting.text.event.HoverEvent;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import java.util.ArrayList; import java.util.ArrayList;
@ -225,7 +227,9 @@ public class EllipsoidRegionSelector implements RegionSelector, CUIRegion {
final Vector3 center = region.getCenter(); final Vector3 center = region.getCenter();
if (center.lengthSq() > 0) { if (center.lengthSq() > 0) {
lines.add(TranslatableComponent.of("worldedit.selection.ellipsoid.info.center", TextComponent.of(center.toString()))); lines.add(TranslatableComponent.of("worldedit.selection.ellipsoid.info.center", TextComponent.of(center.toString())
.clickEvent(ClickEvent.of(ClickEvent.Action.COPY_TO_CLIPBOARD, center.toParserString()))
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to copy")))));
} }
final Vector3 radius = region.getRadius(); final Vector3 radius = region.getRadius();