Skip to content

Commit b5a57e6

Browse files
committed
improved reaction
1 parent 6a03627 commit b5a57e6

File tree

9 files changed

+115
-8
lines changed

9 files changed

+115
-8
lines changed

DeepslateMC/build.gradle

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
plugins {
2+
id 'java'
3+
id("xyz.jpenilla.run-paper") version "2.3.1"
4+
}
5+
6+
group = 'de.pascalpex'
7+
version = '1.21.8'
8+
9+
repositories {
10+
mavenCentral()
11+
maven {
12+
name = "spigotmc-repo"
13+
url = "https://hub.spigotmc.org/nexus/content/repositories/snapshots/"
14+
}
15+
}
16+
17+
dependencies {
18+
compileOnly("org.spigotmc:spigot-api:1.21.8-R0.1-SNAPSHOT")
19+
}
20+
21+
tasks {
22+
runServer {
23+
// Configure the Minecraft version for our task.
24+
// This is the only required configuration besides applying the plugin.
25+
// Your plugin's jar (or shadowJar if present) will be used automatically.
26+
minecraftVersion("1.21")
27+
}
28+
}
29+
30+
def targetJavaVersion = 21
31+
java {
32+
def javaVersion = JavaVersion.toVersion(targetJavaVersion)
33+
sourceCompatibility = javaVersion
34+
targetCompatibility = javaVersion
35+
if (JavaVersion.current() < javaVersion) {
36+
toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
37+
}
38+
}
39+
40+
tasks.withType(JavaCompile).configureEach {
41+
options.encoding = 'UTF-8'
42+
43+
if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
44+
options.release.set(targetJavaVersion)
45+
}
46+
}
47+
48+
processResources {
49+
def props = [version: version]
50+
inputs.properties props
51+
filteringCharset 'UTF-8'
52+
filesMatching('plugin.yml') {
53+
expand props
54+
}
55+
}

DeepslateMC/gradle.properties

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip

DeepslateMC/settings.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rootProject.name = 'DeepslateMC'
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package de.pascalpex.deepslateMC;
2+
3+
import org.bukkit.plugin.java.JavaPlugin;
4+
5+
public final class DeepslateMC extends JavaPlugin {
6+
7+
@Override
8+
public void onEnable() {
9+
// Plugin startup logic
10+
11+
}
12+
13+
@Override
14+
public void onDisable() {
15+
// Plugin shutdown logic
16+
}
17+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
name: DeepslateMC
2+
version: '1.21.8'
3+
main: de.pascalpex.deepslateMC.DeepslateMC
4+
api-version: '1.21'

deepslateMC-server/src/main/java/de/pascalpex/deepslatemc/files/Config.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,11 @@ public static void toggleMaintenanceMode() {
100100
config.set(MAINTENANCE_ENABLED.key, !getMaintenanceMode());
101101
save();
102102
}
103-
public static String getNormalMotd() {
104-
return config.getString(MOTD_NORMAL.key);
103+
public static List<String> getMaintenanceMotd() {
104+
return config.getStringList(MAINTENANCE_MOTD.key);
105105
}
106-
public static String getMaintenanceMotd() {
107-
return config.getString(MOTD_MAINTENANCE.key);
106+
public static boolean useCustomMaintenanceMotd() {
107+
return config.getBoolean(MAINTENANCE_USE_CUSTOM_MOTD.key);
108108
}
109109
public static boolean getSpawnOnJoin() {
110110
return config.getBoolean(SPAWN_ON_JOIN.key);
@@ -189,5 +189,4 @@ public static Map<String, String> getServerLinks() {
189189
config.getConfigurationSection(SERVER_LINKS.key).getKeys(false).forEach(key -> serverLinks.put(key, config.getString(SERVER_LINKS.key + "." + key)));
190190
return serverLinks;
191191
}
192-
193192
}

deepslateMC-server/src/main/java/de/pascalpex/deepslatemc/files/ConfigEntry.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
package de.pascalpex.deepslatemc.files;
22

33
import net.kyori.adventure.bossbar.BossBar;
4-
54
import java.util.List;
65

76
enum ConfigEntry {
87
DISCORD_LINK("discordLink", "https://discord.gg/BGrhNnVczp"),
98
BUILDWORLD("buildworld", null),
109
MAINTENANCE_ENABLED("maintenance.enabled", false),
11-
MOTD_MAINTENANCE("maintenance.motd", "&c&lServer ist in Wartung!\n&7Wir sind bald zurück."),
12-
MOTD_NORMAL("motd.normal", "&a&lDeepSlateMC Netzwerk\n&bJoin the Adventure!"),
10+
MAINTENANCE_MOTD("maintenance.motd", List.of("&cThe server is currently under maintenance.", "&7We will be back soon!")),
11+
MAINTENANCE_USE_CUSTOM_MOTD("maintenance.useCustomMotd", true),
1312
OP_COMMAND_ACTIVE("opCommandActive", true),
1413
SPAWN_ON_JOIN("spawnOnJoin", false),
1514
SPAWN_WORLD("spawn" + ".world", null),
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package de.pascalpex.deepslatemc.util; // oder ein anderer passender package-Name
2+
3+
import de.pascalpex.deepslatemc.files.Config;
4+
import net.kyori.adventure.text.Component;
5+
import net.kyori.adventure.text.minimessage.MiniMessage;
6+
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
7+
import org.bukkit.event.EventHandler;
8+
import org.bukkit.event.Listener;
9+
import org.bukkit.event.server.ServerListPingEvent;
10+
11+
import java.util.List;
12+
13+
public class MaintenanceUtil implements Listener {
14+
15+
@EventHandler
16+
public void onServerPing(ServerListPingEvent event) {
17+
if (Config.getMaintenanceMode() && Config.useCustomMaintenanceMotd()) {
18+
List<String> motdLines = Config.getMaintenanceMotd();
19+
String motdString = String.join("\n", motdLines);
20+
21+
Component motd;
22+
if (Config.getMinimessageMotd()) {
23+
motd = MiniMessage.miniMessage().deserialize(motdString);
24+
} else {
25+
motd = LegacyComponentSerializer.legacyAmpersand().deserialize(motdString);
26+
}
27+
28+
event.motd(motd);
29+
}
30+
}
31+
}

0 commit comments

Comments
 (0)