make component more concise
This commit is contained in:
parent
5f49ef8db5
commit
ceb1747878
1 changed files with 9 additions and 18 deletions
|
@ -21,7 +21,6 @@ import io.github.znetworkw.znpcservers.user.ZUser;
|
||||||
import io.github.znetworkw.znpcservers.utility.location.ZLocation;
|
import io.github.znetworkw.znpcservers.utility.location.ZLocation;
|
||||||
import lol.pyr.znpcsplus.ZNPCsPlus;
|
import lol.pyr.znpcsplus.ZNPCsPlus;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.TextComponent;
|
|
||||||
import net.kyori.adventure.text.event.ClickEvent;
|
import net.kyori.adventure.text.event.ClickEvent;
|
||||||
import net.kyori.adventure.text.event.HoverEvent;
|
import net.kyori.adventure.text.event.HoverEvent;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
|
@ -122,25 +121,18 @@ public class DefaultCommand extends Command {
|
||||||
Configuration.MESSAGES.sendMessage(sender.getCommandSender(), ConfigurationValue.NO_NPC_FOUND);
|
Configuration.MESSAGES.sendMessage(sender.getCommandSender(), ConfigurationValue.NO_NPC_FOUND);
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(ChatColor.DARK_GREEN + "NPC list:");
|
sender.sendMessage(ChatColor.DARK_GREEN + "NPC list:");
|
||||||
for (NPCModel npcModel : ConfigurationConstants.NPC_LIST) {
|
for (NPCModel npcModel : ConfigurationConstants.NPC_LIST)
|
||||||
TextComponent component = Component.text("-")
|
ZNPCsPlus.ADVENTURE.player(sender.getPlayer()).sendMessage(Component.text("-", NamedTextColor.GREEN)
|
||||||
.color(NamedTextColor.GREEN)
|
.append(Component.text(" " + npcModel.getId(), npcModel.getShouldSpawn() ? NamedTextColor.GREEN : NamedTextColor.RED))
|
||||||
.append(Component.text(" " + npcModel.getId())
|
.append(Component.text(" " + npcModel.getHologramLines().toString() +
|
||||||
.color(npcModel.getShouldSpawn() ? NamedTextColor.GREEN : NamedTextColor.RED))
|
" (" + npcModel.getLocation().getWorldName() + " " + (int) npcModel.getLocation().getX() + " " +
|
||||||
.append(Component.text(" " + npcModel.getHologramLines().toString() + " (" + npcModel.getLocation().getWorldName() + " " + (int) npcModel.getLocation().getX() + " " + (int) npcModel.getLocation().getY() + " " + (int) npcModel.getLocation().getZ() + ") ")
|
(int) npcModel.getLocation().getY() + " " + (int) npcModel.getLocation().getZ() + ") ", NamedTextColor.GREEN))
|
||||||
.color(NamedTextColor.GREEN))
|
.append(Component.text("[TELEPORT]", NamedTextColor.GREEN, TextDecoration.BOLD)
|
||||||
.append(Component.text("[TELEPORT]")
|
|
||||||
.color(NamedTextColor.GREEN)
|
|
||||||
.decorate(TextDecoration.BOLD)
|
|
||||||
.clickEvent(ClickEvent.runCommand("/znpcs teleport " + npcModel.getId()))
|
.clickEvent(ClickEvent.runCommand("/znpcs teleport " + npcModel.getId()))
|
||||||
.hoverEvent(HoverEvent.showText(Component.text("Click to teleport to this NPC."))))
|
.hoverEvent(HoverEvent.showText(Component.text("Click to teleport to this NPC."))))
|
||||||
.append(Component.text(" [DELETE]")
|
.append(Component.text(" [DELETE]", NamedTextColor.RED, TextDecoration.BOLD)
|
||||||
.color(NamedTextColor.RED)
|
|
||||||
.decorate(TextDecoration.BOLD)
|
|
||||||
.clickEvent(ClickEvent.runCommand("/znpcs delete " + npcModel.getId()))
|
.clickEvent(ClickEvent.runCommand("/znpcs delete " + npcModel.getId()))
|
||||||
.hoverEvent(HoverEvent.showText(Component.text("Click to delete this NPC."))));
|
.hoverEvent(HoverEvent.showText(Component.text("Click to delete this NPC.")))));
|
||||||
ZNPCsPlus.ADVENTURE.player(sender.getPlayer()).sendMessage(component);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,7 +176,6 @@ public class DefaultCommand extends Command {
|
||||||
foundNPC.getNpcPojo().getNpcEquip().put(EquipmentSlot.valueOf(args.get("slot").toUpperCase()), sender.getPlayer().getInventory().getItemInHand());
|
foundNPC.getNpcPojo().getNpcEquip().put(EquipmentSlot.valueOf(args.get("slot").toUpperCase()), sender.getPlayer().getInventory().getItemInHand());
|
||||||
foundNPC.getPackets().flushCache("equipPackets");
|
foundNPC.getPackets().flushCache("equipPackets");
|
||||||
Objects.requireNonNull(foundNPC);
|
Objects.requireNonNull(foundNPC);
|
||||||
Objects.requireNonNull(foundNPC);
|
|
||||||
foundNPC.getViewers().forEach(foundNPC::sendEquipPackets);
|
foundNPC.getViewers().forEach(foundNPC::sendEquipPackets);
|
||||||
Configuration.MESSAGES.sendMessage(sender.getCommandSender(), ConfigurationValue.SUCCESS);
|
Configuration.MESSAGES.sendMessage(sender.getCommandSender(), ConfigurationValue.SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue