NotGamerFoxY77
📎 1 file 4,416 chars
📄
pasted-code-1791798548214.txt
txt 123 lines
▶
Minecraft Plugin Development Prompt — APEX SMP IP GUARD

Develop a professional, production-ready Minecraft security plugin named APEX SMP IP GUARD, specifically designed for cracked Minecraft servers running in offline mode.

1. Main Objective

The primary purpose of this plugin is to prevent players from joining APEX SMP using another player's username and attempting to access their account.

Since cracked Minecraft servers allow players to use usernames without authenticating through official Microsoft/Mojang account services, the plugin must provide an additional layer of account protection through registered IP verification.

2. Registered IP Protection

When a player registers for the first time, securely store their username, server-generated offline UUID, and registered IP address.

Before allowing a returning player to proceed to authentication, verify their connecting IP against the registered IP.

If the connecting IP does not match the registered IP, immediately disconnect the player before they can enter the server or access the login system.

Display this exact message:

"You Can Only Join From Your Registered IP Address!"

Do not let unauthorized connections bypass verification through /login, /register, alternate launchers, modified clients, or repeated connection attempts.

Perform verification at the earliest suitable connection stage, before normal authentication and gameplay.

Never overwrite a registered IP simply because someone connects using the same username from a different IP.

3. Cracked Server Compatibility

Designed specifically for Paper and compatible Spigot servers operating in offline mode.

Support offline UUIDs while recognizing that usernames and offline UUIDs are not proof of genuine account ownership.

Integrate with AuthMe Reloaded or another compatible authentication plugin.

Ensure IP verification runs before the authentication plugin grants account access.

Handle usernames case-insensitively and validate username formats.

Provide clear compatibility instructions for Velocity and BungeeCord proxies.

4. Administrator Commands

Implement permission-protected commands:

/apexguard info  — View account protection status.

/apexguard setip  — Update a player's registered IP after administrator verification.

/apexguard reset  — Reset a player's IP registration.

/apexguard whitelist add  — Add an approved exception.

/apexguard whitelist remove  — Remove an exception.

/apexguard reload — Reload plugin settings.

/apexguard status — View plugin status.

Only authorized administrators may execute these commands.

5. Configuration

Provide a fully configurable config.yml with:

IP verification enabled by default.

Custom unauthorized-login message.

Strict IP matching.

Proxy support and trusted proxy configuration.

Database settings.

Security logging.

Administrator permissions.

Secure IP-change recovery options.

Optional multiple trusted IP addresses for legitimate users.

6. Database and Security

Use SQLite by default, with optional MySQL support.

Store registered IP addresses securely and restrict access to sensitive records.

Never expose registered IP addresses to regular players.

Use parameterized database queries.

Fail closed if verification cannot be completed, while providing administrators with recovery options.

Avoid race conditions, duplicate registrations, and login bypasses.

7. Important Network Considerations

Correctly identify the real connecting player's IP address.

Never trust arbitrary proxy-forwarded IP headers.

Support only properly configured and trusted proxy connections.

Ensure shared IP addresses are handled according to the configured account policy.

Do not automatically approve a new IP without verification.

8. Deliverables

Provide complete Java source code, Maven or Gradle configuration, plugin.yml, default config.yml, installation instructions, testing instructions, and a compiled plugin JAR.

The finished plugin must be thoroughly tested on an offline-mode Minecraft test server before production use.

Plugin Name: APEX SMP IP GUARD

Target Environment: Cracked Minecraft servers running offline mode.

Unauthorized Connection Message: "You Can Only Join From Your Registered IP Address!"

Primary Goal: Prevent unauthorized players from using another player's registered username to access their account on APEX SMP.
Kodari AI
KodariOct 12 at 9:57 am 1
IPGuardSecurity
IPGuardSecurity is a comprehensive Minecraft security plugin for cracked offline-mode servers that prevents account theft through IP-based verification. It intercepts player connections at the earliest stage, checking connecting IPs against securely stored registered addresses before authentication occurs. Features include SQLite/MySQL storage, strict IP matching, proxy support with trusted header validation, administrator commands for IP management and whitelist exceptions, configurable messages, and detailed security logging. The plugin integrates with AuthMe Reloaded, handles case-insensitive usernames, and fails closed on verification errors to ensure unauthorized users cannot access protected accounts.
  • Add the Paper/Spigot plugin scaffold, SQLite/MySQL storage, and HMAC-protected IP records.

  • Enforce checks before login; enroll new accounts only after successful AuthMe registration.

  • Add admin recovery commands, configuration, and setup/testing instructions.

Created the plugin scaffold, database-backed IP protection, AuthMe registration integration, admin commands, configuration, and setup/testing guide.

  • Existing registrations are checked during pre-login; mismatched IPs receive the configured message. IPs are stored as keyed hashes, not plaintext.

  • New accounts are enrolled only after AuthMe confirms a successful registration. Offline-mode usernames still don’t prove ownership, so secure first-registration procedures remain necessary.

  • Proxy trust must be enforced with secure Paper/proxy forwarding and backend firewall rules; the plugin uses Bukkit’s resolved address and does not trust forwarded headers.

  • The README includes a private-server test checklist; I haven’t run a live offline-mode server test here.

