Abdullah Ahmed Ahmed
📎 1 file 9,909 chars
📄
pasted-code-1793814280187.txt
txt 317 lines
▶
# VANTAGE REBORN – COMPLETE ADVANCED MODERATION PLUGIN

Create a fully functional, professional Minecraft moderation plugin for **Vantage Reborn**, compatible with **Paper 1.21.11**.

The plugin should provide a complete punishment and moderation system suitable for a public SMP server.

Implement every feature below. Do not leave commands unfinished or create placeholder functionality.

# 1. TEMPORARY MUTE – `/tempmute`

**Usage:**
`/tempmute   `

Requirements:
- Temporarily mute the specified player.
- Prevent the player from sending messages in public chat while muted.
- Automatically remove the mute when the duration expires.
- Save mute information so it survives server restarts.
- Support offline players.

When a player gets muted, display:

`Got muted by `

Second line:

`Reason: `

- Show the mute duration and remaining time where appropriate.
- Add `/unmute ` to manually remove an active mute.

# 2. TEMPORARY BAN – `/tempban`

**Usage:**
`/tempban   `

Requirements:
- Temporarily ban the specified player.
- Automatically unban them when the duration expires.
- Save all ban information permanently in storage.
- Support offline players.
- Show the moderator, reason, and remaining duration when the player tries to join.
- Keep expired bans in punishment history.

# 3. PERMANENT BAN – `/VantageBan`

**Usage:**
`/VantageBan  `

Requirements:
- Permanently ban the specified player.
- Permanent bans must never expire automatically.
- Save permanent ban information.
- Allow moderators to remove permanent bans using `/unban `.

# 4. PROFESSIONAL CENTERED BAN SCREEN

This is VERY IMPORTANT.

Whenever a banned player tries to join Vantage Reborn, display a professional, visually centered punishment screen.

**Do NOT simply display:**
- Vantage Guard
- You are banned
- Generic Minecraft ban messages.

The ban screen must clearly show who banned the player and why.

Use this design:

§8§m━━━━━━━━━━━━━━━━━━━━

§c§lVANTAGE REBORN

§4§lYOU ARE BANNED

§fBanned by: §c§l

§fReason: §e

§fDuration: §b

§7Please contact our staff if you believe this punishment was issued incorrectly.

§8§m━━━━━━━━━━━━━━━━━━━━

### Design requirements:
- Make the entire message visually centered in the middle of the disconnect screen.
- VANTAGE REBORN must stand out at the top.
- YOU ARE BANNED must be bold and red.
- The moderator username must be clearly visible.
- The punishment reason must appear on its own line.
- Temporary bans must display the remaining duration.
- Permanent bans must display `PERMANENT`.
- Automatic warning bans must display `Vantage Reborn Warning System` as the issuer.
- Use professional Minecraft colors and bold formatting.
- Use proper spacing and blank lines.
- Never display null, unknown, or missing information.
- Make the design customizable through the configuration file.

**Technical requirement:**

Use the Paper kick/disconnect component message with proper Adventure API formatting. Paper's standard disconnect screen does not provide true horizontal text-centering, so simulate centering through spacing and formatting as closely as possible. Do not claim exact centering if the Minecraft client cannot support it.

Apply this design to ALL temporary bans, permanent bans, and automatic warning bans.

# 5. WARNING SYSTEM – `/warn`

**Usage:**
`/warn  `

Requirements:
- Give the specified player one warning.
- Save every warning with its reason, moderator, and timestamp.
- Warnings must persist even after the player gets banned or unbanned.
- Never automatically reset warnings.

### Automatic escalating punishment system

Implement this exact punishment progression:

| Warning | Automatic punishment |
|---|---|
| 1st warning | Warning only |
| 2nd warning | Warning only |
| 3rd warning | 12-hour ban |
| 4th warning | 1-day ban |
| 5th warning | 3-day ban |

Important:
- Every warning must be recorded separately.
- The 3rd warning triggers a 12-hour ban.
- The 4th warning triggers a 1-day ban.
- The 5th warning triggers a 3-day ban.
- Automatic bans must use the professional Vantage Reborn ban screen.
- Display `Vantage Reborn Warning System` as the issuer for automatic bans.
- Display the reason for the warning that triggered the ban.
- Warnings must remain saved after temporary bans expire.
- Do not reset warning counts automatically.

# 6. REMOVE WARNING – `/unwarn`

**Usage:**
`/unwarn `

Requirements:
- Remove exactly ONE active warning.
- Remove the oldest active warning first.
- Immediately update the player's warning count.
- Record which moderator removed the warning and when.
- Do not erase the player's previous punishment history.
- Do not delete other warnings.

