make npc location display a little better

This commit is contained in:
Pyrbu 2023-05-10 16:57:51 +01:00
parent 4197c58008
commit e0403d67f7
2 changed files with 15 additions and 3 deletions

@ -28,14 +28,26 @@ public class ZLocation {
return this.x;
}
public int getBlockX() {
return (int) getX();
}
public double getY() {
return this.y;
}
public int getBlockY() {
return (int) getY();
}
public double getZ() {
return this.z;
}
public int getBlockZ() {
return (int) getZ();
}
public float getYaw() {
return this.yaw;
}

@ -5,11 +5,11 @@ import lol.pyr.director.adventure.command.CommandHandler;
import lol.pyr.director.common.command.CommandExecutionException;
import lol.pyr.znpcsplus.npc.NpcImpl;
import lol.pyr.znpcsplus.npc.NpcRegistryImpl;
import lol.pyr.znpcsplus.util.ZLocation;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.event.ClickEvent;
import net.kyori.adventure.text.format.NamedTextColor;
import org.bukkit.Location;
public class ListCommand implements CommandHandler {
@Override
@ -17,7 +17,7 @@ public class ListCommand implements CommandHandler {
TextComponent.Builder component = Component.text("Npc's:\n").color(NamedTextColor.GOLD).toBuilder();
for (String id : NpcRegistryImpl.get().modifiableIds()) {
NpcImpl npc = NpcRegistryImpl.get().get(id).getNpc();
Location location = npc.getLocation().toBukkitLocation(npc.getWorld());
ZLocation location = npc.getLocation();
component.append(Component.text("ID: " + id, NamedTextColor.GREEN))
.append(Component.text(" | ", NamedTextColor.GRAY))
.append(Component.text("Type: ", NamedTextColor.GREEN))
@ -26,7 +26,7 @@ public class ListCommand implements CommandHandler {
.append(Component.text("Name: ", NamedTextColor.GREEN))
.append(npc.getHologram().getLine(0).color(NamedTextColor.GREEN))
.append(Component.text(" | ", NamedTextColor.GRAY))
.append(Component.text("Location: " + npc.getWorld().getName() + " X:" + location.getBlockX() + " Y:" + location.getBlockY() + " Z:" + location.getBlockZ(), NamedTextColor.GREEN))
.append(Component.text("Location: " + npc.getWorldName() + " X:" + location.getBlockX() + " Y:" + location.getBlockY() + " Z:" + location.getBlockZ(), NamedTextColor.GREEN))
.append(Component.text(" | ", NamedTextColor.GRAY))
.append(Component.text("[TELEPORT]", NamedTextColor.DARK_GREEN).clickEvent(ClickEvent.runCommand("/npc teleport " + id)))
.append(Component.text("\n", NamedTextColor.GRAY));