Meow Misty
📎 1 file 5,344 chars
📄
pasted-code-1794736141217.txt
txt 182 lines
▶
Minecraft Paper Plugin — MTeam Freeze System

Create a Minecraft plugin called MTeam for Paper 1.21.11, using Java 21.

The plugin's primary purpose is to allow administrators to create multiple teams, assign players to them, and freeze or unfreeze every online member of a selected team simultaneously.

1. Main Command

The main command MUST be:

"/mteam"

IMPORTANT: Another plugin on my server already uses "/team". Therefore:

- Do NOT register "/team".
- Do NOT use "/team" as an alias.
- Register "/mteam" as the main command in "plugin.yml".
- All plugin commands must use "/mteam".

2. Team Management

Implement the following commands:

- "/mteam create " — Create a new team.
- "/mteam delete " — Delete an existing team.
- "/mteam add  " — Add a player to a team.
- "/mteam remove  " — Remove a player from a team.
- "/mteam list" — Display all existing teams.
- "/mteam info " — Display all members of a specific team.

Requirements:

- Multiple teams must be supported.
- A player can only belong to one team at a time.
- Team names must be unique.
- Team information must persist after server restarts.

3. Team Freeze System (Main Feature)

Implement these two commands:

Freeze:
"/mteam  freeze"

Unfreeze:
"/mteam  unfreeze"

When an administrator executes the freeze command, EVERY online player belonging to that team must be frozen simultaneously.

When frozen, players must:

- Be unable to walk in any direction.
- Be unable to jump.
- Be unable to move forwards or backwards.
- Be unable to sprint or sneak.
- Be unable to change their physical position through normal gameplay.
- Be unable to bypass freezing through normal movement abilities.

Camera and Player Interaction

Even while frozen:

- Players MUST be able to move their camera and look around.
- Players MUST be able to use chat.
- Players' health must remain unchanged.
- Players' inventories must remain unchanged.
- Players must not be kicked or disconnected.

Do not completely immobilize the player's camera.

4. Unfreeze System

When an administrator executes:

"/mteam  unfreeze"

Every online member of that team must immediately regain normal movement.

The unfreeze command must only affect the selected team, not other teams.

5. Freeze Persistence and Player Handling

Implement reliable handling for:

- Players disconnecting while frozen.
- Players reconnecting while their team is still frozen.
- Players being transferred between teams.
- Teams being deleted while frozen.
- Server restarts.
- Administrators unfreezing teams.

If a player joins a team that is currently frozen, they should automatically become frozen.

Do not leave players permanently frozen because of an error or server restart.

6. Movement Prevention Technical Requirements

Use Paper's supported event APIs.

Implement movement prevention carefully:

- Cancel player movement when their position changes.
- Allow camera rotation when the player only changes their yaw or pitch.
- Prevent jumping and other movement attempts.
- Handle teleportation and other movement bypasses appropriately.
- Avoid cancelling unrelated interactions such as chat or inventory access.

Do not use unnecessary Fabric dependencies or require a mod loader.

7. Permissions

Create the following permissions:

- "mteam.admin" — Full administrative access.
- "mteam.manage" — Create, delete, and manage teams.
- "mteam.freeze" — Freeze and unfreeze teams.
- "mteam.use" — View team information.

Only authorized administrators should be able to freeze or unfreeze teams.

8. Configurable Messages

Create a "config.yml" containing customizable messages.

Default examples:

- "&aTeam created successfully!"
- "&cThis team does not exist!"
- "&bYour team has been frozen!"
- "&aYour team has been unfrozen!"
- "&cYou cannot move while frozen!"
- "&eYou have been added to a team!"
- "&cYou have been removed from your team!"

Use Minecraft color codes and allow administrators to customize all messages.

9. Tab Completion

Implement intelligent tab completion for "/mteam".

Examples:

- "/mteam create"
- "/mteam delete "
- "/mteam add  "
- "/mteam remove  "
- "/mteam  freeze"
- "/mteam  unfreeze"

Automatically suggest existing team names and online player names where appropriate.

10. Technical Requirements

