Skip to content

Commit

Permalink
GH-880 Fix player placeholder in home admin. (#880)
Browse files Browse the repository at this point in the history
  • Loading branch information
vLuckyyy authored Jan 9, 2025
1 parent 82256c5 commit eb68fdf
Showing 1 changed file with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.eternalcode.core.feature.home.homeadmin;

import com.eternalcode.annotations.scan.command.DescriptionDocs;
import com.eternalcode.core.configuration.implementation.PluginConfiguration;
import com.eternalcode.core.feature.home.Home;
import com.eternalcode.core.feature.home.HomeManager;
import com.eternalcode.core.injector.annotations.Inject;
Expand All @@ -24,11 +25,17 @@ class HomeAdminCommand {

private final HomeManager homeManager;
private final NoticeService noticeService;
private final PluginConfiguration pluginConfiguration;

@Inject
public HomeAdminCommand(HomeManager homeManager, NoticeService noticeService) {
public HomeAdminCommand(
HomeManager homeManager,
NoticeService noticeService,
PluginConfiguration pluginConfiguration
) {
this.homeManager = homeManager;
this.noticeService = noticeService;
this.pluginConfiguration = pluginConfiguration;
}

@Execute(name = "sethome")
Expand All @@ -48,6 +55,7 @@ void setHome(@Context Player sender, @Arg PlayerHomeEntry playerHomeEntry, @Arg
this.noticeService.create()
.notice(translate -> translate.home().overrideHomeLocationAsAdmin())
.placeholder("{HOME}", name)
.placeholder("{PLAYER}", player.getName())
.player(player.getUniqueId())
.send();

Expand All @@ -58,6 +66,7 @@ void setHome(@Context Player sender, @Arg PlayerHomeEntry playerHomeEntry, @Arg
this.noticeService.create()
.notice(translate -> translate.home().createAsAdmin())
.placeholder("{HOME}", name)
.placeholder("{PLAYER}", player.getName())
.player(player.getUniqueId())
.send();
}
Expand All @@ -77,6 +86,7 @@ void deleteHome(@Context Player sender, @Arg PlayerHomeEntry playerHomeEntry) {
this.noticeService.create()
.notice(translate -> translate.home().homeList())
.placeholder("{HOMES}", homes)
.placeholder("{PLAYER}", player.getName())
.player(sender.getUniqueId())
.send();

Expand Down Expand Up @@ -104,6 +114,7 @@ void home(@Context Player player, @Arg PlayerHomeEntry playerHomeEntry) {
this.noticeService.create()
.notice(translate -> translate.home().playerNoOwnedHomes())
.placeholder("{HOME}", home.getName())
.placeholder("{PLAYER}", user.getName())
.player(player.getUniqueId())
.send();

Expand All @@ -121,14 +132,15 @@ void list(@Context Viewer viewer, @Arg User user) {
this.noticeService.create()
.notice(translate -> translate.home().homeListAsAdmin())
.placeholder("{HOMES}", homes)
.placeholder("{PLAYER}", user.getName())
.viewer(viewer)
.send();
}

private String formattedListUserHomes(UUID uniqueId) {
return this.homeManager.getHomes(uniqueId).stream()
.map(home -> home.getName())
.collect(Collectors.joining(", "));
.collect(Collectors.joining(this.pluginConfiguration.format.separator));
}
}

0 comments on commit eb68fdf

Please sign in to comment.