1
0
mirror of https://github.com/Zrips/Jobs.git synced 2025-03-09 21:29:23 +01:00

Fixed IllegalArgumentException while creating a file, #293

- Some clean up code
This commit is contained in:
montlikadani 2018-11-13 17:40:52 +01:00
parent ee4c7ef10d
commit 855cea13ef
4 changed files with 13 additions and 42 deletions

View File

@ -22,7 +22,6 @@ import com.gamingmesh.jobs.container.Job;
import com.gamingmesh.jobs.container.JobInfo;
import com.gamingmesh.jobs.container.JobProgression;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.stuff.Debug;
public class GuiManager {
@ -76,7 +75,7 @@ public class GuiManager {
if (title.length() > 32)
title = title.substring(0, 30) + "..";
// Resizing GUI in case we have more jobs then we could fit in current settup
// Resizing GUI in case we have more jobs then we could fit in current setup
GuiSize = GuiSize - 18 - ((Jobs.getGCManager().getJobsGUIRows() - 2) * 2) < JobsList.size() ? 2 * 9 + ((JobsList.size() % 9) * 9) : GuiSize;
// Lets avoid oversized GUI
@ -98,7 +97,7 @@ public class GuiManager {
// Only add skip if we can fit all of them in max sized Gui
if (JobsList.size() <= 42){
pos += Jobs.getGCManager().getJobsGUISkipAmount();
}
}

View File

@ -26,7 +26,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Entity;
@ -38,7 +37,6 @@ import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.CMILib.ItemManager.CMIMaterial;
import com.gamingmesh.jobs.resources.jfep.Parser;
import com.gamingmesh.jobs.stuff.ChatColor;
import com.gamingmesh.jobs.stuff.Debug;
import com.gamingmesh.jobs.container.CurrencyLimit;
import com.gamingmesh.jobs.container.CurrencyType;
import com.gamingmesh.jobs.container.LocaleReader;

View File

@ -93,38 +93,18 @@ public class LanguageManager {
languages.clear();
languages.add("en");
YmlMaker langFile = null;
if (ls == null || ls.equals("")) {
langFile = new YmlMaker(plugin, "locale" + File.separator + "messages_en.yml");
langFile.saveDefaultConfig();
} else {
langFile = new YmlMaker(plugin, "locale" + File.separator + "messages_" + ls + ".yml");
langFile.saveDefaultConfig();
File customLocaleFile = new File(plugin.getDataFolder(), "locale" + File.separator + "messages_" + ls + ".yml");
if (!customLocaleFile.exists() && !ls.equalsIgnoreCase("en"))
languages.add(ls);
}
File customLocaleFile = new File(plugin.getDataFolder(), "locale" + File.separator + "messages_" + ls + ".yml");
if (!customLocaleFile.exists() && !ls.equalsIgnoreCase("en"))
languages.add(ls);
for (String lang : languages) {
File f = null;
if (ls == null || ls.equals("")) {
f = new File(plugin.getDataFolder(), "locale" + File.separator + "messages_en.yml");
File f = new File(plugin.getDataFolder(), "locale" + File.separator + "messages_" + lang + ".yml");
// Fail safe if file get corrupted and being created with corrupted data, we need to re-create it
if ((f.length() / 1024) > 1024) {
f.delete();
f = new File(plugin.getDataFolder(), "locale" + File.separator + "messages_en.yml");
}
} else {
f = new File(plugin.getDataFolder(), "locale" + File.separator + "messages_" + lang + ".yml");
// Fail safe if file get corrupted and being created with corrupted data, we need to re-create it
if ((f.length() / 1024) > 1024) {
f.delete();
f = new File(plugin.getDataFolder(), "locale" + File.separator + "messages_" + lang + ".yml");
}
}
// Fail safe if file get corrupted and being created with corrupted data, we need to recreate it
if ((f.length() / 1024) > 1024) {
f.delete();
f = new File(plugin.getDataFolder(), "locale" + File.separator + "messages_" + lang + ".yml");
}
YamlConfiguration config = YamlConfiguration.loadConfiguration(f);
CommentedYamlConfiguration writer = new CommentedYamlConfiguration();

View File

@ -236,20 +236,14 @@ public class NameTranslatorManager {
// Just copying default language files, except en, that one will be generated
List<String> languages = new ArrayList<>();
languages.clear();
try {
languages.addAll(LanguageManager.getClassesFromPackage("TranslatableWords", "Words_"));
} catch (ClassNotFoundException e1) {
e1.printStackTrace();
}
for (String lang : languages) {
YmlMaker langFile = new YmlMaker(plugin, "TranslatableWords" + File.separator + "Words_" + lang + ".yml");
langFile.saveDefaultConfig();
}
languages.addAll(Jobs.getLanguageManager().getLanguages());
languages.clear();
languages.add("en");
File customLocaleFile = new File(plugin.getDataFolder(), "TranslatableWords" + File.separator + "Words_" + ls + ".yml");
if (!customLocaleFile.exists() && !ls.equalsIgnoreCase("en"))