From fbe7cf21c13d31f6fc49c038822cba04da8b9c26 Mon Sep 17 00:00:00 2001 From: Darkness Date: Mon, 12 Jun 2023 19:31:26 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A7=D0=A2=D0=9E=D0=9E=D0=9E=D0=9E=D0=9E?= =?UTF-8?q?=D0=9E=20=D0=92=D0=9E=D0=97=D0=9C=D0=9E=D0=96=D0=9D=D0=9E=D0=A1?= =?UTF-8?q?=D0=A2=D0=AC=20=D0=9E=D0=A2=D0=9C=D0=95=D0=9D=D0=98=D0=A2=D0=AC?= =?UTF-8?q?=20=D0=92=D0=9E=D0=A2=D0=95=D0=9A=D0=98=D0=9A=3F!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../darkdustry/commands/ClientCommands.java | 13 ++++++-- .../java/darkdustry/components/Icons.java | 3 +- .../darkdustry/features/votes/VoteKick.java | 9 ++++-- .../darkdustry/features/votes/VoteLoad.java | 4 +-- .../darkdustry/features/votes/VoteRtv.java | 4 +-- .../darkdustry/features/votes/VoteSave.java | 4 +-- .../darkdustry/features/votes/VoteVnw.java | 4 +-- .../darkdustry/listeners/NetHandlers.java | 8 ++--- .../resources/bundles/bundle_en.properties | 31 ++++++++++--------- .../resources/bundles/bundle_ru.properties | 21 +++++++------ 10 files changed, 58 insertions(+), 43 deletions(-) diff --git a/src/main/java/darkdustry/commands/ClientCommands.java b/src/main/java/darkdustry/commands/ClientCommands.java index f9ad4f59..a8e46337 100644 --- a/src/main/java/darkdustry/commands/ClientCommands.java +++ b/src/main/java/darkdustry/commands/ClientCommands.java @@ -56,9 +56,16 @@ public static void load() { }); register("vote", (args, player) -> { - if (notVoting(player, voteKick) - || alreadyVoted(player, voteKick) - || invalidVoteTarget(player, voteKick.target)) return; + if (notVoting(player, voteKick)) return; + + if (args[0].equalsIgnoreCase("c") || args[0].equalsIgnoreCase("cancel")) { + if (notAdmin(player)) return; + + voteKick.cancel(player); + return; + } + + if (alreadyVoted(player, voteKick) || invalidVoteTarget(player, voteKick.target)) return; int sign = voteChoice(args[0]); if (invalidVoteSign(player, sign)) return; diff --git a/src/main/java/darkdustry/components/Icons.java b/src/main/java/darkdustry/components/Icons.java index 804267cf..62eb80cb 100644 --- a/src/main/java/darkdustry/components/Icons.java +++ b/src/main/java/darkdustry/components/Icons.java @@ -20,7 +20,8 @@ public static void load() { icons.put(values[1], String.valueOf((char) Integer.parseInt(values[0]))); } - Structs.each(team -> team.emoji = icons.get(team.name, ""), Team.baseTeams); + for (var team : Team.baseTeams) + team.emoji = icons.get(team.name, ""); DarkdustryPlugin.info("Loaded @ content icons.", icons.size); }, e -> DarkdustryPlugin.error("Unable to fetch content icons from GitHub. Check your internet connection.")); diff --git a/src/main/java/darkdustry/features/votes/VoteKick.java b/src/main/java/darkdustry/features/votes/VoteKick.java index 4b0b57fb..2b9554a1 100644 --- a/src/main/java/darkdustry/features/votes/VoteKick.java +++ b/src/main/java/darkdustry/features/votes/VoteKick.java @@ -36,14 +36,19 @@ public void left(Player player) { @Override public void success() { stop(); - Bundle.send("commands.votekick.passed", target.coloredName(), MILLISECONDS.toMinutes(kickDuration), reason); + Bundle.send("commands.votekick.success", target.coloredName(), MILLISECONDS.toMinutes(kickDuration), reason); Admins.kickReason(target, kickDuration, reason, "kick.vote-kicked", player.coloredName()).kick(kickDuration); } @Override public void fail() { stop(); - Bundle.send("commands.votekick.failed", target.coloredName(), reason); + Bundle.send("commands.votekick.fail", target.coloredName(), reason); + } + + public void cancel(Player admin) { + stop(); + Bundle.send("commands.votekick.cancel", admin.coloredName(), target.coloredName(), reason); } @Override diff --git a/src/main/java/darkdustry/features/votes/VoteLoad.java b/src/main/java/darkdustry/features/votes/VoteLoad.java index 74feb112..478e6dd7 100644 --- a/src/main/java/darkdustry/features/votes/VoteLoad.java +++ b/src/main/java/darkdustry/features/votes/VoteLoad.java @@ -32,13 +32,13 @@ public void left(Player player) { @Override public void success() { stop(); - Bundle.send("commands.loadsave.passed", file.nameWithoutExtension(), mapLoadDelay); + Bundle.send("commands.loadsave.success", file.nameWithoutExtension(), mapLoadDelay); Timer.schedule(() -> reloadWorld(() -> SaveIO.load(file)), mapLoadDelay); } @Override public void fail() { stop(); - Bundle.send("commands.loadsave.failed", file.nameWithoutExtension()); + Bundle.send("commands.loadsave.fail", file.nameWithoutExtension()); } } \ No newline at end of file diff --git a/src/main/java/darkdustry/features/votes/VoteRtv.java b/src/main/java/darkdustry/features/votes/VoteRtv.java index 70596ff2..edf67ed9 100644 --- a/src/main/java/darkdustry/features/votes/VoteRtv.java +++ b/src/main/java/darkdustry/features/votes/VoteRtv.java @@ -32,13 +32,13 @@ public void left(Player player) { @Override public void success() { stop(); - Bundle.send("commands.rtv.passed", map.name(), mapLoadDelay); + Bundle.send("commands.rtv.success", map.name(), mapLoadDelay); Timer.schedule(() -> reloadWorld(() -> world.loadMap(map, map.applyRules(state.rules.mode()))), mapLoadDelay); } @Override public void fail() { stop(); - Bundle.send("commands.rtv.failed", map.name()); + Bundle.send("commands.rtv.fail", map.name()); } } \ No newline at end of file diff --git a/src/main/java/darkdustry/features/votes/VoteSave.java b/src/main/java/darkdustry/features/votes/VoteSave.java index b4ced005..3e062a24 100644 --- a/src/main/java/darkdustry/features/votes/VoteSave.java +++ b/src/main/java/darkdustry/features/votes/VoteSave.java @@ -28,13 +28,13 @@ public void left(Player player) { @Override public void success() { stop(); - Bundle.send("commands.savemap.passed", file.name()); + Bundle.send("commands.savemap.success", file.name()); SaveIO.save(file); } @Override public void fail() { stop(); - Bundle.send("commands.savemap.failed", file.name()); + Bundle.send("commands.savemap.fail", file.name()); } } \ No newline at end of file diff --git a/src/main/java/darkdustry/features/votes/VoteVnw.java b/src/main/java/darkdustry/features/votes/VoteVnw.java index 2474fe25..bea1a6c8 100644 --- a/src/main/java/darkdustry/features/votes/VoteVnw.java +++ b/src/main/java/darkdustry/features/votes/VoteVnw.java @@ -28,13 +28,13 @@ public void left(Player player) { @Override public void success() { stop(); - Bundle.send("commands.vnw.passed", waves); + Bundle.send("commands.vnw.success", waves); for (int i = 0; i < waves; i++) logic.runWave(); } @Override public void fail() { stop(); - Bundle.send("commands.vnw.failed", waves); + Bundle.send("commands.vnw.fail", waves); } } \ No newline at end of file diff --git a/src/main/java/darkdustry/listeners/NetHandlers.java b/src/main/java/darkdustry/listeners/NetHandlers.java index c281fff1..e8f9e6b0 100644 --- a/src/main/java/darkdustry/listeners/NetHandlers.java +++ b/src/main/java/darkdustry/listeners/NetHandlers.java @@ -138,14 +138,14 @@ public static void connect(NetConnection con, ConnectPacket packet) { } public static void adminRequest(NetConnection con, AdminRequestCallPacket packet) { - Player admin = con.player, target = packet.other; - var action = packet.action; + var admin = con.player; + var target = packet.other; if (notAdmin(admin) || target == null || (target.admin && target != admin)) return; - Events.fire(new AdminRequestEvent(admin, target, action)); + Events.fire(new AdminRequestEvent(admin, target, packet.action)); - switch (action) { + switch (packet.action) { case kick -> MenuHandler.showKickMenu(admin, target); case ban -> MenuHandler.showBanMenu(admin, target); case trace -> { diff --git a/src/main/resources/bundles/bundle_en.properties b/src/main/resources/bundles/bundle_en.properties index 969fb641..06bcb5a3 100644 --- a/src/main/resources/bundles/bundle_en.properties +++ b/src/main/resources/bundles/bundle_en.properties @@ -77,10 +77,11 @@ commands.votekick.player-is-you = [scarlet]⚠ You can't start voting to kick yo commands.votekick.player-is-admin = [scarlet]⚠ You can't start voting to kick an admin. commands.votekick.player-is-enemy = [scarlet]⚠ You can't start voting to kick a player from another team. -commands.votekick.left = {0}[lightgray] left. His vote for kicking a player was cancelled. ([accent]{1}[]/[accent]{2}[]) +commands.votekick.left = {0}[lightgray] left. His vote for kicking a player was removed. ([accent]{1}[]/[accent]{2}[]) commands.votekick.vote = {0}[lightgray] voted to kick {1}[lightgray] for [orange]{2}[lightgray]. ([accent]{3}[]/[accent]{4}[])\n[lightgray]Type [orange]/vote [] to vote. -commands.votekick.passed = [#6ced7d]Vote passed. {0}[#6ced7d] was kicked for [orange]{1}[] minutes for [orange]{2}[#6ced7d]. -commands.votekick.failed = [scarlet]Vote failed. Not enough votes to kick {0}[scarlet] for [orange]{1}[scarlet]. +commands.votekick.success = [#6ced7d] Vote passed. {0}[#6ced7d] was kicked for [accent]{1}[] minutes for [accent]{2}[#6ced7d]. +commands.votekick.fail = [scarlet] Vote failed. Not enough votes to kick {0}[scarlet] for [orange]{1}[scarlet]. +commands.votekick.cancel = [accent]\uE837 Admin {0}[accent] canceled the vote to kick {1}[accent] for [orange]{2}[accent]. commands.vote.description = Vote to kick a player. commands.vote.params = @@ -97,31 +98,31 @@ commands.login.fail = [scarlet] Your request was denied. How unfortunate. commands.rtv.description = Vote to change the map. commands.rtv.params = [map...] -commands.rtv.left = {0}[lightgray] left. His vote to change the current map was cancelled. ([accent]{1}[]/[accent]{2}[]) +commands.rtv.left = {0}[lightgray] left. His vote to change the current map was removed. ([accent]{1}[]/[accent]{2}[]) commands.rtv.vote = {0}[lightgray] voted to change the current map to [orange]{1}[lightgray]. ([accent]{2}[]/[accent]{3}[])\nType [orange]y[] or [orange]n[] to vote. -commands.rtv.passed = [#6ced7d]Vote passed. Map [accent]{0}[#6ced7d] will be loaded in [accent]{1}[] seconds... -commands.rtv.failed = [scarlet]Vote failed. Not enough votes to change the current map to [orange]{0}[]. +commands.rtv.success = [#6ced7d] Vote passed. Map [accent]{0}[#6ced7d] will be loaded in [accent]{1}[] seconds... +commands.rtv.fail = [scarlet] Vote failed. Not enough votes to change the current map to [orange]{0}[]. commands.vnw.description = Vote to skip some waves. commands.vnw.params = [amount] -commands.vnw.left = {0}[lightgray] left. His vote to skip waves was cancelled. ([accent]{1}[]/[accent]{2}[]) +commands.vnw.left = {0}[lightgray] left. His vote to skip waves was removed. ([accent]{1}[]/[accent]{2}[]) commands.vnw.vote = {0}[lightgray] voted to skip [orange]{1}[lightgray] waves. ([accent]{2}[]/[accent]{3}[])\nType [orange]y[] or [orange]n[] to vote. -commands.vnw.passed = [#6ced7d]Vote passed. Skipping [accent]{0}[] waves... -commands.vnw.failed = [scarlet]Vote failed. Not enough votes to skip [orange]{0}[] waves. +commands.vnw.success = [#6ced7d] Vote passed. Skipping [accent]{0}[] waves... +commands.vnw.fail = [scarlet] Vote failed. Not enough votes to skip [orange]{0}[] waves. commands.savemap.description = Vote to save the current map. commands.savemap.params = -commands.savemap.left = {0}[lightgray] left. His vote to save the current game was cancelled. ([accent]{1}[]/[accent]{2}[]) +commands.savemap.left = {0}[lightgray] left. His vote to save the current game was removed. ([accent]{1}[]/[accent]{2}[]) commands.savemap.vote = {0}[lightgray] voted to save the current game to [orange]{1}[lightgray]. ([accent]{2}[]/[accent]{3}[])\nType [orange]y[] or [orange]n[] to vote. -commands.savemap.passed = [#6ced7d]Vote passed. Saving the current game to [accent]{0}[]... -commands.savemap.failed = [scarlet]Vote failed. Not enough votes to save the current game to [orange]{0}[]. +commands.savemap.success = [#6ced7d] Vote passed. Saving the current game to [accent]{0}[]... +commands.savemap.fail = [scarlet] Vote failed. Not enough votes to save the current game to [orange]{0}[]. commands.loadsave.description = Vote to load a save. commands.loadsave.params = -commands.loadsave.left = {0}[lightgray] left. His vote to load the save was cancelled. ([accent]{1}[]/[accent]{2}[]) +commands.loadsave.left = {0}[lightgray] left. His vote to load the save was removed. ([accent]{1}[]/[accent]{2}[]) commands.loadsave.vote = {0}[lightgray] voted to load the save [orange]{1}[lightgray]. ([accent]{2}[]/[accent]{3}[])\nType [orange]y[] or [orange]n[] to vote. -commands.loadsave.passed = [#6ced7d]Vote passed. Save [accent]{0}[] will be loaded in [accent]{1}[] seconds... -commands.loadsave.failed = [scarlet]Vote failed. Not enough votes to load the save [orange]{0}[]. +commands.loadsave.success = [#6ced7d] Vote passed. Save [accent]{0}[] will be loaded in [accent]{1}[] seconds... +commands.loadsave.fail = [scarlet] Vote failed. Not enough votes to load the save [orange]{0}[]. commands.artv.description = Force a gameover. commands.artv.params = [map...] diff --git a/src/main/resources/bundles/bundle_ru.properties b/src/main/resources/bundles/bundle_ru.properties index 5d2ae5f5..be4419a4 100644 --- a/src/main/resources/bundles/bundle_ru.properties +++ b/src/main/resources/bundles/bundle_ru.properties @@ -79,8 +79,9 @@ commands.votekick.player-is-enemy = [scarlet]⚠ Ты не можешь нача commands.votekick.left = {0}[lightgray] вышел с сервера. Его голос за кик игрока был отменен. ([accent]{1}[]/[accent]{2}[]) commands.votekick.vote = {0}[lightgray] проголосовал за кик {1}[lightgray] по причине [orange]{2}[lightgray]. ([accent]{3}[]/[accent]{4}[])\n[lightgray]Напиши [orange]/vote [], чтобы проголосовать. -commands.votekick.passed = [#6ced7d]Голосование завершено успешно. {0}[#6ced7d] выгнан на [accent]{1}[] минут по причине [accent]{2}[#6ced7d]. -commands.votekick.failed = [scarlet]Голосование провалилось. Не хватило голосов, чтобы выгнать {0}[scarlet] по причине [orange]{1}[scarlet]. +commands.votekick.success = [#6ced7d] Голосование завершено успешно. {0}[#6ced7d] выгнан на [accent]{1}[] минут по причине [accent]{2}[#6ced7d]. +commands.votekick.fail = [scarlet] Голосование провалилось. Не хватило голосов, чтобы выгнать {0}[scarlet] по причине [orange]{1}[scarlet]. +commands.votekick.cancel = [accent]\uE837 Админ {0}[accent] отменил голосование за кик {1}[accent] по причине [orange]{2}[accent]. commands.vote.description = Проголосовать за кик игрока. commands.vote.params = @@ -99,29 +100,29 @@ commands.rtv.description = Проголосовать за пропуск кар commands.rtv.params = [карта...] commands.rtv.left = {0}[lightgray] вышел с сервера. Его голос за смену карты был отменен. ([accent]{1}[]/[accent]{2}[]) commands.rtv.vote = {0}[lightgray] проголосовал за смену текущей карты на [orange]{1}[lightgray]. ([accent]{2}[]/[accent]{3}[])\nНапишите [orange]y[] или [orange]n[], чтобы проголосовать. -commands.rtv.passed = [#6ced7d]Голосование завершено успешно. Карта [accent]{0}[#6ced7d] будет загружена через [accent]{1}[] секунд... -commands.rtv.failed = [scarlet]Голосование провалилось. Не хватило голосов, чтобы изменить текущую карту на [orange]{0}[scarlet]. +commands.rtv.success = [#6ced7d] Голосование завершено успешно. Карта [accent]{0}[#6ced7d] будет загружена через [accent]{1}[] секунд... +commands.rtv.fail = [scarlet] Голосование провалилось. Не хватило голосов, чтобы изменить текущую карту на [orange]{0}[scarlet]. commands.vnw.description = Проголосовать за пропуск нескольких волн. commands.vnw.params = [количество] commands.vnw.left = {0}[lightgray] вышел с сервера. Его голос за пропуск волн был отменен. ([accent]{1}[]/[accent]{2}[]) commands.vnw.vote = {0}[lightgray] проголосовал за пропуск [orange]{1}[] волн. ([accent]{2}[]/[accent]{3}[])\nНапишите [orange]y[] или [orange]n[], чтобы проголосовать. -commands.vnw.passed = [#6ced7d]Голосование завершено успешно. Пропускаю [accent]{0}[] волн... -commands.vnw.failed = [scarlet]Голосование провалилось. Не хватило голосов, чтобы пропустить [orange]{0}[] волн. +commands.vnw.success = [#6ced7d] Голосование завершено успешно. Пропускаю [accent]{0}[] волн... +commands.vnw.fail = [scarlet] Голосование провалилось. Не хватило голосов, чтобы пропустить [orange]{0}[] волн. commands.savemap.description = Проголосовать за сохранение текущей карты. commands.savemap.params = <файл> commands.savemap.left = {0}[lightgray] вышел с сервера. Его голос за сохранение текущей игры был отменен. ([accent]{1}[]/[accent]{2}[]) commands.savemap.vote = {0}[lightgray] проголосовал за сохранение текущей игры в [orange]{1}[lightgray]. ([accent]{2}[]/[accent]{3}[])\nНапишите [orange]y[] или [orange]n[], чтобы проголосовать. -commands.savemap.passed = [#6ced7d]Голосование завершено успешно. Сохраняю текущую игры в [accent]{0}[]... -commands.savemap.failed = [scarlet]Голосование провалилось. Не хватило голосов, чтобы сохранить текущую игру в [orange]{0}[]. +commands.savemap.success = [#6ced7d] Голосование завершено успешно. Сохраняю текущую игры в [accent]{0}[]... +commands.savemap.fail = [scarlet] Голосование провалилось. Не хватило голосов, чтобы сохранить текущую игру в [orange]{0}[]. commands.loadsave.description = Проголосовать за загрузку сохранения. commands.loadsave.params = <файл> commands.loadsave.left = {0}[lightgray] вышел с сервера. Его голос за загрузку сохранения был отменен. ([accent]{1}[]/[accent]{2}[]) commands.loadsave.vote = {0}[lightgray] проголосовал за загрузку сохранения [orange]{1}[lightgray]. ([accent]{2}[]/[accent]{3}[])\nНапишите [orange]y[] или [orange]n[], чтобы проголосовать. -commands.loadsave.passed = [#6ced7d]Голосование завершено успешно. Сохранение [accent]{0}[] будет загружено через [accent]{1}[] секунд... -commands.loadsave.failed = [scarlet]Голосование провалилось. Не хватило голосов, чтобы загрузить сохранение [orange]{0}[]. +commands.loadsave.success = [#6ced7d] Голосование завершено успешно. Сохранение [accent]{0}[] будет загружено через [accent]{1}[] секунд... +commands.loadsave.fail = [scarlet] Голосование провалилось. Не хватило голосов, чтобы загрузить сохранение [orange]{0}[]. commands.artv.description = Принудительно завершить игру. commands.artv.params = [карта...]