use sync
This commit is contained in:
@@ -54,56 +54,50 @@ public class DragonManager {
|
|||||||
private static final Pattern pattern_attacker_top = Pattern.compile("%attacker_top_(\\d+)%");
|
private static final Pattern pattern_attacker_top = Pattern.compile("%attacker_top_(\\d+)%");
|
||||||
|
|
||||||
public static void reload(){
|
public static void reload(){
|
||||||
new BukkitRunnable(){
|
dragons.clear();
|
||||||
@Override
|
mp.clear();
|
||||||
public void run(){
|
dragon_names.clear();
|
||||||
dragons.clear();
|
sum = 0;
|
||||||
mp.clear();
|
if(Config.dragon_setting_file == null){
|
||||||
dragon_names.clear();
|
Lang.error("\"dragon_setting_file\" in config.yml is empty!");
|
||||||
sum = 0;
|
Lang.warn("Plugin will use the default config...");
|
||||||
if(Config.dragon_setting_file == null){
|
Config.dragon_setting_file = new ArrayList<>();
|
||||||
Lang.error("\"dragon_setting_file\" in config.yml is empty!");
|
Config.dragon_setting_file.add("default:5");
|
||||||
Lang.warn("Plugin will use the default config...");
|
Config.dragon_setting_file.add("special:5");
|
||||||
Config.dragon_setting_file = new ArrayList<>();
|
}
|
||||||
Config.dragon_setting_file.add("default:5");
|
for(String str : Config.dragon_setting_file){
|
||||||
Config.dragon_setting_file.add("special:5");
|
String[] s = str.split(":");
|
||||||
}
|
if(s.length != 2){
|
||||||
for(String str : Config.dragon_setting_file){
|
Lang.error("\"dragon_setting_file\" in config.yml error! Key: " + str);
|
||||||
String[] s = str.split(":");
|
continue;
|
||||||
if(s.length != 2){
|
|
||||||
Lang.error("\"dragon_setting_file\" in config.yml error! Key: " + str);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
String path = "setting/" + s[0] + ".yml";
|
|
||||||
int edge = -1;
|
|
||||||
try {
|
|
||||||
edge = Integer.parseInt(s[1]);
|
|
||||||
} catch (NumberFormatException ignored){}
|
|
||||||
if(edge < 0) {
|
|
||||||
Lang.error("\"dragon_setting_file\" in config.yml error! Key: " + str);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
File file = new File(plugin.getDataFolder(),path);
|
|
||||||
if(!file.exists()) {
|
|
||||||
try{
|
|
||||||
plugin.saveResource("setting/"+file.getName(),false);
|
|
||||||
file = new File(plugin.getDataFolder(),path);
|
|
||||||
}catch (Exception ignored){
|
|
||||||
Lang.error("Not Found setting/" + s[0] + ".yml ,skipped it.");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
FileConfiguration fc = YamlConfiguration.loadConfiguration(file);
|
|
||||||
if(!Version.setting_dragon.equals(fc.getString("version"))){
|
|
||||||
Lang.warn(Lang.plugin_wrong_file_version.replace("{file_name}", file.getName()));
|
|
||||||
}
|
|
||||||
readSettingFile(fc,edge);
|
|
||||||
}
|
|
||||||
dragons.sort((o1, o2) -> o2.priority - o1.priority);
|
|
||||||
RewardManager.reload();
|
|
||||||
}
|
}
|
||||||
}.runTaskAsynchronously(plugin);
|
String path = "setting/" + s[0] + ".yml";
|
||||||
|
int edge = -1;
|
||||||
|
try {
|
||||||
|
edge = Integer.parseInt(s[1]);
|
||||||
|
} catch (NumberFormatException ignored){}
|
||||||
|
if(edge < 0) {
|
||||||
|
Lang.error("\"dragon_setting_file\" in config.yml error! Key: " + str);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
File file = new File(plugin.getDataFolder(),path);
|
||||||
|
if(!file.exists()) {
|
||||||
|
try{
|
||||||
|
plugin.saveResource("setting/"+file.getName(),false);
|
||||||
|
file = new File(plugin.getDataFolder(),path);
|
||||||
|
}catch (Exception ignored){
|
||||||
|
Lang.error("Not Found setting/" + s[0] + ".yml ,skipped it.");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FileConfiguration fc = YamlConfiguration.loadConfiguration(file);
|
||||||
|
if(!Version.setting_dragon.equals(fc.getString("version"))){
|
||||||
|
Lang.warn(Lang.plugin_wrong_file_version.replace("{file_name}", file.getName()));
|
||||||
|
}
|
||||||
|
readSettingFile(fc,edge);
|
||||||
|
}
|
||||||
|
dragons.sort((o1, o2) -> o2.priority - o1.priority);
|
||||||
|
RewardManager.reload();
|
||||||
}
|
}
|
||||||
public static MyDragon judge(){
|
public static MyDragon judge(){
|
||||||
if(Config.special_dragon_jude_mode.equalsIgnoreCase("weight")){
|
if(Config.special_dragon_jude_mode.equalsIgnoreCase("weight")){
|
||||||
|
|||||||
@@ -17,27 +17,22 @@ import static pers.xanadu.enderdragon.EnderDragon.plugin;
|
|||||||
public class GuiManager {
|
public class GuiManager {
|
||||||
private static HashMap<String, GUIWrapper> f = new HashMap<>();
|
private static HashMap<String, GUIWrapper> f = new HashMap<>();
|
||||||
public static void loadGui(){
|
public static void loadGui(){
|
||||||
new BukkitRunnable(){
|
File folder = new File(plugin.getDataFolder(),"gui");
|
||||||
@Override
|
if(!folder.exists()) return;
|
||||||
public void run(){
|
File[] files = folder.listFiles();
|
||||||
File folder = new File(plugin.getDataFolder(),"gui");
|
if(files == null) return;
|
||||||
if(!folder.exists()) return;
|
for(File file : files){
|
||||||
File[] files = folder.listFiles();
|
if(!file.getName().endsWith(".yml")) continue;
|
||||||
if(files == null) return;
|
Lang.info(Lang.plugin_read_file + file.getName());
|
||||||
for(File file : files){
|
FileConfiguration fileConfiguration = YamlConfiguration.loadConfiguration(file);
|
||||||
if(!file.getName().endsWith(".yml")) continue;
|
Iterator it = fileConfiguration.getKeys(false).iterator();
|
||||||
Lang.info(Lang.plugin_read_file + file.getName());
|
while (it.hasNext()){
|
||||||
FileConfiguration fileConfiguration = YamlConfiguration.loadConfiguration(file);
|
String name = (String) it.next();
|
||||||
Iterator it = fileConfiguration.getKeys(false).iterator();
|
ConfigurationSection section = fileConfiguration.getConfigurationSection(name);
|
||||||
while (it.hasNext()){
|
GUIWrapper guiWrapper = new GUIWrapper(section);
|
||||||
String name = (String) it.next();
|
f.put(name, guiWrapper);
|
||||||
ConfigurationSection section = fileConfiguration.getConfigurationSection(name);
|
|
||||||
GUIWrapper guiWrapper = new GUIWrapper(section);
|
|
||||||
f.put(name, guiWrapper);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}.runTaskAsynchronously(plugin);
|
}
|
||||||
}
|
}
|
||||||
public static void disable(){
|
public static void disable(){
|
||||||
f.clear();
|
f.clear();
|
||||||
|
|||||||
Reference in New Issue
Block a user