1
mirror of https://github.com/Shiewk/SModeration.git synced 2026-04-29 06:34:17 +02:00

Rework save format and punishment manager

- Punishments are now saved as JSON in files named after their targets
- Each punishment type now has its own Java class
- Each file contains a list of JSON objects that is updated every time something changes (e.g. player muted, banned or unbanned)
- Punishments have a unique ID now; if something changes, the new version is added to the list and overwrites the old version
- 'Undo' has been renamed to 'cancel'
- You can no longer mute or ban players if they are already muted or banned
This commit is contained in:
Shy
2026-04-08 16:12:01 +02:00
parent fecd21bf19
commit 823093be35
26 changed files with 795 additions and 509 deletions
@@ -4,8 +4,8 @@ import com.mojang.brigadier.Command;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.mojang.brigadier.tree.LiteralCommandNode;
import de.shiewk.smoderation.paper.SModerationPaper;
import de.shiewk.smoderation.paper.inventory.SModMenu;
import de.shiewk.smoderation.paper.punishments.PunishmentManager;
import de.shiewk.smoderation.paper.util.CommandUtil;
import io.papermc.paper.command.brigadier.CommandSourceStack;
import org.bukkit.entity.Player;
@@ -18,6 +18,12 @@ import static io.papermc.paper.command.brigadier.Commands.literal;
@SuppressWarnings("UnstableApiUsage") // Paper Brigadier API
public final class SModCommand implements CommandProvider {
private final PunishmentManager punishmentManager;
public SModCommand(PunishmentManager punishmentManager) {
this.punishmentManager = punishmentManager;
}
@Override
public LiteralCommandNode<CommandSourceStack> getCommandNode() {
return literal("smod")
@@ -28,7 +34,7 @@ public final class SModCommand implements CommandProvider {
private int openMenu(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
Player player = CommandUtil.getExecutingPlayer(context.getSource());
new SModMenu(player, SModerationPaper.container).open();
new SModMenu(player, punishmentManager).open();
return Command.SINGLE_SUCCESS;
}