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

Sign editor (/sign setline <index> <text> command) #886

Open
vLuckyyy opened this issue Jan 11, 2025 · 1 comment · May be fixed by #895
Open

Sign editor (/sign setline <index> <text> command) #886

vLuckyyy opened this issue Jan 11, 2025 · 1 comment · May be fixed by #895
Assignees
Labels
🆕 feature New feature or request

Comments

@vLuckyyy
Copy link
Member

No description provided.

@github-project-automation github-project-automation bot moved this to 📋 Backlog in EternalCore Jan 11, 2025
@igoyek igoyek self-assigned this Jan 11, 2025
@vLuckyyy
Copy link
Member Author

@Command(name = "signedit setline")
@Permission("signedit.setline")
public class SignEditCommand implements MiniMessageHolder {

    private final NoticeService noticeService;
    private final SignConfig signConfig;

    public SignEditCommand(NoticeService noticeService, SignConfig signConfig) {
        this.noticeService = noticeService;
        this.signConfig = signConfig;
    }

    @Execute
    void execute(@Context Player player, @Arg Integer index, @Join String text) {
        Block targetBlock = player.getTargetBlockExact(5);
        if (targetBlock == null || !(targetBlock.getState() instanceof Sign sign)) {
            this.noticeService.create()
                .player(player.getUniqueId())
                .notice(this.signConfig.noSignFound)
                .send();
            return;
        }

        SignSide frontSide = sign.getSide(Side.FRONT);
        if (index < 0 || index >= frontSide.lines().size()) {
            this.noticeService.create()
                .player(player.getUniqueId())
                .notice(this.signConfig.invalidIndex)
                .send();
            return;
        }

        frontSide.line(index, MINI_MESSAGE.deserialize(text));
        sign.update();

        this.noticeService.create()
            .player(player.getUniqueId())
            .notice(this.signConfig.lineSet)
            .send();
    }
}

@igoyek igoyek added the 🌍 for the sake of humanity Humanity will die without it label Jan 11, 2025
@igoyek igoyek changed the title Add /sign setline <index> <text> command Sign editor (/sign set/add/update/clear <index> <text> command) Jan 11, 2025
@igoyek igoyek changed the title Sign editor (/sign set/add/update/clear <index> <text> command) Sign editor (/sign setline <index> <text> command) Jan 22, 2025
@igoyek igoyek linked a pull request Jan 22, 2025 that will close this issue
@vLuckyyy vLuckyyy added 🆕 feature New feature or request and removed 🌍 for the sake of humanity Humanity will die without it labels Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🆕 feature New feature or request
Projects
Status: 📋 Backlog
Development

Successfully merging a pull request may close this issue.

2 participants