mirror of
https://e.coding.net/circlecloud/CityBuild.git
synced 2024-11-24 11:18:49 +00:00
rebuild priject...
Signed-off-by: j502647092 <jtb1@163.com>
This commit is contained in:
parent
f89d2d4f43
commit
56063ff2c2
@ -10,43 +10,47 @@ import cn.citycraft.CityBuild.config.Config;
|
|||||||
import cn.citycraft.CityBuild.listen.Build;
|
import cn.citycraft.CityBuild.listen.Build;
|
||||||
|
|
||||||
public class CityBuild extends JavaPlugin implements CommandExecutor {
|
public class CityBuild extends JavaPlugin implements CommandExecutor {
|
||||||
public String servername;
|
public String servername;
|
||||||
public String pluginname;
|
public String pluginname;
|
||||||
public boolean tipplayer;
|
public boolean tipplayer;
|
||||||
|
|
||||||
public void onLoad() {
|
public String getfullmsg(String path) {
|
||||||
Config.load(this, "1.1");
|
return servername + pluginname + " " + getmessage(path);
|
||||||
servername = getmessage("servername");
|
}
|
||||||
pluginname = getmessage("pluginname");
|
|
||||||
tipplayer = Config.getInstance().getBoolean("tipplayer");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onEnable() {
|
public String getmessage(String path) {
|
||||||
Bukkit.getPluginManager().registerEvents(new Build(this), this);
|
return Config.getMessage(path);
|
||||||
getLogger().info(pluginname + "城市世界建筑保护已加载!");
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String string,
|
@Override
|
||||||
String[] args) {
|
public boolean onCommand(CommandSender sender, Command cmd, String string,
|
||||||
if (args.length == 1) {
|
String[] args) {
|
||||||
if (args[0].equalsIgnoreCase("reload")) {
|
if (args.length == 1) {
|
||||||
onLoad();
|
if (args[0].equalsIgnoreCase("reload")) {
|
||||||
sender.sendMessage(pluginname + getmessage("Message.Reload"));
|
onLoad();
|
||||||
return true;
|
sender.sendMessage(pluginname + getmessage("Message.Reload"));
|
||||||
}
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public void onDisable() {
|
@Override
|
||||||
getLogger().info(pluginname + "城市世界建筑保护已卸载!");
|
public void onDisable() {
|
||||||
}
|
getLogger().info(pluginname + "城市世界建筑保护已卸载!");
|
||||||
|
}
|
||||||
|
|
||||||
public String getfullmsg(String path) {
|
@Override
|
||||||
return servername + pluginname + " " + getmessage(path);
|
public void onEnable() {
|
||||||
}
|
Bukkit.getPluginManager().registerEvents(new Build(this), this);
|
||||||
|
getLogger().info(pluginname + "城市世界建筑保护已加载!");
|
||||||
|
}
|
||||||
|
|
||||||
public String getmessage(String path) {
|
@Override
|
||||||
return Config.getMessage(path);
|
public void onLoad() {
|
||||||
}
|
Config.load(this, "1.1");
|
||||||
|
servername = getmessage("servername");
|
||||||
|
pluginname = getmessage("pluginname");
|
||||||
|
tipplayer = Config.getInstance().getBoolean("tipplayer");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,59 +30,63 @@ import com.google.common.io.Files;
|
|||||||
*/
|
*/
|
||||||
public class FileConfig extends YamlConfiguration {
|
public class FileConfig extends YamlConfiguration {
|
||||||
|
|
||||||
protected final DumperOptions yamlOptions = new DumperOptions();
|
public static FileConfig init(File file) {
|
||||||
protected final Representer yamlRepresenter = new YamlRepresenter();
|
return FileConfig.loadConfiguration(file);
|
||||||
protected final Yaml yaml = new Yaml(new YamlConstructor(),
|
}
|
||||||
yamlRepresenter, yamlOptions);
|
|
||||||
|
|
||||||
public static FileConfig init(File file) {
|
public static FileConfig loadConfiguration(File file) {
|
||||||
return FileConfig.loadConfiguration(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) {
|
protected final DumperOptions yamlOptions = new DumperOptions();
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
protected final Representer yamlRepresenter = new YamlRepresenter();
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void load(File file) throws FileNotFoundException, IOException,
|
protected final Yaml yaml = new Yaml(new YamlConstructor(),
|
||||||
InvalidConfigurationException {
|
yamlRepresenter, yamlOptions);
|
||||||
Validate.notNull(file, "File cannot be null");
|
|
||||||
final FileInputStream stream = new FileInputStream(file);
|
|
||||||
load(new InputStreamReader(stream, Charsets.UTF_8));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void save(File file) throws IOException {
|
@Override
|
||||||
Validate.notNull(file, "File cannot be null");
|
public void load(File file) throws FileNotFoundException, IOException,
|
||||||
Files.createParentDirs(file);
|
InvalidConfigurationException {
|
||||||
String data = saveToString();
|
Validate.notNull(file, "File cannot be null");
|
||||||
Writer writer = new OutputStreamWriter(new FileOutputStream(file),
|
final FileInputStream stream = new FileInputStream(file);
|
||||||
Charsets.UTF_8);
|
load(new InputStreamReader(stream, Charsets.UTF_8));
|
||||||
try {
|
}
|
||||||
writer.write(data);
|
|
||||||
} finally {
|
@Override
|
||||||
writer.close();
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user