1
mirror of https://github.com/Shiewk/SModeration.git synced 2026-04-28 05:54:16 +02:00

Internationalization support

This commit is contained in:
Shy
2025-07-30 13:37:30 +02:00
parent a17086b059
commit 2be16da939
31 changed files with 470 additions and 483 deletions
@@ -3,24 +3,23 @@ package de.shiewk.smoderation.paper.command;
import com.mojang.brigadier.Command;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.tree.LiteralCommandNode;
import de.shiewk.smoderation.paper.SModerationPaper;
import de.shiewk.smoderation.paper.command.argument.PlayerUUIDArgument;
import de.shiewk.smoderation.paper.punishments.Punishment;
import de.shiewk.smoderation.paper.punishments.PunishmentType;
import de.shiewk.smoderation.paper.util.CommandUtil;
import de.shiewk.smoderation.paper.util.PlayerUtil;
import de.shiewk.smoderation.paper.util.TimeUtil;
import io.papermc.paper.command.brigadier.CommandSourceStack;
import net.kyori.adventure.text.Component;
import org.bukkit.command.CommandSender;
import java.util.Collection;
import java.util.List;
import java.util.UUID;
import static de.shiewk.smoderation.paper.SModerationPaper.*;
import static de.shiewk.smoderation.paper.SModerationPaper.container;
import static io.papermc.paper.command.brigadier.Commands.argument;
import static io.papermc.paper.command.brigadier.Commands.literal;
import static net.kyori.adventure.text.Component.text;
import static net.kyori.adventure.text.Component.translatable;
public final class ModLogsCommand implements CommandProvider {
@@ -38,21 +37,17 @@ public final class ModLogsCommand implements CommandProvider {
CommandSender sender = context.getSource().getSender();
UUID uuid = context.getArgument("player", UUID.class);
String name = PlayerUtil.offlinePlayerName(uuid);
sender.sendMessage(CHAT_PREFIX.append(Component.text("Player ").color(PRIMARY_COLOR)
.append(Component.text(name).color(SECONDARY_COLOR))
.append(Component.text(" (%s)".formatted(uuid)).color(INACTIVE_COLOR))));
final List<Punishment> punishments = SModerationPaper.container.findAll(p -> p.to.equals(uuid) && p.isActive());
sender.sendMessage(translatable("smod.command.modlogs.heading", text(name), text(uuid.toString())));
final List<Punishment> punishments = container.findAll(p -> p.to.equals(uuid) && p.isActive());
for (Punishment punishment : punishments) {
sender.sendMessage(Component.text("- is currently ").color(PRIMARY_COLOR)
.append(Component.text(punishment.type == PunishmentType.BAN ? "banned" : "muted").color(SECONDARY_COLOR))
.append(Component.text(" until ").color(PRIMARY_COLOR))
.append(Component.text(TimeUtil.calendarTimestamp(punishment.until)).color(SECONDARY_COLOR))
.append(Component.text(" (in %s)".formatted(TimeUtil.formatTimeLong(punishment.until - System.currentTimeMillis()))).color(INACTIVE_COLOR))
.append(Component.text(". Reason: ").color(PRIMARY_COLOR))
.append(Component.text(punishment.reason).color(SECONDARY_COLOR)));
sender.sendMessage(translatable("smod.command.modlogs." + punishment.type.name().toLowerCase(),
TimeUtil.calendarTimestamp(punishment.until),
TimeUtil.formatTimeLong(punishment.until - System.currentTimeMillis()),
text(punishment.reason)
));
}
if (punishments.isEmpty()){
sender.sendMessage(Component.text("- has no punishments.").color(PRIMARY_COLOR));
sender.sendMessage(translatable("smod.command.modlogs.none"));
}
return Command.SINGLE_SUCCESS;
}