Skip to content

Commit 5d1eff2

Browse files
finreinhardclaude
andcommitted
Add custom MOTD with Angu.li branding and production server scripts
- Add ServerListPingListener with attractive MOTD display - MOTD shows "Angu.li since 2014" and "New Challenge Update" - Easter egg in player count hover with welcome messages - Add start-production.sh for auto-updating production deployments - Add restart.sh for Paper server restart integration - Both scripts auto-download latest plugin from GitHub releases 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent ec674e7 commit 5d1eff2

File tree

4 files changed

+160
-0
lines changed

4 files changed

+160
-0
lines changed

restart.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/bash
2+
3+
# Restart script for Paper server with auto-update
4+
# This script is executed by Paper's /restart command
5+
6+
echo "=== Server Restart with Auto-Update ==="
7+
echo "$(date): Restarting server with latest plugin version..."
8+
9+
# Configuration
10+
GITHUB_REPO="AnguliNetworks/challenge-plugin"
11+
PLUGIN_DIR="plugins"
12+
PLUGIN_NAME="ChallengePlugin.jar"
13+
14+
echo "$(date): Checking for plugin updates..."
15+
16+
# Get the most recent release download URL (including prereleases)
17+
LATEST_RELEASE_URL=$(curl -s "https://api.github.com/repos/$GITHUB_REPO/releases" | \
18+
grep "browser_download_url.*\.jar" | \
19+
head -1 | \
20+
cut -d '"' -f 4)
21+
22+
if [ -n "$LATEST_RELEASE_URL" ]; then
23+
# Extract version info from URL for better logging
24+
VERSION_TAG=$(echo "$LATEST_RELEASE_URL" | grep -o 'v[^/]*' | tail -1)
25+
echo "$(date): Found release: $VERSION_TAG"
26+
echo "$(date): Downloading from: $LATEST_RELEASE_URL"
27+
28+
# Download the latest plugin JAR
29+
if curl -L -o "$PLUGIN_DIR/$PLUGIN_NAME" "$LATEST_RELEASE_URL"; then
30+
echo "$(date): Plugin updated successfully to $VERSION_TAG!"
31+
else
32+
echo "$(date): Warning: Failed to download plugin, using existing version"
33+
fi
34+
else
35+
echo "$(date): Warning: Could not find latest release, using existing plugin version"
36+
fi
37+
38+
echo "$(date): Starting server..."
39+
40+
# Start the server with production settings
41+
exec java -Xms3G -Xmx4G -jar paper-1.21.4.jar --nogui

src/main/kotlin/li/angu/challengeplugin/ChallengePluginPlugin.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import li.angu.challengeplugin.listeners.BlockDropListener
1717
import li.angu.challengeplugin.listeners.PortalListener
1818
import li.angu.challengeplugin.listeners.ExperienceBorderListener
1919
import li.angu.challengeplugin.listeners.LobbyProtectionListener
20+
import li.angu.challengeplugin.listeners.ServerListPingListener
2021
import li.angu.challengeplugin.tasks.TimerTask
2122
import li.angu.challengeplugin.utils.LanguageManager
2223

