Skip to content

Commit

Permalink
1.8.0
Browse files Browse the repository at this point in the history
- Finished Javadoc

- Cleaned up some stuff

- Updated README.md
  • Loading branch information
DiamondIceNS authored and jacobwgillespie committed Apr 29, 2017
1 parent 34575bb commit c709565
Show file tree
Hide file tree
Showing 23 changed files with 686 additions and 79 deletions.
92 changes: 58 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ Bridges chat between Discord and Minecraft (Bukkit/Spigot).

## Installation

<<Coming soon!>>

1. Download the latest release from GitHub
2. Add it to your plugins folder
3. Either run Bukkit/Spigot once to generate DiscordBridge/config.yml or create it using the guide below.
4. All done!


## Configuration

Expand All @@ -32,8 +37,13 @@ username: 'DiscordBridge'
# Use '&' in place of the formatting symbol.
username-color: ''

# (Optional) Define an alternate prefix for all of the bot's commands. These will work in addition to @mentions.
# Will also work in Minecraft if the sender has the required permission for the command they try.
# Leave blank to only allow @mentions to prefix commands
command-prefix: ''

# (Optional) Set this value with a valid Cleverbot API key to enable chatting with Cleverbot
# Look at https://www.cleverbot.com/JDA/ for more info
# Look at https://www.cleverbot.com/api/ for more info
cleverbot-key: ''

# If true, prints verbose log messages to the server console for every action
Expand All @@ -59,22 +69,23 @@ if-vanished:
player-leave: false
player-death: false

