This commit is contained in:
rattatwinko
2025-04-26 21:43:14 +02:00
commit c794b19531
25 changed files with 538 additions and 0 deletions

10
.idea/.gitignore generated vendored Normal file
View File

@@ -0,0 +1,10 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Environment-dependent path to Maven home directory
/mavenHomeManager.xml
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

13
.idea/compiler.xml generated Normal file
View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<annotationProcessing>
<profile name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="MOTD" />
</profile>
</annotationProcessing>
</component>
</project>

7
.idea/encodings.xml generated Normal file
View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/src/main/kotlin" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
</component>
</project>

30
.idea/jarRepositories.xml generated Normal file
View File

@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Central Repository" />
<option name="url" value="https://repo.maven.apache.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="sonatype" />
<option name="name" value="sonatype" />
<option name="url" value="https://oss.sonatype.org/content/groups/public/" />
</remote-repository>
<remote-repository>
<option name="id" value="papermc-repo" />
<option name="name" value="papermc-repo" />
<option name="url" value="https://repo.papermc.io/repository/maven-public/" />
</remote-repository>
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
</component>
</project>

6
.idea/kotlinc.xml generated Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="KotlinJpsPluginSettings">
<option name="version" value="2.2.0-Beta1" />
</component>
</project>

12
.idea/material_theme_project_new.xml generated Normal file
View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="MaterialThemeProjectNewConfig">
<option name="metadata">
<MTProjectMetadataState>
<option name="migrated" value="true" />
<option name="pristineConfig" value="false" />
<option name="userId" value="3730c89c:19672acdc5f:-7ff9" />
</MTProjectMetadataState>
</option>
</component>
</project>

14
.idea/misc.xml generated Normal file
View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_24" default="true" project-jdk-name="24" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

8
.idea/modules.xml generated Normal file
View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/MOTD.iml" filepath="$PROJECT_DIR$/MOTD.iml" />
</modules>
</component>
</project>

6
.idea/vcs.xml generated Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

13
MOTD.iml Normal file
View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<module version="4">
<component name="FacetManager">
<facet type="minecraft" name="Minecraft">
<configuration>
<autoDetectTypes>
<platformType>PAPER</platformType>
</autoDetectTypes>
<projectReimportVersion>1</projectReimportVersion>
</configuration>
</facet>
</component>
</module>

View File

@@ -0,0 +1,72 @@
<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.server_info</groupId>
<artifactId>MOTD</artifactId>
<name>MOTD</name>
<version>1.0-SNAPSHOT</version>
<build>
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
<defaultGoal>clean package</defaultGoal>
<resources>
<resource>
<filtering>true</filtering>
<directory>src/main/resources</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
<configuration>
<jvmTarget>${java.version}</jvmTarget>
</configuration>
</plugin>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>3.5.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>papermc-repo</id>
<url>https://repo.papermc.io/repository/maven-public/</url>
</repository>
<repository>
<id>sonatype</id>
<url>https://oss.sonatype.org/content/groups/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.21.5-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<kotlin.version>2.2.0-Beta1</kotlin.version>
<java.version>21</java.version>
</properties>
</project>

87
pom.xml Normal file
View File