@@ -102,6 +103,7 @@ open class ChallengePluginPlugin : JavaPlugin() {
102103
server.pluginManager.registerEvents(PlayerHealthListener(this), this)
103104
server.pluginManager.registerEvents(PortalListener(this), this)
104105
server.pluginManager.registerEvents(LobbyProtectionListener(this), this)
106+
server.pluginManager.registerEvents(ServerListPingListener(this), this)
105107
server.pluginManager.registerEvents(elytraManager, this)
106108
blockDropListener = BlockDropListener(this)
107109
server.pluginManager.registerEvents(blockDropListener, this)
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
package li.angu.challengeplugin.listeners
2+
3+
import li.angu.challengeplugin.ChallengePluginPlugin
4+
import net.kyori.adventure.text.Component
5+
import net.kyori.adventure.text.format.NamedTextColor
6+
import net.kyori.adventure.text.format.TextDecoration
7+
import org.bukkit.event.EventHandler
8+
import org.bukkit.event.Listener
9+
import com.destroystokyo.paper.event.server.PaperServerListPingEvent
10+
import java.util.UUID
11+
12+
class ServerListPingListener(private val plugin: ChallengePluginPlugin) : Listener {
13+
14+
@EventHandler
15+
fun onServerListPing(event: PaperServerListPingEvent) {
16+
// Create attractive MOTD with Angu.li branding
17+
val line1 = Component.text("", NamedTextColor.GOLD, TextDecoration.BOLD)
18+
.append(Component.text("Angu.li", NamedTextColor.YELLOW, TextDecoration.BOLD))
19+
.append(Component.text("", NamedTextColor.GOLD, TextDecoration.BOLD))
20+
.append(Component.text("since 2014", NamedTextColor.GRAY, TextDecoration.BOLD))
21+
22+
val line2 = Component.text("» ", NamedTextColor.GREEN, TextDecoration.BOLD)
23+
.append(Component.text("New Challenge Update", NamedTextColor.WHITE, TextDecoration.BOLD))
24+
.append(Component.text(" «", NamedTextColor.GREEN, TextDecoration.BOLD))
25+
26+
val motd = Component.text()
27+
.append(line1)
28+
.append(Component.newline())
29+
.append(line2)
30+
.build()
31+
32+
event.motd(motd)
33+
34+
// Easter egg in player count hover - customize the listed players
35+
val listedPlayers = event.listedPlayers
36+
listedPlayers.clear()
37+
38+
// Add easter egg messages first
39+
listedPlayers.add(PaperServerListPingEvent.ListedPlayerInfo("§7─────────────────", UUID.randomUUID()))
40+
listedPlayers.add(PaperServerListPingEvent.ListedPlayerInfo("§6✦ Welcome to Angu.li! ✦", UUID.randomUUID()))
41+
listedPlayers.add(PaperServerListPingEvent.ListedPlayerInfo("§eChallenge yourself today!", UUID.randomUUID()))
42+
listedPlayers.add(PaperServerListPingEvent.ListedPlayerInfo("§7─────────────────", UUID.randomUUID()))
43+
44+
val onlinePlayers = plugin.server.onlinePlayers
45+
46+
if (onlinePlayers.isNotEmpty()) {
47+
// Add actual online players (limit to 8 to leave room for easter egg)
48+
onlinePlayers.take(8).forEach { player ->
49+
listedPlayers.add(PaperServerListPingEvent.ListedPlayerInfo(player.name, player.uniqueId))
50+
}
51+
52+
// If there are more than 8 players, show count
53+
if (onlinePlayers.size > 8) {
54+
val remaining = onlinePlayers.size - 8
55+
listedPlayers.add(PaperServerListPingEvent.ListedPlayerInfo("§7... and $remaining more", UUID.randomUUID()))
56+
}
57+
} else {
58+
// When no players are online, show special invite message
59+
listedPlayers.add(PaperServerListPingEvent.ListedPlayerInfo("§7No players online", UUID.randomUUID()))
60+
listedPlayers.add(PaperServerListPingEvent.ListedPlayerInfo("§6Be the first to join!", UUID.randomUUID()))
61+
listedPlayers.add(PaperServerListPingEvent.ListedPlayerInfo("§eStart a new challenge!", UUID.randomUUID()))
62+
}
63+
}
64+
}

start-production.sh

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/bin/bash
2+
3+
# Production Minecraft Server Startup Script
4+
# Automatically downloads latest plugin release from GitHub before starting
5+
6+
echo "=== Production Server Startup ==="
7+
echo "$(date): Starting production server with auto-update..."
8+
9+
# Configuration
10+
GITHUB_REPO="AnguliNetworks/challenge-plugin"
11+
PLUGIN_DIR="plugins"
12+
PLUGIN_NAME="ChallengePlugin.jar"
13+
14+
# Create plugins directory if it doesn't exist
15+
mkdir -p "$PLUGIN_DIR"
16+
17+
echo "$(date): Checking for latest plugin release..."
18+
19+
# Get the most recent release download URL (including prereleases)
20+
LATEST_RELEASE_URL=$(curl -s "https://api.github.com/repos/$GITHUB_REPO/releases" | \
21+
grep "browser_download_url.*\.jar" | \
22+
head -1 | \
23+
cut -d '"' -f 4)
24+
25+
if [ -n "$LATEST_RELEASE_URL" ]; then
26+
# Extract version info from URL for better logging
27+
VERSION_TAG=$(echo "$LATEST_RELEASE_URL" | grep -o 'v[^/]*' | tail -1)
28+
echo "$(date): Found release: $VERSION_TAG"
29+
echo "$(date): Downloading from: $LATEST_RELEASE_URL"
30+
31+
# Download the latest plugin JAR
32+
if curl -L -o "$PLUGIN_DIR/$PLUGIN_NAME" "$LATEST_RELEASE_URL"; then
33+
echo "$(date): Plugin updated successfully to $VERSION_TAG!"
34+
else
35+
echo "$(date): Warning: Failed to download plugin, using existing version"
36+
fi
37+
else
38+
echo "$(date): Warning: Could not find latest release, using existing plugin version"
39+
fi
40+
41+
echo "$(date): Starting Minecraft server..."
42+
43+
# Start the server with production settings
44+
nohup java -Xms3G -Xmx4G -jar paper-1.21.4.jar --nogui > minecraft.log 2>&1 &
45+
46+
# Get the process ID
47+
SERVER_PID=$!
48+
echo "$(date): Server started with PID: $SERVER_PID"
49+
echo "$SERVER_PID" > server.pid
50+
51+
echo "=== Server startup complete ==="
52+
echo "Monitor logs with: tail -f minecraft.log"
53+
echo "Stop server with: kill \$(cat server.pid)"

0 commit comments

Comments
 (0)