-
-
Save StealWonders/96027959ddc0120c7cfcd3c806a30ccd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Subcommand("list") | |
public void onList(final CommandSender sender) { | |
final List<Project> projects = plugin.getProjectManager().getProjects().stream() | |
.filter(project -> project.getProjectStatus().equals(ProjectStatus.ACTIVE)) | |
.collect(Collectors.toList()); | |
if (projects.size() >= 1) { | |
List<TextComponent> textComponents = new ArrayList<>(); | |
projects.forEach(project -> { | |
TextComponent textComponent = TextComponent.builder(project.getName()).color(TextColor.AQUA) | |
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to teleport!"))) | |
.clickEvent(ClickEvent.of(ClickEvent.Action.RUN_COMMAND, "/project teleport " + project.getName())) | |
.append(TextComponent.of(",").color(TextColor.GOLD)).build(); | |
textComponents.add(textComponent); | |
}); | |
System.out.println(textComponents.size()); | |
TextComponent message = TextComponent.join(TextComponent.of(", ").color(TextColor.GOLD), textComponents); | |
sender.sendMessage(""); | |
TextAdapter.sendComponent(sender, message); | |
sender.sendMessage(""); | |
} else { | |
NO_PROJECTS_AVAILABLE.send(sender); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment