Skip to content

Commit 5f93b64

Browse files
committed
feat: improve /display video error feedback
1 parent df3990a commit 5f93b64

File tree

10 files changed

+31
-9
lines changed

10 files changed

+31
-9
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Plugin:
5252
- [x] Add `/display info` command for quick display information
5353
- [x] Add `/display list` filters (`mine`, `world <name>`, `owner <name>`, `sync`)
5454
- [x] Add translation for `/display list` command
55-
- [ ] Improve `/display video` error feedback (separate invalid URL/not owner/wrong target block)
55+
- [x] Improve `/display video` error feedback (separate invalid URL/not owner/wrong target block)
5656
- [x] Add total value output to `/display stats`
5757
- [ ] Add admin target mode for `/display on|off <player>`
5858
- [ ] Improve `/display reload` output with what was reloaded

spigot/src/main/kotlin/com/dreamdisplays/commands/subcommands/VideoCommand.kt

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,26 @@ class VideoCommand : SubCommand {
2323
return
2424
}
2525

26+
val code = YouTubeUtils.extractVideoIdFromUri(args[1] ?: "")
27+
?: return Message.sendMessage(player, "invalidURL")
28+
2629
val block = player.getTargetBlock(null, 32)
27-
val data = isContains(block.location)
2830

29-
if (
30-
block.type != Main.config.settings.baseMaterial ||
31-
data == null ||
32-
data.ownerId != player.uniqueId
33-
) {
31+
if (block.type != Main.config.settings.baseMaterial) {
32+
Message.sendMessage(player, "displayVideoWrongTargetBlock")
33+
return
34+
}
35+
36+
val data = isContains(block.location)
37+
if (data == null) {
3438
Message.sendMessage(player, "noDisplay")
3539
return
3640
}
3741

38-
val code = YouTubeUtils.extractVideoIdFromUri(args[1] ?: "")
39-
?: return Message.sendMessage(player, "invalidURL")
42+
if (data.ownerId != player.uniqueId) {
43+
Message.sendMessage(player, "displayVideoNotOwner")
44+
return
45+
}
4046

4147
data.apply {
4248
url = "https://youtube.com/watch?v=$code"

spigot/src/main/resources/assets/dreamdisplays/lang/be.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
"noDisplay": "&7D |&f Дысплей не знойдзены!",
1818
"settedURL": "&7D |&f Відэа было загружана!",
1919
"invalidURL": "&7D |&f Ваша спасылка несапраўдная! Калі ласка, выкарыстоўвайце сапраўдную YouTube спасылку",
20+
"displayVideoWrongTargetBlock": "&7D |&f Каб выкарыстаць гэтую каманду, глядзіце на блок дысплея!",
21+
"displayVideoNotOwner": "&7D |&f Вы не ўладальнік гэтага дысплея!",
2022
"reportTooQuickly": "&7D |&f Вы адпраўляеце справаздачы занадта хутка! Пачакайце, калі ласка, перад адпраўкай наступнай",
2123
"reportSent": "&7D |&f Справаздача была адпраўлена!",
2224
"reportFailed": "&7D |&f Не ўдалося адправіць справаздачу. Калі ласка, паспрабуйце пазней.",

spigot/src/main/resources/assets/dreamdisplays/lang/cs.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
"noDisplay": "&7D |&f Displej nebyl nalezen!",
1818
"settedURL": "&7D |&f Video bylo načteno!",
1919
"invalidURL": "&7D |&f Váš odkaz je neplatný! Použijte prosím platný YouTube odkaz",
20+
"displayVideoWrongTargetBlock": "&7D |&f Pro použití tohoto příkazu se musíte dívat na blok displeje!",
21+
"displayVideoNotOwner": "&7D |&f Nejste vlastník tohoto displeje!",
2022
"reportTooQuickly": "&7D |&f Odesíláte zprávy příliš rychle! Počkejte prosím před odesláním další",
2123
"reportSent": "&7D |&f Zpráva byla odeslána!",
2224
"reportFailed": "&7D |&f Nepodařilo se odeslat zprávu. Zkuste to prosím později.",

spigot/src/main/resources/assets/dreamdisplays/lang/de.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
"noDisplay": "&7D |&f Display wurde nicht gefunden!",
1818
"settedURL": "&7D |&f Video wurde geladen!",
1919
"invalidURL": "&7D |&f Deine URL ist ungültig! Bitte verwende einen gültigen YouTube-Link",
20+
"displayVideoWrongTargetBlock": "&7D |&f Du musst auf einen Display-Block schauen, um diesen Befehl zu nutzen!",
21+
"displayVideoNotOwner": "&7D |&f Du bist nicht der Besitzer dieses Displays!",
2022
"reportTooQuickly": "&7D |&f Du sendest Berichte zu schnell! Warte bitte, bevor du einen weiteren sendest",
2123
"reportSent": "&7D |&f Bericht wurde gesendet!",
2224
"reportFailed": "&7D |&f Fehler beim Senden des Berichts. Bitte versuchen Sie es später erneut.",

spigot/src/main/resources/assets/dreamdisplays/lang/en.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
"noDisplay": "&7D |&f Display has not been found!",
1818
"settedURL": "&7D |&f Video has been loaded!",
1919
"invalidURL": "&7D |&f Your URL is invalid! Please use a valid YouTube link",
20+
"displayVideoWrongTargetBlock": "&7D |&f You must look at a display block to use this command!",
21+
"displayVideoNotOwner": "&7D |&f You are not the owner of this display!",
2022
"reportTooQuickly": "&7D |&f You are sending reports too quickly! Please wait before sending another report",
2123
"reportSent": "&7D |&f Report has been sent!",
2224
"reportFailed": "&7D |&f Failed to send report. Please try again later.",

spigot/src/main/resources/assets/dreamdisplays/lang/he.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
"noDisplay": "&7D |&f התצוגה לא נמצאה!",
1818
"settedURL": "&7D |&f הוידאו נטען!",
1919
"invalidURL": "&7D |&f הקישור שלך לא תקין! אנא השתמש בקישור YouTube תקין",
20+
"displayVideoWrongTargetBlock": "&7D |&f כדי להשתמש בפקודה הזו, עליך להסתכל על בלוק תצוגה!",
21+
"displayVideoNotOwner": "&7D |&f אינך הבעלים של התצוגה הזו!",
2022
"reportTooQuickly": "&7D |&f אתה שולח דיווחים מהר מדי! אנא המתן לפני שליחת דיווח נוסף",
2123
"reportSent": "&7D |&f הדיווח נשלח!",
2224
"reportFailed": "&7D |&f נכשל בשליחת הדיווח. אנא נסה שוב מאוחר יותר.",

spigot/src/main/resources/assets/dreamdisplays/lang/pl.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
"noDisplay": "&7D |&f Wyświetlacz nie został znaleziony!",
1515
"settedURL": "&7D |&f Wideo załadowane!",
1616
"invalidURL": "&7D |&f Twój link jest nieprawidłowy! Proszę użyć prawidłowego linku YouTube",
17+
"displayVideoWrongTargetBlock": "&7D |&f Aby użyć tej komendy, musisz patrzeć na blok wyświetlacza!",
18+
"displayVideoNotOwner": "&7D |&f Nie jesteś właścicielem tego wyświetlacza!",
1719
"reportTooQuickly": "&7D |&f Wysyłasz raporty zbyt szybko! Poczekaj przed wysłaniem innego raportu",
1820
"reportSent": "&7D |&f Raport wysłany!",
1921
"reportFailed": "&7D |&f Nie udało się wysłać zgłoszenia. Spróbuj ponownie później.",

spigot/src/main/resources/assets/dreamdisplays/lang/ru.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
"noDisplay": "&7D |&f Дисплей не найден!",
1515
"settedURL": "&7D |&f Видео загружено!",
1616
"invalidURL": "&7D |&f Ваша ссылка недействительна! Пожалуйста, используйте действительную ссылку YouTube",
17+
"displayVideoWrongTargetBlock": "&7D |&f Чтобы использовать эту команду, смотрите на блок дисплея!",
18+
"displayVideoNotOwner": "&7D |&f Вы не владелец этого дисплея!",
1719
"reportTooQuickly": "&7D |&f Вы отправляете отчёты слишком быстро! Подождите перед отправкой другого отчёта",
1820
"reportSent": "&7D |&f Отчёт отправлен!",
1921
"reportFailed": "&7D |&f Не удалось отправить отчёт. Пожалуйста, попробуйте позже.",

spigot/src/main/resources/assets/dreamdisplays/lang/uk.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
"noDisplay": "&7D |&f Дисплей не знайдено!",
1515
"settedURL": "&7D |&f Відео завантажено!",
1616
"invalidURL": "&7D |&f Ваше посилання недійсне! Будь ласка, використовуйте дійсне посилання YouTube",
17+
"displayVideoWrongTargetBlock": "&7D |&f Щоб використати цю команду, дивіться на блок дисплея!",
18+
"displayVideoNotOwner": "&7D |&f Ви не власник цього дисплея!",
1719
"reportTooQuickly": "&7D |&f Ви надсилаєте звіти занадто швидко! Зачекайте перед надсиланням іншого звіту",
1820
"reportSent": "&7D |&f Звіт надіслано!",
1921
"reportFailed": "&7D |&f Не вдалося надіслати звіт. Будь ласка, спробуйте пізніше.",

0 commit comments

Comments
 (0)