- Minecraft version: Paper 1.21.11.
- Java version: Java 21.
- Language: Java.
- Build system: Gradle.
- Main command: "/mteam".
- Plugin name: MTeam.
- No Fabric or Forge dependencies.
- No command conflicts with existing plugins.
- Clean, organized, maintainable source code.

11. Final Deliverables

Provide:

1. Complete Java source code.
2. A complete Gradle project.
3. Correct "plugin.yml".
4. Configurable "config.yml".
5. A compiled, working "MTeam.jar".
6. Installation instructions.
7. A complete list of commands and permissions.

FINAL PRIORITY

The most important feature is the ability to freeze an entire selected team simultaneously while allowing players to look around freely.

Prioritize reliability, performance, compatibility with Paper 1.21.11, and prevention of movement exploits.

Do not provide pseudocode or incomplete placeholder methods. Deliver a complete, buildable plugin project.
Kodari AI
KodariNov 15 at 8:52 am 3
MTeamFreezeSystem
A Paper plugin for Minecraft 1.21.11 that enables administrators to create and manage multiple player teams, then freeze or unfreeze all online members of a selected team simultaneously. Features persistent team storage across restarts, automatic freeze application for players joining frozen teams, and robust movement prevention that blocks walking, jumping, and sprinting while allowing full camera rotation, chat, and inventory access. Includes configurable messages, tab completion, and permission-based access control.
  • Set up the Java 21 Gradle project and register only /mteam.

  • Add persistent team management, permission-checked commands, and team/player tab completion.

  • Enforce frozen state without locking camera or chat, including reconnects, transfers, teleports, and health changes.

Created the Java 21 Gradle project for Paper 1.21.11. Team membership and frozen status persist in teams.yml; frozen players can still look around, chat, and use inventories.

Commands

  • /mteam create <teamName>

  • /mteam delete <teamName>

  • /mteam add <teamName> <player>

  • /mteam remove <teamName> <player>

  • /mteam list

  • /mteam info <teamName>

  • /mteam <teamName> freeze

  • /mteam <teamName> unfreeze

Permissions

  • mteam.admin — full access

  • mteam.manage — create, delete, add, and remove

  • mteam.freeze — freeze and unfreeze teams

  • mteam.use — list and view teams

Messages are customizable in config.yml. Only /mteam is registered; there is no /team command or alias.

Get and install the JAR

  1. On desktop, click Compile in the top bar; on phone, tap ⋮ → Compile Project.

  2. Click Compile, then Download when the build succeeds.

  3. Place the downloaded JAR in your Paper server’s plugins folder and restart the server.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
8 824
src/main/java/me/kodari/mteam/MTeamPlugin.java
package me.kodari.mteam;

import java.util.Map;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

public final class MTeamPlugin extends JavaPlugin {
    private TeamManager teamManager;
    private FreezeListener freezeListener;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        teamManager = new TeamManager(this);
        teamManager.load();
        freezeListener = new FreezeListener(this, teamManager);
        getServer().getPluginManager().registerEvents(freezeListener, this);

        MTeamCommand command = new MTeamCommand(this, teamManager, freezeListener);
        getCommand("mteam").setExecutor(command);
        getCommand("mteam").setTabCompleter(command);

        for (Player player : getServer().getOnlinePlayers()) {
            freezeListener.refreshPlayer(player, true);
        }
    }

    @Override
    public void onDisable() {
        if (teamManager != null) {
            teamManager.save();
        }
    }

    public String formatMessage(String key, Map<String, String> replacements) {
        String message = getConfig().getString("messages." + key, "&cMissing message: " + key);
        for (Map.Entry<String, String> replacement : replacements.entrySet()) {
            message = message.replace("{" + replacement.getKey() + "}", replacement.getValue());
        }
        return ChatColor.translateAlternateColorCodes('&', message);
    }

    public void sendMessage(CommandSender sender, String key) {
        sendMessage(sender, key, Map.of());
    }

    public void sendMessage(CommandSender sender, String key, Map<String, String> replacements) {
        sender.sendMessage(formatMessage(key, replacements));
    }
}