From 56063ff2c21fffc42a88210b8c52413d2eb7c7ac Mon Sep 17 00:00:00 2001 From: j502647092 Date: Thu, 28 May 2015 20:57:49 +0800 Subject: [PATCH] rebuild priject... Signed-off-by: j502647092 --- src/cn/citycraft/CityBuild/CityBuild.java | 68 ++++++------ .../CityBuild/config/FileConfig.java | 100 +++++++++--------- 2 files changed, 88 insertions(+), 80 deletions(-) diff --git a/src/cn/citycraft/CityBuild/CityBuild.java b/src/cn/citycraft/CityBuild/CityBuild.java index 98a226c..8ead958 100644 --- a/src/cn/citycraft/CityBuild/CityBuild.java +++ b/src/cn/citycraft/CityBuild/CityBuild.java @@ -10,43 +10,47 @@ import cn.citycraft.CityBuild.config.Config; import cn.citycraft.CityBuild.listen.Build; public class CityBuild extends JavaPlugin implements CommandExecutor { - public String servername; - public String pluginname; - public boolean tipplayer; + public String servername; + public String pluginname; + public boolean tipplayer; - public void onLoad() { - Config.load(this, "1.1"); - servername = getmessage("servername"); - pluginname = getmessage("pluginname"); - tipplayer = Config.getInstance().getBoolean("tipplayer"); - } + public String getfullmsg(String path) { + return servername + pluginname + " " + getmessage(path); + } - public void onEnable() { - Bukkit.getPluginManager().registerEvents(new Build(this), this); - getLogger().info(pluginname + "城市世界建筑保护已加载!"); - } + public String getmessage(String path) { + return Config.getMessage(path); + } - public boolean onCommand(CommandSender sender, Command cmd, String string, - String[] args) { - if (args.length == 1) { - if (args[0].equalsIgnoreCase("reload")) { - onLoad(); - sender.sendMessage(pluginname + getmessage("Message.Reload")); - return true; - } - } - return false; + @Override + public boolean onCommand(CommandSender sender, Command cmd, String string, + String[] args) { + if (args.length == 1) { + if (args[0].equalsIgnoreCase("reload")) { + onLoad(); + sender.sendMessage(pluginname + getmessage("Message.Reload")); + return true; + } } + return false; + } - public void onDisable() { - getLogger().info(pluginname + "城市世界建筑保护已卸载!"); - } + @Override + public void onDisable() { + getLogger().info(pluginname + "城市世界建筑保护已卸载!"); + } - public String getfullmsg(String path) { - return servername + pluginname + " " + getmessage(path); - } + @Override + public void onEnable() { + Bukkit.getPluginManager().registerEvents(new Build(this), this); + getLogger().info(pluginname + "城市世界建筑保护已加载!"); + } - public String getmessage(String path) { - return Config.getMessage(path); - } + @Override + public void onLoad() { + Config.load(this, "1.1"); + servername = getmessage("servername"); + pluginname = getmessage("pluginname"); + tipplayer = Config.getInstance().getBoolean("tipplayer"); + } } diff --git a/src/cn/citycraft/CityBuild/config/FileConfig.java b/src/cn/citycraft/CityBuild/config/FileConfig.java index 4a878c1..dd6e038 100644 --- a/src/cn/citycraft/CityBuild/config/FileConfig.java +++ b/src/cn/citycraft/CityBuild/config/FileConfig.java @@ -30,59 +30,63 @@ import com.google.common.io.Files; */ public class FileConfig extends YamlConfiguration { - protected final DumperOptions yamlOptions = new DumperOptions(); - protected final Representer yamlRepresenter = new YamlRepresenter(); - protected final Yaml yaml = new Yaml(new YamlConstructor(), - yamlRepresenter, yamlOptions); + public static FileConfig init(File file) { + return FileConfig.loadConfiguration(file); + } - public static FileConfig init(File file) { - return FileConfig.loadConfiguration(file); + public static FileConfig loadConfiguration(File file) { + Validate.notNull(file, "File cannot be null"); + FileConfig config = new FileConfig(); + try { + config.load(file); + } catch (FileNotFoundException ex) { + } catch (IOException ex) { + Bukkit.getLogger().log(Level.SEVERE, "Cannot load " + file, ex); + } catch (InvalidConfigurationException ex) { + Bukkit.getLogger().log(Level.SEVERE, "Cannot load " + file, ex); } + return config; + } - public static FileConfig loadConfiguration(File file) { - Validate.notNull(file, "File cannot be null"); - FileConfig config = new FileConfig(); - try { - config.load(file); - } catch (FileNotFoundException ex) { - } catch (IOException ex) { - Bukkit.getLogger().log(Level.SEVERE, "Cannot load " + file, ex); - } catch (InvalidConfigurationException ex) { - Bukkit.getLogger().log(Level.SEVERE, "Cannot load " + file, ex); - } - return config; - } + protected final DumperOptions yamlOptions = new DumperOptions(); - @Override - public String saveToString() { - yamlOptions.setIndent(options().indent()); - yamlOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); - yamlRepresenter.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); - String header = buildHeader(); - String dump = yaml.dump(getValues(false)); - if (dump.equals(BLANK_CONFIG)) { - dump = ""; - } - return header + dump; - } + protected final Representer yamlRepresenter = new YamlRepresenter(); - public void load(File file) throws FileNotFoundException, IOException, - InvalidConfigurationException { - Validate.notNull(file, "File cannot be null"); - final FileInputStream stream = new FileInputStream(file); - load(new InputStreamReader(stream, Charsets.UTF_8)); - } + protected final Yaml yaml = new Yaml(new YamlConstructor(), + yamlRepresenter, yamlOptions); - public void save(File file) throws IOException { - Validate.notNull(file, "File cannot be null"); - Files.createParentDirs(file); - String data = saveToString(); - Writer writer = new OutputStreamWriter(new FileOutputStream(file), - Charsets.UTF_8); - try { - writer.write(data); - } finally { - writer.close(); - } + @Override + public void load(File file) throws FileNotFoundException, IOException, + InvalidConfigurationException { + Validate.notNull(file, "File cannot be null"); + final FileInputStream stream = new FileInputStream(file); + load(new InputStreamReader(stream, Charsets.UTF_8)); + } + + @Override + public void save(File file) throws IOException { + Validate.notNull(file, "File cannot be null"); + Files.createParentDirs(file); + String data = saveToString(); + Writer writer = new OutputStreamWriter(new FileOutputStream(file), + Charsets.UTF_8); + try { + writer.write(data); + } finally { + writer.close(); } + } + + @Override + public String saveToString() { + yamlOptions.setIndent(options().indent()); + yamlOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); + yamlRepresenter.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); + String header = buildHeader(); + String dump = yaml.dump(getValues(false)); + if (dump.equals(BLANK_CONFIG)) { + dump = ""; + } + return header + dump; + } }