# 7. BAN LIST – `/banlist`

Create a complete ban list.

**Usage:**
`/banlist`

Display:
- Player username.
- Permanent or temporary ban.
- Ban reason.
- Moderator who issued the ban.
- Remaining duration for temporary bans.

Requirements:
- Display all currently banned players.
- Add pagination if the list is too large.
- Automatically remove expired temporary bans from the active ban list.
- Keep expired bans in punishment history.
- Make the list clean and easy to read.

# 8. PUNISHMENT HISTORY – `/history `

**Usage:**
`/history `

Create a detailed punishment history system.

Display:
- Total active warnings.
- All previous warnings.
- Temporary mutes.
- Temporary bans.
- Permanent bans.
- Unbans.
- Unmutes.
- Removed warnings.
- Punishment reasons.
- Moderator usernames.
- Punishment dates.
- Expiration dates.
- Current punishment status.

Show whether each punishment is:
- Active
- Expired
- Removed

If the player has never received a punishment, display:

`This player has no punishment history.`

Requirements:
- History must never disappear when punishments expire.
- History must remain available after server restarts.
- Use player UUIDs to identify players correctly.

# 9. UNBAN – `/unban`

**Usage:**
`/unban `

Requirements:
- Remove active temporary bans.
- Remove permanent bans.
- Record which moderator performed the unban.
- Preserve the original ban in punishment history.
- Never reset the player's warning count.

# 10. UNMUTE – `/unmute`

**Usage:**
`/unmute `

Requirements:
- Remove an active mute.
- Allow the player to speak in chat again.
- Record which moderator performed the unmute.
- Preserve the original mute in punishment history.

# 11. PERMISSIONS AND STAFF SECURITY

Only authorized staff members should be able to use moderation commands.

Requirements:
- OP players must have access to all moderation commands.
- Players with the `sr.admin` permission/rank must have access to all moderation commands.
- Normal players must never be able to access moderation commands.
- Check permissions server-side.
- Prevent unauthorized players from accessing punishment information.
- Prevent moderators from accidentally punishing themselves.
- Provide proper permission-denied messages.

Commands requiring protection:
- `/tempmute`
- `/tempban`
- `/VantageBan`
- `/warn`
- `/unwarn`
- `/banlist`
- `/history`
- `/unban`
- `/unmute`

# 12. STORAGE AND DATA PERSISTENCE

Use SQLite for reliable permanent storage.

Store:
- Player UUIDs.
- Player usernames.
- Warning records.
- Mute records.
- Temporary ban records.
- Permanent ban records.
- Moderator UUIDs.
- Moderator usernames.
- Punishment reasons.
- Punishment timestamps.
- Expiration timestamps.
- Unban and unmute records.
- Warning removal records.

Requirements:
- All information must survive server restarts.
- Use UUIDs rather than usernames as the primary player identifier.
- Support offline players.
- Never lose punishment history.
- Handle expired punishments correctly.
- Prevent duplicate punishment records.

# 13. COMMAND FORMATTING AND GENERAL FEATURES

- Support durations such as `10m`, `30m`, `2h`, `12h`, `1d`, `3d`, and `7d`.
- Provide tab completion for player names and relevant arguments.
- Provide clear error messages.
- Validate command arguments.
- Use professional Minecraft formatting and colors.
- Make messages customizable through configuration files.
- Make all commands reliable and fully functional.

# 14. IMPORTANT DEVELOPMENT REQUIREMENTS

1. The plugin must be compatible with Paper 1.21.11.
2. Use the Adventure API for modern message formatting.
3. Use SQLite for persistent punishment storage.
4. Do not create fake commands or incomplete features.
5. Do not allow temporary bans or mutes to disappear after a restart.
6. Do not reset warnings when a player gets unbanned.
7. Do not erase punishment history when punishments expire.
8. Ensure all punishment commands work together.
9. Make the plugin lightweight and optimized.
10. Avoid unnecessary dependencies.
11. Include a complete configuration file.
12. Include proper error handling.
13. Make sure automatic warning bans do not conflict with existing bans.
14. Do not overwrite an existing active punishment without properly handling it.
15. Ensure the plugin builds successfully and provide the finished `.jar` file.

**FINAL INSTRUCTION:**

Create a complete, production-ready Vantage Reborn moderation plugin. Every command, punishment system, warning escalation, history system, ban list, and professional centered-looking ban screen must work correctly.

