11package com .eternalcode .core .feature .home .command ;
22
33import com .eternalcode .annotations .scan .command .DescriptionDocs ;
4+ import com .eternalcode .core .configuration .implementation .PluginConfiguration ;
45import com .eternalcode .core .feature .home .Home ;
56import com .eternalcode .core .feature .home .HomeService ;
67import com .eternalcode .core .feature .home .HomeTeleportService ;
1415import dev .rollczi .litecommands .annotations .permission .Permission ;
1516import java .util .Collection ;
1617import java .util .Optional ;
18+ import java .util .stream .Collectors ;
1719import org .bukkit .entity .Player ;
1820
1921@ Command (name = "home" )
2022@ Permission ("eternalcore.home" )
2123class HomeCommand {
2224
25+ private static final String CLICK_COMMAND_FORMATTED_LIST = "<click:run_command:'/home %s'>%s</click>" ;
26+
2327 private final HomesSettings homesSettings ;
2428 private final NoticeService noticeService ;
2529 private final HomeService homeService ;
2630 private final HomeTeleportService homeTeleportService ;
31+ private final PluginConfiguration pluginConfiguration ;
2732
2833 @ Inject
2934 HomeCommand (
3035 HomesSettings homesSettings ,
3136 NoticeService noticeService ,
3237 HomeService homeService ,
33- HomeTeleportService homeTeleportService
38+ HomeTeleportService homeTeleportService ,
39+ PluginConfiguration pluginConfiguration
3440 ) {
3541 this .homesSettings = homesSettings ;
3642 this .noticeService = noticeService ;
3743 this .homeService = homeService ;
3844 this .homeTeleportService = homeTeleportService ;
45+ this .pluginConfiguration = pluginConfiguration ;
3946 }
4047
4148 @ Execute
@@ -52,11 +59,7 @@ void execute(@Sender Player player) {
5259 }
5360
5461 if (playerHomes .size () > 1 ) {
55- String homes = String .join (
56- ", " ,
57- playerHomes .stream ()
58- .map (Home ::getName )
59- .toList ());
62+ String homes = this .formatHomeList (playerHomes );
6063
6164 Optional <Home > mainHome = playerHomes .stream ()
6265 .filter (home -> home .getName ().equals (this .homesSettings .defaultName ()))
@@ -85,4 +88,16 @@ void execute(@Sender Player player) {
8588 void execute (@ Sender Player player , @ Arg Home home ) {
8689 this .homeTeleportService .teleport (player , home );
8790 }
91+
92+ private String formatHomeList (Collection <Home > homes ) {
93+ return homes .stream ()
94+ .map (home -> String .format (
95+ CLICK_COMMAND_FORMATTED_LIST ,
96+ home .getName (),
97+ home .getName ()
98+ ))
99+ .collect (Collectors .joining (
100+ this .pluginConfiguration .format .separator
101+ ));
102+ }
88103}
0 commit comments