add reload lang and fix some bug...

pull/1/MERGE
j502647092 2015-04-30 16:32:38 +08:00
parent 2777e7d9aa
commit 49eefa3b28
3 changed files with 18 additions and 5 deletions

View File

@ -45,12 +45,12 @@ public class Soulbound extends JavaPlugin {
public FileConfiguration msgConfig; public FileConfiguration msgConfig;
public void onLoad() { public void onLoad() {
this.saveResource("message.yml", false);
msgfile = new File(this.getDataFolder(), "message.yml"); msgfile = new File(this.getDataFolder(), "message.yml");
msgConfig = YamlConfiguration.loadConfiguration(msgfile);
try { try {
LoadConfig (msgConfig ,msgfile); LoadConfig (msgConfig ,msgfile);
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
this.saveResource("message.yml", false); this.saveResource("message.yml", true);
} catch (IOException e) { } catch (IOException e) {
this.getLogger().info("语言文件读取错误..."); this.getLogger().info("语言文件读取错误...");
} catch (InvalidConfigurationException e) { } catch (InvalidConfigurationException e) {
@ -164,6 +164,18 @@ public class Soulbound extends JavaPlugin {
return message; return message;
} }
public void reloadmessage(){
try {
LoadConfig (msgConfig ,msgfile);
} catch (FileNotFoundException e) {
this.saveResource("message.yml", true);
} catch (IOException e) {
this.getLogger().info("语言文件读取错误...");
} catch (InvalidConfigurationException e) {
this.saveResource("message.yml", true);
}
}
public String getlang(String type) { public String getlang(String type) {
return this.getmessage("Message." + type); return this.getmessage("Message." + type);
} }

View File

@ -1,6 +1,5 @@
package com.me.tft_02.soulbound.commands; package com.me.tft_02.soulbound.commands;
import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -42,7 +41,8 @@ public class SoulboundCommand implements CommandExecutor {
} }
Soulbound.p.reloadConfig(); Soulbound.p.reloadConfig();
sender.sendMessage(ChatColor.GREEN + "Configuration reloaded.");
sender.sendMessage(Soulbound.p.getlang("RELOAD"));
return false; return false;
} }

View File

@ -37,4 +37,5 @@ Message:
CMD_BIND_ON_USE: '&4* &a/bindonuse &7将当前物品标记为 &4使用后绑定' CMD_BIND_ON_USE: '&4* &a/bindonuse &7将当前物品标记为 &4使用后绑定'
CMD_UNBIND: '&4* &a/unbind &7解除手中物品的绑定。' CMD_UNBIND: '&4* &a/unbind &7解除手中物品的绑定。'
CMD_NEXT: '&6使用 /soulbound help %nextPage% 查看更多' CMD_NEXT: '&6使用 /soulbound help %nextPage% 查看更多'
CMD_USE: '使用: /soulbound [reload | help]' CMD_USE: '使用: /soulbound [reload | help]'
RELOAD: '&a配置文件已重载...'