Skip to content

Commit be64b78

Browse files
committed
Initial commit: Connect Notify plugin for Discord webhooks
0 parents  commit be64b78

File tree

27 files changed

+1722
-0
lines changed

27 files changed

+1722
-0
lines changed

.github/workflows/build.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
release:
9+
types: [published]
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
19+
- name: Setup Java
20+
uses: actions/setup-java@v4
21+
with:
22+
distribution: "temurin"
23+
java-version: "17"
24+
25+
- name: Setup Gradle
26+
uses: gradle/actions/setup-gradle@v4
27+
28+
- name: Build
29+
run: ./gradlew build
30+
31+
- name: Upload artifact
32+
uses: actions/upload-artifact@v4
33+
with:
34+
name: ConnectNotify
35+
path: build/libs/ConnectNotify-*.jar
36+
if-no-files-found: error
37+
38+
release:
39+
needs: build
40+
runs-on: ubuntu-latest
41+
if: github.event_name == 'release'
42+
43+
permissions:
44+
contents: write
45+
46+
steps:
47+
- name: Checkout
48+
uses: actions/checkout@v4
49+
50+
- name: Setup Java
51+
uses: actions/setup-java@v4
52+
with:
53+
distribution: "temurin"
54+
java-version: "17"
55+
56+
- name: Setup Gradle
57+
uses: gradle/actions/setup-gradle@v4
58+
59+
- name: Build with release version
60+
run: ./gradlew build -Pversion=${{ github.event.release.tag_name }}
61+
62+
- name: Upload to release
63+
uses: softprops/action-gh-release@v2
64+
with:
65+
files: build/libs/ConnectNotify-*.jar

.gitignore

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Gradle
2+
.gradle/
3+
build/
4+
!gradle/wrapper/gradle-wrapper.jar
5+
6+
# IDE
7+
.idea/
8+
*.iml
9+
*.ipr
10+
*.iws
11+
.vscode/
12+
*.code-workspace
13+
14+
# OS
15+
.DS_Store
16+
Thumbs.db
17+
18+
# Build outputs
19+
out/
20+
target/
21+
22+
# Logs
23+
*.log
24+
25+
# Local config
26+
local.properties
27+

LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
MIT License
2+
3+
Copyright (c) 2024 Minekube
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
22+

