1
0
mirror of https://e.coding.net/circlecloud/Residence.git synced 2024-10-31 22:38:48 +00:00

transport some language in console...

Signed-off-by: j502647092 <jtb1@163.com>
This commit is contained in:
j502647092 2015-05-30 22:18:40 +08:00
parent dfd79af897
commit bb10473fcc

View File

@ -17,7 +17,6 @@ import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.jar.JarEntry; import java.util.jar.JarEntry;
import java.util.jar.JarFile; import java.util.jar.JarFile;
import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -237,7 +236,7 @@ public class Residence extends JavaPlugin {
public void run() { public void run() {
rentmanager.checkCurrentRents(); rentmanager.checkCurrentRents();
if (cmanager.showIntervalMessages()) { if (cmanager.showIntervalMessages()) {
System.out.println("[Residence] - Rent Expirations checked!"); getLog().info(" - Rent Expirations checked!");
} }
} }
}; };
@ -247,7 +246,7 @@ public class Residence extends JavaPlugin {
public void run() { public void run() {
leasemanager.doExpirations(); leasemanager.doExpirations();
if (cmanager.showIntervalMessages()) { if (cmanager.showIntervalMessages()) {
System.out.println("[Residence] - Lease Expirations checked!"); getLog().info(" - Lease Expirations checked!");
} }
} }
}; };
@ -260,7 +259,7 @@ public class Residence extends JavaPlugin {
saveYml(); saveYml();
} }
} catch (Exception ex) { } catch (Exception ex) {
Logger.getLogger("Minecraft").log(Level.SEVERE, "[Residence] 插件数据 保存 错误", ex); getLog().warning("领地数据保存错误,可能造成部分领地丢失,请尝试恢复备份文件!");
} }
} }
}; };
@ -268,8 +267,7 @@ public class Residence extends JavaPlugin {
public Residence() { public Residence() {
} }
private boolean checkNewLanguageVersion(String lang) throws IOException, FileNotFoundException, private boolean checkNewLanguageVersion(String lang) throws IOException, FileNotFoundException, InvalidConfigurationException {
InvalidConfigurationException {
File outFile = new File(new File(this.getDataFolder(), "Language"), lang + ".yml"); File outFile = new File(new File(this.getDataFolder(), "Language"), lang + ".yml");
File checkFile = new File(new File(this.getDataFolder(), "Language"), "temp-" + lang File checkFile = new File(new File(this.getDataFolder(), "Language"), "temp-" + lang
+ ".yml"); + ".yml");
@ -309,26 +307,33 @@ public class Residence extends JavaPlugin {
Plugin p = getServer().getPluginManager().getPlugin("Essentials"); Plugin p = getServer().getPluginManager().getPlugin("Essentials");
if (p != null) { if (p != null) {
economy = new EssentialsEcoAdapter((Essentials) p); economy = new EssentialsEcoAdapter((Essentials) p);
Logger.getLogger("Minecraft").log(Level.INFO, "[Residence] 成功关联Essentials Economy!"); this.getLogger().info("成功关联Essentials Economy!");
} else { } else {
Logger.getLogger("Minecraft").log(Level.INFO, "[Residence] Essentials Economy 未找到!"); this.getLogger().info("Essentials Economy 未找到!");
} }
} }
public void loadLang(File langFile) throws FileNotFoundException, IOException, InvalidConfigurationException {
FileConfig langconfig = new FileConfig();
langconfig.load(langFile);
helppages = HelpEntry.parseHelp(langconfig, "CommandHelp");
HelpEntry.setLinesPerPage(langconfig.getInt("HelpLinesPerPage", 7));
InformationPager.setLinesPerPage(langconfig.getInt("HelpLinesPerPage", 7));
language = Language.parseText(langconfig, "Language");
}
private void loadVaultEconomy() { private void loadVaultEconomy() {
Plugin p = getServer().getPluginManager().getPlugin("Vault"); Plugin p = getServer().getPluginManager().getPlugin("Vault");
if (p != null) { if (p != null) {
ResidenceVaultAdapter vault = new ResidenceVaultAdapter(getServer()); ResidenceVaultAdapter vault = new ResidenceVaultAdapter(getServer());
if (vault.economyOK()) { if (vault.economyOK()) {
Logger.getLogger("Minecraft").log(Level.INFO, this.getLogger().info("发现 Vault 使用经济系统: " + vault.getEconomyName());
"[Residence] 发现 Vault 使用经济系统: " + vault.getEconomyName());
economy = vault; economy = vault;
} else { } else {
Logger.getLogger("Minecraft").log(Level.INFO, this.getLogger().info("发现 Vault, 但是 Vault 未找到经济系统...");
"[Residence] 发现 Vault, 但是 Vault 未找到经济系统...");
} }
} else { } else {
Logger.getLogger("Minecraft").log(Level.INFO, "[Residence] Vault 未找到!"); this.getLogger().info("Vault 未找到!");
} }
} }
@ -385,7 +390,8 @@ public class Residence extends JavaPlugin {
// System.out.print("[Residence] Loaded..."); // System.out.print("[Residence] Loaded...");
return true; return true;
} catch (Exception ex) { } catch (Exception ex) {
Logger.getLogger(Residence.class.getName()).log(Level.SEVERE, null, ex); this.getLogger().warning("领地数据载入时发生错误,请报告一下内容给作者: ");
this.getLogger().warning("错误: " + ex);
throw ex; throw ex;
} }
} }
@ -405,9 +411,9 @@ public class Residence extends JavaPlugin {
saveYml(); saveYml();
ZipLibrary.backup(); ZipLibrary.backup();
} catch (Exception ex) { } catch (Exception ex) {
Logger.getLogger("Minecraft").log(Level.SEVERE, "[Residence] 插件数据保存失败", ex); this.getLogger().warning("领地数据保存错误,可能造成部分领地丢失,请尝试恢复备份文件!");
this.getLogger().warning("错误: " + ex);
} }
Logger.getLogger("Minecraft").log(Level.INFO, "[Residence] Disabled!");
} }
} }
@ -439,7 +445,7 @@ public class Residence extends JavaPlugin {
Plugin plugin = server.getPluginManager().getPlugin(multiworld); Plugin plugin = server.getPluginManager().getPlugin(multiworld);
if (plugin != null) { if (plugin != null) {
if (!plugin.isEnabled()) { if (!plugin.isEnabled()) {
this.getLogger().warning(" - 加载多世界插件: " + multiworld); this.getLogger().info(" - 加载多世界插件: " + multiworld);
server.getPluginManager().enablePlugin(plugin); server.getPluginManager().enablePlugin(plugin);
} }
} }
@ -464,24 +470,14 @@ public class Residence extends JavaPlugin {
+ ".yml"); + ".yml");
try { try {
if (langFile.isFile()) { if (langFile.isFile()) {
FileConfig langconfig = new FileConfig(); loadLang(langFile);
langconfig.load(langFile);
helppages = HelpEntry.parseHelp(langconfig, "CommandHelp");
HelpEntry.setLinesPerPage(langconfig.getInt("HelpLinesPerPage", 7));
InformationPager.setLinesPerPage(langconfig.getInt("HelpLinesPerPage", 7));
language = Language.parseText(langconfig, "Language");
} else { } else {
this.getLogger().warning("语言文件不存在..."); this.getLogger().warning("语言文件不存在...");
} }
} catch (Exception ex) { } catch (Exception ex) {
this.getLogger().warning("语言文件载入失败: " + cmanager.getLanguage() + ".yml 写入默认语言文件"); this.getLogger().warning("语言文件载入失败: " + cmanager.getLanguage() + ".yml 写入默认语言文件");
this.writeDefaultLanguageFile(cmanager.getLanguage()); this.writeDefaultLanguageFile(cmanager.getLanguage());
FileConfig langconfig = new FileConfig(); loadLang(langFile);
langconfig.load(langFile);
helppages = HelpEntry.parseHelp(langconfig, "CommandHelp");
HelpEntry.setLinesPerPage(langconfig.getInt("HelpLinesPerPage", 7));
InformationPager.setLinesPerPage(langconfig.getInt("HelpLinesPerPage", 7));
language = Language.parseText(langconfig, "Language");
} }
economy = null; economy = null;
if (this.getConfig().getBoolean("Global.EnableEconomy", false)) { if (this.getConfig().getBoolean("Global.EnableEconomy", false)) {
@ -507,8 +503,8 @@ public class Residence extends JavaPlugin {
try { try {
this.loadYml(); this.loadYml();
} catch (Exception e) { } catch (Exception e) {
this.getLogger().log(Level.SEVERE, "不能载入保存的文件", e); this.getLogger().warning("领地数据载入错误,可能造成插件无法启动,请尝试恢复备份文件!");
throw e; this.getLogger().warning("错误: " + e);
} }
if (rmanager == null) { if (rmanager == null) {
rmanager = new ResidenceManager(); rmanager = new ResidenceManager();
@ -529,7 +525,7 @@ public class Residence extends JavaPlugin {
Plugin p = server.getPluginManager().getPlugin("WorldEdit"); Plugin p = server.getPluginManager().getPlugin("WorldEdit");
if (p != null) { if (p != null) {
smanager = new WorldEditSelectionManager(server); smanager = new WorldEditSelectionManager(server);
Logger.getLogger("Minecraft").log(Level.INFO, "[Residence] 发现 WorldEdit"); this.getLogger().info("发现 WorldEdit");
} else { } else {
smanager = new SelectionManager(server); smanager = new SelectionManager(server);
this.getLogger().warning("WorldEdit 未找到!"); this.getLogger().warning("WorldEdit 未找到!");
@ -578,14 +574,13 @@ public class Residence extends JavaPlugin {
turnResAdminOn(player); turnResAdminOn(player);
} }
} }
Logger.getLogger("Minecraft").log(Level.INFO, this.getLogger().info("载入完成! 版本: " + this.getDescription().getVersion() + " 重制 by 喵♂呜");
"[Residence] 载入完成! 版本: " + this.getDescription().getVersion() + " 重制 by 喵♂呜");
initsuccess = true; initsuccess = true;
} catch (Exception ex) { } catch (Exception ex) {
initsuccess = false; initsuccess = false;
getServer().getPluginManager().disablePlugin(this); getServer().getPluginManager().disablePlugin(this);
this.getLogger().warning(" - 初始化失败! 卸载插件! 错误:"); this.getLogger().warning(" - 初始化失败! 卸载插件! 请报告一下错误给作者,谢谢!");
Logger.getLogger(Residence.class.getName()).log(Level.SEVERE, null, ex); this.getLogger().warning("错误: " + ex);
} }
} }
@ -709,14 +704,14 @@ public class Residence extends JavaPlugin {
tmpFile.renameTo(ymlSaveLoc); tmpFile.renameTo(ymlSaveLoc);
if (cmanager.showIntervalMessages()) { if (cmanager.showIntervalMessages()) {
System.out.println("[Residence] - 保存插件数据..."); this.getLogger().info(" - 保存插件数据...");
} }
} }
private void writeDefaultConfigFromJar() { private void writeDefaultConfigFromJar() {
if (this.writeDefaultFileFromJar(new File(this.getDataFolder(), "config.yml"), if (this.writeDefaultFileFromJar(new File(this.getDataFolder(), "config.yml"),
"config.yml", true)) { "config.yml", true)) {
System.out.println("[Residence] 保存默认配置文件..."); this.getLogger().info("保存默认配置文件...");
} }
} }
@ -757,7 +752,7 @@ public class Residence extends JavaPlugin {
} }
return false; return false;
} catch (Exception ex) { } catch (Exception ex) {
System.out.println("[Residence] 文件写入失败: " + writeName); this.getLogger().warning("文件写入失败: " + writeName);
return false; return false;
} }
} }
@ -766,7 +761,7 @@ public class Residence extends JavaPlugin {
File outFile = new File(new File(this.getDataFolder(), "Language"), lang + ".yml"); File outFile = new File(new File(this.getDataFolder(), "Language"), lang + ".yml");
outFile.getParentFile().mkdirs(); outFile.getParentFile().mkdirs();
if (this.writeDefaultFileFromJar(outFile, "languagefiles/" + lang + ".yml", true)) { if (this.writeDefaultFileFromJar(outFile, "languagefiles/" + lang + ".yml", true)) {
System.out.println("[Residence] 保存默认 " + lang + " 语言文件..."); this.getLogger().info("保存默认 " + lang + " 语言文件...");
} }
} }
} }