1
0
mirror of https://e.coding.net/circlecloud/ResFly.git synced 2024-11-21 10:48:48 +00:00

rebuild priject...

Signed-off-by: j502647092 <jtb1@163.com>
This commit is contained in:
j502647092 2015-05-28 20:58:37 +08:00
parent e0604098ae
commit 00470cb3b4
2 changed files with 80 additions and 76 deletions

View File

@ -15,12 +15,15 @@ public class ResFly extends JavaPlugin {
public String servername; public String servername;
public String pluginname; public String pluginname;
public void onLoad() { public String getfullmsg(String path) {
Config.load(this); return servername + pluginname + " " + getmessage(path);
servername = getmessage("servername");
pluginname = getmessage("pluginname");
} }
public String getmessage(String path) {
return Config.getMessage(path);
}
@Override
public void onEnable() { public void onEnable() {
PluginManager pm = this.getServer().getPluginManager(); PluginManager pm = this.getServer().getPluginManager();
Plugin res = pm.getPlugin("Residence"); Plugin res = pm.getPlugin("Residence");
@ -29,7 +32,7 @@ public class ResFly extends JavaPlugin {
FlagPermissions.addFlag("fly"); FlagPermissions.addFlag("fly");
FlagPermissions.addResidenceOnlyFlag("fly"); FlagPermissions.addResidenceOnlyFlag("fly");
Bukkit.getPluginManager() Bukkit.getPluginManager()
.registerEvents(new PlayerListen(this), this); .registerEvents(new PlayerListen(this), this);
getLogger().info("玩家领地飞行控制已加载!"); getLogger().info("玩家领地飞行控制已加载!");
} else { } else {
getLogger().info("未找到领地插件停止加载领地飞行!"); getLogger().info("未找到领地插件停止加载领地飞行!");
@ -39,12 +42,11 @@ public class ResFly extends JavaPlugin {
} }
} }
public String getfullmsg(String path) { @Override
return servername + pluginname + " " + getmessage(path); public void onLoad() {
} Config.load(this);
servername = getmessage("servername");
public String getmessage(String path) { pluginname = getmessage("pluginname");
return Config.getMessage(path);
} }
} }

View File

@ -30,15 +30,9 @@ import com.google.common.io.Files;
*/ */
public class FileConfig extends YamlConfiguration { 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) { public static FileConfig init(File file) {
return FileConfig.loadConfiguration(file); return FileConfig.loadConfiguration(file);
} }
public static FileConfig loadConfiguration(File file) { public static FileConfig loadConfiguration(File file) {
Validate.notNull(file, "File cannot be null"); Validate.notNull(file, "File cannot be null");
FileConfig config = new FileConfig(); FileConfig config = new FileConfig();
@ -52,6 +46,34 @@ public class FileConfig extends YamlConfiguration {
} }
return config; return config;
} }
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");
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 @Override
public String saveToString() { public String saveToString() {
@ -65,24 +87,4 @@ public class FileConfig extends YamlConfiguration {
} }
return header + dump; return header + dump;
} }
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));
}
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();
}
}
} }