@@ -0,0 +1,87 @@
<?xml version="1.0" encoding="UTF-8"?>
<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>org.server_info</groupId>
<artifactId>MOTD</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>MOTD</name>
<properties>
<java.version>21</java.version>
<kotlin.version>2.2.0-Beta1</kotlin.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<defaultGoal>clean package</defaultGoal>
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
<plugins>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
<configuration>
<jvmTarget>${java.version}</jvmTarget>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.5.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<repositories>
<repository>
<id>papermc-repo</id>
<url>https://repo.papermc.io/repository/maven-public/</url>
</repository>
<repository>
<id>sonatype</id>
<url>https://oss.sonatype.org/content/groups/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.21.5-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
<version>${kotlin.version}</version>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,123 @@
package org.server_info.MOTD
import org.bukkit.Bukkit
import org.bukkit.plugin.java.JavaPlugin
class MOTD : JavaPlugin() {
private var quotesTask: Int = -1
private val quotesList = ArrayList<String>()
override fun onEnable() {
// Save default config if it doesn't exist
saveDefaultConfig()
// Load quotes from config
loadQuotes()
// Register command
getCommand("motd")?.setExecutor(MOTDCommand(this))
// Schedule the MOTD update task
startQuoteTask()
logger.info("MOTD Quote Plugin enabled! Loaded ${quotesList.size} quotes.")
}
override fun onDisable() {
// Cancel the task when the plugin is disabled
if (quotesTask != -1) {
Bukkit.getScheduler().cancelTask(quotesTask)
}
logger.info("MOTD Quote Plugin disabled!")
}
private fun loadQuotes() {
// Clear existing quotes
quotesList.clear()
// Load quotes from config
val configQuotes = config.getStringList("quotes")
if (configQuotes.isNotEmpty()) {
quotesList.addAll(configQuotes)
} else {
// Add default quotes if none found in config
quotesList.add("If at first you don't succeed, then skydiving definitely isn't for you.")
quotesList.add("I told my wife she was drawing her eyebrows too high. She looked surprised.")
quotesList.add("I'm not lazy, I'm just on energy-saving mode.")
quotesList.add("I don't have a bad handwriting, I have my own font.")
quotesList.add("When life gives you lemons, squirt someone in the eye.")
// Save default quotes to config
config.set("quotes", quotesList)
saveConfig()
logger.info("No quotes found in config, created default quotes list.")
}
}
fun startQuoteTask() {
// Cancel existing task if running
if (quotesTask != -1) {
Bukkit.getScheduler().cancelTask(quotesTask)
}
// Get update interval from config (default: 60 minutes)
val intervalMinutes = config.getLong("update-interval-minutes", 60)
// Schedule repeating task
quotesTask = Bukkit.getScheduler().scheduleSyncRepeatingTask(
this,
{ updateServerMOTD() },
20L, // Initial delay (1 second)
intervalMinutes * 60 * 20L // Convert minutes to ticks (20 ticks = 1 second)
)
logger.info("MOTD update task scheduled to run every $intervalMinutes minutes.")
}
fun updateServerMOTD() {
if (quotesList.isEmpty()) {
logger.warning("No quotes available to set MOTD!")
return
}
// Get a random quote
val quote = getRandomQuote()
// Format the quote
val formattedQuote = formatMOTD(quote)
// Set the server MOTD
val server = Bukkit.getServer()
server.motd = formattedQuote
logger.info("MOTD updated: $formattedQuote")
}
fun getRandomQuote(): String {
return if (quotesList.isNotEmpty()) {
quotesList.random()
} else {
"No quotes available"
}
}
private fun formatMOTD(quote: String): String {
// Get prefix and suffix from config
val prefix = config.getString("motd-prefix", "§e§l") ?: "§e§l"
val suffix = config.getString("motd-suffix", "") ?: ""
// Trim and limit the quote length if it's too long (Minecraft has MOTD length limitations)
val maxLength = config.getInt("max-motd-length", 50)
var trimmedQuote = quote
if (trimmedQuote.length > maxLength) {
trimmedQuote = trimmedQuote.substring(0, maxLength - 3) + "..."
}
return prefix + trimmedQuote + suffix
}
fun reloadQuotes() {
reloadConfig()
loadQuotes()
}
}

View File

