Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-473 Add default death message #474

Merged
merged 2 commits into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public PlayerDeathListener(NoticeService noticeService) {
public void onPlayerDeath(PlayerDeathEvent event) {
Player player = event.getEntity();

event.setDeathMessage(StringUtils.EMPTY);
event.setDeathMessage(null);

if (player.getKiller() != null) {
this.noticeService.create()
Expand All @@ -43,20 +43,25 @@ public void onPlayerDeath(PlayerDeathEvent event) {
return;
}

EntityDamageEvent lastDamageCasue = player.getLastDamageCause();
EntityDamageEvent lastDamageCause = player.getLastDamageCause();

if (lastDamageCasue == null) {
if (lastDamageCause == null) {
this.noticeService.create()
.noticeOption(translation -> RandomUtil.randomElement(translation.event().unknownDeathCause()))
.placeholder("{PLAYER}", player.getName())
.onlinePlayers()
.send();
return;
}

this.noticeService.create()
.noticeOption(translation -> {
EntityDamageEvent.DamageCause cause = lastDamageCasue.getCause();
EntityDamageEvent.DamageCause cause = lastDamageCause.getCause();

List<Notice> notifications = translation.event().deathMessageByDamageCause().get(cause);

if (notifications == null) {
return Option.none();
return RandomUtil.randomElement(translation.event().unknownDeathCause());
}

return RandomUtil.randomElement(notifications);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ interface AfkSection {

interface EventSection {
List<Notice> deathMessage();
List<Notice> unknownDeathCause();
List<Notice> joinMessage();
List<Notice> quitMessage();
List<Notice> firstJoinMessage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,10 @@ public static class ENEventSection implements EventSection {
)
);

public List<Notice> unknownDeathCause = List.of(
Notice.chat("<white>☠ <dark_red>{PLAYER} <red>died!")
);

@Description({ "", "# {PLAYER} - Player who joined" })
public List<Notice> joinMessage = List.of(
Notice.actionbar("<green>► <green>{PLAYER} <white>joined the server!"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,10 @@ public static class PLEventSection implements EventSection {
)
);

public List<Notice> unknownDeathCause = List.of(
Notice.chat("<white>☠ <dark_red>{PLAYER} <red>został zabity przez niezidentyfikowany obiekt bojowy!")
);

@Description({
" ",
"# Podobnie jak w wiadomości o śmierci, EternalCore będzie losował losową wiadomość z poniższej listy",
Expand Down