我想为每个班级/工作做延迟/倒计时。我创建了一个配置并更改了一些内容,每个服务器重新加载/重新启动都会将其重置为默认值。
onEnable():
public void onEnable() {
PluginManager pm = this.getServer().getPluginManager();
pm.addPermission(new Permission("kit." + getConfig().getString("Kits.Names")));
try {
saveConfig();
setupConfig(getConfig());
saveConfig();
} catch (Exception e) {
e.printStackTrace();
}
}
setupConfig():
private void setupConfig(FileConfiguration config) throws IOException {
config.set("Kits.Miner.Items", "274 1, 50 64");
config.set("Kits.Woodcutter.Items", "275 1, 58 1, 4 32");
config.set("Kits.Names", "Miner, Woodcutter");
config.set("Kits.Miner.Delay", 5000);
config.set("Kits.Woodcutter.Delay", 5000);
config.set("np", "You must be a player to execute that command!");
config.set("kg", "You get the");
config.set("ctgtk", "You can't get that kit yet!");
config.set("ugtk", "You got the kit");
config.set("cgtk", "You can get the kit now!");
config.set("udthp", "You don't have permission for this command!");
}
config.yml:
Kits:
Names: Miner, Woodcutter
Miner:
Items: 274 1, 50 64
Delay: 5000
Woodcutter:
Items: 275 1, 58 1, 4 32
Delay: 5000
np: You must be a player to execute that command!
kg: You get the
ctgtk: You can't get that kit yet!
ugtk: You got the kit
cgtk: You can get the kit now!
udthp: You don't have permission for this command!
答案 0 :(得分:0)
我要指出这里发生的重大事情:
Employee &
这是所有相关信息,只是为了澄清,您需要获取配置,将值设置为默认值然后保存。 在保存默认值之前,请尝试检查配置文件是否不存在。