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:
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:
Adding new question generators
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";
}
}Custom rewards
// 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");
}JavaScript generators
// 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();Similar projects
Plugin →Let Me Despawn
Improves performance by tweaking mob despawn rules. Say bye to pesky unintentional persistent mobs.
26.2MSueta
JourneyMap
Real-time map used for mapping in-game or your browser as you explore.
14.7MSueta
Emotecraft
Create your own emotes in Minecraft.
7.9MSueta
Simple Tpa
A simple tpa plugin which sends requests
5.4MSueta
Common Network
Forge and Fabric Unified Networking Solution
4.7MSueta
Set Home
A lightweight plugin for players to set their homes.
3.8MSueta