- * This class holds the main server configuration, including server name, description, - * and server binding details such as address, port, and token. It uses the Configurate + * This class holds the main server configuration, including server name, + * description, + * and server binding details such as address, port, and token. It uses the + * Configurate * library for serialization and supports comments for each field. */ @ConfigSerializable @@ -21,14 +23,14 @@ public class Config { private String description = "A minecraft server"; @Setting("bind") - private ServerSection server = new ServerSection(); + private BindSection server = new BindSection(); -@ConfigSerializable - /** - * Represents the server binding section of the configuration. - * Contains address, port, and bind token for the server. - */ - public static class ServerSection { + @ConfigSerializable + /** + * Represents the server binding section of the configuration. + * Contains address, port, and bind token for the server. + */ + public static class BindSection { @Setting("address") @Comment("Server Address") @@ -42,53 +44,59 @@ public class Config { @Comment("Server Bind Token") private String bindToken = "get token from `mineroo.online/resources/servers` page!"; -/** - * Gets the server address. - * @return the server address - */ - public String getAddress() { + /** + * Gets the server address. + * + * @return the server address + */ + public String getAddress() { return address; } -/** - * Gets the server port. - * @return the server port - */ - public Integer getPort() { + /** + * Gets the server port. + * + * @return the server port + */ + public Integer getPort() { return port; } -/** - * Gets the server bind token. - * @return the bind token - */ - public String getBindToken() { + /** + * Gets the server bind token. + * + * @return the bind token + */ + public String getBindToken() { return bindToken; } } -/** - * Gets the server bind name. - * @return the server name - */ - public String getServerName() { + /** + * Gets the server bind name. + * + * @return the server name + */ + public String getServerName() { return serverName; } -/** - * Gets the server bind description. - * @return the server description - */ - public String getDescription() { + /** + * Gets the server bind description. + * + * @return the server description + */ + public String getDescription() { return description; } -/** - * Gets the server binding section. - * @return the server section - */ - public ServerSection getServer() { + /** + * Gets the server binding section. + * + * @return the server section + */ + public BindSection getBind() { return server; } diff --git a/velocity/src/main/java/online/mineroo/velocity/MinerooPlugin.java b/velocity/src/main/java/online/mineroo/velocity/MinerooCore.java similarity index 94% rename from velocity/src/main/java/online/mineroo/velocity/MinerooPlugin.java rename to velocity/src/main/java/online/mineroo/velocity/MinerooCore.java index a37f920..6d9edac 100644 --- a/velocity/src/main/java/online/mineroo/velocity/MinerooPlugin.java +++ b/velocity/src/main/java/online/mineroo/velocity/MinerooCore.java @@ -12,9 +12,9 @@ import com.velocitypowered.api.plugin.Plugin; import com.velocitypowered.api.plugin.annotation.DataDirectory; import com.velocitypowered.api.proxy.ProxyServer; +import online.mineroo.common.MessageManager; import online.mineroo.velocity.commands.MainCommand; import online.mineroo.velocity.listeners.BindListener; -import online.mineroo.velocity.utils.MessageManager; import java.io.IOException; import java.nio.file.Files; @@ -28,7 +28,7 @@ import org.spongepowered.configurate.yaml.YamlConfigurationLoader; @Plugin(id = "mineroo-velocity", name = "Mineroo Velocity", version = "0.1.0-SNAPSHOT", url = "https://mineroo.online", description = "Mineroo main plugin", authors = { "YuKun Liu" }) -public class MinerooPlugin { +public class MinerooCore { // Reference to the Velocity ProxyServer instance private final ProxyServer server; @@ -54,7 +54,7 @@ public class MinerooPlugin { * @param dataDirectory Directory for plugin data */ @Inject - public MinerooPlugin(ProxyServer server, Logger logger, @DataDirectory Path dataDirectory) { + public MinerooCore(ProxyServer server, Logger logger, @DataDirectory Path dataDirectory) { this.server = server; this.logger = logger; this.dataDirectory = dataDirectory; @@ -70,7 +70,7 @@ public class MinerooPlugin { reloadConfig(); // Initialize message manager - this.messageManager = new MessageManager(config); + this.messageManager = new MessageManager(); // Register main command CommandManager commandManager = server.getCommandManager(); diff --git a/velocity/src/main/java/online/mineroo/velocity/commands/MainCommand.java b/velocity/src/main/java/online/mineroo/velocity/commands/MainCommand.java index 3c1ea6b..7379db4 100644 --- a/velocity/src/main/java/online/mineroo/velocity/commands/MainCommand.java +++ b/velocity/src/main/java/online/mineroo/velocity/commands/MainCommand.java @@ -11,16 +11,16 @@ import com.velocitypowered.api.command.SimpleCommand; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; +import online.mineroo.common.MessageManager; import online.mineroo.velocity.Config; -import online.mineroo.velocity.MinerooPlugin; +import online.mineroo.velocity.MinerooCore; import online.mineroo.velocity.utils.BindRequest; -import online.mineroo.velocity.utils.MessageManager; public class MainCommand implements SimpleCommand { - private final MinerooPlugin plugin; + private final MinerooCore plugin; - public MainCommand(MinerooPlugin plugin) { + public MainCommand(MinerooCore plugin) { this.plugin = plugin; } @@ -86,9 +86,9 @@ public class MainCommand implements SimpleCommand { String bind_name = config.getServerName(); String bind_description = config.getDescription(); - String bind_token = config.getServer().getBindToken(); - String bind_address = config.getServer().getAddress(); - Integer bind_port = config.getServer().getPort(); + String bind_token = config.getBind().getBindToken(); + String bind_address = config.getBind().getAddress(); + Integer bind_port = config.getBind().getPort(); source.sendMessage(msg.get("command.bind.server.start")); diff --git a/velocity/src/main/resources/mineroo/messages.properties b/velocity/src/main/resources/i18n/messages.properties similarity index 100% rename from velocity/src/main/resources/mineroo/messages.properties rename to velocity/src/main/resources/i18n/messages.properties