Austin Luecking

make a bukkit plugin that makes me go in creative and survival mode and the command is /trend and /trend2 and the server is bukkit and 26.2

Kodari AI
KodariSep 7 at 9:32 pm 1
TrendModeSwitcher
A Bukkit plugin for Minecraft 26.2 that provides two simple commands for switching between Creative and Survival game modes. The /trend command instantly switches the player to Creative mode, while /trend2 switches the player to Survival mode. Both commands work for any player who executes them, requiring no special permissions or arguments. The plugin listens for command execution events, validates that the command matches the expected syntax, and applies the appropriate game mode change to the player. It also sends a confirmation message to the player indicating their new mode. The implementation is lightweight, with a single command listener class that handles both commands efficiently, making it easy to install and use on any Bukkit server.

Created the Bukkit plugin with:

  • /trend — switches the player to Creative mode

  • /trend2 — switches the player to Survival mode

  • Console-use protection

  • Permission nodes:

    • trend.creative

    • trend.survival

  • Gradle build configuration and plugin.yml

Main class: com.example.trendgamemode.TrendGameModePlugin

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
4 89
src/main/java/com/example/trendgamemode/TrendGameModePlugin.java
package com.example.trendgamemode;

import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

public final class TrendGameModePlugin extends JavaPlugin implements CommandExecutor {

    @Override
    public void onEnable() {
        getCommand("trend").setExecutor(this);
        getCommand("trend2").setExecutor(this);
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (!(sender instanceof Player player)) {
            sender.sendMessage(ChatColor.RED + "Only players can use this command.");
            return true;
        }

        if (command.getName().equalsIgnoreCase("trend")) {
            player.setGameMode(GameMode.CREATIVE);
            player.sendMessage(ChatColor.GREEN + "You are now in creative mode.");
            return true;
        }

        if (command.getName().equalsIgnoreCase("trend2")) {
            player.setGameMode(GameMode.SURVIVAL);
            player.sendMessage(ChatColor.GREEN + "You are now in survival mode.");
            return true;
        }

        return false;
    }
}