-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
72 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/main/java/net/thenextlvl/tweaks/command/server/MotdCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package net.thenextlvl.tweaks.command.server; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import net.kyori.adventure.text.minimessage.MiniMessage; | ||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder; | ||
import net.thenextlvl.tweaks.TweaksPlugin; | ||
import net.thenextlvl.tweaks.command.api.CommandInfo; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.command.Command; | ||
import org.bukkit.command.CommandExecutor; | ||
import org.bukkit.command.CommandSender; | ||
|
||
@CommandInfo( | ||
name = "motd", | ||
permission = "tweaks.command.motd", | ||
description = "change the motd of the server", | ||
usage = "/motd [message]" | ||
) | ||
@RequiredArgsConstructor | ||
public class MotdCommand implements CommandExecutor { | ||
private final TweaksPlugin plugin; | ||
|
||
@Override | ||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { | ||
var message = String.join(" ", args); | ||
var motd = MiniMessage.miniMessage().deserialize(message); | ||
plugin.bundle().sendMessage(sender, "motd.changed", Placeholder.component("motd", motd)); | ||
plugin.config().serverConfig().motd(message); | ||
plugin.configFile().save(); | ||
Bukkit.motd(motd); | ||
return true; | ||
} | ||
} |
20 changes: 16 additions & 4 deletions
20
src/main/java/net/thenextlvl/tweaks/config/ServerConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,21 @@ | ||
package net.thenextlvl.tweaks.config; | ||
|
||
import com.google.gson.annotations.SerializedName; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
import lombok.experimental.Accessors; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public record ServerConfig( | ||
@SerializedName("enable-lobby-command") boolean enableLobbyCommand, | ||
@SerializedName("lobby-server-name") String lobbyServerName | ||
) { | ||
@Setter | ||
@Getter | ||
@AllArgsConstructor | ||
@Accessors(fluent = true) | ||
public class ServerConfig { | ||
@SerializedName("enable-lobby-command") | ||
private final boolean enableLobbyCommand; | ||
@SerializedName("lobby-server-name") | ||
private final String lobbyServerName; | ||
@SerializedName("motd") | ||
private @Nullable String motd; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters