Skip to content

Commit df8fe74

Browse files
GH-999 Add end screen command (#1104)
* Add end screen feature with translations and command Introduced the end screen overlay functionality, including the EndScreenCommand for showing the end screen to self or another player. Added English and Polish message translations for the end screen, updated the Translation interface and implementations, and extended PaperOverlay to support the new end screen. * Update eternalcore-core/src/main/java/com/eternalcode/core/feature/fun/endscreen/messages/ENEndScreenMessages.java Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> * troll -> fun * follow Martin's suggestions * Added missing config comments --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
1 parent 875b069 commit df8fe74

File tree

10 files changed

+113
-7
lines changed

10 files changed

+113
-7
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package com.eternalcode.core.feature.fun.endscreen;
2+
3+
import com.eternalcode.annotations.scan.command.DescriptionDocs;
4+
import com.eternalcode.core.compatibility.Compatibility;
5+
import com.eternalcode.core.compatibility.Version;
6+
import com.eternalcode.core.injector.annotations.Inject;
7+
import com.eternalcode.core.notice.NoticeService;
8+
import com.eternalcode.paper.PaperOverlay;
9+
import dev.rollczi.litecommands.annotations.argument.Arg;
10+
import dev.rollczi.litecommands.annotations.command.Command;
11+
import dev.rollczi.litecommands.annotations.context.Context;
12+
import dev.rollczi.litecommands.annotations.execute.Execute;
13+
import dev.rollczi.litecommands.annotations.permission.Permission;
14+
import org.bukkit.entity.Player;
15+
16+
@Command(name = "endscreen", aliases = {"end-screen", "win-screen"})
17+
@Permission("eternalcore.endscreen")
18+
@Compatibility(from = @Version(minor = 19, patch = 4)) // Requires Minecraft 1.19.4 or higher
19+
public class EndScreenCommand {
20+
21+
private final NoticeService noticeService;
22+
23+
@Inject
24+
public EndScreenCommand(NoticeService noticeService) {
25+
this.noticeService = noticeService;
26+
}
27+
28+
@Execute
29+
@DescriptionDocs(description = "Show a end screen to yourself")
30+
void self(@Context Player sender) {
31+
PaperOverlay.END_SCREEN.show(sender);
32+
33+
this.noticeService.create()
34+
.notice(translation -> translation.endScreen().shownToSelf())
35+
.player(sender.getUniqueId())
36+
.send();
37+
}
38+
39+
@Execute
40+
@DescriptionDocs(description = "Show a end screen to a player", arguments = "<player>")
41+
void other(@Context Player sender, @Arg Player target) {
42+
PaperOverlay.END_SCREEN.show(target);
43+
44+
this.noticeService.create()
45+
.notice(translation -> translation.endScreen().shownToOtherPlayer())
46+
.player(sender.getUniqueId())
47+
.placeholder("{PLAYER}", target.getName())
48+
.send();
49+
}
50+
51+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.eternalcode.core.feature.fun.endscreen.messages;
2+
3+
import com.eternalcode.multification.notice.Notice;
4+
import eu.okaeri.configs.OkaeriConfig;
5+
import eu.okaeri.configs.annotation.Comment;
6+
import lombok.Getter;
7+
import lombok.experimental.Accessors;
8+
9+
@Getter
10+
@Accessors(fluent = true)
11+
12+
public class ENEndScreenMessages extends OkaeriConfig implements EndScreenMessages {
13+
14+
public Notice shownToSelf = Notice.chat("<green>► <white>You have shown the end screen to yourself!</white>");
15+
16+
@Comment("# {PLAYER} - returns player's name")
17+
public Notice shownToOtherPlayer = Notice.chat("<green>► <white>You have shown the end screen to player <green>{PLAYER}!</green>");
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.eternalcode.core.feature.fun.endscreen.messages;
2+
3+
import com.eternalcode.multification.notice.Notice;
4+
5+
public interface EndScreenMessages {
6+
7+
Notice shownToSelf();
8+
Notice shownToOtherPlayer();
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.eternalcode.core.feature.fun.endscreen.messages;
2+
3+
import com.eternalcode.multification.notice.Notice;
4+
import eu.okaeri.configs.OkaeriConfig;
5+
import eu.okaeri.configs.annotation.Comment;
6+
import lombok.Getter;
7+
import lombok.experimental.Accessors;
8+
9+
@Getter
10+
@Accessors(fluent = true)
11+
public class PLEndScreenMessages extends OkaeriConfig implements EndScreenMessages {
12+
13+
public Notice shownToSelf = Notice.chat("<green>► <white>Pokazałeś ekran końca gry sobie!</white>");
14+
15+
@Comment("# {PLAYER} - ten placeholder zostanie zastąpiony przez nazwę gracza, któremu pokazujesz ekran końca gry.")
16+
public Notice shownToOtherPlayer = Notice.chat("<green>► <white>Pokazałeś ekran końca gry graczowi <green>{PLAYER}!</green>");
17+
}

eternalcore-core/src/main/java/com/eternalcode/core/translation/Translation.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import com.eternalcode.core.feature.burn.messages.BurnMessages;
1010
import com.eternalcode.core.feature.fun.demoscreen.messages.DemoScreenMessages;
1111
import com.eternalcode.core.feature.fun.elderguardian.messages.ElderGuardianMessages;
12+
import com.eternalcode.core.feature.fun.endscreen.messages.EndScreenMessages;
1213
import com.eternalcode.core.feature.helpop.messages.HelpOpSection;
1314
import com.eternalcode.core.feature.home.messages.HomeMessages;
1415
import com.eternalcode.core.feature.itemedit.messages.ItemEditMessages;
@@ -191,6 +192,7 @@ interface ContainerSection {
191192

192193
ElderGuardianMessages elderGuardian();
193194
DemoScreenMessages demoScreen();
195+
EndScreenMessages endScreen();
194196

195197
Language getLanguage();
196198
// argument section

eternalcore-core/src/main/java/com/eternalcode/core/translation/implementation/ENTranslation.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import com.eternalcode.core.feature.burn.messages.ENBurnMessages;
1111
import com.eternalcode.core.feature.fun.demoscreen.messages.ENDemoScreenMessages;
1212
import com.eternalcode.core.feature.fun.elderguardian.messages.ENElderGuardianMessages;
13+
import com.eternalcode.core.feature.fun.endscreen.messages.ENEndScreenMessages;
1314
import com.eternalcode.core.feature.helpop.messages.ENHelpOpMessages;
1415
import com.eternalcode.core.feature.home.messages.ENHomeMessages;
1516
import com.eternalcode.core.feature.itemedit.messages.ENItemEditMessages;
@@ -570,6 +571,9 @@ public static class ENLanguageSection extends OkaeriConfig implements LanguageSe
570571
@Comment({" ", "# This section is responsible for demo screen messages."})
571572
public ENDemoScreenMessages demoScreen = new ENDemoScreenMessages();
572573

574+
@Comment({" ", "# This section is responsible for end screen messages."})
575+
public ENEndScreenMessages endScreen = new ENEndScreenMessages();
576+
573577
@Comment({" ", "# This section is responsible for '/burn' command messages."})
574578
public ENBurnMessages burn = new ENBurnMessages();
575579

eternalcore-core/src/main/java/com/eternalcode/core/translation/implementation/PLTranslation.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import com.eternalcode.core.feature.burn.messages.PLBurnMessages;
1010
import com.eternalcode.core.feature.fun.demoscreen.messages.PLDemoScreenMessages;
1111
import com.eternalcode.core.feature.fun.elderguardian.messages.PLElderGuardianMessages;
12+
import com.eternalcode.core.feature.fun.endscreen.messages.PLEndScreenMessages;
1213
import com.eternalcode.core.feature.helpop.messages.PLHelpOpMessages;
1314
import com.eternalcode.core.feature.home.messages.PLHomeMessages;
1415
import com.eternalcode.core.feature.itemedit.messages.PLItemEditMessages;
@@ -594,6 +595,9 @@ public static class PLLanguageSection extends OkaeriConfig implements LanguageSe
594595
@Comment({" ", "# Ta sekcja odpowiada za wiadomości dotyczące demo screen'a"})
595596
public PLDemoScreenMessages demoScreen = new PLDemoScreenMessages();
596597

598+
@Comment({" ", "# Ta sekcja odpowiada za wiadomości dotyczące końca gry"})
599+
public PLEndScreenMessages endScreen = new PLEndScreenMessages();
600+
597601
@Comment({" ", "# Ta sekcja odpowiada za wiadomości dotyczące komendy /burn"})
598602
public PLBurnMessages burn = new PLBurnMessages();
599603

eternalcore-paper/src/main/java/com/eternalcode/paper/PaperContainer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ public enum PaperContainer {
1313
LOOM("Loom", player -> player.openLoom(null, true)),
1414
SMITHING_TABLE("Smithing Table", player -> player.openSmithingTable(null, true));
1515

16-
private final PaperFeature<PaperContainer> feature;
16+
private final PaperFeature feature;
1717

1818
PaperContainer(String name, Consumer<Player> action) {
19-
this.feature = new PaperFeature<>(action, name) {
19+
this.feature = new PaperFeature(action, name) {
2020
};
2121
}
2222

eternalcore-paper/src/main/java/com/eternalcode/paper/PaperFeature.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import java.util.function.Consumer;
99
import java.util.logging.Logger;
1010

11-
public abstract class PaperFeature<T> {
11+
public abstract class PaperFeature {
1212

1313
private static final Environment ENVIRONMENT = PaperLib.getEnvironment();
1414
private static final Logger LOGGER = Logger.getLogger("EternalCore-Paper");

eternalcore-paper/src/main/java/com/eternalcode/paper/PaperOverlay.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,17 @@
77
public enum PaperOverlay {
88

99
ELDER_GUARDIAN("Elder Guardian", player -> player.showElderGuardian(false)),
10-
ELDER_GUARDIAN_SILENT("Elder Guardian Silent", player -> player.showElderGuardian(true));
10+
ELDER_GUARDIAN_SILENT("Elder Guardian Silent", player -> player.showElderGuardian(true)),
11+
END_SCREEN("End Screen", player -> player.showWinScreen());
1112

12-
private final PaperFeature<PaperOverlay> feature;
13+
private final PaperFeature feature;
1314

1415
PaperOverlay(String name, Consumer<Player> action) {
15-
this.feature = new PaperFeature<>(action, name) {
16+
this.feature = new PaperFeature(action, name) {
1617
};
1718
}
1819

1920
public void show(Player player) {
20-
feature.execute(player);
21+
this.feature.execute(player);
2122
}
2223
}

0 commit comments

Comments
 (0)