mirror of
https://e.coding.net/circlecloud/CityBuild.git
synced 2025-11-24 21:46:25 +00:00
@@ -14,18 +14,15 @@ public class CityBuild extends JavaPlugin implements CommandExecutor {
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String string,
|
||||
String[] args) {
|
||||
if (args.length == 1) {
|
||||
@@ -38,15 +35,22 @@ public class CityBuild extends JavaPlugin implements CommandExecutor {
|
||||
return false;
|
||||
}
|
||||
|
||||
@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");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,11 +30,6 @@ 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);
|
||||
}
|
||||
@@ -53,19 +48,14 @@ public class FileConfig extends YamlConfiguration {
|
||||
return config;
|
||||
}
|
||||
|
||||
@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 DumperOptions yamlOptions = new DumperOptions();
|
||||
|
||||
protected final Representer yamlRepresenter = new YamlRepresenter();
|
||||
|
||||
protected final Yaml yaml = new Yaml(new YamlConstructor(),
|
||||
yamlRepresenter, yamlOptions);
|
||||
|
||||
@Override
|
||||
public void load(File file) throws FileNotFoundException, IOException,
|
||||
InvalidConfigurationException {
|
||||
Validate.notNull(file, "File cannot be null");
|
||||
@@ -73,6 +63,7 @@ public class FileConfig extends YamlConfiguration {
|
||||
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);
|
||||
@@ -85,4 +76,17 @@ public class FileConfig extends YamlConfiguration {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user