Make block positions copy on click for //size (#1546)

* Make block positions copy on click for //size

* PR feedback
This commit is contained in:
Lewis B 2020-10-04 16:08:21 +10:00 committed by GitHub
parent 2b868ce0c1
commit 6925d3715a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 48 additions and 4 deletions

View File

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

View File

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

View File

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

View File

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

View File

@ -33,6 +33,8 @@
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
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 java.util.ArrayList;
@ -255,11 +257,15 @@ public List<Component> getSelectionInfoLines() {
final List<Component> lines = new ArrayList<>();
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) {
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;

View File

@ -37,6 +37,8 @@
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
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 java.text.NumberFormat;
@ -244,7 +246,10 @@ public List<Component> getSelectionInfoLines() {
final List<Component> lines = new ArrayList<>();
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)) {
lines.add(TranslatableComponent.of("worldedit.selection.cylinder.info.radius", TextComponent.of(region.getRadius().toString())));

View File

@ -34,6 +34,8 @@
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
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 java.util.ArrayList;
@ -225,7 +227,9 @@ public List<Component> getSelectionInfoLines() {
final Vector3 center = region.getCenter();
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();