Simple Chat Games icon

Simple Chat Games -----

Basic interactive chat games for players



This is a very basic api for adding chat games your players can interact with.

>2K DOWNLOADS <3

Features:
It comes with 4 default question types that can be disabled through config. These are:
- Letters in the alphabet questions.
- Random letter sequences that need to be copied (Case sensitive)
- Simple math questions
- Scrambled text (defined in config) that needs to be decoded:
upload_2019-2-15_22-21-52.png
the answer being 'flint and steel' in this case

Basic rewards:
- Giving the winner money (requires Vault)
- executing commands (e.g. 'give %player% minecraft:diamond 3')

Note: This is not a stand alone plugin even though it comes with 4 default question types. The plugin itself only has support for basic rewards (e.g. money and commands).

Commands:
/chatgames current - shows current question, answer and duration
/chatgames leaderboard - shows top 10 scores if available
/chatgames list - shows all loaded question generators
/chatgames reload - reloads the plugin
/chatgames reset [player] - resets all scores/the player's score
/chatgames skip - skips the current question
/chatgames toggle - Toggles whether or not you receive chat game announcements
/chatgames version - shows the plugin's version

Permissions:
chatgames.admin - most /chatgames commands
chatgames.admin.reload - /chatgames reload
chatgames.admin.reset - /chatgames reset [player]
chatgames.leaderboard - /chatgames leaderboard
chatgames.blacklist - never get chat games
chatgames.whitelist - always get chat games

API:
Code (Java):
public class ExampleQuestion extends ChatGameGenerator {
    // You need to extend ChatGameGenerator (the generator automatically registers itself, so only create one instance)
    private static final String ALPHABET = "abcdefghijklmnopqrstuvwxyz" ;
    // Required in later versions
    public ExampleQuestion (Plugin plugin ) {
        super (plugin ) ;
    }
    // #getNewQuestion() is called every time this generator gets to ask a question
    @Override
    public Question getNewQuestion ( ) {
        // You return a new Question object containing the question and the answer a player has to type (and if that answer is case sensitive)
        // In this example you have to answer what character is at the given position in the alphabet
        int index = new Random ( ). nextInt (ALPHABET. length ( ) ) ;
        return new Question ( ) {
            @Override
            public String getAnswer ( ) {
                return Character. toString (ALPHABET. charAt (index ) ) ;
            }
            @Override
            public boolean isCaseSensitive ( ) {
                return false ;
            }
            @Override
            public String getQuestion ( ) {
                String message = "what's the %index% letter in the alphabet" ;
                return message. replace ( "%index%", (index + 1 ) + (index < 3 ? (index == 0 ? "st" : (index == 1 ? "nd" : "rd" ) ) : "th" ) ) ;
            }
            @Override
            public String getMessage ( ) {
                return "&7Answer &e%question% &7to get rewards!" ;
            }
        } ;
    }
    // A generator needs a #getIdentifier() method as of update 6.0
    @Override
    public String getName ( ) {
        return "Alphabet" ;
    }
}
Code (Java):
// Note that this event is asynchronous as of update 4.0 because it's called by an AsyncPlayerChatEvent listener
@EventHandler
public void onWin (AsyncChatGameWinEvent event ) {
    Player winner = event. getPlayer ( ) ;
    winner. getInventory ( ). addItem ( new ItemStack (Material. DIAMOND ) ) ;
    event. setWinMessage ( "&aCongratulations! You won a diamond" ) ;
}
Code (Text):
// The script has to return a JSON object with the required members
// Put this script in the ChatGames\scripts directory
function getQuestion() {
    return {
        answer: "true",
        caseSensitive: false,
        question: "this is a lie",
        message: "&7Is '&e%question%&7' a paradox?"
    };
}
getQuestion();
Resource Information
Author:
----------
Total Downloads: 6,829
First Release: Feb 15, 2019
Last Update: Feb 11, 2021
Category: ---------------
All-Time Rating:
19 ratings
Version -----
Released: --------------------
Downloads: ------
Version Rating:
----------------------
-- ratings