Skip to content

GH-999 Add end screen command #1104

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

Merged
merged 6 commits into from
Aug 11, 2025
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
@@ -0,0 +1,51 @@
package com.eternalcode.core.feature.fun.endscreen;

import com.eternalcode.annotations.scan.command.DescriptionDocs;
import com.eternalcode.core.compatibility.Compatibility;
import com.eternalcode.core.compatibility.Version;
import com.eternalcode.core.injector.annotations.Inject;
import com.eternalcode.core.notice.NoticeService;
import com.eternalcode.paper.PaperOverlay;
import dev.rollczi.litecommands.annotations.argument.Arg;
import dev.rollczi.litecommands.annotations.command.Command;
import dev.rollczi.litecommands.annotations.context.Context;
import dev.rollczi.litecommands.annotations.execute.Execute;
import dev.rollczi.litecommands.annotations.permission.Permission;
import org.bukkit.entity.Player;

@Command(name = "endscreen", aliases = {"end-screen", "win-screen"})
@Permission("eternalcore.endscreen")
@Compatibility(from = @Version(minor = 19, patch = 4)) // Requires Minecraft 1.19.4 or higher
public class EndScreenCommand {

private final NoticeService noticeService;

@Inject
public EndScreenCommand(NoticeService noticeService) {
this.noticeService = noticeService;
}

@Execute
@DescriptionDocs(description = "Show a end screen to yourself")
void self(@Context Player sender) {
PaperOverlay.END_SCREEN.show(sender);

this.noticeService.create()
.notice(translation -> translation.endScreen().shownToSelf())
.player(sender.getUniqueId())
.send();
}

@Execute
@DescriptionDocs(description = "Show a end screen to a player", arguments = "<player>")
void other(@Context Player sender, @Arg Player target) {
PaperOverlay.END_SCREEN.show(target);

this.noticeService.create()
.notice(translation -> translation.endScreen().shownToOtherPlayer())
.player(sender.getUniqueId())
.placeholder("{PLAYER}", target.getName())
.send();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.eternalcode.core.feature.fun.endscreen.messages;

import com.eternalcode.multification.notice.Notice;
import eu.okaeri.configs.OkaeriConfig;
import eu.okaeri.configs.annotation.Comment;
import lombok.Getter;
import lombok.experimental.Accessors;

@Getter
@Accessors(fluent = true)

public class ENEndScreenMessages extends OkaeriConfig implements EndScreenMessages {

public Notice shownToSelf = Notice.chat("<green>► <white>You have shown the end screen to yourself!</white>");

@Comment("# {PLAYER} - returns player's name")
public Notice shownToOtherPlayer = Notice.chat("<green>► <white>You have shown the end screen to player <green>{PLAYER}!</green>");
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.eternalcode.core.feature.fun.endscreen.messages;

import com.eternalcode.multification.notice.Notice;

public interface EndScreenMessages {

Notice shownToSelf();
Notice shownToOtherPlayer();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.eternalcode.core.feature.fun.endscreen.messages;

import com.eternalcode.multification.notice.Notice;
import eu.okaeri.configs.OkaeriConfig;
import eu.okaeri.configs.annotation.Comment;
import lombok.Getter;
import lombok.experimental.Accessors;

@Getter
@Accessors(fluent = true)
public class PLEndScreenMessages extends OkaeriConfig implements EndScreenMessages {

public Notice shownToSelf = Notice.chat("<green>► <white>Pokazałeś ekran końca gry sobie!</white>");

@Comment("# {PLAYER} - ten placeholder zostanie zastąpiony przez nazwę gracza, któremu pokazujesz ekran końca gry.")
public Notice shownToOtherPlayer = Notice.chat("<green>► <white>Pokazałeś ekran końca gry graczowi <green>{PLAYER}!</green>");
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.eternalcode.core.feature.burn.messages.BurnMessages;
import com.eternalcode.core.feature.fun.demoscreen.messages.DemoScreenMessages;
import com.eternalcode.core.feature.fun.elderguardian.messages.ElderGuardianMessages;
import com.eternalcode.core.feature.fun.endscreen.messages.EndScreenMessages;
import com.eternalcode.core.feature.helpop.messages.HelpOpSection;
import com.eternalcode.core.feature.home.messages.HomeMessages;
import com.eternalcode.core.feature.itemedit.messages.ItemEditMessages;
Expand Down Expand Up @@ -198,6 +199,7 @@ interface ContainerSection {

ElderGuardianMessages elderGuardian();
DemoScreenMessages demoScreen();
EndScreenMessages endScreen();

Language getLanguage();
// argument section
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.eternalcode.core.feature.burn.messages.ENBurnMessages;
import com.eternalcode.core.feature.fun.demoscreen.messages.ENDemoScreenMessages;
import com.eternalcode.core.feature.fun.elderguardian.messages.ENElderGuardianMessages;
import com.eternalcode.core.feature.fun.endscreen.messages.ENEndScreenMessages;
import com.eternalcode.core.feature.helpop.messages.ENHelpOpMessages;
import com.eternalcode.core.feature.home.messages.ENHomeMessages;
import com.eternalcode.core.feature.itemedit.messages.ENItemEditMessages;
Expand Down Expand Up @@ -573,6 +574,9 @@ public static class ENLanguageSection extends OkaeriConfig implements LanguageSe
@Comment({" ", "# This section is responsible for demo screen messages."})
public ENDemoScreenMessages demoScreen = new ENDemoScreenMessages();

@Comment({" ", "# This section is responsible for end screen messages."})
public ENEndScreenMessages endScreen = new ENEndScreenMessages();

@Comment({" ", "# This section is responsible for '/burn' command messages."})
public ENBurnMessages burn = new ENBurnMessages();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.eternalcode.core.feature.burn.messages.PLBurnMessages;
import com.eternalcode.core.feature.fun.demoscreen.messages.PLDemoScreenMessages;
import com.eternalcode.core.feature.fun.elderguardian.messages.PLElderGuardianMessages;
import com.eternalcode.core.feature.fun.endscreen.messages.PLEndScreenMessages;
import com.eternalcode.core.feature.helpop.messages.PLHelpOpMessages;
import com.eternalcode.core.feature.home.messages.PLHomeMessages;
import com.eternalcode.core.feature.itemedit.messages.PLItemEditMessages;
Expand Down Expand Up @@ -597,6 +598,9 @@ public static class PLLanguageSection extends OkaeriConfig implements LanguageSe
@Comment({" ", "# Ta sekcja odpowiada za wiadomości dotyczące demo screen'a"})
public PLDemoScreenMessages demoScreen = new PLDemoScreenMessages();

@Comment({" ", "# Ta sekcja odpowiada za wiadomości dotyczące końca gry"})
public PLEndScreenMessages endScreen = new PLEndScreenMessages();

@Comment({" ", "# Ta sekcja odpowiada za wiadomości dotyczące komendy /burn"})
public PLBurnMessages burn = new PLBurnMessages();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ public enum PaperContainer {
LOOM("Loom", player -> player.openLoom(null, true)),
SMITHING_TABLE("Smithing Table", player -> player.openSmithingTable(null, true));

private final PaperFeature<PaperContainer> feature;
private final PaperFeature feature;

PaperContainer(String name, Consumer<Player> action) {
this.feature = new PaperFeature<>(action, name) {
this.feature = new PaperFeature(action, name) {
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import java.util.function.Consumer;
import java.util.logging.Logger;

public abstract class PaperFeature<T> {
public abstract class PaperFeature {

private static final Environment ENVIRONMENT = PaperLib.getEnvironment();
private static final Logger LOGGER = Logger.getLogger("EternalCore-Paper");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@
public enum PaperOverlay {

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

private final PaperFeature<PaperOverlay> feature;
private final PaperFeature feature;

PaperOverlay(String name, Consumer<Player> action) {
this.feature = new PaperFeature<>(action, name) {
this.feature = new PaperFeature(action, name) {
};
}

public void show(Player player) {
feature.execute(player);
this.feature.execute(player);
}
}