ื“ื ื™ืืœ ื•ื™ื“ืžืื™ืจ
๐Ÿ“Ž 1 file 4,259 chars
๐Ÿ“„
pasted-code-1790529963345.txt
txt 166 lines
โ–ถ
Create a Minecraft Spigot/Paper plugin called "ChatGames".

The plugin should automatically start random chat mini-games at random times.

GENERAL SYSTEM:

* A new game should start automatically after a random delay.
* The delay must be configurable with a minimum and maximum value.
* Example:

  * Minimum delay: 5 minutes
  * Maximum delay: 15 minutes
* The plugin randomly chooses when the next game starts.
* The plugin also randomly chooses which game type will be played.
* Only one game can be active at a time.
* The reward for winning a game should normally be $25,000.
* Use Vault for the economy and make the reward configurable in config.yml.
* The first player who gives the correct answer wins.
* Announce the winner and reward in chat.
* Add cooldown protection so players cannot spam answers.
* All messages must be configurable.

CHAT GAMES:

1. Math Game
   Example:
   "CHAT GAME: What is 347 + 829?"
   The first player to type the correct answer wins $25,000.

2. Unscramble Game
   Example:
   "CHAT GAME: Unscramble this word: NEMCRAFTI"
   The first player to type "MINECRAFT" wins.

3. Fast Typing Game
   The plugin displays a random word or sentence.
   The first player to type it exactly wins.

4. Reaction Game
   The plugin displays:
   "CHAT GAME: Type '๐Ÿ•'!"
   The first player to type the required text wins.

5. Guess The Number
   The plugin secretly chooses a random number between configurable limits.
   Players try to guess it.
   The first player to guess correctly wins.

6. Trivia Game
   Ask a random Minecraft-related trivia question.
   Example:
   "CHAT GAME: Which mob explodes?"
   Players answer in chat.
   The first correct answer wins.

7. Missing Letter
   Example:
   "CHAT GAME: Complete the word: M_NCRAFT"
   Answer: MINECRAFT.

8. Highest Number
   Give players a short period to type a number.
   When the timer ends, the player with the highest valid number wins.

9. Lowest Number
   Same system as Highest Number, but the lowest valid number wins.

10. Speed Calculation
    Give a more difficult mathematical problem.
    Example:
    "CHAT GAME: (25 ร— 8) + 37 = ?"

11. Word Chain
    The plugin gives a starting letter.
    Players must type a valid word beginning with that letter.
    The first valid answer wins.

12. Minecraft Item Guess
    Give clues about a Minecraft item.
    Example:
    "CHAT GAME:

* It can be found in the Nether.
* It can be used for brewing.
* It is dropped by Blazes."
  Answer: BLAZE ROD.

RANDOMIZATION:

* Randomly select the next game type.
* Randomly select the next start time.
* Randomize questions and answers.
* Do not repeat the same question immediately.
* Allow configurable chances/weights for each game type.
* Allow administrators to disable individual game types.

COMMANDS:

/chatgame
Show information about the ChatGames plugin.

/chatgame start
Immediately start a random game.

/chatgame stop
Stop the current game.

/chatgame next
Force the next game to start.

/chatgame reload
Reload config.yml.

/chatgame stats 
Show how many ChatGames the player has won and their total winnings.

/chatgame top
Show the top ChatGames winners.

PERMISSIONS:

chatgames.admin
chatgames.stats
chatgames.top

CONFIGURATION:

Include a complete config.yml with settings such as:

* Minimum random delay
* Maximum random delay
* Default reward ($25,000)
* Game duration
* Enabled games
* Game weights
* Questions
* Answers
* Messages
* Sound effects
* Whether to announce the winner
* Whether to broadcast the reward

SOUNDS:
Use configurable Minecraft sounds when:

* A game starts
* Someone answers correctly
* Someone wins
* A game expires

IMPORTANT:

* No Skript.
* Use Vault for economy.
* Compatible with EssentialsX Economy.
* Compatible with Aternos.
* Use clean Java code.
* Include plugin.yml.
* Include config.yml.
* Include complete Java source code.
* Include all required dependencies.
* Include tab completion.
* Handle server restarts safely.
* Make sure an active game cannot create duplicate timers.
* Persist player statistics so they survive server restarts.
Kodari AI
KodariSep 27 at 5:28 pm 2
ChatGames
A Minecraft Spigot/Paper plugin that automatically runs randomized chat mini-games at configurable intervals. Features 12 distinct game types including math challenges, word unscrambling, trivia, reaction tests, and number guessing. Players compete in chat for Vault economy rewards with configurable weights, delays, and messages. Includes admin commands, persistent player statistics, leaderboards, sound effects, and full configuration support.
  1. Create the Gradle project, plugin metadata, and configurable defaults.

  2. Implement all 12 game types, timed scheduling, Vault rewards, cooldowns, commands, and tab completion.

  3. Add restart-safe player statistics and handle games/timers safely across reloads.

Created the ChatGames plugin with all 12 game types, weighted random scheduling, configurable messages and sounds, Vault rewards, admin commands with tab completion, and persistent winner statistics. Configuration, plugin metadata, and Gradle dependencies are included.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
13 1,280
src/main/java/com/kodari/chatgames/ChatGamesPlugin.java
package com.kodari.chatgames;

import com.cryptomorin.xseries.XSound;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.Map;

public class ChatGamesPlugin extends JavaPlugin {
    private Economy economy;
    private StatsManager statsManager;
    private ChatGameManager gameManager;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        RegisteredServiceProvider<Economy> registration = getServer().getServicesManager().getRegistration(Economy.class);
        if (registration == null || registration.getProvider() == null) {
            getLogger().severe("No Vault economy provider was found. Install Vault and an economy plugin such as EssentialsX Economy.");
            getServer().getPluginManager().disablePlugin(this);
            return;
        }
        economy = registration.getProvider();
        statsManager = new StatsManager(this);
        gameManager = new ChatGameManager(this, economy, statsManager);

        getServer().getPluginManager().registerEvents(new ChatGameListener(gameManager), this);
        if (getCommand("chatgame") == null) {
            getLogger().severe("The chatgame command is missing from plugin.yml.");
            getServer().getPluginManager().disablePlugin(this);
            return;
        }
        ChatGameCommand command = new ChatGameCommand(this, gameManager, statsManager);
        getCommand("chatgame").setExecutor(command);
        getCommand("chatgame").setTabCompleter(command);
        gameManager.scheduleNextGame();
    }

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

    public String message(String key, Map<String, String> placeholders) {
        String result = getConfig().getString("messages." + key, "");
        result = result.replace("%prefix%", getConfig().getString("messages.prefix", ""));
        for (Map.Entry<String, String> entry : placeholders.entrySet()) {
            result = result.replace("%" + entry.getKey() + "%", entry.getValue());
        }
        return ChatColor.translateAlternateColorCodes('&', result);
    }

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

    public void sendMessage(CommandSender sender, String key, Map<String, String> placeholders) {
        String message = message(key, placeholders);
        if (!message.isEmpty()) {
            sender.sendMessage(message);
        }
    }

    public void broadcast(String key, Map<String, String> placeholders) {
        String message = message(key, placeholders);
        if (!message.isEmpty()) {
            Bukkit.broadcastMessage(message);
        }
    }

    public void playSound(String path) {
        String soundName = getConfig().getString("sounds." + path, "");
        if (soundName == null || soundName.isBlank()) {
            return;
        }
        XSound.matchXSound(soundName).ifPresent(sound -> {
            for (Player player : Bukkit.getOnlinePlayers()) {
                sound.play(player);
            }
        });
    }

    public Economy getEconomy() {
        return economy;
    }

    public ChatGameManager getGameManager() {
        return gameManager;
    }
}