# Set the templates for relayed messages
# %u - The sender's username
# %m - The sender's message
# %w - The name of the world the sender is in (Multiverse alias compatible)
# %r - The death message (Death event only)
# Use '&' in place of the formatting symbol to apply formatting codes.
# Set the templates for various message types
# %u - The username of the one who sent the message or invoked a command, if applicable
# %m - The raw message that would normally display, if applicable
# %w - The name of the world the sender is in
# - Applicable to messages from Minecraft only
# - Multiverse alias compatible
# Use '&' in place of the formatting symbol to apply formatting codes to messages sent to Minecraft
templates:
discord:
chat-message: '<**%u**> %m'
player-join: '**%u** joined the server'
player-leave: '**%u** left the server'
player-death: '%r'
player-death: '%m'
server-start: 'Server started!'
server-stop: 'Shutting down...'
minecraft:
chat-message: '[&b&lDiscord&r]<%u> %m'
chat-message: '[&b&l%w&r]<%u> %m'
```
* `token` is the access token for the Discord bot. Without this, the bot will not function at all.
Expand All @@ -91,51 +102,64 @@ templates:
**Templates**
- `%u` will be replaced with the username
- `%d` will be replaced with the user's display name
- `%u` will be replaced with the player/user's username
- `%m` will be replaced with the message
- `%w` will be replaced with the world name
- `%r` will be replaced with Minecraft's standard death message
- Color codes, prefixed with `&`, will be translated on the Minecraft end
## Features
* Anything said in Minecraft chat will be sent to your chosen Discord channel
* Anything said in your chosen Discord channel will be sent to your Minecraft chat (with a `(discord)` suffix added to usernames)
* If Multiverse-Core is installed and the `%w` tag is specified in your relay message syntax, the alias assigned to your Multiverse worlds will be displayed
* Anything said in your chosen Discord channel will be sent to your Minecraft chat (if the `%w` tag is used in your relay message syntax, Discord messages will display `Discord`)
* If Dynmap is installed, anything said over Dynmap chat will be relayed to your chosen Discord channel (if the `%w` tag is used in your relay messag syntax, Dynmap messages will display `Dynmap`)
* You can link Minecraft accounts to Discord accounts and the bot will translate display names to match where the message appears
* Join / leave messages can be sent to Discord
* Death messages can be sent to Discord
* Server start and stop messages can be sent to Discord
* All of the above messages can be toggled if you don't want them to appear
* Message templates are customized
* Prefixing usernames with `@` in the Minecraft chat will be converted to mentions in the Discord chat if the user exists (you can use their Discord display name with spaces removed, or their Minecraft username if the accounts are linked)
* Image attachments sent in the Discord channel will relay their URLs to Minecraft
* Add scripted responses for the bot to say when it detects a trigger phrase
* Message templates are customizeable
* Prefixing usernames with `@` in the Minecraft chat will be converted to tag mentions in the Discord chat if the user exists (you can use their Discord display name with spaces removed, or their Minecraft username if the accounts are linked)
* Add customizeable scripted responses for the bot to say when it detects a trigger phrase
* A handful of fun and shitposting commands for the full Discord Bot experience both in and out of game
* Cleverbot integration - chat with the bot using `@<name>`. Works in Discord AND Minecraft!
* Cleverbot integration - chat with the bot using `@<bot name>` or `/talk`. Works in Discord AND Minecraft! (requires Cleverbot API key)
* The bot can use any of its commands in any channel it can read (including DMs!) allowing it to function as a general-purpose Discord bot on the side
* Command permissions affect both Minecraft slash command and Minecraft in-chat commands
## Permissions
- `discordbridge.cleverbot` - ability to talk to Cleverbot
- `discordbridge.f` - ability to pay respects with /f
- `discordbridge.reload` - ability to reload data and reconnect the Discord connection
- `discordbridge.eightball` - ability to consult the Magic 8-Ball with /8ball
- `discordbridge.rate` - ability to ask for an out-of-10 rating with /rate
- `discordbridge.insult` - ability to make the bot insult something with /insult
- `discordbridge.discord` - ability to use any command in of the /discord subcommand tree
- `discordbridge.discord.reload` - ability to reload configs and JDA
- `discordbridge.discord.listmembers` - abiliyt to receive a list of members in the Discord channel
- `discordbridge.discord.linkalias` - abiliy to send a request to a Discord member to set up alias translation
- `discordbridge.talk` - ability to talk to Cleverbot
- `discordbridge.f` - ability to use the f command
- `discordbridge.rate` - ability to use the rate command
- `discordbridge.eightball` - ability to use the 8ball command
- `discordbridge.insult` - ability to use the insult command
- `discordbridge.choose` - ability to use the choose command
- `discordbridge.roll` - ability to use the roll command
## Commands
- `/discord reload` - reloads data and reconnects to Discord
- `/discord get online` - provides a list of all Discord users in the relay channel who are Online, Do Not Disturb, and Idle
- `/discord get ids` - provides a list of the Discord IDs of all users in the relay channel, which is useful for...
- `/discord register <discord-id>` - this command will send a DM to the corresponding user asking if that user wishes to link their Discord account with the Minecraft user who issued the command
- `/f` - press F to pay respects
- `/8ball <query>` - consults the Magic 8-Ball to answer your yes/no questions (messages configurable in `botmemory.yml`)
- `/rate <thing to rate>` - asks the bot to rate something on a 0-10 scale
- `/insult <thing to insult>` - makes the bot insult something (messages configurable in `insults.yml`) (*WARNING: The supplied insults are quite offensive! Remove permissions for this command or replace the insults if you intend to use this bot on cleaner servers!*)
- `8ball <question>` - consult the Magic 8-Ball to answer your yes/no questions (messages configurable in `botmemory.yml`)
- `discord reload` - refreshes the JDA connection and reloads configs
- `discord linkalias` - sends a request to a specified Discord user to link aliases for username translation
- `discord listmembers all` - lists all the members in the Discord relay channel
- `discord listmembers online` - lists all the members in the Discord relay channel who are online along with their statuses
- `discord unlinkalias ` - silently breaks an alias link with a Discord user, if one exists
- `f` - press F to pay respects (messages configurable in `f.yml`)
- `rate <thing to be rated>` - have the bot rate something for you (rating scale and messages configurable in `rate.yml`)
- `insult <thing to insult>` - makes the bot insult something (messages configurable in `insults.yml`) (*WARNING: The supplied insults are quite offensive! Remove permissions for this command or replace the insults if you intend to use this bot on cleaner servers!*)
- `choose <choiceA or choiceB || choiceC, choice D...>` - have the bot make a choice for you
- `roll <sides>` - roll a die with a specified number of sides (up to 100)
- `talk <message` - talk to Cleverbot!
## Upcoming Features
* Vanilla Minecraft admin commands (kick, ban, start, stop, give, etc) usable from Discord
* Add support for a URL shortening service so attachment URLs aren't so flipping long
* Some of the 'fun' commands that literally every Discord bot has (with matching Minecraft commands!)
* Add support for relaying embeds
* Make Discord responses for certain commands return in pretty embeds
* More of the 'fun' commands that literally every Discord bot has (with matching Minecraft commands!)
* Multiple Discord channel support?
7 changes: 7 additions & 0 deletions src/main/kotlin/gg/obsidian/discordbridge/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ package gg.obsidian.discordbridge
import gg.obsidian.discordbridge.utils.UtilFunctions.noSpace
import org.bukkit.ChatColor

/**
* Caches primary config information
*/
object Config {

var SERVER_ID: String = ""
Expand Down Expand Up @@ -42,6 +45,10 @@ object Config {
// misc
var BOT_MC_USERNAME = ""

/**
* Load values into memory from the config file
* @param plugin the base Plugin object
*/
fun load(plugin: Plugin) {
plugin.reloadConfig()

Expand Down
20 changes: 20 additions & 0 deletions src/main/kotlin/gg/obsidian/discordbridge/DataConfigAccessor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ package gg.obsidian.discordbridge
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* NOTE: This code has been modified from Java to Kotlin. The functionality is largely identical.
*/

import org.bukkit.configuration.file.FileConfiguration
Expand All @@ -29,6 +31,13 @@ import java.io.IOException
import java.io.InputStreamReader
import java.util.logging.Level

/**
* Acts as an interface between the plugin and a target config file
*
* @param plugin a reference to the base Plugin object
* @param filepath the path to the config file
* @param fileName the name of the config file plus its extension
*/
class DataConfigAccessor(val plugin: Plugin, filepath: File, private val fileName: String) {

private val configFile: File?
Expand All @@ -39,6 +48,11 @@ class DataConfigAccessor(val plugin: Plugin, filepath: File, private val fileNam
this.configFile = File(filepath, fileName)
}

/**
* Reloads the data from the config file into memory
*
* If the file is null, the default file from within the jar file is loaded instead
*/
fun reloadConfig() {
try {
fileConfiguration = YamlConfiguration.loadConfiguration(configFile)
Expand All @@ -59,6 +73,9 @@ class DataConfigAccessor(val plugin: Plugin, filepath: File, private val fileNam
return fileConfiguration!!
}

/**
* Writes the current memory contents of the config back to file
*/
fun saveConfig() {
if (fileConfiguration == null || configFile == null)
return
Expand All @@ -71,6 +88,9 @@ class DataConfigAccessor(val plugin: Plugin, filepath: File, private val fileNam
}
}

/**
* Saves the default config file within the jar to its own file, if it does not already exist
*/
@Suppress("unused")
fun saveDefaultConfig() {
if (!configFile!!.exists())
Expand Down
Loading

0 comments on commit c709565

Please sign in to comment.