Do not remove or modify unrelated existing server features if this is being integrated into an existing plugin. Only add the requested functionality.
Kodari AI
KodariNov 4 at 5:51 pm 2
VantageRebornModeration
A comprehensive Paper 1.21.11 moderation plugin with temporary mutes, temporary and permanent bans, a warning system with automatic escalating punishments, and a professional centered ban screen. Features SQLite persistence, punishment history, ban list with pagination, and full staff permissions. All commands support offline players and survive server restarts.
  1. Add the Paper/Gradle project setup and configurable messages.

  2. Implement SQLite-backed punishment records, expiry, and history.

  3. Register protected commands, chat-mute handling, escalating warnings, and the formatted ban disconnect screen.

Created the Vantage Reborn Paper plugin with SQLite-backed punishment history, protected moderation commands, temporary punishment expiry, warning escalation, paginated ban lists, and a configurable Adventure ban screen. The screen uses spacing to simulate centering; Minecraft’s disconnect screen does not support exact horizontal centering.

To get the .jar:

  1. Click Compile in the top bar (on phone: ⋮ → Compile Project).

  2. Click Compile in the window.

  3. When it succeeds, click Download on the build.

Abdullah Ahmed Ahmed

yea but the colour coding not working at all it showing numbersand& and the text colour is just normal

Kodari AI
KodariNov 4 at 6:10 pm 1
  1. Trace how configured messages and ban-screen text are converted to Adventure components.

  2. Fix legacy color-code rendering while preserving the existing formatting and configuration.

Fixed: messages and the ban screen now parse the & color codes used in config.yml, so colors and formatting should render correctly instead of showing the codes. Recompile and install the updated jar.

Abdullah Ahmed Ahmed

it is now but when the player is banned and the screen it shows as banned it is a little miscentered plz fix it

Kodari AI
KodariNov 4 at 6:22 pm 1

Updated the ban screen to center each line dynamically based on its visible text width, including custom configured lines. It’s still approximate because Minecraft’s disconnect screen doesn’t support true text centering. Recompile and install the updated jar to apply it.

Abdullah Ahmed Ahmed

not alligned and make the tempmute and tempban auto go away once they are actually done like there time is completed and also when i send msg it should how many imeit is left before you get unmuted and as for tempban when they try to join it shouldshow them how many time left before they get unbanned when the that time comes that player should be unban or if it is tempmute that player should get unmute

Kodari AI
KodariNov 4 at 6:35 pm 1
  1. Correct the ban-screen alignment shown in your screenshot.

  2. Make tempmutes and tempbans expire automatically, showing remaining time in chat and on the join screen.

  • Removed the extra space-padding from the ban screen so Minecraft can center each line normally.

  • Tempmutes and tempbans now get marked expired every second; expired mutes stop blocking chat, and expired bans no longer block joins. The mute chat notice shows remaining time, and the ban screen shows the time left until the ban expires.

Recompile and install the updated jar for the changes to take effect.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
manifest.kod
Code
7 872
src/main/java/com/vantage/reborn/VantageRebornPlugin.java
package com.vantage.reborn;

import io.papermc.paper.event.player.AsyncChatEvent;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.PluginCommand;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.plugin.java.JavaPlugin;

import java.sql.SQLException;
import java.util.List;
import java.util.UUID;
import java.util.logging.Level;

public final class VantageRebornPlugin extends JavaPlugin implements Listener {
    private static final LegacyComponentSerializer LEGACY = LegacyComponentSerializer.legacyAmpersand();
    private PunishmentStore store;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        try {
            store = new PunishmentStore(this);
            store.expireDue(System.currentTimeMillis());
        } catch (SQLException exception) {
            getLogger().log(Level.SEVERE, "Could not open the punishment database", exception);
            getServer().getPluginManager().disablePlugin(this);
            return;
        }

