senpaisensei_606
๐Ÿ“Ž 1 file 1,619 chars
๐Ÿ“„
pasted-code-1777925101554.txt
txt 76 lines
โ–ถ
Create a Minecraft plugin for Paper API (versions 1.21โ€“1.21.11) using Java.


plugin name: Cmds-TheSensei
Author name: SenpaiSensei
author team: RHK

๐Ÿ“Œ Plugin Concept:

The plugin tracks specific player commands and sends detailed logs to a Discord channel using a webhook URL.

โš™๏ธ Features:

Monitor only these commands:

gamemode, gm, gS, give, xp, level, ban, ipban, op, deop,
mute, unmute, invsee, enchant, endersee, kill, tp,
tpa, tpahere, kick
When any player executes one of these commands:
Capture:
Player name
UUID
Full command used (including arguments)
Timestamp (formatted, e.g. yyyy-MM-dd HH:mm:ss)
Send this data to a Discord webhook as a formatted message (JSON POST request)
๐Ÿ“‚ Config Requirements:

Create a config.yml with:

webhook-url: "YOUR_DISCORD_WEBHOOK_URL"

tracked-commands:
  - gamemode
  - gm
  - gS
  - give
  - xp
  - level
  - ban
  - ipban
  - op
  - deop
  - mute
  - unmute
  - invsee
  - enchant
  - endersee
  - kill
  - tp
  - tpa
  - tpahere
  - kick
Server owners must be able to:
Add/remove commands
Modify the list without recompiling
๐Ÿง  Technical Requirements:
Use Paper API event listeners (PlayerCommandPreprocessEvent)
Async webhook sending (to avoid blocking server thread)
Clean plugin structure:
Main class
Config manager
Webhook utility class
Handle edge cases:
Ignore commands not in config
Prevent console commands from being logged (only players)
Use proper plugin.yml setup
๐Ÿ’ฌ Discord Message Format:

Example:

๐Ÿ“Œ Command Used

๐Ÿ‘ค Player: Notch
๐Ÿ†” UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
โŒจ๏ธ Command: /gamemode creative {Player_name}
โฐ Time: 2026-05-05 14:32:10
Kodari AI
KodariMay 4 at 8:06 pm 6,858 (v2)

Iโ€™ll create a command tracking plugin that logs specific player commands to Discord via webhook.

CmdsTheSensei
Tracks specific player commands and logs them to Discord via webhook. Monitors administrative and gameplay commands including gamemode, op, ban, tp, and more. Features configurable command tracking, async webhook delivery, and detailed logging with player info, UUID, and timestamps.

Plan

  • Main plugin class with config manager initialization

  • ConfigManager for handling webhook URL and tracked commands list

  • CommandListener using PlayerCommandPreprocessEvent (players only)

  • WebhookUtil for async Discord webhook POST requests with formatted embeds

  • Default config.yml with all specified commands

Created CmdsTheSensei plugin with Discord webhook command logging. The plugin monitors player commands from a configurable list and sends detailed logs (player name, UUID, command, timestamp) to Discord asynchronously. Config allows easy command list modification without recompiling.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
7 240
src/main/java/com/rhk/cmdsthesensei/CmdsTheSensei.java
package com.rhk.cmdsthesensei;

import com.rhk.cmdsthesensei.listener.CommandListener;
import com.rhk.cmdsthesensei.manager.ConfigManager;
import org.bukkit.plugin.java.JavaPlugin;

public class CmdsTheSensei extends JavaPlugin {
    private ConfigManager configManager;
    
    @Override
    public void onEnable() {
        saveDefaultConfig();
        
        this.configManager = new ConfigManager(this);
        
        getServer().getPluginManager().registerEvents(new CommandListener(this, configManager), this);
        
        getLogger().info("CmdsTheSensei enabled - tracking player commands");
    }
    
    @Override
    public void onDisable() {
        getLogger().info("CmdsTheSensei disabled");
    }
    
    public ConfigManager getConfigManager() {
        return configManager;
    }
}