1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-29 22:13:25 +01:00

Fixed some Exception issues

- Fixed IllegalArgumentException when generating TranslatableWords files
- Fixed NPE when the quest section not found
- Fixing version check (from 70bc47773e)
This commit is contained in:
montlikadani 2020-01-22 18:59:02 +01:00
parent 1e2a2473b0
commit 12b262b6b4
3 changed files with 13 additions and 12 deletions

View File

@ -2,8 +2,8 @@ package com.gamingmesh.jobs.CMILib;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.util.Arrays;
import java.util.List;
@ -150,7 +150,6 @@ public class VersionChecker {
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
String currentVersion = plugin.getDescription().getVersion();
String newVersion = getNewVersion();
if (newVersion == null || newVersion.equalsIgnoreCase(currentVersion))
return;
@ -169,12 +168,9 @@ public class VersionChecker {
public String getNewVersion() {
try {
HttpURLConnection con = (HttpURLConnection) new URL("https://www.spigotmc.org/api/general.php").openConnection();
con.setDoOutput(true);
con.setRequestMethod("POST");
con.getOutputStream().write(("key=98BE0FE67F88AB82B4C197FAF1DC3B69206EFDCC4D3B80FC83A00037510B99B4&resource=" + resource).getBytes("UTF-8"));
URLConnection con = new URL("https://api.spigotmc.org/legacy/update.php?resource=" + resource).openConnection();
String version = new BufferedReader(new InputStreamReader(con.getInputStream())).readLine();
if (version.length() <= 7)
if (version.length() <= 8)
return version;
} catch (Throwable t) {
Jobs.consoleMsg("&cFailed to check for " + plugin.getDescription().getName() + " update on spigot web page.");

View File

@ -1017,8 +1017,10 @@ public class ConfigManager {
for (String one : qsection.getKeys(false)) {
try {
ConfigurationSection sqsection = qsection.getConfigurationSection(one);
if (sqsection == null) {
continue;
}
String name = sqsection.getString("Name", one);
Quest quest = new Quest(name, job);

View File

@ -112,9 +112,11 @@ public class NameTranslatorManager {
}
public void readFile() {
YmlMaker ItemFile = new YmlMaker(Jobs.getInstance(), "TranslatableWords" + File.separator + "Words_" + Jobs.getGCManager().localeString + ".yml");
ItemFile.saveDefaultConfig();
YmlMaker ItemFile = new YmlMaker(Jobs.getInstance(), "TranslatableWords" + File.separator + "Words_"
+ Jobs.getGCManager().localeString + ".yml");
if (!ItemFile.getConfigFile().getName().equalsIgnoreCase("en")) {
ItemFile.saveDefaultConfig();
}
if (ItemFile.getConfig().isConfigurationSection("ItemList")) {
ConfigurationSection section = ItemFile.getConfig().getConfigurationSection("ItemList");
@ -193,7 +195,8 @@ public class NameTranslatorManager {
Jobs.consoleMsg("&c[Jobs] The ColorList section not found in " + ItemFile.fileName + " file.");
}
synchronized void load() {
@SuppressWarnings("deprecation")
synchronized void load() {
String ls = Jobs.getGCManager().localeString;
if (ls.isEmpty())
return;