Minecraft Bukkit 和 Delay/Countdown
Minecraft Bukkit and Delay/Countdown
我想为每个 class/job 做 delays/countdowns。我创建了一个配置并更改了其中的一些内容,每个服务器 reload/restart 将其重置为默认值。
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!
我要指出这里发生了什么重要的事情:
public void onEnable() {
try {
setupConfig(getConfig());
saveConfig();
} catch (Exception e) {
e.printStackTrace();
}
这是所有相关信息,为了澄清起见,您正在获取配置,将值设置为默认值,然后保存。
在保存默认值之前尝试检查配置文件是否不存在。
我想为每个 class/job 做 delays/countdowns。我创建了一个配置并更改了其中的一些内容,每个服务器 reload/restart 将其重置为默认值。
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!
我要指出这里发生了什么重要的事情:
public void onEnable() {
try {
setupConfig(getConfig());
saveConfig();
} catch (Exception e) {
e.printStackTrace();
}
这是所有相关信息,为了澄清起见,您正在获取配置,将值设置为默认值,然后保存。 在保存默认值之前尝试检查配置文件是否不存在。