        ModerationCommand moderationCommand = new ModerationCommand(this, store);
        for (String name : List.of("tempmute", "unmute", "tempban", "vantageban", "warn", "unwarn", "banlist", "history", "unban")) {
            PluginCommand command = getCommand(name);
            if (command == null) {
                getLogger().severe("Command is missing from plugin.yml: " + name);
                continue;
            }
            command.setExecutor(moderationCommand);
            command.setTabCompleter(moderationCommand);
        }
        getServer().getPluginManager().registerEvents(this, this);
        getServer().getScheduler().runTaskTimer(this, () -> {
            try {
                store.expireDue(System.currentTimeMillis());
            } catch (SQLException exception) {
                getLogger().log(Level.SEVERE, "Could not expire punishments", exception);
            }
        }, 20L, 20L);
    }

    @EventHandler
    public void onAsyncChat(AsyncChatEvent event) {
        try {
            long now = System.currentTimeMillis();
            store.expireDue(now);
            PunishmentStore.Punishment mute = store.activePunishment(event.getPlayer().getUniqueId(), "MUTE", now);
            if (mute == null) return;
            event.setCancelled(true);
            String notice = getConfig().getString("messages.login-muted-chat", "&cYou are muted.")
                    .replace("{reason}", mute.reason())
                    .replace("{remaining}", remaining(mute.expiresAt()));
            event.getPlayer().sendMessage(LEGACY.deserialize(notice));
        } catch (SQLException exception) {
            getLogger().log(Level.SEVERE, "Could not check a player's mute status", exception);
        }
    }

    @EventHandler
    public void onPlayerLogin(PlayerLoginEvent event) {
        try {
            long now = System.currentTimeMillis();
            store.expireDue(now);
            UUID playerId = event.getPlayer().getUniqueId();
            PunishmentStore.Punishment ban = store.activePunishment(playerId, "PERMBAN", now);
            if (ban == null) ban = store.activePunishment(playerId, "TEMPBAN", now);
            if (ban != null) event.disallow(PlayerLoginEvent.Result.KICK_BANNED, banScreen(ban));
        } catch (SQLException exception) {
            getLogger().log(Level.SEVERE, "Could not check a player's ban status", exception);
            event.disallow(PlayerLoginEvent.Result.KICK_OTHER,
                    LEGACY.deserialize("&cUnable to verify your punishment status. Please try again shortly."));
        }
    }

    Component banScreen(PunishmentStore.Punishment ban) {
        String duration = ban.expiresAt() == null ? "PERMANENT" : remaining(ban.expiresAt());
        String issuer = safe(ban.moderatorName());
        List<String> lines = getConfig().getStringList("ban-screen.lines");
        if (lines.isEmpty()) {
            lines = List.of("&8&m━━━━━━━━━━━━━━━━━━━━", "", "          &c&lVANTAGE REBORN", "",
                    "             &4&lYOU ARE BANNED", "", "   &fBanned by: &c&l{issuer}",
                    "   &fReason: &e{reason}", "   &fDuration: &b{duration}", "",
                    "&7Please contact our staff if you believe this punishment was issued incorrectly.",
                    "", "&8&m━━━━━━━━━━━━━━━━━━━━");
        }
        List<String> renderedLines = lines.stream().map(line -> line.replace("{issuer}", issuer)
                .replace("{reason}", safe(ban.reason())).replace("{duration}", duration)).toList();
        String rendered = centerBanScreen(renderedLines).stream().reduce((a, b) -> a + "\n" + b).orElse("");
        return LEGACY.deserialize(rendered);
    }

    private List<String> centerBanScreen(List<String> lines) {
        return lines.stream().map(String::stripLeading).toList();
    }

    void kickIfOnline(UUID playerId, Component reason) {
        Player player = Bukkit.getPlayer(playerId);
        if (player != null) player.kick(reason);
    }

    UUID resolvePlayerId(String name) throws SQLException {
        UUID known = store.findPlayerId(name);
        if (known != null) return known;
        OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(name);
        return offlinePlayer.getUniqueId();
    }

    String resolvePlayerName(UUID playerId, String suppliedName) {
        Player online = Bukkit.getPlayer(playerId);
        if (online != null) return online.getName();
        OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(playerId);
        String knownName = offlinePlayer.getName();
        return knownName == null || knownName.isBlank() ? suppliedName : knownName;
    }

    Component message(String text) {
        return LEGACY.deserialize(text);
    }

    String configuredMessage(String key, String fallback) {
        return getConfig().getString("messages." + key, fallback);
    }

    String remaining(Long expiresAt) {
        if (expiresAt == null) return "PERMANENT";
        long seconds = Math.max(0, (expiresAt - System.currentTimeMillis() + 999) / 1000);
        long days = seconds / 86400;
        long hours = (seconds % 86400) / 3600;
        long minutes = (seconds % 3600) / 60;
        long remainingSeconds = seconds % 60;
        StringBuilder result = new StringBuilder();
        if (days > 0) result.append(days).append("d ");
        if (hours > 0) result.append(hours).append("h ");
        if (minutes > 0) result.append(minutes).append("m ");
        if (remainingSeconds > 0 || result.isEmpty()) result.append(remainingSeconds).append('s');
        return result.toString().trim();
    }

    String safe(String value) {
        return value == null || value.isBlank() ? "Staff" : value;
    }

    PunishmentStore store() {
        return store;
    }

    @Override
    public void onDisable() {
        if (store == null) return;
        try {
            store.close();
        } catch (SQLException exception) {
            getLogger().log(Level.SEVERE, "Could not close the punishment database", exception);
        }
    }
}