To compile and download the JAR in Kodari: click Compile in the desktop top bar (or ⋮ → Compile Project on phone), click Compile, then click Download when it succeeds.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
manifest.kod
README.md
settings.gradle
Code
12 977
src/main/java/com/apexsmp/ipguard/ApexGuardPlugin.java
package com.apexsmp.ipguard;

import org.bukkit.command.PluginCommand;
import org.bukkit.plugin.java.JavaPlugin;

import java.io.IOException;
import java.nio.file.Path;
import java.util.HashSet;
import java.util.Locale;
import java.util.Set;
import java.util.logging.Level;

public final class ApexGuardPlugin extends JavaPlugin {
    private volatile IpDatabase database;
    private IpHasher ipHasher;
    private AuthMeBridge authMeBridge;
    private Set<String> registrationCommands = Set.of("register", "reg");
    private boolean verificationEnabled;
    private boolean strictIpMatching;
    private boolean allowMultipleTrustedIps;
    private boolean logRejections;
    private String unauthorizedMessage;
    private String verificationErrorMessage;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        try {
            ipHasher = IpHasher.loadOrCreate(getDataFolder().toPath().resolve("ip-hash.key"));
        } catch (IOException exception) {
            getLogger().log(Level.SEVERE, "Could not load or create the IP-hashing key; disabling the plugin.", exception);
            getServer().getPluginManager().disablePlugin(this);
            return;
        }

        reloadGuardSettings();
        getServer().getPluginManager().registerEvents(new IpGuardListener(this), this);
        PluginCommand command = getCommand("apexguard");
        if (command == null) {
            getLogger().severe("The apexguard command is missing from plugin.yml.");
            getServer().getPluginManager().disablePlugin(this);
            return;
        }
        ApexGuardCommand executor = new ApexGuardCommand(this);
        command.setExecutor(executor);
        command.setTabCompleter(executor);
    }

    @Override
    public void onDisable() {
        IpDatabase current = database;
        database = null;
        if (current != null) {
            current.close();
        }
    }

    void reloadGuardSettings() {
        reloadConfig();
        verificationEnabled = getConfig().getBoolean("ip-verification.enabled", true);
        strictIpMatching = getConfig().getBoolean("ip-verification.strict-ip-matching", true);
        allowMultipleTrustedIps = getConfig().getBoolean("ip-verification.allow-multiple-trusted-ips", false);
        unauthorizedMessage = getConfig().getString("ip-verification.unauthorized-message",
                "You Can Only Join From Your Registered IP Address!");
        verificationErrorMessage = getConfig().getString("ip-verification.verification-error-message",
                "IP verification is unavailable. Please contact an administrator.");
        logRejections = getConfig().getBoolean("security.log-rejections", true);

        Set<String> configuredCommands = new HashSet<>();
        for (String value : getConfig().getStringList("authme.registration-commands")) {
            if (value != null && !value.isBlank()) {
                configuredCommands.add(value.toLowerCase(Locale.ROOT));
            }
        }
        registrationCommands = Set.copyOf(configuredCommands);

        IpDatabase oldDatabase = database;
        database = null;
        if (oldDatabase != null) {
            oldDatabase.close();
        }
        try {
            database = new IpDatabase(this, getConfig());
            getLogger().info("IP registration database is ready.");
        } catch (Exception exception) {
            getLogger().log(Level.SEVERE, "Could not initialize the registration database. Connections will fail closed.", exception);
        }

        authMeBridge = new AuthMeBridge(this, getConfig().getBoolean("authme.enabled", true));
        if (getConfig().getBoolean("authme.enabled", true) && !authMeBridge.isAvailable()) {
            getLogger().severe("AuthMe's registration API is unavailable. New accounts will be denied until it is available.");
        }
    }

    IpDatabase getDatabase() {
        return database;
    }

    IpHasher getIpHasher() {
        return ipHasher;
    }

    Boolean isAuthMeRegistered(String username) {
        return authMeBridge == null ? null : authMeBridge.isRegistered(username);
    }

    boolean isAuthMeAvailable() {
        return authMeBridge != null && authMeBridge.isAvailable();
    }

    boolean isRegistrationCommand(String command) {
        return registrationCommands.contains(command.toLowerCase(Locale.ROOT));
    }

    boolean isVerificationEnabled() {
        return verificationEnabled;
    }

    boolean isStrictIpMatching() {
        return strictIpMatching;
    }

    boolean allowsMultipleTrustedIps() {
        return allowMultipleTrustedIps;
    }

    String getUnauthorizedMessage() {
        return unauthorizedMessage;
    }

    String getVerificationErrorMessage() {
        return verificationErrorMessage;
    }

    boolean logsRejections() {
        return logRejections;
    }

    static boolean isValidUsername(String username) {
        return username != null && username.matches("[A-Za-z0-9_]{3,16}");
    }
}