README.md

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
# Connect Notify
2+
3+
**Discord notifications for your Minekube Connect server status.**
4+
5+
Let your friends know when your local Minecraft server is up and ready to join! This plugin sends a Discord webhook message when your server starts or stops, including the Connect endpoint so players can easily connect.
6+
7+
## Features
8+
9+
- 🟢 **Online notifications** – Sends a message when your server starts
10+
- 🔴 **Offline notifications** – Sends a message when your server stops
11+
- 🔗 **Automatic endpoint** – Reads your endpoint from [Minekube Connect](https://connect.minekube.com) config
12+
- 🎨 **Rich embeds** – Beautiful Discord embed messages with customizable colors
13+
- 📢 **Multiple webhooks** – Notify multiple Discord channels or servers at once
14+
-**Zero config required** – Just paste your Discord webhook URL(s) and go!
15+
16+
## Requirements
17+
18+
- Minecraft server running Spigot, Paper, or compatible forks (1.8+)
19+
- [Minekube Connect plugin](https://connect.minekube.com/guide/connectors/plugin) installed and configured
20+
21+
## Installation
22+
23+
1. Download the latest `ConnectNotify.jar` from [Releases](https://github.com/minekube/connect-notify/releases)
24+
2. Drop it into your server's `plugins/` folder
25+
3. Start your server once to generate the config
26+
4. Edit `plugins/ConnectNotify/config.yml` and paste your Discord webhook URL
27+
5. Restart your server – done!
28+
29+
## Configuration
30+
31+
```yaml
32+
# plugins/ConnectNotify/config.yml
33+
34+
# Discord webhook notifications
35+
discord:
36+
# List of webhook URLs to send notifications to
37+
# Create one: Right-click channel > Edit Channel > Integrations > Webhooks
38+
webhooks:
39+
- 'https://discord.com/api/webhooks/...'
40+
# - 'https://discord.com/api/webhooks/...' # Add more webhooks here
41+
42+
# Bot appearance (optional)
43+
username: 'Connect Notify'
44+
avatar-url: 'https://connect.minekube.com/img/logo.png'
45+
46+
# Message settings
47+
messages:
48+
# Online message - sent when server starts
49+
online:
50+
enabled: true
51+
title: 'Server Online! 🟢'
52+
description: 'The server is now up and running.'
53+
color: '#00ff00'
54+
show-endpoint: true
55+
endpoint-text: 'Connect with: `{endpoint}`'
56+
57+
# Offline message - sent when server stops
58+
offline:
59+
enabled: true
60+
title: 'Server Offline 🔴'
61+
description: 'The server has been shut down.'
62+
color: '#ff0000'
63+
```
64+
65+
### Placeholders
66+
67+
| Placeholder | Description |
68+
| --------------- | --------------------------------------------------------------------- |
69+
| `{endpoint}` | Your Minekube Connect endpoint (e.g., `yourserver.play.minekube.net`) |
70+
| `{server-name}` | Your server name from Connect config |
71+
| `{players}` | Current online player count |
72+
| `{max-players}` | Maximum player slots |
73+
74+
## Creating a Discord Webhook
75+
76+
**Option A: Via Channel Settings (easiest)**
77+
78+
1. Right-click the channel where you want notifications
79+
2. Click **Edit Channel** → **Integrations** → **Webhooks**
80+
3. Click **New Webhook**
81+
4. Copy the **Webhook URL**
82+
83+
**Option B: Via Server Settings**
84+
85+
1. Go to **Server Settings** → **Integrations** → **Webhooks**
86+
2. Click **New Webhook**
87+
3. Select the channel for notifications
88+
4. Copy the **Webhook URL**
89+
90+
Then add the URL to `discord.webhooks` in `config.yml`.
91+
92+
> **Tip:** You can add multiple webhooks to notify different channels or servers!
93+
94+
## How It Works
95+
96+
```
97+
┌─────────────────────────────────────────────────────────────┐
98+
│ Your Minecraft Server │
99+
│ ┌─────────────────┐ ┌─────────────────────────────────┐ │
100+
│ │ Minekube Connect│───▶│ Connect Notify (reads endpoint) │ │
101+
│ │ config.yml │ └──────────────┬──────────────────┘ │
102+
│ │ endpoint: xyz │ │ │
103+
│ └─────────────────┘ │ HTTP POST │
104+
└────────────────────────────────────────┼────────────────────┘
105+
106+
┌──────────────────┐
107+
│ Discord Webhooks │
108+
│ #server-status │
109+
│ #announcements │
110+
│ ... │
111+
└──────────────────┘
112+
```
113+
114+
## Example Discord Messages
115+
116+
**Online:**
117+
118+
> ### Server Online! 🟢
119+
>
120+
> The server is now up and running.
121+
>
122+
> Connect with: `myserver.play.minekube.net`
123+
124+
**Offline:**
125+
126+
> ### Server Offline 🔴
127+
>
128+
> The server has been shut down.
129+
130+
## Troubleshooting
131+
132+
### No messages in Discord?
133+
134+
1. Check that your webhook URLs are correct under `discord.webhooks` in `config.yml`
135+
2. Make sure the webhook(s) haven't been deleted in Discord
136+
3. Check server console for error messages
137+
4. Verify Minekube Connect is loaded and has a valid endpoint
138+
139+
### Wrong endpoint showing?
140+
141+
The plugin reads from `plugins/connect/config.yml`. Make sure Connect is properly configured and your endpoint is set.
142+
143+
## Building from Source
144+
145+
```bash
146+
git clone https://github.com/minekube/connect-notify.git
147+
cd connect-notify
148+
./gradlew build
149+
```
150+
151+
The built jar will be in `build/libs/`.
152+
153+
## License
154+
155+
MIT License – See [LICENSE](LICENSE) for details.
156+
157+
## Links
158+
159+
- [Minekube Connect](https://connect.minekube.com) – Free public addresses for your Minecraft server
160+
- [Discord Webhooks Guide](https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks)
161+
- [Report Issues](https://github.com/minekube/connect-notify/issues)
162+
163+
---
164+
165+
<p align="center">
166+
Made with ❤️ by <a href="https://minekube.com">Minekube</a>
167+
</p>

build.gradle.kts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
plugins {
2+
java
3+
id("com.gradleup.shadow") apply false
4+
}
5+
6+
allprojects {
7+
group = "com.minekube.connect"
8+
version = findProperty("version")?.toString()?.takeIf { it != "unspecified" } ?: "1.0.0-SNAPSHOT"
9+
description = "Discord notifications for Minekube Connect server status"
10+
}
11+
12+
subprojects {
13+
apply(plugin = "java")
14+
15+
java {
16+
toolchain {
17+
languageVersion.set(JavaLanguageVersion.of(17))
18+
}
19+
}
20+
21+
tasks.withType<JavaCompile> {
22+
options.encoding = "UTF-8"
23+
}
24+
25+
tasks.withType<ProcessResources> {
26+
val props = mapOf(
27+
"version" to project.version,
28+
"description" to project.description
29+
)
30+
filesMatching(listOf("plugin.yml", "bungee.yml", "velocity-plugin.json")) {
31+
expand(props)
32+
}
33+
}
34+
}
35+

bukkit/build.gradle.kts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
dependencies {
2+
compileOnly(project(":common"))
3+
compileOnly("io.papermc.paper:paper-api:1.20.4-R0.1-SNAPSHOT")
4+
}
5+
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package com.minekube.connect.notify.bukkit;
2+
3+
import com.minekube.connect.notify.common.ConnectNotify;
4+
import com.minekube.connect.notify.common.ConnectNotifyPlatform;
5+
import org.bukkit.Bukkit;
6+
import org.bukkit.plugin.java.JavaPlugin;
7+
8+
import java.io.File;
9+
import java.util.logging.Logger;
10+
11+
/**
12+
* Bukkit/Spigot/Paper implementation of Connect Notify.
13+
*/
14+
public class BukkitConnectNotify extends JavaPlugin implements ConnectNotifyPlatform {
15+
16+
private ConnectNotify connectNotify;
17+
18+
@Override
19+
public void onEnable() {
20+
connectNotify = new ConnectNotify(this);
21+
connectNotify.onEnable();
22+
}
23+
24+
@Override
25+
public void onDisable() {
26+
if (connectNotify != null) {
27+
connectNotify.onDisable();
28+
}
29+
}
30+
31+
@Override
32+
public String getPlatformName() {
33+
return Bukkit.getName();
34+
}
35+
36+
// getDataFolder() and getLogger() are inherited from JavaPlugin
37+
38+
@Override
39+
public void runAsync(Runnable task) {
40+
Bukkit.getScheduler().runTaskAsynchronously(this, task);
41+
}
42+
43+
@Override
44+
public int getOnlinePlayerCount() {
45+
return Bukkit.getOnlinePlayers().size();
46+
}
47+
48+
@Override
49+
public int getMaxPlayerCount() {
50+
return Bukkit.getMaxPlayers();
51+
}
52+
}
53+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: ConnectNotify
2+
version: ${version}
3+
main: com.minekube.connect.notify.bukkit.BukkitConnectNotify
4+
api-version: '1.13'
5+
folia-supported: true
6+
description: ${description}
7+
author: Minekube
8+
website: https://connect.minekube.com
9+
softdepend:
10+
- connect
11+
- Connect
12+

bungee/build.gradle.kts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
dependencies {
2+
compileOnly(project(":common"))
3+
compileOnly("net.md-5:bungeecord-api:1.20-R0.2")
4+
}
5+

0 commit comments

Comments
 (0)