Skip to content

Commit

Permalink
ЧТОООООО ВОЗМОЖНОСТЬ ОТМЕНИТЬ ВОТЕКИК?!
Browse files Browse the repository at this point in the history
  • Loading branch information
Darkness committed Jun 12, 2023
1 parent 3334b51 commit fbe7cf2
Show file tree
Hide file tree
Showing 10 changed files with 58 additions and 43 deletions.
13 changes: 10 additions & 3 deletions src/main/java/darkdustry/commands/ClientCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/darkdustry/components/Icons.java
Original file line number Diff line number Diff line change
Expand Up @@ -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."));
Expand Down
9 changes: 7 additions & 2 deletions src/main/java/darkdustry/features/votes/VoteKick.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/darkdustry/features/votes/VoteLoad.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
4 changes: 2 additions & 2 deletions src/main/java/darkdustry/features/votes/VoteRtv.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
4 changes: 2 additions & 2 deletions src/main/java/darkdustry/features/votes/VoteSave.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
4 changes: 2 additions & 2 deletions src/main/java/darkdustry/features/votes/VoteVnw.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
8 changes: 4 additions & 4 deletions src/main/java/darkdustry/listeners/NetHandlers.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 -> {
Expand Down
31 changes: 16 additions & 15 deletions src/main/resources/bundles/bundle_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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 <y/n>[] 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 = <y/n>
Expand All @@ -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 = <file>
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 = <file>
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...]
Expand Down
21 changes: 11 additions & 10 deletions src/main/resources/bundles/bundle_ru.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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 <y/n>[], чтобы проголосовать.
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 = <y/n>
Expand All @@ -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 = [карта...]
Expand Down

0 comments on commit fbe7cf2

Please sign in to comment.