Skip to content

Commit c709565

Browse files
DiamondIceNSjacobwgillespie
authored andcommitted
1.8.0
- Finished Javadoc - Cleaned up some stuff - Updated README.md
1 parent 34575bb commit c709565

23 files changed

+686
-79
lines changed

README.md

Lines changed: 58 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@ Bridges chat between Discord and Minecraft (Bukkit/Spigot).
99

1010
## Installation
1111

12-
<<Coming soon!>>
12+
13+
1. Download the latest release from GitHub
14+
2. Add it to your plugins folder
15+
3. Either run Bukkit/Spigot once to generate DiscordBridge/config.yml or create it using the guide below.
16+
4. All done!
17+
1318

1419
## Configuration
1520

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

40+
# (Optional) Define an alternate prefix for all of the bot's commands. These will work in addition to @mentions.
41+
# Will also work in Minecraft if the sender has the required permission for the command they try.
42+
# Leave blank to only allow @mentions to prefix commands
43+
command-prefix: ''
44+
3545
# (Optional) Set this value with a valid Cleverbot API key to enable chatting with Cleverbot
36-
# Look at https://www.cleverbot.com/JDA/ for more info
46+
# Look at https://www.cleverbot.com/api/ for more info
3747
cleverbot-key: ''
3848

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

62-
# Set the templates for relayed messages
63-
# %u - The sender's username
64-
# %m - The sender's message
65-
# %w - The name of the world the sender is in (Multiverse alias compatible)
66-
# %r - The death message (Death event only)
67-
# Use '&' in place of the formatting symbol to apply formatting codes.
72+
# Set the templates for various message types
73+
# %u - The username of the one who sent the message or invoked a command, if applicable
74+
# %m - The raw message that would normally display, if applicable
75+
# %w - The name of the world the sender is in
76+
# - Applicable to messages from Minecraft only
77+
# - Multiverse alias compatible
78+
# Use '&' in place of the formatting symbol to apply formatting codes to messages sent to Minecraft
6879
templates:
6980
discord:
7081
chat-message: '<**%u**> %m'
7182
player-join: '**%u** joined the server'
7283
player-leave: '**%u** left the server'
73-
player-death: '%r'
84+
player-death: '%m'
7485
server-start: 'Server started!'
7586
server-stop: 'Shutting down...'
7687
minecraft:
77-
chat-message: '[&b&lDiscord&r]<%u> %m'
88+
chat-message: '[&b&l%w&r]<%u> %m'
7889
```
7990
8091
* `token` is the access token for the Discord bot. Without this, the bot will not function at all.
@@ -91,51 +102,64 @@ templates:
91102
92103
**Templates**
93104
94-
- `%u` will be replaced with the username
95-
- `%d` will be replaced with the user's display name
105+
- `%u` will be replaced with the player/user's username
96106
- `%m` will be replaced with the message
97107
- `%w` will be replaced with the world name
98-
- `%r` will be replaced with Minecraft's standard death message
99108
- Color codes, prefixed with `&`, will be translated on the Minecraft end
100109
101110
## Features
102111
103112
* Anything said in Minecraft chat will be sent to your chosen Discord channel
104-
* Anything said in your chosen Discord channel will be sent to your Minecraft chat (with a `(discord)` suffix added to usernames)
113+
* 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
114+
* 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`)
115+
* 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`)
105116
* You can link Minecraft accounts to Discord accounts and the bot will translate display names to match where the message appears
106117
* Join / leave messages can be sent to Discord
107118
* Death messages can be sent to Discord
108119
* Server start and stop messages can be sent to Discord
109120
* All of the above messages can be toggled if you don't want them to appear
110-
* Message templates are customized
111-
* 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)
112-
* Image attachments sent in the Discord channel will relay their URLs to Minecraft
113-
* Add scripted responses for the bot to say when it detects a trigger phrase
121+
* Message templates are customizeable
122+
* 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)
123+
* Add customizeable scripted responses for the bot to say when it detects a trigger phrase
114124
* A handful of fun and shitposting commands for the full Discord Bot experience both in and out of game
115-
* Cleverbot integration - chat with the bot using `@<name>`. Works in Discord AND Minecraft!
125+
* Cleverbot integration - chat with the bot using `@<bot name>` or `/talk`. Works in Discord AND Minecraft! (requires Cleverbot API key)
116126
* 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
127+
* Command permissions affect both Minecraft slash command and Minecraft in-chat commands
117128
118129
## Permissions
119130
120-
- `discordbridge.cleverbot` - ability to talk to Cleverbot
121-
- `discordbridge.f` - ability to pay respects with /f
122-
- `discordbridge.reload` - ability to reload data and reconnect the Discord connection
123-
- `discordbridge.eightball` - ability to consult the Magic 8-Ball with /8ball
124-
- `discordbridge.rate` - ability to ask for an out-of-10 rating with /rate
125-
- `discordbridge.insult` - ability to make the bot insult something with /insult
131+
- `discordbridge.discord` - ability to use any command in of the /discord subcommand tree
132+
- `discordbridge.discord.reload` - ability to reload configs and JDA
133+
- `discordbridge.discord.listmembers` - abiliyt to receive a list of members in the Discord channel
134+
- `discordbridge.discord.linkalias` - abiliy to send a request to a Discord member to set up alias translation
135+
- `discordbridge.talk` - ability to talk to Cleverbot
136+
- `discordbridge.f` - ability to use the f command
137+
- `discordbridge.rate` - ability to use the rate command
138+
- `discordbridge.eightball` - ability to use the 8ball command
139+
- `discordbridge.insult` - ability to use the insult command
140+
- `discordbridge.choose` - ability to use the choose command
141+
- `discordbridge.roll` - ability to use the roll command
126142
127143
## Commands
128144
129-
- `/discord reload` - reloads data and reconnects to Discord
130-
- `/discord get online` - provides a list of all Discord users in the relay channel who are Online, Do Not Disturb, and Idle
131-
- `/discord get ids` - provides a list of the Discord IDs of all users in the relay channel, which is useful for...
132-
- `/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
133-
- `/f` - press F to pay respects
134-
- `/8ball <query>` - consults the Magic 8-Ball to answer your yes/no questions (messages configurable in `botmemory.yml`)
135-
- `/rate <thing to rate>` - asks the bot to rate something on a 0-10 scale
136-
- `/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!*)
145+
- `8ball <question>` - consult the Magic 8-Ball to answer your yes/no questions (messages configurable in `botmemory.yml`)
146+
- `discord reload` - refreshes the JDA connection and reloads configs
147+
- `discord linkalias` - sends a request to a specified Discord user to link aliases for username translation
148+
- `discord listmembers all` - lists all the members in the Discord relay channel
149+
- `discord listmembers online` - lists all the members in the Discord relay channel who are online along with their statuses
150+
- `discord unlinkalias ` - silently breaks an alias link with a Discord user, if one exists
151+
- `f` - press F to pay respects (messages configurable in `f.yml`)
152+
- `rate <thing to be rated>` - have the bot rate something for you (rating scale and messages configurable in `rate.yml`)
153+
- `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!*)
154+
- `choose <choiceA or choiceB || choiceC, choice D...>` - have the bot make a choice for you
155+
- `roll <sides>` - roll a die with a specified number of sides (up to 100)
156+
- `talk <message` - talk to Cleverbot!
137157
138158
## Upcoming Features
139159
160+
* Vanilla Minecraft admin commands (kick, ban, start, stop, give, etc) usable from Discord
140161
* Add support for a URL shortening service so attachment URLs aren't so flipping long
141-
* Some of the 'fun' commands that literally every Discord bot has (with matching Minecraft commands!)
162+
* Add support for relaying embeds
163+
* Make Discord responses for certain commands return in pretty embeds
164+
* More of the 'fun' commands that literally every Discord bot has (with matching Minecraft commands!)
165+
* Multiple Discord channel support?

src/main/kotlin/gg/obsidian/discordbridge/Config.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ package gg.obsidian.discordbridge
33
import gg.obsidian.discordbridge.utils.UtilFunctions.noSpace
44
import org.bukkit.ChatColor
55

6+
/**
7+
* Caches primary config information
8+
*/
69
object Config {
710

811
var SERVER_ID: String = ""
@@ -42,6 +45,10 @@ object Config {
4245
// misc
4346
var BOT_MC_USERNAME = ""
4447

48+
/**
49+
* Load values into memory from the config file
50+
* @param plugin the base Plugin object
51+
*/
4552
fun load(plugin: Plugin) {
4653
plugin.reloadConfig()
4754

src/main/kotlin/gg/obsidian/discordbridge/DataConfigAccessor.kt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ package gg.obsidian.discordbridge
2020
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2121
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2222
* SOFTWARE.
23+
*
24+
* NOTE: This code has been modified from Java to Kotlin. The functionality is largely identical.
2325
*/
2426

2527
import org.bukkit.configuration.file.FileConfiguration
@@ -29,6 +31,13 @@ import java.io.IOException
2931
import java.io.InputStreamReader
3032
import java.util.logging.Level
3133

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

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

51+
/**
52+
* Reloads the data from the config file into memory
53+
*
54+
* If the file is null, the default file from within the jar file is loaded instead
55+
*/
4256
fun reloadConfig() {
4357
try {
4458
fileConfiguration = YamlConfiguration.loadConfiguration(configFile)
@@ -59,6 +73,9 @@ class DataConfigAccessor(val plugin: Plugin, filepath: File, private val fileNam
5973
return fileConfiguration!!
6074
}
6175

76+
/**
77+
* Writes the current memory contents of the config back to file
78+
*/
6279
fun saveConfig() {
6380
if (fileConfiguration == null || configFile == null)
6481
return
@@ -71,6 +88,9 @@ class DataConfigAccessor(val plugin: Plugin, filepath: File, private val fileNam
7188
}
7289
}
7390

91+
/**
92+
* Saves the default config file within the jar to its own file, if it does not already exist
93+
*/
7494
@Suppress("unused")
7595
fun saveDefaultConfig() {
7696
if (!configFile!!.exists())

0 commit comments

Comments
 (0)