Yamler 是一款轻量级的 Java 对象与 YAML 配置文件绑定的 API。它类似于 BungeeYAML,但不依赖于 Bukkit 的配置 API,并精简了部分功能。该 API 同样适用于 Bukkit/Spigot 环境。
net.cubespace.Yamler.Config.Config。public 或 private,但不能是 final、transient 或 static。CONFIG_FILE 和 CONFIG_HEADER(CONFIG_HEADER 是可选的)。Config.init() 来加载配置。@Getter
@Setter
public class Database extends Config {
public Database(Plugin plugin) {
CONFIG_HEADER = new String[] { "Configuration of the Database" };
CONFIG_FILE = new File(plugin.getDataFolder(), "db.yml");
}
@Comments({
"This is the URL of the Database",
"Must be jdbc:<database engine>:<connection parameter>",
"For H2 (which is the default file based DB): jdbc:h2:{DIR}thesuit.db",
"For MySQL: jdbc:mysql://<host>:<port>/<database>"
})
private String Url = "jdbc:h2:{DIR}thesuit.db";
@Comment("The Username which should be used to auth against the Database")
private String Username = "test";
@Comment("The Password for the User")
private String Password = "test";
}Database dbConfig = null;
try {
dbConfig = new Database(this);
dbConfig.init();
} catch (InvalidConfigurationException ex) {
System.out.println("Your Config YML was wrong");
ex.printStackTrace();
}try {
dbConfig.save();
} catch (InvalidConfigurationException ex) {
System.out.println("Error in saving the Config YML");
ex.printStackTrace();
}如果您喜欢我的工作并想请我吃块饼干,欢迎通过捐赠支持。
友情链接: 网易我的世界 | 泰拉瑞亚 | ocent云计算 | 米饭Minecraft插件文档 | 友链合作
历史访问人次:3,030,579 | 今日访问人次:14,707 | 昨日访问人次:11,147
独立 IP:5,104 | 最近24小时独立访客:6,709
Copyright © 2019-2026 我的世界服务器列表站. All rights reserved.
❤ Powered by GermMC 京ICP备17023959号-6