Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobwgillespie committed Nov 8, 2015
0 parents commit 70e006a
Show file tree
Hide file tree
Showing 10 changed files with 268 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.idea/
*.iml
target/
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Copyright (c) 2015 Jacob Gillespie <[email protected]>

Permission is hereby granted, free of charge, to any person ob-
taining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without restric-
tion, including without limitation the rights to use, copy, modi-
fy, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is fur-
nished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONIN-
FRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 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.
41 changes: 41 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# DiscordBridge [![Build Status](https://travis-ci.org/the-obsidian/DiscordBridge.svg?branch=master)](https://travis-ci.org/the-obsidian/DiscordBridge)

Bridges chat between Discord and Minecraft (Bukkit/Spigot).

## Installation

1. Download the [latest release](https://github.com/the-obsidian/DiscordBridge/releases) from GitHub
1. Add it to your `plugins` folder
1. Either run Bukkit/Spigot once to generate `DiscordBridge/config.yml` or create it using the guide below.
1. All done!

## Configuration

DiscordBridge has several options that can be configured in the `config.yml` file:

```yaml
settings:
server-id: '00000000'
channel: 'test'
username: 'username'
email: '[email protected]'
password: 'password'
```
* `server-id` is the ID if your Discord server. This can be found under *Server Settings > Widget > Server ID*
* `channel` is the Discord channel name you would like to bridge with your Minecraft server
* `username` is the Discord username of your bot user
* `email` is the Discord email address of your bot user
* `password` is the Discord password of your bot user

## 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)

## Upcoming Features

* Ability to customize the display format
* Deeper integration into Minecraft chat (like supporting chat channels inside Minecraft)
* A "merge accounts" function to allow Minecraft players to associate their Discord accounts with their Minecraft accounts so that usernames are properly translated
* Ability to post messages to Discord on behalf of Discord users, rather than using a bot user (hopefully after the official API is released)
122 changes: 122 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

<groupId>gg.obsidian</groupId>
<artifactId>DiscourseGroupSync</artifactId>
<version>1.0.0</version>
<description>Syncronizes user groups between Minecraft and Discourse</description>
<url>https://github.com/the-obsidian/DiscourseGroupSync</url>

<scm>
<connection>scm:git:https://github.com/the-obsidian/DiscourseGroupSync.git</connection>
<developerConnection>scm:git:https://github.com/the-obsidian/DiscourseGroupSync.git</developerConnection>
<url>https://github.com/the-obsidian/DiscourseGroupSync</url>
</scm>

<packaging>jar</packaging>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<kotlin.version>1.0.0-beta-1103</kotlin.version>
</properties>

<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.8.8-R0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<version>${kotlin.version}</version>
</dependency>
<dependency>
<groupId>com.github.wareninja</groupId>
<artifactId>discourse-api-client</artifactId>
<version>0.0.3</version>
</dependency>
<dependency>
<groupId>com.google.http-client</groupId>
<artifactId>google-http-client-gson</artifactId>
<version>1.20.0</version>
</dependency>
</dependencies>

<build>
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
<defaultGoal>clean install</defaultGoal>

<resources>
<resource>
<targetPath>.</targetPath>
<filtering>true</filtering>
<directory>${basedir}/src/main/resources</directory>
<includes>
<include>*.yml</include>
</includes>
</resource>
</resources>

<plugins>
<plugin>
<artifactId>kotlin-maven-plugin</artifactId>
<groupId>org.jetbrains.kotlin</groupId>
<version>${kotlin.version}</version>

<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<minimizeJar>true</minimizeJar>
<createDependencyReducedPom>false</createDependencyReducedPom>
<artifactSet>
<includes>
<include>org.jetbrains.kotlin:*</include>
<include>com.github.wareninja:discourse-api-client:*</include>
</includes>
</artifactSet>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
36 changes: 36 additions & 0 deletions src/main/kotlin/gg/obsidian/discoursegroupsync/Configuration.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package gg.obsidian.discoursegroupsync

import java.util.*

class Configuration(val plugin: DiscourseGroupSync) {

var DISCOURSE_URL = ""
var GROUPS: HashSet<Group> = HashSet<Group>()

fun load() {
plugin.reloadConfig()

DISCOURSE_URL = plugin.getConfig().getString("discourse-url")

if (plugin.getConfig().isList("groups")) {
for (rawDefinition in plugin.getConfig().getMapList("groups")) {
val definition = rawDefinition as Map<String, Any>
var discourseGroup: Int? = null
var minecraftGroup: String? = null

if (definition.contains("discourse") && definition.getRaw("discourse") is String) {
discourseGroup = definition["discourse"] as Int
}

if (definition.contains("minecraft")) {
minecraftGroup = definition["minecraft"] as String
}

if (discourseGroup == null || minecraftGroup == null) return

val group = Group(discourseGroup, minecraftGroup)
GROUPS.add(group)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package gg.obsidian.discoursegroupsync

import org.bukkit.event.Listener
import org.bukkit.plugin.java.JavaPlugin
import java.io.File
import java.util.*

class DiscourseGroupSync : JavaPlugin(), Listener {

val config = Configuration(this)

override fun onEnable() {
val configFile = File(dataFolder, "config.yml")
if (!configFile.exists()) {
getConfig().options().copyDefaults(true)
saveConfig()
}

config.load()

server.pluginManager.registerEvents(this, this)
}

fun getUser(username: String): List<Int> {
return ArrayList<Int>();
}
}
3 changes: 3 additions & 0 deletions src/main/kotlin/gg/obsidian/discoursegroupsync/Group.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package gg.obsidian.discoursegroupsync

data class Group(var discourseGroup: Int, var minecraftGroup: String)
3 changes: 3 additions & 0 deletions src/main/kotlin/gg/obsidian/discoursegroupsync/User.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package gg.obsidian.discoursegroupsync

data class User(val username: String, val minecraftGroups: Set<String>)
3 changes: 3 additions & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
groups:
# - discourse: 4
# minecraft: groupname
9 changes: 9 additions & 0 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: DiscourseGroupSync
version: ${project.version}
description: ${project.description}

author: Jacob Gillespie
website: ${project.url}

main: gg.obsidian.discoursegroupsync.DiscourseGroupSync

0 comments on commit 70e006a

Please sign in to comment.