@@ -0,0 +1,48 @@
package org.server_info.MOTD
import org.bukkit.ChatColor
import org.bukkit.command.Command
import org.bukkit.command.CommandExecutor
import org.bukkit.command.CommandSender
class MOTDCommand(private val plugin: MOTD) : CommandExecutor {
override fun onCommand(sender: CommandSender, command: Command, label: String, args: Array<out String>): Boolean {
if (args.isEmpty()) {
// Display help
sender.sendMessage("${ChatColor.GOLD}==== MOTD Quote Plugin ====")
sender.sendMessage("${ChatColor.YELLOW}/motd refresh ${ChatColor.WHITE}- Set a new random quote")
sender.sendMessage("${ChatColor.YELLOW}/motd reload ${ChatColor.WHITE}- Reload quotes from config")
return true
}
when (args[0].lowercase()) {
"refresh" -> {
if (!sender.hasPermission("motd.refresh")) {
sender.sendMessage("${ChatColor.RED}You don't have permission to use this command.")
return true
}
sender.sendMessage("${ChatColor.YELLOW}Setting a new random quote...")
plugin.updateServerMOTD()
sender.sendMessage("${ChatColor.GREEN}MOTD has been updated!")
return true
}
"reload" -> {
if (!sender.hasPermission("motd.reload")) {
sender.sendMessage("${ChatColor.RED}You don't have permission to use this command.")
return true
}
plugin.reloadQuotes()
plugin.startQuoteTask()
sender.sendMessage("${ChatColor.GREEN}MOTD quotes reloaded from config!")
return true
}
else -> {
sender.sendMessage("${ChatColor.RED}Unknown command. Use /motd for help.")
return true
}
}
}
}

View File

@@ -0,0 +1,21 @@
# MOTD Quote Plugin Configuration
# How often to update the MOTD (in minutes)
update-interval-minutes: 60
# Maximum length for MOTD quotes
max-motd-length: 50
# Style settings
motd-prefix: "§e§l" # Gold color and bold
motd-suffix: ""
# Debug mode (shows more console output)
debug: false
# List of quotes to use for MOTD
quotes:
- "Wie heißt der Workshop? Rassismus ohne Schule"
- "What da fäck is hier passiert bitte sehr?"
- "Digga meine Yeezys!"
- "Da Sessel kommt auffi, nd owi."

View File

@@ -0,0 +1,22 @@
name: MOTD
version: 1.0-SNAPSHOT
main: org.server_info.MOTD.MOTD
api-version: 1.19
description: Sets the server MOTD to random quotes from config
author: YourName
commands:
motd:
description: Control the MOTD quote plugin
usage: /motd [refresh|reload]
permission: motd.use
aliases: [quotemotd]
permissions:
motd.use:
description: Allows using basic MOTD commands
default: true
motd.refresh:
description: Allows refreshing the MOTD quote
default: op
motd.reload:
description: Allows reloading the plugin configuration
default: op

Binary file not shown.

Binary file not shown.

21
target/classes/config.yml Normal file
View File

@@ -0,0 +1,21 @@
# MOTD Quote Plugin Configuration
# How often to update the MOTD (in minutes)
update-interval-minutes: 60
# Maximum length for MOTD quotes
max-motd-length: 50
# Style settings
motd-prefix: "§e§l" # Gold color and bold
motd-suffix: ""
# Debug mode (shows more console output)
debug: false
# List of quotes to use for MOTD
quotes:
- "Wie heißt der Workshop? Rassismus ohne Schule"
- "What da fäck is hier passiert bitte sehr?"
- "Digga meine Yeezys!"
- "Da Sessel kommt auffi, nd owi."

Binary file not shown.

Binary file not shown.

22
target/classes/plugin.yml Normal file
View File

@@ -0,0 +1,22 @@
name: MOTD
version: 1.0-SNAPSHOT
main: org.server_info.MOTD.MOTD
api-version: 1.19
description: Sets the server MOTD to random quotes from config
author: YourName
commands:
motd:
description: Control the MOTD quote plugin
usage: /motd [refresh|reload]
permission: motd.use
aliases: [quotemotd]
permissions:
motd.use:
description: Allows using basic MOTD commands
default: true
motd.refresh:
description: Allows refreshing the MOTD quote
default: op
motd.reload:
description: Allows reloading the plugin configuration
default: op

View File

@@ -0,0 +1,3 @@
artifactId=MOTD
groupId=org.server_info
version=1.0-SNAPSHOT

Binary file not shown.